Files
wwdpublic/Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.cs
Spatison 2549ec061e [Feature] Body Types (#180)
* feature: body types

# Conflicts:
#	Content.Shared/Humanoid/Markings/MarkingManager.cs
#	Resources/Prototypes/Nyanotrasen/Species/Oni.yml
#	Resources/Prototypes/Nyanotrasen/Species/felinid.yml
#	Resources/Prototypes/Species/arachne.yml
#	Resources/Prototypes/Species/dwarf.yml
#	Resources/Prototypes/Species/harpy.yml
#	Resources/Prototypes/Species/human.yml
#	Resources/Prototypes/Species/ipc.yml
#	Resources/Textures/Clothing/OuterClothing/Armor/armor_reflec.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/bulletproof.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/cult_armour.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/heavy.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/heavygreen.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/heavyred.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/lingarmor.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/magusblue.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/magusred.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/riot.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/security.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/security_slim.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Bio/virology.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/bomber.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/brigmedic.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/detective.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/gentlecoat.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/jensencoat.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/labcoat_gene.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/labcoat_robo.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/pirate.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/windbreaker_paramedic.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/ERTSuits/ertengineer.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/ERTSuits/ertjanitor.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/ERTSuits/ertleader.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/ERTSuits/ertmedical.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/ERTSuits/ertsecurity.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/basic.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/capspace.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/cburn.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/cybersun.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/lingspacesuit.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/luxury.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/medical.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/paramed.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/rd.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/salvage.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/spatio.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/syndicate.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/syndiecommander.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/syndieelite.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/wizard.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/apron.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/apronbotanist.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/apronchef.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/cardborg.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/chaplain_hoodie.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/chef.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/classicponcho.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/cultrobes.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/grey_hoodie.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/judge.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/plaguedoctorsuit.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/redwizard.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/santa.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/skubbody.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/straight_jacket.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/violetwizard.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/wizard.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/atmos_firesuit.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/bombsuit.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/chicken.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/fire.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/monkey.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/rad.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/shrine-maiden.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Vests/mercwebvest.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Vests/vest.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Vests/webvest.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coat.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatatmos.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatbar.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatcap.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatcargo.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatce.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatcentcom.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatchef.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatchem.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatcmo.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatengi.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatgen.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coathop.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coathos.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coathydro.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatjani.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatmed.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatmime.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatminer.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatnomi.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatparamed.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatqm.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatrd.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatrobo.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatsci.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatsec.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatviro.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatwarden.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatwardenarmored.rsi/meta.json

* feature: body types: 2

* add: loc

* fix: rsi validate

* tweak: displasment jumpsuit

* tweak: clean up

* tweak: displasment shoes

* tweak: displasment gloves

* tweak: clean up

* tweak: displasment outerClothing

* Revert "tweak: displasment outerClothing"

This reverts commit 698fd688591a6c00a4cd19eebac7a204dce18e98.

* fix

* fix

* fix

* fix

* tweak: dwarf, Oni and Felenid now can choose slim body type

* add: outer displacement

* some fix

* some fix

* no more tags shitcode

* Reptilian body type

* harpy body type

* some fix

* rsi validator fix

* Update ClientClothingSystem.cs

* Update Model.cs

* Update MarkingManager.cs

* Update ClientClothingSystem.cs

* Update reptilian.yml
2025-03-03 18:03:18 +02:00

160 lines
6.5 KiB
C#

using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Preferences;
using Content.Shared.Verbs;
using Robust.Shared.GameObjects.Components.Localization;
namespace Content.Server.Humanoid;
public sealed partial class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem
{
[Dependency] private readonly MarkingManager _markingManager = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HumanoidAppearanceComponent, HumanoidMarkingModifierMarkingSetMessage>(OnMarkingsSet);
SubscribeLocalEvent<HumanoidAppearanceComponent, HumanoidMarkingModifierBaseLayersSetMessage>(OnBaseLayersSet);
SubscribeLocalEvent<HumanoidAppearanceComponent, GetVerbsEvent<Verb>>(OnVerbsRequest);
}
// this was done enough times that it only made sense to do it here
/// <summary>
/// Clones a humanoid's appearance to a target mob, provided they both have humanoid components.
/// </summary>
/// <param name="source">Source entity to fetch the original appearance from.</param>
/// <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, HumanoidAppearanceComponent? sourceHumanoid = null,
HumanoidAppearanceComponent? targetHumanoid = null)
{
if (!Resolve(source, ref sourceHumanoid) || !Resolve(target, ref targetHumanoid))
{
return;
}
targetHumanoid.Species = sourceHumanoid.Species;
targetHumanoid.SkinColor = sourceHumanoid.SkinColor;
targetHumanoid.EyeColor = sourceHumanoid.EyeColor;
targetHumanoid.Age = sourceHumanoid.Age;
SetTTSVoice(target, sourceHumanoid.Voice, humanoid:targetHumanoid); // WD EDIT
targetHumanoid.BodyType = sourceHumanoid.BodyType; // WD EDIT
targetHumanoid.Height = sourceHumanoid.Height;
targetHumanoid.Width = sourceHumanoid.Width;
SetSex(target, sourceHumanoid.Sex, false, targetHumanoid);
targetHumanoid.CustomBaseLayers = new(sourceHumanoid.CustomBaseLayers);
targetHumanoid.MarkingSet = new(sourceHumanoid.MarkingSet);
targetHumanoid.Gender = sourceHumanoid.Gender;
if (TryComp<GrammarComponent>(target, out var grammar))
{
grammar.Gender = sourceHumanoid.Gender;
}
targetHumanoid.LastProfileLoaded = sourceHumanoid.LastProfileLoaded;
Dirty(target, targetHumanoid);
}
/// <summary>
/// Removes a marking from a humanoid by ID.
/// </summary>
/// <param name="uid">Humanoid mob's UID</param>
/// <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, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid)
|| !_markingManager.Markings.TryGetValue(marking, out var prototype))
{
return;
}
humanoid.MarkingSet.Remove(prototype.MarkingCategory, marking);
if (sync)
Dirty(uid, humanoid);
}
/// <summary>
/// Removes a marking from a humanoid by category and index.
/// </summary>
/// <param name="uid">Humanoid mob's UID</param>
/// <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, HumanoidAppearanceComponent? humanoid = null)
{
if (index < 0
|| !Resolve(uid, ref humanoid)
|| !humanoid.MarkingSet.TryGetCategory(category, out var markings)
|| index >= markings.Count)
{
return;
}
humanoid.MarkingSet.Remove(category, index);
Dirty(uid, humanoid);
}
/// <summary>
/// Sets the marking ID of the humanoid in a category at an index in the category's list.
/// </summary>
/// <param name="uid">Humanoid mob's UID</param>
/// <param name="category">Category of the marking</param>
/// <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, HumanoidAppearanceComponent? humanoid = null)
{
if (index < 0
|| !_markingManager.MarkingsByCategory(category).TryGetValue(markingId, out var markingPrototype)
|| !Resolve(uid, ref humanoid)
|| !humanoid.MarkingSet.TryGetCategory(category, out var markings)
|| index >= markings.Count)
{
return;
}
var marking = markingPrototype.AsMarking();
for (var i = 0; i < marking.MarkingColors.Count && i < markings[index].MarkingColors.Count; i++)
{
marking.SetColor(i, markings[index].MarkingColors[i]);
}
humanoid.MarkingSet.Replace(category, index, marking);
Dirty(uid, humanoid);
}
/// <summary>
/// Sets the marking colors of the humanoid in a category at an index in the category's list.
/// </summary>
/// <param name="uid">Humanoid mob's UID</param>
/// <param name="category">Category of the marking</param>
/// <param name="index">Index of the marking</param>
/// <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,
HumanoidAppearanceComponent? humanoid = null)
{
if (index < 0
|| !Resolve(uid, ref humanoid)
|| !humanoid.MarkingSet.TryGetCategory(category, out var markings)
|| index >= markings.Count)
{
return;
}
for (var i = 0; i < markings[index].MarkingColors.Count && i < colors.Count; i++)
{
markings[index].SetColor(i, colors[i]);
}
Dirty(uid, humanoid);
}
}