Example #1
0
        protected bool CheckDefer(Map map, Vector3 drawPosition)
        {
            MapTile deferToTile;
            Direction checkDirection;
            if (Entity is Mobile && ((Mobile)Entity).IsMoving)
            {
                Mobile mobile = Entity as Mobile;
                if (
                    ((mobile.Facing & Direction.FacingMask) == Direction.Left) ||
                    ((mobile.Facing & Direction.FacingMask) == Direction.South) ||
                    ((mobile.Facing & Direction.FacingMask) == Direction.East))
                {
                    deferToTile = map.GetMapTile(Entity.Position.X, Entity.Position.Y + 1);
                    checkDirection = mobile.Facing & Direction.FacingMask;
                }
                else if ((mobile.Facing & Direction.FacingMask) == Direction.Down)
                {
                    deferToTile = map.GetMapTile(Entity.Position.X + 1, Entity.Position.Y + 1);
                    checkDirection = Direction.Down;
                }
                else
                {
                    deferToTile = map.GetMapTile(Entity.Position.X + 1, Entity.Position.Y);
                    checkDirection = Direction.East;
                }
            }
            else
            {
                deferToTile = map.GetMapTile(Entity.Position.X + 1, Entity.Position.Y);
                checkDirection = Direction.East;
            }

            if (deferToTile != null)
            {
                if (Entity is Mobile)
                {
                    Mobile mobile = Entity as Mobile;
                    int z;
                    if (MobileMovementCheck.CheckMovementForced(mobile, Entity.Position, checkDirection, out z))
                    {
                        DeferredEntity deferred = new DeferredEntity(mobile, drawPosition, z);
                        deferToTile.OnEnter(deferred);
                        return true;
                    }
                }
                else
                {
                    DeferredEntity deferred = new DeferredEntity(Entity, drawPosition, Entity.Z);
                    deferToTile.OnEnter(deferred);
                    return true;
                }
            }
            return false;
        }
Example #2
0
        // ======================================================================
        // Deferred drawing code
        // ======================================================================

        protected void CheckDefer(Map map, Vector3 drawPosition)
        {
            MapTile deferToTile;
            Direction checkDirection;
            if (Entity is Mobile && ((Mobile)Entity).IsMoving)
            {
                Direction facing = (Entity as Mobile).DrawFacing;
                if (
                    ((facing & Direction.FacingMask) == Direction.Left) ||
                    ((facing & Direction.FacingMask) == Direction.South) ||
                    ((facing & Direction.FacingMask) == Direction.East))
                {
                    deferToTile = map.GetMapTile(Entity.Position.X, Entity.Position.Y + 1);
                    checkDirection = facing & Direction.FacingMask;
                }
                else if ((facing & Direction.FacingMask) == Direction.Down)
                {
                    deferToTile = map.GetMapTile(Entity.Position.X + 1, Entity.Position.Y + 1);
                    checkDirection = Direction.Down;
                }
                else
                {
                    deferToTile = map.GetMapTile(Entity.Position.X + 1, Entity.Position.Y);
                    checkDirection = Direction.East;
                }
            }
            else
            {
                deferToTile = map.GetMapTile(Entity.Position.X, Entity.Position.Y + 1);
                checkDirection = Direction.South;
            }

            if (deferToTile != null)
            {
                if (Entity is Mobile)
                {
                    Mobile mobile = Entity as Mobile;
                    // This calculates the z position of the mobile as if it had moved into the next tile.
                    // Strictly speaking, this isn't necessary, but looks nice for mobiles that are walking.
                    int z = MobileMovementCheck.GetNextZ(mobile, Entity.Position, checkDirection); 
                    DeferredEntity deferred = new DeferredEntity(mobile, drawPosition, z);
                    deferToTile.OnEnter(deferred);
                }
                else
                {
                    DeferredEntity deferred = new DeferredEntity(Entity, drawPosition, Entity.Z);
                    deferToTile.OnEnter(deferred);
                }
            }
        }
Example #3
0
 public DeferredView(DeferredEntity entity, Vector3 drawPosition, AEntityView baseView)
     : base(entity)
 {
     m_DrawPosition = drawPosition;
     m_BaseView = baseView;
 }