1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2020, 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;
30 class CProgrammableObject;
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 
72     //! Returns true if you can control the robot while the task is executing
73     virtual bool    IsPilot() = 0;
74 
75     //! Returns true if this task is meant to be run as a background task
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:
CForegroundTask(COldObject * object)97     CForegroundTask(COldObject* object) : CTask(object) {}
98 
IsBackground()99     bool IsBackground() override final { return false; }
IsPilot()100     bool IsPilot() override { return false; }
101 };
102 
103 class CBackgroundTask : public CTask
104 {
105 public:
CBackgroundTask(COldObject * object)106     CBackgroundTask(COldObject* object) : CTask(object) {}
107 
IsBackground()108     bool IsBackground() override final { return true; }
IsPilot()109     bool IsPilot() override final { return true; }
110 };
111