From f4131dab4e7835b5c59b124b864cd25298b04a97 Mon Sep 17 00:00:00 2001 From: FN Date: Sat, 27 Apr 2024 23:09:08 +0700 Subject: [PATCH 1/8] Unparent players before debris despawn --- .../Worldgen/Systems/LocalityLoaderSystem.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs index 363fd004e3b..f082d51994f 100644 --- a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs +++ b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs @@ -1,9 +1,11 @@ using Content.Server.Worldgen.Components; +using Content.Server.Worldgen.Components.Debris; +using Content.Shared.Humanoid; +using Content.Shared.Mobs.Components; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.Spawners; - namespace Content.Server.Worldgen.Systems; /// @@ -16,6 +18,11 @@ public sealed class LocalityLoaderSystem : BaseWorldSystem // Duration to reset the despawn timer to when a debris is loaded into a player's view. private const float DebrisActiveDuration = 420; // 7 минут Corvax, а то 5 было маловато людям. + public override void Initialize() + { + SubscribeLocalEvent(OnDebrisDespawn); + } + /// public override void Update(float frameTime) { @@ -77,6 +84,18 @@ private void ResetTimedDespawn(EntityUid uid) timedDespawn.Lifetime = DebrisActiveDuration; } } + + private void OnDebrisDespawn(EntityUid entity, SpaceDebrisComponent component, TimedDespawnEvent e) + { + if (!EntityManager.TryGetComponent(entity, out var transform)) + return; + + var mobQuery = AllEntityQuery(); + + while (mobQuery.MoveNext(out var mob, out _, out _, out var xform)) + if (xform.MapUid is not null && xform.GridUid == transform.GridUid) + _xformSys.SetCoordinates(mob, new(xform.MapUid.Value, _xformSys.GetWorldPosition(xform))); + } } /// From 35976d1f697fde02ea92f7c4766c6ef01ae8fea8 Mon Sep 17 00:00:00 2001 From: FN Date: Sat, 27 Apr 2024 23:10:16 +0700 Subject: [PATCH 2/8] Debris despawn time reduced to 5 minutes --- Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs index f082d51994f..e8c5bff4e44 100644 --- a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs +++ b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs @@ -16,7 +16,7 @@ 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 = 420; // 7 минут Corvax, а то 5 было маловато людям. + private const float DebrisActiveDuration = 300; // 5 минут Corvax, а то 5 было маловато людям. public override void Initialize() { From 50dfe1577de756e0641e23285f8d2904e5bbadc5 Mon Sep 17 00:00:00 2001 From: FN Date: Sat, 27 Apr 2024 23:29:07 +0700 Subject: [PATCH 3/8] Changed comment --- Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs index e8c5bff4e44..af5fcde25de 100644 --- a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs +++ b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs @@ -16,7 +16,7 @@ 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 = 300; // 5 минут Corvax, а то 5 было маловато людям. + private const float DebrisActiveDuration = 300; // 5 минут Corvax. public override void Initialize() { From 2f48ba321f8e2180250e29b31ff6df924691225d Mon Sep 17 00:00:00 2001 From: FN Date: Sat, 27 Apr 2024 23:39:13 +0700 Subject: [PATCH 4/8] Fixed grid check --- Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs index af5fcde25de..ab8105dc501 100644 --- a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs +++ b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs @@ -87,13 +87,10 @@ private void ResetTimedDespawn(EntityUid uid) private void OnDebrisDespawn(EntityUid entity, SpaceDebrisComponent component, TimedDespawnEvent e) { - if (!EntityManager.TryGetComponent(entity, out var transform)) - return; - var mobQuery = AllEntityQuery(); while (mobQuery.MoveNext(out var mob, out _, out _, out var xform)) - if (xform.MapUid is not null && xform.GridUid == transform.GridUid) + if (xform.MapUid is not null && xform.GridUid == entity) _xformSys.SetCoordinates(mob, new(xform.MapUid.Value, _xformSys.GetWorldPosition(xform))); } } From eede6db9e8909833e0bbb8f7aafa0dad6fab65d7 Mon Sep 17 00:00:00 2001 From: FN Date: Sun, 28 Apr 2024 00:11:42 +0700 Subject: [PATCH 5/8] Added debug loggers --- .../Worldgen/Systems/LocalityLoaderSystem.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs index ab8105dc501..283210f45ac 100644 --- a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs +++ b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs @@ -2,8 +2,8 @@ using Content.Server.Worldgen.Components.Debris; using Content.Shared.Humanoid; using Content.Shared.Mobs.Components; +using Microsoft.Extensions.Logging; using Robust.Server.GameObjects; -using Robust.Shared.GameObjects; using Robust.Shared.Spawners; namespace Content.Server.Worldgen.Systems; @@ -89,9 +89,21 @@ private void OnDebrisDespawn(EntityUid entity, SpaceDebrisComponent component, T { var mobQuery = AllEntityQuery(); + var logger = IoCManager.Resolve(); + + logger.LogDebug(ToPrettyString(entity)); + while (mobQuery.MoveNext(out var mob, out _, out _, out var xform)) + { + logger.LogDebug($"{ToPrettyString(mob)} {xform.GridUid}"); + if (xform.MapUid is not null && xform.GridUid == entity) + { _xformSys.SetCoordinates(mob, new(xform.MapUid.Value, _xformSys.GetWorldPosition(xform))); + + logger.LogDebug($"Unparented!"); + } + } } } From b5118b841f08f3d679d119bda6eae0d33b2d91e1 Mon Sep 17 00:00:00 2001 From: FN Date: Sun, 28 Apr 2024 00:30:03 +0700 Subject: [PATCH 6/8] Fixed logger --- Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs index 283210f45ac..dbdb9edc952 100644 --- a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs +++ b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs @@ -2,7 +2,6 @@ using Content.Server.Worldgen.Components.Debris; using Content.Shared.Humanoid; using Content.Shared.Mobs.Components; -using Microsoft.Extensions.Logging; using Robust.Server.GameObjects; using Robust.Shared.Spawners; @@ -89,19 +88,19 @@ private void OnDebrisDespawn(EntityUid entity, SpaceDebrisComponent component, T { var mobQuery = AllEntityQuery(); - var logger = IoCManager.Resolve(); + var logger = IoCManager.Resolve().GetSawmill("world.debris.debug"); - logger.LogDebug(ToPrettyString(entity)); + logger.Debug(ToPrettyString(entity)); while (mobQuery.MoveNext(out var mob, out _, out _, out var xform)) { - logger.LogDebug($"{ToPrettyString(mob)} {xform.GridUid}"); + logger.Debug($"{ToPrettyString(mob)} {xform.GridUid}"); if (xform.MapUid is not null && xform.GridUid == entity) { _xformSys.SetCoordinates(mob, new(xform.MapUid.Value, _xformSys.GetWorldPosition(xform))); - logger.LogDebug($"Unparented!"); + logger.Debug($"Unparented!"); } } } From bd04fc8f9f15eb7125cb739209f9b2eb36587ad3 Mon Sep 17 00:00:00 2001 From: FN Date: Sun, 28 Apr 2024 00:54:37 +0700 Subject: [PATCH 7/8] Changed trackable event --- Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs index dbdb9edc952..99248ccc49f 100644 --- a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs +++ b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs @@ -19,7 +19,7 @@ public sealed class LocalityLoaderSystem : BaseWorldSystem public override void Initialize() { - SubscribeLocalEvent(OnDebrisDespawn); + SubscribeLocalEvent(OnDebrisDespawn); } /// @@ -84,7 +84,7 @@ private void ResetTimedDespawn(EntityUid uid) } } - private void OnDebrisDespawn(EntityUid entity, SpaceDebrisComponent component, TimedDespawnEvent e) + private void OnDebrisDespawn(EntityUid entity, SpaceDebrisComponent component, EntityTerminatingEvent e) { var mobQuery = AllEntityQuery(); From 100829182ec3f797931ef43a4c7b9f2d5cba7163 Mon Sep 17 00:00:00 2001 From: FN Date: Sun, 28 Apr 2024 01:17:52 +0700 Subject: [PATCH 8/8] Clean --- .../Worldgen/Systems/LocalityLoaderSystem.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs index 99248ccc49f..4dbf23ba65d 100644 --- a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs +++ b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs @@ -88,21 +88,9 @@ private void OnDebrisDespawn(EntityUid entity, SpaceDebrisComponent component, E { var mobQuery = AllEntityQuery(); - var logger = IoCManager.Resolve().GetSawmill("world.debris.debug"); - - logger.Debug(ToPrettyString(entity)); - while (mobQuery.MoveNext(out var mob, out _, out _, out var xform)) - { - logger.Debug($"{ToPrettyString(mob)} {xform.GridUid}"); - if (xform.MapUid is not null && xform.GridUid == entity) - { _xformSys.SetCoordinates(mob, new(xform.MapUid.Value, _xformSys.GetWorldPosition(xform))); - - logger.Debug($"Unparented!"); - } - } } }