Re-organize all projects (#4166)
This commit is contained in:
34
Content.Server/Access/Components/PresetIdCardComponent.cs
Normal file
34
Content.Server/Access/Components/PresetIdCardComponent.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
#nullable enable
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Access.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class PresetIdCardComponent : Component, IMapInit
|
||||
{
|
||||
public override string Name => "PresetIdCard";
|
||||
|
||||
[DataField("job")]
|
||||
private string? _jobName;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user