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

Commit

Permalink
Автоудаление обломков
Browse files Browse the repository at this point in the history
  • Loading branch information
Vonsant committed Apr 23, 2024
1 parent dca810d commit 0924193
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Content.Server/Worldgen/Prototypes/GCQueuePrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public sealed class GCQueuePrototype : IPrototype
/// The maximum amount of time that can be spent processing this queue.
/// </summary>
[DataField("maximumTickTime")]
public TimeSpan MaximumTickTime { get; } = TimeSpan.FromMilliseconds(1);
public TimeSpan MaximumTickTime { get; } = TimeSpan.FromMilliseconds(5);

/// <summary>
/// The minimum depth before entities in the queue actually get processed for deletion.
Expand Down
28 changes: 25 additions & 3 deletions Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Content.Server.Worldgen.Components;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Spawners;


namespace Content.Server.Worldgen.Systems;

Expand All @@ -10,6 +13,9 @@ public sealed class LocalityLoaderSystem : BaseWorldSystem
{
[Dependency] private readonly TransformSystem _xformSys = default!;

// Duration to reset the despawn timer to when a debris is loaded into a player's view.
private const float DebrisActiveDuration = 360; // 10 минут Corvax

/// <inheritdoc />
public override void Update(float frameTime)
{
Expand Down Expand Up @@ -45,6 +51,9 @@ public override void Update(float frameTime)
if ((_xformSys.GetWorldPosition(loaderXform) - _xformSys.GetWorldPosition(xform)).Length() > loadable.LoadingDistance)
continue;

// Reset the TimedDespawnComponent's lifetime when loaded
ResetTimedDespawn(uid);

RaiseLocalEvent(uid, new LocalStructureLoadedEvent());
RemCompDeferred<LocalityLoaderComponent>(uid);
done = true;
Expand All @@ -54,10 +63,23 @@ public override void Update(float frameTime)
}
}
}

private void ResetTimedDespawn(EntityUid uid)
{
if (TryComp<TimedDespawnComponent>(uid, out var timedDespawn))
{
timedDespawn.Lifetime = DebrisActiveDuration;
}
else
{
// Add TimedDespawnComponent if it does not exist
timedDespawn = AddComp<TimedDespawnComponent>(uid);
timedDespawn.Lifetime = DebrisActiveDuration;
}
}
}

/// <summary>
/// A directed fired on a loadable entity when a local loader enters it's vicinity.
/// An event fired on a loadable entity when a local loader enters its vicinity.
/// </summary>
public record struct LocalStructureLoadedEvent;

public record struct LocalStructureLoadedEvent;
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/World/Debris/base_debris.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
components:
- type: OwnedDebris
- type: LocalityLoader
- type: TimedDespawn
lifetime: 120
5 changes: 3 additions & 2 deletions Resources/Prototypes/GC/world.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- type: gcQueue
id: SpaceDebris
depth: 512 # So there's a decent bit of time before roids unload.
minDepthToProcess: 256
depth: 256 # Corvax
minDepthToProcess: 128 # Corvax
trySkipQueue: true # Попытка немедленного удаления, если это возможно
4 changes: 2 additions & 2 deletions Resources/Prototypes/_NF/Maps/POI/cove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
- type: StationJobs
overflowJobs: []
availableJobs:
PirateCaptain: [ 0, 0 ]
PirateFirstMate: [ 0, 0 ]
PirateCaptain: [ 1, 1 ]
PirateFirstMate: [ 2, 2 ]

0 comments on commit 0924193

Please sign in to comment.