random loadout support (#11027)

This commit is contained in:
Nemanja
2022-09-16 10:03:45 -04:00
committed by GitHub
parent 2003a58138
commit dc1d8ec9b4
5 changed files with 26 additions and 20 deletions

View File

@@ -2,6 +2,7 @@ using Content.Server.Clothing.Components;
using Content.Server.Station.Systems;
using Content.Shared.Roles;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server.Clothing
{
@@ -12,6 +13,7 @@ namespace Content.Server.Clothing
{
[Dependency] private readonly StationSpawningSystem _station = default!;
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
@@ -22,10 +24,10 @@ namespace Content.Server.Clothing
private void OnStartup(EntityUid uid, LoadoutComponent component, ComponentStartup args)
{
if (component.Prototype == string.Empty)
if (component.Prototypes == null)
return;
var proto = _protoMan.Index<StartingGearPrototype>(component.Prototype);
var proto = _protoMan.Index<StartingGearPrototype>(_random.Pick(component.Prototypes));
_station.EquipStartingGear(uid, proto, null);
}
}