예제 #1
0
 public void AddPhysicalObject(PhysicalObject Object)
 {
     if (!PhysicalObjects.Contains(Object))
     {
         PhysicalObjects.Add(Object);
     }
 }
예제 #2
0
        public void Remove(PhysicalObject po)
        {
            int squareX = (int)(po.Position.X - _lowX) / Square.SquareSize;
            int squareZ = (int)(po.Position.Z - _lowZ) / Square.SquareSize;

            InformNearby(po, new ToClient.DropPhysicalObject(po));
            _square[squareX, squareZ].Remove(po);
            PhysicalObjects.Remove(po.ObjectInstanceId);
            if (po is MobileAvatar)
            {
                Mobiles.Remove((MobileAvatar)po);
            }
            _log.Info("Removed " + po.GetType() + " " + po.ObjectInstanceId + " from the world.");
        }
예제 #3
0
        public void AddPhysicalObjectToStage(PhysicalObject Object, Vector2 Location)
        {
            if (!MainStage.Children.Contains(Object.ObjectImage) && PhysicalObjects.Contains(Object))
            {
                MainStage.Children.Add(Object.ObjectImage);

                if (Object.ColliderHandler != null)
                {
                    MainStage.Children.Add(Object.ColliderHandler.BoxCollider);
                    ManagerCollision.AddCollider(Object.ColliderHandler);
                }

                SetLocation(Object, Location.X, Location.Y);
            }
        }
예제 #4
0
        public void Add(PhysicalObject po)
        {
            if (po.Position.X > _highX || po.Position.Z > _highZ ||
                po.Position.X < _lowX || po.Position.Z < _lowZ)
            {
                _log.Error("Tried to add physical object " + po.ObjectInstanceId + " outside the world.");
                return;
            }

            if (po is Terrain)
            {
                // keep terrain separate
                int terrainX = DivTruncate((int)(po.Position.X - _lowX), Constants.TerrainPieceSize);
                int terrainZ = DivTruncate((int)(po.Position.Z - _lowZ), Constants.TerrainPieceSize);
                _terrain[terrainX, terrainZ] = (Terrain)po;
            }
            else
            {
                // keep everything at ground level
                double?altitude = AltitudeAt(po.Position.X, po.Position.Z);
                if (altitude.HasValue)
                {
                    po.Position.Y = altitude.Value + po.Height / 2F;
                }
                else
                {
                    _log.Warn("Physical object " + po.ObjectInstanceId + " is not on terrain.");
                }

                // add the object to the world
                PhysicalObjects.Add(po.ObjectInstanceId, po);
                if (po is MobileAvatar)
                {
                    Mobiles.Add((MobileAvatar)po);
                }
                int squareX = (int)(po.Position.X - _lowX) / Square.SquareSize;
                int squareZ = (int)(po.Position.Z - _lowZ) / Square.SquareSize;
                if (_square[squareX, squareZ] == null)
                {
                    _square[squareX, squareZ] = new Square();
                }
                _square[squareX, squareZ].Add(po);
            }
            // notify all nearby clients that a new
            // physical object has entered the world
            InformNearby(po, ToClient.AddPhysicalObject.CreateMessage(po));
            //Log.Info( "Added new " + po.GetType() + " " + po.ObjectInstanceID + " at (" + po.Position.X + "," + po.Position.Y + "," +po.Position.Z + ") - ("+squareX+","+squareZ+")" );
        }
예제 #5
0
        public void RemovePhysicalObject(PhysicalObject Object)
        {
            if (PhysicalObjects.Contains(Object))
            {
                PhysicalObjects.Remove(Object);

                if (MainStage.Children.Contains(Object.ObjectImage))
                {
                    MainStage.Children.Remove(Object.ObjectImage);

                    if (Object.ColliderHandler != null)
                    {
                        MainStage.Children.Remove(Object.ColliderHandler.BoxCollider);
                        ManagerCollision.RemoveCollider(Object.ColliderHandler);
                    }
                }
            }
        }