Contents

SushiEngine::Simulation::IWorldEditor

send_message

virtual void send_message(EntityId sender, EntityId target, const std::string &name, const ScriptField &payload={})=0

Parameters

NameTypeDescription
senderEntityId

Handed to each receiver as on_message's sender; not validated.

targetEntityId

An unknown entity, or one with no behaviors, makes the call a no-op.

nameconst std::string &
payloadconst ScriptField &

Description

Broadcasts a named message to every behavior on target.

See also

engine/world/simulation/include/EDITOR.md

Example

void on_update(SushiEngine::Simulation::IWorldEditor& world,
               SushiEngine::Simulation::EntityId id,
               const SushiEngine::Simulation::TickContext& context) override
{
    elapsed_seconds_ += context.delta_seconds;
    if (sent_ || elapsed_seconds_ < SushiEngine::Scalar(10))
        return;
    world.send_message(id, world.parent(id), "TurnOff", {});
    sent_ = true;
}