/
GameObject.cpp
89 lines (67 loc) · 2.11 KB
/
GameObject.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
#include "stdafx.h"
#include "GameObject.h"
GameObject::GameObject(int index, const char *name)
{
objData = AllocateObjectMaster(CallMain, index, name);
if (!objData)
{
objData->DisplaySub = CallDisplay;
objData->DeleteSub = CallDelete;
objData->Data2.Undefined = this;
}
}
GameObject::GameObject(ObjectMaster *obj)
{
objData = obj;
objData->MainSub = CallMain;
objData->DisplaySub = CallDisplay;
objData->DeleteSub = CallDelete;
objData->Data2.Undefined = this;
initFromObj = true;
}
void GameObject::CallMain(ObjectMaster *obj)
{
((GameObject *)obj->Data2.Undefined)->Main();
}
void GameObject::CallDisplay(ObjectMaster *obj)
{
((GameObject *)obj->Data2.Undefined)->Display();
}
void GameObject::CallDelete(ObjectMaster *obj)
{
GameObject *cgo = (GameObject *)obj->Data2.Undefined;
cgo->Delete();
obj->Data2.Undefined = nullptr;
cgo->objData = nullptr;
if (cgo->initFromObj)
delete cgo;
}
void GameObject::Display(){}
void GameObject::Delete(){}
const char *GameObject::GetName(){ return objData->Name; }
SETObjectData *GameObject::GetSETData(){ return objData->SETData; }
GameObject::~GameObject()
{
if (objData)
{
Delete();
objData->Data2.Undefined = nullptr;
objData->DeleteSub = nullptr;
DeleteObject_(objData);
}
}
GameEntity::GameEntity(int index, const char *name) :GameObject(index, name)
{
objData->Data1.Entity = AllocateEntityData1();
}
EntityData1 *GameEntity::GetData() { return objData->Data1.Entity; }
char GameEntity::GetAction() { return GetData()->Action; }
void GameEntity::SetAction(char action) { GetData()->Action = action; }
Rotation &GameEntity::GetRotation() { return GetData()->Rotation; }
typedef Rotation rot; // bleh
void GameEntity::SetRotation(rot &rotation) { GetData()->Rotation = rotation; }
NJS_VECTOR &GameEntity::GetPosition() { return GetData()->Position; }
void GameEntity::SetPosition(NJS_VECTOR &position) { GetData()->Position = position; }
NJS_VECTOR &GameEntity::GetScale() { return GetData()->Scale; }
void GameEntity::SetScale(NJS_VECTOR &scale) { GetData()->Scale = scale; }
CollisionInfo *GameEntity::GetCollisionInfo() { return GetData()->Collision; }