Scripting / Interactables
IPushable
Marks an object as pushable. Instruction_Push searches for this interface one tile ahead of the player, validates the push with Validate(direction), and then calls Push(context, direction) while animating the movement. Stop() is called when the push animation ends.
Properties
| Property | Type | Description |
|---|---|---|
transform | Transform | The transform of the pushable object. Same explicit implementation pattern as ICarryObject. |
Methods
| Method | Returns | Description |
|---|---|---|
Validate(Direction direction) | bool | Default implementation provided — performs a Physics2D.OverlapBoxAll at the target cell and returns false if any IObstacle is found. Override only if you need custom validation logic. |
Push( | void | Moves the object one tile in the given direction. Use MapManager.cellSize for the offset. The engine calls this during the push animation frame. |
Stop() | void | Called when the push animation finishes. Stop any looping push sounds or effects here. |
Default Validate Implementation
// Default Validate() — no override needed for most objects public bool Validate(Direction direction) { Collider2D[] obs = Physics2D.OverlapBoxAll( transform.position.ToVector2() + direction.AsVector2() * MapManager.cellSize, Vector2.one, 0); foreach (Collider2D o in obs) if (o.GetComponent<IObstacle>() != null) return false; return true; }