-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimationHub.es
More file actions
162 lines (139 loc) · 4.7 KB
/
AnimationHub.es
File metadata and controls
162 lines (139 loc) · 4.7 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* Copyright (c) 2002-2012 Croteam Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as published by
the Free Software Foundation
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
228
%{
#include "StdH.h"
#include <Entities/AnimationChanger.h>
%}
class CAnimationHub : CRationalEntity {
name "AnimationHub";
thumbnail "Thumbnails\\AnimationHub.tbn";
features "HasName", "IsTargetable";
properties:
1 CTString m_strName "Name" 'N' = "Animation hub",
2 CTString m_strDescription = "",
3 FLOAT m_tmDelayEach "Delay each" 'D' = 0.0f,
10 CEntityPointer m_penTarget0 "Target0" 'T' COLOR(C_GREEN|0xFF),
11 CEntityPointer m_penTarget1 "Target1" COLOR(C_GREEN|0xFF),
12 CEntityPointer m_penTarget2 "Target2" COLOR(C_GREEN|0xFF),
13 CEntityPointer m_penTarget3 "Target3" COLOR(C_GREEN|0xFF),
14 CEntityPointer m_penTarget4 "Target4" COLOR(C_GREEN|0xFF),
15 CEntityPointer m_penTarget5 "Target5" COLOR(C_GREEN|0xFF),
16 CEntityPointer m_penTarget6 "Target6" COLOR(C_GREEN|0xFF),
17 CEntityPointer m_penTarget7 "Target7" COLOR(C_GREEN|0xFF),
18 CEntityPointer m_penTarget8 "Target8" COLOR(C_GREEN|0xFF),
19 CEntityPointer m_penTarget9 "Target9" COLOR(C_GREEN|0xFF),
20 FLOAT m_tmDelay0 "Delay0" = 0.0f,
21 FLOAT m_tmDelay1 "Delay1" = 0.0f,
22 FLOAT m_tmDelay2 "Delay2" = 0.0f,
23 FLOAT m_tmDelay3 "Delay3" = 0.0f,
24 FLOAT m_tmDelay4 "Delay4" = 0.0f,
25 FLOAT m_tmDelay5 "Delay5" = 0.0f,
26 FLOAT m_tmDelay6 "Delay6" = 0.0f,
27 FLOAT m_tmDelay7 "Delay7" = 0.0f,
28 FLOAT m_tmDelay8 "Delay8" = 0.0f,
29 FLOAT m_tmDelay9 "Delay9" = 0.0f,
100 INDEX m_iModelAnim = 0,
101 BOOL m_bModelLoop = 0,
102 INDEX m_iTextureAnim = 0,
103 BOOL m_bTextureLoop = 0,
104 INDEX m_iLightAnim = 0,
105 BOOL m_bLightLoop = 0,
106 COLOR m_colAmbient = 0,
107 COLOR m_colDiffuse = 0,
110 INDEX m_iCounter = 0,
components:
1 model MODEL_HUB "Models\\Editor\\AnimationHub.mdl",
2 texture TEXTURE_HUB "Models\\Editor\\AnimationHub.tex"
functions:
const CTString &GetDescription(void) const {
((CTString&)m_strDescription).PrintF("-><none>");
if (m_penTarget0!=NULL) {
((CTString&)m_strDescription).PrintF("->%s...", m_penTarget0->GetName());
}
return m_strDescription;
}
procedures:
RelayEvents()
{
// for each target
m_iCounter=0;
while(m_iCounter<10) {
// get delay
FLOAT fDelay = m_tmDelayEach + (&m_tmDelay0)[m_iCounter];
// if has delay
if (fDelay>0) {
// wait
autowait(fDelay);
}
// get the target
CEntity *penTarget = (&m_penTarget0)[m_iCounter];
// if no more targets
if (penTarget==NULL) {
// stop
jump WaitChange();
}
// sent event to it
EChangeAnim eca;
eca.iModelAnim = m_iModelAnim ;
eca.bModelLoop = m_bModelLoop ;
eca.iTextureAnim = m_iTextureAnim;
eca.bTextureLoop = m_bTextureLoop;
eca.iLightAnim = m_iLightAnim ;
eca.bLightLoop = m_bLightLoop ;
eca.colAmbient = m_colAmbient ;
eca.colDiffuse = m_colDiffuse ;
penTarget->SendEvent(eca);
m_iCounter++;
}
jump WaitChange();
}
WaitChange()
{
// wait forever
while(TRUE) {
wait() {
on (EChangeAnim eca) : {
m_iModelAnim = eca.iModelAnim ;
m_bModelLoop = eca.bModelLoop ;
m_iTextureAnim = eca.iTextureAnim;
m_bTextureLoop = eca.bTextureLoop;
m_iLightAnim = eca.iLightAnim ;
m_bLightLoop = eca.bLightLoop ;
m_colAmbient = eca.colAmbient ;
m_colDiffuse = eca.colDiffuse ;
jump RelayEvents();
}
}
}
}
Main()
{
InitAsEditorModel();
SetPhysicsFlags(EPF_MODEL_IMMATERIAL);
SetCollisionFlags(ECF_IMMATERIAL);
// set appearance
SetModel(MODEL_HUB);
SetModelMainTexture(TEXTURE_HUB);
// check target types
for (INDEX i=0; i<10; i++) {
CEntityPointer &penTarget = (&m_penTarget0)[i];
if (penTarget!=NULL &&
!IsOfClass(penTarget, "ModelHolder2") &&
!IsOfClass(penTarget, "Light")) {
WarningMessage("All targets must be ModelHolder2 or Light!");
penTarget=NULL;
}
}
jump WaitChange();
}
};