Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
taskshield.h
1 // * This file is part of the COLOBOT source code
2 // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
3 // *
4 // * This program is free software: you can redistribute it and/or modify
5 // * it under the terms of the GNU General Public License as published by
6 // * the Free Software Foundation, either version 3 of the License, or
7 // * (at your option) any later version.
8 // *
9 // * This program is distributed in the hope that it will be useful,
10 // * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // * GNU General Public License for more details.
13 // *
14 // * You should have received a copy of the GNU General Public License
15 // * along with this program. If not, see http://www.gnu.org/licenses/.
16 
17 // taskshield.h
18 
19 #pragma once
20 
21 
22 #include "object/task/task.h"
23 
24 #include "math/vector.h"
25 
26 
27 const float RADIUS_SHIELD_MIN = 40.0f; // minimum radius of the protected zone
28 const float RADIUS_SHIELD_MAX = 100.0f; // maximum radius of the protected zone
29 
30 
31 enum TaskShieldPhase
32 {
33  TS_UP1 = 1, // up
34  TS_UP2 = 2, // up
35  TS_SHIELD = 3, // shield deployed
36  TS_SMOKE = 4, // smoke
37  TS_DOWN1 = 5, // down
38  TS_DOWN2 = 6, // down
39 };
40 
41 enum TaskShieldMode
42 {
43  TSM_UP = 1, // deploys shield
44  TSM_DOWN = 2, // returns the shield
45  TSM_UPDATE = 3, // radius change
46 };
47 
48 
49 
50 class CTaskShield : public CTask
51 {
52 public:
53  CTaskShield(CObject* object);
54  ~CTaskShield();
55 
56  bool EventProcess(const Event &event);
57 
58  Error Start(TaskShieldMode mode, float delay);
59  Error IsEnded();
60  bool IsBusy();
61  bool Abort();
62 
63 protected:
64  Error Stop();
65  bool CreateLight(Math::Vector pos);
66  void IncreaseShield();
67  float GetRadius();
68 
69 protected:
70  TaskShieldPhase m_phase;
71  float m_progress;
72  float m_speed;
73  float m_time;
74  float m_delay;
75  float m_lastParticle;
76  float m_lastRay;
77  float m_lastIncrease;
78  float m_energyUsed;
79  bool m_bError;
80  Math::Vector m_shieldPos;
81  int m_rankSphere;
82  int m_soundChannel;
83  int m_effectLight;
84 };
85