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
42 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);
43 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);
45 void Init(EngineContext *parent, VM *vm, Ogre::SceneManager* mSceneManager, const Vector3 &position, Real rotation, const Vector3 &area_min, const Vector3 &area_max);
46 ScriptProcessor* GetScriptProcessor();
47 ::SBS::SBS *GetSystem() { return Simcore; }
48 bool IsCameraActive();
49 bool Run();
50 void Shutdown();
51 bool GetShutdownState() { return shutdown; }
52 bool Load(std::string filename);
53 bool IsLoading() { return loading; }
54 bool IsRunning() { return running; }
55 bool IsReloading() { return reloading; }
56 void DoReload();
57 std::string GetFilename();
58 bool Start(std::vector<Ogre::Camera*> &cameras);
59 void Report(const std::string &message);
60 bool ReportError(const std::string &message);
61 bool ReportFatalError(const std::string &message);
62 bool IsLoadingFinished();
63 bool UpdateProgress(int percent);
64 int GetProgress() { return progress; }
65 int GetNumber() { return instance; }
66 ::SBS::CameraState GetCameraState();
67 void SetCameraState(const ::SBS::CameraState &state, bool set_floor = true);
68 bool IsInside();
69 bool IsInside(const Vector3 &position);
70 void DetachCamera(bool reset_building = false);
71 void AttachCamera(std::vector<Ogre::Camera*> &cameras, bool init_state = true);
72 void RefreshCamera();
73 void ResetCamera();
74 void RevertMovement();
75 Vector3 GetCameraPosition();
76 void OnEnter();
77 void OnExit();
78 void CutForEngine(EngineContext *engine);
79 void AddChild(EngineContext *engine);
80 void RemoveChild(EngineContext *engine);
81 void RemoveParent() { parent = 0; }
82 void Move(Vector3 &position, bool move_children = false);
83 EngineContext* GetParent() { return parent; }
84 bool IsParent(EngineContext *engine, bool recursive = false);
85 VM* GetVM();
86 bool InRunloop();
87 bool IsRoot();
88 bool InitSim();
89 bool LoadDefault();
90 void Boot();
91 void GatherReset();
92 void Gather();
93 void ResetPrepare();
94
95private:
96
97 void StartSim();
98 void UnloadSim();
99 void Init();
100
101 ScriptProcessor* processor; //script processor
102 ::SBS::SBS *Simcore; //sim engine instance
103 int instance; //instance number
104 EngineContext *parent; //parent engine
105 unsigned long finish_time;
110 bool raised;
112 bool inside;
113 std::string InstancePrompt;
115
116 //override information
118
119 Ogre::SceneManager* mSceneManager;
120 FMOD::System *fmodsystem;
125
126 //child engines
127 std::vector<EngineContext*> children;
128
129 //VM instance
131};
132
133}
134
135#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