12 using bl::script::Function;
13 using bl::script::SymbolTable;
14 using bl::script::Value;
16 typedef void (*Builtin)(bl::ecs::Entity,
const bl::tmap::Position&,
const map::Event&, Value&);
18 void triggeringEntity(bl::ecs::Entity entity,
const bl::tmap::Position& pos,
19 const map::Event& event, Value&);
21 void triggerPosition(bl::ecs::Entity entity,
const bl::tmap::Position& pos,
22 const map::Event& event, Value&);
24 void eventType(bl::ecs::Entity entity,
const bl::tmap::Position& pos,
const map::Event& event,
27 void eventPosition(bl::ecs::Entity entity,
const bl::tmap::Position& pos,
const map::Event& event,
30 void eventSize(bl::ecs::Entity entity,
const bl::tmap::Position& pos,
const map::Event& event,
33 Value bind(bl::ecs::Entity entity,
const bl::tmap::Position& pos,
const map::Event& event,
35 return Value(Function(std::bind(func, entity, pos, event, std::placeholders::_3)));
41 const map::Event& event,
const bl::tmap::Position& tile)
50 table.set(
"triggeringEntity", bind(entity, tile, event, &triggeringEntity));
51 table.set(
"triggerPosition", bind(entity, tile, event, &triggerPosition));
52 table.set(
"eventType", bind(entity, tile, event, &eventType));
53 table.set(
"eventPosition", bind(entity, tile, event, &eventPosition));
54 table.set(
"eventSize", bind(entity, tile, event, &eventSize));
59 void triggeringEntity(bl::ecs::Entity entity,
const bl::tmap::Position&,
const map::Event&,
61 result =
static_cast<float>(entity);
64 void triggerPosition(bl::ecs::Entity,
const bl::tmap::Position& pos,
const map::Event&,
69 void eventType(bl::ecs::Entity,
const bl::tmap::Position&,
const map::Event& event,
71 switch (event.trigger) {
79 result =
"onEnterOrExit";
85 result =
"OnInteract";
92 void eventPosition(bl::ecs::Entity,
const bl::tmap::Position&,
const map::Event& event,
94 coord.setProperty(
"x", {
static_cast<float>(
event.position.x)});
95 coord.setProperty(
"y", {
static_cast<float>(
event.position.y)});
98 void eventSize(bl::ecs::Entity,
const bl::tmap::Position&,
const map::Event& event, Value& size) {
99 size.setProperty(
"x", {
static_cast<float>(
event.areaSize.x)});
100 size.setProperty(
"y", {
static_cast<float>(
event.areaSize.y)});
Core classes and functionality for both the editor and game.
Represents an event in a Map. A script that is run on a trigger within a given region.
@ OnInteract
The event triggers when the player interacts with the zone.
@ OnExit
The event triggers when the player steps out of the zone.
@ onEnterOrExit
The event triggers when the player either enters or exits the zone.
@ WhileIn
The event triggers repeatedly while the player is in the zone.
@ OnEnter
The event triggers when the player steps into the zone.
static bl::script::Value makePosition(const bl::tmap::Position &pos)
Helper function for other script functions to make script position values from the position component...
static void addDefaults(bl::script::SymbolTable &table, system::Systems &systems)
Adds the universal built-in functions to the given symbol table.
MapEventContext(system::Systems &systems, bl::ecs::Entity entity, const map::Event &event, const bl::tmap::Position &tile)
Construct a new MapEventContext.
virtual void addCustomSymbols(bl::script::SymbolTable &table) const override
Owns all primary systems and a reference to the engine.