Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Add SSD check to autodelete #114

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Content.Server/Corvax/AutoDeleteItems/AutoDeleteComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ public sealed partial class AutoDeleteComponent : Component
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool IsHumanoidNear;

[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public bool IsSSDNear = false;

[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool ReadyToDelete = false;

Expand Down
72 changes: 47 additions & 25 deletions Content.Server/Corvax/AutoDeleteItems/AutoDeleteSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Content.Shared.Humanoid;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Timing;
using Robust.Shared.Player;
using Content.Shared.SSDIndicator;

namespace Content.Server.Corvax.AutoDeleteItems;

Expand All @@ -28,40 +30,60 @@ public override void Update(float frameTime)
{
return;
}
var humanoids = new HashSet<Entity<HumanoidAppearanceComponent>>();

if (autoDeleteComponent.NextTimeToCheck > _gameTiming.CurTime)
return;
_lookup.GetEntitiesInRange(xform.Coordinates, autoDeleteComponent.DistanceToCheck, humanoids);

if (humanoids.Count > 0)
autoDeleteComponent.IsHumanoidNear = true;
else
autoDeleteComponent.IsHumanoidNear = false;

if (autoDeleteComponent.IsHumanoidNear == false && autoDeleteComponent.ReadyToDelete == true && autoDeleteComponent.NextTimeToDelete < _gameTiming.CurTime)
SSDIndicatorComponent? ssdComponent = null;
//if (!TryComp<SSDIndicatorComponent>(xform., out var ssd))
// continue;
foreach (var iterator in _lookup.GetEntitiesInRange<HumanoidAppearanceComponent>(xform.Coordinates, autoDeleteComponent.DistanceToCheck))
{
EntityManager.DeleteEntity(uid);
}
if (TryComp(iterator, out ssdComponent) && ssdComponent.IsSSD == true)
{
autoDeleteComponent.IsSSDNear = true;
}
else if(TryComp(iterator, out ssdComponent) && ssdComponent.IsSSD == false)
{
autoDeleteComponent.IsSSDNear = false;
}

if (iterator.Owner == uid)
continue;

if (autoDeleteComponent.IsHumanoidNear == true)
{
if (autoDeleteComponent.ReadyToDelete == true)
autoDeleteComponent.ReadyToDelete = false;
var humanoids = new HashSet<Entity<HumanoidAppearanceComponent>>();

autoDeleteComponent.NextTimeToDelete = _gameTiming.CurTime + autoDeleteComponent.DelayToDelete;
autoDeleteComponent.NextTimeToCheck = _gameTiming.CurTime + autoDeleteComponent.DelayToCheck;
}
_lookup.GetEntitiesInRange(xform.Coordinates, autoDeleteComponent.DistanceToCheck, humanoids);

if (autoDeleteComponent.IsHumanoidNear == false && autoDeleteComponent.ReadyToDelete == false)
{
autoDeleteComponent.NextTimeToDelete = _gameTiming.CurTime + autoDeleteComponent.DelayToDelete;
autoDeleteComponent.NextTimeToCheck = _gameTiming.CurTime + autoDeleteComponent.DelayToCheck;
autoDeleteComponent.ReadyToDelete = true;
}
if (humanoids.Count > 0 && !autoDeleteComponent.IsSSDNear)
autoDeleteComponent.IsHumanoidNear = true;
else
autoDeleteComponent.IsHumanoidNear = false;

if (autoDeleteComponent.IsHumanoidNear == false && autoDeleteComponent.ReadyToDelete == true && autoDeleteComponent.NextTimeToDelete < _gameTiming.CurTime)
{
EntityManager.DeleteEntity(uid);
}
if (autoDeleteComponent.IsSSDNear == true)
{
autoDeleteComponent.IsHumanoidNear = false;
}
if (autoDeleteComponent.IsHumanoidNear == true && autoDeleteComponent.IsSSDNear == false)
{
if (autoDeleteComponent.ReadyToDelete == true)
autoDeleteComponent.ReadyToDelete = false;

//autoDeleteComponent.NextTimeToDelete = _gameTiming.CurTime + autoDeleteComponent.DelayToDelete;
//autoDeleteComponent.NextTimeToCheck = _gameTiming.CurTime + autoDeleteComponent.DelayToCheck;
autoDeleteComponent.NextTimeToDelete = _gameTiming.CurTime + autoDeleteComponent.DelayToDelete;
autoDeleteComponent.NextTimeToCheck = _gameTiming.CurTime + autoDeleteComponent.DelayToCheck;
}

if (autoDeleteComponent.IsHumanoidNear == false && autoDeleteComponent.ReadyToDelete == false)
{
autoDeleteComponent.NextTimeToDelete = _gameTiming.CurTime + autoDeleteComponent.DelayToDelete;
autoDeleteComponent.NextTimeToCheck = _gameTiming.CurTime + autoDeleteComponent.DelayToCheck;
autoDeleteComponent.ReadyToDelete = true;
}
}
}
}
}
Loading