Skyscraper 2.0
enginecontext.h
Go to the documentation of this file.
1/*
2 Skyscraper 2.0 - Engine Context
3 Copyright (C)2004-2024 Ryan Thoryk
4 https://www.skyscrapersim.net
5 https://sourceforge.net/projects/skyscraper/
6 Contact - ryan@skyscrapersim.net
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21*/
22
23#ifndef ENGINECONTEXT_H
24#define ENGINECONTEXT_H
25
26#include "vm.h"
27
28namespace Skyscraper {
29
30class ScriptProcessor;
31
33{
34public:
35
36 bool Reload;
37 bool Moved; //true if engine has been moved on startup
38 bool started;
39 bool NewEngine; //true if this is a new engine
40 unsigned long current_time, time_stat;
41 bool Paused;
42
43 EngineContext(EngineContext *parent, VM *vm, Ogre::SceneManager* mSceneManager, FMOD::System *fmodsystem, const Vector3 &position = Vector3::ZERO, Real rotation = 0.0, const Vector3 &area_min = Vector3::ZERO, const Vector3 &area_max = Vector3::ZERO);
44 EngineContext(EngineContext *parent, VM *vm, Ogre::SceneManager* mSceneManager, const Vector3 &position = Vector3::ZERO, Real rotation = 0.0, const Vector3 &area_min = Vector3::ZERO, const Vector3 &area_max = Vector3::ZERO);
46 void Init(EngineContext *parent, VM *vm, Ogre::SceneManager* mSceneManager, const Vector3 &position, Real rotation, const Vector3 &area_min, const Vector3 &area_max);
47 ScriptProcessor* GetScriptProcessor();
48 ::SBS::SBS *GetSystem() { return Simcore; }
49 bool IsCameraActive();
50 bool Run();
51 void Shutdown();
52 bool GetShutdownState() { return shutdown; }
53 bool Load(std::string filename);
54 bool IsLoading() { return loading; }
55 bool IsRunning() { return running; }
56 bool IsReloading() { return reloading; }
57 void DoReload();
58 std::string GetFilename();
59 bool Start(std::vector<Ogre::Camera*> &cameras);
60 void Report(const std::string &message);
61 bool ReportError(const std::string &message);
62 bool ReportFatalError(const std::string &message);
63 bool IsLoadingFinished();
64 bool UpdateProgress(int percent);
65 int GetProgress() { return progress; }
66 int GetNumber() { return instance; }
67 ::SBS::CameraState GetCameraState();
68 void SetCameraState(const ::SBS::CameraState &state, bool set_floor = true);
69 bool IsInside();
70 bool IsInside(const Vector3 &position);
71 void DetachCamera(bool reset_building = false);
72 void AttachCamera(std::vector<Ogre::Camera*> &cameras, bool init_state = true);
73 void RefreshCamera();
74 void ResetCamera();
75 void RevertMovement();
76 Vector3 GetCameraPosition();
77 void OnEnter();
78 void OnExit();
79 void CutForEngine(EngineContext *engine);
80 void AddChild(EngineContext *engine);
81 void RemoveChild(EngineContext *engine);
82 void RemoveParent() { parent = 0; }
83 void Move(Vector3 &position, bool move_children = false);
84 EngineContext* GetParent() { return parent; }
85 bool IsParent(EngineContext *engine, bool recursive = false);
86 VM* GetVM();
87 bool InRunloop();
88 bool IsRoot();
89 bool InitSim();
90 bool LoadDefault();
91 void Boot();
92 void GatherReset();
93 void Gather();
94 void ResetPrepare();
95
96private:
97
98 void StartSim();
99 void UnloadSim();
100 void Init();
101
102 ScriptProcessor* processor; //script processor
103 ::SBS::SBS *Simcore; //sim engine instance
104 int instance; //instance number
105 EngineContext *parent; //parent engine
106 unsigned long finish_time;
111 bool raised;
113 bool inside;
114 std::string InstancePrompt;
116
117 //override information
119
120 Ogre::SceneManager* mSceneManager;
121 FMOD::System *fmodsystem;
126
127 //child engines
128 std::vector<EngineContext*> children;
129
130 //VM instance
132};
133
134}
135
136#endif
Ogre::SceneManager * mSceneManager
std::vector< EngineContext * > children
::SBS::CameraState * reload_state
ScriptProcessor * processor
EngineContext * GetParent()
Ogre::Vector3 Vector3
Definition globals.h:58
Ogre::Real Real
Definition globals.h:57
std::atomic< bool > shutdown
Definition vmconsole.cpp:45
#define VMIMPEXP
Definition vm.h:49