Skip to content

Commit

Permalink
Replace obsolete EntityCoordiates.InRange() with TransformSystem.InRa…
Browse files Browse the repository at this point in the history
…nge() (#29993)

* Replace EntityCoordiates.InRange() with TransformSystem.InRange()

* nullspace

* I figured it out

* man I have no clue how client side sutff works

* please have mercy

* remove RadiationPulseOverlay changes

* nullspace

---------

Co-authored-by: plykiya <plykiya@protonmail.com>
  • Loading branch information
Plykiya and plykiya authored Jul 13, 2024
1 parent a03b889 commit b7aa97e
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Content.Client/RCD/AlignRCDConstruction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override bool IsValidPosition(EntityCoordinates position)
if (!_entityManager.TryGetComponent<TransformComponent>(player, out var xform))
return false;

if (!xform.Coordinates.InRange(_entityManager, _transformSystem, position, SharedInteractionSystem.InteractionRange))
if (!_transformSystem.InRange(xform.Coordinates, position, SharedInteractionSystem.InteractionRange))
{
InvalidPlaceColor = InvalidPlaceColor.WithAlpha(0);
return false;
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Storage/Systems/StorageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ public void PickupAnimation(EntityUid item, EntityCoordinates initialCoords, Ent
{
if (!_timing.IsFirstTimePredicted)
return;

if (finalCoords.InRange(EntityManager, TransformSystem, initialCoords, 0.1f) ||
if (TransformSystem.InRange(finalCoords, initialCoords, 0.1f) ||
!Exists(initialCoords.EntityId) || !Exists(finalCoords.EntityId))
{
return;
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private bool UpdateAnalyzer(EntityUid uid, GasAnalyzerComponent? component = nul
if (component.LastPosition.HasValue)
{
// Check if position is out of range => don't update and disable
if (!component.LastPosition.Value.InRange(EntityManager, _transform, userPos, SharedInteractionSystem.InteractionRange))
if (!_transform.InRange(component.LastPosition.Value, userPos, SharedInteractionSystem.InteractionRange))
{
if (component.User is { } userId && component.Enabled)
_popup.PopupEntity(Loc.GetString("gas-analyzer-shutoff"), userId, userId);
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Dragon/DragonSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private void OnSpawnRift(EntityUid uid, DragonComponent component, DragonSpawnRi
// cant stack rifts near eachother
foreach (var (_, riftXform) in EntityQuery<DragonRiftComponent, TransformComponent>(true))
{
if (riftXform.Coordinates.InRange(EntityManager, _transform, xform.Coordinates, RiftRange))
if (_transform.InRange(riftXform.Coordinates, xform.Coordinates, RiftRange))
{
_popup.PopupEntity(Loc.GetString("carp-rift-proximity", ("proximity", RiftRange)), uid, uid);
return;
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Guardian/GuardianSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ private void CheckGuardianMove(
if (!guardianComponent.GuardianLoose)
return;

if (!guardianXform.Coordinates.InRange(EntityManager, _transform, hostXform.Coordinates, guardianComponent.DistanceAllowed))
if (!_transform.InRange(guardianXform.Coordinates, hostXform.Coordinates, guardianComponent.DistanceAllowed))
RetractGuardian(hostUid, hostComponent, guardianUid, guardianComponent);
}

Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Instruments/InstrumentSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ public override void Update(float frameTime)

var trans = transformQuery.GetComponent(uid);
var masterTrans = transformQuery.GetComponent(master);
if (!masterTrans.Coordinates.InRange(EntityManager, _transform, trans.Coordinates, 10f))
if (!_transform.InRange(masterTrans.Coordinates, trans.Coordinates, 10f)
)
{
Clean(uid, instrument);
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Medical/HealthAnalyzerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override void Update(float frameTime)

//Get distance between health analyzer and the scanned entity
var patientCoordinates = Transform(patient).Coordinates;
if (!patientCoordinates.InRange(EntityManager, _transformSystem, transform.Coordinates, component.MaxScanRange))
if (!_transformSystem.InRange(patientCoordinates, transform.Coordinates, component.MaxScanRange))
{
//Range too far, disable updates
StopAnalyzingEntity((uid, component), patient);
Expand Down
5 changes: 3 additions & 2 deletions Content.Server/Movement/Systems/PullController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public sealed class PullController : VirtualController
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedGravitySystem _gravity = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;

/// <summary>
/// If distance between puller and pulled entity lower that this threshold,
Expand Down Expand Up @@ -133,8 +134,8 @@ private bool OnRequestMovePulledObject(ICommonSession? session, EntityCoordinate
var range = 2f;
var fromUserCoords = coords.WithEntityId(player, EntityManager);
var userCoords = new EntityCoordinates(player, Vector2.Zero);

if (!coords.InRange(EntityManager, TransformSystem, userCoords, range))
if (!_transformSystem.InRange(coords, userCoords, range))
{
var direction = fromUserCoords.Position - userCoords.Position;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ namespace Content.Server.NPC.HTN.Preconditions;
public sealed partial class CoordinatesInRangePrecondition : HTNPrecondition
{
[Dependency] private readonly IEntityManager _entManager = default!;
private SharedTransformSystem _transformSystem = default!;

[DataField("targetKey", required: true)] public string TargetKey = default!;

[DataField("rangeKey", required: true)]
public string RangeKey = default!;

public override void Initialize(IEntitySystemManager sysManager)
{
base.Initialize(sysManager);
_transformSystem = sysManager.GetEntitySystem<SharedTransformSystem>();
}

public override bool IsMet(NPCBlackboard blackboard)
{
if (!blackboard.TryGetValue<EntityCoordinates>(NPCBlackboard.OwnerCoordinates, out var coordinates, _entManager))
Expand All @@ -22,6 +29,6 @@ public override bool IsMet(NPCBlackboard blackboard)
if (!blackboard.TryGetValue<EntityCoordinates>(TargetKey, out var target, _entManager))
return false;

return coordinates.InRange(_entManager, _entManager.System<SharedTransformSystem>(), target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
return _transformSystem.InRange(coordinates, target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ namespace Content.Server.NPC.HTN.Preconditions;
public sealed partial class CoordinatesNotInRangePrecondition : HTNPrecondition
{
[Dependency] private readonly IEntityManager _entManager = default!;
private SharedTransformSystem _transformSystem = default!;

[DataField("targetKey", required: true)] public string TargetKey = default!;

[DataField("rangeKey", required: true)]
public string RangeKey = default!;

public override void Initialize(IEntitySystemManager sysManager)
{
base.Initialize(sysManager);
_transformSystem = sysManager.GetEntitySystem<SharedTransformSystem>();
}

public override bool IsMet(NPCBlackboard blackboard)
{
if (!blackboard.TryGetValue<EntityCoordinates>(NPCBlackboard.OwnerCoordinates, out var coordinates, _entManager))
Expand All @@ -22,7 +29,7 @@ public override bool IsMet(NPCBlackboard blackboard)
if (!blackboard.TryGetValue<EntityCoordinates>(TargetKey, out var target, _entManager))
return false;

return !coordinates.InRange(_entManager, _entManager.System<SharedTransformSystem>(), target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
return !_transformSystem.InRange(coordinates, target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ namespace Content.Server.NPC.HTN.Preconditions;
public sealed partial class TargetInRangePrecondition : HTNPrecondition
{
[Dependency] private readonly IEntityManager _entManager = default!;
private SharedTransformSystem _transformSystem = default!;

[DataField("targetKey", required: true)] public string TargetKey = default!;

[DataField("rangeKey", required: true)]
public string RangeKey = default!;
public override void Initialize(IEntitySystemManager sysManager)
{
base.Initialize(sysManager);
_transformSystem = sysManager.GetEntitySystem<SharedTransformSystem>();
}

public override bool IsMet(NPCBlackboard blackboard)
{
Expand All @@ -23,6 +29,7 @@ public override bool IsMet(NPCBlackboard blackboard)
!_entManager.TryGetComponent<TransformComponent>(target, out var targetXform))
return false;

return coordinates.InRange(_entManager, _entManager.System<SharedTransformSystem>(), targetXform.Coordinates, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
var transformSystem = _entManager.System<SharedTransformSystem>;
return _transformSystem.InRange(coordinates, targetXform.Coordinates, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
}
}
2 changes: 1 addition & 1 deletion Content.Server/Pointing/EntitySystems/PointingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public bool InRange(EntityUid pointer, EntityCoordinates coordinates)
{
if (HasComp<GhostComponent>(pointer))
{
return Transform(pointer).Coordinates.InRange(EntityManager, _transform, coordinates, 15);
return _transform.InRange(Transform(pointer).Coordinates, coordinates, 15);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Actions/SharedActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ private bool ValidateWorldTargetBase(EntityUid user, EntityCoordinates coords, W
if (action.Range <= 0)
return true;

return coords.InRange(EntityManager, _transformSystem, Transform(user).Coordinates, action.Range);
return _transformSystem.InRange(coords, Transform(user).Coordinates, action.Range);
}

return _interactionSystem.InRangeUnobstructed(user, coords, range: action.Range);
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/DoAfter/SharedDoAfterSystem.Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private bool ShouldCancel(DoAfter doAfter,
if (args.BreakOnMove && !(!args.BreakOnWeightlessMove && _gravity.IsWeightless(args.User, xform: userXform)))
{
// Whether the user has moved too much from their original position.
if (!userXform.Coordinates.InRange(EntityManager, _transform, doAfter.UserPosition, args.MovementThreshold))
if (!_transform.InRange(userXform.Coordinates, doAfter.UserPosition, args.MovementThreshold))
return true;

// Whether the distance between the user and target(if any) has changed too much.
Expand Down

0 comments on commit b7aa97e

Please sign in to comment.