/// <summary> ///Updates a existing addition or removes the old addition to replace it ///by the new one (timed). /// </summary> /// <param name="target">Target on which the addition is casted</param> /// <param name="Addition">Addition which is casted</param> /// <param name="Duration">How long the addition lasts (ms)</param> public static void UpdateAddition(Actor target, uint addition, uint duration) { Saga.Factory.Additions.Info info; if (Singleton.Additions.TryGetAddition(addition, out info)) { Predicate <AdditionState> c = delegate(AdditionState state) { return(state.Addition == addition); }; target._additions._skipcheck = true; int index = target._additions.timed_additions.FindIndex(c); if (index > -1) //reset lifetime { AdditionState state = target._additions.timed_additions[index]; state.Lifetime = duration; SendDeleteStatus(target, addition); SendExchangeStatus(target, addition, duration); } else //add new { Singleton.Additions.ApplyAddition(addition, target); AdditionState state = new AdditionState(addition, duration, info); state.canexpire = true; target._additions.timed_additions.Add(state); SendExchangeStatus(target, addition, duration); } target._additions._skipcheck = false; } }
protected internal void UpdateAdditions() { //PROCESS ADDITION if (this._additions._skipcheck == false) { List <AdditionState> appliedadditions = this._additions.timed_additions; for (int i = 0; i < appliedadditions.Count; i++) { AdditionState state = appliedadditions[i]; if (state.IsExpired) { Singleton.Additions.DeapplyAddition(state.Addition, this); Common.Skills.SendDeleteStatus(this, state.Addition); appliedadditions.RemoveAt(i); i--; } else { state.Update(this, Target); } } if (_status.Updates > 0) { Character character = this as Character; if (character != null) { LifeCycle.Update(character); _status.Updates = 0; } } } }
/// <summary> /// Creates a new addition which is a timed addition /// </summary> /// <param name="target">Target on which the addition is casted</param> /// <param name="addition">Addition which is casted</param> /// <param name="duration">How long the addition lasts (ms)</param> public static void CreateAddition(Actor target, uint addition, uint duration) { Saga.Factory.Additions.Info info; if (Singleton.Additions.TryGetAddition(addition, out info)) { target._additions._skipcheck = true; Singleton.Additions.ApplyAddition(addition, target); AdditionState state = new AdditionState(addition, duration, info); state.canexpire = true; target._additions.timed_additions.Add(state); SendExchangeStatus(target, addition, duration); target._additions._skipcheck = false; } }