Makes humanoid appearance component networked. (#13009)

Fixes https://github.com/space-wizards/space-station-14/issues/12248
This commit is contained in:
Leon Friedrich
2023-01-24 13:38:19 +13:00
committed by GitHub
parent 7ce8f7634a
commit 48bcd30ef9
50 changed files with 878 additions and 1074 deletions

View File

@@ -25,7 +25,7 @@ public sealed class BodySystem : SharedBodySystem
{
[Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly HumanoidSystem _humanoidSystem = default!;
[Dependency] private readonly HumanoidAppearanceSystem _humanoidSystem = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
@@ -83,7 +83,7 @@ public sealed class BodySystem : SharedBodySystem
return false;
if (part.Body is { } body &&
TryComp<HumanoidComponent>(body, out var humanoid))
TryComp<HumanoidAppearanceComponent>(body, out var humanoid))
{
var layer = part.ToHumanoidLayers();
if (layer != null)
@@ -103,7 +103,7 @@ public sealed class BodySystem : SharedBodySystem
if (!base.DropPart(partId, part))
return false;
if (oldBody == null || !TryComp<HumanoidComponent>(oldBody, out var humanoid))
if (oldBody == null || !TryComp<HumanoidAppearanceComponent>(oldBody, out var humanoid))
return true;
var layer = part.ToHumanoidLayers();

View File

@@ -31,6 +31,7 @@ using Robust.Shared.Random;
using Robust.Shared.Configuration;
using Robust.Shared.Containers;
using Robust.Shared.Physics.Components;
using Content.Shared.Humanoid;
namespace Content.Server.Cloning
{
@@ -41,7 +42,7 @@ namespace Content.Server.Cloning
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly EuiManager _euiManager = null!;
[Dependency] private readonly CloningConsoleSystem _cloningConsoleSystem = default!;
[Dependency] private readonly HumanoidSystem _humanoidSystem = default!;
[Dependency] private readonly HumanoidAppearanceSystem _humanoidSystem = default!;
[Dependency] private readonly ContainerSystem _containerSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
@@ -170,7 +171,7 @@ namespace Content.Server.Cloning
if (mind.UserId == null || !_playerManager.TryGetSessionById(mind.UserId.Value, out var client))
return false; // If we can't track down the client, we can't offer transfer. That'd be quite bad.
if (!TryComp<HumanoidComponent>(bodyToClone, out var humanoid))
if (!TryComp<HumanoidAppearanceComponent>(bodyToClone, out var humanoid))
return false; // whatever body was to be cloned, was not a humanoid
if (!_prototype.TryIndex<SpeciesPrototype>(humanoid.Species, out var speciesPrototype))

View File

@@ -1,39 +1,7 @@
using Content.Server.Humanoid;
using Content.Shared.Clothing.Components;
using Content.Shared.Clothing.EntitySystems;
using Content.Shared.Humanoid;
using Content.Shared.Inventory.Events;
using Content.Shared.Tag;
namespace Content.Server.Clothing;
public sealed class ServerClothingSystem : ClothingSystem
{
[Dependency] private readonly HumanoidSystem _humanoidSystem = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
protected override void OnGotEquipped(EntityUid uid, ClothingComponent component, GotEquippedEvent args)
{
base.OnGotEquipped(uid, component, args);
// why the fuck is humanoid visuals server-only???
if (args.Slot == "head"
&& _tagSystem.HasTag(args.Equipment, "HidesHair"))
{
_humanoidSystem.ToggleHiddenLayer(args.Equipee, HumanoidVisualLayers.Hair);
}
}
protected override void OnGotUnequipped(EntityUid uid, ClothingComponent component, GotUnequippedEvent args)
{
base.OnGotUnequipped(uid, component, args);
// why the fuck is humanoid visuals server-only???
if (args.Slot == "head"
&& _tagSystem.HasTag(args.Equipment, "HidesHair"))
{
_humanoidSystem.ToggleHiddenLayer(args.Equipee, HumanoidVisualLayers.Hair);
}
}
}

View File

@@ -303,7 +303,7 @@ namespace Content.Server.Dragon
var ichorInjection = new Solution(component.DevourChem, component.DevourHealRate);
//Humanoid devours allow dragon to get eggs, corpses included
if (!EntityManager.HasComponent<HumanoidComponent>(args.Target))
if (!EntityManager.HasComponent<HumanoidAppearanceComponent>(args.Target))
{
ichorInjection.ScaleSolution(0.5f);
}

View File

@@ -148,7 +148,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem
private void CheckRoundEnd(EntityUid target)
{
//we only care about players, not monkeys and such.
if (!HasComp<HumanoidComponent>(target))
if (!HasComp<HumanoidAppearanceComponent>(target))
return;
var percent = GetInfectedPercentage(out var num);
@@ -196,7 +196,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem
private float GetInfectedPercentage(out List<EntityUid> livingHumans)
{
var allPlayers = EntityQuery<HumanoidComponent, MobStateComponent>(true);
var allPlayers = EntityQuery<HumanoidAppearanceComponent, MobStateComponent>(true);
var allZombers = GetEntityQuery<ZombieComponent>();
var totalPlayers = new List<EntityUid>();

View File

@@ -1,50 +1,32 @@
using System.Linq;
using Content.Server.GameTicking;
using Content.Shared.Examine;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.IdentityManagement;
using Content.Shared.Inventory.Events;
using Content.Shared.Preferences;
using Content.Shared.Tag;
using Content.Shared.Verbs;
using Robust.Shared.GameObjects.Components.Localization;
using Robust.Shared.Prototypes;
namespace Content.Server.Humanoid;
public sealed partial class HumanoidSystem : SharedHumanoidSystem
public sealed partial class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem
{
[Dependency] private readonly MarkingManager _markingManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override void Initialize()
{
SubscribeLocalEvent<HumanoidComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<HumanoidComponent, HumanoidMarkingModifierMarkingSetMessage>(OnMarkingsSet);
SubscribeLocalEvent<HumanoidComponent, HumanoidMarkingModifierBaseLayersSetMessage>(OnBaseLayersSet);
SubscribeLocalEvent<HumanoidComponent, GetVerbsEvent<Verb>>(OnVerbsRequest);
SubscribeLocalEvent<HumanoidComponent, ExaminedEvent>(OnExamined);
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 Synchronize(EntityUid uid, HumanoidComponent? component = null)
{
if (!Resolve(uid, ref component))
{
return;
}
SetAppearance(uid,
component.Species,
component.CustomBaseLayers,
component.SkinColor,
component.Sex,
component.AllHiddenLayers.ToList(),
component.CurrentMarkings.GetForwardEnumerator().ToList());
}
private void OnInit(EntityUid uid, HumanoidComponent humanoid, ComponentInit args)
private void OnInit(EntityUid uid, HumanoidAppearanceComponent humanoid, ComponentInit args)
{
if (string.IsNullOrEmpty(humanoid.Species))
{
@@ -67,7 +49,7 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
LoadProfile(uid, startingSet.Profile, humanoid);
}
private void OnExamined(EntityUid uid, HumanoidComponent component, ExaminedEvent args)
private void OnExamined(EntityUid uid, HumanoidAppearanceComponent component, ExaminedEvent args)
{
var identity = Identity.Entity(component.Owner, EntityManager);
var species = GetSpeciesRepresentation(component.Species).ToLower();
@@ -82,7 +64,7 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
/// <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, HumanoidComponent? humanoid = null)
public void LoadProfile(EntityUid uid, HumanoidCharacterProfile profile, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid))
{
@@ -91,11 +73,11 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
SetSpecies(uid, profile.Species, false, humanoid);
humanoid.Sex = profile.Sex;
humanoid.EyeColor = profile.Appearance.EyeColor;
SetSkinColor(uid, profile.Appearance.SkinColor, false);
SetBaseLayerColor(uid, HumanoidVisualLayers.Eyes, profile.Appearance.EyeColor, false);
humanoid.CurrentMarkings.Clear();
humanoid.MarkingSet.Clear();
// Hair/facial hair - this may eventually be deprecated.
@@ -117,7 +99,7 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
humanoid.Age = profile.Age;
Synchronize(uid);
Dirty(humanoid);
}
// this was done enough times that it only made sense to do it here
@@ -129,8 +111,8 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
/// <param name="target">Target entity to apply the source entity's appearance to.</param>
/// <param name="sourceHumanoid">Source entity's humanoid component.</param>
/// <param name="targetHumanoid">Target entity's humanoid component.</param>
public void CloneAppearance(EntityUid source, EntityUid target, HumanoidComponent? sourceHumanoid = null,
HumanoidComponent? targetHumanoid = null)
public void CloneAppearance(EntityUid source, EntityUid target, HumanoidAppearanceComponent? sourceHumanoid = null,
HumanoidAppearanceComponent? targetHumanoid = null)
{
if (!Resolve(source, ref sourceHumanoid) || !Resolve(target, ref targetHumanoid))
{
@@ -141,7 +123,7 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
targetHumanoid.SkinColor = sourceHumanoid.SkinColor;
targetHumanoid.Sex = sourceHumanoid.Sex;
targetHumanoid.CustomBaseLayers = new(sourceHumanoid.CustomBaseLayers);
targetHumanoid.CurrentMarkings = new(sourceHumanoid.CurrentMarkings);
targetHumanoid.MarkingSet = new(sourceHumanoid.MarkingSet);
targetHumanoid.Gender = sourceHumanoid.Gender;
if (TryComp<GrammarComponent>(target, out var grammar))
@@ -149,180 +131,7 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
grammar.Gender = sourceHumanoid.Gender;
}
Synchronize(target, targetHumanoid);
}
/// <summary>
/// Set a humanoid mob's species. This will change their base sprites, as well as their current
/// set of markings to fit against the mob's new species.
/// </summary>
/// <param name="uid">The humanoid mob's UID.</param>
/// <param name="species">The species to set the mob to. Will return if the species prototype was invalid.</param>
/// <param name="sync">Whether to immediately synchronize this to the humanoid mob, or not.</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void SetSpecies(EntityUid uid, string species, bool sync = true, HumanoidComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid) || !_prototypeManager.TryIndex<SpeciesPrototype>(species, out var prototype))
{
return;
}
humanoid.Species = species;
humanoid.CurrentMarkings.FilterSpecies(species, _markingManager);
var oldMarkings = humanoid.CurrentMarkings.GetForwardEnumerator().ToList();
humanoid.CurrentMarkings = new(oldMarkings, prototype.MarkingPoints, _markingManager, _prototypeManager);
if (sync)
{
Synchronize(uid, humanoid);
}
}
/// <summary>
/// Sets the skin color of this humanoid mob. Will only affect base layers that are not custom,
/// custom base layers should use <see cref="SetBaseLayerColor"/> instead.
/// </summary>
/// <param name="uid">The humanoid mob's UID.</param>
/// <param name="skinColor">Skin color to set on the humanoid mob.</param>
/// <param name="sync">Whether to synchronize this to the humanoid mob, or not.</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void SetSkinColor(EntityUid uid, Color skinColor, bool sync = true, HumanoidComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid))
{
return;
}
humanoid.SkinColor = skinColor;
if (sync)
Synchronize(uid, humanoid);
}
/// <summary>
/// Sets the base layer ID of this humanoid mob. A humanoid mob's 'base layer' is
/// the skin sprite that is applied to the mob's sprite upon appearance refresh.
/// </summary>
/// <param name="uid">The humanoid mob's UID.</param>
/// <param name="layer">The layer to target on this humanoid mob.</param>
/// <param name="id">The ID of the sprite to use. See <see cref="HumanoidSpeciesSpriteLayer"/>.</param>
/// <param name="sync">Whether to synchronize this to the humanoid mob, or not.</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void SetBaseLayerId(EntityUid uid, HumanoidVisualLayers layer, string id, bool sync = true,
HumanoidComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid)
|| !_prototypeManager.HasIndex<HumanoidSpeciesSpriteLayer>(id))
{
return;
}
if (humanoid.CustomBaseLayers.TryGetValue(layer, out var info))
{
humanoid.CustomBaseLayers[layer] = new(id, info.Color);
}
else
{
var layerInfo = new CustomBaseLayerInfo(id, humanoid.SkinColor);
humanoid.CustomBaseLayers.Add(layer, layerInfo);
}
if (sync)
Synchronize(uid, humanoid);
}
/// <summary>
/// Sets the color of this humanoid mob's base layer. See <see cref="SetBaseLayerId"/> for a
/// description of how base layers work.
/// </summary>
/// <param name="uid">The humanoid mob's UID.</param>
/// <param name="layer">The layer to target on this humanoid mob.</param>
/// <param name="color">The color to set this base layer to.</param>
public void SetBaseLayerColor(EntityUid uid, HumanoidVisualLayers layer, Color color, bool sync = true, HumanoidComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid))
{
return;
}
if (humanoid.CustomBaseLayers.TryGetValue(layer, out var info))
{
humanoid.CustomBaseLayers[layer] = new(info.ID, color);
}
else
{
var layerInfo = new CustomBaseLayerInfo(string.Empty, color);
humanoid.CustomBaseLayers.Add(layer, layerInfo);
}
if (sync)
Synchronize(uid, humanoid);
}
/// <summary>
/// Toggles a humanoid's sprite layer visibility.
/// </summary>
/// <param name="uid">Humanoid mob's UID</param>
/// <param name="layer">Layer to toggle visibility for</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void ToggleHiddenLayer(EntityUid uid, HumanoidVisualLayers layer, HumanoidComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid, false))
{
return;
}
if (humanoid.HiddenLayers.Contains(layer))
{
humanoid.HiddenLayers.Remove(layer);
}
else
{
humanoid.HiddenLayers.Add(layer);
}
Synchronize(uid, humanoid);
}
/// <summary>
/// Sets the visibility for multiple layers at once on a humanoid's sprite.
/// </summary>
/// <param name="uid">Humanoid mob's UID</param>
/// <param name="layers">An enumerable of all sprite layers that are going to have their visibility set</param>
/// <param name="visible">The visibility state of the layers given</param>
/// <param name="permanent">If this is a permanent change, or temporary. Permanent layers are stored in their own hash set.</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void SetLayersVisibility(EntityUid uid, IEnumerable<HumanoidVisualLayers> layers, bool visible, bool permanent = false,
HumanoidComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid))
{
return;
}
foreach (var layer in layers)
{
if (visible)
{
if (permanent && humanoid.PermanentlyHidden.Contains(layer))
{
humanoid.PermanentlyHidden.Remove(layer);
}
humanoid.HiddenLayers.Remove(layer);
}
else
{
if (permanent)
{
humanoid.PermanentlyHidden.Add(layer);
}
humanoid.HiddenLayers.Add(layer);
}
}
Synchronize(uid, humanoid);
Dirty(targetHumanoid);
}
/// <summary>
@@ -334,7 +143,7 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
/// <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, HumanoidComponent? humanoid = null)
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))
@@ -352,10 +161,10 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
}
}
humanoid.CurrentMarkings.AddBack(prototype.MarkingCategory, markingObject);
humanoid.MarkingSet.AddBack(prototype.MarkingCategory, markingObject);
if (sync)
Synchronize(uid, humanoid);
Dirty(humanoid);
}
/// <summary>
@@ -367,7 +176,7 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
/// <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, HumanoidComponent? humanoid = null)
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))
@@ -377,10 +186,10 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
var markingObject = new Marking(marking, colors);
markingObject.Forced = forced;
humanoid.CurrentMarkings.AddBack(prototype.MarkingCategory, markingObject);
humanoid.MarkingSet.AddBack(prototype.MarkingCategory, markingObject);
if (sync)
Synchronize(uid, humanoid);
Dirty(humanoid);
}
/// <summary>
@@ -390,7 +199,7 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
/// <param name="marking">The marking to try and remove.</param>
/// <param name="sync">Whether to immediately sync this to the humanoid</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void RemoveMarking(EntityUid uid, string marking, bool sync = true, HumanoidComponent? humanoid = null)
public void RemoveMarking(EntityUid uid, string marking, bool sync = true, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid)
|| !_markingManager.Markings.TryGetValue(marking, out var prototype))
@@ -398,10 +207,10 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
return;
}
humanoid.CurrentMarkings.Remove(prototype.MarkingCategory, marking);
humanoid.MarkingSet.Remove(prototype.MarkingCategory, marking);
if (sync)
Synchronize(uid, humanoid);
Dirty(humanoid);
}
/// <summary>
@@ -411,19 +220,18 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
/// <param name="category">Category of the marking</param>
/// <param name="index">Index of the marking</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void RemoveMarking(EntityUid uid, MarkingCategories category, int index, HumanoidComponent? humanoid = null)
public void RemoveMarking(EntityUid uid, MarkingCategories category, int index, HumanoidAppearanceComponent? humanoid = null)
{
if (index < 0
|| !Resolve(uid, ref humanoid)
|| !humanoid.CurrentMarkings.TryGetCategory(category, out var markings)
|| !humanoid.MarkingSet.TryGetCategory(category, out var markings)
|| index >= markings.Count)
{
return;
}
humanoid.CurrentMarkings.Remove(category, index);
Synchronize(uid, humanoid);
humanoid.MarkingSet.Remove(category, index);
Dirty(humanoid);
}
/// <summary>
@@ -434,12 +242,12 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
/// <param name="index">Index of the marking</param>
/// <param name="markingId">The marking ID to use</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void SetMarkingId(EntityUid uid, MarkingCategories category, int index, string markingId, HumanoidComponent? humanoid = null)
public void SetMarkingId(EntityUid uid, MarkingCategories category, int index, string markingId, HumanoidAppearanceComponent? humanoid = null)
{
if (index < 0
|| !_markingManager.MarkingsByCategory(category).TryGetValue(markingId, out var markingPrototype)
|| !Resolve(uid, ref humanoid)
|| !humanoid.CurrentMarkings.TryGetCategory(category, out var markings)
|| !humanoid.MarkingSet.TryGetCategory(category, out var markings)
|| index >= markings.Count)
{
return;
@@ -451,9 +259,8 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
marking.SetColor(i, markings[index].MarkingColors[i]);
}
humanoid.CurrentMarkings.Replace(category, index, marking);
Synchronize(uid, humanoid);
humanoid.MarkingSet.Replace(category, index, marking);
Dirty(humanoid);
}
/// <summary>
@@ -465,11 +272,11 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
/// <param name="colors">The marking colors to use</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void SetMarkingColor(EntityUid uid, MarkingCategories category, int index, List<Color> colors,
HumanoidComponent? humanoid = null)
HumanoidAppearanceComponent? humanoid = null)
{
if (index < 0
|| !Resolve(uid, ref humanoid)
|| !humanoid.CurrentMarkings.TryGetCategory(category, out var markings)
|| !humanoid.MarkingSet.TryGetCategory(category, out var markings)
|| index >= markings.Count)
{
return;
@@ -480,7 +287,7 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
markings[index].SetColor(i, colors[i]);
}
Synchronize(uid, humanoid);
Dirty(humanoid);
}
/// <summary>
@@ -521,13 +328,13 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
return Loc.GetString("identity-age-old");
}
private void EnsureDefaultMarkings(EntityUid uid, HumanoidComponent? humanoid)
private void EnsureDefaultMarkings(EntityUid uid, HumanoidAppearanceComponent? humanoid)
{
if (!Resolve(uid, ref humanoid))
{
return;
}
humanoid.CurrentMarkings.EnsureDefault(humanoid.SkinColor, _markingManager);
humanoid.MarkingSet.EnsureDefault(humanoid.SkinColor, _markingManager);
}
}

View File

@@ -7,12 +7,12 @@ using Robust.Server.Player;
namespace Content.Server.Humanoid;
public sealed partial class HumanoidSystem
public sealed partial class HumanoidAppearanceSystem
{
[Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
private void OnVerbsRequest(EntityUid uid, HumanoidComponent component, GetVerbsEvent<Verb> args)
private void OnVerbsRequest(EntityUid uid, HumanoidAppearanceComponent component, GetVerbsEvent<Verb> args)
{
if (!TryComp<ActorComponent>(args.User, out var actor))
{
@@ -35,12 +35,12 @@ public sealed partial class HumanoidSystem
_uiSystem.TrySetUiState(
uid,
HumanoidMarkingModifierKey.Key,
new HumanoidMarkingModifierState(component.CurrentMarkings, component.Species, component.SkinColor, component.CustomBaseLayers));
new HumanoidMarkingModifierState(component.MarkingSet, component.Species, component.SkinColor, component.CustomBaseLayers));
}
});
}
private void OnBaseLayersSet(EntityUid uid, HumanoidComponent component,
private void OnBaseLayersSet(EntityUid uid, HumanoidAppearanceComponent component,
HumanoidMarkingModifierBaseLayersSetMessage message)
{
if (message.Session is not IPlayerSession player
@@ -55,24 +55,21 @@ public sealed partial class HumanoidSystem
}
else
{
if (!component.CustomBaseLayers.TryAdd(message.Layer, message.Info))
{
component.CustomBaseLayers[message.Layer] = message.Info;
}
component.CustomBaseLayers[message.Layer] = message.Info.Value;
}
Synchronize(uid, component);
Dirty(component);
if (message.ResendState)
{
_uiSystem.TrySetUiState(
uid,
HumanoidMarkingModifierKey.Key,
new HumanoidMarkingModifierState(component.CurrentMarkings, component.Species, component.SkinColor, component.CustomBaseLayers));
new HumanoidMarkingModifierState(component.MarkingSet, component.Species, component.SkinColor, component.CustomBaseLayers));
}
}
private void OnMarkingsSet(EntityUid uid, HumanoidComponent component,
private void OnMarkingsSet(EntityUid uid, HumanoidAppearanceComponent component,
HumanoidMarkingModifierMarkingSetMessage message)
{
if (message.Session is not IPlayerSession player
@@ -81,15 +78,15 @@ public sealed partial class HumanoidSystem
return;
}
component.CurrentMarkings = message.MarkingSet;
Synchronize(uid, component);
component.MarkingSet = message.MarkingSet;
Dirty(component);
if (message.ResendState)
{
_uiSystem.TrySetUiState(
uid,
HumanoidMarkingModifierKey.Key,
new HumanoidMarkingModifierState(component.CurrentMarkings, component.Species, component.SkinColor, component.CustomBaseLayers));
new HumanoidMarkingModifierState(component.MarkingSet, component.Species, component.SkinColor, component.CustomBaseLayers));
}
}

View File

@@ -1,4 +1,4 @@
using Content.Server.CharacterAppearance.Components;
using Content.Server.CharacterAppearance.Components;
using Content.Shared.Humanoid;
using Content.Shared.Preferences;
@@ -6,7 +6,7 @@ namespace Content.Server.Humanoid.Systems;
public sealed class RandomHumanoidAppearanceSystem : EntitySystem
{
[Dependency] private readonly HumanoidSystem _humanoid = default!;
[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
public override void Initialize()
{
@@ -18,7 +18,7 @@ public sealed class RandomHumanoidAppearanceSystem : EntitySystem
private void OnMapInit(EntityUid uid, RandomHumanoidAppearanceComponent component, MapInitEvent args)
{
// If we have an initial profile/base layer set, do not randomize this humanoid.
if (!TryComp(uid, out HumanoidComponent? humanoid) || !string.IsNullOrEmpty(humanoid.Initial))
if (!TryComp(uid, out HumanoidAppearanceComponent? humanoid) || !string.IsNullOrEmpty(humanoid.Initial))
{
return;
}

View File

@@ -17,7 +17,7 @@ public sealed class RandomHumanoidSystem : EntitySystem
[Dependency] private readonly IComponentFactory _compFactory = default!;
[Dependency] private readonly ISerializationManager _serialization = default!;
[Dependency] private readonly HumanoidSystem _humanoid = default!;
[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
/// <inheritdoc/>
public override void Initialize()

View File

@@ -118,7 +118,7 @@ public class IdentitySystem : SharedIdentitySystem
/// </summary>
private IdentityRepresentation GetIdentityRepresentation(EntityUid target,
InventoryComponent? inventory=null,
HumanoidComponent? appearance=null)
HumanoidAppearanceComponent? appearance=null)
{
int age = 18;
Gender gender = Gender.Epicene;

View File

@@ -13,7 +13,7 @@ namespace Content.Server.MagicMirror;
public sealed class MagicMirrorSystem : EntitySystem
{
[Dependency] private readonly MarkingManager _markings = default!;
[Dependency] private readonly HumanoidSystem _humanoid = default!;
[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
@@ -30,14 +30,14 @@ public sealed class MagicMirrorSystem : EntitySystem
private void OnOpenUIAttempt(EntityUid uid, MagicMirrorComponent mirror, ActivatableUIOpenAttemptEvent args)
{
if (!HasComp<HumanoidComponent>(args.User))
if (!HasComp<HumanoidAppearanceComponent>(args.User))
args.Cancel();
}
private void OnMagicMirrorSelect(EntityUid uid, MagicMirrorComponent component,
MagicMirrorSelectMessage message)
{
if (message.Session.AttachedEntity == null || !TryComp<HumanoidComponent>(message.Session.AttachedEntity.Value, out var humanoid))
if (message.Session.AttachedEntity == null || !TryComp<HumanoidAppearanceComponent>(message.Session.AttachedEntity.Value, out var humanoid))
{
return;
}
@@ -63,7 +63,7 @@ public sealed class MagicMirrorSystem : EntitySystem
private void OnMagicMirrorChangeColor(EntityUid uid, MagicMirrorComponent component,
MagicMirrorChangeColorMessage message)
{
if (message.Session.AttachedEntity == null || !TryComp<HumanoidComponent>(message.Session.AttachedEntity.Value, out var humanoid))
if (message.Session.AttachedEntity == null || !TryComp<HumanoidAppearanceComponent>(message.Session.AttachedEntity.Value, out var humanoid))
{
return;
}
@@ -90,7 +90,7 @@ public sealed class MagicMirrorSystem : EntitySystem
private void OnMagicMirrorRemoveSlot(EntityUid uid, MagicMirrorComponent component,
MagicMirrorRemoveSlotMessage message)
{
if (message.Session.AttachedEntity == null || !TryComp<HumanoidComponent>(message.Session.AttachedEntity.Value, out var humanoid))
if (message.Session.AttachedEntity == null || !TryComp<HumanoidAppearanceComponent>(message.Session.AttachedEntity.Value, out var humanoid))
{
return;
}
@@ -116,7 +116,7 @@ public sealed class MagicMirrorSystem : EntitySystem
private void OnMagicMirrorAddSlot(EntityUid uid, MagicMirrorComponent component,
MagicMirrorAddSlotMessage message)
{
if (message.Session.AttachedEntity == null || !TryComp<HumanoidComponent>(message.Session.AttachedEntity.Value, out var humanoid))
if (message.Session.AttachedEntity == null || !TryComp<HumanoidAppearanceComponent>(message.Session.AttachedEntity.Value, out var humanoid))
{
return;
}
@@ -145,34 +145,34 @@ public sealed class MagicMirrorSystem : EntitySystem
UpdateInterface(uid, message.Session.AttachedEntity.Value, message.Session);
}
private void UpdateInterface(EntityUid uid, EntityUid playerUid, ICommonSession session, HumanoidComponent? humanoid = null)
private void UpdateInterface(EntityUid uid, EntityUid playerUid, ICommonSession session, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(playerUid, ref humanoid) || session is not IPlayerSession player)
{
return;
}
var hair = humanoid.CurrentMarkings.TryGetCategory(MarkingCategories.Hair, out var hairMarkings)
var hair = humanoid.MarkingSet.TryGetCategory(MarkingCategories.Hair, out var hairMarkings)
? new List<Marking>(hairMarkings)
: new();
var facialHair = humanoid.CurrentMarkings.TryGetCategory(MarkingCategories.FacialHair, out var facialHairMarkings)
var facialHair = humanoid.MarkingSet.TryGetCategory(MarkingCategories.FacialHair, out var facialHairMarkings)
? new List<Marking>(facialHairMarkings)
: new();
var msg = new MagicMirrorUiData(
humanoid.Species,
hair,
humanoid.CurrentMarkings.PointsLeft(MarkingCategories.Hair) + hair.Count,
humanoid.MarkingSet.PointsLeft(MarkingCategories.Hair) + hair.Count,
facialHair,
humanoid.CurrentMarkings.PointsLeft(MarkingCategories.FacialHair) + facialHair.Count);
humanoid.MarkingSet.PointsLeft(MarkingCategories.FacialHair) + facialHair.Count);
_uiSystem.TrySendUiMessage(uid, MagicMirrorUiKey.Key, msg, player);
}
private void AfterUIOpen(EntityUid uid, MagicMirrorComponent component, AfterActivatableUIOpenEvent args)
{
var looks = Comp<HumanoidComponent>(args.User);
var looks = Comp<HumanoidAppearanceComponent>(args.User);
var actor = Comp<ActorComponent>(args.User);
UpdateInterface(uid, args.User, args.Session);

View File

@@ -26,6 +26,7 @@ using Robust.Shared.Random;
using Robust.Shared.Configuration;
using Robust.Server.Player;
using Robust.Shared.Physics.Components;
using Content.Shared.Humanoid;
namespace Content.Server.Medical.BiomassReclaimer
{
@@ -256,7 +257,7 @@ namespace Content.Server.Medical.BiomassReclaimer
// Reject souled bodies in easy mode.
if (_configManager.GetCVar(CCVars.BiomassEasyMode) &&
HasComp<HumanoidComponent>(dragged) &&
HasComp<HumanoidAppearanceComponent>(dragged) &&
TryComp<MindComponent>(dragged, out var mindComp))
{
if (mindComp.Mind?.UserId != null && _playerManager.TryGetSessionById(mindComp.Mind.UserId.Value, out _))

View File

@@ -32,7 +32,7 @@ namespace Content.Server.Polymorph.Systems
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly HumanoidSystem _humanoid = default!;
[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
[Dependency] private readonly ContainerSystem _container = default!;
public override void Initialize()

View File

@@ -276,7 +276,7 @@ namespace Content.Server.Preferences.Managers
case HumanoidCharacterProfile hp:
{
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var selectedSpecies = HumanoidSystem.DefaultSpecies;
var selectedSpecies = HumanoidAppearanceSystem.DefaultSpecies;
if (prototypeManager.TryIndex<SpeciesPrototype>(hp.Species, out var species) && species.RoundStart)
{

View File

@@ -29,6 +29,7 @@ using Content.Shared.Mobs.Systems;
using Content.Shared.Revenant.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Utility;
using Content.Shared.Humanoid;
namespace Content.Server.Revenant.EntitySystems;
@@ -70,7 +71,7 @@ public sealed partial class RevenantSystem
return;
}
if (!HasComp<MobStateComponent>(target) || !HasComp<HumanoidComponent>(target) || HasComp<RevenantComponent>(target))
if (!HasComp<MobStateComponent>(target) || !HasComp<HumanoidAppearanceComponent>(target) || HasComp<RevenantComponent>(target))
return;
args.Handled = true;

View File

@@ -70,7 +70,7 @@ public sealed class VocalSystem : EntitySystem
if (!_blocker.CanSpeak(uid))
return false;
var sex = CompOrNull<HumanoidComponent>(uid)?.Sex ?? Sex.Unsexed;
var sex = CompOrNull<HumanoidAppearanceComponent>(uid)?.Sex ?? Sex.Unsexed;
if (_random.Prob(component.WilhelmProbability))
{

View File

@@ -34,7 +34,7 @@ public sealed class StationSpawningSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly HandsSystem _handsSystem = default!;
[Dependency] private readonly HumanoidSystem _humanoidSystem = 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!;
@@ -106,7 +106,7 @@ public sealed class StationSpawningSystem : EntitySystem
}
var entity = EntityManager.SpawnEntity(
_prototypeManager.Index<SpeciesPrototype>(profile?.Species ?? HumanoidSystem.DefaultSpecies).Prototype,
_prototypeManager.Index<SpeciesPrototype>(profile?.Species ?? HumanoidAppearanceSystem.DefaultSpecies).Prototype,
coordinates);
if (job?.StartingGear != null)

View File

@@ -3,6 +3,7 @@ using Content.Shared.Humanoid;
using Content.Shared.Store;
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
using Content.Shared.Humanoid;
namespace Content.Server.Store.Conditions;
@@ -28,7 +29,7 @@ public sealed class BuyerSpeciesCondition : ListingCondition
{
var ent = args.EntityManager;
if (!ent.TryGetComponent<HumanoidComponent>(args.Buyer, out var appearance))
if (!ent.TryGetComponent<HumanoidAppearanceComponent>(args.Buyer, out var appearance))
return true; // inanimate or non-humanoid entities should be handled elsewhere, main example being surplus crates
if (Blacklist != null)

View File

@@ -34,7 +34,7 @@ namespace Content.Server.Zombies
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly HumanoidSystem _humanoidSystem = default!;
[Dependency] private readonly HumanoidAppearanceSystem _humanoidSystem = default!;
public override void Initialize()
{

View File

@@ -46,7 +46,7 @@ namespace Content.Server.Zombies
[Dependency] private readonly BloodstreamSystem _bloodstream = default!;
[Dependency] private readonly ServerInventorySystem _serverInventory = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly HumanoidSystem _sharedHuApp = default!;
[Dependency] private readonly HumanoidAppearanceSystem _sharedHuApp = default!;
[Dependency] private readonly IdentitySystem _identity = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!;
[Dependency] private readonly IChatManager _chatMan = default!;
@@ -125,7 +125,7 @@ namespace Content.Server.Zombies
Dirty(melee);
//We have specific stuff for humanoid zombies because they matter more
if (TryComp<HumanoidComponent>(target, out var huApComp)) //huapcomp
if (TryComp<HumanoidAppearanceComponent>(target, out var huApComp)) //huapcomp
{
//store some values before changing them in case the humanoid get cloned later
zombiecomp.BeforeZombifiedSkinColor = huApComp.SkinColor;