How to Implement an Action¶
Actions are generalized by the class TriggerInterface, under src/GamePlay of the engine. Each new action must implement this interface. These actions can be assigned to trigger volumes or GUI button.They can also be run on map load.
Action constructors will get a populated LimonAPI instance for the world they are to be run in. Using this instance, API calls can be made to interact or change the world to game design.
Actions never get persisted, but parameters to pass to actions are persisted with maps.
The constructor of the interface.
All actions must have the same signature, no other parameters should be required.
Returns a vector of ParameterRequest struct, These parameters are going to be set by map designer using the editor.
The parameters with their set values will be provided. The logic of the action should be this method. Return true if run succesfully. Return false if the run failed for some reason.
The actions result might be queried by other actions. This method should return the results. Engine itself doesn’t use this method, so it can return an empty vector. The usage of this method is game specific.
For example if the action adds a GUI element, and another action wants to remove this element, the other action might query for gui element id.
Returns the name of the action.
The name must be unique, or the results will be undefined.
How to enable Dynamic Library discovery¶
Limon engine will try to load custom actions on engine startup, from libcustomTriggers file (extension based on platform). If the file is found, engine will check for a method with following signature:
void registerAsTrigger(std::map<std::string, TriggerInterface*(*)(LimonAPI*)>* triggerMap)
This method should fill the triggerMap passed, with all the custom actions, like this:
(*triggerMap)["$ACTION_NAME1$"] = &createT<$ActionClass1$>; (*triggerMap)["$ACTION_NAME2$"] = &createT<$ActionClass2$>;