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

Commit

Permalink
Merge pull request #114 from Corvax-Frontier/deleteitems-sh1ntra
Browse files Browse the repository at this point in the history
Add SSD check to autodelete
  • Loading branch information
Vonsant authored May 3, 2024
2 parents 7dcdb67 + 9794365 commit 0649b13
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 25 deletions.
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;
}
}
}
}
}

0 comments on commit 0649b13

Please sign in to comment.