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-2015, 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/event.h"
29 #include "common/error.h"
30 
31 #include "graphics/core/color.h"
32 
34 
35 #include "math/sphere.h"
36 
37 #include "object/object_type.h"
38 
39 #include <vector>
40 
41 class CObject;
42 class CRobotMain;
43 class CSoundInterface;
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 CLight;
55 class CLightManager;
56 
63 class CPyro
64 {
65 protected:
66  friend class CPyroManager;
67 
69  bool Create(PyroType type, CObject* obj, float force);
71  void DeleteObject();
72 
73 public:
74  CPyro(); // should only be called by CPyroManager
75  ~CPyro();
76 
78  Error IsEnded();
79 
81  void CutObjectLink(CObject* obj);
82 
84  bool EventProcess(const Event& event);
85 
86 protected:
89  void DisplayError(PyroType type, CObject* obj);
90 
92  void CreateLight(Math::Vector pos, float height);
94  void DeleteObject(bool primary, bool secondary);
95 
97  void CreateTriangle(CObject* obj, ObjectType type, int part);
98 
100  void ExploStart();
102  void ExploTerminate();
103 
105  void BurnStart();
107  void BurnAddPart(int part, Math::Vector pos, Math::Vector angle);
109  void BurnProgress();
111  bool BurnIsKeepPart(int part);
113  void BurnTerminate();
114 
116  void FallStart();
120  void FallProgress(float rTime);
122  Error FallIsEnded();
123 
125  void LightOperFlush();
127  void LightOperAdd(float progress, float intensity, float r, float g, float b);
129  void LightOperFrame(float rTime);
130 
131 protected:
132  CEngine* m_engine = nullptr;
133  CTerrain* m_terrain = nullptr;
134  CCamera* m_camera = nullptr;
135  CParticle* m_particle = nullptr;
136  CLightManager* m_lightMan = nullptr;
137  CObject* m_object = nullptr;
138  CRobotMain* m_main = nullptr;
139  CSoundInterface* m_sound = nullptr;
140 
141  Math::Vector m_pos; // center of the effect
142  Math::Vector m_posPower; // center of the battery
143  bool m_power = false; // battery exists?
144  PyroType m_type = PT_NULL;
145  float m_force = 0.0f;
146  float m_size = 0.0f;
147  float m_progress = 0.0f;
148  float m_speed = 0.0f;
149  float m_time = 0.0f;
150  float m_lastParticle = 0.0f;
151  float m_lastParticleSmoke = 0.0f;
152  int m_soundChannel = -1;
153 
154  int m_lightRank = -1;
155  float m_lightHeight = 0.0f;
156 
158  {
159  float progress = 0.0f;
160  float intensity = 0.0f;
161  Color color;
162  };
163  std::vector<PyroLightOper> m_lightOper;
164 
165  ObjectType m_burnType = OBJECT_NULL;
166  int m_burnPartTotal = 0;
167 
169  {
170  int part = 0;
171  Math::Vector initialPos;
172  Math::Vector finalPos;
173  Math::Vector initialAngle;
174  Math::Vector finalAngle;
175  };
176  PyroBurnPart m_burnPart[10];
177  int m_burnKeepPart[10] = {};
178  float m_burnFall = 0.0f;
179 
180  float m_fallFloor = 0.0f;
181  float m_fallSpeed = 0.0f;
182  float m_fallBulletTime = 0.0f;
183  bool m_fallEnding = false;
184 
185  std::vector<Math::Sphere> m_crashSpheres;
186  float m_resetAngle = 0.0f;
187 };
188 
189 
190 } // namespace Gfx
bool EventProcess(const Event &event)
Management of an event.
Definition: pyro.cpp:604
void DeleteObject()
Destroys the object.
Definition: pyro.cpp:65
void ExploStart()
Starts the explosion of a vehicle.
Definition: pyro.cpp:1530
void LightOperFlush()
Empty the table of operations of animation of light.
Definition: pyro.cpp:2325
void DisplayError(PyroType type, CObject *obj)
Definition: pyro.cpp:1231
Error FallIsEnded()
Indicates whether the fall is over.
Definition: pyro.cpp:2312
void ExploTerminate()
Ends the explosion of a vehicle.
Definition: pyro.cpp:1601
void LightOperFrame(float rTime)
Updates the associated light.
Definition: pyro.cpp:2343
void BurnStart()
Starts a vehicle fire.
Definition: pyro.cpp:1606
void FallProgress(float rTime)
Fall of an object's freight.
Definition: pyro.cpp:2244
Manager for dynamic lights in 3D scene.
Definition: lightman.h:146
Definition: pyro.h:157
CObject * FallSearchBeeExplo()
Seeks an object to explode by the falling ball of bees.
Definition: pyro.cpp:2193
Fire effect renderer.
Definition: pyro.h:63
ObjectType enum.
Definition: robotmain.h:151
PyroType
Type of pyro effect.
Definition: pyro_type.h:34
Particle engine.
Definition: particle.h:223
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:2079
Definition: pyro.h:168
void CutObjectLink(CObject *obj)
Indicates that the object binds to the effect no longer exists, without deleting it.
Definition: pyro.cpp:1225
void BurnProgress()
Advances of a vehicle fire.
Definition: pyro.cpp:2095
void CreateLight(Math::Vector pos, float height)
Creates light to accompany a pyrotechnic effect.
Definition: pyro.cpp:1312
bool BurnIsKeepPart(int part)
Indicates whether a part should be retained.
Definition: pyro.cpp:2125
Camera moving in 3D scene.
Definition: camera.h:134
Terrain loader/generator and manager.
Definition: terrain.h:145
Error IsEnded()
Indicates whether the pyrotechnic effect is complete.
Definition: pyro.cpp:1155
PyroType enum.
Namespace for (new) graphics code.
Definition: app.h:49
The graphics engine.
Definition: engine.h:620
Event types, structs and event queue.
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:2330
3D (3x1) vector
Definition: vector.h:53
void BurnTerminate()
Ends the fire of an insect or a vehicle.
Definition: pyro.cpp:2135
void CreateTriangle(CObject *obj, ObjectType type, int part)
Creates an explosion with triangular form of particles.
Definition: pyro.cpp:1400
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:2182
RGBA color.
Definition: color.h:39
Event sent by system, interface or game.
Definition: event.h:709
Base class for all 3D in-game objects.
Definition: object.h:59
Sound plugin interface.
Definition: sound.h:57