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

@@ -1,12 +1,16 @@
using Content.Shared.Roles; using Content.Shared.Roles;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
namespace Content.Server.Clothing.Components namespace Content.Server.Clothing.Components
{ {
[RegisterComponent] [RegisterComponent]
public sealed class LoadoutComponent : Component public sealed class LoadoutComponent : Component
{ {
[DataField("prototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<StartingGearPrototype>))] /// <summary>
public string Prototype = string.Empty; /// A list of starting gears, of which one will be given.
/// All elements are weighted the same in the list.
/// </summary>
[DataField("prototypes", required: true, customTypeSerializer: typeof(PrototypeIdListSerializer<StartingGearPrototype>))]
public List<string>? Prototypes;
} }
} }

View File

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

View File

@@ -7,4 +7,4 @@
suffix: AI suffix: AI
components: components:
- type: InputMover - type: InputMover
- type: MobMover - type: MobMover

View File

@@ -7,7 +7,7 @@
- type: InputMover - type: InputMover
- type: MobMover - type: MobMover
- type: Loadout - type: Loadout
prototype: PassengerGear prototypes: [PassengerGear]
- type: Faction - type: Faction
factions: factions:
- NanoTrasen - NanoTrasen
@@ -34,7 +34,7 @@
components: components:
- type: RandomHumanoidAppearance - type: RandomHumanoidAppearance
- type: Loadout - type: Loadout
prototype: CBURNGear prototypes: [CBURNGear]
- type: GhostTakeoverAvailable - type: GhostTakeoverAvailable
makeSentient: false makeSentient: false
name: CBURN Agent name: CBURN Agent

View File

@@ -46,7 +46,7 @@
name: CentCom official name: CentCom official
description: Inspect the station, jot down performance reviews for heads of staff, bug the Captain. description: Inspect the station, jot down performance reviews for heads of staff, bug the Captain.
- type: Loadout - type: Loadout
prototype: CentcomGear prototypes: [CentcomGear]
- type: RandomHumanoidAppearance - type: RandomHumanoidAppearance
# ERT Leader # ERT Leader
@@ -62,7 +62,7 @@
name: ERT Leader name: ERT Leader
description: Lead a team of specialists to resolve the stations issues. description: Lead a team of specialists to resolve the stations issues.
- type: Loadout - type: Loadout
prototype: ERTLeaderGear prototypes: [ERTLeaderGear]
- type: RandomMetadata - type: RandomMetadata
nameSegments: [NamesFirstMilitaryLeader] nameSegments: [NamesFirstMilitaryLeader]
- type: RandomHumanoidAppearance - type: RandomHumanoidAppearance
@@ -78,7 +78,7 @@
sprite: Markers/jobs.rsi sprite: Markers/jobs.rsi
state: ertleadereva state: ertleadereva
- type: Loadout - type: Loadout
prototype: ERTLeaderGearEVA prototypes: [ERTLeaderGearEVA]
# ERT Engineer # ERT Engineer
- type: entity - type: entity
@@ -93,7 +93,7 @@
name: ERT Engineer name: ERT Engineer
description: Assist with engineering efforts to resolve the stations issues. description: Assist with engineering efforts to resolve the stations issues.
- type: Loadout - type: Loadout
prototype: ERTEngineerGear prototypes: [ERTEngineerGear]
- type: entity - type: entity
name: ERT engineer name: ERT engineer
@@ -105,7 +105,7 @@
sprite: Markers/jobs.rsi sprite: Markers/jobs.rsi
state: ertengineereva state: ertengineereva
- type: Loadout - type: Loadout
prototype: ERTEngineerGearEVA prototypes: [ERTEngineerGearEVA]
# ERT Security # ERT Security
- type: entity - type: entity
@@ -120,7 +120,7 @@
name: ERT Security name: ERT Security
description: Assist with security efforts to resolve the stations issues. description: Assist with security efforts to resolve the stations issues.
- type: Loadout - type: Loadout
prototype: ERTSecurityGear prototypes: [ERTSecurityGear]
- type: entity - type: entity
name: ERT security name: ERT security
@@ -132,7 +132,7 @@
sprite: Markers/jobs.rsi sprite: Markers/jobs.rsi
state: ertsecurityeva state: ertsecurityeva
- type: Loadout - type: Loadout
prototype: ERTSecurityGearEVA prototypes: [ERTSecurityGearEVA]
# ERT Medical # ERT Medical
- type: entity - type: entity
@@ -147,7 +147,7 @@
name: ERT Medic name: ERT Medic
description: Assist with medical efforts to resolve the stations issues. description: Assist with medical efforts to resolve the stations issues.
- type: Loadout - type: Loadout
prototype: ERTMedicalGear prototypes: [ERTMedicalGear]
- type: entity - type: entity
name: ERT medic name: ERT medic
@@ -159,7 +159,7 @@
sprite: Markers/jobs.rsi sprite: Markers/jobs.rsi
state: ertmedicaleva state: ertmedicaleva
- type: Loadout - type: Loadout
prototype: ERTMedicalGearEVA prototypes: [ERTMedicalGearEVA]
# ERT Janitor # ERT Janitor
- type: entity - type: entity
@@ -174,7 +174,7 @@
name: ERT Janitor name: ERT Janitor
description: Assist with custodial efforts to resolve the stations issues. description: Assist with custodial efforts to resolve the stations issues.
- type: Loadout - type: Loadout
prototype: ERTJanitorGear prototypes: [ERTJanitorGear]
- type: entity - type: entity
name: ERT janitor name: ERT janitor
@@ -186,7 +186,7 @@
sprite: Markers/jobs.rsi sprite: Markers/jobs.rsi
state: ertjanitoreva state: ertjanitoreva
- type: Loadout - type: Loadout
prototype: ERTJanitorGearEVA prototypes: [ERTJanitorGearEVA]
#Syndie #Syndie
- type: entity - type: entity
@@ -195,7 +195,7 @@
name: Syndicate Agent name: Syndicate Agent
components: components:
- type: Loadout - type: Loadout
prototype: SyndicateOperativeGearExtremelyBasic prototypes: [SyndicateOperativeGearExtremelyBasic]
- type: RandomMetadata - type: RandomMetadata
nameSegments: [names_death_commando] nameSegments: [names_death_commando]