fCraft.Map.InBounds C# (CSharp) Method

InBounds() public method

Checks whether the given coordinate (in block units) is within the bounds of the map.
public InBounds ( Vector3I vec ) : bool
vec Vector3I Coordinate vector (X,Y,Z).
return bool
        public bool InBounds( Vector3I vec )
        {
            return vec.X < Width && vec.Y < Length && vec.Z < Height && vec.X >= 0 && vec.Y >= 0 && vec.Z >= 0;
        }

Same methods

Map::InBounds ( int x, int y, int z ) : bool

Usage Example

Example #1
0
        private static void PlayerMoving(object sender, PlayerMovingEventArgs e)
        {
            if (_world != null && e.Player.World == _world)
            {
                if (_world.gameMode == GameMode.MineField && !Failed.Contains(e.Player))
                {
                    if (e.NewPosition != null)
                    {
                        Vector3I oldPos = new Vector3I(e.OldPosition.X / 32, e.OldPosition.Y / 32, e.OldPosition.Z / 32);
                        Vector3I newPos = new Vector3I(e.NewPosition.X / 32, e.NewPosition.Y / 32, e.NewPosition.Z / 32);

                        if (oldPos.X != newPos.X || oldPos.Y != newPos.Y || oldPos.Z != newPos.Z)
                        {
                            if (!_map.InBounds(newPos))
                            {
                                e.Player.TeleportTo(_map.Spawn);
                                newPos = ( Vector3I )_map.Spawn;
                            }
                            // Check if the player jumped, flew, whatevers
                            if (newPos.Z > _ground + 2)
                            {
                                e.Player.TeleportTo(e.OldPosition);
                                newPos = oldPos;
                            }
                            foreach (Vector3I pos in Mines.Values)
                            {
                                if (newPos == new Vector3I(pos.X, pos.Y, pos.Z + 2) ||
                                    newPos == new Vector3I(pos.X, pos.Y, pos.Z + 1) ||
                                    newPos == new Vector3I(pos.X, pos.Y, pos.Z))
                                {
                                    _world.Map.QueueUpdate(new BlockUpdate(null, pos, Block.TNT));
                                    _world.AddPhysicsTask(new TNTTask(_world, pos, null, true, false), 0);
                                    Vector3I removed;
                                    Mines.TryRemove(pos.ToString(), out removed);
                                }
                            }
                            if (_map.GetBlock(newPos.X, newPos.Y, newPos.Z - 2) == Block.Green &&
                                !_stopped)
                            {
                                _stopped = true;
                                Stop(e.Player, true);
                            }
                        }
                    }
                }
            }
        }
All Usage Examples Of fCraft.Map::InBounds