2022-05-29 18:14:47 -04:00
|
|
|
using Content.Server.Clothing.Components;
|
|
|
|
|
using Content.Server.Station.Systems;
|
|
|
|
|
using Content.Shared.Roles;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
2022-09-16 10:03:45 -04:00
|
|
|
using Robust.Shared.Random;
|
2022-05-29 18:14:47 -04:00
|
|
|
|
|
|
|
|
namespace Content.Server.Clothing
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Assigns a loadout to an entity based on the startingGear prototype
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class LoadoutSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly StationSpawningSystem _station = default!;
|
|
|
|
|
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
2022-09-16 10:03:45 -04:00
|
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
2022-05-29 18:14:47 -04:00
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<LoadoutComponent, ComponentStartup>(OnStartup);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnStartup(EntityUid uid, LoadoutComponent component, ComponentStartup args)
|
|
|
|
|
{
|
2022-09-16 10:03:45 -04:00
|
|
|
if (component.Prototypes == null)
|
2022-05-29 18:14:47 -04:00
|
|
|
return;
|
|
|
|
|
|
2022-09-16 10:03:45 -04:00
|
|
|
var proto = _protoMan.Index<StartingGearPrototype>(_random.Pick(component.Prototypes));
|
2022-05-29 18:14:47 -04:00
|
|
|
_station.EquipStartingGear(uid, proto, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|