2016-10-02 21:49:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2016-10-03 11:37:49 +00:00
|
|
|
#include "object.hpp"
|
|
|
|
|
2016-10-02 21:49:40 +00:00
|
|
|
// 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 {
|
2016-10-03 11:37:49 +00:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2016-10-02 21:49:40 +00:00
|
|
|
class StateUpdateEvent {
|
|
|
|
public:
|
2016-10-03 11:37:49 +00:00
|
|
|
StateUpdateEvent(LifeCycle cycle, EventType event, Object *object, bool changesContinuously=false)
|
2016-10-02 21:49:40 +00:00
|
|
|
: m_lifeCycle(cycle), m_eventType(event)
|
2016-10-03 11:37:49 +00:00
|
|
|
, m_object(object)
|
|
|
|
, m_changesContinuously(changesContinuously)
|
2016-10-02 21:49:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-03 11:37:49 +00:00
|
|
|
LifeCycle lifeCycle() const { return m_lifeCycle; }
|
|
|
|
EventType eventType() const { return m_eventType; }
|
|
|
|
bool changesContinuously() const { return m_changesContinuously; }
|
|
|
|
Object* object() const { return m_object; }
|
2016-10-02 21:49:40 +00:00
|
|
|
|
2016-10-03 11:37:49 +00:00
|
|
|
void setChangesContinuously(bool enable) { m_changesContinuously = enable; }
|
2016-10-02 21:49:40 +00:00
|
|
|
|
2016-10-03 11:37:49 +00:00
|
|
|
//std::string description() const
|
|
|
|
//{
|
|
|
|
// // TODO
|
|
|
|
// return "StateUpdateEvent(" + lifeCycleToString(m_lifeCycle) + ", " + eventTypeToString(m_eventType) + ")";
|
|
|
|
//}
|
2016-10-02 22:23:21 +00:00
|
|
|
|
2016-10-03 11:37:49 +00:00
|
|
|
//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>";
|
|
|
|
// }
|
|
|
|
//}
|
2016-10-02 21:49:40 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const LifeCycle m_lifeCycle;
|
|
|
|
const EventType m_eventType;
|
2016-10-03 11:37:49 +00:00
|
|
|
Object *m_object;
|
|
|
|
bool m_changesContinuously;
|
2016-10-02 21:49:40 +00:00
|
|
|
};
|
|
|
|
}
|