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/interface/damageable_object.h" 23 24 /** 25 * \enum DestructionType 26 * \brief Type of effect on object destruction, for use in CDestroyableObject::DestroyObject 27 */ 28 enum class DestructionType 29 { 30 NoEffect = 0, //!< no effect, just disappear (only for MissionController constants, do not actually pass this to DestroyObject) 31 Explosion = 1, //!< explosion 32 ExplosionWater = 2, //!< explosion underwater 33 Burn = 3, //!< burning 34 Drowned = 4, //!< drowned (only for Me) 35 Win = 5, //!< used when removing objects from a team that won 36 Squash = 6, //!< flatten 37 }; 38 39 /** 40 * \enum DeathType 41 * \brief A status to set while the object is dying (see CDestroyableObject::SetDying) 42 */ 43 enum class DeathType 44 { 45 Alive = -1, //!< not dead 46 Exploding, //!< killed by explosion 47 Burning, //!< killed by fire 48 Dead //!< dead human 49 }; 50 51 /** 52 * \class CDestroyableObject 53 * \brief Interface for objects that can be destroyed 54 * 55 * NOTE: None of the objects should inherit this class directly. Instead, inherit one of the subclasses (CShieldedObject or CFragileObject) 56 */ 57 class CDestroyableObject : public CDamageableObject 58 { 59 public: CDestroyableObject(ObjectInterfaceTypes & types)60 explicit CDestroyableObject(ObjectInterfaceTypes& types) 61 : CDamageableObject(types) 62 { 63 types[static_cast<int>(ObjectInterfaceType::Destroyable)] = true; 64 } ~CDestroyableObject()65 virtual ~CDestroyableObject() 66 {} 67 68 //! Destroy the object immediately. Use this only if you are 100% sure this is what you want, because object with magnifyDamage=0 should be able to bypass all damage. It's recommended to use CDamageableObject::DamageObject() instead. 69 /** NOTE: After this function exits, you can assume the object has been definetly destroyed */ 70 virtual void DestroyObject(DestructionType type, CObject* killer = nullptr) = 0; 71 72 //! Returns the distance modifier for CLightning, used to modify hit probability. Value in range [0..1], where 0 is never and 1 is normal probability 73 virtual float GetLightningHitProbability() = 0; 74 75 //! Set the status that means the object is currently dying 76 virtual void SetDying(DeathType deathType) = 0; 77 //! Return object death type 78 virtual DeathType GetDying() = 0; 79 //! Is object currently dying? 80 virtual bool IsDying() = 0; 81 }; 82