protected bool CheckDefer(Map map, Vector3 drawPosition) { MapTile deferToTile; Direction checkDirection; var entity = Entity as Mobile; if (entity != null && entity.IsMoving) { var mobile = entity; switch ((mobile.Facing & Direction.FacingMask)) { case Direction.Left: case Direction.South: case Direction.East: deferToTile = map.GetMapTile(entity.Position.X, entity.Position.Y + 1); checkDirection = mobile.Facing & Direction.FacingMask; break; case Direction.Down: deferToTile = map.GetMapTile(entity.Position.X + 1, entity.Position.Y + 1); checkDirection = Direction.Down; break; default: deferToTile = map.GetMapTile(entity.Position.X + 1, entity.Position.Y); checkDirection = Direction.East; break; } } else { deferToTile = map.GetMapTile(Entity.Position.X + 1, Entity.Position.Y); checkDirection = Direction.East; } if (deferToTile == null) { return(false); } var mobile1 = Entity as Mobile; if (mobile1 != null) { var mobile = mobile1; int z; if (!MobileMovementCheck.CheckMovementForced(mobile, mobile1.Position, checkDirection, out z)) { return(false); } var deferred = new DeferredEntity(mobile, drawPosition, z); deferToTile.OnEnter(deferred); return(true); } else { var deferred = new DeferredEntity(Entity, drawPosition, Entity.Z); deferToTile.OnEnter(deferred); return(true); } }
public static void GetSortValues(AEntity e, out int z, out int type, out int threshold, out int tiebreaker) { if (e is AEffect) { AEffect effect = e as AEffect; z = effect.Z; type = 4; threshold = 2; tiebreaker = 0; } else if (e is DeferredEntity) { DeferredEntity mobile = (DeferredEntity)e; z = mobile.Z; type = 2; threshold = 1; tiebreaker = 0; } else if (e is Mobile) { Mobile mobile = (Mobile)e; z = mobile.Z; type = mobile.IsSitting ? 0 : 3; threshold = 2; tiebreaker = mobile.IsClientEntity ? 0x40000000 : (int)mobile.Serial; } else if (e is Ground) { Ground tile = (Ground)e; z = tile.GetView().SortZ; type = 0; threshold = 0; tiebreaker = 0; } else if (e is StaticItem) { StaticItem item = (StaticItem)e; z = item.Z; type = 1; threshold = (item.ItemData.Height > 0 ? 1 : 0) + (item.ItemData.IsBackground ? 0 : 1); tiebreaker = item.SortInfluence; } else if (e is Item) { Item item = (Item)e; z = item.Z; type = ((item.ItemID & 0x3fff) == 0x2006) ? 4 : 2; // corpses show on top of mobiles and items. threshold = (item.ItemData.Height > 0 ? 1 : 0) + (item.ItemData.IsBackground ? 0 : 1); tiebreaker = item.Serial; } else { z = 0; threshold = 0; type = 0; tiebreaker = 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); }
// ============================================================================================================ // 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); } } }
public DeferredView(DeferredEntity entity, Vector3 drawPosition, AEntityView baseView) : base(entity) { m_DrawPosition = drawPosition; m_BaseView = baseView; }
public static void GetSortValues(AEntity e, out int z, out int threshold, out int type, out int tiebreaker) { if (e is AEffect) { AEffect effect = e as AEffect; z = effect.Z; threshold = 2; type = 4; tiebreaker = 0; } else if (e is DeferredEntity) { DeferredEntity mobile = (DeferredEntity)e; z = mobile.Z; threshold = 1; type = 2; tiebreaker = 0; } else if (e is Mobile) { Mobile mobile = (Mobile)e; z = mobile.Z; threshold = 2; type = 3; if (mobile.IsClientEntity) { tiebreaker = 0x40000000; } else { tiebreaker = mobile.Serial; } } else if (e is Ground) { Ground tile = (Ground)e; z = tile.GetView().SortZ; threshold = 0; type = 0; tiebreaker = 0; } else if (e is StaticItem) { int sort; StaticItem item = (StaticItem)e; z = item.Z; if (item.ItemData.IsBackground) { sort = 0; } else { sort = 1; } threshold = (item.ItemData.Height == 0) ? sort : (sort + 1); type = 1; tiebreaker = item.SortInfluence; } else if (e is Item) // this was previously dynamicitem - I think Kirros and I use the word 'Dynamic' for different purposes. { int sort; Item item = (Item)e; z = item.Z; if (item.ItemData.IsBackground) { sort = 0; } else { sort = 1; } threshold = (item.ItemData.Height == 0) ? sort : (sort + 1); type = ((item.ItemID & 0x3fff) == 0x2006) ? 4 : 2; // is corpse? Corpse inherits from Container, which inherits from Item, so this works here. tiebreaker = item.Serial; } else { z = 0; threshold = 0; type = 0; tiebreaker = 0; } }
public DeferredView(DeferredEntity deferred, View baseView, Vector3 position) : base(deferred) { _baseView = baseView; _position = position; }