diff --git a/Content.Client/Body/UI/BodyScannerDisplay.cs b/Content.Client/Body/UI/BodyScannerDisplay.cs index 0bfd30f3de..75c7a67b6d 100644 --- a/Content.Client/Body/UI/BodyScannerDisplay.cs +++ b/Content.Client/Body/UI/BodyScannerDisplay.cs @@ -109,11 +109,12 @@ namespace Content.Client.Body.UI _bodyPartsList.Clear(); var bodySystem = IoCManager.Resolve().GetEntitySystem(); + var factory = IoCManager.Resolve(); var i = 0; foreach (var part in bodySystem.GetBodyChildren(_currentEntity)) { _bodyPartsList[i++] = part.Component.ParentSlot!; - BodyPartList.AddItem(Loc.GetString(part.Component.Name)); + BodyPartList.AddItem(Loc.GetString(factory.GetComponentName(part.Component.GetType()))); } } diff --git a/Content.Server/Administration/Commands/RemoveExtraComponents.cs b/Content.Server/Administration/Commands/RemoveExtraComponents.cs index 5d3a981b63..c630f55488 100644 --- a/Content.Server/Administration/Commands/RemoveExtraComponents.cs +++ b/Content.Server/Administration/Commands/RemoveExtraComponents.cs @@ -15,6 +15,7 @@ namespace Content.Server.Administration.Commands var id = args.Length == 0 ? null : string.Join(" ", args); var entityManager = IoCManager.Resolve(); var prototypeManager = IoCManager.Resolve(); + var fac = IoCManager.Resolve(); EntityPrototype? prototype = null; var checkPrototype = !string.IsNullOrEmpty(id); @@ -40,7 +41,7 @@ namespace Content.Server.Administration.Commands foreach (var component in entityManager.GetComponents(entity)) { - if (metaData.EntityPrototype.Components.ContainsKey(component.Name)) + if (metaData.EntityPrototype.Components.ContainsKey(fac.GetComponentName(component.GetType()))) continue; entityManager.RemoveComponent(entity, component); diff --git a/Content.Server/Body/Commands/DestroyMechanismCommand.cs b/Content.Server/Body/Commands/DestroyMechanismCommand.cs index 8780797d9b..57cd2452ab 100644 --- a/Content.Server/Body/Commands/DestroyMechanismCommand.cs +++ b/Content.Server/Body/Commands/DestroyMechanismCommand.cs @@ -37,6 +37,8 @@ namespace Content.Server.Body.Commands } var entityManager = IoCManager.Resolve(); + var fac = IoCManager.Resolve(); + if (!entityManager.TryGetComponent(attached, out BodyComponent? body)) { var random = IoCManager.Resolve(); @@ -51,7 +53,7 @@ namespace Content.Server.Body.Commands foreach (var organ in bodySystem.GetBodyOrgans(body.Owner, body)) { - if (organ.Component.Name.ToLowerInvariant() == mechanismName) + if (fac.GetComponentName(organ.Component.GetType()).ToLowerInvariant() == mechanismName) { bodySystem.DeleteOrgan(organ.Id, organ.Component); shell.WriteLine($"Mechanism with name {mechanismName} has been destroyed."); diff --git a/Content.Server/Cabinet/ItemCabinetSystem.cs b/Content.Server/Cabinet/ItemCabinetSystem.cs index 39165021bb..c00b8850d7 100644 --- a/Content.Server/Cabinet/ItemCabinetSystem.cs +++ b/Content.Server/Cabinet/ItemCabinetSystem.cs @@ -12,6 +12,7 @@ namespace Content.Server.Cabinet { public sealed class ItemCabinetSystem : EntitySystem { + [Dependency] private readonly IComponentFactory _factory = default!; [Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!; public override void Initialize() @@ -33,7 +34,7 @@ namespace Content.Server.Cabinet private void OnComponentInit(EntityUid uid, ItemCabinetComponent cabinet, ComponentInit args) { - _itemSlotsSystem.AddItemSlot(uid, cabinet.Name, cabinet.CabinetSlot); + _itemSlotsSystem.AddItemSlot(uid, _factory.GetComponentName(cabinet.GetType()), cabinet.CabinetSlot); } private void OnComponentRemove(EntityUid uid, ItemCabinetComponent cabinet, ComponentRemove args) { diff --git a/Content.Server/Construction/ConstructionSystem.Initial.cs b/Content.Server/Construction/ConstructionSystem.Initial.cs index 2b950902df..3510620fc5 100644 --- a/Content.Server/Construction/ConstructionSystem.Initial.cs +++ b/Content.Server/Construction/ConstructionSystem.Initial.cs @@ -23,7 +23,7 @@ namespace Content.Server.Construction { public sealed partial class ConstructionSystem { - + [Dependency] private readonly IComponentFactory _factory = default!; [Dependency] private readonly InventorySystem _inventorySystem = default!; [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!; @@ -192,7 +192,7 @@ namespace Content.Server.Construction case ArbitraryInsertConstructionGraphStep arbitraryStep: foreach (var entity in EnumerateNearby(user)) { - if (!arbitraryStep.EntityValid(entity, EntityManager)) + if (!arbitraryStep.EntityValid(entity, EntityManager, _factory)) continue; if (string.IsNullOrEmpty(arbitraryStep.Store)) @@ -455,7 +455,7 @@ namespace Content.Server.Construction switch (step) { case EntityInsertConstructionGraphStep entityInsert: - if (entityInsert.EntityValid(holding, EntityManager)) + if (entityInsert.EntityValid(holding, EntityManager, _factory)) valid = true; break; case ToolConstructionGraphStep _: diff --git a/Content.Server/Construction/ConstructionSystem.Interactions.cs b/Content.Server/Construction/ConstructionSystem.Interactions.cs index 1875ea2365..e73d7bb6e9 100644 --- a/Content.Server/Construction/ConstructionSystem.Interactions.cs +++ b/Content.Server/Construction/ConstructionSystem.Interactions.cs @@ -285,7 +285,7 @@ namespace Content.Server.Construction // Since many things inherit this step, we delegate the "is this entity valid?" logic to them. // While this is very OOP and I find it icky, I must admit that it simplifies the code here a lot. - if(!insertStep.EntityValid(insert, EntityManager)) + if(!insertStep.EntityValid(insert, EntityManager, _factory)) return HandleResult.False; // If we're only testing whether this step would be handled by the given event, then we're done. diff --git a/Content.Shared/Construction/Steps/ComponentConstructionGraphStep.cs b/Content.Shared/Construction/Steps/ComponentConstructionGraphStep.cs index cd707ec5c6..8908eac5aa 100644 --- a/Content.Shared/Construction/Steps/ComponentConstructionGraphStep.cs +++ b/Content.Shared/Construction/Steps/ComponentConstructionGraphStep.cs @@ -7,11 +7,11 @@ namespace Content.Shared.Construction.Steps { [DataField("component")] public string Component { get; } = string.Empty; - public override bool EntityValid(EntityUid uid, IEntityManager entityManager) + public override bool EntityValid(EntityUid uid, IEntityManager entityManager, IComponentFactory compFactory) { foreach (var component in entityManager.GetComponents(uid)) { - if (component.Name == Component) + if (compFactory.GetComponentName(component.GetType()) == Component) return true; } diff --git a/Content.Shared/Construction/Steps/EntityInsertConstructionGraphStep.cs b/Content.Shared/Construction/Steps/EntityInsertConstructionGraphStep.cs index 0ce716ce86..7bd14ee00b 100644 --- a/Content.Shared/Construction/Steps/EntityInsertConstructionGraphStep.cs +++ b/Content.Shared/Construction/Steps/EntityInsertConstructionGraphStep.cs @@ -5,6 +5,6 @@ { [DataField("store")] public string Store { get; } = string.Empty; - public abstract bool EntityValid(EntityUid uid, IEntityManager entityManager); + public abstract bool EntityValid(EntityUid uid, IEntityManager entityManager, IComponentFactory compFactory); } } diff --git a/Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs b/Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs index 98b00f616f..93f81fd91c 100644 --- a/Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs +++ b/Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs @@ -23,7 +23,7 @@ namespace Content.Shared.Construction.Steps examinedEvent.Message.AddMarkup(Loc.GetString("construction-insert-material-entity", ("amount", Amount), ("materialName", material.Name))); } - public override bool EntityValid(EntityUid uid, IEntityManager entityManager) + public override bool EntityValid(EntityUid uid, IEntityManager entityManager, IComponentFactory compFactory) { return entityManager.TryGetComponent(uid, out StackComponent? stack) && stack.StackTypeId == MaterialPrototypeId && stack.Count >= Amount; } diff --git a/Content.Shared/Construction/Steps/MultipleTagsConstructionGraphStep.cs b/Content.Shared/Construction/Steps/MultipleTagsConstructionGraphStep.cs index 59b371000d..083bdd0c40 100644 --- a/Content.Shared/Construction/Steps/MultipleTagsConstructionGraphStep.cs +++ b/Content.Shared/Construction/Steps/MultipleTagsConstructionGraphStep.cs @@ -15,7 +15,7 @@ namespace Content.Shared.Construction.Steps return list == null || list.Count == 0; } - public override bool EntityValid(EntityUid uid, IEntityManager entityManager) + public override bool EntityValid(EntityUid uid, IEntityManager entityManager, IComponentFactory compFactory) { // This step can only happen if either list has tags. if (IsNullOrEmpty(_allTags) && IsNullOrEmpty(_anyTags)) diff --git a/Content.Shared/Construction/Steps/TagConstructionGraphStep.cs b/Content.Shared/Construction/Steps/TagConstructionGraphStep.cs index 24e73fa114..db87e6adff 100644 --- a/Content.Shared/Construction/Steps/TagConstructionGraphStep.cs +++ b/Content.Shared/Construction/Steps/TagConstructionGraphStep.cs @@ -8,7 +8,7 @@ namespace Content.Shared.Construction.Steps [DataField("tag")] private string? _tag; - public override bool EntityValid(EntityUid uid, IEntityManager entityManager) + public override bool EntityValid(EntityUid uid, IEntityManager entityManager, IComponentFactory compFactory) { var tagSystem = entityManager.EntitySysManager.GetEntitySystem(); return !string.IsNullOrEmpty(_tag) && tagSystem.HasTag(uid, _tag);