Contains() 공개 메소드

Checks if another bounding box is wholly contained inside this one.
public Contains ( BoundingBox other ) : bool
other BoundingBox
리턴 bool
예제 #1
0
		static void KillExplosion(Player player, Vector3I coords) {
			foreach (Player p in world.Players) {
				if (p == player)
					continue;
				Vector3I cpPos = p.Position.ToBlockCoords();
				Vector3I cpPosMax = new Vector3I(cpPos.X + 2, cpPos.Y + 2, cpPos.Z + 2);
				Vector3I cpPosMin = new Vector3I(cpPos.X - 2, cpPos.Y - 2, cpPos.Z - 2);
				BoundingBox bounds = new BoundingBox(cpPosMin, cpPosMax);
				
				if (bounds.Contains(coords) && p.Team != player.Team)
					Kill(player, p, " &cexploded ");
			}
		}
예제 #2
0
        public BlockDBEntry[] Lookup([NotNull] PlayerInfo info, [NotNull] BoundingBox area, TimeSpan span)
        {
            if (!IsEnabled || !IsEnabledGlobally)
            {
                throw new InvalidOperationException("Trying to lookup on disabled BlockDB.");
            }
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            if (area == null)
            {
                throw new ArgumentNullException("area");
            }
            long ticks = DateTime.UtcNow.Subtract(span).ToUnixTime();
            Dictionary <int, BlockDBEntry> results = new Dictionary <int, BlockDBEntry>();
            Map map = World.LoadMap();

            if (isPreloaded)
            {
                lock ( SyncRoot )
                {
                    fixed(BlockDBEntry *entries = cacheStore)
                    {
                        for (int i = CacheSize - 1; i >= 0; i--)
                        {
                            if (entries[i].Timestamp < ticks)
                            {
                                break;
                            }
                            if (entries[i].PlayerID == info.ID && area.Contains(entries[i].X, entries[i].Y, entries[i].Z))
                            {
                                int index = map.Index(entries[i].X, entries[i].Y, entries[i].Z);
                                results[index] = entries[i];
                            }
                        }
                    }
                }
            }
            else
            {
                Flush();
                byte[] bytes      = Load();
                int    entryCount = bytes.Length / BlockDBEntry.Size;
                fixed(byte *parr = bytes)
                {
                    BlockDBEntry *entries = (BlockDBEntry *)parr;

                    for (int i = entryCount - 1; i >= 0; i--)
                    {
                        if (entries[i].Timestamp < ticks)
                        {
                            break;
                        }
                        if (entries[i].PlayerID == info.ID && area.Contains(entries[i].X, entries[i].Y, entries[i].Z))
                        {
                            int index = map.Index(entries[i].X, entries[i].Y, entries[i].Z);
                            results[index] = entries[i];
                        }
                    }
                }
            }
            return(results.Values.ToArray());
        }