From d548bce3473b60a95cf19929dab27a89c8eccaf8 Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Tue, 16 Dec 2025 13:23:47 +0000 Subject: [PATCH] make EntityQuery.Resolve error not useless (#6320) * make EntityQuery.Resolve error not useless * it actually wasnt that bad * goida * make EntityQuery constructor internal --------- Co-authored-by: deltanedas <@deltanedas:kde.org> --- .../GameObjects/EntityManager.Components.cs | 16 +++++++--------- Robust.Shared/GameObjects/EntityManager.cs | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Robust.Shared/GameObjects/EntityManager.Components.cs b/Robust.Shared/GameObjects/EntityManager.Components.cs index cff5c5841..09dd5cdf5 100644 --- a/Robust.Shared/GameObjects/EntityManager.Components.cs +++ b/Robust.Shared/GameObjects/EntityManager.Components.cs @@ -1180,14 +1180,14 @@ namespace Robust.Shared.GameObjects { var comps = _entTraitArray[CompIdx.ArrayIndex()]; DebugTools.Assert(comps != null, $"Unknown component: {typeof(TComp1).Name}"); - return new EntityQuery(comps, _resolveSawmill); + return new EntityQuery(this, comps); } public EntityQuery GetEntityQuery(Type type) { var comps = _entTraitDict[type]; DebugTools.Assert(comps != null, $"Unknown component: {type.Name}"); - return new EntityQuery(comps, _resolveSawmill); + return new EntityQuery(this, comps); } /// @@ -1789,13 +1789,13 @@ namespace Robust.Shared.GameObjects /// EntityManager.GetEntityQuery() public readonly struct EntityQuery where TComp1 : IComponent { + private readonly EntityManager _entMan; private readonly Dictionary _traitDict; - private readonly ISawmill _sawmill; - public EntityQuery(Dictionary traitDict, ISawmill sawmill) + internal EntityQuery(EntityManager entMan, Dictionary traitDict) { + _entMan = entMan; _traitDict = traitDict; - _sawmill = sawmill; } /// @@ -1947,9 +1947,7 @@ namespace Robust.Shared.GameObjects } if (logMissing) - { - _sawmill.Error($"Can't resolve \"{typeof(TComp1)}\" on entity {uid}!\n{Environment.StackTrace}"); - } + _entMan.ResolveSawmill.Error($"Can't resolve \"{typeof(TComp1)}\" on entity {_entMan.ToPrettyString(uid)}!\n{Environment.StackTrace}"); return false; } @@ -2068,7 +2066,7 @@ namespace Robust.Shared.GameObjects } if (logMissing) - _sawmill.Error($"Can't resolve \"{typeof(TComp1)}\" on entity {uid}!\n{new StackTrace(1, true)}"); + _entMan.ResolveSawmill.Error($"Can't resolve \"{typeof(TComp1)}\" on entity {_entMan.ToPrettyString(uid)}!\n{new StackTrace(1, true)}"); return false; } diff --git a/Robust.Shared/GameObjects/EntityManager.cs b/Robust.Shared/GameObjects/EntityManager.cs index 718e4bf48..349e648fc 100644 --- a/Robust.Shared/GameObjects/EntityManager.cs +++ b/Robust.Shared/GameObjects/EntityManager.cs @@ -118,7 +118,7 @@ namespace Robust.Shared.GameObjects private SharedMapSystem _mapSystem = default!; private ISawmill _sawmill = default!; - private ISawmill _resolveSawmill = default!; + internal ISawmill ResolveSawmill = default!; public bool Started { get; protected set; } @@ -149,7 +149,7 @@ namespace Robust.Shared.GameObjects _xformReg = _componentFactory.GetRegistration(typeof(TransformComponent)); _xformName = _xformReg.Name; _sawmill = LogManager.GetSawmill("entity"); - _resolveSawmill = LogManager.GetSawmill("resolve"); + ResolveSawmill = LogManager.GetSawmill("resolve"); #if DEBUG _mainThreadId = Environment.CurrentManagedThreadId;