2 using System.Reflection;
17 private const float DefaultEffectTime = 1.0f;
29 CharacterAbilityGroup = characterAbilityGroup ??
throw new ArgumentNullException(nameof(characterAbilityGroup));
49 if (conditionsMatched)
56 VerifyState(conditionsMatched, timeSinceLastUpdate);
60 protected virtual void VerifyState(
bool conditionsMatched,
float timeSinceLastUpdate)
62 DebugConsole.ThrowError($
"Error in talent {CharacterTalent.DebugIdentifier}: Ability {this} does not have an implementation for VerifyState! This ability does not work in interval ability groups.",
68 if (abilityObject is
null)
80 DebugConsole.AddWarning($
"Ability {this} used improperly! This ability does not have a definition for ApplyEffect in talent {CharacterTalent.DebugIdentifier}",
86 DebugConsole.AddWarning($
"Ability {this} used improperly! This ability does not take a parameter for ApplyEffect in talent {CharacterTalent.DebugIdentifier}",
92 DebugConsole.ThrowError($
"Incompatible ability! Ability {this} is incompatitible with this type of ability effect type in talent {CharacterTalent.DebugIdentifier}",
100 string type = abilityElement.
Name.ToString().ToLowerInvariant();
103 abilityType = ReflectionUtils.GetTypeWithBackwardsCompatibility(
"Barotrauma.Abilities", type,
false,
true);
104 if (abilityType ==
null)
106 if (errorMessages) DebugConsole.ThrowError(
"Could not find the CharacterAbility \"" + type +
"\" (" + characterAbilityGroup.
CharacterTalent.
DebugIdentifier +
")",
115 DebugConsole.ThrowError(
"Could not find the CharacterAbility \"" + type +
"\" (" + characterAbilityGroup.
CharacterTalent.
DebugIdentifier +
")", e,
121 object[] args = { characterAbilityGroup, abilityElement };
126 characterAbility = (
CharacterAbility)Activator.CreateInstance(abilityType, args);
128 catch (TargetInvocationException e)
130 DebugConsole.ThrowError(
"Error while creating an instance of a CharacterAbility of the type " + abilityType +
".", e.InnerException,
135 return characterAbility;
CharacterTalent CharacterTalent
float TimeSinceLastUpdate
float EffectDeltaTime
Used primarily for StatusEffects. Default to constant outside interval abilities.
virtual bool AllowClientSimulation
virtual void UpdateCharacterAbility(bool conditionsMatched, float timeSinceLastUpdate)
virtual void VerifyState(bool conditionsMatched, float timeSinceLastUpdate)
virtual void ApplyEffect()
void ApplyAbilityEffect(AbilityObject abilityObject)
virtual bool AppliesEffectOnIntervalUpdate
virtual void InitializeAbility(bool addingFirstTime)
CharacterAbility(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement)
void LogAbilityObjectMismatch()
static CharacterAbility Load(ContentXElement abilityElement, CharacterAbilityGroup characterAbilityGroup, bool errorMessages=true)
virtual void ApplyEffect(AbilityObject abilityObject)
readonly TalentPrefab Prefab
ContentPackage? ContentPackage
bool GetAttributeBool(string key, bool def)
static NetworkMember NetworkMember
ContentPackage? ContentPackage