Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
taskmanip.h
1 // * This file is part of the COLOBOT source code
2 // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
3 // *
4 // * This program is free software: you can redistribute it and/or modify
5 // * it under the terms of the GNU General Public License as published by
6 // * the Free Software Foundation, either version 3 of the License, or
7 // * (at your option) any later version.
8 // *
9 // * This program is distributed in the hope that it will be useful,
10 // * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // * GNU General Public License for more details.
13 // *
14 // * You should have received a copy of the GNU General Public License
15 // * along with this program. If not, see http://www.gnu.org/licenses/.
16 
17 // taskmanip.h
18 
19 #pragma once
20 
21 
22 #include "object/task/task.h"
23 #include "object/object.h"
24 #include "math/vector.h"
25 
26 
27 
28 enum TaskManipOrder
29 {
30  TMO_AUTO = 0, // deposits or takes automatically
31  TMO_GRAB = 1, // takes an object
32  TMO_DROP = 2, // deposits the object
33 };
34 
35 enum TaskManipArm
36 {
37  TMA_NEUTRAL = 1, // empty arm at rest
38  TMA_STOCK = 2, // right arm resting
39  TMA_FFRONT = 3, // arm on the ground
40  TMA_FBACK = 4, // arm behind the robot
41  TMA_POWER = 5, // arm behind the robot
42  TMA_OTHER = 6, // arm behind a friend robot
43  TMA_GRAB = 7, // takes immediately
44 };
45 
46 enum TaskManipHand
47 {
48  TMH_OPEN = 1, // open clamp
49  TMH_CLOSE = 2, // closed clamp
50 };
51 
52 
53 
54 class CTaskManip : public CTask
55 {
56 public:
57  CTaskManip(CObject* object);
58  ~CTaskManip();
59 
60  bool EventProcess(const Event &event);
61 
62  Error Start(TaskManipOrder order, TaskManipArm arm);
63  Error IsEnded();
64  bool Abort();
65 
66 protected:
67  void InitAngle();
68  CObject* SearchTakeUnderObject(Math::Vector &pos, float dLimit);
69  CObject* SearchTakeFrontObject(bool bAdvance, Math::Vector &pos, float &distance, float &angle);
70  CObject* SearchTakeBackObject(bool bAdvance, Math::Vector &pos, float &distance, float &angle);
71  CObject* SearchOtherObject(bool bAdvance, Math::Vector &pos, float &distance, float &angle, float &height);
72  bool TruckTakeObject();
73  bool TruckDeposeObject();
74  bool IsFreeDeposeObject(Math::Vector pos);
75  void SoundManip(float time, float amplitude=1.0f, float frequency=1.0f);
76 
77 protected:
78  TaskManipOrder m_order;
79  TaskManipArm m_arm;
80  TaskManipHand m_hand;
81  int m_step;
82  float m_speed;
83  float m_progress;
84  float m_initialAngle[5];
85  float m_finalAngle[5];
86  float m_height;
87  float m_advanceLength;
88  float m_energy;
89  bool m_bError;
90  bool m_bTurn;
91  bool m_bSubm;
92  bool m_bBee;
93  float m_angle;
94  float m_move;
95  Math::Vector m_targetPos;
96  float m_timeLimit;
97  ObjectType m_fretType;
98 };
99 
ObjectType
Type of game object.
Definition: object.h:46
CObject - base class for all game objects.
Vector struct and related functions.
Definition: task.h:61
Error
Type of error or info message.
Definition: global.h:29
3D (3x1) vector
Definition: vector.h:49
Definition: taskmanip.h:54
Event sent by system, interface or game.
Definition: event.h:687
Definition: object.h:372