Files
tbd-station-14/Content.Server/GameObjects/Components/Access/PresetIdCardComponent.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

42 lines
1.1 KiB
C#

#nullable enable
using Content.Shared.Roles;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Access
{
[RegisterComponent]
public class PresetIdCardComponent : Component, IMapInit
{
public override string Name => "PresetIdCard";
private string? _jobName;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _jobName, "job", null);
}
void IMapInit.MapInit()
{
if (_jobName == null)
{
return;
}
var prototypes = IoCManager.Resolve<IPrototypeManager>();
var job = prototypes.Index<JobPrototype>(_jobName);
var access = Owner.GetComponent<AccessComponent>();
var idCard = Owner.GetComponent<IdCardComponent>();
access.SetTags(job.Access);
idCard.JobTitle = job.Name;
}
}
}