Esempio n. 1
0
 /// <summary>
 /// Removes a modifier from the System Component.
 /// </summary>
 /// <param name="modifier">The ISystemModifier to remove.  Uses Equals().</param>
 public virtual void RemoveModifier(SystemModifier modifier)
 {
     if (_modifiers.Remove(modifier) && _isActive)
     {
         RecalculateStat(modifier.stat);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Removes a modifier from the System Component.
 /// </summary>
 /// <param name="modifier">The ISystemModifier to remove.  Uses Equals().</param>
 public void RemoveModifier(SystemModifier modifier)
 {
     if (_modifiers.Remove(modifier))
     {
         RecalculateStat(modifier.stat);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Replaces an existing modifier with a new one, or adds a new one if it doesn't exist yet.
 /// </summary>
 /// <param name="modifier">The SystemModifier to add or replace.</param>
 public virtual void ReplaceModifier(SystemModifier modifier)
 {
     _modifiers.Replace(modifier);
     if (_isActive)
     {
         RecalculateStat(modifier.stat);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Adds a modifier to the System Component.
 /// </summary>
 /// <param name="modifier">The SystemModifier to add.</param>
 public virtual void AddModifier(SystemModifier modifier)
 {
     _modifiers.Add(modifier);
     if (_isActive)
     {
         RecalculateStat(modifier.stat);
     }
 }
Esempio n. 5
0
    /// <summary>
    /// Get the index of a SystemModifier in the list.
    /// </summary>
    /// <returns>The index of the modifier or -1 if not found.</returns>
    public int IndexOf(SystemModifier modifier)
    {
        int index = 0;

        foreach (SystemModifier mod in _modifiers)
        {
            if (mod.id == modifier.id)
            {
                return(index);
            }
            ++index;
        }

        return(-1);
    }
Esempio n. 6
0
    /// <summary>
    /// Remove an existing modifier from the list.  Uses the
    /// <c>Equals()</c> method of the ISystemModifier.
    /// </summary>
    /// <returns>True if a modifier was found and removed.</returns>
    public bool Remove(SystemModifier modifier)
    {
        if (_modifiers.Count == 0)
        {
            return(false);
        }

        int index = IndexOf(modifier);

        if (index != -1)
        {
            ResetCache(modifier.stat);
            _modifiers.RemoveAt(index);
            return(true);
        }

        return(false);
    }
Esempio n. 7
0
    /// <summary>
    /// Either replaces an existing modifier, or adds a new one if it doesn't exist yet.
    /// </summary>
    /// <returns>True if a modifier was replaced, false if a new one was added.</returns>
    public bool Replace(SystemModifier modifier)
    {
        ResetCache(modifier.stat);

        if (_modifiers.Count > 0)
        {
            // try and find the modifier to replace.
            int index = IndexOf(modifier);
            if (index != -1)
            {
                _modifiers[index] = modifier;
                return(true);
            }
        }

        // Otherwise, just add the modifier.
        _modifiers.Add(modifier);
        return(false);
    }
Esempio n. 8
0
 /// <summary>
 /// Adds a new ISystemModifier to the list.
 /// </summary>
 public void Add(SystemModifier modifier)
 {
     ResetCache(modifier.stat);
     _modifiers.Add(modifier);
 }
Esempio n. 9
0
 /// <summary>
 /// Replaces an existing modifier with a new one, or adds a new one if it doesn't exist yet.
 /// </summary>
 /// <param name="modifier">The SystemModifier to add or replace.</param>
 public void ReplaceModifier(SystemModifier modifier)
 {
     _modifiers.Replace(modifier);
     RecalculateStat(modifier.stat);
 }
Esempio n. 10
0
 /// <summary>
 /// Adds a modifier to the System Component.
 /// </summary>
 /// <param name="modifier">The SystemModifier to add.</param>
 public void AddModifier(SystemModifier modifier)
 {
     _modifiers.Add(modifier);
     RecalculateStat(modifier.stat);
 }