public void InsertUnstoppable(BuffQueueInfo bqi) { NewBuff buff = TryCreateBuff(bqi); if (buff != null) { _pendingBuffs.Add(buff); _filledSlots[buff.BuffId] = true; } buff?.StartBuff(); }
public void Hotswap(NewBuff oldBuff, ushort newBuffEntry) { BuffInfo newInfo = AbilityMgr.GetBuffInfo(newBuffEntry); NewBuff buff = new NewBuff(); buff.Initialize(oldBuff.Caster, (Unit)_Owner, oldBuff.BuffId, 40, newInfo.MaxStack, newInfo, this); _pendingBuffs[_pendingBuffs.IndexOf(oldBuff)] = buff; _buffs[_buffs.IndexOf(oldBuff)] = buff; buff.StartBuff(); }
public override void Update(long tick) { bool bBuffsModified = false; List <BuffQueueInfo> queuedList = null; // Pull in the buffinfo for buffs that are pending creation lock (_queuedInfo) { if (_queuedInfo.Count > 0) { queuedList = new List <BuffQueueInfo>(); queuedList.AddRange(_queuedInfo); _queuedInfo.Clear(); } } int pendingLen = _pendingBuffs.Count; // Clear out any expired buffs from the pendingBuffs array for (int i = 0; i < pendingLen; ++i) { if (!_pendingBuffs[i].BuffHasExpired) { continue; } NewBuff curBuff = _pendingBuffs[i]; bBuffsModified = true; curBuff.RemoveBuff(false); if (curBuff.PersistsOnLogout && curBuff.BuffState == (byte)EBuffState.Ended) { RemoveSavedBuff(curBuff); } _filledSlots[curBuff.BuffId] = false; if (curBuff.BuffGroup == BuffGroups.Guard && _Owner != curBuff.Caster) { _backingGuardBuffs.Remove((GuardBuff)curBuff); _guardsChanged = true; } else if (curBuff is AuraBuff && curBuff.Caster == _Owner) { _auraCount--; } else if (curBuff.BuffGroup == BuffGroups.SelfClassBuff) { _careerBuffs[0] = null; } else if (curBuff.BuffGroup == BuffGroups.SelfClassSecondaryBuff) { _careerBuffs[1] = null; } #if DEBUG && ABILITY_DEVELOPMENT _Owner.Say("[X] " + curBuff.BuffName); #endif _pendingBuffs.RemoveAt(i); --i; pendingLen = _pendingBuffs.Count; } // Then add any queued buffs if (queuedList != null) { foreach (BuffQueueInfo bqi in queuedList) { if (_unitOwner.IsDead && bqi.BuffInfo.RequiresTargetAlive) { continue; } if (!_unitOwner.IsDead && bqi.BuffInfo.RequiresTargetDead) { continue; } NewBuff buff = TryCreateBuff(bqi); if (buff != null) { bBuffsModified = true; _pendingBuffs.Add(buff); _filledSlots[buff.BuffId] = true; } // Let the invoker of the buff know the result. bqi.BuffCallback(buff); if (buff != null) { buff.StartBuff(); if (buff.PersistsOnLogout) { RegisterSavedBuff(buff); } } } } if (_unitOwner != null && _unitOwner.IsDead && bBuffsModified) { pendingLen = _pendingBuffs.Count; for (int i = 0; i < pendingLen; ++i) { if (_pendingBuffs[i].RequiresTargetAlive) { RemoveFromPending(_pendingBuffs[i]); --pendingLen; --i; } } } // Manage Guard if (_guardsChanged) { _guardBuffs = new List <GuardBuff>(_backingGuardBuffs); _guardsChanged = false; } // Copy the pending buffs into the used buff array if (bBuffsModified) { _buffRWLock.EnterWriteLock(); try { _buffs.Clear(); _buffs.AddRange(_pendingBuffs); } finally { _buffRWLock.ExitWriteLock(); } } // Update all the buffs if (_buffs.Count > 0 && TCPManager.GetTimeStampMS() > _nextBuffUpdateTime) { for (int index = 0; index < _buffs.Count; index++) { _buffs[index].Update(tick); } _nextBuffUpdateTime = TCPManager.GetTimeStampMS() + BUFF_UPDATE_INTERVAL; } }