-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtension.cpp
More file actions
146 lines (100 loc) · 2.57 KB
/
Extension.cpp
File metadata and controls
146 lines (100 loc) · 2.57 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
133
134
135
136
137
138
139
140
141
142
143
144
145
#include "Common.h"
///
/// EXTENSION CONSTRUCTOR/DESTRUCTOR
///
Extension::Extension(LPRDATA _rdPtr, LPEDATA edPtr, fpcob cobPtr)
: rdPtr(_rdPtr), rhPtr(_rdPtr->rHo.hoAdRunHeader), Runtime(_rdPtr)
{
/*
Link all your action/condition/expression functions to their IDs to match the
IDs in the JSON here
*/
LinkAction(0, AttachObjects);
LinkExpression(0, NumObjects);
/*
This is where you'd do anything you'd do in CreateRunObject in the original SDK
It's the only place you'll get access to edPtr at runtime, so you should transfer
anything from edPtr to the extension class here.
*/
}
Extension::~Extension()
{
/*
This is where you'd do anything you'd do in DestroyRunObject in the original SDK.
(except calling destructors and other such atrocities, because that's automatic in Edif)
*/
}
short Extension::Handle()
{
/* We loop through all objects and update them... */
for(unsigned int i = 0; i < AttachedObjects.size(); ++i)
{
/* Store a pointer to the current loop's object */
RunObject* Object = AttachedObjects[i];
/* Check if this object was deleted */
if(Object->roHo.hoFlags & HOF_DESTROYED)
{
/* If so, remove it from this array */
AttachedObjects.erase(AttachedObjects.begin() + i);
/* Now we need to process this loop index again. */
i--;
continue;
}
/* Modify it somehow */
Object->roHo.hoX += (rand() % 5) - (rand() % 5);
Object->roHo.hoY += (rand() % 5) - (rand() % 5);
Object->roc.rcAngle += (rand() % 5) - (rand() % 5);
/* Tell MMF to redraw the object */
Object->roc.rcChanged = true;
}
/* Returning 0 will make sure Handle() gets called again... */
return 0;
}
short Extension::Display()
{
/*
If you return REFLAG_DISPLAY in Handle() this routine will run.
*/
// Ok
return 0;
}
short Extension::Pause()
{
// Ok
return 0;
}
short Extension::Continue()
{
// Ok
return 0;
}
bool Extension::Save(HANDLE File)
{
bool OK = false;
#ifndef VITALIZE
// Save the object's data here
OK = true;
#endif
return OK;
}
bool Extension::Load(HANDLE File)
{
bool OK = false;
#ifndef VITALIZE
// Load the object's data here
OK = true;
#endif
return OK;
}
// These are called if there's no function linked to an ID
void Extension::Action(int ID, LPRDATA rdPtr, long param1, long param2)
{
}
long Extension::Condition(int ID, LPRDATA rdPtr, long param1, long param2)
{
return false;
}
long Extension::Expression(int ID, LPRDATA rdPtr, long param)
{
return 0;
}