Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
lightning.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 
30 #include "math/vector.h"
31 
32 
33 class CObject;
34 class CSoundInterface;
35 
36 
37 // Graphics module namespace
38 namespace Gfx {
39 
40 class CEngine;
41 class CTerrain;
42 class CCamera;
43 
45 const float LTNG_PROTECTION_RADIUS = 200.0f;
46 
47 
55 {
56 public:
57  CLightning(CEngine* engine);
58  ~CLightning();
59 
61  bool Create(float sleep, float delay, float magnetic);
62 
64  void Flush();
65 
67  bool GetStatus(float &sleep, float &delay, float &magnetic, float &progress);
69  bool SetStatus(float sleep, float delay, float magnetic, float progress);
70 
72  bool EventProcess(const Event &event);
73 
75  void Draw();
76 
77 protected:
79  bool EventFrame(const Event &event);
82 
83 protected:
84  CEngine* m_engine;
85  CTerrain* m_terrain;
86  CCamera* m_camera;
87  CSoundInterface* m_sound;
88 
89  bool m_lightningExists;
90  float m_sleep;
91  float m_delay;
92  float m_magnetic;
93 
94  float m_speed;
95  float m_progress;
96  Math::Vector m_pos;
97 
98  enum LightningPhase
99  {
100  LP_WAIT,
101  LP_FLASH,
102  };
103  LightningPhase m_phase;
104 
105  static const short FLASH_SEGMENTS = 50;
106  Math::Point m_shift[FLASH_SEGMENTS];
107  float m_width[FLASH_SEGMENTS];
108 };
109 
110 
111 } // namespace Gfx
112 
void Flush()
Removes lightning.
Definition: lightning.cpp:58
bool GetStatus(float &sleep, float &delay, float &magnetic, float &progress)
Gives the status of lightning.
Definition: lightning.cpp:203
Lightning effect renderer.
Definition: lightning.h:54
2D point
Definition: point.h:49
Camera moving in 3D scene.
Definition: camera.h:133
const float LTNG_PROTECTION_RADIUS
Radius of lightning protection.
Definition: lightning.h:45
Terrain loader/generator and manager.
Definition: terrain.h:222
bool EventFrame(const Event &event)
Updates lightning.
Definition: lightning.cpp:80
Namespace for (new) graphics code.
Definition: app.h:49
void Draw()
Draws lightning.
Definition: lightning.cpp:229
Vector struct and related functions.
The graphics engine.
Definition: engine.h:684
Event types, structs and event queue.
CObject * SearchObject(Math::Vector pos)
Seeks for the object closest to the lightning.
Definition: lightning.cpp:309
3D (3x1) vector
Definition: vector.h:52
Event sent by system, interface or game.
Definition: event.h:678
Definition: object.h:357
bool SetStatus(float sleep, float delay, float magnetic, float progress)
Specifies the status of lightning.
Definition: lightning.cpp:215
bool EventProcess(const Event &event)
Management of an event.
Definition: lightning.cpp:72
Sound plugin interface.
Definition: sound.h:151
bool Create(float sleep, float delay, float magnetic)
Triggers lightning.
Definition: lightning.cpp:179