Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
taskbuild.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 // taskbuild.h
18 
19 #pragma once
20 
21 
22 #include "object/task/task.h"
23 #include "object/object.h"
24 #include "math/vector.h"
25 
26 
27 
28 const float BUILDMARGIN = 16.0f;
29 const int TBMAXLIGHT = 4;
30 
31 
32 enum TaskBuildPhase
33 {
34  TBP_TURN = 1, // turns
35  TBP_MOVE = 2, // forward/backward
36  TBP_TAKE = 3, // takes gun
37  TBP_PREP = 4, // prepares
38  TBP_BUILD = 5, // builds
39  TBP_TERM = 6, // ends
40  TBP_RECEDE = 7, // back terminal
41 };
42 
43 
44 
45 class CTaskBuild : public CTask
46 {
47 public:
48  CTaskBuild(CObject* object);
49  ~CTaskBuild();
50 
51  bool EventProcess(const Event &event);
52 
53  Error Start(ObjectType type);
54  Error IsEnded();
55  bool Abort();
56 
57 protected:
58  Error FlatFloor();
59  bool CreateBuilding(Math::Vector pos, float angle);
60  void CreateLight();
61  void BlackLight();
62  CObject* SearchMetalObject(float &angle, float dMin, float dMax, float aLimit, Error &err);
63  void DeleteMark(Math::Vector pos, float radius);
64 
65 protected:
66  ObjectType m_type; // type of construction
67  CObject* m_metal; // transforms metal object
68  CObject* m_power; // the vehicle battery
69  CObject* m_building; // building built
70  TaskBuildPhase m_phase; // phase of the operation
71  bool m_bError; // true -> operation impossible
72  bool m_bBuild; // true -> building built
73  bool m_bBlack; // true -> lights black -> white
74  float m_time; // absolute time
75  float m_lastParticle; // time of generation last particle
76  float m_progress; // progression (0..1)
77  float m_speed; // speed of progression
78  float m_angleY; // rotation angle of the vehicle
79  float m_angleZ; // angle of rotation of the gun
80  Math::Vector m_buildingPos; // initial position of the building
81  float m_buildingHeight; // height of the building
82  int m_lightRank[TBMAXLIGHT]; // lights for the effects
83  int m_soundChannel;
84 };
85