KlassischeKeplerKriege/game/state/state_update_event.hpp

73 lines
2.2 KiB
C++

#pragma once
#include <string>
#include "object.hpp"
// 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 {
enum class LifeCycle {
Create, // something was created
Modify, // something was modified (look at attributes)
Destroy // something was destroyed
};
// add all possible classes here
// TODO:
// there can be different things in here, like:
enum class EventType {
Explosion,
Missile,
Ship
};
class StateUpdateEvent {
public:
StateUpdateEvent(LifeCycle cycle, EventType event, Object *object, bool changesContinuously=false)
: m_lifeCycle(cycle), m_eventType(event)
, m_object(object)
, m_changesContinuously(changesContinuously)
{
}
LifeCycle lifeCycle() const { return m_lifeCycle; }
EventType eventType() const { return m_eventType; }
bool changesContinuously() const { return m_changesContinuously; }
Object* object() const { return m_object; }
void setChangesContinuously(bool enable) { m_changesContinuously = enable; }
//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;
Object *m_object;
bool m_changesContinuously;
};
}