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

Commit

Permalink
Check for MapComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
FireNameFN committed Apr 27, 2024
1 parent 9636970 commit c3aa1c6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Content.Server/NPC/HTN/HTNSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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 @@ -30,8 +31,8 @@ public sealed class HTNSystem : EntitySystem
[Dependency] private readonly WorldControllerSystem _world = default!;

private EntityQuery<TransformComponent> _xformQuery;

private EntityQuery<LoadedChunkComponent> _loadedQuery;
private EntityQuery<MapComponent> _mapQuery;

private readonly JobQueue _planQueue = new(0.004);

Expand All @@ -43,6 +44,7 @@ public override void Initialize()
base.Initialize();
_xformQuery = GetEntityQuery<TransformComponent>();
_loadedQuery = GetEntityQuery<LoadedChunkComponent>();
_mapQuery = GetEntityQuery<MapComponent>();
SubscribeLocalEvent<HTNComponent, MobStateChangedEvent>(_npc.OnMobStateChange);
SubscribeLocalEvent<HTNComponent, MapInitEvent>(_npc.OnNPCMapInit);
SubscribeLocalEvent<HTNComponent, PlayerAttachedEvent>(_npc.OnPlayerNPCAttach);
Expand Down Expand Up @@ -263,6 +265,9 @@ 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))
return true;

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

Expand Down

0 comments on commit c3aa1c6

Please sign in to comment.