fix: Codegens talismans - Fixes memory leak (#1469)
This commit is contained in:
parent
ca89b8b08b
commit
ffb0b24e1a
41 changed files with 1979 additions and 2256 deletions
|
|
@ -10,6 +10,7 @@ public class UnsummonTimer : Timer
|
|||
// Track timers since some of them are really long and might hold references to long dead/deleted mobs
|
||||
private static readonly Dictionary<BaseCreature, UnsummonTimer> _timers = new();
|
||||
private BaseCreature _creature;
|
||||
private Action _onUnsummon;
|
||||
|
||||
public static void StopTimer(BaseCreature creature)
|
||||
{
|
||||
|
|
@ -19,8 +20,9 @@ public class UnsummonTimer : Timer
|
|||
}
|
||||
}
|
||||
|
||||
public UnsummonTimer(BaseCreature creature, TimeSpan delay) : base(delay)
|
||||
public UnsummonTimer(BaseCreature creature, TimeSpan delay, Action onUnsummon = null) : base(delay)
|
||||
{
|
||||
_onUnsummon = onUnsummon;
|
||||
_creature = creature;
|
||||
|
||||
ref var timer = ref CollectionsMarshal.GetValueRefOrAddDefault(_timers, creature, out bool exists);
|
||||
|
|
@ -36,5 +38,6 @@ public class UnsummonTimer : Timer
|
|||
{
|
||||
// BaseCreature.OnAfterDelete will remove the creature from the timers table
|
||||
_creature?.Delete();
|
||||
_onUnsummon?.Invoke();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue