Fix examine threading issues (#30160)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user