public void Serialize(IDataHelper helper) { IDictionary <SaveItem, int> saveData = new Dictionary <SaveItem, int>(); foreach (KeyValuePair <Character, Hat> kvp in this.hatsByCharacter) { SaveItem item = new SaveItem(kvp.Key.currentLocation.Name, kvp.Key.GetType().FullName, kvp.Key.Name, kvp.Key.Position); saveData[item] = kvp.Value.which.Value; this.monitor.Log($"Saved a hat for '{item}'. The hat is {kvp.Value.which.Value}. :)", LogLevel.Trace); } helper.WriteSaveData(SingleHatStorageProvider.SaveKey, saveData); }
private void PlaceHatOn(List <Character> characters, SaveItem item, int whichHat) { if (characters.Count == 0) { this.monitor.Log($"Couldn't put a hat on {item}. The hat {whichHat} is lost. :(", LogLevel.Trace); } else if (characters.Count == 1) { this.AddHat(characters[0], new Hat(whichHat)); this.monitor.Log($"Put a hat on '{item}'. The hat is {whichHat}. :)", LogLevel.Trace); } else { this.PlaceHatOn(characters.Where(character => character.Position == item.Position).ToList(), item, whichHat); } }