public static Deserialize ( int maxChannels, List |
||
maxChannels | int | |
existingActorStates | List |
|
frameActorStates | List |
|
objectIndexToName | string | |
classNetCacheByName | ClassNetCache>.IDictionary | |
versionMajor | ||
versionMinor | ||
br | BitReader | |
return |
public static Frame Deserialize(ref List <ActorState> existingActorStates, IDictionary <int, string> objectIdToName, IEnumerable <ClassNetCache> classNetCache, BitReader br) { var f = new Frame(); f.Position = br.Position; f.Time = br.ReadFloat(); f.Delta = br.ReadFloat(); f.ActorStates = new List <ActorState>(); ActorState lastActorState = null; while (br.ReadBit()) { lastActorState = ActorState.Deserialize(existingActorStates, f.ActorStates, objectIdToName, classNetCache, br); var existingActor = existingActorStates.Where(x => x.Id == lastActorState.Id).SingleOrDefault(); if (lastActorState.State != ActorStateState.Deleted) { if (existingActor == null) { existingActorStates.Add(lastActorState); } } else { existingActorStates = existingActorStates.Where(x => x.Id != lastActorState.Id).ToList(); } f.ActorStates.Add(lastActorState); #if DEBUG if (!lastActorState.Complete) { break; } #endif } #if DEBUG if (lastActorState == null || lastActorState.Complete) { f.Complete = true; } if (lastActorState != null && lastActorState.Failed) { f.Failed = true; } f.RawData = br.GetBits(f.Position, br.Position - f.Position).ToArray(); #endif return(f); }
public static Frame Deserialize(int maxChannels, ref List <ActorState> existingActorStates, string[] objectIdToName, IDictionary <string, ClassNetCache> classNetCacheByName, UInt32 versionMajor, UInt32 versionMinor, BitReader br) { var f = new Frame(); f.Position = br.Position; f.Time = br.ReadFloat(); f.Delta = br.ReadFloat(); if (f.Time < 0 || f.Delta < 0 || (f.Time > 0 && f.Time < 1E-10) || (f.Delta > 0 && f.Delta < 1E-10)) { string error = string.Format("\"Frame\" at postion {0} has time values that are negative or suspicious. The parser got lost. Check the previous frame for bad data. Time {1}, Delta {2}", f.Position, f.Time, f.Delta); #if DEBUG Console.WriteLine(error); f.Failed = true; return(f); #endif throw new Exception(error); } f.ActorStates = new List <ActorState>(); ActorState lastActorState = null; while (br.ReadBit()) { lastActorState = ActorState.Deserialize(maxChannels, existingActorStates, f.ActorStates, objectIdToName, classNetCacheByName, versionMajor, versionMinor, br); var existingActor = existingActorStates.Where(x => x.Id == lastActorState.Id).SingleOrDefault(); if (lastActorState.State != ActorStateState.Deleted) { if (existingActor == null) { existingActorStates.Add(lastActorState); } } else { existingActorStates = existingActorStates.Where(x => x.Id != lastActorState.Id).ToList(); } f.ActorStates.Add(lastActorState); #if DEBUG if (!lastActorState.Complete) { break; } #endif } #if DEBUG if (lastActorState == null || lastActorState.Complete) { f.Complete = true; } if (lastActorState != null && lastActorState.Failed) { f.Failed = true; } f.RawData = br.GetBits(f.Position, br.Position - f.Position).ToArray(); #endif return(f); }