Allow non-humanoid roles (#9604)
This commit is contained in:
@@ -17,6 +17,9 @@ namespace Content.Server.Roles
|
||||
[ViewVariables]
|
||||
public string? StartingGear => Prototype.StartingGear;
|
||||
|
||||
[ViewVariables]
|
||||
public string? JobEntity => Prototype.JobEntity;
|
||||
|
||||
[ViewVariables]
|
||||
public bool CanBeAntag;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using Content.Server.Hands.Systems;
|
||||
using Content.Server.PDA;
|
||||
using Content.Server.Roles;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Server.Mind.Commands;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Inventory;
|
||||
@@ -20,6 +20,7 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
|
||||
namespace Content.Server.Station.Systems;
|
||||
|
||||
/// <summary>
|
||||
@@ -92,6 +93,15 @@ public sealed class StationSpawningSystem : EntitySystem
|
||||
HumanoidCharacterProfile? profile,
|
||||
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(
|
||||
_prototypeManager.Index<SpeciesPrototype>(profile?.Species ?? SpeciesManager.DefaultSpecies).Prototype,
|
||||
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>())
|
||||
{
|
||||
jobSpecial.AfterEquip(entity);
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -51,6 +51,14 @@ namespace Content.Shared.Roles
|
||||
[DataField("startingGear", customTypeSerializer: typeof(PrototypeIdSerializer<StartingGearPrototype>))]
|
||||
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("special", serverOnly:true)]
|
||||
|
||||
Reference in New Issue
Block a user