コード例 #1
0
        public virtual void Update(CharacterHealth characterHealth, Limb targetLimb, float deltaTime)
        {
            foreach (AfflictionPrefab.PeriodicEffect periodicEffect in Prefab.PeriodicEffects)
            {
                PeriodicEffectTimers[periodicEffect] -= deltaTime;
                if (PeriodicEffectTimers[periodicEffect] <= 0.0f)
                {
                    if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient)
                    {
                        PeriodicEffectTimers[periodicEffect] = 0.0f;
                    }
                    else
                    {
                        foreach (StatusEffect statusEffect in periodicEffect.StatusEffects)
                        {
                            ApplyStatusEffect(statusEffect, 1.0f, characterHealth, targetLimb);
                            PeriodicEffectTimers[periodicEffect] = Rand.Range(periodicEffect.MinInterval, periodicEffect.MaxInterval);
                        }
                    }
                }
            }

            AfflictionPrefab.Effect currentEffect = Prefab.GetActiveEffect(Strength);
            if (currentEffect == null)
            {
                return;
            }

            if (currentEffect.StrengthChange < 0) // Reduce diminishing of buffs if boosted
            {
                _strength += currentEffect.StrengthChange * deltaTime * StrengthDiminishMultiplier;
            }
            else // Reduce strengthening of afflictions if resistant
            {
                _strength += currentEffect.StrengthChange * deltaTime * (1f - characterHealth.GetResistance(Prefab.Identifier));
            }
            // Don't use the property, because it's virtual and some afflictions like husk overload it for external use.
            _strength = MathHelper.Clamp(_strength, 0.0f, Prefab.MaxStrength);

            foreach (StatusEffect statusEffect in currentEffect.StatusEffects)
            {
                ApplyStatusEffect(statusEffect, deltaTime, characterHealth, targetLimb);
            }

            float amount = deltaTime;

            if (Prefab.GrainBurst > 0)
            {
                amount /= Prefab.GrainBurst;
            }
            if (PendingAdditionStrenght >= 0)
            {
                AdditionStrength        += amount;
                PendingAdditionStrenght -= deltaTime;
            }
            else if (AdditionStrength > 0)
            {
                AdditionStrength -= amount;
            }
        }
コード例 #2
0
        public virtual void Update(CharacterHealth characterHealth, Limb targetLimb, float deltaTime)
        {
            AfflictionPrefab.Effect currentEffect = Prefab.GetActiveEffect(Strength);
            if (currentEffect == null)
            {
                return;
            }

            if (currentEffect.StrengthChange < 0) // Reduce diminishing of buffs if boosted
            {
                _strength += currentEffect.StrengthChange * deltaTime * StrengthDiminishMultiplier;
            }
            else // Reduce strengthening of afflictions if resistant
            {
                _strength += currentEffect.StrengthChange * deltaTime * (1f - characterHealth.GetResistance(Prefab.Identifier));
            }
            // Don't use the property, because its virtual and some afflictions like husk overload it for external use.
            _strength = MathHelper.Clamp(_strength, 0.0f, Prefab.MaxStrength);

            foreach (StatusEffect statusEffect in currentEffect.StatusEffects)
            {
                statusEffect.SetUser(Source);
                if (statusEffect.HasTargetType(StatusEffect.TargetType.Character))
                {
                    statusEffect.Apply(ActionType.OnActive, deltaTime, characterHealth.Character, characterHealth.Character);
                }
                if (targetLimb != null && statusEffect.HasTargetType(StatusEffect.TargetType.Limb))
                {
                    statusEffect.Apply(ActionType.OnActive, deltaTime, characterHealth.Character, targetLimb);
                }
                if (targetLimb != null && statusEffect.HasTargetType(StatusEffect.TargetType.AllLimbs))
                {
                    statusEffect.Apply(ActionType.OnActive, deltaTime, targetLimb.character, targetLimb.character.AnimController.Limbs.Cast <ISerializableEntity>().ToList());
                }
                if (statusEffect.HasTargetType(StatusEffect.TargetType.NearbyItems) ||
                    statusEffect.HasTargetType(StatusEffect.TargetType.NearbyCharacters))
                {
                    var targets = new List <ISerializableEntity>();
                    statusEffect.GetNearbyTargets(characterHealth.Character.WorldPosition, targets);
                    statusEffect.Apply(ActionType.OnActive, deltaTime, targetLimb.character, targets);
                }
            }
        }
コード例 #3
0
        public virtual void Update(CharacterHealth characterHealth, Limb targetLimb, float deltaTime)
        {
            AfflictionPrefab.Effect currentEffect = Prefab.GetActiveEffect(Strength);
            if (currentEffect == null)
            {
                return;
            }

            if (currentEffect.StrengthChange < 0) // Reduce diminishing of buffs if boosted
            {
                Strength += currentEffect.StrengthChange * deltaTime * StrengthDiminishMultiplier;
            }
            else // Reduce strengthening of afflictions if resistant
            {
                Strength += currentEffect.StrengthChange * deltaTime * (1f - characterHealth.GetResistance(Prefab.Identifier));
            }

            foreach (StatusEffect statusEffect in currentEffect.StatusEffects)
            {
                if (statusEffect.HasTargetType(StatusEffect.TargetType.Character))
                {
                    statusEffect.Apply(ActionType.OnActive, deltaTime, characterHealth.Character, characterHealth.Character);
                }
                if (targetLimb != null && statusEffect.HasTargetType(StatusEffect.TargetType.Limb))
                {
                    statusEffect.Apply(ActionType.OnActive, deltaTime, characterHealth.Character, targetLimb);
                }
                if (targetLimb != null && statusEffect.HasTargetType(StatusEffect.TargetType.AllLimbs))
                {
                    statusEffect.Apply(ActionType.OnActive, deltaTime, targetLimb.character, targetLimb.character.AnimController.Limbs.Cast <ISerializableEntity>().ToList());
                }
                if (statusEffect.HasTargetType(StatusEffect.TargetType.NearbyItems) ||
                    statusEffect.HasTargetType(StatusEffect.TargetType.NearbyCharacters))
                {
                    var targets = new List <ISerializableEntity>();
                    statusEffect.GetNearbyTargets(characterHealth.Character.WorldPosition, targets);
                    statusEffect.Apply(ActionType.OnActive, deltaTime, targetLimb.character, targets);
                }
            }
        }