SushiEngine::Simulation::IEntityBehavior
on_message
Message: the engine calls this function.
virtual void on_message(IWorldEditor &world, EntityId self, EntityId sender, const std::string &name, const ScriptField &payload)Parameters
| Name | Type | Description |
|---|---|---|
world | IWorldEditor & | |
self | EntityId | This instance's own entity, the role |
sender | EntityId | The entity |
name | const std::string & | |
payload | const ScriptField & |
Description
Runs when IWorldEditor::send_message targets this behavior's entity; a behavior that does not recognize name does nothing.
Example
void on_message(SushiEngine::Simulation::IWorldEditor& world,
SushiEngine::Simulation::EntityId self,
SushiEngine::Simulation::EntityId sender,
const std::string& name,
const SushiEngine::Simulation::ScriptField& payload) override
{
if (name == "TurnOff")
world.set_enabled(self, false);
}

