21 std::cout <<
"Enter script: ";
23 std::getline(std::cin, cmd);
25 bl::script::Script script(cmd);
28 script.run(&systems.
engine().scriptManager());
40 :
State(systems,
bl::engine::StateMask::Running)
50 bl::event::Dispatcher::subscribe(
this);
51 if (state == MapFadein) {
57 .putTask<bl::rc::rgi::FadeEffectTask>(
64 engine.renderer().getObserver().getRenderGraph().removeTasks<bl::rc::rgi::FadeEffectTask>();
69 case SwitchMapFadeout:
70 if (fadeout->complete()) {
71 BL_LOG_INFO <<
"Switching to map: " << replacementMap <<
" spawn " << spawnId;
73 BL_LOG_ERROR <<
"Failed to switch maps";
83 .putTask<bl::rc::rgi::FadeEffectTask>(
89 if (fadeout->complete()) {
97 .removeTask<bl::rc::rgi::FadeEffectTask>();
107 switch (event.
type) {
117 void MainGame::observe(
const sf::Event& event) {
118 #ifdef PEOPLEMON_DEBUG
119 if (event.type == sf::Event::KeyPressed) {
120 static std::atomic_bool running =
false;
122 if (event.key.code == sf::Keyboard::F1) {
125 else if (event.key.code == sf::Keyboard::Tilde) {
128 std::thread t(&runDebugScript, std::ref(
systems), std::ref(running));
132 else if (event.key.code == sf::Keyboard::F5) {
135 auto& ppl = team.front();
137 const unsigned int lvl = ppl.evolveLevel();
139 while (ppl.currentLevel() < lvl) {
140 const auto move = ppl.levelUp();
148 else if (event.key.code == sf::Keyboard::F6) {
151 for (
const auto& town : towns) { visited.emplace(town.name); }
152 core::debug::DebugBanner::display(
"All towns visited");
162 replacementMap =
event.newMap;
163 spawnId =
event.spawn;
164 state = SwitchMapFadeout;
174 std::unique_ptr<core::battle::Battle>& battle =
175 const_cast<std::unique_ptr<core::battle::Battle>&
>(
event.battle);
Parent namespace for all functionality unique to the game.
Fired when a battle should start. This does not actually start a battle, but communicates to the curr...
Fired when the map should be switched to something else.
Fired when the game should switch states. This event type is primarily for decoupling input code in C...
@ GamePaused
The game should pause.
const Type type
The type of state change that should occur.
Fired when the storage system should be opened.
Event that is fired by the Core module to signal to the game to open a store.
static const std::vector< Town > & FlyMapTowns()
Returns the set of towns that can be flown to.
std::vector< pplmn::OwnedPeoplemon > peoplemon
std::unordered_set< std::string > visitedTowns
static float ScreenFadePeriod()
Script context for debug scripts ran from the terminal.
void resetAllLocks()
Resets all controllable entity locks to the last stored state.
void setAllLocks(bool locked, bool preserve=true)
Sets the lock state for all controllable entities.
player::State & state()
Returns the state of the player.
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.
Controllable & controllable()
Returns the controllable entity system.
WildPeoplemon & wildPeoplemon()
Returns the wild peoplemon system.
World & world()
Modifiable accessor for the world system.
void startDebugBattle()
Starts a wild Peoplemon battle for debugging.
bool switchMaps(const std::string &newMap, int spawnId)
Switches the current map to the map in the given file.
static bl::engine::State::Ptr create(core::system::Systems &systems, std::unique_ptr< core::battle::Battle > &&battle)
Creates a new BattleState.
static bl::engine::State::Ptr create(core::system::Systems &systems, core::pplmn::OwnedPeoplemon &ppl)
The big honcho. This is the primary state that runs a majority of the time.
virtual const char * name() const override
Returns "MainGame".
virtual void deactivate(bl::engine::Engine &engine) override
Deactivates the game state.
virtual void activate(bl::engine::Engine &engine) override
Activates the state.
virtual ~MainGame()
Destroy the Main Game state.
virtual void update(bl::engine::Engine &engine, float dt, float) override
Updates all of the primary systems.
static bl::engine::State::Ptr create(core::system::Systems &systems)
Creates the main game state. The game state must be initialized before invoking the main game state.
static bl::engine::State::Ptr create(core::system::Systems &systems)
Creates a new MapExplorer state.
static bl::engine::State::Ptr create(core::system::Systems &systems)
Creates a new pause menu state.
Parent to all game states. Provides some commonly required data like core game systems.
core::system::Systems & systems
static bl::engine::State::Ptr create(core::system::Systems &systems)
Create a new storage system menu.
static bl::engine::State::Ptr create(core::system::Systems &systems, const core::event::StoreOpened &data)
Create a new StoreMenu.