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 "object/task/task.h"
23 
24 #include "math/vector.h"
25 
26 #include "object/object_type.h"
27 
28 
29 class CObject;
30 
31 enum TaskTakeOrder
32 {
33     TTO_TAKE    = 1,    // takes an object
34     TTO_DEPOSE  = 2,    // deposes the object
35 };
36 
37 enum TaskTakeArm
38 {
39     TTA_NEUTRAL = 1,    // empty arm at rest
40     TTA_FFRONT  = 2,    // arm on the ground
41     TTA_FRIEND  = 3,    // arm behind a friend robot
42 };
43 
44 
45 
46 class CTaskTake : public CForegroundTask
47 {
48 public:
49     CTaskTake(COldObject* object);
50     ~CTaskTake();
51 
52     bool        EventProcess(const Event &event) override;
53 
54     Error       Start();
55     Error       IsEnded() override;
56     bool        Abort() override;
57 
58 protected:
59     CObject*    SearchTakeObject(float &angle, float dLimit, float aLimit);
60     CObject*    SearchFriendObject(float &angle, float dLimit, float aLimit);
61     bool        TransporterTakeObject();
62     bool        TransporterDeposeObject();
63     bool        IsFreeDeposeObject(Math::Vector pos);
64 
65 protected:
66     TaskTakeOrder   m_order = TTO_TAKE;
67     TaskTakeArm     m_arm = TTA_NEUTRAL;
68     int             m_step = 0;
69     float           m_speed = 0.0f;
70     float           m_progress = 0.0f;
71     float           m_height = 0.0f;
72     bool            m_bError = false;
73     bool            m_bTurn = false;
74     float           m_angle = 0.0f;
75     ObjectType      m_cargoType = OBJECT_NULL;
76 };
77