private void ApplyClientDelta(DreamDeltaState.ClientDelta clientDelta) { if (clientDelta.NewEyeID.HasValue) { ATOM newEye = null; if (clientDelta.NewEyeID.Value != UInt32.MaxValue) { if (Program.OpenDream.ATOMs.ContainsKey(clientDelta.NewEyeID.Value)) { newEye = Program.OpenDream.ATOMs[clientDelta.NewEyeID.Value]; } else { Console.WriteLine("Delta state packet gives a new eye with an invalid ATOM, and was ignored (ID " + clientDelta.NewEyeID.Value + ")"); } } Program.OpenDream.Eye = newEye; } if (clientDelta.ScreenObjectAdditions != null) { foreach (UInt32 screenObjectAtomID in clientDelta.ScreenObjectAdditions) { if (Program.OpenDream.ATOMs.ContainsKey(screenObjectAtomID)) { ATOM screenObject = Program.OpenDream.ATOMs[screenObjectAtomID]; if (!Program.OpenDream.ScreenObjects.Contains(screenObject)) { Program.OpenDream.ScreenObjects.Add(screenObject); } else { Console.WriteLine("Delta state packet says to add a screen object that's already there, and was ignored (ID " + screenObjectAtomID + ")"); } } else { Console.WriteLine("Delta state packet says to add a screen object that doesn't exist, and was ignored (ID " + screenObjectAtomID + ")"); } } } if (clientDelta.ScreenObjectRemovals != null) { foreach (UInt32 screenObjectAtomID in clientDelta.ScreenObjectRemovals) { if (Program.OpenDream.ATOMs.ContainsKey(screenObjectAtomID)) { ATOM screenObject = Program.OpenDream.ATOMs[screenObjectAtomID]; if (Program.OpenDream.ScreenObjects.Contains(screenObject)) { Program.OpenDream.ScreenObjects.Remove(screenObject); } else { Console.WriteLine("Delta state packet says to remove a screen object that's not there, and was ignored (ID " + screenObjectAtomID + ")"); } } else { Console.WriteLine("Delta state packet says to remove a screen object that doesn't exist, and was ignored (ID " + screenObjectAtomID + ")"); } } } }
public PacketDeltaGameState(DreamDeltaState deltaState, string targetCKey) { DeltaState = deltaState; ClientDelta = deltaState.ClientDeltas.ContainsKey(targetCKey) ? deltaState.ClientDeltas[targetCKey] : new DreamDeltaState.ClientDelta(); }