Fix humanoid appearances for placement manager (#18291)

This commit is contained in:
metalgearsloth
2023-08-05 14:25:47 +10:00
committed by GitHub
parent d58786faf4
commit ead47c541d
16 changed files with 313 additions and 295 deletions

View File

@@ -1,13 +1,7 @@
using Content.Shared.Body.Components;
using Content.Shared.Body.Prototypes;
using Content.Shared.Body.Systems;
using Content.Shared.Body.Systems;
namespace Content.Client.Body.Systems;
public sealed class BodySystem : SharedBodySystem
{
protected override void InitBody(BodyComponent body, BodyPrototype prototype)
{
return;
}
}

View File

@@ -126,7 +126,7 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem
/// This should not be used if the entity is owned by the server. The server will otherwise
/// override this with the appearance data it sends over.
/// </remarks>
public void LoadProfile(EntityUid uid, HumanoidCharacterProfile profile, HumanoidAppearanceComponent? humanoid = null)
public override void LoadProfile(EntityUid uid, HumanoidCharacterProfile profile, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid))
{

View File

@@ -0,0 +1,8 @@
using Content.Shared.Station;
namespace Content.Client.Station;
public sealed class StationSpawningSystem : SharedStationSpawningSystem
{
}

View File

@@ -181,22 +181,6 @@ public sealed class BodySystem : SharedBodySystem
return true;
}
protected override void InitBody(BodyComponent body, BodyPrototype prototype)
{
var root = prototype.Slots[prototype.Root];
Containers.EnsureContainer<Container>(body.Owner, BodyContainerId);
if (root.Part == null)
return;
var bodyId = Spawn(root.Part, body.Owner.ToCoordinates());
var partComponent = Comp<BodyPartComponent>(bodyId);
var slot = new BodyPartSlot(root.Part, body.Owner, partComponent.PartType);
body.Root = slot;
partComponent.Body = bodyId;
AttachPart(bodyId, slot, partComponent);
InitPart(partComponent, prototype, prototype.Root);
}
public override HashSet<EntityUid> GibBody(EntityUid? bodyId, bool gibOrgans = false, BodyComponent? body = null, bool deleteItems = false)
{
if (bodyId == null || !Resolve(bodyId.Value, ref body, false))

View File

@@ -1,16 +0,0 @@
using Content.Shared.Roles;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
namespace Content.Server.Clothing.Components
{
[RegisterComponent]
public sealed class LoadoutComponent : Component
{
/// <summary>
/// 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

@@ -1,34 +0,0 @@
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
{
/// <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!;
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<LoadoutComponent, ComponentStartup>(OnStartup);
}
private void OnStartup(EntityUid uid, LoadoutComponent component, ComponentStartup args)
{
if (component.Prototypes == null)
return;
var proto = _protoMan.Index<StartingGearPrototype>(_random.Pick(component.Prototypes));
_station.EquipStartingGear(uid, proto, null);
}
}
}

View File

@@ -1,4 +1,3 @@
using System.Linq;
using Content.Shared.Examine;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
@@ -19,130 +18,21 @@ public sealed partial class HumanoidAppearanceSystem : SharedHumanoidAppearanceS
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HumanoidAppearanceComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<HumanoidAppearanceComponent, HumanoidMarkingModifierMarkingSetMessage>(OnMarkingsSet);
SubscribeLocalEvent<HumanoidAppearanceComponent, HumanoidMarkingModifierBaseLayersSetMessage>(OnBaseLayersSet);
SubscribeLocalEvent<HumanoidAppearanceComponent, GetVerbsEvent<Verb>>(OnVerbsRequest);
SubscribeLocalEvent<HumanoidAppearanceComponent, ExaminedEvent>(OnExamined);
}
private void OnInit(EntityUid uid, HumanoidAppearanceComponent humanoid, ComponentInit args)
{
if (string.IsNullOrEmpty(humanoid.Species))
{
return;
}
if (string.IsNullOrEmpty(humanoid.Initial)
|| !_prototypeManager.TryIndex(humanoid.Initial, out HumanoidProfilePrototype? startingSet))
{
LoadProfile(uid, HumanoidCharacterProfile.DefaultWithSpecies(humanoid.Species), humanoid);
return;
}
// Do this first, because profiles currently do not support custom base layers
foreach (var (layer, info) in startingSet.CustomBaseLayers)
{
humanoid.CustomBaseLayers.Add(layer, info);
}
LoadProfile(uid, startingSet.Profile, humanoid);
}
private void OnExamined(EntityUid uid, HumanoidAppearanceComponent component, ExaminedEvent args)
{
var identity = Identity.Entity(component.Owner, EntityManager);
var identity = Identity.Entity(uid, EntityManager);
var species = GetSpeciesRepresentation(component.Species).ToLower();
var age = GetAgeRepresentation(component.Species, component.Age);
args.PushText(Loc.GetString("humanoid-appearance-component-examine", ("user", identity), ("age", age), ("species", species)));
}
/// <summary>
/// Loads a humanoid character profile directly onto this humanoid mob.
/// </summary>
/// <param name="uid">The mob's entity UID.</param>
/// <param name="profile">The character profile to load.</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void LoadProfile(EntityUid uid, HumanoidCharacterProfile profile, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid))
{
return;
}
SetSpecies(uid, profile.Species, false, humanoid);
SetSex(uid, profile.Sex, false, humanoid);
humanoid.EyeColor = profile.Appearance.EyeColor;
SetSkinColor(uid, profile.Appearance.SkinColor, false);
humanoid.MarkingSet.Clear();
// Add markings that doesn't need coloring. We store them until we add all other markings that doesn't need it.
var markingFColored = new Dictionary<Marking, MarkingPrototype>();
foreach (var marking in profile.Appearance.Markings)
{
if (_markingManager.TryGetMarking(marking, out var prototype))
{
if (!prototype.ForcedColoring)
{
AddMarking(uid, marking.MarkingId, marking.MarkingColors, false);
}
else
{
markingFColored.Add(marking, prototype);
}
}
}
// Hair/facial hair - this may eventually be deprecated.
// We need to ensure hair before applying it or coloring can try depend on markings that can be invalid
var hairColor = _markingManager.MustMatchSkin(profile.Species, HumanoidVisualLayers.Hair, out var hairAlpha, _prototypeManager)
? profile.Appearance.SkinColor.WithAlpha(hairAlpha) : profile.Appearance.HairColor;
var facialHairColor = _markingManager.MustMatchSkin(profile.Species, HumanoidVisualLayers.FacialHair, out var facialHairAlpha, _prototypeManager)
? profile.Appearance.SkinColor.WithAlpha(facialHairAlpha) : profile.Appearance.FacialHairColor;
if (_markingManager.Markings.TryGetValue(profile.Appearance.HairStyleId, out var hairPrototype) &&
_markingManager.CanBeApplied(profile.Species, hairPrototype, _prototypeManager))
{
AddMarking(uid, profile.Appearance.HairStyleId, hairColor, false);
}
if (_markingManager.Markings.TryGetValue(profile.Appearance.FacialHairStyleId, out var facialHairPrototype) &&
_markingManager.CanBeApplied(profile.Species, facialHairPrototype, _prototypeManager))
{
AddMarking(uid, profile.Appearance.FacialHairStyleId, facialHairColor, false);
}
humanoid.MarkingSet.EnsureSpecies(profile.Species, profile.Appearance.SkinColor, _markingManager, _prototypeManager);
// Finally adding marking with forced colors
foreach (var (marking, prototype) in markingFColored)
{
var markingColors = MarkingColoring.GetMarkingLayerColors(
prototype,
profile.Appearance.SkinColor,
profile.Appearance.EyeColor,
humanoid.MarkingSet
);
AddMarking(uid, marking.MarkingId, markingColors, false);
}
EnsureDefaultMarkings(uid, humanoid);
humanoid.Gender = profile.Gender;
if (TryComp<GrammarComponent>(uid, out var grammar))
{
grammar.Gender = profile.Gender;
}
humanoid.Age = profile.Age;
Dirty(humanoid);
}
// this was done enough times that it only made sense to do it here
/// <summary>
@@ -177,64 +67,6 @@ public sealed partial class HumanoidAppearanceSystem : SharedHumanoidAppearanceS
Dirty(targetHumanoid);
}
/// <summary>
/// Adds a marking to this humanoid.
/// </summary>
/// <param name="uid">Humanoid mob's UID</param>
/// <param name="marking">Marking ID to use</param>
/// <param name="color">Color to apply to all marking layers of this marking</param>
/// <param name="sync">Whether to immediately sync this marking or not</param>
/// <param name="forced">If this marking was forced (ignores marking points)</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void AddMarking(EntityUid uid, string marking, Color? color = null, bool sync = true, bool forced = false, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid)
|| !_markingManager.Markings.TryGetValue(marking, out var prototype))
{
return;
}
var markingObject = prototype.AsMarking();
markingObject.Forced = forced;
if (color != null)
{
for (var i = 0; i < prototype.Sprites.Count; i++)
{
markingObject.SetColor(i, color.Value);
}
}
humanoid.MarkingSet.AddBack(prototype.MarkingCategory, markingObject);
if (sync)
Dirty(humanoid);
}
/// <summary>
///
/// </summary>
/// <param name="uid">Humanoid mob's UID</param>
/// <param name="marking">Marking ID to use</param>
/// <param name="colors">Colors to apply against this marking's set of sprites.</param>
/// <param name="sync">Whether to immediately sync this marking or not</param>
/// <param name="forced">If this marking was forced (ignores marking points)</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void AddMarking(EntityUid uid, string marking, IReadOnlyList<Color> colors, bool sync = true, bool forced = false, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid)
|| !_markingManager.Markings.TryGetValue(marking, out var prototype))
{
return;
}
var markingObject = new Marking(marking, colors);
markingObject.Forced = forced;
humanoid.MarkingSet.AddBack(prototype.MarkingCategory, markingObject);
if (sync)
Dirty(humanoid);
}
/// <summary>
/// Removes a marking from a humanoid by ID.
/// </summary>
@@ -370,13 +202,4 @@ public sealed partial class HumanoidAppearanceSystem : SharedHumanoidAppearanceS
return Loc.GetString("identity-age-old");
}
private void EnsureDefaultMarkings(EntityUid uid, HumanoidAppearanceComponent? humanoid)
{
if (!Resolve(uid, ref humanoid))
{
return;
}
humanoid.MarkingSet.EnsureDefault(humanoid.SkinColor, humanoid.EyeColor, _markingManager);
}
}

View File

@@ -20,6 +20,7 @@ using Content.Shared.Random;
using Content.Shared.Random.Helpers;
using Content.Shared.Roles;
using Content.Shared.StatusIcon;
using Content.Shared.Station;
using JetBrains.Annotations;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
@@ -34,15 +35,13 @@ namespace Content.Server.Station.Systems;
/// Also provides helpers for spawning in the player's mob.
/// </summary>
[PublicAPI]
public sealed class StationSpawningSystem : EntitySystem
public sealed class StationSpawningSystem : SharedStationSpawningSystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly HandsSystem _handsSystem = default!;
[Dependency] private readonly HumanoidAppearanceSystem _humanoidSystem = default!;
[Dependency] private readonly IdCardSystem _cardSystem = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly PdaSystem _pdaSystem = default!;
[Dependency] private readonly SharedAccessSystem _accessSystem = default!;
[Dependency] private readonly IdentitySystem _identity = default!;
@@ -169,39 +168,6 @@ public sealed class StationSpawningSystem : EntitySystem
}
}
/// <summary>
/// Equips starting gear onto the given entity.
/// </summary>
/// <param name="entity">Entity to load out.</param>
/// <param name="startingGear">Starting gear to use.</param>
/// <param name="profile">Character profile to use, if any.</param>
public void EquipStartingGear(EntityUid entity, StartingGearPrototype startingGear, HumanoidCharacterProfile? profile)
{
if (_inventorySystem.TryGetSlots(entity, out var slotDefinitions))
{
foreach (var slot in slotDefinitions)
{
var equipmentStr = startingGear.GetGear(slot.Name, profile);
if (!string.IsNullOrEmpty(equipmentStr))
{
var equipmentEntity = EntityManager.SpawnEntity(equipmentStr, EntityManager.GetComponent<TransformComponent>(entity).Coordinates);
_inventorySystem.TryEquip(entity, equipmentEntity, slot.Name, true);
}
}
}
if (!TryComp(entity, out HandsComponent? handsComponent))
return;
var inhand = startingGear.Inhand;
var coords = EntityManager.GetComponent<TransformComponent>(entity).Coordinates;
foreach (var (hand, prototype) in inhand)
{
var inhandEntity = EntityManager.SpawnEntity(prototype, coords);
_handsSystem.TryPickup(entity, inhandEntity, hand, checkActionBlocker: false, handsComp: handsComponent);
}
}
/// <summary>
/// Equips an ID card and PDA onto the given entity.
/// </summary>
@@ -211,7 +177,7 @@ public sealed class StationSpawningSystem : EntitySystem
/// <param name="station">The station this player is being spawned on.</param>
public void EquipIdCard(EntityUid entity, string characterName, JobPrototype jobPrototype, EntityUid? station)
{
if (!_inventorySystem.TryGetSlotEntity(entity, "id", out var idUid))
if (!InventorySystem.TryGetSlotEntity(entity, "id", out var idUid))
return;
if (!EntityManager.TryGetComponent(idUid, out PdaComponent? pdaComponent) || !TryComp<IdCardComponent>(pdaComponent.ContainedId, out var card))

View File

@@ -8,11 +8,14 @@ using Content.Shared.Coordinates;
using Content.Shared.DragDrop;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Network;
namespace Content.Shared.Body.Systems;
public partial class SharedBodySystem
{
[Dependency] private readonly INetManager _netManager = default!;
public void InitializeBody()
{
SubscribeLocalEvent<BodyComponent, ComponentInit>(OnBodyInit);
@@ -34,7 +37,10 @@ public partial class SharedBodySystem
return;
var prototype = Prototypes.Index<BodyPrototype>(body.Prototype);
if (!_netManager.IsClient || bodyId.IsClientSide())
InitBody(body, prototype);
Dirty(body); // Client doesn't actually spawn the body, need to sync it
}
@@ -72,7 +78,21 @@ public partial class SharedBodySystem
return true;
}
protected abstract void InitBody(BodyComponent body, BodyPrototype prototype);
protected void InitBody(BodyComponent body, BodyPrototype prototype)
{
var root = prototype.Slots[prototype.Root];
Containers.EnsureContainer<Container>(body.Owner, BodyContainerId);
if (root.Part == null)
return;
var bodyId = Spawn(root.Part, body.Owner.ToCoordinates());
var partComponent = Comp<BodyPartComponent>(bodyId);
var slot = new BodyPartSlot(root.Part, body.Owner, partComponent.PartType);
body.Root = slot;
partComponent.Body = bodyId;
AttachPart(bodyId, slot, partComponent);
InitPart(partComponent, prototype, prototype.Root);
}
protected void InitPart(BodyPartComponent parent, BodyPrototype prototype, string slotId, HashSet<string>? initialized = null)
{

View File

@@ -0,0 +1,16 @@
using Content.Shared.Roles;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
namespace Content.Shared.Clothing.Components;
[RegisterComponent, NetworkedComponent]
public sealed class LoadoutComponent : Component
{
/// <summary>
/// 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>)), AutoNetworkedField]
public List<string>? Prototypes;
}

View File

@@ -0,0 +1,35 @@
using Content.Shared.Clothing.Components;
using Content.Shared.Roles;
using Content.Shared.Station;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Shared.Clothing;
/// <summary>
/// Assigns a loadout to an entity based on the startingGear prototype
/// </summary>
public sealed class LoadoutSystem : EntitySystem
{
// Shared so we can predict it for placement manager.
[Dependency] private readonly SharedStationSpawningSystem _station = default!;
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<LoadoutComponent, MapInitEvent>(OnMapInit);
}
private void OnMapInit(EntityUid uid, LoadoutComponent component, MapInitEvent args)
{
if (component.Prototypes == null)
return;
var proto = _protoMan.Index<StartingGearPrototype>(_random.Pick(component.Prototypes));
_station.EquipStartingGear(uid, proto, null);
}
}

View File

@@ -4,6 +4,9 @@ using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using System.Linq;
using Content.Shared.Preferences;
using Robust.Shared.GameObjects.Components.Localization;
using Robust.Shared.Network;
namespace Content.Shared.Humanoid;
@@ -18,6 +21,7 @@ namespace Content.Shared.Humanoid;
/// </summary>
public abstract class SharedHumanoidAppearanceSystem : EntitySystem
{
[Dependency] private readonly INetManager _netManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly MarkingManager _markingManager = default!;
@@ -26,9 +30,33 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HumanoidAppearanceComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<HumanoidAppearanceComponent, ComponentGetState>(OnGetState);
}
private void OnInit(EntityUid uid, HumanoidAppearanceComponent humanoid, ComponentInit args)
{
if (string.IsNullOrEmpty(humanoid.Species) || _netManager.IsClient && !uid.IsClientSide())
{
return;
}
if (string.IsNullOrEmpty(humanoid.Initial)
|| !_prototypeManager.TryIndex(humanoid.Initial, out HumanoidProfilePrototype? startingSet))
{
LoadProfile(uid, HumanoidCharacterProfile.DefaultWithSpecies(humanoid.Species), humanoid);
return;
}
// Do this first, because profiles currently do not support custom base layers
foreach (var (layer, info) in startingSet.CustomBaseLayers)
{
humanoid.CustomBaseLayers.Add(layer, info);
}
LoadProfile(uid, startingSet.Profile, humanoid);
}
private void OnGetState(EntityUid uid, HumanoidAppearanceComponent component, ref ComponentGetState args)
{
args.State = new HumanoidAppearanceState(component.MarkingSet,
@@ -233,4 +261,155 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
Dirty(humanoid);
}
}
/// <summary>
/// Loads a humanoid character profile directly onto this humanoid mob.
/// </summary>
/// <param name="uid">The mob's entity UID.</param>
/// <param name="profile">The character profile to load.</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public virtual void LoadProfile(EntityUid uid, HumanoidCharacterProfile profile, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid))
{
return;
}
SetSpecies(uid, profile.Species, false, humanoid);
SetSex(uid, profile.Sex, false, humanoid);
humanoid.EyeColor = profile.Appearance.EyeColor;
SetSkinColor(uid, profile.Appearance.SkinColor, false);
humanoid.MarkingSet.Clear();
// Add markings that doesn't need coloring. We store them until we add all other markings that doesn't need it.
var markingFColored = new Dictionary<Marking, MarkingPrototype>();
foreach (var marking in profile.Appearance.Markings)
{
if (_markingManager.TryGetMarking(marking, out var prototype))
{
if (!prototype.ForcedColoring)
{
AddMarking(uid, marking.MarkingId, marking.MarkingColors, false);
}
else
{
markingFColored.Add(marking, prototype);
}
}
}
// Hair/facial hair - this may eventually be deprecated.
// We need to ensure hair before applying it or coloring can try depend on markings that can be invalid
var hairColor = _markingManager.MustMatchSkin(profile.Species, HumanoidVisualLayers.Hair, out var hairAlpha, _prototypeManager)
? profile.Appearance.SkinColor.WithAlpha(hairAlpha) : profile.Appearance.HairColor;
var facialHairColor = _markingManager.MustMatchSkin(profile.Species, HumanoidVisualLayers.FacialHair, out var facialHairAlpha, _prototypeManager)
? profile.Appearance.SkinColor.WithAlpha(facialHairAlpha) : profile.Appearance.FacialHairColor;
if (_markingManager.Markings.TryGetValue(profile.Appearance.HairStyleId, out var hairPrototype) &&
_markingManager.CanBeApplied(profile.Species, hairPrototype, _prototypeManager))
{
AddMarking(uid, profile.Appearance.HairStyleId, hairColor, false);
}
if (_markingManager.Markings.TryGetValue(profile.Appearance.FacialHairStyleId, out var facialHairPrototype) &&
_markingManager.CanBeApplied(profile.Species, facialHairPrototype, _prototypeManager))
{
AddMarking(uid, profile.Appearance.FacialHairStyleId, facialHairColor, false);
}
humanoid.MarkingSet.EnsureSpecies(profile.Species, profile.Appearance.SkinColor, _markingManager, _prototypeManager);
// Finally adding marking with forced colors
foreach (var (marking, prototype) in markingFColored)
{
var markingColors = MarkingColoring.GetMarkingLayerColors(
prototype,
profile.Appearance.SkinColor,
profile.Appearance.EyeColor,
humanoid.MarkingSet
);
AddMarking(uid, marking.MarkingId, markingColors, false);
}
EnsureDefaultMarkings(uid, humanoid);
humanoid.Gender = profile.Gender;
if (TryComp<GrammarComponent>(uid, out var grammar))
{
grammar.Gender = profile.Gender;
}
humanoid.Age = profile.Age;
Dirty(humanoid);
}
/// <summary>
/// Adds a marking to this humanoid.
/// </summary>
/// <param name="uid">Humanoid mob's UID</param>
/// <param name="marking">Marking ID to use</param>
/// <param name="color">Color to apply to all marking layers of this marking</param>
/// <param name="sync">Whether to immediately sync this marking or not</param>
/// <param name="forced">If this marking was forced (ignores marking points)</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void AddMarking(EntityUid uid, string marking, Color? color = null, bool sync = true, bool forced = false, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid)
|| !_markingManager.Markings.TryGetValue(marking, out var prototype))
{
return;
}
var markingObject = prototype.AsMarking();
markingObject.Forced = forced;
if (color != null)
{
for (var i = 0; i < prototype.Sprites.Count; i++)
{
markingObject.SetColor(i, color.Value);
}
}
humanoid.MarkingSet.AddBack(prototype.MarkingCategory, markingObject);
if (sync)
Dirty(humanoid);
}
private void EnsureDefaultMarkings(EntityUid uid, HumanoidAppearanceComponent? humanoid)
{
if (!Resolve(uid, ref humanoid))
{
return;
}
humanoid.MarkingSet.EnsureDefault(humanoid.SkinColor, humanoid.EyeColor, _markingManager);
}
/// <summary>
///
/// </summary>
/// <param name="uid">Humanoid mob's UID</param>
/// <param name="marking">Marking ID to use</param>
/// <param name="colors">Colors to apply against this marking's set of sprites.</param>
/// <param name="sync">Whether to immediately sync this marking or not</param>
/// <param name="forced">If this marking was forced (ignores marking points)</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void AddMarking(EntityUid uid, string marking, IReadOnlyList<Color> colors, bool sync = true, bool forced = false, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid)
|| !_markingManager.Markings.TryGetValue(marking, out var prototype))
{
return;
}
var markingObject = new Marking(marking, colors);
markingObject.Forced = forced;
humanoid.MarkingSet.AddBack(prototype.MarkingCategory, markingObject);
if (sync)
Dirty(humanoid);
}
}

View File

@@ -0,0 +1,46 @@
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Inventory;
using Content.Shared.Preferences;
using Content.Shared.Roles;
namespace Content.Shared.Station;
public abstract class SharedStationSpawningSystem : EntitySystem
{
[Dependency] protected readonly InventorySystem InventorySystem = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
/// <summary>
/// Equips starting gear onto the given entity.
/// </summary>
/// <param name="entity">Entity to load out.</param>
/// <param name="startingGear">Starting gear to use.</param>
/// <param name="profile">Character profile to use, if any.</param>
public void EquipStartingGear(EntityUid entity, StartingGearPrototype startingGear, HumanoidCharacterProfile? profile)
{
if (InventorySystem.TryGetSlots(entity, out var slotDefinitions))
{
foreach (var slot in slotDefinitions)
{
var equipmentStr = startingGear.GetGear(slot.Name, profile);
if (!string.IsNullOrEmpty(equipmentStr))
{
var equipmentEntity = EntityManager.SpawnEntity(equipmentStr, EntityManager.GetComponent<TransformComponent>(entity).Coordinates);
InventorySystem.TryEquip(entity, equipmentEntity, slot.Name, true);
}
}
}
if (!TryComp(entity, out HandsComponent? handsComponent))
return;
var inhand = startingGear.Inhand;
var coords = EntityManager.GetComponent<TransformComponent>(entity).Coordinates;
foreach (var (hand, prototype) in inhand)
{
var inhandEntity = EntityManager.SpawnEntity(prototype, coords);
_handsSystem.TryPickup(entity, inhandEntity, hand, checkActionBlocker: false, handsComp: handsComponent);
}
}
}

View File

@@ -1442,7 +1442,6 @@
- type: GhostTakeoverAvailable
- type: IdExaminable
- type: Loadout
prototype: SyndicateOperativeGearMonkey
prototypes: [SyndicateOperativeGearMonkey]
# I have included a snake_hiss.ogg sound file so if you want to use that be my guest

View File

@@ -11,7 +11,6 @@
name: Syndicate Agent
components:
- type: Loadout
prototype: SyndicateOperativeGearExtremelyBasic
prototypes: [SyndicateOperativeGearExtremelyBasic]
- type: RandomMetadata
nameSegments: [names_death_commando]
@@ -46,7 +45,6 @@
randomizeName: false
- type: NukeOperative
- type: Loadout
prototype: SyndicateOperativeGearFull
prototypes: [SyndicateOperativeGearFull]
- type: RandomMetadata
nameSegments: