using CommonAI.Zone.Helper; using CommonAI.ZoneClient; using CommonLang; using System; using System.Collections; using UnityEngine; using CommonLang.Concurrent; using CommonAI.Zone; using System.Collections.Generic; using System.IO; using CommonAIClient.Unity.Utils; namespace CommonAIClient.Unity.Battle { public partial class ComAIUnit { HashMap mBuffs = new HashMap(); private void UpdateBuff(float deltaTime) { foreach (var elem in mBuffs) { elem.Value.Update(deltaTime); } } protected virtual void ZUnit_OnBuffAdded(ZoneUnit unit, ZoneUnit.BuffState state) { Buff buff = new Buff(this, state); mBuffs.Add(state, buff); } protected virtual void ZUnit_OnBuffChanged(ZoneUnit unit, ZoneUnit.BuffState state) { Buff buff = null; if (mBuffs.TryGetValue(state, out buff)) { buff.OnChange(state); } } protected virtual void ZUnit_OnBuffRemoved(ZoneUnit unit, ZoneUnit.BuffState state) { Buff buff = mBuffs.RemoveByKey(state); if (buff != null) { buff.Dispose(); } } public class Buff { #region RefCount private static AtomicInteger s_alloc_count = new AtomicInteger(0); private static AtomicInteger s_active_count = new AtomicInteger(0); /// /// 分配实例数量 /// public static int AllocCount { get { return s_alloc_count.Value; } } /// /// 未释放实例数量 /// public static int ActiveCount { get { return s_active_count.Value; } } #endregion private bool mDisposed = false; private List mModels = new List(); private List