KlassischeKeplerKriege/game/state/state_update_event.hpp

51 lines
1.4 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 "<event>";
}
static std::string lifeCycleToString(LifeCycle lifeCycle)
{
switch(lifeCycle) {
case StateUpdateEvent::LifeCycle::Create: return "create";
case StateUpdateEvent::LifeCycle::Modify: return "modify";
case StateUpdateEvent::LifeCycle::Destroy: return "destroy";
default: return "<invalid>";
}
}
private:
const LifeCycle m_lifeCycle;
const EventType m_eventType;
};
}