-
Notifications
You must be signed in to change notification settings - Fork 2
/
FactoryManager.cpp
105 lines (82 loc) · 2.37 KB
/
FactoryManager.cpp
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
#include "stdafx.h"
#include "FactoryManager.h"
#include "DrillBuilding.h"
#include "Spore/Simulator/cInteractableObject.h"
/// AUTOGENERATED METHODS ///
using namespace Simulator;
int FactoryManager::AddRef() {
return Simulator::cStrategy::AddRef();
}
int FactoryManager::Release() {
return Simulator::cStrategy::Release();
}
const char* FactoryManager::GetName() const {
return "RattlerSpore::FactoryManager";
}
bool FactoryManager::Write(Simulator::ISerializerStream* stream)
{
return Simulator::ClassSerializer(this, ATTRIBUTES).Write(stream);
}
bool FactoryManager::WriteToXML(Simulator::XmlSerializer* writexml)
{
return false;
}
bool FactoryManager::Read(Simulator::ISerializerStream* stream)
{
return Simulator::ClassSerializer(this, ATTRIBUTES).Read(stream);
}
/// END OF AUTOGENERATED METHODS ///
////////////////////////////////////
Simulator::Attribute FactoryManager::ATTRIBUTES[] = {
// Add more attributes here
// This one must always be at the end
//SimAttribute(FactoryManager,SavedBuildings,1),
Simulator::Attribute()
};
void FactoryManager::Initialize() {
sInstance = this;
}
void FactoryManager::Dispose() {
//SavedBuildings.clear();
}
void FactoryManager::Update(int deltaTime, int deltaGameTime) {
if (GetCurrentContext() == SpaceContext::Planet) {
if (!LoadPlanet) {
uint32_t pid = GetActivePlanetRecord()->GetID().internalValue;
auto buildings = GetData<DrillBuilding>();
// SavedBuildings.clear();
for (auto fact : buildings) {
if (fact->getPlanetID() == pid) {
App::ConsolePrintF("Loaded a Factory");
fact->render();
}
// SavedBuildings.push_back(fact);
LoadPlanet = true;
}
}
}
else {
LoadPlanet = false;
//If simulator got cleared
// auto buildings = GetData<DrillBuilding>();
// if (buildings.size() < SavedBuildings.size()) {
// for (auto fact : SavedBuildings) {
// auto factory = simulator_new<DrillBuilding>();
// factory->init(fact->getPosition(), fact->getPlanetID());
// }
// }
}
}
FactoryManager* FactoryManager::Get()
{
return sInstance;
}
bool FactoryManager::CreateBuilding(const Vector3& position, uint32_t buildingType)
{
const PlanetID mario = GetActivePlanetRecord()->GetID();
uint32_t greg = mario.internalValue;
auto factory = simulator_new<DrillBuilding>();
factory->init(position, greg);
return false;
}
FactoryManager* FactoryManager::sInstance;