menu_bookDocumentation

Component Interfaces: ExecuteInEditor, ICollisionListener, IDamageable in s&box

calendar_today May 20, 2026 schedule ~1 min read person PatrickJr verified 50

s&box provides several Component interfaces for specific purposes: editor execution, collision handling, triggers, damage, and networking.

ExecuteInEditor

Components marked with Component.ExecuteInEditor run lifecycle methods (OnAwake, OnEnabled, OnDisabled, OnUpdate, OnFixedUpdate) in edit mode:

CSHARP
public sealed class EditorSample : Component, Component.ExecuteInEditor
{
    protected override void OnEnabled()
    {
        if ( Game.IsEditor )
            Log.Info( "Running in editor!" );
    }
}

ICollisionListener

React to physics collisions:

CSHARP
public sealed class CollisionSample : Component, Component.ICollisionListener
{
    public void OnCollisionStart( Collision other )
    {
        Log.Info( "Hit: " + other.Other.GameObject );
    }
    public void OnCollisionUpdate( Collision other ) { }
    public void OnCollisionStop( CollisionStop other ) { }
}

IDamageable

Mark components that can receive damage:

CSHARP
public sealed class Health : Component, Component.IDamageable
{
    public void OnDamage( in DamageInfo damage )
    {
        Log.Info( $"Damaged for {damage.Damage} by {damage.Attacker}" );
    }
}

// Dealing damage:
var damageable = trace.GameObject.Components.Get<IDamageable>();
damageable?.OnDamage( new DamageInfo { Damage = 12, Attacker = GameObject, Position = hitPos } );

Other Interfaces

Was this helpful?