#pragma once #include #include #include #include #include #include #include namespace VCtrl { //////////////////////////////////////////////////////////////////////////////// class RoomDestructionComponent final : public dtEntity::Component { public: static const dtEntity::StringId TYPE; dtEntity::ComponentType GetType() const override { return TYPE; } virtual bool IsInstanceOf(dtEntity::ComponentType id) const { return ((id == TYPE)); } void OnAddedToEntity(dtEntity::Entity &entity) override { mEntity = &entity; } void OnEnteredWorld(); void OnRemovedFromEntity(dtEntity::Entity &) override { mEntity = nullptr; } bool SetRoomDestructionValue(const std::string &room, float value); bool SetBuildingDestructionValue(float value); using RoomDestructions = std::map; const RoomDestructions &GetRoomDestructions() const { return mRoomDestructions; } private: RoomDestructions mRoomDestructions; dtEntity::Entity *mEntity = nullptr; }; /////////////////////////////////////////////// // iterates over MovementComponents and updates the translation of the entity // after applying forces class RoomDestructionSystem final : public dtEntity::DefaultEntitySystem { public: static const dtEntity::StringId TYPE; explicit RoomDestructionSystem(dtEntity::EntityManager &em); void OnEnterWorld(const dtEntity::Message &msg); private: dtEntity::MessageFunctor mEnterWorldFunctor; }; }