| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- /*
- * Copyright (C) 2022 The V-Gears Team
- *
- * This file is part of V-Gears
- *
- * V-Gears is free software: you can redistribute it and/or modify it under
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, version 3.0 (GPLv3) of the License.
- *
- * V-Gears is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
- #include <iostream>
- #include <OgreRoot.h>
- #include "Manager.h"
- #include "common/Logger.h"
- Manager::Manager(): module_(Module::FIELD), prev_module_(Module::FIELD), paused_(false){}
- Manager::~Manager(){}
- Manager::Module Manager::GetModule() const{return module_;}
- bool Manager::IsFieldModule() const{return (module_ == Module::FIELD);}
- bool Manager::IsBattleModule() const{return (module_ == Module::BATTLE);}
- bool Manager::IsWorldModule() const{return (module_ == Module::WORLD);}
- void Manager::SetModule(const Module module){
- if (module == Module::FIELD){
- ClearBattle();
- ClearWorld();
- }
- else if (module == Module::WORLD){
- ClearBattle();
- ClearField();
- }
- else if (module == Module::BATTLE){
- prev_module_ = module_;
- }
- module_ = module;
- }
- void Manager::SetFieldModule(){SetModule(Module::FIELD);}
- void Manager::SetBattleModule(){SetModule(Module::BATTLE);}
- void Manager::SetWorldModule(){SetModule(Module::WORLD);}
- void Manager::SetPreviousModule(){
- if (module_ != Module::BATTLE){
- LOG_WARNING(
- std::string("Called Manager::SetPreviousModule without battle module active. ")
- + "Doing nothing. Current module is " + std::to_string(module_)
- );
- return;
- }
- if (prev_module_ == Module::BATTLE){
- LOG_WARNING(
- "Called Manager::SetPreviousModule but there is no previous module. Doing nothing."
- );
- return;
- }
- module_ = prev_module_;
- }
- void Manager::Update(){
- UpdateDebug();
- if (paused_ == true) return;
- Update(module_);
- }
- void Manager::Update(const Module module){
- switch (module){
- case Module::FIELD:
- UpdateField();
- break;
- case Module::BATTLE:
- UpdateBattle();
- break;
- case Module::WORLD:
- UpdateWorld();
- break;
- }
- }
- void Manager::Clear(){Clear(module_);}
- void Manager::Clear(const Module module){
- switch (module){
- case Module::FIELD:
- ClearField();
- break;
- case Module::BATTLE:
- ClearBattle();
- break;
- case Module::WORLD:
- ClearWorld();
- break;
- }
- }
- void Manager::ScriptSetPaused(const bool paused){paused_ = paused;}
|