/// <summary> /// Updates the compendium item with id matching the parameter's id /// </summary> public void UpdateItem(ItemModel model) { ItemModel currentModel = _items.FirstOrDefault(x => x.Id == model.Id); if (currentModel != null) { string oldName = currentModel.Name; _items[_items.IndexOf(currentModel)] = model; List <Guid> characterIDs = new List <Guid>(); foreach (CharacterModel character in _characters) { foreach (BagModel bag in character.Bags) { foreach (EquipmentModel equipment in bag.Equipment) { if (equipment.Item != null && equipment.Item.Id == model.Id) { equipment.Item = model; if (equipment.Name.Equals(oldName, StringComparison.CurrentCultureIgnoreCase)) { equipment.Name = model.Name; } characterIDs.Add(character.Id); } } } } if (characterIDs.Any()) { CharacterChanged?.Invoke(this, new CompendiumChangeEventArgs(characterIDs.Distinct())); } } }
/// <summary> /// Updates the compendium condition with id matching the parameter's id /// </summary> public void UpdateCondition(ConditionModel model) { ConditionModel currentModel = _conditions.FirstOrDefault(x => x.Id == model.Id); if (currentModel != null) { string oldName = currentModel.Name; _conditions[_conditions.IndexOf(currentModel)] = model; List <Guid> characterIDs = new List <Guid>(); foreach (CharacterModel character in _characters) { foreach (AppliedConditionModel appliedCondition in character.Conditions) { if (appliedCondition.ConditionModel != null && appliedCondition.ConditionModel.Id == model.Id) { appliedCondition.ConditionModel = model; if (appliedCondition.Name.Equals(oldName, StringComparison.CurrentCultureIgnoreCase)) { appliedCondition.Name = model.Name; } characterIDs.Add(character.Id); } } } if (characterIDs.Any()) { CharacterChanged?.Invoke(this, new CompendiumChangeEventArgs(characterIDs.Distinct())); } } }
/// <summary> /// Updates the compendium feat with id matching the parameter's id /// </summary> public void UpdateFeat(FeatModel model) { FeatModel currentModel = _feats.FirstOrDefault(x => x.Id == model.Id); if (currentModel != null) { _feats[_feats.IndexOf(currentModel)] = model; List <Guid> characterIDs = new List <Guid>(); foreach (CharacterModel character in _characters) { foreach (LevelModel level in character.Levels) { for (int i = 0; i < level.Feats.Count; ++i) { FeatModel feat = level.Feats[i]; if (feat.Id == model.Id) { level.Feats[i] = model; characterIDs.Add(character.Id); } } } } if (characterIDs.Any()) { CharacterChanged?.Invoke(this, new CompendiumChangeEventArgs(characterIDs.Distinct())); } } }
/// <summary> /// Updates the compendium spell with id matching the parameter's id /// </summary> public void UpdateSpell(SpellModel model) { SpellModel currentModel = _spells.FirstOrDefault(x => x.Id == model.Id); if (currentModel != null) { _spells[_spells.IndexOf(currentModel)] = model; List <Guid> characterIDs = new List <Guid>(); foreach (CharacterModel character in _characters) { foreach (SpellbookModel spellbook in character.Spellbooks) { foreach (SpellbookEntryModel spellbookEntry in spellbook.Spells) { if (spellbookEntry.Spell != null && spellbookEntry.Spell.Id == model.Id) { spellbookEntry.Spell = model; characterIDs.Add(character.Id); } } } } if (characterIDs.Any()) { CharacterChanged?.Invoke(this, new CompendiumChangeEventArgs(characterIDs.Distinct())); } } }
/// <summary> /// Updates the compendium monster with id matching the parameter's id /// </summary> public void UpdateMonster(MonsterModel model) { MonsterModel currentModel = _monsters.FirstOrDefault(x => x.Id == model.Id); if (currentModel != null) { string oldName = currentModel.Name; _monsters[_monsters.IndexOf(currentModel)] = model; List <Guid> characterIDs = new List <Guid>(); foreach (CharacterModel character in _characters) { foreach (CompanionModel companion in character.Companions) { if (companion.MonsterModel != null && companion.MonsterModel.Id == model.Id) { companion.MonsterModel = model; if (companion.Name.Equals(oldName, StringComparison.CurrentCultureIgnoreCase)) { companion.Name = model.Name; } characterIDs.Add(character.Id); } } } if (characterIDs.Any()) { CharacterChanged?.Invoke(this, new CompendiumChangeEventArgs(characterIDs.Distinct())); } List <Guid> encounterIDs = new List <Guid>(); foreach (EncounterModel encounter in _encounters) { foreach (EncounterMonsterModel encounterMonster in encounter.Creatures.Where(x => x is EncounterMonsterModel)) { if (encounterMonster.MonsterModel != null && encounterMonster.MonsterModel.Id == model.Id) { encounterMonster.MonsterModel = model; if (encounter.Name.Equals(oldName, StringComparison.CurrentCultureIgnoreCase)) { encounterMonster.Name = model.Name; } encounterIDs.Add(encounter.Id); } } } if (encounterIDs.Any()) { EncounterChanged?.Invoke(this, new CompendiumChangeEventArgs(encounterIDs.Distinct())); } } }
private void Enabler(bool selector) { if (selector) { characters[0].transform.position = characters[1].transform.position; ChangerEneble(); CharacterChanged?.Invoke(characters[0]); } else { characters[1].transform.position = characters[0].transform.position; ChangerEneble(); CharacterChanged?.Invoke(characters[1]); } }
private void CharacterPropChanged(object e, PropertyChangedEventArgs args) { int id = (e as Character)?.Id ?? Character.PreRegisteredId; if (args.PropertyName == nameof(Character.Name)) { CharacterChanged?.Invoke(id, UpdatedField.Name); } else if (args.PropertyName == nameof(Character.TraitNames)) { CharacterChanged?.Invoke(id, UpdatedField.Trait); } else { CharacterChanged?.Invoke(id, UpdatedField.Unspecified); } }
/// <summary> /// Updates the compendium class with id matching the parameter's id /// </summary> public void UpdateClass(ClassModel model) { ClassModel currentModel = _classes.FirstOrDefault(x => x.Id == model.Id); if (currentModel != null) { _classes[_classes.IndexOf(currentModel)] = model; List <Guid> characterIDs = new List <Guid>(); foreach (CharacterModel character in _characters) { foreach (LevelModel level in character.Levels) { if (level.Class.Id == model.Id) { level.Class = model; IEnumerable <FeatureModel> allFeatures = model.AutoLevels.SelectMany(x => x.Features); for (int i = 0; i < level.Features.Count; ++i) { FeatureModel feature = level.Features[i]; FeatureModel newFeature = allFeatures.FirstOrDefault(x => x.ID == feature.ID); if (newFeature != null) { level.Features[i] = newFeature; } else { level.Features.Remove(feature); } } characterIDs.Add(character.Id); } } } if (characterIDs.Any()) { CharacterChanged?.Invoke(this, new CompendiumChangeEventArgs(characterIDs.Distinct())); } } }
/// <summary> /// Updates the compendium background with id matching the parameter's id /// </summary> public void UpdateBackground(BackgroundModel model) { BackgroundModel currentModel = _backgrounds.FirstOrDefault(x => x.Id == model.Id); if (currentModel != null) { _backgrounds[_backgrounds.IndexOf(currentModel)] = model; List <Guid> characterIDs = new List <Guid>(); foreach (CharacterModel character in _characters) { if (character.Background.Id == model.Id) { character.Background = model; characterIDs.Add(character.Id); } } if (characterIDs.Any()) { CharacterChanged?.Invoke(this, new CompendiumChangeEventArgs(characterIDs.Distinct())); } } }
public void OnCharacterChanged(Character _char) { CharacterChanged?.Invoke(_char); }