Colobot
task.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 #include "common/error.h"
23 
24 #include "math/const.h"
25 
26 
27 class CPhysics;
28 class CMotion;
29 class COldObject;
31 class CRobotMain;
32 class CSoundInterface;
33 struct Event;
34 
35 namespace Gfx
36 {
37 class CEngine;
38 class CLightManager;
39 class CParticle;
40 class CTerrain;
41 class CWater;
42 class CCamera;
43 } /* Gfx */
44 
45 
46 const float TAKE_DIST = 6.0f; // distance to an object to pick it
47 const float TAKE_DIST_OTHER = 1.5f; // additional distance if on friend
48 
49 //?const float ARM_NEUTRAL_ANGLE1 = 155.0f*Math::PI/180.0f;
50 //?const float ARM_NEUTRAL_ANGLE2 = -125.0f*Math::PI/180.0f;
51 //?const float ARM_NEUTRAL_ANGLE3 = -45.0f*Math::PI/180.0f;
52 const float ARM_NEUTRAL_ANGLE1 = 110.0f*Math::PI/180.0f;
53 const float ARM_NEUTRAL_ANGLE2 = -130.0f*Math::PI/180.0f;
54 const float ARM_NEUTRAL_ANGLE3 = -50.0f*Math::PI/180.0f;
55 
56 const float ARM_STOCK_ANGLE1 = 110.0f*Math::PI/180.0f;
57 const float ARM_STOCK_ANGLE2 = -100.0f*Math::PI/180.0f;
58 const float ARM_STOCK_ANGLE3 = -70.0f*Math::PI/180.0f;
59 
60 
61 class CTask
62 {
63 public:
64  CTask(COldObject* object);
65  virtual ~CTask();
66 
67  virtual bool EventProcess(const Event &event);
68  virtual Error IsEnded();
69  virtual bool IsBusy();
70  virtual bool Abort();
71 
73  virtual bool IsPilot() = 0;
74 
76  virtual bool IsBackground() = 0;
77 
78 protected:
79  Gfx::CEngine* m_engine = nullptr;
80  Gfx::CLightManager* m_lightMan = nullptr;
81  Gfx::CParticle* m_particle = nullptr;
82  Gfx::CTerrain* m_terrain = nullptr;
83  Gfx::CWater* m_water = nullptr;
84  Gfx::CCamera* m_camera = nullptr;
85  CRobotMain* m_main = nullptr;
86  CSoundInterface* m_sound = nullptr;
87 
88  COldObject* m_object = nullptr;
89  CProgrammableObject* m_programmable = nullptr;
90  CMotion* m_motion = nullptr;
91  CPhysics* m_physics = nullptr;
92 };
93 
94 class CForegroundTask : public CTask
95 {
96 public:
97  CForegroundTask(COldObject* object) : CTask(object) {}
98 
99  bool IsBackground() final { return false; }
100  bool IsPilot() override { return false; }
101 };
102 
103 class CBackgroundTask : public CTask
104 {
105 public:
106  CBackgroundTask(COldObject* object) : CTask(object) {}
107 
108  bool IsBackground() final { return true; }
109  bool IsPilot() final { return true; }
110 };
bool IsPilot() override
Returns true if you can control the robot while the task is executing.
Definition: task.h:100
Definition: old_object.h:79
Definition: physics.h:97
Manager for dynamic lights in 3D scene.
Definition: lightman.h:146
Interface for programmable objects.
Definition: programmable_object.h:36
const float PI
PI.
Definition: const.h:48
Definition: robotmain.h:159
Particle engine.
Definition: particle.h:223
Definition: task.h:94
Camera moving in 3D scene.
Definition: camera.h:128
Terrain loader/generator and manager.
Definition: terrain.h:147
Constants used in math functions.
Namespace for (new) graphics code.
Definition: app.h:49
Definition: motion.h:47
Definition: task.h:61
The graphics engine.
Definition: engine.h:585
Water manager/renderer.
Definition: water.h:72
Definition: task.h:103
bool IsPilot() final
Returns true if you can control the robot while the task is executing.
Definition: task.h:109
bool IsBackground() final
Returns true if this task is meant to be run as a background task.
Definition: task.h:108
bool IsBackground() final
Returns true if this task is meant to be run as a background task.
Definition: task.h:99
Event sent by system, interface or game.
Definition: event.h:735
Sound plugin interface.
Definition: sound.h:60