diff --git a/Robust.Server/ViewVariables/Traits/ViewVariablesTraitEntity.cs b/Robust.Server/ViewVariables/Traits/ViewVariablesTraitEntity.cs index 3e7e457b5..726f10cec 100644 --- a/Robust.Server/ViewVariables/Traits/ViewVariablesTraitEntity.cs +++ b/Robust.Server/ViewVariables/Traits/ViewVariablesTraitEntity.cs @@ -20,6 +20,7 @@ namespace Robust.Server.ViewVariables.Traits public override ViewVariablesBlob? DataRequest(ViewVariablesRequest viewVariablesRequest) { var entMan = IoCManager.Resolve(); + var compFactory = IoCManager.Resolve(); if (viewVariablesRequest is ViewVariablesRequestMembers) { @@ -38,7 +39,7 @@ namespace Robust.Server.ViewVariables.Traits { var type = component.GetType(); list.Add(new ViewVariablesBlobEntityComponents.Entry - {Stringified = PrettyPrint.PrintUserFacingTypeShort(type, 2), FullName = type.FullName, ComponentName = component.Name}); + {Stringified = PrettyPrint.PrintUserFacingTypeShort(type, 2), FullName = type.FullName, ComponentName = compFactory.GetComponentName(type)}); } return new ViewVariablesBlobEntityComponents diff --git a/Robust.Shared/GameObjects/Component.cs b/Robust.Shared/GameObjects/Component.cs index 8a2fcfb66..1792c568b 100644 --- a/Robust.Shared/GameObjects/Component.cs +++ b/Robust.Shared/GameObjects/Component.cs @@ -1,8 +1,6 @@ using System; using Robust.Shared.GameStates; using Robust.Shared.IoC; -using Robust.Shared.Network; -using Robust.Shared.Players; using Robust.Shared.Reflection; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Timing; @@ -16,18 +14,13 @@ namespace Robust.Shared.GameObjects [ImplicitDataDefinitionForInheritors] public abstract class Component : IComponent { - /// - [ViewVariables(VVAccess.ReadOnly)] - [Obsolete("Resolve IComponentFactory and call GetComponentName instead")] - public virtual string Name => IoCManager.Resolve().GetComponentName(GetType()); - - /// [DataField("netsync")] [ViewVariables(VVAccess.ReadWrite)] public bool _netSync { get; set; } = true; internal bool Networked = true; + /// public bool NetSyncEnabled { get => Networked && _netSync; @@ -247,7 +240,7 @@ namespace Robust.Shared.GameObjects /// /// The life stages of an ECS component. /// - public enum ComponentLifeStage + public enum ComponentLifeStage : byte { /// /// The component has just been allocated. diff --git a/Robust.Shared/GameObjects/ComponentFactory.cs b/Robust.Shared/GameObjects/ComponentFactory.cs index 47147425b..fc2fabab3 100644 --- a/Robust.Shared/GameObjects/ComponentFactory.cs +++ b/Robust.Shared/GameObjects/ComponentFactory.cs @@ -136,15 +136,6 @@ namespace Robust.Shared.GameObjects static string CalculateComponentName(Type type) { - // Backward compatible fallback -#pragma warning disable CS0618 - if (type.GetProperty(nameof(Component.Name))!.DeclaringType != typeof(Component)) -#pragma warning restore CS0618 - { - var instance = (IComponent) Activator.CreateInstance(type)!; - return instance.Name; - } - // Attributes can use any name they want, they are for bypassing the automatic names // If a parent class has this attribute, a child class will use the same name, unless it also uses this attribute if (Attribute.GetCustomAttribute(type, typeof(ComponentProtoNameAttribute)) is ComponentProtoNameAttribute attribute) diff --git a/Robust.Shared/GameObjects/IComponent.cs b/Robust.Shared/GameObjects/IComponent.cs index 4d9c5bc0d..a314310cd 100644 --- a/Robust.Shared/GameObjects/IComponent.cs +++ b/Robust.Shared/GameObjects/IComponent.cs @@ -13,12 +13,6 @@ namespace Robust.Shared.GameObjects /// public interface IComponent { - /// - /// Name that this component is represented with in prototypes. - /// - /// - string Name { get; } - /// /// The current lifetime stage of this component. You can use this to check /// if the component is initialized or being deleted. diff --git a/Robust.UnitTesting/Shared/GameObjects/EntityManager_Components_Tests.cs b/Robust.UnitTesting/Shared/GameObjects/EntityManager_Components_Tests.cs index 01f1fe793..8bf7b04ce 100644 --- a/Robust.UnitTesting/Shared/GameObjects/EntityManager_Components_Tests.cs +++ b/Robust.UnitTesting/Shared/GameObjects/EntityManager_Components_Tests.cs @@ -265,6 +265,7 @@ namespace Robust.UnitTesting.Shared.GameObjects // Arrange var sim = SimulationFactory(); var entMan = sim.Resolve(); + var fac = sim.Resolve(); var entity = entMan.SpawnEntity(null, DefaultCoords); var component = IoCManager.Resolve().AddComponent(entity); @@ -272,7 +273,7 @@ namespace Robust.UnitTesting.Shared.GameObjects var result = entMan.GetComponents(entity); // Assert - var list = result.Where(c=>c.Name == "Dummy").ToList(); + var list = result.Where(c=>fac.GetComponentName(c.GetType()) == "Dummy").ToList(); Assert.That(list.Count, Is.EqualTo(1)); Assert.That(list[0], Is.EqualTo(component)); }