79 lines
1.7 KiB
C++
Executable File
79 lines
1.7 KiB
C++
Executable File
#pragma once
|
|
|
|
#include <dtEntity/commandmessages.h>
|
|
#include <dtEntity/systemmessages.h>
|
|
#include <dtEntity/component.h>
|
|
#include <dtEntity/entity.h>
|
|
#include <dtEntity/defaultentitysystem.h>
|
|
#include <osgSim/DOFTransform>
|
|
#include <dtEntity/dynamicproperty.h>
|
|
|
|
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<std::string, float>;
|
|
|
|
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<RoomDestructionComponent>
|
|
{
|
|
|
|
public:
|
|
static const dtEntity::StringId TYPE;
|
|
|
|
explicit RoomDestructionSystem(dtEntity::EntityManager &em);
|
|
void OnEnterWorld(const dtEntity::Message &msg);
|
|
|
|
private:
|
|
|
|
dtEntity::MessageFunctor mEnterWorldFunctor;
|
|
|
|
};
|
|
|
|
}
|