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 23 #include "object/task/task.h" 24 25 #include "math/vector.h" 26 27 #include "object/object_type.h" 28 29 30 31 class CObject; 32 33 enum TaskManipOrder 34 { 35 TMO_AUTO = 0, // deposits or takes automatically 36 TMO_GRAB = 1, // takes an object 37 TMO_DROP = 2, // deposits the object 38 }; 39 40 enum TaskManipArm 41 { 42 TMA_NEUTRAL = 1, // empty arm at rest 43 TMA_STOCK = 2, // right arm resting 44 TMA_FFRONT = 3, // arm on the ground 45 TMA_FBACK = 4, // arm behind the robot 46 TMA_POWER = 5, // arm behind the robot 47 TMA_OTHER = 6, // arm behind a friend robot 48 TMA_GRAB = 7, // takes immediately 49 }; 50 51 enum TaskManipHand 52 { 53 TMH_OPEN = 1, // open clamp 54 TMH_CLOSE = 2, // closed clamp 55 }; 56 57 58 59 class CTaskManip : public CForegroundTask 60 { 61 public: 62 CTaskManip(COldObject* object); 63 ~CTaskManip(); 64 65 bool EventProcess(const Event &event) override; 66 67 Error Start(TaskManipOrder order, TaskManipArm arm); 68 Error IsEnded() override; 69 bool Abort() override; 70 71 protected: 72 void InitAngle(); 73 CObject* SearchTakeUnderObject(Math::Vector &pos, float dLimit); 74 CObject* SearchTakeFrontObject(bool bAdvance, Math::Vector &pos, float &distance, float &angle); 75 CObject* SearchTakeBackObject(bool bAdvance, Math::Vector &pos, float &distance, float &angle); 76 CObject* SearchOtherObject(bool bAdvance, Math::Vector &pos, float &distance, float &angle, float &height); 77 bool TransporterTakeObject(); 78 bool TransporterDeposeObject(); 79 bool IsFreeDeposeObject(Math::Vector pos); 80 void SoundManip(float time, float amplitude=1.0f, float frequency=1.0f); 81 82 protected: 83 TaskManipOrder m_order = TMO_AUTO; 84 TaskManipArm m_arm = TMA_NEUTRAL; 85 TaskManipHand m_hand = TMH_OPEN; 86 int m_step = 0; 87 float m_speed = 0.0f; 88 float m_progress = 0.0f; 89 float m_initialAngle[5] = {}; 90 float m_finalAngle[5] = {}; 91 float m_height = 0.0f; 92 float m_advanceLength = 0.0f; 93 float m_energy = 0.0f; 94 bool m_bError = false; 95 bool m_bTurn = false; 96 bool m_bSubm = false; 97 bool m_bBee = false; 98 float m_angle = 0.0f; 99 float m_move = 0.0f; 100 Math::Vector m_targetPos; 101 float m_timeLimit = 0.0f; 102 ObjectType m_cargoType = OBJECT_NULL; 103 }; 104