|
|
@@ -11,8 +11,8 @@
|
|
|
|
|
|
#include "danmaku/bullet.hpp"
|
|
|
#include "danmaku/bullet_pattern.hpp"
|
|
|
-#include "game/engine/serial.hpp"
|
|
|
-#include "game/graphics/object.hpp"
|
|
|
+#include "danmaku/level.hpp"
|
|
|
+#include "game/engine/entity.hpp"
|
|
|
#include "game/math/angle.hpp"
|
|
|
#include "game/math/common.hpp"
|
|
|
#include "game/math/math_fwd.hpp"
|
|
|
@@ -28,15 +28,16 @@ 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, graphics::object object);
|
|
|
+ bullet bullet, engine::entity ent);
|
|
|
void update(float delta) override;
|
|
|
|
|
|
danmaku::actor * actor;
|
|
|
danmaku::bullet_timer shot_timer;
|
|
|
float last_fired{std::numeric_limits<float>::lowest()};
|
|
|
+ std::size_t idx{0};
|
|
|
std::vector<shot> shots;
|
|
|
bullet bullet_proto;
|
|
|
- graphics::object object_proto;
|
|
|
+ engine::entity entity_proto;
|
|
|
};
|
|
|
|
|
|
std::vector<shot> shot_vector(std::size_t count, float facing, float covered,
|
|
|
@@ -60,9 +61,9 @@ 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, graphics::object obj)
|
|
|
+ std::vector<shot> shots, bullet blt, engine::entity ent)
|
|
|
: actor(actor), shot_timer{shot_interval}, shots(shots), bullet_proto(blt),
|
|
|
- object_proto(obj) {}
|
|
|
+ entity_proto(ent) {}
|
|
|
|
|
|
std::shared_ptr<burstshot> burstshot::create(danmaku::actor * actor,
|
|
|
Json::Value const & json,
|
|
|
@@ -73,10 +74,19 @@ std::shared_ptr<burstshot> burstshot::create(danmaku::actor * actor,
|
|
|
json["centerAngle"].asFloat(), json["burstAngle"].asFloat(),
|
|
|
json["bulletSpeed"].asFloat(), json["clockwise"].asBool()),
|
|
|
json["prototype"]["damage"].asInt(),
|
|
|
- engine::to_object(json["prototype"], manager));
|
|
|
+ engine::entity(json["prototype"], manager));
|
|
|
}
|
|
|
|
|
|
-void burstshot::update(float delta) {}
|
|
|
+void burstshot::update(float delta) {
|
|
|
+ if ((shot_timer.remaining -= delta) <= 0.f) {
|
|
|
+ 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; }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
namespace danmaku {
|
|
|
BIND_BULLET_PATTERN("burstshot", &burstshot::create);
|