Ejemplo n.º 1
0
    /// <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);
            }
        }
    }
Ejemplo n.º 2
0
 public void ApplyPropertiesFromSave(MicrobeCamera camera)
 {
     SaveApplyHelper.CopyJSONSavedPropertiesAndFields(this, camera, new List <string>()
     {
         "ObjectToFollow"
     });
 }
Ejemplo n.º 3
0
    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);
    }
Ejemplo n.º 4
0
 public void ApplyPropertiesFromSave(SpawnSystem spawner)
 {
     SaveApplyHelper.CopyJSONSavedPropertiesAndFields(this, spawner);
 }