KlassischeKeplerKriege/game/state/state_update_event.hpp

59 lines
1.7 KiB
C++

#pragma once
#include <string>
// TODO: make life cycle object class.
// objects from that class can be created and destroyed only through factory
// methods which create updates too.
namespace game {
class StateUpdateEvent {
public:
enum class LifeCycle {
Create, // something was created
Modify, // something was modified (look at attributes)
Destroy // something was destroyed
};
// add all possible classes here
enum class EventType {
Explosion
};
StateUpdateEvent(LifeCycle cycle, EventType event)
: m_lifeCycle(cycle), m_eventType(event)
{
}
LifeCycle lifeCycle() const { return m_lifeCycle; }
EventType eventType() const { return m_eventType; }
std::string description() const
{
// TODO
return "StateUpdateEvent(" + lifeCycleToString(m_lifeCycle) + ", " + eventTypeToString(m_eventType) + ")";
}
static std::string lifeCycleToString(LifeCycle lifeCycle)
{
switch(lifeCycle) {
case LifeCycle::Create: return "create";
case LifeCycle::Modify: return "modify";
case LifeCycle::Destroy: return "destroy";
default: return "<no name>";
}
}
static std::string eventTypeToString(EventType eventType)
{
switch(eventType) {
case EventType::Explosion: return "explosion";
default: return "<no name>";
}
}
private:
const LifeCycle m_lifeCycle;
const EventType m_eventType;
};
}