public override void Deserialize(WriteDictionary data, GameReader.LoadMode mode) { var keys = PropertyHelper.Settings.Keys.ToList(); foreach (var key in keys) { PropertyHelper.SetProperty(PropertyHelper.Settings, key, data.Get(key, PropertyHelper.GetProperty(PropertyHelper.Settings, key))); } }
public override WriteDictionary Serialize(GameReader.LoadMode mode) { var data = new WriteDictionary(); foreach (var Pair in PropertyHelper.Settings) { data[Pair.Key] = PropertyHelper.GetProperty(PropertyHelper.Settings, Pair.Key); } return(data); }
//This file is called when a save game is loaded, if there is any data relevant to this ACTIVE mod //Note that this function is called very early in the loading process, so all save game data might not be initialized yet public override void Deserialize(WriteDictionary data, GameReader.LoadMode mode) { //The WriteDictionary Get function tries to fetch a value from the dictionary //but will return a default value if the key is not present //In this case MaxFloor is returned if the "Floor" key is not present var keys = PropertyHelper.Settings.Keys.ToList(); foreach (var key in keys) { PropertyHelper.Settings[key] = data.Get(key, PropertyHelper.Settings[key]); } //Note that we are not saving this value to the settings file, as this is save file specific //This way the player can have a default value for all new games, and a value for specific saves }
public override WriteDictionary Serialize(GameReader.LoadMode mode) { //The WriteDictionary is a simple dictionary the game uses to save data to a file //Note that the type saved needs to be a value type or have an empty contructor //You can safely save arrays, lists, hashsets and dictionaries //In this case we are saving a 32 bit integer, which is a value type var data = new WriteDictionary(); foreach (var Pair in PropertyHelper.Settings) { data[Pair.Key] = Pair.Value; } return(data); }
public override void Deserialize(WriteDictionary data, GameReader.LoadMode mode) { var settings = Helpers.Settings.Keys.ToList(); foreach (var setting in settings) { Helpers.SetProperty(Helpers.Settings, setting, data.Get(setting, Helpers.GetProperty(Helpers.Settings, setting))); } var stores = Helpers.Stores.Keys.ToList(); foreach (var store in stores) { Helpers.SetProperty(Helpers.Stores, store, data.Get(store, Helpers.GetProperty(Helpers.Stores, store))); } }
public override WriteDictionary Serialize(GameReader.LoadMode mode) { var data = new WriteDictionary(); foreach (var setting in Helpers.Settings) { data[setting.Key] = Helpers.GetProperty(Helpers.Settings, setting.Key); } foreach (var store in Helpers.Stores) { data[store.Key] = Helpers.GetProperty(Helpers.Stores, store.Key); } return(data); }