|
|
@@ -12,7 +12,7 @@
|
|
|
#include "danmaku/bullet.hpp"
|
|
|
#include "danmaku/bullet_pattern.hpp"
|
|
|
#include "danmaku/level.hpp"
|
|
|
-#include "game/engine/entity.hpp"
|
|
|
+#include "game/engine/serial.hpp"
|
|
|
#include "game/math/angle.hpp"
|
|
|
#include "game/math/common.hpp"
|
|
|
#include "game/math/math_fwd.hpp"
|
|
|
@@ -28,7 +28,7 @@ struct burstshot : public danmaku::bullet_pattern {
|
|
|
create(danmaku::actor *, Json::Value const &, graphics::manager &);
|
|
|
|
|
|
burstshot(danmaku::actor *, float shot_interval, std::vector<shot> shots,
|
|
|
- bullet bullet, engine::entity ent);
|
|
|
+ bullet bullet);
|
|
|
void update(float delta) override;
|
|
|
|
|
|
danmaku::actor * actor;
|
|
|
@@ -37,7 +37,6 @@ struct burstshot : public danmaku::bullet_pattern {
|
|
|
std::size_t idx{0};
|
|
|
std::vector<shot> shots;
|
|
|
bullet bullet_proto;
|
|
|
- engine::entity entity_proto;
|
|
|
};
|
|
|
|
|
|
std::vector<shot> shot_vector(std::size_t count, float facing, float covered,
|
|
|
@@ -61,9 +60,13 @@ std::vector<shot> shot_vector(std::size_t count, float facing, float covered,
|
|
|
}
|
|
|
|
|
|
burstshot::burstshot(danmaku::actor * actor, float shot_interval,
|
|
|
- std::vector<shot> shots, bullet blt, engine::entity ent)
|
|
|
- : actor(actor), shot_timer{shot_interval}, shots(shots), bullet_proto(blt),
|
|
|
- entity_proto(ent) {}
|
|
|
+ std::vector<shot> shots, bullet blt)
|
|
|
+ : actor(actor), shot_timer{shot_interval}, shots(shots), bullet_proto(blt) {
|
|
|
+}
|
|
|
+
|
|
|
+bullet make_bullet(Json::Value const & json, graphics::manager & manager) {
|
|
|
+ return bullet(json["damage"].asInt(), {}, engine::to_object(json, manager));
|
|
|
+}
|
|
|
|
|
|
std::shared_ptr<burstshot> burstshot::create(danmaku::actor * actor,
|
|
|
Json::Value const & json,
|
|
|
@@ -73,8 +76,7 @@ std::shared_ptr<burstshot> burstshot::create(danmaku::actor * actor,
|
|
|
shot_vector(json["bulletsPerWave"].asUInt(),
|
|
|
json["centerAngle"].asFloat(), json["burstAngle"].asFloat(),
|
|
|
json["bulletSpeed"].asFloat(), json["clockwise"].asBool()),
|
|
|
- json["prototype"]["damage"].asInt(),
|
|
|
- engine::entity(json["prototype"], manager));
|
|
|
+ make_bullet(json["prototype"], manager));
|
|
|
}
|
|
|
|
|
|
void burstshot::update(float delta) {
|
|
|
@@ -82,8 +84,12 @@ void burstshot::update(float delta) {
|
|
|
shot_timer.remaining = shot_timer.interval;
|
|
|
std::size_t shots_fired = std::size_t(delta / shots.size());
|
|
|
while (shots_fired-- > 0) {
|
|
|
- actor->level()->add_bullet(bullet_proto, entity_proto);
|
|
|
- if (idx == shots.size()) { idx = 0; }
|
|
|
+ bullet new_bullet{bullet_proto};
|
|
|
+ new_bullet.set_velocity(shots[idx].first);
|
|
|
+ new_bullet.set_position(actor->render_info().location.origin,
|
|
|
+ math::degree(shots[idx].second));
|
|
|
+ actor->level()->add_bullet(std::move(bullet_proto));
|
|
|
+ if (++idx == shots.size()) { idx = 0; }
|
|
|
}
|
|
|
}
|
|
|
}
|