Beispiel #1
0
        bool CheckTagRequirementsMet(GameplayEffectSpec geSpec)
        {
            /// Build temporary list of all gametags currently applied
            var appliedTags = new List <GameplayTagScriptableObject>();

            for (var i = 0; i < AppliedGameplayEffects.Count; i++)
            {
                appliedTags.AddRange(AppliedGameplayEffects[i].spec.GameplayEffect.gameplayEffectTags.GrantedTags);
            }

            // Every tag in the ApplicationTagRequirements.RequireTags needs to be in the character tags list
            // In other words, if any tag in ApplicationTagRequirements.RequireTags is not present, requirement is not met
            for (var i = 0; i < geSpec.GameplayEffect.gameplayEffectTags.ApplicationTagRequirements.RequireTags.Length; i++)
            {
                if (!appliedTags.Contains(geSpec.GameplayEffect.gameplayEffectTags.ApplicationTagRequirements.RequireTags[i]))
                {
                    return(false);
                }
            }

            // No tag in the ApplicationTagRequirements.IgnoreTags must in the character tags list
            // In other words, if any tag in ApplicationTagRequirements.IgnoreTags is present, requirement is not met
            for (var i = 0; i < geSpec.GameplayEffect.gameplayEffectTags.ApplicationTagRequirements.IgnoreTags.Length; i++)
            {
                if (appliedTags.Contains(geSpec.GameplayEffect.gameplayEffectTags.ApplicationTagRequirements.IgnoreTags[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Applies the gameplay effect spec to self
        /// </summary>
        /// <param name="geSpec">GameplayEffectSpec to apply</param>
        public bool ApplyGameplayEffectSpecToSelf(GameplayEffectSpec geSpec)
        {
            if (geSpec == null)
            {
                return(true);
            }
            bool tagRequirementsOK = CheckTagRequirementsMet(geSpec);

            if (tagRequirementsOK == false)
            {
                return(false);
            }


            switch (geSpec.GameplayEffect.gameplayEffect.DurationPolicy)
            {
            case EDurationPolicy.HasDuration:
            case EDurationPolicy.Infinite:
                ApplyDurationalGameplayEffect(geSpec);
                break;

            case EDurationPolicy.Instant:
                ApplyInstantGameplayEffect(geSpec);
                return(true);
            }

            return(true);
        }
Beispiel #3
0
        void ApplyDurationalGameplayEffect(GameplayEffectSpec spec)
        {
            var modifiersToApply = new List <GameplayEffectContainer.ModifierContainer>();

            for (var i = 0; i < spec.GameplayEffect.gameplayEffect.Modifiers.Length; i++)
            {
                var modifier          = spec.GameplayEffect.gameplayEffect.Modifiers[i];
                var magnitude         = (modifier.ModifierMagnitude.CalculateMagnitude(spec) * modifier.Multiplier).GetValueOrDefault();
                var attributeModifier = new AttributeModifier();
                switch (modifier.ModifierOperator)
                {
                case EAttributeModifier.Add:
                    attributeModifier.Add = magnitude;
                    break;

                case EAttributeModifier.Multiply:
                    attributeModifier.Multiply = magnitude;
                    break;

                case EAttributeModifier.Override:
                    attributeModifier.Override = magnitude;
                    break;
                }
                modifiersToApply.Add(new GameplayEffectContainer.ModifierContainer()
                {
                    Attribute = modifier.Attribute, Modifier = attributeModifier
                });
            }
            AppliedGameplayEffects.Add(new GameplayEffectContainer()
            {
                spec = spec, modifiers = modifiersToApply.ToArray()
            });
        }
Beispiel #4
0
        void ApplyInstantGameplayEffect(GameplayEffectSpec spec)
        {
            for (var i = 0; i < spec.GameplayEffect.gameplayEffect.Modifiers.Length; i++)
            {
                var modifier  = spec.GameplayEffect.gameplayEffect.Modifiers[i];
                var magnitude = (modifier.ModifierMagnitude.CalculateMagnitude(spec) * modifier.Multiplier).GetValueOrDefault();
                var attribute = modifier.Attribute;
                this.AttributeSystem.GetAttributeValue(attribute, out var attributeValue);

                switch (modifier.ModifierOperator)
                {
                case EAttributeModifier.Add:
                    attributeValue.BaseValue += magnitude;
                    break;

                case EAttributeModifier.Multiply:
                    attributeValue.BaseValue *= magnitude;
                    break;

                case EAttributeModifier.Override:
                    attributeValue.BaseValue = magnitude;
                    break;
                }
                this.AttributeSystem.SetAttributeBaseValue(attribute, attributeValue.BaseValue);
            }
        }
Beispiel #5
0
 public GameplayEffectSpec MakeOutgoingSpec(GameplayEffectScriptableObject GameplayEffect, float?level = 1f)
 {
     level = level ?? this.Level;
     return(GameplayEffectSpec.CreateNew(
                GameplayEffect: GameplayEffect,
                Source: this,
                Level: level.GetValueOrDefault(1)));
 }
 public override float?CalculateMagnitude(GameplayEffectSpec spec)
 {
     return(ScalingFunction.Evaluate(spec.Level));
 }
 public override void Initialise(GameplayEffectSpec spec)
 {
 }