CompFactory updates (#37559)

This commit is contained in:
metalgearsloth
2025-05-20 15:08:55 +10:00
committed by GitHub
parent bc0139f961
commit 0d4f9640b5
38 changed files with 70 additions and 102 deletions

View File

@@ -5,8 +5,6 @@ namespace Content.Server.Speech.EntitySystems;
public sealed class AddAccentClothingSystem : EntitySystem
{
[Dependency] private readonly IComponentFactory _componentFactory = default!;
public override void Initialize()
{
base.Initialize();
@@ -19,12 +17,12 @@ public sealed class AddAccentClothingSystem : EntitySystem
private void OnGotEquipped(EntityUid uid, AddAccentClothingComponent component, ref ClothingGotEquippedEvent args)
{
// does the user already has this accent?
var componentType = _componentFactory.GetRegistration(component.Accent).Type;
var componentType = Factory.GetRegistration(component.Accent).Type;
if (HasComp(args.Wearer, componentType))
return;
// add accent to the user
var accentComponent = (Component) _componentFactory.GetComponent(componentType);
var accentComponent = (Component) Factory.GetComponent(componentType);
AddComp(args.Wearer, accentComponent);
// snowflake case for replacement accent
@@ -40,11 +38,8 @@ public sealed class AddAccentClothingSystem : EntitySystem
return;
// try to remove accent
var componentType = _componentFactory.GetRegistration(component.Accent).Type;
if (EntityManager.HasComponent(args.Wearer, componentType))
{
EntityManager.RemoveComponent(args.Wearer, componentType);
}
var componentType = Factory.GetRegistration(component.Accent).Type;
EntityManager.RemoveComponent(args.Wearer, componentType);
component.IsActive = false;
}