From a0d5d85019d1e19613d00312f46fc695172ad432 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Wed, 16 Apr 2025 15:01:54 -0400 Subject: [PATCH] Cleanup warnings in GunSystem (#36629) * Cleanup warnings in GunSystem * Remove _transform and use shared's TransformSystem instead * Missed one --- .../Ranged/Systems/GunSystem.AutoFire.cs | 2 +- .../Weapons/Ranged/Systems/GunSystem.cs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.AutoFire.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.AutoFire.cs index e5439cdb06..47b0d5f3c6 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.AutoFire.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.AutoFire.cs @@ -31,7 +31,7 @@ public sealed partial class GunSystem } else if (gun.BurstActivated) { - var parent = _transform.GetParentUid(uid); + var parent = TransformSystem.GetParentUid(uid); if (HasComp(parent)) AttemptShoot(parent, uid, gun, gun.ShootCoordinates ?? new EntityCoordinates(uid, gun.DefaultDirection)); else diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs index 86be82d1c3..b8d488b575 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs @@ -32,9 +32,9 @@ public sealed partial class GunSystem : SharedGunSystem [Dependency] private readonly DamageExamineSystem _damageExamine = default!; [Dependency] private readonly PricingSystem _pricing = default!; [Dependency] private readonly SharedColorFlashEffectSystem _color = default!; - [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly StaminaSystem _stamina = default!; [Dependency] private readonly SharedContainerSystem _container = default!; + [Dependency] private readonly SharedMapSystem _map = default!; private const float DamagePitchVariation = 0.05f; @@ -76,16 +76,16 @@ public sealed partial class GunSystem : SharedGunSystem } } - var fromMap = fromCoordinates.ToMap(EntityManager, TransformSystem); - var toMap = toCoordinates.ToMapPos(EntityManager, TransformSystem); + var fromMap = TransformSystem.ToMapCoordinates(fromCoordinates); + var toMap = TransformSystem.ToMapCoordinates(toCoordinates).Position; var mapDirection = toMap - fromMap.Position; var mapAngle = mapDirection.ToAngle(); var angle = GetRecoilAngle(Timing.CurTime, gun, mapDirection.ToAngle()); // If applicable, this ensures the projectile is parented to grid on spawn, instead of the map. - var fromEnt = MapManager.TryFindGridAt(fromMap, out var gridUid, out var grid) - ? fromCoordinates.WithEntityId(gridUid, EntityManager) - : new EntityCoordinates(MapManager.GetMapEntityId(fromMap.MapId), fromMap.Position); + var fromEnt = MapManager.TryFindGridAt(fromMap, out var gridUid, out _) + ? TransformSystem.WithEntityId(fromCoordinates, gridUid) + : new EntityCoordinates(_map.GetMapOrInvalid(fromMap.MapId), fromMap.Position); // Update shot based on the recoil toMap = fromMap.Position + angle.ToVec() * mapDirection.Length(); @@ -196,7 +196,7 @@ public sealed partial class GunSystem : SharedGunSystem break; fromEffect = Transform(hit).Coordinates; - from = fromEffect.ToMap(EntityManager, _transform); + from = TransformSystem.ToMapCoordinates(fromEffect); dir = ev.Direction; lastUser = hit; } @@ -405,13 +405,13 @@ public sealed partial class GunSystem : SharedGunSystem if (gridUid != fromCoordinates.EntityId && TryComp(gridUid, out TransformComponent? gridXform)) { var (_, gridRot, gridInvMatrix) = TransformSystem.GetWorldPositionRotationInvMatrix(gridXform); - var map = _transform.ToMapCoordinates(fromCoordinates); + var map = TransformSystem.ToMapCoordinates(fromCoordinates); fromCoordinates = new EntityCoordinates(gridUid.Value, Vector2.Transform(map.Position, gridInvMatrix)); angle -= gridRot; } else { - angle -= _transform.GetWorldRotation(fromXform); + angle -= TransformSystem.GetWorldRotation(fromXform); } if (distance >= 1f) -- 2.51.2