public static PseudoFullGameWorldState Create(GameCore game)
        {
            var state = new PseudoFullGameWorldState();

            state.Overwrite(game);
            return(state);
        }
        public PseudoFullGameWorldState MakeDelta(PseudoFullGameWorldState lastState)
        {
            var state = new PseudoFullGameWorldState();

            foreach (var obj in lastState.ObjectStates.Values)
            {
                //It was destroyed, flag it
                if (!ObjectStates.ContainsKey(obj.ObjectId))
                {
                    state._objectStates.Add(obj.ObjectId, new PseudoFullObjectState(obj, true));
                }
                //Otherwise, compute state differences
                else
                {
                    var objState = new PseudoFullObjectState(obj, ObjectStates[obj.ObjectId]);
                    if (objState.HasChanges(obj))
                    {
                        state._objectStates.Add(obj.ObjectId, objState);
                    }
                }
            }

            //Then do a reverse search to find the new ones
            foreach (var obj in ObjectStates.Values)
            {
                if (!lastState.ObjectStates.ContainsKey(obj.ObjectId) &&
                    !state.ObjectStates.ContainsKey(obj.ObjectId))
                {
                    state._objectStates.Add(obj.ObjectId, obj);
                }
            }

            state.CurrentGameStatus           = CurrentGameStatus;
            state.CurrentGameTimeMilliseconds = CurrentGameTimeMilliseconds;
            state.FriendlyFireEnabled         = FriendlyFireEnabled;

            return(state);
        }
        public static PseudoFullGameWorldState Read(NetIncomingMessage message)
        {
            var state = new PseudoFullGameWorldState();

            state.CurrentGameStatus           = (GameCore.CurrentGameStatus)message.ReadByte();
            state.CurrentGameTimeMilliseconds = message.ReadDouble();
            state.FriendlyFireEnabled         = message.ReadBoolean();

            message.ReadPadBits();

            var ct = message.ReadUInt16();

            for (var i = 0; i < ct; i++)
            {
                var objState = new PseudoFullObjectState();
                objState.ObjectId                = message.ReadUInt16();
                objState.VelocityChanged         = message.ReadBoolean();
                objState.PositionChanged         = message.ReadBoolean();
                objState.RotationChanged         = message.ReadBoolean();
                objState.RotationVelocityChanged = message.ReadBoolean();
                objState.RestitutionChanged      = message.ReadBoolean();
                objState.SizeChanged             = message.ReadBoolean();
                objState.IsSensorObject          = message.ReadBoolean();
                objState.IsStaticObject          = message.ReadBoolean();
                objState.WasDestroyed            = message.ReadBoolean();

                message.ReadPadBits();

                if (objState.VelocityChanged)
                {
                    objState.Velocity = new HalfVector2 {
                        PackedValue = message.ReadUInt32()
                    }
                }
                ;

                if (objState.PositionChanged)
                {
                    objState.Position = new Vector2(message.ReadFloat(), message.ReadFloat());
                }

                if (objState.RotationChanged)
                {
                    objState.Rotation = new Half()
                    {
                        InternalValue = message.ReadUInt16()
                    }
                }
                ;

                if (objState.RotationVelocityChanged)
                {
                    objState.RotationVelocity = new Half()
                    {
                        InternalValue = message.ReadUInt16()
                    }
                }
                ;

                if (objState.RestitutionChanged)
                {
                    objState.Restitution = new Half()
                    {
                        InternalValue = message.ReadUInt16()
                    }
                }
                ;

                if (objState.SizeChanged)
                {
                    objState.Size = new HalfVector2()
                    {
                        PackedValue = message.ReadUInt32()
                    }
                }
                ;

                state._objectStates.Add(objState.ObjectId, objState);
            }

            return(state);
        }