30 for (
auto &[
_, data] :
mData)
46 auto it =
mData.find(key);
47 if (it ==
mData.end())
53 return static_cast<IntData *
>(it->second)->getData();
68 auto it =
mData.find(key);
69 if (it ==
mData.end())
75 return static_cast<StringData *
>(it->second)->getData();
91 auto it =
mData.find(key);
92 if (it ==
mData.end())
98 return static_cast<FloatData *
>(it->second)->getData();
113 auto it =
mData.find(key);
114 if (it ==
mData.end())
120 return static_cast<BoolData *
>(it->second)->getData();
135 auto it =
mData.find(key);
136 if (it ==
mData.end())
142 return static_cast<ItemData *
>(it->second)->getData();
157 auto it =
mData.find(key);
158 if (it ==
mData.end())
164 return static_cast<ActorData *
>(it->second)->getData();
178 for (
auto *listener : it->second)
179 listener->event(channel, event);
195 listeners.erase(listener);
ActorSprite * getActor(const std::string &key) const
Returns the given variable if it is set and an actor.
void setBool(const std::string &key, bool value)
Sets the given variable to the given boolean, if it isn't already set.
const T & value() const
Returns the value of the event.
static void unbind(EventListener *listener, Channel channel)
Unbinds the given listener from the given channel.
void setString(const std::string &key, const std::string &value)
Sets the given variable to the given string, if it isn't already set.
double getFloat(const std::string &key) const
Returns the given variable if it is set and a floating-point.
void trigger(Channel channel) const
Sends this event to all classes listening to the given channel.
const std::string & getString(const std::string &key) const
Returns the given variable if it is set and a string.
Item * getItem(const std::string &key) const
Returns the given variable if it is set and an Item.
static ListenMap mBindings
void setFloat(const std::string &key, double value)
Sets the given variable to the given floating-point, if it isn't already set.
void setActor(const std::string &key, ActorSprite *value)
Sets the given variable to the given actor, if it isn't already set.
std::map< std::string, VariableData * > mData
static void remove(EventListener *listener)
Unbinds the given listener from all channels.
void setInt(const std::string &key, int value)
Sets the given variable to the given integer, if it isn't already set.
static void bind(EventListener *listener, Channel channel)
Binds the given listener to the given channel.
std::map< Channel, std::set< EventListener * > > ListenMap
int getInt(const std::string &key) const
Returns the given variable if it is set and an integer.
void setItem(const std::string &key, Item *value)
Sets the given variable to the given Item, if it isn't already set.
bool getBool(const std::string &key) const
Returns the given variable if it is set and a boolean.
Represents one or more instances of a certain item type.