Improves the JobSpecial system. (#4626)

* Improves the JobSpecial system.

* clean up code
This commit is contained in:
Vera Aguilera Puerto
2021-09-16 15:17:19 +02:00
committed by GitHub
parent 4fffb3c582
commit 078a62762f
11 changed files with 79 additions and 84 deletions

View File

@@ -0,0 +1,26 @@
using Content.Server.Interaction.Components;
using Content.Shared.Roles;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Jobs
{
[UsedImplicitly]
public sealed class AddComponentSpecial : JobSpecial
{
// TODO: Type serializer that ensures the component exists.
[DataField("component", required:true)]
public string Component { get; } = string.Empty;
public override void AfterEquip(IEntity mob)
{
// Yes, this will throw if your component is invalid.
var component = (Component)IoCManager.Resolve<IComponentFactory>().GetComponent(Component);
component.Owner = mob;
IoCManager.Resolve<IComponentManager>().AddComponent(mob, component);
}
}
}