Exemplo n.º 1
0
    public void Load(Module.Save loadedSave)
    {
        List <object> saveVariables = this.SaveVariables;
        int           num           = 0;

        for (int i = 0; i < saveVariables.Count; i++)
        {
            if (saveVariables[i] is FloatValueHolder)
            {
                (saveVariables[i] as FloatValueHolder).floatValue = float.Parse(loadedSave.valuesList[num]);
                num++;
            }
            else if (saveVariables[i] is FloatValueHolder[])
            {
                FloatValueHolder[] array = saveVariables[i] as FloatValueHolder[];
                for (int j = 0; j < array.Length; j++)
                {
                    array[j].floatValue = float.Parse(loadedSave.valuesList[num]);
                    num++;
                }
            }
            else if (saveVariables[i] is BoolValueHolder)
            {
                (saveVariables[i] as BoolValueHolder).boolValue = (loadedSave.valuesList[num] == "True");
                num++;
            }
        }
    }
Exemplo n.º 2
0
        public Save(Part part, Orientation orientation, List <Part> parts)
        {
            this.partName    = part.partData.name;
            this.orientation = orientation;
            Module.Save[] array = new Module.Save[part.modules.Length];
            for (int i = 0; i < part.modules.Length; i++)
            {
                array[i] = new Module.Save(part.modules[i].GetType().ToString(), part.modules[i].SaveVariables);
            }
            this.moduleSaves = array;


            StringBuilder sb = new StringBuilder();

            foreach (string text in part.partData.tags.Keys)
            {
                sb.Append(string.Concat(new string[]
                {
                    part.partData.tags[text].GetType().AssemblyQualifiedName,
                    "#",
                    text,
                    "#",
                    JsonUtility.ToJson(part.partData.tags[text]),
                    "|"
                }));
            }
            this.tagsString = sb.ToString();
            this.GUID       = part.partData.GUID.ToString();
        }
Exemplo n.º 3
0
 public Save(Part part, Orientation orientation, List <Part> parts)
 {
     this.partName    = part.partData.name;
     this.orientation = orientation;
     Module.Save[] array = new Module.Save[part.modules.Length];
     for (int i = 0; i < part.modules.Length; i++)
     {
         array[i] = new Module.Save(part.modules[i].GetType().ToString(), part.modules[i].SaveVariables);
     }
     this.moduleSaves = array;
 }
Exemplo n.º 4
0
    public void Load(Module.Save loadedSave)
    {
        float         num           = 0f;
        List <object> saveVariables = this.SaveVariables;
        int           num2          = 0;

        for (int i = 0; i < saveVariables.Count; i++)
        {
            if (saveVariables[i] is FloatValueHolder)
            {
                if (saveVariables.Count > i && loadedSave.valuesList.Length > num2 && float.TryParse(loadedSave.valuesList[num2], out num))
                {
                    (saveVariables[i] as FloatValueHolder).floatValue = float.Parse(loadedSave.valuesList[num2]);
                }
                num2++;
            }
            else if (saveVariables[i] is FloatValueHolder[])
            {
                if (saveVariables.Count > i)
                {
                    FloatValueHolder[] array = saveVariables[i] as FloatValueHolder[];
                    for (int j = 0; j < array.Length; j++)
                    {
                        if (loadedSave.valuesList.Length > num2 && float.TryParse(loadedSave.valuesList[num2], out num))
                        {
                            array[j].floatValue = float.Parse(loadedSave.valuesList[num2]);
                        }
                        num2++;
                    }
                }
            }
            else if (saveVariables[i] is BoolValueHolder)
            {
                if (saveVariables.Count > i && loadedSave.valuesList.Length > num2)
                {
                    (saveVariables[i] as BoolValueHolder).boolValue = (loadedSave.valuesList[num2] == "True");
                }
                num2++;
            }
        }
    }