fix: Fixes fillable containers start respawn on unlock. (#2069)
This commit is contained in:
parent
f5e944335b
commit
64e32a817d
3 changed files with 142 additions and 290 deletions
|
|
@ -79,20 +79,23 @@ public abstract partial class FillableContainer : LockableContainer
|
|||
|
||||
public virtual void AcquireContent()
|
||||
{
|
||||
if (_contentType != FillableContentType.None)
|
||||
if (_contentType == FillableContentType.None)
|
||||
{
|
||||
return;
|
||||
_contentType = FillableContent.Acquire(GetWorldLocation(), Map);
|
||||
}
|
||||
|
||||
// Don't trigger serialization code
|
||||
_contentType = FillableContent.Acquire(GetWorldLocation(), Map);
|
||||
|
||||
if (_contentType != FillableContentType.None)
|
||||
{
|
||||
Respawn();
|
||||
}
|
||||
}
|
||||
|
||||
public override void LockPick(Mobile from)
|
||||
{
|
||||
base.LockPick(from);
|
||||
CheckRespawn();
|
||||
}
|
||||
|
||||
public override void OnItemRemoved(Item item)
|
||||
{
|
||||
CheckRespawn();
|
||||
|
|
@ -120,29 +123,13 @@ public abstract partial class FillableContainer : LockableContainer
|
|||
|
||||
public void CheckRespawn()
|
||||
{
|
||||
var canSpawn =
|
||||
_contentType != FillableContentType.None &&
|
||||
!Deleted && !Movable && Parent == null && !IsLockedDown && !IsSecure &&
|
||||
(
|
||||
GetItemsCount() <= SpawnThreshold ||
|
||||
IsLockable && !Locked ||
|
||||
IsTrappable && TrapType == TrapType.None
|
||||
);
|
||||
if (_respawnTimer?.Running == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (canSpawn)
|
||||
{
|
||||
if (_respawnTimer?.Running != true)
|
||||
{
|
||||
var mins = Utility.RandomMinMax(MinRespawnMinutes, MaxRespawnMinutes);
|
||||
var delay = TimeSpan.FromMinutes(mins);
|
||||
_respawnTimer = Timer.DelayCall(delay, Respawn);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_respawnTimer?.Stop();
|
||||
_respawnTimer = null;
|
||||
}
|
||||
var delay = TimeSpan.FromMinutes(Utility.RandomMinMax(MinRespawnMinutes, MaxRespawnMinutes));
|
||||
_respawnTimer = Timer.DelayCall(delay, Respawn);
|
||||
}
|
||||
|
||||
public void Respawn()
|
||||
|
|
@ -182,8 +169,6 @@ public abstract partial class FillableContainer : LockableContainer
|
|||
TrapPower = 0;
|
||||
TrapLevel = 0;
|
||||
}
|
||||
|
||||
CheckRespawn();
|
||||
}
|
||||
|
||||
protected virtual int GetSpawnCount()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue