Add CanLoad for biomes (#33050)

CPUJob to come later.
This commit is contained in:
metalgearsloth
2024-11-01 14:18:06 +11:00
committed by GitHub
parent c9cd778133
commit d7a1753c7d

View File

@@ -10,6 +10,7 @@ using Content.Server.Shuttles.Events;
using Content.Server.Shuttles.Systems;
using Content.Shared.Atmos;
using Content.Shared.Decals;
using Content.Shared.Ghost;
using Content.Shared.Gravity;
using Content.Shared.Parallax.Biomes;
using Content.Shared.Parallax.Biomes.Layers;
@@ -51,6 +52,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
private EntityQuery<BiomeComponent> _biomeQuery;
private EntityQuery<FixturesComponent> _fixturesQuery;
private EntityQuery<GhostComponent> _ghostQuery;
private EntityQuery<TransformComponent> _xformQuery;
private readonly HashSet<EntityUid> _handledEntities = new();
@@ -81,6 +83,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
Log.Level = LogLevel.Debug;
_biomeQuery = GetEntityQuery<BiomeComponent>();
_fixturesQuery = GetEntityQuery<FixturesComponent>();
_ghostQuery = GetEntityQuery<GhostComponent>();
_xformQuery = GetEntityQuery<TransformComponent>();
SubscribeLocalEvent<BiomeComponent, MapInitEvent>(OnBiomeMapInit);
SubscribeLocalEvent<FTLStartedEvent>(OnFTLStarted);
@@ -315,6 +318,11 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
}
}
private bool CanLoad(EntityUid uid)
{
return !_ghostQuery.HasComp(uid);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
@@ -332,7 +340,8 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
if (_xformQuery.TryGetComponent(pSession.AttachedEntity, out var xform) &&
_handledEntities.Add(pSession.AttachedEntity.Value) &&
_biomeQuery.TryGetComponent(xform.MapUid, out var biome) &&
biome.Enabled)
biome.Enabled &&
CanLoad(pSession.AttachedEntity.Value))
{
var worldPos = _transform.GetWorldPosition(xform);
AddChunksInRange(biome, worldPos);
@@ -349,7 +358,8 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
if (!_handledEntities.Add(viewer) ||
!_xformQuery.TryGetComponent(viewer, out xform) ||
!_biomeQuery.TryGetComponent(xform.MapUid, out biome) ||
!biome.Enabled)
!biome.Enabled ||
!CanLoad(viewer))
{
continue;
}