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

Commit

Permalink
Check for WorldControllerComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
FireNameFN committed Apr 27, 2024
1 parent c3aa1c6 commit 7823f9e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Content.Server/NPC/HTN/HTNSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using JetBrains.Annotations;
using Robust.Shared.CPUJob.JobQueues;
using Robust.Shared.CPUJob.JobQueues.Queues;
using Robust.Shared.Map.Components;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
Expand All @@ -32,7 +31,7 @@ public sealed class HTNSystem : EntitySystem

private EntityQuery<TransformComponent> _xformQuery;
private EntityQuery<LoadedChunkComponent> _loadedQuery;
private EntityQuery<MapComponent> _mapQuery;
private EntityQuery<WorldControllerComponent> _mapQuery;

private readonly JobQueue _planQueue = new(0.004);

Expand All @@ -44,7 +43,7 @@ public override void Initialize()
base.Initialize();
_xformQuery = GetEntityQuery<TransformComponent>();
_loadedQuery = GetEntityQuery<LoadedChunkComponent>();
_mapQuery = GetEntityQuery<MapComponent>();
_mapQuery = GetEntityQuery<WorldControllerComponent>();
SubscribeLocalEvent<HTNComponent, MobStateChangedEvent>(_npc.OnMobStateChange);
SubscribeLocalEvent<HTNComponent, MapInitEvent>(_npc.OnNPCMapInit);
SubscribeLocalEvent<HTNComponent, PlayerAttachedEvent>(_npc.OnPlayerNPCAttach);
Expand Down Expand Up @@ -265,10 +264,10 @@ private bool IsNPCActive(HTNComponent component)

/*return _physics.GetCollidingEntities(xform.MapID, Box2.CenteredAround(_transform.GetWorldPosition(xform), new(12))).Any(physicsComponent => physicsComponent.);*/

if (!_mapQuery.HasComponent(xform.MapUid))
if (!_mapQuery.TryGetComponent(xform.MapUid, out var worldComponent))
return true;

return _loadedQuery.HasComponent(_world.GetOrCreateChunk(WorldGen.WorldToChunkCoords(xform.WorldPosition).Floored(), xform.MapUid!.Value));
return _loadedQuery.HasComponent(_world.GetOrCreateChunk(WorldGen.WorldToChunkCoords(xform.WorldPosition).Floored(), xform.MapUid!.Value, worldComponent));
}

private void AppendDebugText(HTNTask task, StringBuilder text, List<int> planBtr, List<int> btr, ref int level)
Expand Down

0 comments on commit 7823f9e

Please sign in to comment.