Пример #1
0
        public virtual void UpdatePosition(PositionUpdateData data)
        {
            if (BodyPositionUpdated == null)
            {
                return;
            }

            BodyPositionUpdated(this, new BodyPositionUpdatedEventArgs(data, DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond));
        }
Пример #2
0
        public void NewLerp(PositionUpdateData data)
        {
            var vel = new Vector2(data.XVel, data.YVel);
            var pos = new Vector2(data.XPos, data.YPos);

            var currentState = new PositionState(AttachedShip.AngularVelocity, AttachedShip.Rotation, AttachedShip.LinearVelocity, AttachedShip.Position);
            var nextState    = new PositionState(data.AngularVelocity, data.Rotation, vel, pos);

            var newState = LerpState(currentState, nextState);

            AttachedShip.AngularVelocity = newState.AngularVelocity;
            AttachedShip.Rotation        = newState.Rotation;
            AttachedShip.LinearVelocity  = newState.LinearVelocity;
            AttachedShip.Position        = newState.Position;
        }
Пример #3
0
        /// <summary>
        /// Returns false if the ship is not found, true otherwise.
        /// </summary>
        public bool UpdateShip(PositionUpdateData ud)
        {
            if (!_ships.ContainsKey(ud.TargetId))
            {
                return(false);
            }

            var s = _ships[ud.TargetId];

            s.PosX      = ud.XPos;
            s.PosY      = ud.YPos;
            s.Rotation  = ud.Rotation;
            s.VelX      = ud.XVel;
            s.VelY      = ud.YVel;
            s.AngVel    = ud.AngularVelocity;
            s.Thrusting = ud.Thrusting;

            return(true);
        }
Пример #4
0
        private void UpdateShipPosition(PositionUpdateData posUpdate)
        {
            var s = _clientShipManager.GetShip(posUpdate.TargetId);

            if (s == null)
            {
                ClientLogger.Log(Log_Type.ERROR, "RECIEVED POSITION UPDATE FOR A SHIP THAT WAS NOT IN THE SHIPLIST");
                return;
            }
#if DEBUG
            if (_clientShipManager.PlayerShip != null && s.Id == _clientShipManager.PlayerShip.Id)
            {
                ConsoleManager.WriteLine("Error: Received position update for player ship!", ConsoleMessageType.Error);
            }
#endif

            _clientShipManager.HandlePositionUpdate(posUpdate);

            s.Shields.CurrentShields = (int)posUpdate.CurrentShields;
            s.CurrentHealth          = (int)posUpdate.CurrentHealth;
            s.Thrusting = posUpdate.Thrusting;
        }
Пример #5
0
        /// <summary>
        /// Updates ship based on server data
        /// </summary>
        public void HandlePositionUpdate(PositionUpdateData data)
        {
            if (!_shipList.ContainsKey(data.TargetId))
            {
                Console.WriteLine("Could not find ship. The new connection was never added to the shipList.");

                ClientLogger.Log(Log_Type.ERROR, "Could not find ship. The new connection was never added.");
                // Debug for Client

                return;
            }


            if (_updateIgnoreList.Contains(data.TargetId)) //Player's ship or locally simulated ships
            {
                ClientLogger.Log(Log_Type.WARNING, "Ignoring own player ID in update");
                return;
            }

            var ship = _shipList[data.TargetId];

            ship.UpdatePosition(data);
        }
Пример #6
0
 public BodyPositionUpdatedEventArgs(PositionUpdateData newPositionUpdateData, long timestamp)
 {
     NewPositionUpdate = newPositionUpdateData;
     Timestamp         = timestamp;
 }
 public static Vector2 GetPositionFromUpdate(this PositionUpdateData positionUpdate)
 {
     return(new Vector2(positionUpdate.XPos, positionUpdate.YPos));
 }