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