Replace obsolete functions in NPC systems (#31448)

This commit is contained in:
Mervill
2024-08-26 15:29:44 -07:00
committed by GitHub
parent f65f57ef92
commit e85c25a746
4 changed files with 12 additions and 10 deletions

View File

@@ -20,6 +20,7 @@ public sealed class NPCJukeSystem : EntitySystem
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly MeleeWeaponSystem _melee = default!; [Dependency] private readonly MeleeWeaponSystem _melee = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly SharedTransformSystem _transform = default!;
private EntityQuery<NPCMeleeCombatComponent> _npcMeleeQuery; private EntityQuery<NPCMeleeCombatComponent> _npcMeleeQuery;
@@ -59,7 +60,7 @@ public sealed class NPCJukeSystem : EntitySystem
return; return;
} }
var currentTile = grid.CoordinatesToTile(args.Transform.Coordinates); var currentTile = _mapSystem.CoordinatesToTile(args.Transform.GridUid.Value, grid, args.Transform.Coordinates);
if (component.TargetTile == null) if (component.TargetTile == null)
{ {
@@ -116,7 +117,7 @@ public sealed class NPCJukeSystem : EntitySystem
return; return;
} }
var targetCoords = grid.GridTileToWorld(component.TargetTile.Value); var targetCoords = _mapSystem.GridTileToWorld(args.Transform.GridUid.Value, grid, component.TargetTile.Value);
var targetDir = (targetCoords.Position - args.WorldPosition); var targetDir = (targetCoords.Position - args.WorldPosition);
targetDir = args.OffsetRotation.RotateVec(targetDir); targetDir = args.OffsetRotation.RotateVec(targetDir);
const float weight = 1f; const float weight = 1f;

View File

@@ -166,8 +166,8 @@ public sealed partial class NPCSteeringSystem
} }
// Check if mapids match. // Check if mapids match.
var targetMap = targetCoordinates.ToMap(EntityManager, _transform); var targetMap = _transform.ToMapCoordinates(targetCoordinates);
var ourMap = ourCoordinates.ToMap(EntityManager, _transform); var ourMap = _transform.ToMapCoordinates(ourCoordinates);
if (targetMap.MapId != ourMap.MapId) if (targetMap.MapId != ourMap.MapId)
{ {
@@ -258,7 +258,7 @@ public sealed partial class NPCSteeringSystem
return false; return false;
} }
targetMap = targetCoordinates.ToMap(EntityManager, _transform); targetMap = _transform.ToMapCoordinates(targetCoordinates);
// Can't make it again. // Can't make it again.
if (ourMap.MapId != targetMap.MapId) if (ourMap.MapId != targetMap.MapId)
@@ -439,7 +439,7 @@ public sealed partial class NPCSteeringSystem
if (!node.Data.IsFreeSpace) if (!node.Data.IsFreeSpace)
break; break;
var nodeMap = node.Coordinates.ToMap(EntityManager, _transform); var nodeMap = _transform.ToMapCoordinates(node.Coordinates);
// If any nodes are 'behind us' relative to the target we'll prune them. // If any nodes are 'behind us' relative to the target we'll prune them.
// This isn't perfect but should fix most cases of stutter stepping. // This isn't perfect but should fix most cases of stutter stepping.

View File

@@ -207,7 +207,7 @@ public sealed partial class NPCSteeringSystem
return; return;
} }
foreach (var ent in grid.GetLocalAnchoredEntities(poly.Box)) foreach (var ent in _mapSystem.GetLocalAnchoredEntities(poly.GraphUid, grid, poly.Box))
{ {
if (!_physicsQuery.TryGetComponent(ent, out var body) || if (!_physicsQuery.TryGetComponent(ent, out var body) ||
!body.Hard || !body.Hard ||

View File

@@ -54,6 +54,7 @@ public sealed partial class NPCSteeringSystem : SharedNPCSteeringSystem
[Dependency] private readonly NpcFactionSystem _npcFaction = default!; [Dependency] private readonly NpcFactionSystem _npcFaction = default!;
[Dependency] private readonly PathfindingSystem _pathfindingSystem = default!; [Dependency] private readonly PathfindingSystem _pathfindingSystem = default!;
[Dependency] private readonly PryingSystem _pryingSystem = default!; [Dependency] private readonly PryingSystem _pryingSystem = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interaction = default!; [Dependency] private readonly SharedInteractionSystem _interaction = default!;
[Dependency] private readonly SharedMeleeWeaponSystem _melee = default!; [Dependency] private readonly SharedMeleeWeaponSystem _melee = default!;
[Dependency] private readonly SharedMoverController _mover = default!; [Dependency] private readonly SharedMoverController _mover = default!;