Skip to content

Commit

Permalink
Obsolete Logger cleanup for EntitySystems part 2 (space-wizards#2…
Browse files Browse the repository at this point in the history
…6159)

* Kill the static InRangeUnOccluded

* Adjusted 4 more EntitySystems that were missed.
  • Loading branch information
LordCarve authored Mar 17, 2024
1 parent 90be67e commit 7d275a4
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 25 deletions.
5 changes: 3 additions & 2 deletions Content.Client/CardboardBox/CardboardBoxSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Numerics;
using System.Numerics;
using Content.Shared.CardboardBox;
using Content.Shared.CardboardBox.Components;
using Content.Shared.Examine;
Expand All @@ -11,6 +11,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
{
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -55,7 +56,7 @@ private void OnBoxEffect(PlayBoxEffectMessage msg)
foreach (var mob in mobMoverEntities)
{
var mapPos = _transform.GetMapCoordinates(mob);
if (!ExamineSystemShared.InRangeUnOccluded(sourcePos, mapPos, box.Distance, null))
if (!_examine.InRangeUnOccluded(sourcePos, mapPos, box.Distance, null))
continue;

var ent = Spawn(box.Effect, mapPos);
Expand Down
5 changes: 4 additions & 1 deletion Content.Client/Popups/PopupOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public sealed class PopupOverlay : Overlay
private readonly IUserInterfaceManager _uiManager;
private readonly PopupSystem _popup;
private readonly PopupUIController _controller;
private readonly ExamineSystemShared _examine;

private readonly ShaderInstance _shader;

Expand All @@ -33,12 +34,14 @@ public PopupOverlay(
IPrototypeManager protoManager,
IUserInterfaceManager uiManager,
PopupUIController controller,
ExamineSystemShared examine,
PopupSystem popup)
{
_configManager = configManager;
_entManager = entManager;
_playerMgr = playerMgr;
_uiManager = uiManager;
_examine = examine;
_popup = popup;
_controller = controller;

Expand Down Expand Up @@ -81,7 +84,7 @@ private void DrawWorld(DrawingHandleScreen worldHandle, OverlayDrawArgs args, fl
var distance = (mapPos.Position - args.WorldBounds.Center).Length();

// Should handle fade here too wyci.
if (!args.WorldBounds.Contains(mapPos.Position) || !ExamineSystemShared.InRangeUnOccluded(viewPos, mapPos, distance,
if (!args.WorldBounds.Contains(mapPos.Position) || !_examine.InRangeUnOccluded(viewPos, mapPos, distance,
e => e == popup.InitialPos.EntityId || e == ourEntity, entMan: _entManager))
continue;

Expand Down
3 changes: 3 additions & 0 deletions Content.Client/Popups/PopupSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Content.Shared.Examine;
using Content.Shared.GameTicking;
using Content.Shared.Popups;
using Robust.Client.Graphics;
Expand Down Expand Up @@ -26,6 +27,7 @@ public sealed class PopupSystem : SharedPopupSystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
[Dependency] private readonly IReplayRecordingManager _replayRecording = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;

public IReadOnlyList<WorldPopupLabel> WorldLabels => _aliveWorldLabels;
public IReadOnlyList<CursorPopupLabel> CursorLabels => _aliveCursorLabels;
Expand All @@ -51,6 +53,7 @@ public override void Initialize()
_prototype,
_uiManager,
_uiManager.GetUIController<PopupUIController>(),
_examine,
this));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ private void UpdateQueuedSpeechBubbles(FrameEventArgs delta)

var otherPos = EntityManager.GetComponent<TransformComponent>(ent).MapPosition;

if (occluded && !ExamineSystemShared.InRangeUnOccluded(
if (occluded && !_examine.InRangeUnOccluded(
playerPos,
otherPos, 0f,
(ent, player), predicate))
Expand Down
8 changes: 4 additions & 4 deletions Content.Client/Verbs/VerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Content.Client.Verbs
public sealed class VerbSystem : SharedVerbSystem
{
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly ExamineSystem _examineSystem = default!;
[Dependency] private readonly ExamineSystem _examine = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
Expand Down Expand Up @@ -77,7 +77,7 @@ public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true
bool Predicate(EntityUid e) => e == player || entitiesUnderMouse.Contains(e);

// first check the general location.
if (!_examineSystem.CanExamine(player.Value, targetPos, Predicate))
if (!_examine.CanExamine(player.Value, targetPos, Predicate))
return false;

TryComp(player.Value, out ExaminerComponent? examiner);
Expand All @@ -86,7 +86,7 @@ public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true
entities = new();
foreach (var ent in _entityLookup.GetEntitiesInRange(targetPos, EntityMenuLookupSize))
{
if (_examineSystem.CanExamine(player.Value, targetPos, Predicate, ent, examiner))
if (_examine.CanExamine(player.Value, targetPos, Predicate, ent, examiner))
entities.Add(ent);
}
}
Expand Down Expand Up @@ -147,7 +147,7 @@ public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true
{
var entity = entities[i];

if (!ExamineSystemShared.InRangeUnOccluded(
if (!_examine.InRangeUnOccluded(
playerPos,
xformQuery.GetComponent(entity).MapPosition,
ExamineSystemShared.ExamineRange,
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Administration/Systems/AdminVerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public sealed partial class AdminVerbSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly StationSystem _stations = default!;
[Dependency] private readonly StationSpawningSystem _spawning = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;

private readonly Dictionary<ICommonSession, List<EditSolutionsEui>> _openSolutionUis = new();

Expand Down Expand Up @@ -416,7 +417,7 @@ private void AddDebugVerbs(GetVerbsEvent<Verb> args)
Act = () =>
{
var message = ExamineSystemShared.InRangeUnOccluded(args.User, args.Target)
var message = _examine.InRangeUnOccluded(args.User, args.Target)
? Loc.GetString("in-range-unoccluded-verb-on-activate-not-occluded")
: Loc.GetString("in-range-unoccluded-verb-on-activate-occluded");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,14 +635,14 @@ private void AdjustEqMovement(TileAtmosphere tile, AtmosDirection direction, flo
// Turns out: no they don't. Temporary debug checks to figure out which caller is causing problems:
if (tile == null)
{
Logger.Error($"Encountered null-tile in {nameof(AdjustEqMovement)}. Trace: {Environment.StackTrace}");
Log.Error($"Encountered null-tile in {nameof(AdjustEqMovement)}. Trace: {Environment.StackTrace}");
return;
}
var adj = tile.AdjacentTiles[direction.ToIndex()];
if (adj == null)
{
var nonNull = tile.AdjacentTiles.Where(x => x != null).Count();
Logger.Error($"Encountered null adjacent tile in {nameof(AdjustEqMovement)}. Dir: {direction}, Tile: {tile.Tile}, non-null adj count: {nonNull}, Trace: {Environment.StackTrace}");
Log.Error($"Encountered null adjacent tile in {nameof(AdjustEqMovement)}. Dir: {direction}, Tile: {tile.Tile}, non-null adj count: {nonNull}, Trace: {Environment.StackTrace}");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void OnClientTypingChanged(TypingChangedEvent ev, EntitySessionEventArgs
var uid = args.SenderSession.AttachedEntity;
if (!Exists(uid))
{
Logger.Warning($"Client {args.SenderSession} sent TypingChangedEvent without an attached entity.");
Log.Warning($"Client {args.SenderSession} sent TypingChangedEvent without an attached entity.");
return;
}

Expand Down
4 changes: 2 additions & 2 deletions Content.Server/GameTicking/Rules/PiratesRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private void OnPlayerSpawningEvent(RulePlayerSpawningEvent ev)

if (!gridId.HasValue)
{
Logger.ErrorS("pirates", $"Gridid was null when loading \"{map}\", aborting.");
Log.Error($"Gridid was null when loading \"{map}\", aborting.");
foreach (var session in ops)
{
ev.PlayerPool.Add(session);
Expand Down Expand Up @@ -230,7 +230,7 @@ private void OnPlayerSpawningEvent(RulePlayerSpawningEvent ev)
if (spawns.Count == 0)
{
spawns.Add(Transform(pirates.PirateShip).Coordinates);
Logger.WarningS("pirates", $"Fell back to default spawn for pirates!");
Log.Warning($"Fell back to default spawn for pirates!");
}

for (var i = 0; i < ops.Length; i++)
Expand Down
5 changes: 3 additions & 2 deletions Content.Server/NPC/Systems/NPCUtilitySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public sealed class NPCUtilitySystem : EntitySystem
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SolutionContainerSystem _solutions = default!;
[Dependency] private readonly WeldableSystem _weldable = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;

private EntityQuery<PuddleComponent> _puddleQuery;
private EntityQuery<TransformComponent> _xformQuery;
Expand Down Expand Up @@ -296,7 +297,7 @@ private float GetScore(NPCBlackboard blackboard, EntityUid targetUid, UtilityCon
{
var radius = blackboard.GetValueOrDefault<float>(NPCBlackboard.VisionRadius, EntityManager);

return ExamineSystemShared.InRangeUnOccluded(owner, targetUid, radius + 0.5f, null) ? 1f : 0f;
return _examine.InRangeUnOccluded(owner, targetUid, radius + 0.5f, null) ? 1f : 0f;
}
case TargetInLOSOrCurrentCon:
{
Expand All @@ -313,7 +314,7 @@ private float GetScore(NPCBlackboard blackboard, EntityUid targetUid, UtilityCon
return 1f;
}

return ExamineSystemShared.InRangeUnOccluded(owner, targetUid, radius + bufferRange, null) ? 1f : 0f;
return _examine.InRangeUnOccluded(owner, targetUid, radius + bufferRange, null) ? 1f : 0f;
}
case TargetIsAliveCon:
{
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Pointing/EntitySystems/PointingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ internal sealed class PointingSystem : SharedPointingSystem
[Dependency] private readonly VisibilitySystem _visibilitySystem = default!;
[Dependency] private readonly SharedMindSystem _minds = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;

private static readonly TimeSpan PointDelay = TimeSpan.FromSeconds(0.5f);

Expand Down Expand Up @@ -100,7 +101,7 @@ public bool InRange(EntityUid pointer, EntityCoordinates coordinates)
}
else
{
return ExamineSystemShared.InRangeUnOccluded(pointer, coordinates, 15, predicate: e => e == pointer);
return _examine.InRangeUnOccluded(pointer, coordinates, 15, predicate: e => e == pointer);
}
}

Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Remotes/DoorRemoteSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public sealed class DoorRemoteSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly DoorSystem _doorSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;
// I'm so sorry [Dependency] private readonly SharedAirlockSystem _sharedAirlockSystem = default!;

public override void Initialize()
Expand Down Expand Up @@ -67,7 +68,7 @@ private void OnBeforeInteract(EntityUid uid, DoorRemoteComponent component, Befo
|| !TryComp<DoorComponent>(args.Target, out var doorComp) // If it isn't a door we don't use it
// Only able to control doors if they are within your vision and within your max range.
// Not affected by mobs or machines anymore.
|| !ExamineSystemShared.InRangeUnOccluded(args.User, args.Target.Value, SharedInteractionSystem.MaxRaycastRange, null))
|| !_examine.InRangeUnOccluded(args.User, args.Target.Value, SharedInteractionSystem.MaxRaycastRange, null))
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Tabletop/TabletopSystem.Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public TabletopSession EnsureSession(TabletopGameComponent tabletop)
// Since this is the first time opening this session, set up the game
tabletop.Setup.SetupTabletop(session, EntityManager);

Logger.Info($"Created tabletop session number {tabletop} at position {session.Position}.");
Log.Info($"Created tabletop session number {tabletop} at position {session.Position}.");

return session;
}
Expand Down
12 changes: 6 additions & 6 deletions Content.Shared/Examine/ExamineSystemShared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public bool IsOccluded(EntityUid uid)
return TryComp<EyeComponent>(uid, out var eye) && eye.DrawFov;
}

public static bool InRangeUnOccluded(MapCoordinates origin, MapCoordinates other, float range, Ignored? predicate, bool ignoreInsideBlocker = true, IEntityManager? entMan = null)
public bool InRangeUnOccluded(MapCoordinates origin, MapCoordinates other, float range, Ignored? predicate, bool ignoreInsideBlocker = true, IEntityManager? entMan = null)
{
// No, rider. This is better.
// ReSharper disable once ConvertToLocalFunction
Expand All @@ -154,7 +154,7 @@ public static bool InRangeUnOccluded(MapCoordinates origin, MapCoordinates other
return InRangeUnOccluded(origin, other, range, predicate, wrapped, ignoreInsideBlocker, entMan);
}

public static bool InRangeUnOccluded<TState>(MapCoordinates origin, MapCoordinates other, float range,
public bool InRangeUnOccluded<TState>(MapCoordinates origin, MapCoordinates other, float range,
TState state, Func<EntityUid, TState, bool> predicate, bool ignoreInsideBlocker = true, IEntityManager? entMan = null)
{
if (other.MapId != origin.MapId ||
Expand All @@ -171,7 +171,7 @@ public static bool InRangeUnOccluded<TState>(MapCoordinates origin, MapCoordinat

if (length > MaxRaycastRange)
{
Logger.Warning("InRangeUnOccluded check performed over extreme range. Limiting CollisionRay size.");
Log.Warning("InRangeUnOccluded check performed over extreme range. Limiting CollisionRay size.");
length = MaxRaycastRange;
}

Expand Down Expand Up @@ -207,7 +207,7 @@ public static bool InRangeUnOccluded<TState>(MapCoordinates origin, MapCoordinat
return true;
}

public static bool InRangeUnOccluded(EntityUid origin, EntityUid other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
public bool InRangeUnOccluded(EntityUid origin, EntityUid other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
{
var entMan = IoCManager.Resolve<IEntityManager>();
var originPos = entMan.GetComponent<TransformComponent>(origin).MapPosition;
Expand All @@ -216,7 +216,7 @@ public static bool InRangeUnOccluded(EntityUid origin, EntityUid other, float ra
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
}

public static bool InRangeUnOccluded(EntityUid origin, EntityCoordinates other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
public bool InRangeUnOccluded(EntityUid origin, EntityCoordinates other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
{
var entMan = IoCManager.Resolve<IEntityManager>();
var originPos = entMan.GetComponent<TransformComponent>(origin).MapPosition;
Expand All @@ -225,7 +225,7 @@ public static bool InRangeUnOccluded(EntityUid origin, EntityCoordinates other,
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
}

public static bool InRangeUnOccluded(EntityUid origin, MapCoordinates other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
public bool InRangeUnOccluded(EntityUid origin, MapCoordinates other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
{
var entMan = IoCManager.Resolve<IEntityManager>();
var originPos = entMan.GetComponent<TransformComponent>(origin).MapPosition;
Expand Down

0 comments on commit 7d275a4

Please sign in to comment.