|
|
@@ -42,32 +42,9 @@ namespace Model
|
|
|
{
|
|
|
this.idBuff.Add(buff.Id, buff);
|
|
|
this.typeBuff.Add(buff.Config.Type, buff);
|
|
|
- AddToTimer(this.Owner, buff);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void AddToTimer(Unit owner, Buff buff)
|
|
|
- {
|
|
|
- if (buff.Expiration == 0)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- Env env = new Env();
|
|
|
- env[EnvKey.OwnerId] = owner.Id;
|
|
|
- env[EnvKey.BuffId] = buff.Id;
|
|
|
- buff.TimerId = World.Instance.GetComponent<TimerComponent>()
|
|
|
- .Add(buff.Expiration, CallbackType.BuffTimeoutCallback, env);
|
|
|
- }
|
|
|
-
|
|
|
- private static void RemoveFromTimer(Buff buff)
|
|
|
- {
|
|
|
- if (buff.Expiration == 0)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- World.Instance.GetComponent<TimerComponent>().Remove(buff.TimerId);
|
|
|
- }
|
|
|
-
|
|
|
public void Add(Buff buff)
|
|
|
{
|
|
|
if (this.buffs.Contains(buff))
|
|
|
@@ -89,7 +66,6 @@ namespace Model
|
|
|
this.buffs.Add(buff);
|
|
|
this.idBuff.Add(buff.Id, buff);
|
|
|
this.typeBuff.Add(buff.Config.Type, buff);
|
|
|
- AddToTimer(this.Owner, buff);
|
|
|
|
|
|
World.Instance.GetComponent<EventComponent<EventAttribute>>().Run(EventType.AfterAddBuff, env);
|
|
|
}
|
|
|
@@ -130,16 +106,17 @@ namespace Model
|
|
|
this.buffs.Remove(buff);
|
|
|
this.idBuff.Remove(buff.Id);
|
|
|
this.typeBuff.Remove(buff.Config.Type, buff);
|
|
|
- RemoveFromTimer(buff);
|
|
|
|
|
|
World.Instance.GetComponent<EventComponent<EventAttribute>>().Run(EventType.AfterRemoveBuff, env);
|
|
|
- }
|
|
|
+
|
|
|
+ buff.Dispose();
|
|
|
+ }
|
|
|
|
|
|
public void RemoveById(ObjectId id)
|
|
|
{
|
|
|
Buff buff = this.GetById(id);
|
|
|
this.Remove(buff);
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
public void RemoveByType(BuffType type)
|
|
|
{
|
|
|
@@ -147,7 +124,7 @@ namespace Model
|
|
|
foreach (Buff buff in allbuffs)
|
|
|
{
|
|
|
this.Remove(buff);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|