// Tick public void Tick() { for (int i = ActiveGameplayEffects.Count() - 1; i >= 0; i--) { GameplayEffect Effect = ActiveGameplayEffects[i]; Attribute Attribute = Effect.TickAttribute; int Value = Effect.TickValue; if (Attribute != null) { TryApplyAttributeChange(Attribute.GetType(), Value); } Effect.Duration--; if (Effect.Duration <= 0) { if (Effect.RevertInitialChangeWhenRemoved && Effect.InitialAttribute != null) { TryApplyAttributeChange(Effect.InitialAttribute.GetType(), -Effect.InitialValue); } foreach (TypeTag Tag in Effect.AppliedTags) { ActiveTags[Tag.GetType()] = ActiveTags[Tag.GetType()] - 1; if (ActiveTags[Tag.GetType()] <= 0) { ActiveTags.Remove(Tag.GetType()); } } ActiveGameplayEffects.RemoveAt(i); } } }
public bool TryApplyEffectToSelf(GameplayEffect Effect) { if (IsBlocked(Effect.BlockedByTags) || !HasRequired(Effect.RequiredTags)) { return(false); } if (Effect.InitialAttribute != null) { TryApplyAttributeChange(Effect.InitialAttribute.GetType(), Effect.InitialValue); } foreach (TypeTag Tag in Effect.AppliedTags) { if (!ActiveTags.ContainsKey(Tag.GetType())) { ActiveTags.Add(Tag.GetType(), 1); } else { ActiveTags[Tag.GetType()] = ActiveTags[Tag.GetType()] + 1; } } if (Effect.EffectType == EffectDurationType.Duration) { ActiveGameplayEffects.Add(UnityEngine.Object.Instantiate(Effect)); } return(true); }
// Apply Effect public bool CanApplyFullEffectToSelf(GameplayEffect Effect) { if (IsBlocked(Effect.BlockedByTags) || !HasRequired(Effect.RequiredTags)) { return(false); } if (Effect.InitialAttribute == null) { return(true); } if (!AttributeSet.ContainsKey(Effect.InitialAttribute.GetType())) { return(false); } int?Value = GetAttributeValue(Effect.InitialAttribute); if (!Value.HasValue) { return(false); } return(Value.Value - Effect.InitialValue >= 0); }
/// <inheritdoc /> public GameplayEffect ApplyGameEffectToTarget(GameplayEffect Effect, IGameplayAbilitySystem Target, float Level = 0) { if (Effect.ExecuteEffect(Target)) { this.AddGameplayEffectToActiveList(Effect); } return(Effect); }
protected void ApplyEffectToTarget(AbilitySystem Owner, AbilitySystem Target) { int?PowerModifier = null; if (AbilityTag.Is(TypeTag.StrengthAbility)) { PowerModifier = Owner.GetAttributeValue(Attribute.Strength); } else if (AbilityTag.Is(TypeTag.DexterityAbility)) { PowerModifier = Owner.GetAttributeValue(Attribute.Dexterity); } else if (AbilityTag.Is(TypeTag.IntelligenceAbility)) { PowerModifier = Owner.GetAttributeValue(Attribute.Intelligence); } if (AppliedEffect != null) { GameplayEffect Instance = Instantiate(AppliedEffect); if (PowerModifier.HasValue) { if (Instance.InitialAttribute != null) { Instance.InitialValue += PowerModifier.Value / 2; } if (Instance.TickAttribute != null) { Instance.TickValue += PowerModifier.Value / 6; } } int?AddedDamage = Owner.GetAttributeValue(Attribute.AddedDamage); if (AddedDamage.HasValue && Owner != Target) { if (Instance.InitialAttribute != null && Instance.InitialAttribute.Is(Attribute.Health)) { Instance.InitialValue += AddedDamage.Value; } if (Instance.TickAttribute != null && Instance.TickAttribute.Is(Attribute.Health)) { Instance.TickValue += AddedDamage.Value / 3; } } Target.TryApplyEffectToSelf(Instance); } }
public ActiveGameplayEffectData(GameplayEffect effect, float cooldownTimeElapsed = 0f) { this._gameplayEffect = effect; this._cooldownTimeElapsed = cooldownTimeElapsed; this._stacks = 1; }
/// <inheritdoc /> public void AddGameplayEffectToActiveList(GameplayEffect Effect) { this._activeGameplayEffects.Add(new ActiveGameplayEffectData(Effect)); }
/// <inheritdoc /> public bool AttemptCalculateMagnitude(GameplayEffect GameplayEffect, out float EvaluatedMagnitude) { //TODO: PROPER IMPLEMENTATION EvaluatedMagnitude = this.ScaledMagnitude; return(true); }