public bool Replace( SerialObject oldObj, SerialObject newObj ) { if( oldObj != null && newObj != null ) { if( oldObj.Serial.Type != newObj.Serial.Type ) return false; Dictionary<int, SerialObject> dic = GetDictionary( oldObj.Serial.Type ); if( dic.ContainsKey( oldObj.Serial ) == true ) dic[ oldObj.Serial ] = newObj; else dic.Add( newObj.Serial, newObj ); return true; } if( oldObj != null ) { Dictionary<int, SerialObject> dic = GetDictionary( oldObj.Serial.Type ); dic.Remove( oldObj.Serial ); return true; } if( newObj != null ) { Dictionary<int, SerialObject> dic = GetDictionary( newObj.Serial.Type ); dic.Add( newObj.Serial, newObj ); return true; } return false; }
public void serialize() { height = GetComponent<Background>().height; width = GetComponent<Background>().width; start = GetComponent<Background>().start; end = GetComponent<Background>().end; dangerMap = GetComponent<DangerMap>().getDangerMap(); var = GetComponent<DangerMap>().var; enemies = GetComponent<Enemies>().getEnemy(); trace = GetComponent<Player>().getTrace(); filteredTrace_a = GetComponent<Player>().get_filteredTrace_a(); filteredTrace_b = GetComponent<Player>().get_filteredTrace_b(); stepsize = GetComponent<Player>().stepsize; forecast_d = GetComponent<Forecast>().get_forecast_d(); angle = GetComponent<Forecast>().angle; SerialObject obj = new SerialObject(width, height, start, end, dangerMap, var, enemies, trace, filteredTrace_a, filteredTrace_b, stepsize, forecast_d, angle); string file = dir + filePrefix + "_serial.xml"; Stream stream = File.Open(file, FileMode.Create); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, obj); stream.Close(); }
public void addSprite(string path, Sprite sprite) { SerialObject obj = new SerialObject(); obj.m_sprite = sprite; obj.m_path = path; m_objList.Add(obj); }
private static void WalkToXY_Tick(SerialObject obj) { // Player needs to notify clients about a successfull move if (obj is Character) { ((obj as Character).Parent.Netstate).Send(new WorldWalkOK(obj as Character)); } }
public bool Add( SerialObject u ) { Dictionary<int, SerialObject> dic = GetDictionary( u.Serial.Type ); if( dic.ContainsKey( u.Serial ) == false ) { dic.Add( u.Serial, u ); return true; } return false; }
public bool Remove( SerialObject u ) { Dictionary<int, SerialObject> dic = GetDictionary( u.Serial.Type ); if( dic.ContainsKey( u.Serial ) == true ) { dic.Remove( u.Serial ); return true; } return false; }
/// <summary> /// Generic Method to add HP /// </summary> /// <param name="Player"></param> /// <param name="Item"></param> public static void AddHP(SerialObject obj, params object[] args) { Item item = obj as Item; if (item == null) { return; } if (args == null || args.Length == 0) { return; } //Player.Active.Status.AddHP( (int)args[ 0 ] ); // gets <Value> HP }
public void OnLeave(SerialObject obj) { Remove(obj); }
public void OnEnter(SerialObject obj) { Add(obj); }
public void OnLeave( SerialObject obj ) { Remove( obj ); }
private void Move( SerialObject obj, Point3D OldLocation ) { this[ OldLocation ].DelUnit( obj ); this[ obj.Location.X, obj.Location.Y ].AddUnit( obj ); }
internal int? ParseRecord(SerialObject parentObject) { int? serialObjectReferenceID = null; if (PendingNullCounter == 0) { long startPosition = reader.BaseStream.Position; SerialObject si = null; RecordTypeEnumeration nextRecordType = (RecordTypeEnumeration)reader.ReadByte(); switch (nextRecordType) { case RecordTypeEnumeration.SerializedStreamHeader: //header is 4 values that I wouldn't know what to do with (what type of message, what version, etc) - trash. reader.ReadBytes(16); break; case RecordTypeEnumeration.ClassWithID: //just two ints, read directly si = new ClassInfo().ReadObjectId(this); int refObj = reader.ReadInt32(); //Use the referenced object definition for data retrieval rules // -> this will overwrite the original values in the referenced object, but who cares - the values are trash anyway (for now). ((ClassInfo)SerialObjectsFound[refObj]).ReadValues(this); break; case RecordTypeEnumeration.SystemClassWithMembers: si = new ClassInfo().ReadMembers(this).ReadValues(this); break; case RecordTypeEnumeration.ClassWithMembers: si = new ClassInfo().ReadMembers(this).ReadLibraryId(this).ReadValues(this); break; case RecordTypeEnumeration.SystemClassWithMembersAndTypes: si = new ClassInfo().ReadMembers(this).ReadTypeInfo(this).ReadValues(this); break; case RecordTypeEnumeration.ClassWithMembersAndTypes: si = new ClassInfo().ReadMembers(this).ReadTypeInfo(this).ReadLibraryId(this).ReadValues(this); break; case RecordTypeEnumeration.BinaryObjectString: si = new ObjectString().ReadObjectId(this).ReadString(this); break; case RecordTypeEnumeration.BinaryArray: si = new BinaryArray().ReadStruct(this).ReadValues(this); break; case RecordTypeEnumeration.MemberPrimitiveTyped: //Don't know how this can happen - I think it's for messages/remoting only throw new NotImplementedException(); case RecordTypeEnumeration.MemberReference: //just return the ID that was referenced. serialObjectReferenceID = reader.ReadInt32(); break; case RecordTypeEnumeration.ObjectNull: //a single null; do nothing, as null is the default return value. break; case RecordTypeEnumeration.MessageEnd: //do nothing, quit. Wasn't that fun? endRecordReached = true; break; case RecordTypeEnumeration.BinaryLibrary: int newLibraryID = reader.ReadInt32(); LibrariesFound.Add(newLibraryID, new BinaryLibrary { LibraryID = newLibraryID, Name = ReadAssemblyName() }); break; case RecordTypeEnumeration.ObjectNullMultiple256: //a sequence of nulls; return null, and start a counter to continue returning N nulls over the next calls. PendingNullCounter = reader.ReadByte() - 1; break; case RecordTypeEnumeration.ObjectNullMultiple: //a sequence of nulls; return null, and start a counter to continue returning N nulls over the next calls. PendingNullCounter = reader.ReadInt32() - 1; //not yet tested: if it happens, take a look around. throw new NotImplementedException(); case RecordTypeEnumeration.ArraySinglePrimitive: si = new BinaryArray(BinaryTypeEnumeration.Primitive).ReadObjectId(this).ReadLengths(this).ReadPrimitiveType(this).ReadValues(this); break; case RecordTypeEnumeration.ArraySingleObject: si = new BinaryArray(BinaryTypeEnumeration.Object).ReadObjectId(this).ReadLengths(this).ReadValues(this); //not yet tested: if it happens, take a look around. throw new NotImplementedException(); case RecordTypeEnumeration.ArraySingleString: si = new BinaryArray(BinaryTypeEnumeration.String).ReadObjectId(this).ReadLengths(this).ReadValues(this); //not yet tested: if it happens, take a look around. throw new NotImplementedException(); case RecordTypeEnumeration.MethodCall: //messages/remoting functionality not implemented throw new NotImplementedException(); case RecordTypeEnumeration.MethodReturn: //messages/remoting functionality not implemented throw new NotImplementedException(); default: throw new Exception("Parsing appears to have failed dramatically. Unknown record type, we must be lost in the bytestream!"); } //standard: if this was a serial object, add to list and record its length. if (si != null) { if (parentObject != null) si.ParentObjectID = parentObject.ObjectID; SerialObjectsFound.Add(si.ObjectID, si); return si.ObjectID; } } else PendingNullCounter--; return serialObjectReferenceID; }
private void Remove(SerialObject obj) { this[obj.Location.X, obj.Location.Y].DelUnit(obj); obj.Map = null; }
internal int?ParseRecord(SerialObject parentObject) { int?serialObjectReferenceID = null; if (PendingNullCounter == 0) { long startPosition = reader.BaseStream.Position; SerialObject si = null; ClassInfo ci = null, ttccii = null; RecordTypeEnumeration nextRecordType = (RecordTypeEnumeration)reader.ReadByte(); Log("============= " + Enum.GetName(typeof(RecordTypeEnumeration), nextRecordType) + " ================="); switch (nextRecordType) { case RecordTypeEnumeration.SerializedStreamHeader: Log(new SerializationHeaderRecord(this)); // reader.ReadBytes(16); break; case RecordTypeEnumeration.ClassWithID: //just two ints, read directly ci = new ClassInfo(); ci.ObjectID = reader.ReadInt32(); LogInternal("ObjectID=" + ci.ObjectID); ci.ReferencedObject = reader.ReadInt32(); LogInternal("ReferencedID=" + ci.ReferencedObject); //Use the referenced object definition for data retrieval rules // -> this will overwrite the original values in the referenced object, but who cares - the values are trash anyway (for now). ttccii = (ClassInfo)SerialObjectsFound[ci.ReferencedObject.Value]; ttccii.ReadValueInfo(this); si = ci; break; case RecordTypeEnumeration.SystemClassWithMembers: //single structure, read in constructor si = new ClassInfo(this); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.ClassWithMembers: //single structure, read in constructor si = new ClassInfo(this); //also library ID, read into place. ((ClassInfo)si).LibraryID = reader.ReadInt32(); LogInternal("LibraryID=" + ((ClassInfo)si).LibraryID); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.SystemClassWithMembersAndTypes: //single structure, read in constructor si = new ClassInfo(this); //also member type info, read into place. ((ClassInfo)si).ReadTypeInfo(this); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.ClassWithMembersAndTypes: //single structure, read in constructor si = new ClassInfo(this); //also member type info, read into place. ((ClassInfo)si).ReadTypeInfo(this); //also library ID, read into place. ((ClassInfo)si).LibraryID = reader.ReadInt32(); LogInternal("LibraryID=" + ((ClassInfo)si).LibraryID); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.BinaryObjectString: //simple structure, just an ID and a string si = new ObjectString(); si.ObjectID = reader.ReadInt32(); LogInternal("ObjectID=" + si.ObjectID); ((ObjectString)si).String = reader.ReadString(); LogInternal("String=" + ((ObjectString)si).String); break; case RecordTypeEnumeration.BinaryArray: //complex process, read in constructor. si = new BinaryArray(this); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.MemberPrimitiveTyped: MessagePrimitiveTyped msg = new MessagePrimitiveTyped(this); msg.ReadValueInfo(this); break; case RecordTypeEnumeration.MemberReference: //just return the ID that was referenced. serialObjectReferenceID = reader.ReadInt32(); Log("::::> Reference=" + serialObjectReferenceID); break; case RecordTypeEnumeration.ObjectNull: //a single null; do nothing, as null is the default return value. Log("::::> NULL VALUE"); break; case RecordTypeEnumeration.MessageEnd: //do nothing, quit. Wasn't that fun? endRecordReached = true; Log(":::::> End-of-message"); break; case RecordTypeEnumeration.BinaryLibrary: int newLibraryID = reader.ReadInt32(); LibrariesFound.Add(newLibraryID, new BinaryLibrary()); LibrariesFound[newLibraryID].LibraryID = newLibraryID; LibrariesFound[newLibraryID].Name = reader.ReadString(); LibrariesFound[newLibraryID].recordLength = reader.BaseStream.Position - startPosition; Log("\t" + LibrariesFound[newLibraryID].ToString()); break; case RecordTypeEnumeration.ObjectNullMultiple256: //a sequence of nulls; return null, and start a counter to continue returning N nulls over the next calls. PendingNullCounter = reader.ReadByte() - 1; Log("\tPending Null256 Counter=" + (PendingNullCounter + 1)); break; case RecordTypeEnumeration.ObjectNullMultiple: //a sequence of nulls; return null, and start a counter to continue returning N nulls over the next calls. PendingNullCounter = reader.ReadInt32() - 1; Log("\tPending Null Counter=" + (PendingNullCounter + 1)); #if (DEBUG) //not yet tested: if it happens, take a look around. System.Diagnostics.Debugger.Break(); #endif break; case RecordTypeEnumeration.ArraySinglePrimitive: //This one's pretty easy to build, do locally. si = new BinaryArray(); si.ObjectID = reader.ReadInt32(); LogInternal("ObjectID=" + si.ObjectID); ((BinaryArray)si).ArrayType = BinaryArrayTypeEnumeration.Single; LogInternal("ArrayType=" + Enum.GetName(typeof(BinaryArrayTypeEnumeration), ((BinaryArray)si).ArrayType)); ((BinaryArray)si).BinaryType = BinaryTypeEnumeration.Primitive; LogInternal("BinaryType=" + Enum.GetName(typeof(BinaryTypeEnumeration), ((BinaryArray)si).BinaryType)); ((BinaryArray)si).Rank = 1; LogInternal("Rank=" + ((BinaryArray)si).Rank); ((BinaryArray)si).Lengths = new List <int>(); ((BinaryArray)si).Lengths.Add(reader.ReadInt32()); LogInternal("Lenghts=" + ToString(((BinaryArray)si).Lengths)); ((BinaryArray)si).PrimitiveType = (PrimitiveTypeEnumeration)reader.ReadByte(); LogInternal("PrimitiveType=" + Enum.GetName(typeof(PrimitiveTypeEnumeration), ((BinaryArray)si).PrimitiveType)); //and then read the values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.ArraySingleObject: //This should be pretty easy to build, do locally. si = new BinaryArray(); si.ObjectID = reader.ReadInt32(); LogInternal("ObjectID=" + si.ObjectID); ((BinaryArray)si).ArrayType = BinaryArrayTypeEnumeration.Single; LogInternal("ArrayType=" + Enum.GetName(typeof(BinaryArrayTypeEnumeration), ((BinaryArray)si).ArrayType)); ((BinaryArray)si).BinaryType = BinaryTypeEnumeration.Object; LogInternal("BinaryType=" + Enum.GetName(typeof(BinaryTypeEnumeration), ((BinaryArray)si).BinaryType)); ((BinaryArray)si).Rank = 1; LogInternal("Rank=" + ((BinaryArray)si).Rank); ((BinaryArray)si).Lengths = new List <int>(); ((BinaryArray)si).Lengths.Add(reader.ReadInt32()); LogInternal("Lenghts=" + ToString(((BinaryArray)si).Lengths)); //and then read the values. si.ReadValueInfo(this); #if (DEBUG) //not yet tested: if it happens, take a look around. System.Diagnostics.Debugger.Break(); #endif break; case RecordTypeEnumeration.ArraySingleString: //This should be pretty easy to build, do locally. si = new BinaryArray(); si.ObjectID = reader.ReadInt32(); LogInternal("ObjectID=" + si.ObjectID); ((BinaryArray)si).ArrayType = BinaryArrayTypeEnumeration.Single; LogInternal("ArrayType=" + Enum.GetName(typeof(BinaryArrayTypeEnumeration), ((BinaryArray)si).ArrayType)); ((BinaryArray)si).BinaryType = BinaryTypeEnumeration.String; LogInternal("BinaryType=" + Enum.GetName(typeof(BinaryTypeEnumeration), ((BinaryArray)si).BinaryType)); ((BinaryArray)si).Rank = 1; LogInternal("Rank=" + ((BinaryArray)si).Rank); ((BinaryArray)si).Lengths = new List <int>(); ((BinaryArray)si).Lengths.Add(reader.ReadInt32()); LogInternal("Lenghts=" + ToString(((BinaryArray)si).Lengths)); //and then read the values. si.ReadValueInfo(this); #if (DEBUG) //not yet tested: if it happens, take a look around. System.Diagnostics.Debugger.Break(); #endif break; case RecordTypeEnumeration.MethodCall: //messages/remoting functionality not implemented throw new NotImplementedException("Method Call N/A"); case RecordTypeEnumeration.MethodReturn: //messages/remoting functionality not implemented throw new NotImplementedException("Method Return N/A"); default: throw new Exception("Parsing appears to have failed dramatically. Unknown record type, we must be lost in the bytestream!"); } //standard: if this was a serial object, add to list and record its length. if (si != null) { Log(si); SerialObjectsFound.Add(si.ObjectID, si); SerialObjectsFound[si.ObjectID].recordLength = reader.BaseStream.Position - startPosition; if (parentObject != null) { SerialObjectsFound[si.ObjectID].ParentObjectID = parentObject.ObjectID; } return(si.ObjectID); } } else { PendingNullCounter--; } return(serialObjectReferenceID); }
private void Add( SerialObject obj ) { this[ obj.Location.X, obj.Location.Y ].AddUnit( obj ); obj.Map = this; }
public void DelUnit( SerialObject Unit ) { if( mEvent.HasEvent() ) mEvent.OnLeave( Unit ); mUnits.Remove( Unit ); }
public void AddUnit( SerialObject Unit ) { mUnits.Add( Unit ); if( mEvent.HasEvent() ) mEvent.OnEnter( Unit ); }
private void Replace( SerialObject oldObj, SerialObject newObj ) { this[ oldObj.Location.X, oldObj.Location.Y ].Units.Replace( oldObj, newObj ); oldObj.Map = null; newObj.Map = this; }
public void OnMove(SerialObject obj, Point3D OldLocation) { Move(obj, OldLocation); }
public static void WalkToXY(SerialObject obj, NetState state) { Timer.DelayCall(TimeSpan.FromMilliseconds(120), new TimerStateCallback<SerialObject>(WalkToXY_Tick), obj); }
private void Add(SerialObject obj) { this[obj.Location.X, obj.Location.Y].AddUnit(obj); obj.Map = this; }
public void OnMove( SerialObject obj, Point3D OldLocation ) { Move( obj, OldLocation ); }
private void Move(SerialObject obj, Point3D OldLocation) { this[OldLocation].DelUnit(obj); this[obj.Location.X, obj.Location.Y].AddUnit(obj); }
public virtual void OnLeave( SerialObject obj ) { }
internal long? ParseRecord(SerialObject parentObject) { long? serialObjectReferenceID = null; if(PendingNullCounter == 0) { long startPosition = reader.BaseStream.Position; SerialObject si = null; RecordTypeEnumeration nextRecordType = (RecordTypeEnumeration)reader.ReadByte(); switch(nextRecordType) { case RecordTypeEnumeration.SerializedStreamHeader: //header is 4 values that I wouldn't know what to do with (what type of message, what version, etc) - trash. reader.ReadBytes(16); break; case RecordTypeEnumeration.ClassWithID: //just two ints, read directly si = new ClassInfo(); si.ObjectID = ReadID(); ((ClassInfo)si).ReferencedObject = ReadID(); //Use the referenced object definition for data retrieval rules // -> this will overwrite the original values in the referenced object, but who cares - the values are trash anyway (for now). ((ClassInfo)SerialObjectsFound[((ClassInfo)si).ReferencedObject.Value]).ReadValueInfo(this); break; case RecordTypeEnumeration.SystemClassWithMembers: //single structure, read in constructor si = new ClassInfo(this); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.ClassWithMembers: //single structure, read in constructor si = new ClassInfo(this); //also library ID, read into place. ((ClassInfo)si).LibraryID = ReadID(); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.SystemClassWithMembersAndTypes: //single structure, read in constructor si = new ClassInfo(this); //also member type info, read into place. ((ClassInfo)si).ReadTypeInfo(this); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.ClassWithMembersAndTypes: //single structure, read in constructor si = new ClassInfo(this); //also member type info, read into place. ((ClassInfo)si).ReadTypeInfo(this); //also library ID, read into place. ((ClassInfo)si).LibraryID = ReadID(); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.BinaryObjectString: //simple structure, just an ID and a string si = new ObjectString(); si.ObjectID = ReadID(); ((ObjectString)si).String = reader.ReadString(); break; case RecordTypeEnumeration.BinaryArray: //complex process, read in constructor. si = new BinaryArray(this); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.MemberPrimitiveTyped: var junk = new MemberInfo(); junk.BinaryType = BinaryTypeEnumeration.Primitive; junk.PrimitiveType = (PrimitiveTypeEnumeration)reader.ReadByte(); TypeHelper.GetTypeValue(junk, junk, this); break; case RecordTypeEnumeration.MemberReference: //just return the ID that was referenced. serialObjectReferenceID = ReadID(); break; case RecordTypeEnumeration.ObjectNull: //a single null; do nothing, as null is the default return value. break; case RecordTypeEnumeration.MessageEnd: //do nothing, quit. Wasn't that fun? endRecordReached = true; break; case RecordTypeEnumeration.BinaryLibrary: var newLibraryID = ReadID(); LibrariesFound.Add(newLibraryID, new BinaryLibrary { LibraryID = newLibraryID, Name = reader.ReadString(), recordLength = reader.BaseStream.Position - startPosition, }); break; case RecordTypeEnumeration.ObjectNullMultiple256: //a sequence of nulls; return null, and start a counter to continue returning N nulls over the next calls. PendingNullCounter = reader.ReadByte() - 1; break; case RecordTypeEnumeration.ObjectNullMultiple: //a sequence of nulls; return null, and start a counter to continue returning N nulls over the next calls. PendingNullCounter = reader.ReadInt32() - 1; #if (DEBUG) //not yet tested: if it happens, take a look around. System.Diagnostics.Debugger.Break(); #endif break; case RecordTypeEnumeration.ArraySinglePrimitive: //This one's pretty easy to build, do locally. si = new BinaryArray(); si.ObjectID = ReadID(); ((BinaryArray)si).ArrayType = BinaryArrayTypeEnumeration.Single; ((BinaryArray)si).BinaryType = BinaryTypeEnumeration.Primitive; ((BinaryArray)si).Rank = 1; ((BinaryArray)si).Lengths = new List<int>(); ((BinaryArray)si).Lengths.Add(reader.ReadInt32()); ((BinaryArray)si).PrimitiveType = (PrimitiveTypeEnumeration)reader.ReadByte(); //and then read the values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.ArraySingleObject: //This should be pretty easy to build, do locally. si = new BinaryArray(); si.ObjectID = ReadID(); ((BinaryArray)si).ArrayType = BinaryArrayTypeEnumeration.Single; ((BinaryArray)si).BinaryType = BinaryTypeEnumeration.Object; ((BinaryArray)si).Rank = 1; ((BinaryArray)si).Lengths = new List<int>(); ((BinaryArray)si).Lengths.Add(reader.ReadInt32()); //and then read the values. si.ReadValueInfo(this); #if (DEBUG) //not yet tested: if it happens, take a look around. System.Diagnostics.Debugger.Break(); #endif break; case RecordTypeEnumeration.ArraySingleString: //This should be pretty easy to build, do locally. si = new BinaryArray(); si.ObjectID = ReadID(); ((BinaryArray)si).ArrayType = BinaryArrayTypeEnumeration.Single; ((BinaryArray)si).BinaryType = BinaryTypeEnumeration.String; ((BinaryArray)si).Rank = 1; ((BinaryArray)si).Lengths = new List<int>(); ((BinaryArray)si).Lengths.Add(reader.ReadInt32()); //and then read the values. si.ReadValueInfo(this); #if (DEBUG) //not yet tested: if it happens, take a look around. System.Diagnostics.Debugger.Break(); #endif break; case RecordTypeEnumeration.MethodCall: //messages/remoting functionality not implemented throw new NotImplementedException(nextRecordType.ToString()); case RecordTypeEnumeration.MethodReturn: //messages/remoting functionality not implemented throw new NotImplementedException(nextRecordType.ToString()); default: throw new Exception("Parsing appears to have failed dramatically. Unknown record type, we must be lost in the bytestream!"); } //standard: if this was a serial object, add to list and record its length. if(si != null) { SerialObjectsFound.Add(si.ObjectID, si); si.recordLength = reader.BaseStream.Position - startPosition; if(parentObject != null) si.ParentObjectID = parentObject.ObjectID; return si.ObjectID; } } else PendingNullCounter--; return serialObjectReferenceID; }
private void Remove( SerialObject obj ) { this[ obj.Location.X, obj.Location.Y ].DelUnit( obj ); obj.Map = null; }
public void OnEnter( SerialObject Unit ) { if( OnEnterHandler != null ) OnEnterHandler( Unit ); }
public void OnLeave( SerialObject Unit ) { if( OnLeaveHandler != null ) OnLeaveHandler( Unit ); }
public virtual void OnEnter( SerialObject obj ) { }
internal long?ParseRecord(SerialObject parentObject) { long?serialObjectReferenceID = null; if (PendingNullCounter == 0) { long startPosition = reader.BaseStream.Position; SerialObject si = null; RecordTypeEnumeration nextRecordType = (RecordTypeEnumeration)reader.ReadByte(); switch (nextRecordType) { case RecordTypeEnumeration.SerializedStreamHeader: //header is 4 values that I wouldn't know what to do with (what type of message, what version, etc) - trash. reader.ReadBytes(16); break; case RecordTypeEnumeration.ClassWithID: //just two ints, read directly si = new ClassInfo(); si.ObjectID = ReadID(); ((ClassInfo)si).ReferencedObject = ReadID(); //Use the referenced object definition for data retrieval rules // -> this will overwrite the original values in the referenced object, but who cares - the values are trash anyway (for now). ((ClassInfo)SerialObjectsFound[((ClassInfo)si).ReferencedObject.Value]).ReadValueInfo(this); break; case RecordTypeEnumeration.SystemClassWithMembers: //single structure, read in constructor si = new ClassInfo(this); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.ClassWithMembers: //single structure, read in constructor si = new ClassInfo(this); //also library ID, read into place. ((ClassInfo)si).LibraryID = ReadID(); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.SystemClassWithMembersAndTypes: //single structure, read in constructor si = new ClassInfo(this); //also member type info, read into place. ((ClassInfo)si).ReadTypeInfo(this); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.ClassWithMembersAndTypes: //single structure, read in constructor si = new ClassInfo(this); //also member type info, read into place. ((ClassInfo)si).ReadTypeInfo(this); //also library ID, read into place. ((ClassInfo)si).LibraryID = ReadID(); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.BinaryObjectString: //simple structure, just an ID and a string si = new ObjectString(); si.ObjectID = ReadID(); ((ObjectString)si).String = reader.ReadString(); break; case RecordTypeEnumeration.BinaryArray: //complex process, read in constructor. si = new BinaryArray(this); //also values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.MemberPrimitiveTyped: var junk = new MemberInfo(); junk.BinaryType = BinaryTypeEnumeration.Primitive; junk.PrimitiveType = (PrimitiveTypeEnumeration)reader.ReadByte(); TypeHelper.GetTypeValue(junk, junk, this); break; case RecordTypeEnumeration.MemberReference: //just return the ID that was referenced. serialObjectReferenceID = ReadID(); break; case RecordTypeEnumeration.ObjectNull: //a single null; do nothing, as null is the default return value. break; case RecordTypeEnumeration.MessageEnd: //do nothing, quit. Wasn't that fun? endRecordReached = true; break; case RecordTypeEnumeration.BinaryLibrary: var newLibraryID = ReadID(); LibrariesFound.Add(newLibraryID, new BinaryLibrary { LibraryID = newLibraryID, Name = reader.ReadString(), recordLength = reader.BaseStream.Position - startPosition, }); break; case RecordTypeEnumeration.ObjectNullMultiple256: //a sequence of nulls; return null, and start a counter to continue returning N nulls over the next calls. PendingNullCounter = reader.ReadByte() - 1; break; case RecordTypeEnumeration.ObjectNullMultiple: //a sequence of nulls; return null, and start a counter to continue returning N nulls over the next calls. PendingNullCounter = reader.ReadInt32() - 1; #if (DEBUG) //not yet tested: if it happens, take a look around. System.Diagnostics.Debugger.Break(); #endif break; case RecordTypeEnumeration.ArraySinglePrimitive: //This one's pretty easy to build, do locally. si = new BinaryArray(); si.ObjectID = ReadID(); ((BinaryArray)si).ArrayType = BinaryArrayTypeEnumeration.Single; ((BinaryArray)si).BinaryType = BinaryTypeEnumeration.Primitive; ((BinaryArray)si).Rank = 1; ((BinaryArray)si).Lengths = new List <int>(); ((BinaryArray)si).Lengths.Add(reader.ReadInt32()); ((BinaryArray)si).PrimitiveType = (PrimitiveTypeEnumeration)reader.ReadByte(); //and then read the values. si.ReadValueInfo(this); break; case RecordTypeEnumeration.ArraySingleObject: //This should be pretty easy to build, do locally. si = new BinaryArray(); si.ObjectID = ReadID(); ((BinaryArray)si).ArrayType = BinaryArrayTypeEnumeration.Single; ((BinaryArray)si).BinaryType = BinaryTypeEnumeration.Object; ((BinaryArray)si).Rank = 1; ((BinaryArray)si).Lengths = new List <int>(); ((BinaryArray)si).Lengths.Add(reader.ReadInt32()); //and then read the values. si.ReadValueInfo(this); #if (DEBUG) //not yet tested: if it happens, take a look around. System.Diagnostics.Debugger.Break(); #endif break; case RecordTypeEnumeration.ArraySingleString: //This should be pretty easy to build, do locally. si = new BinaryArray(); si.ObjectID = ReadID(); ((BinaryArray)si).ArrayType = BinaryArrayTypeEnumeration.Single; ((BinaryArray)si).BinaryType = BinaryTypeEnumeration.String; ((BinaryArray)si).Rank = 1; ((BinaryArray)si).Lengths = new List <int>(); ((BinaryArray)si).Lengths.Add(reader.ReadInt32()); //and then read the values. si.ReadValueInfo(this); #if (DEBUG) //not yet tested: if it happens, take a look around. System.Diagnostics.Debugger.Break(); #endif break; case RecordTypeEnumeration.MethodCall: //messages/remoting functionality not implemented throw new NotImplementedException(nextRecordType.ToString()); case RecordTypeEnumeration.MethodReturn: //messages/remoting functionality not implemented throw new NotImplementedException(nextRecordType.ToString()); default: throw new Exception("Parsing appears to have failed dramatically. Unknown record type, we must be lost in the bytestream!"); } //standard: if this was a serial object, add to list and record its length. if (si != null) { SerialObjectsFound.Add(si.ObjectID, si); si.recordLength = reader.BaseStream.Position - startPosition; if (parentObject != null) { si.ParentObjectID = parentObject.ObjectID; } return(si.ObjectID); } } else { PendingNullCounter--; } return(serialObjectReferenceID); }
public virtual void OnMove( SerialObject obj, Point3D p ) { }
public void OnEnter( SerialObject obj ) { Add( obj ); }