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-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.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/error.h"
29 
30 #include "graphics/core/color.h"
31 
33 
34 #include "math/sphere.h"
35 
36 #include "object/object_type.h"
37 
38 #include <vector>
39 
40 class CObject;
41 class CRobotMain;
42 class CSoundInterface;
43 struct Event;
44 
45 
46 // Graphics module namespace
47 namespace Gfx
48 {
49 
50 class CEngine;
51 class CTerrain;
52 class CCamera;
53 class CParticle;
54 class CLightManager;
55 
62 class CPyro
63 {
64 protected:
65  friend class CPyroManager;
66 
68  bool Create(PyroType type, CObject* obj, float force);
70  void DeleteObject();
71 
72 public:
73  CPyro(); // should only be called by CPyroManager
74  ~CPyro();
75 
77  Error IsEnded();
78 
80  void CutObjectLink(CObject* obj);
81 
83  bool EventProcess(const Event& event);
84 
85 protected:
88  void DisplayError(PyroType type, CObject* obj);
89 
91  void CreateLight(Math::Vector pos, float height);
93  void DeleteObject(bool primary, bool secondary);
94 
96  void CreateTriangle(CObject* obj, ObjectType oType, int part);
97 
99  void ExploStart();
101  void ExploTerminate();
102 
104  void BurnStart();
106  void BurnAddPart(int part, Math::Vector pos, Math::Vector angle);
108  void BurnProgress();
110  bool BurnIsKeepPart(int part);
112  void BurnTerminate();
113 
115  void FallStart();
119  void FallProgress(float rTime);
121  Error FallIsEnded();
122 
124  void LightOperFlush();
126  void LightOperAdd(float progress, float intensity, float r, float g, float b);
128  void LightOperFrame(float rTime);
129 
130 protected:
131  CEngine* m_engine = nullptr;
132  CTerrain* m_terrain = nullptr;
133  CCamera* m_camera = nullptr;
134  CParticle* m_particle = nullptr;
135  CLightManager* m_lightMan = nullptr;
136  CObject* m_object = nullptr;
137  CRobotMain* m_main = nullptr;
138  CSoundInterface* m_sound = nullptr;
139 
140  Math::Vector m_pos; // center of the effect
141  Math::Vector m_posPower; // center of the battery
142  bool m_power = false; // battery exists?
143  PyroType m_type = PT_NULL;
144  float m_force = 0.0f;
145  float m_size = 0.0f;
146  float m_progress = 0.0f;
147  float m_speed = 0.0f;
148  float m_time = 0.0f;
149  float m_lastParticle = 0.0f;
150  float m_lastParticleSmoke = 0.0f;
151  int m_soundChannel = -1;
152 
153  int m_lightRank = -1;
154  float m_lightHeight = 0.0f;
155 
157  {
158  float progress = 0.0f;
159  float intensity = 0.0f;
160  Color color;
161  };
162  std::vector<PyroLightOper> m_lightOper;
163 
164  ObjectType m_burnType = OBJECT_NULL;
165  int m_burnPartTotal = 0;
166 
168  {
169  int part = 0;
170  Math::Vector initialPos;
171  Math::Vector finalPos;
172  Math::Vector initialAngle;
173  Math::Vector finalAngle;
174  };
175  PyroBurnPart m_burnPart[10];
176  int m_burnKeepPart[10] = {};
177  float m_burnFall = 0.0f;
178 
179  float m_fallFloor = 0.0f;
180  float m_fallSpeed = 0.0f;
181  float m_fallBulletTime = 0.0f;
182  bool m_fallEnding = false;
183 
184  std::vector<Math::Sphere> m_crashSpheres;
185  float m_resetAngle = 0.0f;
186 };
187 
188 
189 } // namespace Gfx
bool EventProcess(const Event &event)
Management of an event.
Definition: pyro.cpp:612
void DeleteObject()
Destroys the object.
Definition: pyro.cpp:65
void ExploStart()
Starts the explosion of a vehicle.
Definition: pyro.cpp:1539
void LightOperFlush()
Empty the table of operations of animation of light.
Definition: pyro.cpp:2348
void DisplayError(PyroType type, CObject *obj)
Definition: pyro.cpp:1239
Error FallIsEnded()
Indicates whether the fall is over.
Definition: pyro.cpp:2335
void ExploTerminate()
Ends the explosion of a vehicle.
Definition: pyro.cpp:1610
void LightOperFrame(float rTime)
Updates the associated light.
Definition: pyro.cpp:2366
void BurnStart()
Starts a vehicle fire.
Definition: pyro.cpp:1615
void FallProgress(float rTime)
Fall of an object&#39;s freight.
Definition: pyro.cpp:2267
Manager for dynamic lights in 3D scene.
Definition: lightman.h:146
Definition: pyro.h:156
CObject * FallSearchBeeExplo()
Seeks an object to explode by the falling ball of bees.
Definition: pyro.cpp:2216
Fire effect renderer.
Definition: pyro.h:62
ObjectType enum.
Definition: robotmain.h:159
PyroType
Type of pyro effect.
Definition: pyro_type.h:34
Particle engine.
Definition: particle.h:223
void CreateTriangle(CObject *obj, ObjectType oType, int part)
Creates an explosion with triangular form of particles.
Definition: pyro.cpp:1408
Definition: pyro_manager.h:41
Color structs and related functions.
void BurnAddPart(int part, Math::Vector pos, Math::Vector angle)
Adds a part move.
Definition: pyro.cpp:2097
Definition: pyro.h:167
void CutObjectLink(CObject *obj)
Indicates that the object binds to the effect no longer exists, without deleting it.
Definition: pyro.cpp:1233
void BurnProgress()
Advances of a vehicle fire.
Definition: pyro.cpp:2113
void CreateLight(Math::Vector pos, float height)
Creates light to accompany a pyrotechnic effect.
Definition: pyro.cpp:1320
bool BurnIsKeepPart(int part)
Indicates whether a part should be retained.
Definition: pyro.cpp:2148
Camera moving in 3D scene.
Definition: camera.h:128
Terrain loader/generator and manager.
Definition: terrain.h:147
Error IsEnded()
Indicates whether the pyrotechnic effect is complete.
Definition: pyro.cpp:1163
PyroType enum.
Namespace for (new) graphics code.
Definition: app.h:49
The graphics engine.
Definition: engine.h:585
ObjectType
Type of game object.
Definition: object_type.h:33
void LightOperAdd(float progress, float intensity, float r, float g, float b)
Adds an animation operation of the light.
Definition: pyro.cpp:2353
3D (3x1) vector
Definition: vector.h:53
void BurnTerminate()
Ends the fire of an insect or a vehicle.
Definition: pyro.cpp:2158
bool Create(PyroType type, CObject *obj, float force)
Creates pyrotechnic effect.
Definition: pyro.cpp:74
void FallStart()
Start of an object freight falling.
Definition: pyro.cpp:2205
RGBA color.
Definition: color.h:39
Event sent by system, interface or game.
Definition: event.h:735
Base class for all 3D in-game objects.
Definition: object.h:63
Sound plugin interface.
Definition: sound.h:60