5 internal sealed
class CharacterAbilityGiveReputation : CharacterAbility
7 private readonly Identifier factionIdentifier;
8 private readonly
float amount;
10 public CharacterAbilityGiveReputation(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement) : base(characterAbilityGroup, abilityElement)
12 factionIdentifier = abilityElement.GetAttributeIdentifier(
"identifier", Identifier.Empty);
13 amount = abilityElement.GetAttributeFloat(
"amount", 0f);
14 if (factionIdentifier.IsEmpty)
16 DebugConsole.ThrowError($
"Error in talent {CharacterTalent.DebugIdentifier}, faction identifier not defined.",
17 contentPackage: abilityElement.ContentPackage);
21 DebugConsole.ThrowError($
"Error in talent {CharacterTalent.DebugIdentifier}, amount of reputation to give is 0.",
22 contentPackage: abilityElement.ContentPackage);
26 protected override void ApplyEffect()
28 if (GameMain.GameSession?.Campaign is not { } campaign) {
return; }
30 foreach (Faction faction
in campaign.Factions)
32 if (faction.Prefab.Identifier != factionIdentifier) {
continue; }
34 faction.Reputation.AddReputation(amount);
39 protected override void ApplyEffect(AbilityObject abilityObject) => ApplyEffect();