Remove last component.Name calls (#13593)
This commit is contained in:
@@ -109,11 +109,12 @@ namespace Content.Client.Body.UI
|
|||||||
_bodyPartsList.Clear();
|
_bodyPartsList.Clear();
|
||||||
|
|
||||||
var bodySystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SharedBodySystem>();
|
var bodySystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SharedBodySystem>();
|
||||||
|
var factory = IoCManager.Resolve<IComponentFactory>();
|
||||||
var i = 0;
|
var i = 0;
|
||||||
foreach (var part in bodySystem.GetBodyChildren(_currentEntity))
|
foreach (var part in bodySystem.GetBodyChildren(_currentEntity))
|
||||||
{
|
{
|
||||||
_bodyPartsList[i++] = part.Component.ParentSlot!;
|
_bodyPartsList[i++] = part.Component.ParentSlot!;
|
||||||
BodyPartList.AddItem(Loc.GetString(part.Component.Name));
|
BodyPartList.AddItem(Loc.GetString(factory.GetComponentName(part.Component.GetType())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace Content.Server.Administration.Commands
|
|||||||
var id = args.Length == 0 ? null : string.Join(" ", args);
|
var id = args.Length == 0 ? null : string.Join(" ", args);
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||||
|
var fac = IoCManager.Resolve<IComponentFactory>();
|
||||||
|
|
||||||
EntityPrototype? prototype = null;
|
EntityPrototype? prototype = null;
|
||||||
var checkPrototype = !string.IsNullOrEmpty(id);
|
var checkPrototype = !string.IsNullOrEmpty(id);
|
||||||
@@ -40,7 +41,7 @@ namespace Content.Server.Administration.Commands
|
|||||||
|
|
||||||
foreach (var component in entityManager.GetComponents(entity))
|
foreach (var component in entityManager.GetComponents(entity))
|
||||||
{
|
{
|
||||||
if (metaData.EntityPrototype.Components.ContainsKey(component.Name))
|
if (metaData.EntityPrototype.Components.ContainsKey(fac.GetComponentName(component.GetType())))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
entityManager.RemoveComponent(entity, component);
|
entityManager.RemoveComponent(entity, component);
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ namespace Content.Server.Body.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
|
var fac = IoCManager.Resolve<IComponentFactory>();
|
||||||
|
|
||||||
if (!entityManager.TryGetComponent(attached, out BodyComponent? body))
|
if (!entityManager.TryGetComponent(attached, out BodyComponent? body))
|
||||||
{
|
{
|
||||||
var random = IoCManager.Resolve<IRobustRandom>();
|
var random = IoCManager.Resolve<IRobustRandom>();
|
||||||
@@ -51,7 +53,7 @@ namespace Content.Server.Body.Commands
|
|||||||
|
|
||||||
foreach (var organ in bodySystem.GetBodyOrgans(body.Owner, body))
|
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);
|
bodySystem.DeleteOrgan(organ.Id, organ.Component);
|
||||||
shell.WriteLine($"Mechanism with name {mechanismName} has been destroyed.");
|
shell.WriteLine($"Mechanism with name {mechanismName} has been destroyed.");
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace Content.Server.Cabinet
|
|||||||
{
|
{
|
||||||
public sealed class ItemCabinetSystem : EntitySystem
|
public sealed class ItemCabinetSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IComponentFactory _factory = default!;
|
||||||
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
|
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -33,7 +34,7 @@ namespace Content.Server.Cabinet
|
|||||||
|
|
||||||
private void OnComponentInit(EntityUid uid, ItemCabinetComponent cabinet, ComponentInit args)
|
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)
|
private void OnComponentRemove(EntityUid uid, ItemCabinetComponent cabinet, ComponentRemove args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace Content.Server.Construction
|
|||||||
{
|
{
|
||||||
public sealed partial class ConstructionSystem
|
public sealed partial class ConstructionSystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IComponentFactory _factory = default!;
|
||||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
||||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||||
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
||||||
@@ -192,7 +192,7 @@ namespace Content.Server.Construction
|
|||||||
case ArbitraryInsertConstructionGraphStep arbitraryStep:
|
case ArbitraryInsertConstructionGraphStep arbitraryStep:
|
||||||
foreach (var entity in EnumerateNearby(user))
|
foreach (var entity in EnumerateNearby(user))
|
||||||
{
|
{
|
||||||
if (!arbitraryStep.EntityValid(entity, EntityManager))
|
if (!arbitraryStep.EntityValid(entity, EntityManager, _factory))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(arbitraryStep.Store))
|
if (string.IsNullOrEmpty(arbitraryStep.Store))
|
||||||
@@ -455,7 +455,7 @@ namespace Content.Server.Construction
|
|||||||
switch (step)
|
switch (step)
|
||||||
{
|
{
|
||||||
case EntityInsertConstructionGraphStep entityInsert:
|
case EntityInsertConstructionGraphStep entityInsert:
|
||||||
if (entityInsert.EntityValid(holding, EntityManager))
|
if (entityInsert.EntityValid(holding, EntityManager, _factory))
|
||||||
valid = true;
|
valid = true;
|
||||||
break;
|
break;
|
||||||
case ToolConstructionGraphStep _:
|
case ToolConstructionGraphStep _:
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ namespace Content.Server.Construction
|
|||||||
|
|
||||||
// Since many things inherit this step, we delegate the "is this entity valid?" logic to them.
|
// 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.
|
// 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;
|
return HandleResult.False;
|
||||||
|
|
||||||
// If we're only testing whether this step would be handled by the given event, then we're done.
|
// If we're only testing whether this step would be handled by the given event, then we're done.
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ namespace Content.Shared.Construction.Steps
|
|||||||
{
|
{
|
||||||
[DataField("component")] public string Component { get; } = string.Empty;
|
[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))
|
foreach (var component in entityManager.GetComponents(uid))
|
||||||
{
|
{
|
||||||
if (component.Name == Component)
|
if (compFactory.GetComponentName(component.GetType()) == Component)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,6 @@
|
|||||||
{
|
{
|
||||||
[DataField("store")] public string Store { get; } = string.Empty;
|
[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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace Content.Shared.Construction.Steps
|
|||||||
examinedEvent.Message.AddMarkup(Loc.GetString("construction-insert-material-entity", ("amount", Amount), ("materialName", material.Name)));
|
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;
|
return entityManager.TryGetComponent(uid, out StackComponent? stack) && stack.StackTypeId == MaterialPrototypeId && stack.Count >= Amount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Content.Shared.Construction.Steps
|
|||||||
return list == null || list.Count == 0;
|
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.
|
// This step can only happen if either list has tags.
|
||||||
if (IsNullOrEmpty(_allTags) && IsNullOrEmpty(_anyTags))
|
if (IsNullOrEmpty(_allTags) && IsNullOrEmpty(_anyTags))
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Content.Shared.Construction.Steps
|
|||||||
[DataField("tag")]
|
[DataField("tag")]
|
||||||
private string? _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<TagSystem>();
|
var tagSystem = entityManager.EntitySysManager.GetEntitySystem<TagSystem>();
|
||||||
return !string.IsNullOrEmpty(_tag) && tagSystem.HasTag(uid, _tag);
|
return !string.IsNullOrEmpty(_tag) && tagSystem.HasTag(uid, _tag);
|
||||||
|
|||||||
Reference in New Issue
Block a user