17 DummyController() =
default;
18 virtual ~DummyController() =
default;
25 virtual void onUpdate(
bool,
bool)
override {
26 if (timer.getElapsedTime().asSeconds() >= 3.f) {
35 std::unique_ptr<core::battle::Battle>&& battle) {
36 return bl::engine::State::Ptr(
37 new BattleState(
systems, std::forward<std::unique_ptr<core::battle::Battle>>(battle)));
41 std::unique_ptr<core::battle::Battle>&& battle)
42 :
State(systems,
bl::engine::StateMask::Menu)
43 , battle(std::forward<std::unique_ptr<
core::battle::Battle>>(battle)) {
44 if (!this->battle->controller) {
45 BL_LOG_WARN <<
"Invalid battle controller, using dummy";
46 this->battle->setController(std::make_unique<DummyController>());
54 scene = engine.renderer().getObserver().pushScene<bl::rc::scene::CodeScene>(
56 battle->view.init(
static_cast<bl::rc::scene::CodeScene*
>(scene.get()));
58 else { engine.renderer().getObserver().pushScene(scene); }
59 systems.
engine().inputSystem().getActor().addListener(battle->view);
60 bl::event::Dispatcher::subscribe(
this);
64 engine.renderer().getObserver().popScene();
65 systems.
engine().inputSystem().getActor().removeListener(battle->view);
66 bl::event::Dispatcher::unsubscribe(
this);
67 bl::audio::AudioSystem::popPlaylist();
71 battle->controller->update();
72 battle->view.update(dt);
73 battle->state.localPlayer().refresh();
74 battle->state.enemy().refresh();
84 bl::event::Dispatcher::dispatch<core::event::BattleCompleted>(
85 {battle->type, std::move(battle->result)});
Core classes and functionality for both the editor and game.
Parent namespace for all functionality unique to the game.
Interface for battle controllers. Battle controllers manage the flow of state and interaction for bat...
void render(bl::rc::scene::CodeScene::RenderContext &ctx)
Renders the battle view.
Emitted by the BattleFSM. All UI is handled via a queue of commands. Commands are resolved in the ord...
Event that is fired when the bag menu should be opened.
int *const chosenPeoplemon
Special event to trigger the opening of the peoplemon menu.
bool hasLivingPeoplemon() const
Returns whether or not the player has any living peoplemon.
void healPeoplemon()
Restores HP and removes all ailments.
player::State & state()
Returns the state of the player.
void whiteout()
Heals all Peoplemon and respawns at the last PC center.
Owns all primary systems and a reference to the engine.
const bl::engine::Engine & engine() const
Const accessor for the Engine.
Player & player()
Returns the player system.
static bl::engine::State::Ptr create(core::system::Systems &systems, Context ctx, core::item::Id *result=nullptr, int outNow=-1, int *chosenPeoplemon=nullptr, bool *unpause=nullptr)
Creates a new BagMenu.
This game state does all battling. When the battle is complete it will pop itself from the engine sta...
virtual const char * name() const override
Returns "BattleState".
virtual void deactivate(bl::engine::Engine &) override
Does nothing.
static bl::engine::State::Ptr create(core::system::Systems &systems, std::unique_ptr< core::battle::Battle > &&battle)
Creates a new BattleState.
virtual void activate(bl::engine::Engine &) override
Does nothing.
virtual void update(bl::engine::Engine &, float dt, float) override
Calls into the battle's update method.
static bl::engine::State::Ptr create(core::system::Systems &systems, Context ctx, int outNow=-1, int *chosen=nullptr, core::item::Id item=core::item::Id::None)
Creates a new PeoplemonMenu state.
Parent to all game states. Provides some commonly required data like core game systems.
core::system::Systems & systems