Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
pyro.h
Go to the documentation of this file.
1 // * This file is part of the COLOBOT source code
2 // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
3 // * Copyright (C) 2012, Polish Portal of Colobot (PPC)
4 // *
5 // * This program is free software: you can redistribute it and/or modify
6 // * it under the terms of the GNU General Public License as published by
7 // * the Free Software Foundation, either version 3 of the License, or
8 // * (at your option) any later version.
9 // *
10 // * This program is distributed in the hope that it will be useful,
11 // * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // * GNU General Public License for more details.
14 // *
15 // * You should have received a copy of the GNU General Public License
16 // * along with this program. If not, see http://www.gnu.org/licenses/.
17 
23 #pragma once
24 
25 
26 #include "common/event.h"
27 #include "common/global.h"
28 
29 #include "graphics/engine/engine.h"
30 
31 #include "object/object.h"
32 
33 
34 class CObject;
35 class CRobotMain;
36 class CSoundInterface;
37 
38 
39 // Graphics module namespace
40 namespace Gfx {
41 
42 class CEngine;
43 class CTerrain;
44 class CCamera;
45 class CParticle;
46 class CLight;
47 
48 
54 {
55  PT_NULL = 0,
56  PT_FRAGT = 1,
57  PT_FRAGO = 2,
58  PT_FRAGW = 4,
59  PT_EXPLOT = 5,
60  PT_EXPLOO = 6,
61  PT_EXPLOW = 8,
62  PT_SHOTT = 9,
63  PT_SHOTH = 10,
64  PT_SHOTM = 11,
65  PT_SHOTW = 12,
66  PT_EGG = 13,
67  PT_BURNT = 14,
68  PT_BURNO = 15,
69  PT_SPIDER = 16,
70  PT_FALL = 17,
71  PT_WPCHECK = 18,
72  PT_FLCREATE = 19,
73  PT_FLDELETE = 20,
74  PT_RESET = 21,
75  PT_WIN = 22,
76  PT_LOST = 23,
77  PT_DEADG = 24,
78  PT_DEADW = 25,
79  PT_FINDING = 26,
80 };
81 
82 
84 {
85  int part;
86  Math::Vector initialPos;
87  Math::Vector finalPos;
88  Math::Vector initialAngle;
89  Math::Vector finalAngle;
90 };
91 
93 {
94  float progress;
95  float intensity;
96  Color color;
97 };
98 
99 
106 class CPyro
107 {
108 public:
109  CPyro();
110  ~CPyro();
111 
113  bool Create(PyroType type, CObject* obj, float force=1.0f);
115  void DeleteObject();
116 
118  Error IsEnded();
119 
121  void CutObjectLink(CObject* obj);
122 
124  bool EventProcess(const Event& event);
125 
126 protected:
129  void DisplayError(PyroType type, CObject* obj);
130 
132  void CreateLight(Math::Vector pos, float height);
134  void DeleteObject(bool primary, bool secondary);
135 
137  void CreateTriangle(CObject* obj, ObjectType type, int part);
138 
140  void ExploStart();
142  void ExploTerminate();
143 
145  void BurnStart();
147  void BurnAddPart(int part, Math::Vector pos, Math::Vector angle);
149  void BurnProgress();
151  bool BurnIsKeepPart(int part);
153  void BurnTerminate();
154 
156  void FallStart();
160  void FallProgress(float rTime);
162  Error FallIsEnded();
163 
165  void LightOperFlush();
167  void LightOperAdd(float progress, float intensity, float r, float g, float b);
169  void LightOperFrame(float rTime);
170 
171 protected:
172  CEngine* m_engine;
173  CTerrain* m_terrain;
174  CCamera* m_camera;
175  CParticle* m_particle;
176  CLightManager* m_lightMan;
177  CObject* m_object;
178  CRobotMain* m_main;
179  CSoundInterface* m_sound;
180 
181  Math::Vector m_pos; // center of the effect
182  Math::Vector m_posPower; // center of the battery
183  bool m_power; // battery exists?
184  PyroType m_type;
185  float m_force;
186  float m_size;
187  float m_progress;
188  float m_speed;
189  float m_time;
190  float m_lastParticle;
191  float m_lastParticleSmoke;
192  int m_soundChannel;
193 
194  int m_lightRank;
195  int m_lightOperTotal;
196  PyroLightOper m_lightOper[10];
197  float m_lightHeight;
198 
199  ObjectType m_burnType;
200  int m_burnPartTotal;
201  PyroBurnPart m_burnPart[10];
202  int m_burnKeepPart[10];
203  float m_burnFall;
204 
205  float m_fallFloor;
206  float m_fallSpeed;
207  float m_fallBulletTime;
208  bool m_fallEnding;
209 
210  int m_crashSphereUsed; // number of spheres used
211  Math::Vector m_crashSpherePos[50];
212  float m_crashSphereRadius[50];
213 };
214 
215 
216 } // namespace Gfx
217