Properties

PropertyTypeDescription
transformTransformThe transform of the pushable object. Same explicit implementation pattern as ICarryObject.

Methods

MethodReturnsDescription
Validate(Direction direction)boolDefault 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(
  ExecutionContext context,
  Direction direction)
voidMoves the object one tile in the given direction. Use MapManager.cellSize for the offset. The engine calls this during the push animation frame.
Stop()voidCalled 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;
}
ℹ️