public Boolean Collides(OrientedBoundingBox box) { try { GridBlockCollection gridBlockCollection = GridBlocks.GetBlocksNearBoundingBox(box); if (gridBlockCollection == null) { return(true); } if (gridBlockCollection.Any(gridBlock => box.Collides(gridBlock.LowBox) || box.Collides(gridBlock.MidBox) || (box.Collides(gridBlock.HighBox) && !gridBlock.HasSkybox))) { return(true); } if (gridBlockCollection.Where(gridBlock => gridBlock.LowBoxTile != null).Any(gridBlock => gridBlock.LowBoxTile.TileBlocks.Where(tileBlock => tileBlock.BottomBoundingBox != null).Any(tileBlock => box.Collides(tileBlock.BottomBoundingBox)))) { return(true); } if (Triggers.Where(t => t.TriggerType == TriggerType.Elevator).Where(t => (Int32)System.Math.Floor(box.Origin.X / 64) == t.X1 && (Int32)System.Math.Floor(box.Origin.Y / 64) == t.Y1).Any(t => box.Origin.Z > t.OffHeight && box.Origin.Z < t.Position.Z)) { return(true); } } catch (Exception) { return(true); } return(false); }
public Boolean TileCollides(OrientedBoundingBox box) { GridBlockCollection gridBlockCollection = GridBlocks.GetBlocksNearBoundingBox(box); if (gridBlockCollection.Count == 0) { return(false); } foreach (GridBlock gridBlock in gridBlockCollection) { if (gridBlock != null && gridBlock.LowBoxTile != null) { foreach (TileBlock tileBlock in gridBlock.LowBoxTile.TileBlocks) { if (tileBlock.TopBoundingBox != null) { if (box.Collides(tileBlock.TopBoundingBox)) { return(true); } } if (tileBlock.BottomBoundingBox != null) { if (box.Collides(tileBlock.BottomBoundingBox)) { return(true); } } } } } return(false); }