SushiEngine::Simulation::IWorldEditor
remove_script_component
virtual void remove_script_component(EntityId id, const std::string &type_name)=0Parameters
| Name | Type |
|---|---|
id | EntityId |
type_name | const std::string & |
Description
Detaches the script component named type_name; a no-op if absent.
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 == "StartSpinning")
{
SushiEngine::Simulation::ScriptField speed;
speed.name = "speed";
speed.kind = SushiEngine::Simulation::ScriptFieldKind::Float;
speed.number = payload.number;
SushiEngine::Simulation::ScriptComponent script;
script.type_name = "SpinningLight";
script.fields.push_back(speed);
world.add_script_component(self, script);
}
if (name == "StopSpinning")
world.remove_script_component(self, "SpinningLight");
}

