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