Exemple #1
0
    public void RemoveStatusEffect(StatusEffect effect)
    {
        if (!AcceptsStatusEffects)
        {
            return;
        }
        ;

        statusEffects.Remove(effect);
        OnStatusEffectsChanged?.Invoke();
    }
Exemple #2
0
    public void ApplyStatusEffect(StatusEffect effect)
    {
        if (!AcceptsStatusEffects)
        {
            return;
        }
        ;

        //find if we already have a status of this type
        StatusEffect existingCopy = null;

        foreach (StatusEffect e in statusEffects)
        {
            if (e.GetType() == effect.GetType())
            {
                existingCopy = e;
                break;
            }
        }

        if (existingCopy == null)
        {
            statusEffects.Add(effect);
            if (effect is IStatusApplyEventHandler applyResponder)
            {
                applyResponder.OnApply(this);
            }
        }
        else
        {
            //if we can stack, we stack
            if (existingCopy is IStackableStatus stack)
            {
                stack.GainStack(effect as IStackableStatus);
            }
            else //if we can't stack, we replace the old one with the new one
            {
                statusEffects.Remove(existingCopy);
                statusEffects.Add(effect);
                if (effect is IStatusApplyEventHandler applyResponder)
                {
                    applyResponder.OnApply(this);
                }
            }
        }
        OnStatusEffectsChanged?.Invoke();
        Debug.Log("entity now has " + statusEffects.Count + " status effects");
    }
Exemple #3
0
    public void RemoveStatusEffect(Type type)
    {
        if (!AcceptsStatusEffects)
        {
            return;
        }
        ;

        for (int i = statusEffects.Count - 1; i >= 0; i--)
        {
            StatusEffect effect = statusEffects[i];
            if (effect.GetType() == type)
            {
                statusEffects.RemoveAt(i);
            }
        }

        OnStatusEffectsChanged?.Invoke();
    }