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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
|
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program 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/.
// object.h
#pragma once
#include "graphics/engine/engine.h"
#include "graphics/engine/camera.h"
#include "object/object_ids.h"
#include "sound/sound.h"
class CInstanceManager;
class CApplication;
class CPhysics;
class CBrain;
class CMotion;
class CAuto;
class CDisplayText;
class CRobotMain;
class CBotVar;
class CScript;
namespace Ui
{
class CDisplayText;
}
// The father of all parts must always be the part number zero!
const int OBJECTMAXPART = 40;
const int MAXCRASHSPHERE = 40;
const int OBJECTMAXDESELLIST = 10;
const int OBJECTMAXINFO = 10;
const int OBJECTMAXCMDLINE = 20;
enum ObjectMaterial
{
OM_METAL = 0, // metal
OM_PLASTIC = 1, // plastic
OM_HUMAN = 2, // cosmonaut
OM_ANIMAL = 3, // insect
OM_VEGETAL = 4, // plant
OM_MINERAL = 5, // stone
};
struct ObjectPart
{
char bUsed;
int object; // number of the object in CEngine
int parentPart; // number of father part
int masterParti; // master canal of the particle
Math::Vector position;
Math::Vector angle;
Math::Vector zoom;
char bTranslate;
char bRotate;
char bZoom;
Math::Matrix matTranslate;
Math::Matrix matRotate;
Math::Matrix matTransform;
Math::Matrix matWorld;
};
struct Character
{
float wheelFront; // position X of the front wheels
float wheelBack; // position X of the back wheels
float wheelLeft; // position Z of the left wheels
float wheelRight; // position Z of the right wheels
float height; // normal height on top of ground
Math::Vector posPower; // position of the battery
};
struct Info
{
char name[20]; // name of the information
float value; // value of the information
};
enum ExploType
{
EXPLO_BOUM = 1,
EXPLO_BURN = 2,
EXPLO_WATER = 3,
};
enum ResetCap
{
RESET_NONE = 0,
RESET_MOVE = 1,
RESET_DELETE = 2,
};
enum RadarFilter
{
FILTER_NONE = 0,
FILTER_ONLYLANDING = 1,
FILTER_ONLYFLYING = 2,
};
class CObject
{
public:
CObject(CInstanceManager* iMan);
~CObject();
void DeleteObject(bool bAll=false);
void Simplify();
bool ExploObject(ExploType type, float force, float decay=1.0f);
bool EventProcess(const Event &event);
void UpdateMapping();
int CreatePart();
void DeletePart(int part);
void SetObjectRank(int part, int objRank);
int GetObjectRank(int part);
void SetObjectParent(int part, int parent);
void SetType(ObjectType type);
ObjectType GetType();
char* GetName();
void SetOption(int option);
int GetOption();
void SetID(int id);
int GetID();
bool Write(char *line);
bool Read(char *line);
void SetDrawWorld(bool bDraw);
void SetDrawFront(bool bDraw);
bool CreateVehicle(Math::Vector pos, float angle, ObjectType type, float power, bool bTrainer, bool bToy);
bool CreateInsect(Math::Vector pos, float angle, ObjectType type);
bool CreateBuilding(Math::Vector pos, float angle, float height, ObjectType type, float power=1.0f);
bool CreateResource(Math::Vector pos, float angle, ObjectType type, float power=1.0f);
bool CreateFlag(Math::Vector pos, float angle, ObjectType type);
bool CreateBarrier(Math::Vector pos, float angle, float height, ObjectType type);
bool CreatePlant(Math::Vector pos, float angle, float height, ObjectType type);
bool CreateMushroom(Math::Vector pos, float angle, float height, ObjectType type);
bool CreateTeen(Math::Vector pos, float angle, float zoom, float height, ObjectType type);
bool CreateQuartz(Math::Vector pos, float angle, float height, ObjectType type);
bool CreateRoot(Math::Vector pos, float angle, float height, ObjectType type);
bool CreateHome(Math::Vector pos, float angle, float height, ObjectType type);
bool CreateRuin(Math::Vector pos, float angle, float height, ObjectType type);
bool CreateApollo(Math::Vector pos, float angle, ObjectType type);
bool ReadProgram(int rank, const char* filename);
bool WriteProgram(int rank, char* filename);
bool RunProgram(int rank);
int GetShadowLight();
int GetEffectLight();
void FlushCrashShere();
int CreateCrashSphere(Math::Vector pos, float radius, Sound sound, float hardness=0.45f);
int GetCrashSphereTotal();
bool GetCrashSphere(int rank, Math::Vector &pos, float &radius);
float GetCrashSphereHardness(int rank);
Sound GetCrashSphereSound(int rank);
void DeleteCrashSphere(int rank);
void SetGlobalSphere(Math::Vector pos, float radius);
void GetGlobalSphere(Math::Vector &pos, float &radius);
void SetJotlerSphere(Math::Vector pos, float radius);
void GetJotlerSphere(Math::Vector &pos, float &radius);
void SetShieldRadius(float radius);
float GetShieldRadius();
void SetFloorHeight(float height);
void FloorAdjust();
void SetLinVibration(Math::Vector dir);
Math::Vector GetLinVibration();
void SetCirVibration(Math::Vector dir);
Math::Vector GetCirVibration();
void SetInclinaison(Math::Vector dir);
Math::Vector GetInclinaison();
void SetPosition(int part, const Math::Vector &pos);
Math::Vector GetPosition(int part);
void SetAngle(int part, const Math::Vector &angle);
Math::Vector GetAngle(int part);
void SetAngleY(int part, float angle);
void SetAngleX(int part, float angle);
void SetAngleZ(int part, float angle);
float GetAngleY(int part);
float GetAngleX(int part);
float GetAngleZ(int part);
void SetZoom(int part, float zoom);
void SetZoom(int part, Math::Vector zoom);
Math::Vector GetZoom(int part);
void SetZoomX(int part, float zoom);
float GetZoomX(int part);
void SetZoomY(int part, float zoom);
float GetZoomY(int part);
void SetZoomZ(int part, float zoom);
float GetZoomZ(int part);
float GetWaterLevel();
void SetTrainer(bool bEnable);
bool GetTrainer();
void SetToy(bool bEnable);
bool GetToy();
void SetManual(bool bManual);
bool GetManual();
void SetResetCap(ResetCap cap);
ResetCap GetResetCap();
void SetResetBusy(bool bBusy);
bool GetResetBusy();
void SetResetPosition(const Math::Vector &pos);
Math::Vector GetResetPosition();
void SetResetAngle(const Math::Vector &angle);
Math::Vector GetResetAngle();
void SetResetRun(int run);
int GetResetRun();
void SetMasterParticle(int part, int parti);
int GetMasterParticle(int part);
void SetPower(CObject* power);
CObject* GetPower();
void SetFret(CObject* fret);
CObject* GetFret();
void SetTruck(CObject* truck);
CObject* GetTruck();
void SetTruckPart(int part);
int GetTruckPart();
void InfoFlush();
void DeleteInfo(int rank);
void SetInfo(int rank, Info info);
Info GetInfo(int rank);
int GetInfoTotal();
void SetInfoReturn(float value);
float GetInfoReturn();
void SetInfoUpdate(bool bUpdate);
bool GetInfoUpdate();
bool SetCmdLine(int rank, float value);
float GetCmdLine(int rank);
Math::Matrix* GetRotateMatrix(int part);
Math::Matrix* GetTranslateMatrix(int part);
Math::Matrix* GetTransformMatrix(int part);
Math::Matrix* GetWorldMatrix(int part);
void SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
Math::Vector &lookat, Math::Vector &upVec,
Gfx::CameraType type);
void SetCharacter(Character* character);
void GetCharacter(Character* character);
Character* GetCharacter();
float GetAbsTime();
void SetEnergy(float level);
float GetEnergy();
void SetCapacity(float capacity);
float GetCapacity();
void SetShield(float level);
float GetShield();
void SetRange(float delay);
float GetRange();
void SetTransparency(float value);
float GetTransparency();
ObjectMaterial GetMaterial();
void SetGadget(bool bMode);
bool GetGadget();
void SetFixed(bool bFixed);
bool GetFixed();
void SetClip(bool bClip);
bool GetClip();
bool JostleObject(float force);
void StartDetectEffect(CObject *target, bool bFound);
void SetVirusMode(bool bEnable);
bool GetVirusMode();
float GetVirusTime();
void SetCameraType(Gfx::CameraType type);
Gfx::CameraType GetCameraType();
void SetCameraDist(float dist);
float GetCameraDist();
void SetCameraLock(bool bLock);
bool GetCameraLock();
void SetHilite(bool bMode);
bool GetHilite();
void SetSelect(bool bMode, bool bDisplayError=true);
bool GetSelect(bool bReal=false);
void SetSelectable(bool bMode);
bool GetSelectable();
void SetActivity(bool bMode);
bool GetActivity();
void SetVisible(bool bVisible);
bool GetVisible();
void SetEnable(bool bEnable);
bool GetEnable();
void SetCheckToken(bool bMode);
bool GetCheckToken();
void SetProxyActivate(bool bActivate);
bool GetProxyActivate();
void SetProxyDistance(float distance);
float GetProxyDistance();
void SetMagnifyDamage(float factor);
float GetMagnifyDamage();
void SetParam(float value);
float GetParam();
void SetExplo(bool bExplo);
bool GetExplo();
void SetLock(bool bLock);
bool GetLock();
void SetCargo(bool bCargo);
bool GetCargo();
void SetBurn(bool bBurn);
bool GetBurn();
void SetDead(bool bDead);
bool GetDead();
bool GetRuin();
bool GetActif();
void SetGunGoalV(float gunGoal);
void SetGunGoalH(float gunGoal);
float GetGunGoalV();
float GetGunGoalH();
bool StartShowLimit();
void StopShowLimit();
bool IsProgram();
void CreateSelectParticle();
void SetRunScript(CScript* script);
CScript* GetRunScript();
CBotVar* GetBotVar();
CPhysics* GetPhysics();
CBrain* GetBrain();
CMotion* GetMotion();
CAuto* GetAuto();
void SetAuto(CAuto* automat);
void SetDefRank(int rank);
int GetDefRank();
bool GetTooltipName(char* name);
void AddDeselList(CObject* pObj);
CObject* SubDeselList();
void DeleteDeselList(CObject* pObj);
bool CreateShadowCircle(float radius, float intensity, Gfx::EngineShadowType type = Gfx::ENG_SHADOW_NORM);
bool CreateShadowLight(float height, Gfx::Color color);
bool CreateEffectLight(float height, Gfx::Color color);
void FlatParent();
bool GetTraceDown();
void SetTraceDown(bool bDown);
int GetTraceColor();
void SetTraceColor(int color);
float GetTraceWidth();
void SetTraceWidth(float width);
std::string GetModelDirName();
protected:
bool EventFrame(const Event &event);
void VirusFrame(float rTime);
void PartiFrame(float rTime);
void CreateOtherObject(ObjectType type);
void InitPart(int part);
void UpdateTotalPart();
int SearchDescendant(int parent, int n);
void UpdateEnergyMapping();
bool UpdateTransformObject(int part, bool bForceUpdate);
bool UpdateTransformObject();
void UpdateSelectParticle();
protected:
CInstanceManager* m_iMan;
CApplication* m_app;
Gfx::CEngine* m_engine;
Gfx::CLightManager* m_lightMan;
Gfx::CTerrain* m_terrain;
Gfx::CWater* m_water;
Gfx::CCamera* m_camera;
Gfx::CParticle* m_particle;
CPhysics* m_physics;
CBrain* m_brain;
CMotion* m_motion;
CAuto* m_auto;
Ui::CDisplayText* m_displayText;
CRobotMain* m_main;
CSoundInterface* m_sound;
CBotVar* m_botVar;
CScript* m_runScript;
ObjectType m_type; // OBJECT_*
int m_id; // unique identifier
char m_name[50]; // name of the object
Character m_character; // characteristic
int m_option; // option
int m_partiReactor; // number of the particle of the reactor
int m_shadowLight; // number of light from the shadows
float m_shadowHeight; // height of light from the shadows
int m_effectLight; // number of light effects
float m_effectHeight; // height of light effects
Math::Vector m_linVibration; // linear vibration
Math::Vector m_cirVibration; // circular vibration
Math::Vector m_inclinaison; // tilt
CObject* m_power; // battery used by the vehicle
CObject* m_fret; // object transported
CObject* m_truck; // object with the latter
int m_truckLink; // part
float m_energy; // energy contained (if battery)
float m_lastEnergy;
float m_capacity; // capacity (if battery)
float m_shield; // shield
float m_range; // flight range
float m_transparency; // transparency (0..1)
int m_material; // matter(0..n)
float m_aTime;
float m_shotTime; // time since last shot
bool m_bVirusMode; // virus activated/triggered
float m_virusTime; // lifetime of the virus
float m_lastVirusParticle;
float m_lastParticle;
bool m_bHilite;
bool m_bSelect; // object selected
bool m_bSelectable; // selectable object
bool m_bCheckToken; // object with audited tokens
bool m_bVisible; // object active but undetectable
bool m_bEnable; // dead object
bool m_bProxyActivate; // active object so close
bool m_bGadget; // object nonessential
bool m_bLock;
bool m_bExplo;
bool m_bCargo;
bool m_bBurn;
bool m_bDead;
bool m_bFlat;
bool m_bTrainer; // drive vehicle (without remote)
bool m_bToy; // toy key
bool m_bManual; // manual control (Scribbler)
bool m_bFixed;
bool m_bClip;
bool m_bShowLimit;
float m_showLimitRadius;
float m_gunGoalV;
float m_gunGoalH;
Gfx::CameraType m_cameraType;
float m_cameraDist;
bool m_bCameraLock;
int m_defRank;
float m_magnifyDamage;
float m_proxyDistance;
float m_param;
int m_crashSphereUsed; // number of spheres used
Math::Vector m_crashSpherePos[MAXCRASHSPHERE];
float m_crashSphereRadius[MAXCRASHSPHERE];
float m_crashSphereHardness[MAXCRASHSPHERE];
Sound m_crashSphereSound[MAXCRASHSPHERE];
Math::Vector m_globalSpherePos;
float m_globalSphereRadius;
Math::Vector m_jotlerSpherePos;
float m_jotlerSphereRadius;
float m_shieldRadius;
int m_totalPart;
ObjectPart m_objectPart[OBJECTMAXPART];
int m_totalDesectList;
CObject* m_objectDeselectList[OBJECTMAXDESELLIST];
int m_partiSel[4];
ResetCap m_resetCap;
bool m_bResetBusy;
Math::Vector m_resetPosition;
Math::Vector m_resetAngle;
int m_resetRun;
int m_infoTotal;
Info m_info[OBJECTMAXINFO];
float m_infoReturn;
bool m_bInfoUpdate;
float m_cmdLine[OBJECTMAXCMDLINE];
};
|