Contents

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

NameTypeDescription
worldIWorldEditor &
selfEntityId

This instance's own entity, the role id plays in every other hook.

senderEntityId

The entity send_message was given; not validated, so it may not exist.

nameconst std::string &
payloadconst 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);
}