Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
taskmanip.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 // taskmanip.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 enum TaskManipOrder
32 {
33  TMO_AUTO = 0, // deposits or takes automatically
34  TMO_GRAB = 1, // takes an object
35  TMO_DROP = 2, // deposits the object
36 };
37 
38 enum TaskManipArm
39 {
40  TMA_NEUTRAL = 1, // empty arm at rest
41  TMA_STOCK = 2, // right arm resting
42  TMA_FFRONT = 3, // arm on the ground
43  TMA_FBACK = 4, // arm behind the robot
44  TMA_POWER = 5, // arm behind the robot
45  TMA_OTHER = 6, // arm behind a friend robot
46  TMA_GRAB = 7, // takes immediately
47 };
48 
49 enum TaskManipHand
50 {
51  TMH_OPEN = 1, // open clamp
52  TMH_CLOSE = 2, // closed clamp
53 };
54 
55 
56 
57 class CTaskManip : public CTask
58 {
59 public:
60  CTaskManip(CObject* object);
61  ~CTaskManip();
62 
63  bool EventProcess(const Event &event);
64 
65  Error Start(TaskManipOrder order, TaskManipArm arm);
66  Error IsEnded();
67  bool Abort();
68 
69 protected:
70  void InitAngle();
71  CObject* SearchTakeUnderObject(Math::Vector &pos, float dLimit);
72  CObject* SearchTakeFrontObject(bool bAdvance, Math::Vector &pos, float &distance, float &angle);
73  CObject* SearchTakeBackObject(bool bAdvance, Math::Vector &pos, float &distance, float &angle);
74  CObject* SearchOtherObject(bool bAdvance, Math::Vector &pos, float &distance, float &angle, float &height);
75  bool TruckTakeObject();
76  bool TruckDeposeObject();
77  bool IsFreeDeposeObject(Math::Vector pos);
78  void SoundManip(float time, float amplitude=1.0f, float frequency=1.0f);
79 
80 protected:
81  TaskManipOrder m_order;
82  TaskManipArm m_arm;
83  TaskManipHand m_hand;
84  int m_step;
85  float m_speed;
86  float m_progress;
87  float m_initialAngle[5];
88  float m_finalAngle[5];
89  float m_height;
90  float m_advanceLength;
91  float m_energy;
92  bool m_bError;
93  bool m_bTurn;
94  bool m_bSubm;
95  bool m_bBee;
96  float m_angle;
97  float m_move;
98  Math::Vector m_targetPos;
99  float m_timeLimit;
100  ObjectType m_fretType;
101 };
102 
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
Definition: taskmanip.h:57
Event sent by system, interface or game.
Definition: event.h:678
Definition: object.h:357