fix: Fixes spawner timer deserialization, decimal deserialization, and adds potion keg reverse lookup (#1711)

### Summary
* Fixes spawner timer deserialization
* Adds a check for a null timer and allows the timer to get recreated
* Adds PotionKeg reverse lookup
* Heavily optimizes decimal serialize/deserialize
This commit is contained in:
Kamron Batman 2024-03-28 13:34:12 -07:00 committed by GitHub
parent 70575e1517
commit 1a7e7c7c70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 126 additions and 49 deletions

View file

@ -194,8 +194,11 @@ public abstract partial class BaseSpawner : Item, ISpawner
get => _running && _timer?.Running == true ? End - Core.Now : TimeSpan.Zero;
set
{
Start();
DoTimer(value);
if (!_running && Entries.Count > 0)
{
_running = true;
DoTimer(value);
}
}
}
@ -219,7 +222,7 @@ public abstract partial class BaseSpawner : Item, ISpawner
entry?.RemoveFromSpawned(spawn);
}
if (_running && !IsFull && _timer?.Running == false)
if (_running && !IsFull && _timer?.Running != true)
{
DoTimer();
}
@ -377,13 +380,10 @@ public abstract partial class BaseSpawner : Item, ISpawner
public void Start()
{
if (!_running)
if (!_running && Entries.Count > 0)
{
if (Entries.Count > 0)
{
_running = true;
DoTimer();
}
_running = true;
DoTimer();
}
}
@ -757,7 +757,14 @@ public abstract partial class BaseSpawner : Item, ISpawner
return;
}
End = Core.Now + delay;
if (delay <= TimeSpan.Zero)
{
End = Core.Now;
}
else
{
End = Core.Now + delay;
}
if (_timer == null)
{
@ -795,7 +802,7 @@ public abstract partial class BaseSpawner : Item, ISpawner
Entries.Remove(entry);
if (_running && !IsFull && _timer?.Running == false)
if (_running && !IsFull && _timer?.Running != true)
{
DoTimer();
}
@ -847,7 +854,7 @@ public abstract partial class BaseSpawner : Item, ISpawner
}
}
if (_running && !IsFull && _timer?.Running == false)
if (_running && !IsFull && _timer?.Running != true)
{
DoTimer();
}
@ -912,10 +919,7 @@ public abstract partial class BaseSpawner : Item, ISpawner
}
}
if (_running && _end > Core.Now)
{
DoTimer(_end - Core.Now);
}
DoTimer(_end - Core.Now);
}
private class InternalTimer : Timer