Use new ComponentPauseGenerator (#25183)

Also includes some (non critical) changes to the solution file to re-organize the Roslyn components.
This commit is contained in:
Pieter-Jan Briers
2024-02-26 04:36:19 +01:00
committed by GitHub
parent 2a2324ecaf
commit e00f74505c
130 changed files with 150 additions and 539 deletions

View File

@@ -3,7 +3,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.NPC.Components;
[RegisterComponent]
[RegisterComponent, AutoGenerateComponentPause]
public sealed partial class NPCJukeComponent : Component
{
[DataField("jukeType")]
@@ -13,6 +13,7 @@ public sealed partial class NPCJukeComponent : Component
public float JukeDuration = 0.5f;
[DataField("nextJuke", customTypeSerializer:typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan NextJuke;
[DataField("targetTile")]

View File

@@ -11,7 +11,7 @@ namespace Content.Server.NPC.Components;
/// <summary>
/// Added to NPCs that are moving.
/// </summary>
[RegisterComponent]
[RegisterComponent, AutoGenerateComponentPause]
public sealed partial class NPCSteeringComponent : Component
{
#region Context Steering
@@ -49,6 +49,7 @@ public sealed partial class NPCSteeringComponent : Component
/// Next time we can change our steering direction.
/// </summary>
[DataField("nextSteer", customTypeSerializer:typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan NextSteer = TimeSpan.Zero;
[DataField("lastSteerIndex")]
@@ -66,6 +67,7 @@ public sealed partial class NPCSteeringComponent : Component
public EntityCoordinates LastStuckCoordinates;
[DataField("lastStuckTime", customTypeSerializer:typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan LastStuckTime;
public const float StuckDistance = 1f;

View File

@@ -5,7 +5,7 @@ namespace Content.Server.NPC.Pathfinding;
/// <summary>
/// Stores the relevant pathfinding data for grids.
/// </summary>
[RegisterComponent, Access(typeof(PathfindingSystem))]
[RegisterComponent, Access(typeof(PathfindingSystem)), AutoGenerateComponentPause]
public sealed partial class GridPathfindingComponent : Component
{
[ViewVariables]
@@ -15,6 +15,7 @@ public sealed partial class GridPathfindingComponent : Component
/// Next time the graph is allowed to update.
/// </summary>
/// Removing this datafield is the lazy fix HOWEVER I want to purge this anyway and do pathfinding at runtime.
[AutoPausedField]
public TimeSpan NextUpdate;
[ViewVariables]

View File

@@ -44,7 +44,6 @@ public sealed partial class PathfindingSystem
{
SubscribeLocalEvent<GridInitializeEvent>(OnGridInit);
SubscribeLocalEvent<GridRemovalEvent>(OnGridRemoved);
SubscribeLocalEvent<GridPathfindingComponent, EntityUnpausedEvent>(OnGridPathPause);
SubscribeLocalEvent<GridPathfindingComponent, ComponentShutdown>(OnGridPathShutdown);
SubscribeLocalEvent<CollisionChangeEvent>(OnCollisionChange);
SubscribeLocalEvent<CollisionLayerChangeEvent>(OnCollisionLayerChange);
@@ -61,10 +60,6 @@ public sealed partial class PathfindingSystem
DirtyChunk(ev.Entity, Comp<MapGridComponent>(ev.Entity).GridTileToLocal(ev.NewTile.GridIndices));
}
private void OnGridPathPause(EntityUid uid, GridPathfindingComponent component, ref EntityUnpausedEvent args)
{
component.NextUpdate += args.PausedTime;
}
private void OnGridPathShutdown(EntityUid uid, GridPathfindingComponent component, ComponentShutdown args)
{

View File

@@ -33,15 +33,9 @@ public sealed class NPCJukeSystem : EntitySystem
_npcRangedQuery = GetEntityQuery<NPCRangedCombatComponent>();
_physicsQuery = GetEntityQuery<PhysicsComponent>();
SubscribeLocalEvent<NPCJukeComponent, EntityUnpausedEvent>(OnJukeUnpaused);
SubscribeLocalEvent<NPCJukeComponent, NPCSteeringEvent>(OnJukeSteering);
}
private void OnJukeUnpaused(EntityUid uid, NPCJukeComponent component, ref EntityUnpausedEvent args)
{
component.NextJuke += args.PausedTime;
}
private void OnJukeSteering(EntityUid uid, NPCJukeComponent component, ref NPCSteeringEvent args)
{
if (component.JukeType == JukeType.AdjacentTile)

View File

@@ -107,7 +107,6 @@ public sealed partial class NPCSteeringSystem : SharedNPCSteeringSystem
Subs.CVar(_configManager, CCVars.NPCPathfinding, SetNPCPathfinding, true);
SubscribeLocalEvent<NPCSteeringComponent, ComponentShutdown>(OnSteeringShutdown);
SubscribeLocalEvent<NPCSteeringComponent, EntityUnpausedEvent>(OnSteeringUnpaused);
SubscribeNetworkEvent<RequestNPCSteeringDebugEvent>(OnDebugRequest);
}
@@ -158,12 +157,6 @@ public sealed partial class NPCSteeringSystem : SharedNPCSteeringSystem
component.PathfindToken = null;
}
private void OnSteeringUnpaused(EntityUid uid, NPCSteeringComponent component, ref EntityUnpausedEvent args)
{
component.LastStuckTime += args.PausedTime;
component.NextSteer += args.PausedTime;
}
/// <summary>
/// Adds the AI to the steering system to move towards a specific target
/// </summary>