public static void SaveLadderDirections() { int cnt = 0; string toSave = ""; if (LadderDirections != null && LadderDirections.Count > 0) { foreach (KeyValuePair <string, KeyValuePair <int, bool> > direction in LadderDirections) { toSave += string.Format(CultureInfo.InvariantCulture, "{0}={1}={2}{3}", direction.Key, direction.Value.Key.ToString(), direction.Value.Value ? "1" : "0", Environment.NewLine); cnt++; } } if (!string.IsNullOrEmpty(toSave)) { string saveDir = FilesHelper.GetSaveFolderPath(); if (!Directory.Exists(saveDir)) { Directory.CreateDirectory(saveDir); } string saveFile = FilesHelper.Combine(saveDir, "outdoorladders.txt"); Logger.Log("INFO: Saving {0} outdoor ladder directions to \"{1}\".", cnt, saveFile); File.WriteAllText(saveFile, toSave, Encoding.UTF8); } }
// Load seamoth doll state public void OnProtoDeserialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { return; } } string filePath = FilesHelper.Combine(FilesHelper.GetSaveFolderPath(), "seamothdoll_" + id.Id + ".txt"); if (File.Exists(filePath)) { string state = File.ReadAllText(filePath, Encoding.UTF8).Trim(); GameObject extras = this.gameObject.FindChild("Model").FindChild("Submersible_SeaMoth_extras"); Renderer[] renderers = extras.GetAllComponentsInChildren <Renderer>(); foreach (Renderer renderer in renderers) { renderer.enabled = (string.Compare(state, "1", false, CultureInfo.InvariantCulture) == 0); } } }
public static void SaveAddedNotifications() { int cnt = 0; string toSave = ""; string toLog = ""; if (AddedNotifications != null && AddedNotifications.Count > 0) { foreach (KeyValuePair <int, bool> notif in AddedNotifications) { if (notif.Value) { toSave += string.Format(CultureInfo.InvariantCulture, "{0}={1}{2}", notif.Key, notif.Value, Environment.NewLine); toLog += notif.Key.ToString() + ";"; ++cnt; } } } if (!string.IsNullOrEmpty(toSave)) { string saveDir = FilesHelper.GetSaveFolderPath(); if (!Directory.Exists(saveDir)) { Directory.CreateDirectory(saveDir); } string saveFile = FilesHelper.Combine(saveDir, "discovered.txt"); if (toLog.EndsWith(";")) { toLog = toLog.Substring(0, toLog.Length - 1); } Logger.Log("INFO: Saving {0}/{1} discoveries to \"{2}\" (Discovered TechTypes: {3}).", cnt, AddedNotifications.Count, saveFile, toLog); File.WriteAllText(saveFile, toSave, Encoding.UTF8); } }
public void OnProtoSerialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { return; } } string saveFolder = FilesHelper.GetSaveFolderPath(); if (!Directory.Exists(saveFolder)) { Directory.CreateDirectory(saveFolder); } GameObject model = this.gameObject.FindChild("forklift"); string size = Convert.ToString(model.transform.localScale.y, CultureInfo.InvariantCulture); BoxCollider collider = this.gameObject.GetComponent <BoxCollider>(); size += Environment.NewLine + Convert.ToString(collider.size.y, CultureInfo.InvariantCulture); File.WriteAllText(FilesHelper.Combine(saveFolder, "forklift_" + id.Id + ".txt"), size, Encoding.UTF8); }
public static void LoadAddedNotifications(string saveGame) { AddedNotifications.Clear(); string saveDir = FilesHelper.GetSaveFolderPath(saveGame); if (saveDir != null) { if (Directory.Exists(saveDir)) { string saveFile = FilesHelper.Combine(saveDir, "discovered.txt"); if (File.Exists(saveFile)) { Logger.Log("INFO: Loading discoveries from \"" + saveFile + "\"."); int cnt = 0; string[] lines = File.ReadAllLines(saveFile, Encoding.UTF8); if (lines != null && lines.Length > 0) { foreach (string line in lines) { if (line.Length > 5 && line.Contains("=")) { string[] splitted = line.Split(new char[] { '=' }, StringSplitOptions.None); if (splitted != null && splitted.Length == 2 && int.TryParse(splitted[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out int techTypeId) && techTypeId >= 0) { bool discovered = !(string.Compare(splitted[1], "false", true, CultureInfo.InvariantCulture) == 0); if (AddedNotifications.ContainsKey(techTypeId)) { AddedNotifications[techTypeId] = discovered; } else { AddedNotifications.Add(techTypeId, discovered); } if (discovered) { ++cnt; } } } } } Logger.Log("INFO: Discoveries loaded. Player made {0}/{1} discoveries ({2} remaining).", cnt, AddedNotifications.Count, AddedNotifications.Count - cnt); } else { Logger.Log("INFO: No discoveries saved at \"" + saveFile + "\"."); } } else { Logger.Log("INFO: No save directory found for discoveries at \"" + saveDir + "\"."); } } else { Logger.Log("INFO: Could not find save slot for discoveries."); } }
public static void LoadLadderDirections(string saveGame) { LadderDirections.Clear(); string saveDir = FilesHelper.GetSaveFolderPath(saveGame); if (saveDir != null) { if (Directory.Exists(saveDir)) { string saveFile = FilesHelper.Combine(saveDir, "outdoorladders.txt"); if (File.Exists(saveFile)) { Logger.Log("INFO: Loading outdoor ladder directions from \"" + saveFile + "\"."); int cnt = 0; string[] lines = File.ReadAllLines(saveFile, Encoding.UTF8); if (lines != null && lines.Length > 0) { foreach (string line in lines) { if (line.Length > 3 && line.Contains("=")) { string[] splitted = line.Split(new char[] { '=' }, StringSplitOptions.None); if (splitted != null && splitted.Length == 3) { string pid = splitted[0]; bool inverted = splitted[2] == "1"; if (int.TryParse(splitted[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out int direction) && direction >= 0 && direction <= 3) { LadderDirections[pid] = new KeyValuePair <int, bool>(direction, inverted); ++cnt; } } } } } Logger.Log("INFO: {0} outdoor ladder directions were loaded.", cnt); } else { Logger.Log("INFO: No outdoor ladder directions saved at \"" + saveFile + "\"."); } } else { Logger.Log("INFO: No save directory found for outdoor ladders at \"" + saveDir + "\"."); } } else { Logger.Log("INFO: Could not find save slot for outdoor ladders."); } }
public void OnProtoDeserialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { return; } } string filePath = FilesHelper.Combine(FilesHelper.GetSaveFolderPath(), "warperspecimen_" + id.Id + ".txt"); if (File.Exists(filePath)) { string tmpSize = File.ReadAllText(filePath, Encoding.UTF8).Replace(',', '.'); // Replace , with . for backward compatibility. if (tmpSize == null) { return; } string[] sizes = tmpSize.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (sizes != null && sizes.Length == 2 && this.gameObject != null) { string[] xyz; GameObject model = this.gameObject.FindChild("Model"); if (model != null) { xyz = sizes[0].Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (xyz != null && xyz.Length == 3) { float sizeX = float.Parse(xyz[0], CultureInfo.InvariantCulture); float sizeY = float.Parse(xyz[1], CultureInfo.InvariantCulture); float sizeZ = float.Parse(xyz[2], CultureInfo.InvariantCulture); model.transform.localScale = new Vector3(sizeX, sizeY, sizeZ); } } BoxCollider collider = this.gameObject.GetComponent <BoxCollider>(); if (collider != null) { xyz = sizes[1].Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (xyz != null && xyz.Length == 3) { float colliderSizeX = float.Parse(xyz[0], CultureInfo.InvariantCulture); float colliderSizeY = float.Parse(xyz[1], CultureInfo.InvariantCulture); float colliderSizeZ = float.Parse(xyz[2], CultureInfo.InvariantCulture); collider.size = new Vector3(colliderSizeX, colliderSizeY, colliderSizeZ); } } } } }
public void OnProtoDeserialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { return; } } string filePath = FilesHelper.Combine(FilesHelper.GetSaveFolderPath(), "cyclopsdoll_" + id.Id + ".txt"); if (File.Exists(filePath)) { string tmpSize = File.ReadAllText(filePath, Encoding.UTF8); if (tmpSize == null) { return; } string[] sizes = tmpSize.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (sizes != null && sizes.Length >= 7) // Backward compat (used to be 7 lines) { GameObject model = this.gameObject.FindChild("CyclopsDoll"); if (model != null) { float sizeX = float.Parse(sizes[0], CultureInfo.InvariantCulture); float sizeY = float.Parse(sizes[1], CultureInfo.InvariantCulture); float sizeZ = float.Parse(sizes[2], CultureInfo.InvariantCulture); model.transform.localScale = new Vector3(sizeX, sizeY, sizeZ); } BoxCollider collider = this.gameObject.GetComponent <BoxCollider>(); if (collider != null) { float colliderSizeX = float.Parse(sizes[3], CultureInfo.InvariantCulture); float colliderSizeY = float.Parse(sizes[4], CultureInfo.InvariantCulture); float colliderSizeZ = float.Parse(sizes[5], CultureInfo.InvariantCulture); collider.size = new Vector3(colliderSizeX, colliderSizeY, colliderSizeZ); } sizeStep = int.Parse(sizes[6], CultureInfo.InvariantCulture); if (sizes.Length == 10) // Current format (10 lines) { float posX = float.Parse(sizes[7], CultureInfo.InvariantCulture); float posY = float.Parse(sizes[8], CultureInfo.InvariantCulture); float posZ = float.Parse(sizes[9], CultureInfo.InvariantCulture); model.transform.localPosition = new Vector3(posX, posY, posZ); } } } }
public void OnProtoDeserialize(ProtobufSerializer serializer) { #if DEBUG_COVE_TREE Logger.Log("DEBUG: OnProtoDeserialize covetree: Entry"); #endif // Retrieve prefab unique ID PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { return; } } #if DEBUG_COVE_TREE Logger.Log("DEBUG: OnProtoDeserialize covetree: Loading saved file"); #endif string filePath = FilesHelper.Combine(FilesHelper.GetSaveFolderPath(), "covetree_" + id.Id + ".txt"); if (File.Exists(filePath)) { string covetreedata = File.ReadAllText(filePath, Encoding.UTF8); if (covetreedata == null) { return; } string[] covetreeparams = covetreedata.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (covetreeparams != null && covetreeparams.Length == 1) { // Check if we need to display eggs bool showEggs = (string.Compare(covetreeparams[0], "1", false, CultureInfo.InvariantCulture) == 0); #if DEBUG_COVE_TREE Logger.Log("DEBUG: OnProtoDeserialize covetree: showEggs=[" + showEggs + "]"); #endif // Get eggs game objects GameObject model = this.gameObject.FindChild("lost_river_cove_tree_01"); GameObject eggs = model.FindChild("lost_river_cove_tree_01_eggs"); GameObject shells = model.FindChild("lost_river_cove_tree_01_eggs_shells"); // Show/hide eggs eggs.SetActive(showEggs); shells.SetActive(showEggs); #if DEBUG_COVE_TREE Logger.Log("DEBUG: OnProtoDeserialize covetree: showEggs value has been set"); #endif } } }
public void OnProtoSerialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { if ((id = this.gameObject.GetComponent <PrefabIdentifier>()) == null) { return; } } } #if DEBUG_CARGO_CRATES Logger.Log("DEBUG: Serialize(): PrefabID=[" + id.Id + "]"); #endif string saveFolder = FilesHelper.GetSaveFolderPath(); if (!Directory.Exists(saveFolder)) { Directory.CreateDirectory(saveFolder); } GameObject model = this.gameObject.FindChild("cargobox01_damaged"); if (model == null) { if ((model = this.gameObject.FindChild("cargobox01a")) == null) { model = this.gameObject.FindChild("cargobox01b"); } } if (model == null) { return; } string saveData = Convert.ToString(model.transform.localScale.y, CultureInfo.InvariantCulture); BoxCollider collider = this.gameObject.GetComponent <BoxCollider>(); saveData += Environment.NewLine + Convert.ToString(collider.size.x, CultureInfo.InvariantCulture) + "|" + Convert.ToString(collider.size.y, CultureInfo.InvariantCulture) + "|" + Convert.ToString(collider.size.z, CultureInfo.InvariantCulture); #if DEBUG_CARGO_CRATES Logger.Log("DEBUG: Serialize(): Saving cargo crates nbItems=[" + _storageContainer?.container?.count + "] size=[" + Convert.ToString(model.transform.localScale.y, CultureInfo.InvariantCulture) + "] collider x=[" + Convert.ToString(collider.size.x, CultureInfo.InvariantCulture) + "] y=[" + Convert.ToString(collider.size.y, CultureInfo.InvariantCulture) + "] z=[" + Convert.ToString(collider.size.z, CultureInfo.InvariantCulture) + "]."); #endif File.WriteAllText(FilesHelper.Combine(saveFolder, "cargocrate_" + id.Id + ".txt"), saveData, Encoding.UTF8); }
public void OnProtoSerialize(ProtobufSerializer serializer) { #if DEBUG_COVE_TREE Logger.Log("DEBUG: OnProtoSerialize covetree: Entry"); #endif // Retrieve prefab unique ID PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { return; } } #if DEBUG_COVE_TREE Logger.Log("DEBUG: OnProtoSerialize covetree: Get save folder"); #endif string saveFolder = FilesHelper.GetSaveFolderPath(); if (!Directory.Exists(saveFolder)) { Directory.CreateDirectory(saveFolder); } Plantable plant = this.gameObject.GetComponent <Plantable>(); GrownPlant grownPlant = this.gameObject.GetComponent <GrownPlant>(); if (grownPlant == null && plant != null && plant.linkedGrownPlant != null) { grownPlant = plant.linkedGrownPlant; } if (grownPlant != null) { GameObject eggs = grownPlant.gameObject.FindChild("lost_river_cove_tree_01").FindChild("lost_river_cove_tree_01_eggs"); #if DEBUG_COVE_TREE Logger.Log("DEBUG: OnProtoSerialize covetree: Found grown plant. Eggs active=[" + eggs.activeSelf + "]"); #endif File.WriteAllText(FilesHelper.Combine(saveFolder, "covetree_" + id.Id + ".txt"), eggs.activeSelf ? "1" : "0", Encoding.UTF8); } #if DEBUG_COVE_TREE else { Logger.Log("DEBUG: OnProtoSerialize covetree: Cannot find grown plant"); } #endif }
public void OnProtoSerialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { return; } } string saveFolder = FilesHelper.GetSaveFolderPath(); if (!Directory.Exists(saveFolder)) { Directory.CreateDirectory(saveFolder); } GameObject model = this.gameObject.FindChild("CyclopsDoll"); string toSave = string.Format(CultureInfo.InvariantCulture, "{0}{3}{1}{3}{2}{3}", Convert.ToString(model.transform.localScale.x, CultureInfo.InvariantCulture), Convert.ToString(model.transform.localScale.y, CultureInfo.InvariantCulture), Convert.ToString(model.transform.localScale.z, CultureInfo.InvariantCulture), Environment.NewLine); BoxCollider collider = this.gameObject.GetComponent <BoxCollider>(); toSave += string.Format(CultureInfo.InvariantCulture, "{0}{3}{1}{3}{2}{3}", Convert.ToString(collider.size.x, CultureInfo.InvariantCulture), Convert.ToString(collider.size.y, CultureInfo.InvariantCulture), Convert.ToString(collider.size.z, CultureInfo.InvariantCulture), Environment.NewLine); toSave += Convert.ToString(sizeStep, CultureInfo.InvariantCulture) + Environment.NewLine; toSave += string.Format(CultureInfo.InvariantCulture, "{0}{3}{1}{3}{2}{3}", Convert.ToString(model.transform.localPosition.x, CultureInfo.InvariantCulture), Convert.ToString(model.transform.localPosition.y, CultureInfo.InvariantCulture), Convert.ToString(model.transform.localPosition.z, CultureInfo.InvariantCulture), Environment.NewLine); File.WriteAllText(FilesHelper.Combine(saveFolder, "cyclopsdoll_" + id.Id + ".txt"), toSave, Encoding.UTF8); }
// Save seamoth doll state public void OnProtoSerialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { return; } } string saveFolder = FilesHelper.GetSaveFolderPath(); if (!Directory.Exists(saveFolder)) { Directory.CreateDirectory(saveFolder); } GameObject model = this.gameObject.FindChild("Model").FindChild("Submersible_SeaMoth_extras").FindChild("Submersible_seaMoth_geo 1").FindChild("seaMoth_storage_01_L_geo"); Renderer rend = model.GetComponent <Renderer>(); File.WriteAllText(FilesHelper.Combine(saveFolder, "seamothdoll_" + id.Id + ".txt"), rend.enabled ? "1" : "0", Encoding.UTF8); }
public void OnProtoSerialize(ProtobufSerializer serializer) { // Retrieve prefab unique ID PrefabIdentifier id = GetComponent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponentInParent <PrefabIdentifier>()) == null) { return; } } // Get saves folder and create it if it doesn't exist string saveFolder = FilesHelper.GetSaveFolderPath(); if (!Directory.Exists(saveFolder)) { Directory.CreateDirectory(saveFolder); } // Save model angles GameObject frame = this.gameObject.FindChild("mesh"); string saveData = Convert.ToString(frame.transform.localEulerAngles.x, CultureInfo.InvariantCulture) + "|" + Convert.ToString(frame.transform.localEulerAngles.y, CultureInfo.InvariantCulture) + "|" + Convert.ToString(frame.transform.localEulerAngles.z, CultureInfo.InvariantCulture) + Environment.NewLine; // Save collider size GameObject trigger = this.gameObject.FindChild("Trigger"); BoxCollider collider = trigger.GetComponent <BoxCollider>(); saveData += Convert.ToString(collider.size.x, CultureInfo.InvariantCulture) + "|" + Convert.ToString(collider.size.y, CultureInfo.InvariantCulture) + "|" + Convert.ToString(collider.size.z, CultureInfo.InvariantCulture) + Environment.NewLine; // Save picture scale PictureFrame pf = this.gameObject.GetComponent <PictureFrame>(); saveData += Convert.ToString(pf.imageRenderer.transform.localScale.x, CultureInfo.InvariantCulture) + "|" + Convert.ToString(pf.imageRenderer.transform.localScale.y, CultureInfo.InvariantCulture) + "|" + Convert.ToString(pf.imageRenderer.transform.localScale.z, CultureInfo.InvariantCulture) + Environment.NewLine; // Save frame border visibility GameObject pictureFrame = frame.FindChild("submarine_Picture_Frame"); GameObject poster = this.gameObject.FindChild("poster_decorations(Clone)"); GameObject posterModel = poster.FindChild("model"); GameObject magnetModel = posterModel.FindChild("poster_kitty"); MeshRenderer frameRenderer = pictureFrame.GetComponent <MeshRenderer>(); if (frameRenderer.enabled) { saveData += "1" + Environment.NewLine; } else { MeshRenderer magnetRenderer = magnetModel.GetComponent <MeshRenderer>(); if (magnetRenderer.enabled) { saveData += "2" + Environment.NewLine; } else { saveData += "0" + Environment.NewLine; } } // Save constructable bounds extents ConstructableBounds constructableBounds = this.gameObject.GetComponent <ConstructableBounds>(); saveData += Convert.ToString(constructableBounds.bounds.extents.x, CultureInfo.InvariantCulture) + "|" + Convert.ToString(constructableBounds.bounds.extents.y, CultureInfo.InvariantCulture) + "|" + Convert.ToString(constructableBounds.bounds.extents.z, CultureInfo.InvariantCulture) + Environment.NewLine; // Save current sizes saveData += Convert.ToString(frame.transform.localScale.x, CultureInfo.InvariantCulture) + "|" + Convert.ToString(frame.transform.localScale.y, CultureInfo.InvariantCulture) + "|" + Convert.ToString(frame.transform.localScale.z, CultureInfo.InvariantCulture) + Environment.NewLine; saveData += Convert.ToString(poster.transform.localPosition.x, CultureInfo.InvariantCulture) + "|" + Convert.ToString(poster.transform.localPosition.y, CultureInfo.InvariantCulture) + "|" + Convert.ToString(poster.transform.localPosition.z, CultureInfo.InvariantCulture) + Environment.NewLine; saveData += Convert.ToString(posterModel.transform.localPosition.x, CultureInfo.InvariantCulture) + "|" + Convert.ToString(posterModel.transform.localPosition.y, CultureInfo.InvariantCulture) + "|" + Convert.ToString(posterModel.transform.localPosition.z, CultureInfo.InvariantCulture) + Environment.NewLine; saveData += Convert.ToString(posterModel.transform.localScale.x, CultureInfo.InvariantCulture) + "|" + Convert.ToString(posterModel.transform.localScale.y, CultureInfo.InvariantCulture) + "|" + Convert.ToString(posterModel.transform.localScale.z, CultureInfo.InvariantCulture) + Environment.NewLine; saveData += Convert.ToString(pf.imageRenderer.transform.localPosition.x, CultureInfo.InvariantCulture) + "|" + Convert.ToString(pf.imageRenderer.transform.localPosition.y, CultureInfo.InvariantCulture) + "|" + Convert.ToString(pf.imageRenderer.transform.localPosition.z, CultureInfo.InvariantCulture) + Environment.NewLine; saveData += Convert.ToString(magnetModel.transform.localScale.x, CultureInfo.InvariantCulture) + "|" + Convert.ToString(magnetModel.transform.localScale.y, CultureInfo.InvariantCulture) + "|" + Convert.ToString(magnetModel.transform.localScale.z, CultureInfo.InvariantCulture) + Environment.NewLine; saveData += Convert.ToString(frame.transform.localPosition.x, CultureInfo.InvariantCulture) + "|" + Convert.ToString(frame.transform.localPosition.y, CultureInfo.InvariantCulture) + "|" + Convert.ToString(frame.transform.localPosition.z, CultureInfo.InvariantCulture) + Environment.NewLine; // Save random image mode saveData += (this.RandomImage ? "1" : "0") + Environment.NewLine; // Save slideshow mode saveData += (this.Slideshow ? "1" : "0") + Environment.NewLine; // Save state to file File.WriteAllText(FilesHelper.Combine(saveFolder, "custompictureframe_" + id.Id + ".txt"), saveData, Encoding.UTF8); }
public void OnProtoDeserialize(ProtobufSerializer serializer) { #if DEBUG_LAMP Logger.Log("DEBUG: Entering onProtoDeserialize for ReactorLampBrightness name=[" + this.gameObject.name + "]"); #endif PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { if ((id = this.gameObject.GetComponent <PrefabIdentifier>()) == null) { return; } } } string filePath = FilesHelper.Combine(FilesHelper.GetSaveFolderPath(), "reactorlamp_" + id.Id + ".txt"); if (File.Exists(filePath)) { var reactorRodLight = this.gameObject.GetComponentInChildren <Light>(); Renderer[] renderers = this.gameObject.GetComponentsInChildren <Renderer>(); Renderer renderer = null; foreach (Renderer rend in renderers) { if (string.Compare(rend.name, "nuclear_reactor_rod_mesh", true, CultureInfo.InvariantCulture) == 0) { renderer = rend; break; } } string rawState = File.ReadAllText(filePath, Encoding.UTF8).Replace(',', '.'); // Replace , with . for backward compatibility. if (rawState == null) { return; } string[] state = rawState.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (state != null && state.Length == 8) { reactorRodLight.range = float.Parse(state[0], CultureInfo.InvariantCulture); savedRange = reactorRodLight.range; reactorRodLight.intensity = float.Parse(state[1], CultureInfo.InvariantCulture); savedIntensity = reactorRodLight.intensity; switch (state[2]) { case "0": // White renderer.material.SetTexture("_Illum", white); break; case "1": // Yellow renderer.material.SetTexture("_Illum", yellow); break; case "2": // Orange renderer.material.SetTexture("_Illum", orange); break; case "3": // Red renderer.material.SetTexture("_Illum", red); break; case "4": // Pink renderer.material.SetTexture("_Illum", pink); break; case "5": // Purple renderer.material.SetTexture("_Illum", purple); break; case "6": // Blue renderer.material.SetTexture("_Illum", blue); break; case "7": // Cyan renderer.material.SetTexture("_Illum", cyan); break; case "8": // Green renderer.material.SetTexture("_Illum", green); break; default: // Default (White) renderer.material.SetTexture("_Illum", white); break; } float Cred = float.Parse(state[3], CultureInfo.InvariantCulture); float Cgreen = float.Parse(state[4], CultureInfo.InvariantCulture); float Cblue = float.Parse(state[5], CultureInfo.InvariantCulture); reactorRodLight.color = new Color(Cred, Cgreen, Cblue); float Cglow = float.Parse(state[6], CultureInfo.InvariantCulture); savedGlowColor = new Color(Cglow, Cglow, Cglow, 1.0f); renderer.material.SetColor("_GlowColor", savedGlowColor); if (string.Compare(state[7], "0", false, CultureInfo.InvariantCulture) == 0) { SwitchLampOff(renderer, reactorRodLight, true); } } } }
public void OnProtoDeserialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { if ((id = this.gameObject.GetComponent <PrefabIdentifier>()) == null) { return; } } } #if DEBUG_CARGO_CRATES Logger.Log("DEBUG: Deserialize(): PrefabID=[" + id.Id + "]"); #endif string filePath = FilesHelper.Combine(FilesHelper.GetSaveFolderPath(), "cargocrate_" + id.Id + ".txt"); if (File.Exists(filePath)) { #if DEBUG_CARGO_CRATES Logger.Log("DEBUG: Deserialize() A"); #endif string tmpSize = File.ReadAllText(filePath, Encoding.UTF8).Replace(',', '.'); // Replace , with . for backward compatibility. if (tmpSize == null) { return; } string[] sizes = tmpSize.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (sizes != null && sizes.Length == 2) { #if DEBUG_CARGO_CRATES Logger.Log("DEBUG: Deserialize() B"); #endif GameObject model = this.gameObject.FindChild("cargobox01_damaged"); if (model == null) { if ((model = this.gameObject.FindChild("cargobox01a")) == null) { model = this.gameObject.FindChild("cargobox01b"); } } if (model == null) { return; } BoxCollider collider = this.gameObject.GetComponent <BoxCollider>(); #if DEBUG_CARGO_CRATES Logger.Log("DEBUG: Deserialize() C"); #endif float size = float.Parse(sizes[0], CultureInfo.InvariantCulture); model.transform.localScale = new Vector3(size, size, size); string[] colliderSizes = sizes[1].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (colliderSizes.Length == 3) { #if DEBUG_CARGO_CRATES Logger.Log("DEBUG: Deserialize() D"); #endif float colliderSizeX = float.Parse(colliderSizes[0], CultureInfo.InvariantCulture); float colliderSizeY = float.Parse(colliderSizes[1], CultureInfo.InvariantCulture); float colliderSizeZ = float.Parse(colliderSizes[2], CultureInfo.InvariantCulture); collider.size = new Vector3(colliderSizeX, colliderSizeY, colliderSizeZ); } else // Backward compatibility { float colliderSize; if (float.TryParse(sizes[1], NumberStyles.Float, CultureInfo.InvariantCulture, out colliderSize)) { collider.size = new Vector3(colliderSize * 0.4583f, colliderSize, colliderSize * 0.5555f); } #if DEBUG_CARGO_CRATES Logger.Log("DEBUG: Deserialize() E"); #endif } } } }
// Load seamoth doll state public void OnProtoDeserialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { return; } } string filePath = FilesHelper.Combine(FilesHelper.GetSaveFolderPath(), "prawnsuitdoll_" + id.Id + ".txt"); if (File.Exists(filePath)) { string state = File.ReadAllText(filePath, Encoding.UTF8).Trim(); if (state.Length == 2) { string rightArmState = state.Substring(0, 1); switch (rightArmState) { case "0": // Torpedo arm SetRightArm(this.gameObject, "0"); break; case "1": // Drill arm SetRightArm(this.gameObject, "1"); break; case "2": // Grapplin arm SetRightArm(this.gameObject, "2"); break; case "3": // Propulsion arm SetRightArm(this.gameObject, "3"); break; default: // Right hand arm SetRightArm(this.gameObject, "4"); break; } string leftArmState = state.Substring(1, 1); switch (leftArmState) { case "0": // Torpedo arm SetLeftArm(this.gameObject, "0"); break; case "1": // Drill arm SetLeftArm(this.gameObject, "1"); break; case "2": // Grapplin arm SetLeftArm(this.gameObject, "2"); break; case "3": // Propulsion arm SetLeftArm(this.gameObject, "3"); break; default: // Right hand arm SetLeftArm(this.gameObject, "4"); break; } } } }
// Save seamoth doll state public void OnProtoSerialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { return; } } string saveFolder = FilesHelper.GetSaveFolderPath(); if (!Directory.Exists(saveFolder)) { Directory.CreateDirectory(saveFolder); } GameObject rightArm = this.gameObject.FindChild("prawnsuit").FindChild("ExosuitArmRight"); GameObject rightArmRig = rightArm.FindChild("exosuit_01_armRight 1").FindChild("ArmRig 1"); GameObject rightTorpedoArm = rightArmRig.FindChild("exosuit_arm_torpedoLauncher_geo 1"); GameObject rightDrillArm = rightArmRig.FindChild("exosuit_drill_geo 1"); GameObject rightGrapplinArm = rightArmRig.FindChild("exosuit_grapplingHook_geo 1"); GameObject rightPropulsionArm = rightArmRig.FindChild("exosuit_propulsion_geo 1"); string state; if (rightTorpedoArm.GetComponent <Renderer>().enabled) { state = "0"; } else if (rightDrillArm.GetComponent <Renderer>().enabled) { state = "1"; } else if (rightGrapplinArm.GetComponent <Renderer>().enabled) { state = "2"; } else if (rightPropulsionArm.GetComponent <Renderer>().enabled) { state = "3"; } else // Right hand arm { state = "4"; } GameObject leftArm = this.gameObject.FindChild("prawnsuit").FindChild("ExosuitArmLeft"); GameObject leftArmRig = leftArm.FindChild("exosuit_01_armRight").FindChild("ArmRig"); GameObject leftTorpedoArm = leftArmRig.FindChild("exosuit_arm_torpedoLauncher_geo"); GameObject leftDrillArm = leftArmRig.FindChild("exosuit_drill_geo"); GameObject leftGrapplinArm = leftArmRig.FindChild("exosuit_grapplingHook_geo"); GameObject leftPropulsionArm = leftArmRig.FindChild("exosuit_propulsion_geo"); if (leftTorpedoArm.GetComponent <Renderer>().enabled) { state += "0"; } else if (leftDrillArm.GetComponent <Renderer>().enabled) { state += "1"; } else if (leftGrapplinArm.GetComponent <Renderer>().enabled) { state += "2"; } else if (leftPropulsionArm.GetComponent <Renderer>().enabled) { state += "3"; } else // Right hand arm { state += "4"; } File.WriteAllText(FilesHelper.Combine(saveFolder, "prawnsuitdoll_" + id.Id + ".txt"), state, Encoding.UTF8); }
public void OnProtoSerialize(ProtobufSerializer serializer) { PrefabIdentifier id = this.gameObject.GetComponent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { if ((id = GetComponentInParent <PrefabIdentifier>()) == null) { return; } } } #if DEBUG_FLORA Logger.Log("DEBUG: Entering onProtoSerialize for gameobject name=[" + this.gameObject.name + "] id=[" + id.Id + "] position x=[" + this.gameObject.transform.localPosition.x + "] y=[" + this.gameObject.transform.localPosition.y + "] z=[" + this.gameObject.transform.localPosition.z + "]"); #endif Plantable plant = this.gameObject.GetComponent <Plantable>(); if (plant.linkedGrownPlant != null) { PlantGenericController plantController = plant.linkedGrownPlant.gameObject.GetComponent <PlantGenericController>(); LandTree1Controller treeController = plant.linkedGrownPlant.gameObject.GetComponent <LandTree1Controller>(); PlantMonoTransformController plantMonoTransformController = plant.linkedGrownPlant.GetComponent <PlantMonoTransformController>(); float progress = -1.0f; if (plantController != null && plantController._progress >= 0.0f) { progress = plantController._progress; #if DEBUG_FLORA Logger.Log("DEBUG: LinkedGrownPlant) plantController) Saving progress=[" + progress + "] for gameObject name=[" + this.gameObject.name + "]"); #endif } else if (treeController != null && treeController._progress >= 0.0f) { progress = treeController._progress; #if DEBUG_FLORA Logger.Log("DEBUG: LinkedGrownPlant) treeController) Saving progress=[" + progress + "] for gameObject name=[" + this.gameObject.name + "]"); #endif } else if (plantMonoTransformController != null && plantMonoTransformController._progress >= 0.0f) { progress = plantMonoTransformController._progress; #if DEBUG_FLORA Logger.Log("DEBUG: LinkedGrownPlant) plantMonoTransformController) Saving progress=[" + progress + "] for gameObject name=[" + this.gameObject.name + "]"); } else { Logger.Log("DEBUG: LinkedGrownPlant) No controller found for gameObject name=[" + this.gameObject.name + "]"); } #else } #endif if (progress >= 0.0f) { // Open save directory string saveFolder = FilesHelper.GetSaveFolderPath(); if (!saveFolder.Contains("/test/")) { if (!Directory.Exists(saveFolder)) { Directory.CreateDirectory(saveFolder); } // Save custom flora state File.WriteAllText(FilesHelper.Combine(saveFolder, "customflora_" + id.Id + ".txt"), Convert.ToString(progress, CultureInfo.InvariantCulture), Encoding.UTF8); } else { Logger.Log("WARNING: Cannot save custom flora state: Save game folder path \"" + saveFolder + "\" is incorrect."); } } }
public void OnProtoSerialize(ProtobufSerializer serializer) { #if DEBUG_LAMP Logger.Log("DEBUG: Entering onProtoSerialize for ReactorLampBrightness name=[" + this.gameObject.name + "]"); #endif PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { if ((id = this.gameObject.GetComponent <PrefabIdentifier>()) == null) { return; } } } string saveFolder = FilesHelper.GetSaveFolderPath(); if (!Directory.Exists(saveFolder)) { Directory.CreateDirectory(saveFolder); } Light reactorRodLight = this.gameObject.GetComponentInChildren <Light>(); Renderer[] renderers = this.gameObject.GetComponentsInChildren <Renderer>(); Renderer renderer = null; foreach (Renderer rend in renderers) { if (string.Compare(rend.name, "nuclear_reactor_rod_mesh", true, CultureInfo.InvariantCulture) == 0) { renderer = rend; break; } } string range = null; string intensity = null; Color currentGlow = Color.black; string glowColor = "0"; Texture current = null; string rodColor = "0"; if (renderer != null && reactorRodLight != null) { bool turnedOn = false; if (!this.isOn) { SwitchLampOn(renderer, reactorRodLight, true); turnedOn = true; } // Save current reactor rod intensity currentGlow = renderer.material.GetColor("_GlowColor"); glowColor = Convert.ToString(currentGlow.r, CultureInfo.InvariantCulture); // Save current reactor rod illum current = renderer.material.GetTexture("_Illum"); if (current != null) { switch (current.name) { case "nuclear_reactor_rod_illum_yellow": rodColor = "1"; // Yellow break; case "nuclear_reactor_rod_illum_orange": rodColor = "2"; // Orange break; case "nuclear_reactor_rod_illum_red": rodColor = "3"; // Red break; case "nuclear_reactor_rod_illum_pink": rodColor = "4"; // Pink break; case "nuclear_reactor_rod_illum_purple": rodColor = "5"; // Purple break; case "nuclear_reactor_rod_illum_blue": rodColor = "6"; // Blue break; case "nuclear_reactor_rod_illum": rodColor = "7"; // Cyan break; case "nuclear_reactor_rod_illum_green": rodColor = "8"; // Green break; default: rodColor = "0"; // White break; } } // Get current lamp intensity intensity = Convert.ToString(reactorRodLight.intensity, CultureInfo.InvariantCulture); // Get current lamp range range = Convert.ToString(reactorRodLight.range, CultureInfo.InvariantCulture); // Get current lamp color string red = Convert.ToString(reactorRodLight.color.r, CultureInfo.InvariantCulture); string green = Convert.ToString(reactorRodLight.color.g, CultureInfo.InvariantCulture); string blue = Convert.ToString(reactorRodLight.color.b, CultureInfo.InvariantCulture); File.WriteAllText(FilesHelper.Combine(saveFolder, "reactorlamp_" + id.Id + ".txt"), range + Environment.NewLine + intensity + Environment.NewLine + rodColor + Environment.NewLine + red + Environment.NewLine + green + Environment.NewLine + blue + Environment.NewLine + glowColor + Environment.NewLine + (turnedOn ? "0" : "1"), Encoding.UTF8); if (turnedOn) { SwitchLampOff(renderer, reactorRodLight, true); } } }
public void OnProtoDeserialize(ProtobufSerializer serializer) { // Retrieve save file PrefabIdentifier id = GetComponent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponentInParent <PrefabIdentifier>()) == null) { return; } } string filePath = FilesHelper.Combine(FilesHelper.GetSaveFolderPath(), "custompictureframe_" + id.Id + ".txt"); if (File.Exists(filePath)) { GameObject frame = this.gameObject.FindChild("mesh"); PictureFrame pf = this.gameObject.GetComponent <PictureFrame>(); string tmpSize = File.ReadAllText(filePath, Encoding.UTF8).Replace(',', '.'); // Replace , with . for backward compatibility. if (tmpSize == null) { return; } string[] sizes = tmpSize.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (sizes != null && sizes.Length >= 10 && sizes.Length <= 14) { // Restore frame angles string[] eulerAngles = sizes[0].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (eulerAngles.Length == 3) { Vector3 savedEulerAngles = new Vector3(OriginFrameEulerAngles.x, OriginFrameEulerAngles.y, OriginFrameEulerAngles.z); float.TryParse(eulerAngles[0], NumberStyles.Float, CultureInfo.InvariantCulture, out savedEulerAngles.x); float.TryParse(eulerAngles[1], NumberStyles.Float, CultureInfo.InvariantCulture, out savedEulerAngles.y); float.TryParse(eulerAngles[2], NumberStyles.Float, CultureInfo.InvariantCulture, out savedEulerAngles.z); frame.transform.localEulerAngles = savedEulerAngles; } // Restore collider size string[] colliderSize = sizes[1].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (colliderSize.Length == 3) { Vector3 savedColliderSize = new Vector3(OriginColliderSize.x, OriginColliderSize.y, OriginColliderSize.z); float.TryParse(colliderSize[0], NumberStyles.Float, CultureInfo.InvariantCulture, out savedColliderSize.x); float.TryParse(colliderSize[1], NumberStyles.Float, CultureInfo.InvariantCulture, out savedColliderSize.y); float.TryParse(colliderSize[2], NumberStyles.Float, CultureInfo.InvariantCulture, out savedColliderSize.z); GameObject trigger = this.gameObject.FindChild("Trigger"); BoxCollider collider = trigger.GetComponent <BoxCollider>(); collider.size = savedColliderSize; } // Restore picture scale string[] imageRendererScale = sizes[2].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (imageRendererScale.Length == 3) { Vector3 savedImageRendererScale = new Vector3(OriginImageScale.x, OriginImageScale.y, OriginImageScale.z); float.TryParse(imageRendererScale[0], NumberStyles.Float, CultureInfo.InvariantCulture, out savedImageRendererScale.x); float.TryParse(imageRendererScale[1], NumberStyles.Float, CultureInfo.InvariantCulture, out savedImageRendererScale.y); float.TryParse(imageRendererScale[2], NumberStyles.Float, CultureInfo.InvariantCulture, out savedImageRendererScale.z); pf.imageRenderer.transform.localScale = savedImageRendererScale; } // Restore frame border visibility GameObject pictureFrame = frame.FindChild("submarine_Picture_Frame"); MeshRenderer frameRenderer = pictureFrame.GetComponent <MeshRenderer>(); frameRenderer.enabled = ((string.Compare(sizes[3], "1", false, CultureInfo.InvariantCulture) == 0) ? true : false); GameObject frameButton = pictureFrame.FindChild("submarine_Picture_Frame_button"); MeshRenderer buttonRenderer = frameButton.GetComponent <MeshRenderer>(); buttonRenderer.enabled = ((string.Compare(sizes[3], "1", false, CultureInfo.InvariantCulture) == 0) ? true : false); GameObject poster = this.gameObject.FindChild("poster_decorations(Clone)"); GameObject posterModel = poster.FindChild("model"); GameObject magnetModel = posterModel.FindChild("poster_kitty"); // Restore constructable bounds extents string[] constructableBoundsExtents = sizes[4].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (constructableBoundsExtents.Length == 3) { Vector3 savedConstructableBoundsExtents = new Vector3(OriginConstructableBoundsExtents.x, OriginConstructableBoundsExtents.y, OriginConstructableBoundsExtents.z); float.TryParse(constructableBoundsExtents[0], NumberStyles.Float, CultureInfo.InvariantCulture, out savedConstructableBoundsExtents.x); float.TryParse(constructableBoundsExtents[1], NumberStyles.Float, CultureInfo.InvariantCulture, out savedConstructableBoundsExtents.y); float.TryParse(constructableBoundsExtents[2], NumberStyles.Float, CultureInfo.InvariantCulture, out savedConstructableBoundsExtents.z); ConstructableBounds constructableBounds = this.gameObject.GetComponent <ConstructableBounds>(); constructableBounds.bounds.extents = savedConstructableBoundsExtents; } // Restore picture frame sizes & positions string[] modelScale = sizes[5].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (modelScale.Length == 3) { Vector3 updateModelScale = new Vector3(OriginFrameScale.x, OriginFrameScale.y, OriginFrameScale.z); float.TryParse(modelScale[0], NumberStyles.Float, CultureInfo.InvariantCulture, out updateModelScale.x); float.TryParse(modelScale[1], NumberStyles.Float, CultureInfo.InvariantCulture, out updateModelScale.y); float.TryParse(modelScale[2], NumberStyles.Float, CultureInfo.InvariantCulture, out updateModelScale.z); frame.transform.localScale = updateModelScale; } string[] posterMagnetPosition = sizes[6].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (posterMagnetPosition.Length == 3) { Vector3 updatePosterMagnetPosition = new Vector3(OriginPosterPosition.x, OriginPosterPosition.y, OriginPosterPosition.z); float.TryParse(posterMagnetPosition[0], NumberStyles.Float, CultureInfo.InvariantCulture, out updatePosterMagnetPosition.x); float.TryParse(posterMagnetPosition[1], NumberStyles.Float, CultureInfo.InvariantCulture, out updatePosterMagnetPosition.y); float.TryParse(posterMagnetPosition[2], NumberStyles.Float, CultureInfo.InvariantCulture, out updatePosterMagnetPosition.z); poster.transform.localPosition = updatePosterMagnetPosition; } string[] posterModelPosition = sizes[7].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (posterModelPosition.Length == 3) { Vector3 updatePosterModelPosition = new Vector3(OriginPosterModelPosition.x, OriginPosterModelPosition.y, OriginPosterModelPosition.z); float.TryParse(posterModelPosition[0], NumberStyles.Float, CultureInfo.InvariantCulture, out updatePosterModelPosition.x); float.TryParse(posterModelPosition[1], NumberStyles.Float, CultureInfo.InvariantCulture, out updatePosterModelPosition.y); float.TryParse(posterModelPosition[2], NumberStyles.Float, CultureInfo.InvariantCulture, out updatePosterModelPosition.z); posterModel.transform.localPosition = updatePosterModelPosition; } string[] posterModelScale = sizes[8].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (posterModelScale.Length == 3) { Vector3 updatePosterModelScale = new Vector3(OriginPosterModelScale.x, OriginPosterModelScale.y, OriginPosterModelScale.z); float.TryParse(posterModelScale[0], NumberStyles.Float, CultureInfo.InvariantCulture, out updatePosterModelScale.x); float.TryParse(posterModelScale[1], NumberStyles.Float, CultureInfo.InvariantCulture, out updatePosterModelScale.y); float.TryParse(posterModelScale[2], NumberStyles.Float, CultureInfo.InvariantCulture, out updatePosterModelScale.z); posterModel.transform.localScale = updatePosterModelScale; } string[] imageRendererPosition = sizes[9].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (imageRendererPosition.Length == 3) { Vector3 updateImageRendererPosition = Vector3.zero; float.TryParse(imageRendererPosition[0], NumberStyles.Float, CultureInfo.InvariantCulture, out updateImageRendererPosition.x); float.TryParse(imageRendererPosition[1], NumberStyles.Float, CultureInfo.InvariantCulture, out updateImageRendererPosition.y); float.TryParse(imageRendererPosition[2], NumberStyles.Float, CultureInfo.InvariantCulture, out updateImageRendererPosition.z); pf.imageRenderer.transform.localPosition = updateImageRendererPosition; } // Restore magnet scale if (sizes.Length >= 11) { string[] posterMagnetScale = sizes[10].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (posterMagnetScale.Length == 3) { Vector3 updateMagnetScale = new Vector3(OriginMagnetScale.x, OriginMagnetScale.y, OriginMagnetScale.z); float.TryParse(posterMagnetScale[0], NumberStyles.Float, CultureInfo.InvariantCulture, out updateMagnetScale.x); float.TryParse(posterMagnetScale[1], NumberStyles.Float, CultureInfo.InvariantCulture, out updateMagnetScale.y); float.TryParse(posterMagnetScale[2], NumberStyles.Float, CultureInfo.InvariantCulture, out updateMagnetScale.z); magnetModel.transform.localScale = updateMagnetScale; } } // Restore frame position if (sizes.Length >= 12) { string[] framePosition = sizes[11].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (framePosition.Length == 3) { Vector3 updateFramePosition = new Vector3(OriginFramePosition.x, OriginFramePosition.y, OriginFramePosition.z + 0.0001f); float.TryParse(framePosition[0], NumberStyles.Float, CultureInfo.InvariantCulture, out updateFramePosition.x); float.TryParse(framePosition[1], NumberStyles.Float, CultureInfo.InvariantCulture, out updateFramePosition.y); float.TryParse(framePosition[2], NumberStyles.Float, CultureInfo.InvariantCulture, out updateFramePosition.z); frame.transform.localPosition = updateFramePosition; } } // Restore random image mode if (sizes.Length >= 13) { this.RandomImage = (sizes[12] == "1"); if (this.RandomImage) { PictureFrameEnumHelper.SetStateMethod.Invoke(pf, new object[] { PictureFrameEnumHelper.NoneEnumValue }); pf.fileName = null; this.SetRandomImage(id, pf); } } // Restore slideshow mode if (sizes.Length >= 14) { bool isSlideshowOn = (sizes[13] == "1"); if (!isSlideshowOn) { this.Slideshow = false; } else { PictureFrameEnumHelper.SetStateMethod.Invoke(pf, new object[] { PictureFrameEnumHelper.NoneEnumValue }); pf.fileName = null; this.StartSlideshow(id, pf); } } // Restore flip toogle this.Flipped = (pf.imageRenderer.transform.localScale.x > pf.imageRenderer.transform.localScale.y); GameObject bgBisModel = posterModel.FindChild("poster_background_bis"); MeshRenderer bgBisRenderer = bgBisModel?.GetComponent <MeshRenderer>(); GameObject bgPivotModel = posterModel.FindChild("poster_background_pivot"); MeshRenderer bgPivotRenderer = bgPivotModel?.GetComponent <MeshRenderer>(); // Rotate poster background if needed if (this.Flipped) { bgPivotRenderer.enabled = !(string.Compare(sizes[3], "1", false, CultureInfo.InvariantCulture) == 0); bgBisRenderer.enabled = false; } else { bgPivotRenderer.enabled = false; bgBisRenderer.enabled = !(string.Compare(sizes[3], "1", false, CultureInfo.InvariantCulture) == 0); } MeshRenderer magnetRenderer = magnetModel.GetComponent <MeshRenderer>(); // Adjust magnet position if (bgPivotRenderer.enabled) { magnetModel.transform.localPosition = new Vector3(0f, -0.0115f, 0f); } else { magnetModel.transform.localPosition = Vector3.zero; } // Restore magnet visibility magnetRenderer.enabled = (string.Compare(sizes[3], "2", false, CultureInfo.InvariantCulture) == 0); // Refresh picture PictureFrameEnumHelper.SetStateMethod.Invoke(pf, new object[] { PictureFrameEnumHelper.ThumbnailEnumValue }); this.Invoke("MySetState", 2f); #if DEBUG_CUSTOM_PICTURE_FRAME Logger.Log("DEBUG: Current image in picture frame: fileName=[" + (string.IsNullOrEmpty(pf.fileName) ? "?" : pf.fileName) + "]"); #endif } } }