コード例 #1
0
        public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null, Limb targetLimb = null, Entity useTarget = null, Character user = null, Vector2?worldPosition = null, float applyOnUserFraction = 0.0f)
        {
            if (statusEffectLists == null)
            {
                return;
            }

            if (!statusEffectLists.TryGetValue(type, out List <StatusEffect> statusEffects))
            {
                return;
            }

            bool broken           = item.Condition <= 0.0f;
            bool reducesCondition = false;

            foreach (StatusEffect effect in statusEffects)
            {
                if (broken && !effect.AllowWhenBroken && effect.type != ActionType.OnBroken)
                {
                    continue;
                }
                if (user != null)
                {
                    effect.SetUser(user);
                }
                item.ApplyStatusEffect(effect, type, deltaTime, character, targetLimb, useTarget, isNetworkEvent: false, checkCondition: false, worldPosition);
                if (user != null && applyOnUserFraction > 0.0f && effect.HasTargetType(StatusEffect.TargetType.Character))
                {
                    effect.AfflictionMultiplier = applyOnUserFraction;
                    item.ApplyStatusEffect(effect, type, deltaTime, user, targetLimb == null ? null : user.AnimController.GetLimb(targetLimb.type), useTarget, false, false, worldPosition);
                    effect.AfflictionMultiplier = 1.0f;
                }
                reducesCondition |= effect.ReducesItemCondition();
            }
            //if any of the effects reduce the item's condition, set the user for OnBroken effects as well
            if (reducesCondition && user != null && type != ActionType.OnBroken)
            {
                foreach (ItemComponent ic in item.Components)
                {
                    if (ic.statusEffectLists == null || !ic.statusEffectLists.TryGetValue(ActionType.OnBroken, out List <StatusEffect> brokenEffects))
                    {
                        continue;
                    }
                    brokenEffects.ForEach(e => e.SetUser(user));
                }
            }

#if CLIENT
            HintManager.OnStatusEffectApplied(this, type, character);
#endif
        }
コード例 #2
0
        public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null, Limb targetLimb = null, Entity useTarget = null, Character user = null, Vector2?worldPosition = null)
        {
            if (statusEffectLists == null)
            {
                return;
            }

            if (!statusEffectLists.TryGetValue(type, out List <StatusEffect> statusEffects))
            {
                return;
            }

            bool broken           = item.Condition <= 0.0f;
            bool reducesCondition = false;

            foreach (StatusEffect effect in statusEffects)
            {
                if (broken && effect.type != ActionType.OnBroken)
                {
                    continue;
                }
                if (user != null)
                {
                    effect.SetUser(user);
                }
                item.ApplyStatusEffect(effect, type, deltaTime, character, targetLimb, useTarget, false, false, worldPosition);
                reducesCondition |= effect.ReducesItemCondition();
            }
            //if any of the effects reduce the item's condition, set the user for OnBroken effects as well
            if (reducesCondition && user != null && type != ActionType.OnBroken)
            {
                foreach (ItemComponent ic in item.Components)
                {
                    if (ic.statusEffectLists == null || !ic.statusEffectLists.TryGetValue(ActionType.OnBroken, out List <StatusEffect> brokenEffects))
                    {
                        continue;
                    }
                    brokenEffects.ForEach(e => e.SetUser(user));
                }
            }

#if CLIENT
            HintManager.OnStatusEffectApplied(this, type, character);
#endif
        }