public static WorldSaveState GetSaveState(string reality) { string path = OutputUtils.RealitySaveDirectory + reality + OutputUtils.WorldStateSaveFile; WorldSaveState sd = InputUtils.FileToObject<WorldSaveState>(path); return sd; }
public static void SaveWorldState(World world) { // Get world state object. WorldSaveState sd = new WorldSaveState(world); string path = OutputUtils.RealitySaveDirectory + world.RealityName + OutputUtils.WorldStateSaveFile; OutputUtils.ObjectToFile(sd, path); Debug.Log("Saved world state to '" + path + "'"); }
public static void LoadWorldState(World world) { // Tryo to load from file. string path = OutputUtils.RealitySaveDirectory + world.RealityName + OutputUtils.WorldStateSaveFile; WorldSaveState sd = InputUtils.FileToObject<WorldSaveState>(path); if(sd != null) { sd.Apply(world); Debug.Log("Applied loaded world state..."); } else { Debug.LogError("Null world state save file, no world state data applied."); } }
public void RealityNameChange() { if (RealityName == null) { Title.text = "LoadReality_SelectPrompt".Translate(); D_Day.text = "LoadReality_DayLabel".Translate("<color=white>---</color>"); D_LastPlayed.text = "LoadReality_LastPlayed".Translate("<color=white>---</color>", ""); EnterReality.text = "LoadReality_NoneSelected".Translate(); Play.interactable = false; Delete.interactable = false; } else { Title.text = RealityName.Trim(); D_Day.text = "LoadReality_DayLabel".Translate("<color=white>0</color>"); D_LastPlayed.text = "LoadReality_LastPlayed".Translate("<color=white>Never</color>", ""); EnterReality.text = "LoadReality_EnterReality".Translate(RealityName.Trim()); Play.interactable = true; Delete.interactable = true; WorldSaveState st = null; try { st = WorldIO.GetSaveState(RealityName); } catch { Debug.LogWarning(string.Format("Error loading reality state for '{0}'", RealityName)); } if (st != null) { D_Day.text = "LoadReality_DayLabel".Translate("<b><color=white>" + (int)(st.Time) + "</color></b>"); D_LastPlayed.text = "LoadReality_LastPlayed".Translate("<b><color=white>" + st.LastPlayed.ToString("g") + "</color></b>", "<b><color=white>" + st.LastPlayed.TimeAgo() + "</color></b>"); } } }