Files
wwdpublic/Content.Shared/Humanoid/HumanoidAppearanceComponent.cs
sleepyyapril 529420cc05 Player Customization (#1626)
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

Adds cosmetic pronouns, visible through examining people (if they have
any) as a PushMarkup.
Adds Station AI/borg name customization.

CCVars:
customize.allow_cosmetic_pronouns (default false)
customize.allow_custom_station_ai_name (default false)
customize.allow_custom_cyborg_name (default false, for borgs, mediborgs,
etc)

---

# Changelog

<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

🆑
- add: Added cosmetic pronouns. (disabled by default)
- add: Added Station AI name customization through character
customization. (disabled by default)
- add: Added Cyborg name customization through character customization.
(disabled by default)

(cherry picked from commit 07fb6bc9a1a770f969bf44690676128970cb9eb7)
2025-01-23 08:08:54 +03:00

154 lines
4.8 KiB
C#

using Content.Shared._White.TTS;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Preferences; // DeltaV
using Robust.Shared.Enums;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Content.Shared.Preferences; //DeltaV, used for Metempsychosis, Fugitive, and Paradox Anomaly
namespace Content.Shared.Humanoid;
[NetworkedComponent, RegisterComponent, AutoGenerateComponentState(true)]
public sealed partial class HumanoidAppearanceComponent : Component
{
public MarkingSet ClientOldMarkings = new();
[DataField, AutoNetworkedField]
public MarkingSet MarkingSet = new();
[DataField]
public Dictionary<HumanoidVisualLayers, HumanoidSpeciesSpriteLayer> BaseLayers = new();
[DataField, AutoNetworkedField]
public HashSet<HumanoidVisualLayers> PermanentlyHidden = new();
// Couldn't these be somewhere else?
[DataField, AutoNetworkedField]
public Gender Gender;
[DataField, AutoNetworkedField]
public string? DisplayPronouns;
[DataField, AutoNetworkedField]
public string? StationAiName;
[DataField, AutoNetworkedField]
public string? CyborgName;
[DataField, AutoNetworkedField]
public int Age = 18;
[DataField, AutoNetworkedField]
public string CustomSpecieName = "";
/// <summary>
/// Any custom base layers this humanoid might have. See:
/// limb transplants (potentially), robotic arms, etc.
/// Stored on the server, this is merged in the client into
/// all layer settings.
/// </summary>
[DataField, AutoNetworkedField]
public Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> CustomBaseLayers = new();
/// <summary>
/// Current species. Dictates things like base body sprites,
/// base humanoid to spawn, etc.
/// </summary>
[DataField(required: true), AutoNetworkedField]
public ProtoId<SpeciesPrototype> Species { get; set; }
/// <summary>
/// The initial profile and base layers to apply to this humanoid.
/// </summary>
[DataField]
public ProtoId<HumanoidProfilePrototype>? Initial { get; private set; }
/// <summary>
/// Skin color of this humanoid.
/// </summary>
[DataField, AutoNetworkedField]
public Color SkinColor { get; set; } = Color.FromHex("#C0967F");
/// <summary>
/// Visual layers currently hidden. This will affect the base sprite
/// on this humanoid layer, and any markings that sit above it.
/// </summary>
[DataField, AutoNetworkedField]
public HashSet<HumanoidVisualLayers> HiddenLayers = new();
[DataField, AutoNetworkedField]
public Sex Sex = Sex.Male;
[DataField, AutoNetworkedField]
public Color EyeColor = Color.Brown;
/// <summary>
/// Hair color of this humanoid. Used to avoid looping through all markings
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public Color? CachedHairColor;
/// <summary>
/// Facial Hair color of this humanoid. Used to avoid looping through all markings
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public Color? CachedFacialHairColor;
/// <summary>
/// Which layers of this humanoid that should be hidden on equipping a corresponding item..
/// </summary>
[DataField]
public HashSet<HumanoidVisualLayers> HideLayersOnEquip = [HumanoidVisualLayers.Hair];
/// <summary>
/// DeltaV - let paradox anomaly be cloned
/// </summary>
[ViewVariables]
public HumanoidCharacterProfile? LastProfileLoaded;
/// <summary>
/// The height of this humanoid.
/// </summary>
[DataField, AutoNetworkedField]
public float Height = 1f;
/// <summary>
/// The width of this humanoid.
/// </summary>
[DataField, AutoNetworkedField]
public float Width = 1f;
// WD EDIT START
[DataField, AutoNetworkedField]
public ProtoId<TTSVoicePrototype> Voice { get; set; } = SharedHumanoidAppearanceSystem.DefaultVoice;
// WD EDIT END
}
[DataDefinition]
[Serializable, NetSerializable]
public readonly partial struct CustomBaseLayerInfo
{
public CustomBaseLayerInfo(string? id, Color? color = null)
{
DebugTools.Assert(id == null || IoCManager.Resolve<IPrototypeManager>().HasIndex<HumanoidSpeciesSpriteLayer>(id));
Id = id;
Color = color;
}
/// <summary>
/// ID of this custom base layer. Must be a <see cref="HumanoidSpeciesSpriteLayer"/>.
/// </summary>
[DataField]
public ProtoId<HumanoidSpeciesSpriteLayer>? Id { get; init; }
/// <summary>
/// Color of this custom base layer. Null implies skin colour if the corresponding <see cref="HumanoidSpeciesSpriteLayer"/> is set to match skin.
/// </summary>
[DataField]
public Color? Color { get; init; }
}