Beispiel #1
0
    void PreSave()
    {
        HashSet <Machine> machines = this.machines;

        Machine.Save[] machineSaves = new Machine.Save[machines.Count];
        int            i            = 0;

        foreach (Machine machine in machines)
        {
            machine.GetSave(out machineSaves[i]);
            ++i;
        }

        save.machines = machineSaves;
    }
Beispiel #2
0
 void PostLoad()
 {
     Machine.Save[] saveMachines = save.machines ?? Array.Empty <Machine.Save>();
     for (int i = 0, len = saveMachines.Length; i < len; ++i)
     {
         ref Machine.Save saveMachine = ref saveMachines[i];
         MachineInfo      machineInfo = ScriptableObjects.instance.GetMachineInfo(saveMachine.machineName);
         if (machineInfo)
         {
             Machine machine = DoCreateMachine(machineInfo, saveMachine.bounds);
             machine.SetSave(in saveMachine);
         }
         else
         {
             Debug.LogWarning($"Failed to find MachineInfo {saveMachine.machineName} while loading machine.");
         }
     }