Colobot
pyro.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
25 #pragma once
26 
27 
28 #include "common/event.h"
29 #include "common/global.h"
30 
31 #include "graphics/engine/engine.h"
32 
33 #include "object/object.h"
34 
35 
36 class CObject;
37 class CRobotMain;
38 class CSoundInterface;
39 
40 
41 // Graphics module namespace
42 namespace Gfx {
43 
44 class CEngine;
45 class CTerrain;
46 class CCamera;
47 class CParticle;
48 class CLight;
49 
50 
56 {
57  PT_NULL = 0,
58  PT_FRAGT = 1,
59  PT_FRAGO = 2,
60  PT_FRAGW = 4,
61  PT_EXPLOT = 5,
62  PT_EXPLOO = 6,
63  PT_EXPLOW = 8,
64  PT_SHOTT = 9,
65  PT_SHOTH = 10,
66  PT_SHOTM = 11,
67  PT_SHOTW = 12,
68  PT_EGG = 13,
69  PT_BURNT = 14,
70  PT_BURNO = 15,
71  PT_SPIDER = 16,
72  PT_FALL = 17,
73  PT_WPCHECK = 18,
74  PT_FLCREATE = 19,
75  PT_FLDELETE = 20,
76  PT_RESET = 21,
77  PT_WIN = 22,
78  PT_LOST = 23,
79  PT_DEADG = 24,
80  PT_DEADW = 25,
81  PT_FINDING = 26,
82 };
83 
84 
86 {
87  int part;
88  Math::Vector initialPos;
89  Math::Vector finalPos;
90  Math::Vector initialAngle;
91  Math::Vector finalAngle;
92 };
93 
95 {
96  float progress;
97  float intensity;
98  Color color;
99 };
100 
101 
108 class CPyro
109 {
110 public:
111  CPyro();
112  ~CPyro();
113 
115  bool Create(PyroType type, CObject* obj, float force=1.0f);
117  void DeleteObject();
118 
120  Error IsEnded();
121 
123  void CutObjectLink(CObject* obj);
124 
126  bool EventProcess(const Event& event);
127 
128 protected:
131  void DisplayError(PyroType type, CObject* obj);
132 
134  void CreateLight(Math::Vector pos, float height);
136  void DeleteObject(bool primary, bool secondary);
137 
139  void CreateTriangle(CObject* obj, ObjectType type, int part);
140 
142  void ExploStart();
144  void ExploTerminate();
145 
147  void BurnStart();
149  void BurnAddPart(int part, Math::Vector pos, Math::Vector angle);
151  void BurnProgress();
153  bool BurnIsKeepPart(int part);
155  void BurnTerminate();
156 
158  void FallStart();
162  void FallProgress(float rTime);
164  Error FallIsEnded();
165 
167  void LightOperFlush();
169  void LightOperAdd(float progress, float intensity, float r, float g, float b);
171  void LightOperFrame(float rTime);
172 
173 protected:
174  CEngine* m_engine;
175  CTerrain* m_terrain;
176  CCamera* m_camera;
177  CParticle* m_particle;
178  CLightManager* m_lightMan;
179  CObject* m_object;
180  CRobotMain* m_main;
181  CSoundInterface* m_sound;
182 
183  Math::Vector m_pos; // center of the effect
184  Math::Vector m_posPower; // center of the battery
185  bool m_power; // battery exists?
186  PyroType m_type;
187  float m_force;
188  float m_size;
189  float m_progress;
190  float m_speed;
191  float m_time;
192  float m_lastParticle;
193  float m_lastParticleSmoke;
194  int m_soundChannel;
195 
196  int m_lightRank;
197  int m_lightOperTotal;
198  PyroLightOper m_lightOper[10];
199  float m_lightHeight;
200 
201  ObjectType m_burnType;
202  int m_burnPartTotal;
203  PyroBurnPart m_burnPart[10];
204  int m_burnKeepPart[10];
205  float m_burnFall;
206 
207  float m_fallFloor;
208  float m_fallSpeed;
209  float m_fallBulletTime;
210  bool m_fallEnding;
211 
212  int m_crashSphereUsed; // number of spheres used
213  Math::Vector m_crashSpherePos[50];
214  float m_crashSphereRadius[50];
215 };
216 
217 
218 } // namespace Gfx
219 
bool EventProcess(const Event &event)
Management of an event.
Definition: pyro.cpp:622
void DeleteObject()
Destroys the object.
Definition: pyro.cpp:68
void ExploStart()
Starts the explosion of a vehicle.
Definition: pyro.cpp:1550
< black smoke
Definition: pyro.h:79
< burning of technical object
Definition: pyro.h:70
void LightOperFlush()
Empty the table of operations of animation of light.
Definition: pyro.cpp:2394
< spider explosion
Definition: pyro.h:72
Main graphics engine - CEngine class.
void DisplayError(PyroType type, CObject *obj)
Definition: pyro.cpp:1248
< explosion of organic object
Definition: pyro.h:63
< cargo falling
Definition: pyro.h:73
Error FallIsEnded()
Indicates whether the fall is over.
Definition: pyro.cpp:2381
void ExploTerminate()
Ends the explosion of a vehicle.
Definition: pyro.cpp:1618
void LightOperFrame(float rTime)
Updates the associated light.
Definition: pyro.cpp:2412
< indicator reaches
Definition: pyro.h:74
void BurnStart()
Starts a vehicle fire.
Definition: pyro.cpp:1623
void FallProgress(float rTime)
Fall of an object's freight.
Definition: pyro.cpp:2316
< fragmentation of object under water
Definition: pyro.h:61
Some common, global definitions.
< drowning death
Definition: pyro.h:81
< hit technical object
Definition: pyro.h:65
< explosion of technical object
Definition: pyro.h:62
< hit under water
Definition: pyro.h:68
Manager for dynamic lights in 3D scene.
Definition: lightman.h:144
CObject * FallSearchBeeExplo()
Seeks an object to explode by the falling ball of bees.
Definition: pyro.cpp:2215
Fire effect renderer.
Definition: pyro.h:108
Definition: robotmain.h:172
PyroType
Type of pyro effect.
Definition: pyro.h:55
Particle engine.
Definition: particle.h:268
< fireworks
Definition: pyro.h:78
< shooting death
Definition: pyro.h:80
ObjectType
Type of game object.
Definition: object.h:51
void BurnAddPart(int part, Math::Vector pos, Math::Vector angle)
Adds a part move.
Definition: pyro.cpp:2105
void CutObjectLink(CObject *obj)
Indicates that the object binds to the effect no longer exists, without deleting it.
Definition: pyro.cpp:1242
void BurnProgress()
Advances of a vehicle fire.
Definition: pyro.cpp:2117
void CreateLight(Math::Vector pos, float height)
Creates light to accompany a pyrotechnic effect.
Definition: pyro.cpp:1329
bool BurnIsKeepPart(int part)
Indicates whether a part should be retained.
Definition: pyro.cpp:2144
< reset position of the object
Definition: pyro.h:77
Camera moving in 3D scene.
Definition: camera.h:133
< hit human
Definition: pyro.h:66
Terrain loader/generator and manager.
Definition: terrain.h:222
Error IsEnded()
Indicates whether the pyrotechnic effect is complete.
Definition: pyro.cpp:1171
Namespace for (new) graphics code.
Definition: app.h:49
CObject - base class for all game objects.
The graphics engine.
Definition: engine.h:684
< fragmentation of organic object
Definition: pyro.h:60
< hit queen
Definition: pyro.h:67
Event types, structs and event queue.
Error
Type of error or info message.
Definition: global.h:32
< break the egg
Definition: pyro.h:69
< flag create
Definition: pyro.h:75
< explosion of object under water
Definition: pyro.h:64
void LightOperAdd(float progress, float intensity, float r, float g, float b)
Adds an animation operation of the light.
Definition: pyro.cpp:2399
3D (3x1) vector
Definition: vector.h:52
void BurnTerminate()
Ends the fire of an insect or a vehicle.
Definition: pyro.cpp:2154
void CreateTriangle(CObject *obj, ObjectType type, int part)
Creates an explosion with triangular form of particles.
Definition: pyro.cpp:1410
void FallStart()
Start of an object freight falling.
Definition: pyro.cpp:2204
bool Create(PyroType type, CObject *obj, float force=1.0f)
Creates pyrotechnic effect.
Definition: pyro.cpp:77
RGBA color.
Definition: color.h:38
< flag destroy
Definition: pyro.h:76
Event sent by system, interface or game.
Definition: event.h:678
Definition: pyro.h:85
Definition: object.h:357
Sound plugin interface.
Definition: sound.h:151
< fragmentation of technical object
Definition: pyro.h:59
Definition: pyro.h:94
< burning of organic object
Definition: pyro.h:71