]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix examine threading issues (#30160)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sun, 28 Jul 2024 03:43:59 +0000 (13:43 +1000)
committerGitHub <noreply@github.com>
Sun, 28 Jul 2024 03:43:59 +0000 (13:43 +1000)
Content.Shared/Examine/ExamineSystemShared.cs

index 4100b07483fc7e10c54908d320fc1ea20417f2bf..682018949ab6050a01b765049100bd99e6d26926 100644 (file)
@@ -18,6 +18,7 @@ namespace Content.Shared.Examine
 {
     public abstract partial class ExamineSystemShared : EntitySystem
     {
+        [Dependency] private readonly OccluderSystem _occluder = default!;
         [Dependency] private readonly SharedTransformSystem _transform = default!;
         [Dependency] private readonly SharedContainerSystem _containerSystem = default!;
         [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
@@ -182,12 +183,9 @@ namespace Content.Shared.Examine
                 length = MaxRaycastRange;
             }
 
-            var occluderSystem = Get<OccluderSystem>();
-            IoCManager.Resolve(ref entMan);
-
             var ray = new Ray(origin.Position, dir.Normalized());
-            var rayResults = occluderSystem
-                .IntersectRayWithPredicate(origin.MapId, ray, length, state, predicate, false).ToList();
+            var rayResults = _occluder
+                .IntersectRayWithPredicate(origin.MapId, ray, length, state, predicate, false);
 
             if (rayResults.Count == 0) return true;
 
@@ -195,13 +193,13 @@ namespace Content.Shared.Examine
 
             foreach (var result in rayResults)
             {
-                if (!entMan.TryGetComponent(result.HitEntity, out OccluderComponent? o))
+                if (!TryComp(result.HitEntity, out OccluderComponent? o))
                 {
                     continue;
                 }
 
                 var bBox = o.BoundingBox;
-                bBox = bBox.Translated(entMan.GetComponent<TransformComponent>(result.HitEntity).WorldPosition);
+                bBox = bBox.Translated(_transform.GetWorldPosition(result.HitEntity));
 
                 if (bBox.Contains(origin.Position) || bBox.Contains(other.Position))
                 {
@@ -216,7 +214,6 @@ namespace Content.Shared.Examine
 
         public bool InRangeUnOccluded(EntityUid origin, EntityUid other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
         {
-            var entMan = IoCManager.Resolve<IEntityManager>();
             var originPos = _transform.GetMapCoordinates(origin);
             var otherPos = _transform.GetMapCoordinates(other);
 
@@ -225,16 +222,14 @@ namespace Content.Shared.Examine
 
         public bool InRangeUnOccluded(EntityUid origin, EntityCoordinates other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
         {
-            var entMan = IoCManager.Resolve<IEntityManager>();
             var originPos = _transform.GetMapCoordinates(origin);
-            var otherPos = other.ToMap(entMan, _transform);
+            var otherPos = _transform.ToMapCoordinates(other);
 
             return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
         }
 
         public bool InRangeUnOccluded(EntityUid origin, MapCoordinates other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
         {
-            var entMan = IoCManager.Resolve<IEntityManager>();
             var originPos = _transform.GetMapCoordinates(origin);
 
             return InRangeUnOccluded(originPos, other, range, predicate, ignoreInsideBlocker);
@@ -250,11 +245,12 @@ namespace Content.Shared.Examine
             }
 
             var hasDescription = false;
+            var metadata = MetaData(entity);
 
             //Add an entity description if one is declared
-            if (!string.IsNullOrEmpty(EntityManager.GetComponent<MetaDataComponent>(entity).EntityDescription))
+            if (!string.IsNullOrEmpty(metadata.EntityDescription))
             {
-                message.AddText(EntityManager.GetComponent<MetaDataComponent>(entity).EntityDescription);
+                message.AddText(metadata.EntityDescription);
                 hasDescription = true;
             }