Allow non-humanoid roles (#9604)

This commit is contained in:
Rane
2022-07-10 21:10:03 -04:00
committed by GitHub
parent e57294bd78
commit cfe39123a7
3 changed files with 29 additions and 3 deletions

View File

@@ -17,6 +17,9 @@ namespace Content.Server.Roles
[ViewVariables] [ViewVariables]
public string? StartingGear => Prototype.StartingGear; public string? StartingGear => Prototype.StartingGear;
[ViewVariables]
public string? JobEntity => Prototype.JobEntity;
[ViewVariables] [ViewVariables]
public bool CanBeAntag; public bool CanBeAntag;

View File

@@ -6,7 +6,7 @@ using Content.Server.Hands.Systems;
using Content.Server.PDA; using Content.Server.PDA;
using Content.Server.Roles; using Content.Server.Roles;
using Content.Server.Station.Components; using Content.Server.Station.Components;
using Content.Shared.Access.Components; using Content.Server.Mind.Commands;
using Content.Shared.Access.Systems; using Content.Shared.Access.Systems;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.Inventory; using Content.Shared.Inventory;
@@ -20,6 +20,7 @@ using Robust.Shared.Map;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Utility; using Robust.Shared.Utility;
namespace Content.Server.Station.Systems; namespace Content.Server.Station.Systems;
/// <summary> /// <summary>
@@ -92,6 +93,15 @@ public sealed class StationSpawningSystem : EntitySystem
HumanoidCharacterProfile? profile, HumanoidCharacterProfile? profile,
EntityUid? station) EntityUid? station)
{ {
// If we're not spawning a humanoid, we're gonna exit early without doing all the humanoid stuff.
if (job?.JobEntity != null)
{
var jobEntity = EntityManager.SpawnEntity(job.JobEntity, coordinates);
MakeSentientCommand.MakeSentient(jobEntity, EntityManager);
DoJobSpecials(job, jobEntity);
return jobEntity;
}
var entity = EntityManager.SpawnEntity( var entity = EntityManager.SpawnEntity(
_prototypeManager.Index<SpeciesPrototype>(profile?.Species ?? SpeciesManager.DefaultSpecies).Prototype, _prototypeManager.Index<SpeciesPrototype>(profile?.Species ?? SpeciesManager.DefaultSpecies).Prototype,
coordinates); coordinates);
@@ -114,12 +124,17 @@ public sealed class StationSpawningSystem : EntitySystem
} }
} }
DoJobSpecials(job, entity);
return entity;
}
private void DoJobSpecials(Job? job, EntityUid entity)
{
foreach (var jobSpecial in job?.Prototype.Special ?? Array.Empty<JobSpecial>()) foreach (var jobSpecial in job?.Prototype.Special ?? Array.Empty<JobSpecial>())
{ {
jobSpecial.AfterEquip(entity); jobSpecial.AfterEquip(entity);
} }
return entity;
} }
/// <summary> /// <summary>

View File

@@ -51,6 +51,14 @@ namespace Content.Shared.Roles
[DataField("startingGear", customTypeSerializer: typeof(PrototypeIdSerializer<StartingGearPrototype>))] [DataField("startingGear", customTypeSerializer: typeof(PrototypeIdSerializer<StartingGearPrototype>))]
public string? StartingGear { get; private set; } public string? StartingGear { get; private set; }
/// <summary>
/// Use this to spawn in as a non-humanoid (borg, test subject, etc.)
/// Starting gear will be ignored.
/// If you want to just add special attributes to a humanoid, use AddComponentSpecial instead.
/// </summary>
[DataField("jobEntity", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? JobEntity = null;
[DataField("icon")] public string Icon { get; } = string.Empty; [DataField("icon")] public string Icon { get; } = string.Empty;
[DataField("special", serverOnly:true)] [DataField("special", serverOnly:true)]