Colobot
taskshield.h
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 
20 #pragma once
21 
22 
23 #include "object/task/task.h"
24 
25 #include "math/vector.h"
26 
27 
28 const float RADIUS_SHIELD_MIN = 40.0f; // minimum radius of the protected zone
29 const float RADIUS_SHIELD_MAX = 100.0f; // maximum radius of the protected zone
30 
31 
32 enum TaskShieldPhase
33 {
34  TS_UP1 = 1, // up
35  TS_UP2 = 2, // up
36  TS_SHIELD = 3, // shield deployed
37  TS_SMOKE = 4, // smoke
38  TS_DOWN1 = 5, // down
39  TS_DOWN2 = 6, // down
40 };
41 
42 enum TaskShieldMode
43 {
44  TSM_UP = 1, // deploys shield
45  TSM_DOWN = 2, // returns the shield
46  TSM_UPDATE = 3, // radius change
47  TSM_START = 4, // start with shield up
48 };
49 
50 class CShielder;
51 
52 
53 
55 {
56 public:
57  CTaskShield(COldObject* object);
58  ~CTaskShield();
59 
60  bool EventProcess(const Event &event) override;
61 
62  Error Start(TaskShieldMode mode, float delay);
63  Error IsEnded() override;
64  bool IsBusy() override;
65  bool Abort() override;
66 
67  float GetActiveRadius();
68 
69 protected:
70  Error Stop();
71  bool CreateLight(Math::Vector pos);
72  void IncreaseShield();
73  float GetRadius();
74 
75 protected:
76  CShielder* m_shielder;
77  TaskShieldPhase m_phase = TS_UP1;
78  float m_progress = 0.0f;
79  float m_speed = 0.0f;
80  float m_time = 0.0f;
81  float m_delay = 0.0f;
82  float m_lastParticle = 0.0f;
83  float m_lastRay = 0.0f;
84  float m_lastIncrease = 0.0f;
85  float m_energyUsed = 0.0f;
86  bool m_bError = false;
87  Math::Vector m_shieldPos;
88  int m_rankSphere = 0;
89  int m_soundChannel = 0;
90  int m_effectLight = 0;
91 };
Definition: old_object.h:79
Definition: taskshield.h:54
Definition: shielder.h:32
Vector struct and related functions.
Definition: task.h:103
3D (3x1) vector
Definition: vector.h:53
Event sent by system, interface or game.
Definition: event.h:735