forked from Spore-Community/Spore-ModAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimulatorSystem.cpp
More file actions
132 lines (117 loc) · 4 KB
/
Copy pathSimulatorSystem.cpp
File metadata and controls
132 lines (117 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef MODAPI_DLL_EXPORT
/****************************************************************************
* Copyright (C) 2019 Eric Mor
*
* This file is part of Spore ModAPI.
*
* Spore ModAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <Spore\Simulator\SubSystem\SimulatorSystem.h>
#include <Spore\Simulator\SubSystem\StarManager.h>
#include <Spore\Simulator\SubSystem\SpacePlayerData.h>
#include <Spore\Simulator\SubSystem\GameViewManager.h>
#include <Spore\Simulator\SubSystem\cStrategy.h>
#include <Spore\UTFWin\IWindowManager.h>
#include <Spore\ModAPI.h>
namespace Simulator
{
auto_STATIC_METHOD_(cSimulatorSystem, cSimulatorSystem*, Get);
bool cSimulatorSystem::AddStrategy(ISimulatorStrategy* strategy, uint32_t id) {
if (!ModAPI::AddSimulatorStrategy(strategy, id)) return false;
mSubSystems.push_back(strategy);
strategy->Initialize();
return true;
}
void InitializeWithoutPlanet() {
cStarRecord* pRecord = StarManager.GetStarRecord(0);
pRecord->mEmpireID = StarManager.NextPoliticalID(true);
SpacePlayerData::Get()->mPlayerEmpireID = pRecord->mEmpireID;
SpacePlayerData::Get()->mpPlayerEmpire = StarManager.GetEmpireForStar(pRecord);
cPlanetPtr planet;
StarManager.RecordToPlanet(pRecord->GetPlanetRecord(0), planet);
SpacePlayerData::Get()->mpActivePlanet = planet.get();
GameViewManager.PrepareSimulator();
}
UI::Minimap* GetMinimapWindow() {
if (WindowManager.GetMainWindow()) {
UTFWin::IWindow* minimapHolder = WindowManager.GetMainWindow()->FindWindowByID(0x0190722E);
if (minimapHolder) {
return object_cast<UI::Minimap>(minimapHolder->FindWindowByID(0x0));
}
}
return nullptr;
}
/// cStrategy ///
cStrategy::cStrategy()
: mnRefCount(0)
, mLastGameMode(0xFFFFFFFF)
, mCurrentGameMode(0xFFFFFFFF)
, mCurrentTransition(0xFFFFFFFF)
, mCurrentTransitionPhase(0)
{}
cStrategy::~cStrategy() {}
int cStrategy::AddRef() {
return ++mnRefCount;
}
int cStrategy::Release() {
if (--mnRefCount == 0) {
delete this;
return 0;
}
else return mnRefCount;
}
void cStrategy::OnModeExited(uint32_t previousModeID, uint32_t newModeID) {
if (newModeID != GetLastGameMode()) {
func40h(newModeID);
func48h();
}
}
void cStrategy::OnModeEntered(uint32_t previousModeID, uint32_t newModeID) {
if (newModeID != GetCurrentGameMode()) {
func44h(newModeID);
func4Ch();
}
}
uint32_t cStrategy::GetLastGameMode() const {
return mLastGameMode;
}
uint32_t cStrategy::GetCurrentGameMode() const {
return mCurrentGameMode;
}
bool cStrategy::func24h(uint32_t mode) {
return mode == GetCurrentGameMode() && mode == GetLastGameMode() && mCurrentTransition == 0xFFFFFFFF;
}
void cStrategy::OnLoad(const cSavedGameHeader& savedGame) {}
void cStrategy::Update(int deltaTime, int deltaGameTime) {}
void cStrategy::PostUpdate(int deltaTime, int deltaGameTime) {}
void cStrategy::func40h(uint32_t mode) {
mCurrentTransitionPhase = 1;
if (mCurrentTransition == 0xFFFFFFFF) mCurrentTransition = mode;
}
void cStrategy::func44h(uint32_t mode) {
mCurrentTransitionPhase = 2;
if (mCurrentTransition == 0xFFFFFFFF) mCurrentTransition = mode;
}
void cStrategy::func48h() {
mLastGameMode = mCurrentTransition;
mCurrentTransition = 0xFFFFFFFF;
mCurrentTransitionPhase = 0;
}
void cStrategy::func4Ch() {
mCurrentGameMode = mCurrentTransition;
mCurrentTransition = 0xFFFFFFFF;
mCurrentTransitionPhase = 0;
}
}
#endif