/// <summary> /// Register ISerializableGameObject with SerializableStateManager. /// </summary> public void RegisterStatefulGameObject(ISerializableGameObject serializableObject) { if (serializableObject.LoadID == 0) { throw new Exception(invalidLoadIDExceptionText); } if (serializableObject is SerializablePlayer) { serializablePlayer = serializableObject as SerializablePlayer; } else { StatefulGameObjectTypes sgObjType = GetStatefulGameObjectType(serializableObject); Dictionary <ulong, ISerializableGameObject> serializableObjects = statefulGameObjects[(int)sgObjType]; if (serializableObjects.ContainsKey(serializableObject.LoadID)) { DaggerfallUnity.LogMessage(string.Format(duplicateLoadIDErrorText, sgObjType, serializableObject.LoadID)); } else { serializableObjects.Add(serializableObject.LoadID, serializableObject); } } }
/// <summary> /// Force deregister all ISerializableGameObject instances from SerializableStateManager. /// </summary> public void DeregisterAllStatefulGameObjects(bool keepPlayer = true) { // Optionally deregister player if (!keepPlayer) { serializablePlayer = null; } // Deregister other objects foreach (Dictionary <ulong, ISerializableGameObject> serializableObjects in statefulGameObjects) { serializableObjects.Clear(); } }