HTNComponent from SharedNPCSystem (#42750)

* init

* move system

* doc
This commit is contained in:
Shegare 2026-03-05 00:54:28 +03:00 committed by Coryler
parent 2438155aa7
commit b28568d2da
6 changed files with 28 additions and 20 deletions

View File

@ -1,5 +1,4 @@
using Content.Client.Hands.Systems;
using Content.Client.NPC.HTN;
using Content.Shared.CCVar;
using Content.Shared.CombatMode;
using Robust.Client.Graphics;
@ -59,11 +58,6 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
UpdateHud(entity);
}
protected override bool IsNpc(EntityUid uid)
{
return HasComp<HTNComponent>(uid);
}
private void UpdateHud(EntityUid entity)
{
if (entity != _playerManager.LocalEntity || !Timing.IsFirstTimePredicted)

View File

@ -0,0 +1,12 @@
using Content.Client.NPC.HTN;
using Content.Shared.NPC.Systems;
namespace Content.Client.NPC.Systems;
public sealed class NPCSystem : SharedNPCSystem
{
public override bool IsNpc(EntityUid uid)
{
return HasComp<HTNComponent>(uid);
}
}

View File

@ -1,12 +1,5 @@
using Content.Server.NPC.HTN;
using Content.Shared.CombatMode;
namespace Content.Server.CombatMode;
public sealed class CombatModeSystem : SharedCombatModeSystem
{
protected override bool IsNpc(EntityUid uid)
{
return HasComp<HTNComponent>(uid);
}
}
public sealed class CombatModeSystem : SharedCombatModeSystem;

View File

@ -18,7 +18,7 @@ namespace Content.Server.NPC.Systems
/// <summary>
/// Handles NPCs running every tick.
/// </summary>
public sealed partial class NPCSystem : EntitySystem
public sealed partial class NPCSystem : SharedNPCSystem
{
private static readonly Gauge ActiveGauge = Metrics.CreateGauge(
"npc_active_count",
@ -78,6 +78,11 @@ namespace Content.Server.NPC.Systems
SleepNPC(uid, component);
}
public override bool IsNpc(EntityUid uid)
{
return HasComp<HTNComponent>(uid);
}
/// <summary>
/// Is the NPC awake and updating?
/// </summary>

View File

@ -2,8 +2,8 @@ using Content.Shared.Actions;
using Content.Shared.Mind;
using Content.Shared.MouseRotator;
using Content.Shared.Movement.Components;
using Content.Shared.NPC.Systems;
using Content.Shared.Popups;
using Robust.Shared.Network;
using Robust.Shared.Timing;
namespace Content.Shared.CombatMode;
@ -14,6 +14,7 @@ public abstract class SharedCombatModeSystem : EntitySystem
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly SharedNPCSystem _npc = default!;
public override void Initialize()
{
@ -77,7 +78,7 @@ public abstract class SharedCombatModeSystem : EntitySystem
_actionsSystem.SetToggled(component.CombatToggleActionEntity, component.IsInCombatMode);
// Change mouse rotator comps if flag is set
if (!component.ToggleMouseRotator || IsNpc(entity) && !_mind.TryGetMind(entity, out _, out _))
if (!component.ToggleMouseRotator || _npc.IsNpc(entity) && !_mind.TryGetMind(entity, out _, out _))
return;
SetMouseRotatorComponents(entity, value);
@ -96,9 +97,6 @@ public abstract class SharedCombatModeSystem : EntitySystem
RemComp<NoRotateOnMoveComponent>(uid);
}
}
// todo: When we stop making fucking garbage abstract shared components, remove this shit too.
protected abstract bool IsNpc(EntityUid uid);
}
public sealed partial class ToggleCombatActionEvent : InstantActionEvent

View File

@ -2,4 +2,10 @@ namespace Content.Shared.NPC.Systems;
public abstract partial class SharedNPCSystem : EntitySystem
{
/// <summary>
/// Returns whether the given entity is an NPC.
/// </summary>
/// <param name="uid">Entity UID to check.</param>
/// <returns><c>true</c> if the entity is an NPC, otherwise <c>false</c>.</returns>
public abstract bool IsNpc(EntityUid uid);
}