/// <summary> /// Applies child properties to an object that wasn't deserialized, from an object that was deserialized. /// Used in conjunction with scene loading objects /// </summary> /// <param name="newData">The new object to copy non-ignored fields and properties to target</param> /// <param name="target">The object to apply properties to</param> /// <param name="serializer">Serializer to use for reference handling</param> /// <param name="data">Options for the child assign</param> private void ApplyOnlyChildProperties(object newData, object target, JsonSerializer serializer, AssignOnlyChildItemsOnDeserializeAttribute data) { if (target == null) { throw new JsonSerializationException("Copy only child properties target is null"); } // Need to register for deletion the orphaned Godot object if (newData is Node node) { TemporaryLoadedNodeDeleter.Instance.Register(node); } SaveApplyHelper.CopyJSONSavedPropertiesAndFields(target, newData, DefaultOnlyChildCopyIgnore); // Make sure target gets a chance to run stuff like normally deserialized objects RunPrePropertyDeserializeActions(target); RunPostPropertyDeserializeActions(target); if (data.ReplaceReferences && serializer.ReferenceResolver != null) { if (serializer.ReferenceResolver.IsReferenced(serializer, newData)) { serializer.ReferenceResolver.AddReference(serializer, serializer.ReferenceResolver.GetReference(serializer, newData), target); } } }
public void ApplyPropertiesFromSave(MicrobeCamera camera) { SaveApplyHelper.CopyJSONSavedPropertiesAndFields(this, camera, new List <string>() { "ObjectToFollow" }); }
protected virtual bool SkipMember(string name) { // By default IsLoadedFromSave is ignored as properties by default don't inherit attributes so this makes // things a bit easier when adding new types if (SaveApplyHelper.IsNameLoadedFromSaveName(name)) { return(true); } return(false); }
private void ApplyPropertiesFromSave(MicrobeStage savedMicrobeStage) { SaveApplyHelper.CopyJSONSavedPropertiesAndFields(this, savedMicrobeStage, new List <string>() { "spawner", "Player", "Camera", "Clouds", }); spawner.ApplyPropertiesFromSave(savedMicrobeStage.spawner); Clouds.ApplyPropertiesFromSave(savedMicrobeStage.Clouds); Camera.ApplyPropertiesFromSave(savedMicrobeStage.Camera); }
public void ApplyPropertiesFromSave(SpawnSystem spawner) { SaveApplyHelper.CopyJSONSavedPropertiesAndFields(this, spawner); }