예제 #1
0
    /// <summary>
    /// Checks if there is a CellBehavior implementing
    /// IMinecartInteracter in the direction that is passed.  If
    /// there is one, true is returned.
    ///
    /// If null is passed for rotation, the cell the cart is on is
    /// checked.
    /// <returns></returns>
    private bool checkForInteractor(Rotation rotation)
    {
        Position p = rotation == null ? this.position : this.position + rotation;

        if (this.world.isOutOfBounds(p))
        {
            return(false);
        }

        CellState adjacentState = this.world.getCellState(p);

        if (adjacentState != null && adjacentState.behavior is IMinecartInteractor)
        {
            IMinecartInteractor cartInteracter = (IMinecartInteractor)adjacentState.behavior;

            if (cartInteracter.shouldCartInteract(this))
            {
                this.cartInteractor = cartInteracter;
                return(true);
            }
        }

        return(false);
    }
예제 #2
0
 public void release()
 {
     this.cartInteractor = null;
 }