Humanoid appearance refactor (#10882)

* initial commit
- species prototype modifications
- markings points as its own file
- shared humanoid component

* adds a tool to convert sprite accessories to markings (in go)

* removes a fmt call

* converts sprite accessory to markings

* adds hair and facial hair to marking categories

* multiple changes
- humanoid visualizer system
- markings modifications for visualizer
- modifications to shared humanoid component
- lays out a base for humanoid system

* hidden layers, ports some properties from appearance component, shrinks DefaultMarkings a little

* squishes the initialize event calls into one function

adds stuff to set species/skin color externally from a server message - currently laid out as if it a dirty call to a networked component, may be subject to change (server-side has not been implemented yet)

* makes the sprite pipeline more obvious

* apply all markings, hidden layer set replacement

* ensures that markings are cleared when the new set is applied

* starts refactoring markingsset (unfinished)

* more additions to the markingset api

* adds constructor logic to markingset

* adds a method to filter out markings in a set based on a given species

* fixes enumerators in markingset

* adds validator into MarkingSet, fixes ForwardMarkingEnumerator

* modifications to the humanoid visual system

* ensuredefault in markingset

* oop

* fixes up data keys, populates OnAppearanceChange in visualizer

* changes to humanoid component, markings

marking equality is now more strict, humanoidcomponent is now implemented for client as a child of sharedhumanoidcomponent

* markings are now applied the visualizer by diffing them

* base sprites are now applied to humanoids from humanoidvisualizer

* passes along base sprite settings to the marking application so that markings know to follow skin color/alpha or not (see: slimes)

* custom base layers on humanoids

* merges all data keys into one data class for humanoid visualizers

* setappearance in sharedhumanoidsystem, removes custombaselayercolors

* humanoidcomponent, system (empty) in server

* adds some basic public API functions to HumanoidSystem

* add marking, remove marking

* changes appearance MarkingsSet to a List<Marking>, adds listener for PlayerSpawnCompleteEvent in HumanoidSystem

* ensuredefaultmarkings, oninit for humanoids

* markingmanager API changes

* removes MarkingsSet

* LoadProfile, adjusts randomization in humanoid appearance to account for species

* base layer settings in humanoidsystem, eye color from profile

* rearranges files to centralize under Humanoid namespace

* more reorganization, deletes some stuff

gotta break stuff to make other things work, right?

goodbye SpriteAccessory...

* fixes a good chunk of server-side issues

still does not compile, yet

* singlemarkingpicker xaml layout

* singlemarkingpicker logic

* magic mirror window (varying pieces of it, mostly client-oriented)

* removes some imports, gives MagicMirror a BUI class (not filled in yet)

* populates magic mirror BUI functionality / window callbacks

* fixes up some errors in humanoidprofileeditor

* changes to SingleMarkingPicker

SingleMarkingPicker now accepts a List<Marking>, species, and total possible markings available in that marking category

* fixes up hair pickers on humanoid profile editor

* fixes the errors in markingpicker

* markingsystem is now gone

* fixes a bunch of build errors

* so that's why i did it like that

* namespace issues, adds robustxamlloader to singlemarkingpicker

* another robustxamlloader

* human, lizard sprites/points

* prototype fixes, deletion of old spriteaccessory

* component registration, fixes dwarf skin toning

no, 'ReptilianToned' does not exist

* removes component registration from abstract humanoid component

* visualizer data now cloneable

* serialize for visualizer key

* zero-count edge case

* missing semi-colon moment

* setspecies in humanoidsystem

* ensures that default markings, if empty, will cause ensuredefault to skip over that given category

* tryadd instead of add

* whoops

* diff and apply should properly apply markings now

* always ensure default, fixes double load for player spawning

* apply skin color now sets the skin color property in humanoidcomponent

* removes sprite from a few species prototypes

* sprite changes for specific base layers based on humanoid sex

* layer ordering fix, and a missing base layer should now disallow markings on that layer

* anymarking base layer, adds the right leg/foot for humans

* loading a profile will now clear all markings on that humanoid

* adds missing layers for humans

* separates species.yml into respective species prototype files

* ensures that if layer visibility was changed, all markings have to be reapplied

* server-side enforcement of hiding hair (and other head-related markings) when equipping things that hide hair

* slime fix, clothingsystem now dictates layer visibility server side

* sussy

* layer settings should now ensure a marking should match the skin tone

* whoops

* skincolor static class and functions in UI

* skin color validation in humanoidcharacterappearance

* markingpicker now shows only the markings for the selected category in used

* getter for slot in singlemarkingpicker now ensures slot is 0 if markings exists

* FilterSpecies no longer attempts to do removal while iterating

* expands for SingleMarkingPicker

* humanoid base dummy has blank layers now (and snout/tail/headside/headtop)

* fixes an issue with visualizer system if the marking count was different but the markings themselves were (somewhat) the same

* whoops

* adds edge case handlers for count differences in humanoid markings

* preview now loads profile instead of directly setting appearance

* moves marking set loading to update controls

* clones a marking set in markingpicker by using the deep clone constructor

* whoops (deep cloning a marking now copies the marking id)

* adds replace function for markingset

* points should now update after the markings are remove/added

* merging base layer sprites into a humanoid should now clear them before merging

* sets dirty range start to count only if the dirty range start was never set above 0

* fixes up some issues with singlemarkingpicker

* color selector sliders in single marking picker should now expand

* hair from hair pickers should now apply in profile loading (client-side)

* category in singlemarkingpicker now sets the private category variable

* slot selector should now populate

* single marking picker buttons now have text, also shows the category name over all user-clickable elements

* removes a comment

* removing hair slots now sets it to bald, defaults to zero used slots if current hair is bald on hair/facial hair

* random skin color, eye color

* populate colors now checks if the marking count is greater than zero in singlemarkingpicker

* hair/facial hair pickers now just get the first possible hair from the respective species list

* different approach to random skin color

* oh, that's why it wasn't working

* randomize everything now just updates every single control

* selecting a new marking in SingleMarkingPicker should attempt to copy over old colors, populate list now uses cache,

* markingmanager now uses OnlyWhitelisted to populate by category and species

* filterspecies now uses onlyWhitelist to filter markings based on whitelist or not

* oops

* ui fix for singlemarkingpicker, ensures that cache is not null if it is null when populatelist is called

* order of operations for the horizontal expand for add/remove

* hair pickers should now update when you add/remove the hair slot

* fixes variable naming error in character appearance

* loc string fix in singlemarkingpicker

* lizards, vox now have onlyWhitelist, vox restriction for hair/facialhairs

* having zero possible hairs should no longer cause an exception in randomization

* setting species should now update hair pickers

* ignore categories for marking picker

* and a clear as well for the category button

* places that functionality in its own function instead

* adds eye base sprite, vox now also have their own custom eye sprites

* loading a profile client-side should do FilterSpecies for markings now

* client-side load profile does filter species after adding in the hairs now

* magic mirror

* callbacks now call the callback instead of adding it on construct

* whoops

* in removemarking too

* adds missing synchronize calls

* comments out an updateinterface call in magic mirror

* magic mirror window title, minimum sizing

* fixes minsize, adds warning for players who try to set their hair for species that have no hair

* removes spaces in xaml

* namespace changes/organization

* whoopsie (merge conflicts)

* re-enables identity from humanoid component

* damagevisuals now uses the enum given to it instead of the layerstate given on that layer tied to the enum

* removes commas from json

* changes to visuals system so the change is consistent

* chest

* reptilian

* visualizer system now handles body sprite setting/coloration, similar to how characterappearance did it

not a big fan of this

* adds a check in applybasesprites

* adding/removing parts should now make them invisible on a humanoid

* body part removal/adding now enumerates over sublayers instead

* synchro now runs in bodycomponent startup

* parts instead of slots

* humanoidcompnent check

* switches from rsi to actualrsi

* removes all the body stuff (too slow)

* cleans up resolves from humanoid visualizer system

* merging sprites now checks if the base sprites have been modified or not (through things like species changes, or custom base sprite changes)

* not forgetting that one again

* merging now returns an actual dirty value

* replaces the sequenceequal with a more accurate solution

* permanent layers, layer visibility on add/remove part in body

* should send all hidden layers over now

* isdirty in visualizer system for base layers

* isdirty checks count as well

* ok, IsDirty should now set the base layers if the merged sprites are different

* equals override in HumanoidSpritePrototypes.cs

temporary until record prototypes :heck:

* makes fields readonly, equates IDs instead

* adds forced markings through marking picker

* forced in humanoidsystem api, ignorespecies in markingpicker

* marking bui

* makes that serializable as well

* ignore species/forced toggles now work

* adds icon to modifier verb, interface and keys to humanoid bases

* needs the actual enum value to open, no?

* makes the key the actual key

* actions now propagate upwards

* ignore species when set now repopulates markingpicker

* modifiable base layers in the markings window

* oops!

* layout changes

* info box should now appear

* adds ignorespecies for marking picker, collapsible for base layer section of appearance modification window

* collapsible layout moment

* if base layers have changed, all markings are now dirty (and if a base layer is missing, the marking is still 'applied' but it's now just invisible

* small change to marking visibility

* small changes to modifier UI

* markings now match skin on zombification

* zombie stuff

* makes the line edit in marking modifier window more obvious

* disables vox on round start

* horizontal expand on the single label in base layer modifiers

* humanoid profiles in prototypes

* randomhumanoidappearance won't work if the humanoid has a profile already stored

* removes unused code

* documentation in humanoidsystem server-side

* documentation in shared/client

* whoops

* converts accessory into marking in locale files (also adds marking loc string into single marking picker)

* be gone, shared humanoid appearance system from the last upstream merge

* species ignore on randomization (defaults to no ignored species)

* more upstream merge parts that bypassed any errors before merge

* addresses review (also just adds typeserializers in some places)

* submodule moment

* upstream merge issues
This commit is contained in:
Flipp Syder
2022-09-22 15:19:00 -07:00
committed by GitHub
parent dd994e9ee1
commit 5a0a04bde7
184 changed files with 7667 additions and 5209 deletions

View File

@@ -1,269 +0,0 @@
using System;
using System.Linq;
using Content.Client.Stylesheets;
using Content.Shared.CharacterAppearance;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.Utility;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using static Content.Shared.CharacterAppearance.Components.SharedMagicMirrorComponent;
using static Robust.Client.UserInterface.Controls.BoxContainer;
namespace Content.Client.CharacterAppearance
{
[UsedImplicitly]
public sealed class MagicMirrorBoundUserInterface : BoundUserInterface
{
private MagicMirrorWindow? _window;
public MagicMirrorBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new MagicMirrorWindow(this);
_window.OnClose += Close;
_window.Open();
}
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
{
switch (message)
{
case MagicMirrorInitialDataMessage initialData:
_window?.SetInitialData(initialData);
break;
}
}
internal void HairSelected(string name, bool isFacialHair)
{
SendMessage(new HairSelectedMessage(name, isFacialHair));
}
internal void HairColorSelected(Color color, bool isFacialHair)
{
SendMessage(new HairColorSelectedMessage((color.RByte, color.GByte, color.BByte),
isFacialHair));
}
internal void EyeColorSelected(Color color)
{
SendMessage(new EyeColorSelectedMessage((color.RByte, color.GByte, color.BByte)));
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_window?.Dispose();
}
}
}
public sealed class HairStylePicker : Control
{
[Dependency] private readonly SpriteAccessoryManager _spriteAccessoryManager = default!;
public event Action<Color>? OnHairColorPicked;
public event Action<string>? OnHairStylePicked;
private readonly ItemList _items;
private readonly Control _colorContainer;
private readonly ColorSelectorSliders _colorSelectors;
private Color _lastColor;
private SpriteAccessoryCategories _categories;
public void SetData(Color color, string styleId, SpriteAccessoryCategories categories, bool canColor)
{
if (_categories != categories)
{
_categories = categories;
Populate();
}
_colorContainer.Visible = canColor;
_lastColor = color;
_colorSelectors.Color = color;
foreach (var item in _items)
{
var prototype = (SpriteAccessoryPrototype) item.Metadata!;
item.Selected = prototype.ID == styleId;
}
UpdateStylePickerColor();
}
private void UpdateStylePickerColor()
{
foreach (var item in _items)
{
item.IconModulate = _lastColor;
}
}
public HairStylePicker()
{
IoCManager.InjectDependencies(this);
var vBox = new BoxContainer
{
Orientation = LayoutOrientation.Vertical
};
AddChild(vBox);
_colorContainer = new BoxContainer
{
Orientation = LayoutOrientation.Vertical
};
vBox.AddChild(_colorContainer);
_colorContainer.AddChild(_colorSelectors = new ());
_colorSelectors.OnColorChanged += color => ColorValueChanged(color);
_items = new ItemList
{
VerticalExpand = true,
MinSize = (300, 250)
};
vBox.AddChild(_items);
_items.OnItemSelected += ItemSelected;
}
private void ColorValueChanged(Color newColor)
{
OnHairColorPicked?.Invoke(newColor);
_lastColor = newColor;
UpdateStylePickerColor();
}
public void Populate()
{
var styles = _spriteAccessoryManager
.AccessoriesForCategory(_categories)
.ToList();
styles.Sort(HairStyles.SpriteAccessoryComparer);
foreach (var style in styles)
{
var item = _items.AddItem(style.Name, style.Sprite.Frame0());
item.Metadata = style;
}
}
private void ItemSelected(ItemList.ItemListSelectedEventArgs args)
{
var prototype = (SpriteAccessoryPrototype?) _items[args.ItemIndex].Metadata;
var style = prototype?.ID;
if (style != null)
{
OnHairStylePicked?.Invoke(style);
}
}
// ColorSlider
}
public sealed class EyeColorPicker : Control
{
public event Action<Color>? OnEyeColorPicked;
private readonly ColorSelectorSliders _colorSelectors;
private Color _lastColor;
public void SetData(Color color)
{
_lastColor = color;
_colorSelectors.Color = color;
}
public EyeColorPicker()
{
var vBox = new BoxContainer
{
Orientation = LayoutOrientation.Vertical
};
AddChild(vBox);
vBox.AddChild(_colorSelectors = new ColorSelectorSliders());
_colorSelectors.OnColorChanged += ColorValueChanged;
}
private void ColorValueChanged(Color newColor)
{
OnEyeColorPicked?.Invoke(newColor);
_lastColor = newColor;
}
// ColorSlider
}
public sealed class MagicMirrorWindow : DefaultWindow
{
private readonly HairStylePicker _hairStylePicker;
private readonly HairStylePicker _facialHairStylePicker;
private readonly EyeColorPicker _eyeColorPicker;
public MagicMirrorWindow(MagicMirrorBoundUserInterface owner)
{
SetSize = MinSize = (500, 360);
Title = Loc.GetString("magic-mirror-window-title");
_hairStylePicker = new HairStylePicker {HorizontalExpand = true};
_hairStylePicker.OnHairStylePicked += newStyle => owner.HairSelected(newStyle, false);
_hairStylePicker.OnHairColorPicked += newColor => owner.HairColorSelected(newColor, false);
_facialHairStylePicker = new HairStylePicker {HorizontalExpand = true};
_facialHairStylePicker.OnHairStylePicked += newStyle => owner.HairSelected(newStyle, true);
_facialHairStylePicker.OnHairColorPicked += newColor => owner.HairColorSelected(newColor, true);
_eyeColorPicker = new EyeColorPicker { HorizontalExpand = true };
_eyeColorPicker.OnEyeColorPicked += newColor => owner.EyeColorSelected(newColor);
Contents.AddChild(new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
SeparationOverride = 8,
Children = {_hairStylePicker, _facialHairStylePicker, _eyeColorPicker}
});
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_hairStylePicker.Dispose();
_facialHairStylePicker.Dispose();
_eyeColorPicker.Dispose();
}
}
public void SetInitialData(MagicMirrorInitialDataMessage initialData)
{
_facialHairStylePicker.SetData(initialData.FacialHairColor, initialData.FacialHairId, initialData.CategoriesFacialHair, initialData.CanColorFacialHair);
_hairStylePicker.SetData(initialData.HairColor, initialData.HairId, initialData.CategoriesHair, initialData.CanColorHair);
_eyeColorPicker.SetData(initialData.EyeColor);
}
}
}

View File

@@ -1,165 +0,0 @@
using Content.Client.Cuffs.Components;
using Content.Shared.Body.Components;
using Content.Shared.CharacterAppearance;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.CharacterAppearance.Systems;
using Robust.Client.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.Client.CharacterAppearance.Systems
{
public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem
{
[Dependency] private readonly SpriteAccessoryManager _accessoryManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HumanoidAppearanceComponent, ChangedHumanoidAppearanceEvent>(UpdateLooks);
SubscribeLocalEvent<HumanoidAppearanceBodyPartAddedEvent>(BodyPartAdded);
SubscribeLocalEvent<HumanoidAppearanceBodyPartRemovedEvent>(BodyPartRemoved);
}
public readonly static HumanoidVisualLayers[] BodyPartLayers = {
HumanoidVisualLayers.Chest,
HumanoidVisualLayers.Head,
HumanoidVisualLayers.Snout,
HumanoidVisualLayers.HeadTop,
HumanoidVisualLayers.HeadSide,
HumanoidVisualLayers.Tail,
HumanoidVisualLayers.Eyes,
HumanoidVisualLayers.RArm,
HumanoidVisualLayers.LArm,
HumanoidVisualLayers.RHand,
HumanoidVisualLayers.LHand,
HumanoidVisualLayers.RLeg,
HumanoidVisualLayers.LLeg,
HumanoidVisualLayers.RFoot,
HumanoidVisualLayers.LFoot
};
private void UpdateLooks(EntityUid uid, HumanoidAppearanceComponent component,
ChangedHumanoidAppearanceEvent args)
{
var spriteQuery = EntityManager.GetEntityQuery<SpriteComponent>();
if (!spriteQuery.TryGetComponent(uid, out var sprite))
return;
if (EntityManager.TryGetComponent(uid, out SharedBodyComponent? body))
{
foreach (var (part, _) in body.Parts)
{
if (spriteQuery.TryGetComponent(part.Owner, out var partSprite))
{
partSprite.Color = component.Appearance.SkinColor;
}
}
}
// Like body parts some stuff may not have hair.
if (sprite.LayerMapTryGet(HumanoidVisualLayers.Hair, out var hairLayer))
{
var hairColor = component.CanColorHair ? component.Appearance.HairColor : Color.White;
hairColor = component.HairMatchesSkin ? component.Appearance.SkinColor : hairColor;
sprite.LayerSetColor(hairLayer, hairColor.WithAlpha(component.HairAlpha));
var hairStyle = component.Appearance.HairStyleId;
if (string.IsNullOrWhiteSpace(hairStyle) ||
!_accessoryManager.IsValidAccessoryInCategory(hairStyle, component.CategoriesHair))
{
hairStyle = HairStyles.DefaultHairStyle;
}
var hairPrototype = _prototypeManager.Index<SpriteAccessoryPrototype>(hairStyle);
sprite.LayerSetSprite(hairLayer, hairPrototype.Sprite);
}
if (sprite.LayerMapTryGet(HumanoidVisualLayers.FacialHair, out var facialLayer))
{
var facialHairColor = component.CanColorHair ? component.Appearance.FacialHairColor : Color.White;
facialHairColor = component.HairMatchesSkin ? component.Appearance.SkinColor : facialHairColor;
sprite.LayerSetColor(facialLayer, facialHairColor.WithAlpha(component.HairAlpha));
var facialHairStyle = component.Appearance.FacialHairStyleId;
if (string.IsNullOrWhiteSpace(facialHairStyle) ||
!_accessoryManager.IsValidAccessoryInCategory(facialHairStyle, component.CategoriesFacialHair))
{
facialHairStyle = HairStyles.DefaultFacialHairStyle;
}
var facialHairPrototype = _prototypeManager.Index<SpriteAccessoryPrototype>(facialHairStyle);
sprite.LayerSetSprite(facialLayer, facialHairPrototype.Sprite);
}
foreach (var layer in BodyPartLayers)
{
// Not every mob may have the furry layers hence we just skip it.
if (!sprite.LayerMapTryGet(layer, out var actualLayer)) continue;
if (!sprite[actualLayer].Visible) continue;
sprite.LayerSetColor(actualLayer, component.Appearance.SkinColor);
}
sprite.LayerSetColor(HumanoidVisualLayers.Eyes, component.Appearance.EyeColor);
sprite.LayerSetState(HumanoidVisualLayers.Chest, component.Sex == Sex.Male ? "torso_m" : "torso_f");
sprite.LayerSetState(HumanoidVisualLayers.Head, component.Sex == Sex.Male ? "head_m" : "head_f");
if (sprite.LayerMapTryGet(HumanoidVisualLayers.StencilMask, out _))
sprite.LayerSetVisible(HumanoidVisualLayers.StencilMask, component.Sex == Sex.Female);
if (EntityManager.TryGetComponent<CuffableComponent>(uid, out var cuffed))
{
sprite.LayerSetVisible(HumanoidVisualLayers.Handcuffs, !cuffed.CanStillInteract);
}
else
{
sprite.LayerSetVisible(HumanoidVisualLayers.Handcuffs, false);
}
}
// Scaffolding until Body is moved to ECS.
private void BodyPartAdded(HumanoidAppearanceBodyPartAddedEvent args)
{
if (!EntityManager.TryGetComponent(args.Uid, out SpriteComponent? sprite))
{
return;
}
if (!EntityManager.HasComponent<SpriteComponent>(args.Args.Part.Owner))
{
return;
}
var layers = args.Args.Part.ToHumanoidLayers();
// TODO BODY Layer color, sprite and state
foreach (var layer in layers)
{
if (!sprite.LayerMapTryGet(layer, out _))
continue;
sprite.LayerSetVisible(layer, true);
}
}
private void BodyPartRemoved(HumanoidAppearanceBodyPartRemovedEvent args)
{
if (!EntityManager.TryGetComponent(args.Uid, out SpriteComponent? sprite))
{
return;
}
if (!EntityManager.HasComponent<SpriteComponent>(args.Args.Part.Owner))
{
return;
}
var layers = args.Args.Part.ToHumanoidLayers();
// TODO BODY Layer color, sprite and state
foreach (var layer in layers)
sprite.LayerSetVisible(layer, false);
}
}
}

View File

@@ -2,9 +2,9 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Client.Inventory;
using Content.Shared.CharacterAppearance;
using Content.Shared.Clothing;
using Content.Shared.Clothing.Components;
using Content.Shared.Humanoid;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Shared.Item;
@@ -150,17 +150,6 @@ public sealed class ClothingVisualsSystem : EntitySystem
private void OnGotUnequipped(EntityUid uid, ClothingComponent component, GotUnequippedEvent args)
{
if (component.InSlot == "head"
&& _tagSystem.HasTag(uid, "HidesHair")
&& TryComp(args.Equipee, out SpriteComponent? sprite))
{
if (sprite.LayerMapTryGet(HumanoidVisualLayers.FacialHair, out var facial))
sprite[facial].Visible = true;
if (sprite.LayerMapTryGet(HumanoidVisualLayers.Hair, out var hair))
sprite[hair].Visible = true;
}
component.InSlot = null;
}
@@ -198,17 +187,6 @@ public sealed class ClothingVisualsSystem : EntitySystem
{
component.InSlot = args.Slot;
if (args.Slot == "head"
&& _tagSystem.HasTag(uid, "HidesHair")
&& TryComp(args.Equipee, out SpriteComponent? sprite))
{
if (sprite.LayerMapTryGet(HumanoidVisualLayers.FacialHair, out var facial))
sprite[facial].Visible = false;
if (sprite.LayerMapTryGet(HumanoidVisualLayers.Hair, out var hair))
sprite[hair].Visible = false;
}
RenderEquipment(args.Equipee, uid, args.Slot, clothingComponent: component);
}

View File

@@ -1,6 +1,6 @@
using Content.Shared.ActionBlocker;
using Content.Shared.CharacterAppearance;
using Content.Shared.Cuffs.Components;
using Content.Shared.Humanoid;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.GameObjects;

View File

@@ -230,8 +230,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
// the layer key just doesn't exist, we skip it.
foreach (var key in damageVisComp.TargetLayers)
{
if (!spriteComponent.LayerMapTryGet(key, out var index)
|| spriteComponent.LayerGetState(index).ToString() == null)
if (!spriteComponent.LayerMapTryGet(key, out var index))
{
Logger.WarningS(SawmillName, $"Layer at key {key} was invalid for entity {entity}.");
continue;
@@ -253,18 +252,18 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
// Otherwise, we start reserving layers. Since the filtering
// loop above ensures that all of these layers are not null,
// and have valid state IDs, there should be no issues.
foreach (object layer in damageVisComp.TargetLayerMapKeys)
foreach (var layer in damageVisComp.TargetLayerMapKeys)
{
var layerCount = spriteComponent.AllLayers.Count();
var index = spriteComponent.LayerMapGet(layer);
var layerState = spriteComponent.LayerGetState(index).ToString()!;
// var layerState = spriteComponent.LayerGetState(index).ToString()!;
if (index + 1 != layerCount)
{
index += 1;
}
damageVisComp.LayerMapKeyStates.Add(layer, layerState);
damageVisComp.LayerMapKeyStates.Add(layer, layer.ToString());
// If we're an overlay, and we're targeting groups,
// we reserve layers per damage group.
@@ -274,7 +273,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{
AddDamageLayerToSprite(spriteComponent,
sprite,
$"{layerState}_{group}_{damageVisComp.Thresholds[1]}",
$"{layer}_{group}_{damageVisComp.Thresholds[1]}",
$"{layer}{group}",
index);
}
@@ -288,7 +287,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{
AddDamageLayerToSprite(spriteComponent,
damageVisComp.DamageOverlay,
$"{layerState}_{damageVisComp.Thresholds[1]}",
$"{layer}_{damageVisComp.Thresholds[1]}",
$"{layer}trackDamage",
index);
damageVisComp.DisabledLayers.Add(layer, false);

View File

@@ -0,0 +1,40 @@
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.Humanoid;
public sealed class EyeColorPicker : Control
{
public event Action<Color>? OnEyeColorPicked;
private readonly ColorSelectorSliders _colorSelectors;
private Color _lastColor;
public void SetData(Color color)
{
_lastColor = color;
_colorSelectors.Color = color;
}
public EyeColorPicker()
{
var vBox = new BoxContainer
{
Orientation = BoxContainer.LayoutOrientation.Vertical
};
AddChild(vBox);
vBox.AddChild(_colorSelectors = new ColorSelectorSliders());
_colorSelectors.OnColorChanged += ColorValueChanged;
}
private void ColorValueChanged(Color newColor)
{
OnEyeColorPicked?.Invoke(newColor);
_lastColor = newColor;
}
}

View File

@@ -0,0 +1,15 @@
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes;
namespace Content.Client.Humanoid;
[RegisterComponent]
public sealed class HumanoidComponent : SharedHumanoidComponent
{
[ViewVariables] public List<Marking> CurrentMarkings = new();
public Dictionary<HumanoidVisualLayers, HumanoidSpeciesSpriteLayer> BaseLayers = new();
public string LastSpecies = default!;
}

View File

@@ -0,0 +1,62 @@
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Robust.Client.GameObjects;
namespace Content.Client.Humanoid;
// Marking BUI.
// Do not use this in any non-privileged instance. This just replaces an entire marking set
// with the set sent over.
public sealed class HumanoidMarkingModifierBoundUserInterface : BoundUserInterface
{
public HumanoidMarkingModifierBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{
}
private HumanoidMarkingModifierWindow? _window;
protected override void Open()
{
base.Open();
_window = new();
_window.OnClose += Close;
_window.OnMarkingAdded += SendMarkingSet;
_window.OnMarkingRemoved += SendMarkingSet;
_window.OnMarkingColorChange += SendMarkingSetNoResend;
_window.OnMarkingRankChange += SendMarkingSet;
_window.OnLayerInfoModified += SendBaseLayer;
_window.OpenCenteredLeft();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (_window == null || state is not HumanoidMarkingModifierState cast)
{
return;
}
_window.SetState(cast.MarkingSet, cast.Species, cast.SkinColor, cast.CustomBaseLayers);
}
private void SendMarkingSet(MarkingSet set)
{
SendMessage(new HumanoidMarkingModifierMarkingSetMessage(set, true));
}
private void SendMarkingSetNoResend(MarkingSet set)
{
SendMessage(new HumanoidMarkingModifierMarkingSetMessage(set, false));
}
private void SendBaseLayer(HumanoidVisualLayers layer, CustomBaseLayerInfo? info)
{
SendMessage(new HumanoidMarkingModifierBaseLayersSetMessage(layer, info, true));
}
}

View File

@@ -0,0 +1,18 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:humanoid="clr-namespace:Content.Client.Humanoid">
<ScrollContainer MinHeight="500" MinWidth="700">
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<humanoid:MarkingPicker Name="MarkingPickerWidget" />
<BoxContainer>
<CheckBox Name="MarkingForced" Text="Force" Pressed="True" />
<CheckBox Name="MarkingIgnoreSpecies" Text="Ignore Species" Pressed="True" />
</BoxContainer>
<Collapsible Orientation="Vertical" HorizontalExpand="True">
<CollapsibleHeading Title="Base layers" />
<CollapsibleBody HorizontalExpand="True">
<BoxContainer Name="BaseLayersContainer" Orientation="Vertical" HorizontalExpand="True" />
</CollapsibleBody>
</Collapsible>
</BoxContainer>
</ScrollContainer>
</DefaultWindow>

View File

@@ -0,0 +1,138 @@
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.Humanoid;
// hack for a panel that modifies an entity's markings on demand
[GenerateTypedNameReferences]
public sealed partial class HumanoidMarkingModifierWindow : DefaultWindow
{
public Action<MarkingSet>? OnMarkingAdded;
public Action<MarkingSet>? OnMarkingRemoved;
public Action<MarkingSet>? OnMarkingColorChange;
public Action<MarkingSet>? OnMarkingRankChange;
public Action<HumanoidVisualLayers, CustomBaseLayerInfo?>? OnLayerInfoModified;
private readonly Dictionary<HumanoidVisualLayers, HumanoidBaseLayerModifier> _modifiers = new();
public HumanoidMarkingModifierWindow()
{
RobustXamlLoader.Load(this);
foreach (var layer in Enum.GetValues<HumanoidVisualLayers>())
{
var modifier = new HumanoidBaseLayerModifier(layer);
BaseLayersContainer.AddChild(modifier);
_modifiers.Add(layer, modifier);
modifier.OnStateChanged += delegate
{
OnLayerInfoModified!(
layer,
modifier.Enabled
? new CustomBaseLayerInfo(modifier.State, modifier.Color)
: null);
};
}
MarkingPickerWidget.OnMarkingAdded += set => OnMarkingAdded!(set);
MarkingPickerWidget.OnMarkingRemoved += set => OnMarkingRemoved!(set);
MarkingPickerWidget.OnMarkingColorChange += set => OnMarkingColorChange!(set);
MarkingPickerWidget.OnMarkingRankChange += set => OnMarkingRankChange!(set);
MarkingForced.OnToggled += args => MarkingPickerWidget.Forced = args.Pressed;
MarkingIgnoreSpecies.OnToggled += args => MarkingPickerWidget.Forced = args.Pressed;
MarkingPickerWidget.Forced = MarkingForced.Pressed;
MarkingPickerWidget.IgnoreSpecies = MarkingForced.Pressed;
}
public void SetState(MarkingSet markings, string species, Color skinColor, Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> info)
{
MarkingPickerWidget.SetData(markings, species, skinColor);
foreach (var (layer, modifier) in _modifiers)
{
if (!info.TryGetValue(layer, out var layerInfo))
{
modifier.SetState(false, string.Empty, Color.White);
continue;
}
modifier.SetState(true, layerInfo.ID, layerInfo.Color);
}
}
private sealed class HumanoidBaseLayerModifier : BoxContainer
{
private CheckBox _enable;
private LineEdit _lineEdit;
private ColorSelectorSliders _colorSliders;
private BoxContainer _infoBox;
public bool Enabled => _enable.Pressed;
public string State => _lineEdit.Text;
public Color Color => _colorSliders.Color;
public Action? OnStateChanged;
public HumanoidBaseLayerModifier(HumanoidVisualLayers layer)
{
HorizontalExpand = true;
Orientation = LayoutOrientation.Vertical;
var labelBox = new BoxContainer
{
MinWidth = 250,
HorizontalExpand = true
};
AddChild(labelBox);
labelBox.AddChild(new Label
{
HorizontalExpand = true,
Text = layer.ToString()
});
_enable = new CheckBox
{
Text = "Enable",
HorizontalAlignment = HAlignment.Right
};
labelBox.AddChild(_enable);
_infoBox = new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
Visible = false
};
_enable.OnToggled += args =>
{
_infoBox.Visible = args.Pressed;
OnStateChanged!();
};
var lineEditBox = new BoxContainer();
lineEditBox.AddChild(new Label { Text = "Prototype id: "});
_lineEdit = new();
_lineEdit.OnTextEntered += args => OnStateChanged!();
lineEditBox.AddChild(_lineEdit);
_infoBox.AddChild(lineEditBox);
_colorSliders = new();
_colorSliders.OnColorChanged += color => OnStateChanged!();
_infoBox.AddChild(_colorSliders);
AddChild(_infoBox);
}
public void SetState(bool enabled, string state, Color color)
{
_enable.Pressed = enabled;
_infoBox.Visible = enabled;
_lineEdit.Text = state;
_colorSliders.Color = color;
}
}
}

View File

@@ -0,0 +1,63 @@
using System.Linq;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Preferences;
using Robust.Shared.Prototypes;
namespace Content.Client.Humanoid;
public sealed class HumanoidSystem : SharedHumanoidSystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly MarkingManager _markingManager = default!;
/// <summary>
/// Loads a profile directly into a humanoid.
/// </summary>
/// <param name="uid">The humanoid entity's UID</param>
/// <param name="profile">The profile to load.</param>
/// <param name="humanoid">The humanoid entity's humanoid component.</param>
/// <remarks>
/// 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, HumanoidComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid))
{
return;
}
humanoid.Species = profile.Species;
var customBaseLayers = new Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo>
{
[HumanoidVisualLayers.Eyes] = new CustomBaseLayerInfo(string.Empty, profile.Appearance.EyeColor)
};
var speciesPrototype = _prototypeManager.Index<SpeciesPrototype>(profile.Species);
var markings = new MarkingSet(profile.Appearance.Markings, speciesPrototype.MarkingPoints, _markingManager,
_prototypeManager);
markings.EnsureDefault(profile.Appearance.SkinColor, _markingManager);
// legacy: remove in the future?
markings.RemoveCategory(MarkingCategories.Hair);
markings.RemoveCategory(MarkingCategories.FacialHair);
var hair = new Marking(profile.Appearance.HairStyleId, new[] { profile.Appearance.HairColor });
markings.AddBack(MarkingCategories.Hair, hair);
var facialHair = new Marking(profile.Appearance.FacialHairStyleId,
new[] { profile.Appearance.FacialHairColor });
markings.AddBack(MarkingCategories.FacialHair, facialHair);
markings.FilterSpecies(profile.Species, _markingManager, _prototypeManager);
SetAppearance(uid,
profile.Species,
customBaseLayers,
profile.Appearance.SkinColor,
new(), // doesn't exist yet
markings.GetForwardEnumerator().ToList());
}
}

View File

@@ -0,0 +1,447 @@
using System.Linq;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Client.Humanoid;
public sealed class HumanoidVisualizerSystem : VisualizerSystem<HumanoidComponent>
{
[Dependency] private IPrototypeManager _prototypeManager = default!;
[Dependency] private MarkingManager _markingManager = default!;
protected override void OnAppearanceChange(EntityUid uid, HumanoidComponent component, ref AppearanceChangeEvent args)
{
base.OnAppearanceChange(uid, component, ref args);
if (args.Sprite == null)
{
return;
}
if (!args.AppearanceData.TryGetValue(HumanoidVisualizerKey.Key, out var dataRaw)
|| dataRaw is not HumanoidVisualizerData data)
{
return;
}
if (!_prototypeManager.TryIndex(data.Species, out SpeciesPrototype? speciesProto)
|| !_prototypeManager.TryIndex(speciesProto.SpriteSet, out HumanoidSpeciesBaseSpritesPrototype? baseSprites))
{
return;
}
bool dirty;
if (data.CustomBaseLayerInfo.Count != 0)
{
dirty = MergeCustomBaseSprites(uid, baseSprites.Sprites, data.CustomBaseLayerInfo, component);
}
else
{
dirty = MergeCustomBaseSprites(uid, baseSprites.Sprites, null, component);
}
if (dirty)
{
ApplyBaseSprites(uid, component, args.Sprite);
ApplySkinColor(uid, data.SkinColor, component, args.Sprite);
}
if (data.CustomBaseLayerInfo.Count != 0)
{
foreach (var (layer, info) in data.CustomBaseLayerInfo)
{
SetBaseLayerColor(uid, layer, info.Color, args.Sprite);
}
}
var layerVis = data.LayerVisibility.ToHashSet();
dirty |= ReplaceHiddenLayers(uid, layerVis, component, args.Sprite);
DiffAndApplyMarkings(uid, data.Markings, dirty, component, args.Sprite);
}
private bool ReplaceHiddenLayers(EntityUid uid, HashSet<HumanoidVisualLayers> hiddenLayers,
HumanoidComponent humanoid, SpriteComponent sprite)
{
if (hiddenLayers.SetEquals(humanoid.HiddenLayers))
{
return false;
}
SetSpriteVisibility(uid, hiddenLayers, false, sprite);
humanoid.HiddenLayers.ExceptWith(hiddenLayers);
SetSpriteVisibility(uid, humanoid.HiddenLayers, true, sprite);
humanoid.HiddenLayers.Clear();
humanoid.HiddenLayers.UnionWith(hiddenLayers);
return true;
}
private void SetSpriteVisibility(EntityUid uid, HashSet<HumanoidVisualLayers> layers, bool visibility, SpriteComponent sprite)
{
foreach (var layer in layers)
{
if (!sprite.LayerMapTryGet(layer, out var index))
{
continue;
}
sprite[index].Visible = visibility;
}
}
private void DiffAndApplyMarkings(EntityUid uid,
List<Marking> newMarkings,
bool layersDirty,
HumanoidComponent humanoid,
SpriteComponent sprite)
{
// skip this entire thing if both sets are empty
if (humanoid.CurrentMarkings.Count == 0 && newMarkings.Count == 0)
{
return;
}
var dirtyMarkings = new List<int>();
var dirtyRangeStart = humanoid.CurrentMarkings.Count == 0 ? 0 : -1;
// edge cases:
// humanoid.CurrentMarkings < newMarkings.Count
// - check if count matches this condition before diffing
// - if count is unequal, set dirty range to start from humanoid.CurrentMarkings.Count
// humanoid.CurrentMarkings > newMarkings.Count, no dirty markings
// - break count upon meeting this condition
// - clear markings from newMarkings.Count to humanoid.CurrentMarkings.Count - newMarkings.Count
for (var i = 0; i < humanoid.CurrentMarkings.Count; i++)
{
// if we've reached the end of the new set of markings,
// then that means it's time to finish
if (newMarkings.Count == i)
{
break;
}
// if the marking is different here, set the range start to i and break, we need
// to rebuild all markings starting from i
if (humanoid.CurrentMarkings[i].MarkingId != newMarkings[i].MarkingId)
{
dirtyRangeStart = i;
break;
}
// otherwise, we add the current marking to dirtyMarkings if it has different
// settings
// however: if the hidden layers are set to dirty, then we need to
// instead just add every single marking, since we don't know ahead of time
// where these markings go
if (humanoid.CurrentMarkings[i] != newMarkings[i] || layersDirty)
{
dirtyMarkings.Add(i);
}
}
foreach (var i in dirtyMarkings)
{
if (!_markingManager.TryGetMarking(newMarkings[i], out var dirtyMarking))
{
continue;
}
ApplyMarking(uid, dirtyMarking, newMarkings[i].MarkingColors, newMarkings[i].Visible, humanoid, sprite);
}
if (humanoid.CurrentMarkings.Count < newMarkings.Count && dirtyRangeStart < 0)
{
dirtyRangeStart = humanoid.CurrentMarkings.Count;
}
if (dirtyRangeStart >= 0)
{
var range = newMarkings.GetRange(dirtyRangeStart, newMarkings.Count - dirtyRangeStart);
if (humanoid.CurrentMarkings.Count > 0)
{
var oldRange = humanoid.CurrentMarkings.GetRange(dirtyRangeStart, humanoid.CurrentMarkings.Count - dirtyRangeStart);
ClearMarkings(uid, oldRange, humanoid, sprite);
}
ApplyMarkings(uid, range, humanoid, sprite);
}
else if (humanoid.CurrentMarkings.Count != newMarkings.Count)
{
if (newMarkings.Count == 0)
{
ClearAllMarkings(uid, humanoid, sprite);
}
else if (humanoid.CurrentMarkings.Count > newMarkings.Count)
{
var rangeStart = newMarkings.Count;
var rangeCount = humanoid.CurrentMarkings.Count - newMarkings.Count;
var range = humanoid.CurrentMarkings.GetRange(rangeStart, rangeCount);
ClearMarkings(uid, range, humanoid, sprite);
}
}
if (dirtyMarkings.Count > 0 || dirtyRangeStart >= 0 || humanoid.CurrentMarkings.Count != newMarkings.Count)
{
humanoid.CurrentMarkings = newMarkings;
}
}
private void ClearAllMarkings(EntityUid uid, HumanoidComponent humanoid,
SpriteComponent spriteComp)
{
ClearMarkings(uid, humanoid.CurrentMarkings, humanoid, spriteComp);
}
private void ClearMarkings(EntityUid uid, List<Marking> markings, HumanoidComponent humanoid,
SpriteComponent spriteComp)
{
foreach (var marking in markings)
{
RemoveMarking(uid, marking, spriteComp);
}
}
private void RemoveMarking(EntityUid uid, Marking marking,
SpriteComponent spriteComp)
{
if (!_markingManager.TryGetMarking(marking, out var prototype))
{
return;
}
foreach (var sprite in prototype.Sprites)
{
if (sprite is not SpriteSpecifier.Rsi rsi)
{
continue;
}
var layerId = $"{marking.MarkingId}-{rsi.RsiState}";
if (!spriteComp.LayerMapTryGet(layerId, out var index))
{
continue;
}
spriteComp.LayerMapRemove(layerId);
spriteComp.RemoveLayer(index);
}
}
private void ApplyMarkings(EntityUid uid,
List<Marking> markings,
HumanoidComponent humanoid,
SpriteComponent spriteComp)
{
foreach (var marking in new ReverseMarkingEnumerator(markings))
{
if (!_markingManager.TryGetMarking(marking, out var markingPrototype))
{
continue;
}
ApplyMarking(uid, markingPrototype, marking.MarkingColors, marking.Visible, humanoid, spriteComp);
}
}
private void ApplyMarking(EntityUid uid,
MarkingPrototype markingPrototype,
IReadOnlyList<Color>? colors,
bool visible,
HumanoidComponent humanoid,
SpriteComponent sprite)
{
if (!sprite.LayerMapTryGet(markingPrototype.BodyPart, out int targetLayer))
{
return;
}
visible &= !humanoid.HiddenLayers.Contains(markingPrototype.BodyPart);
visible &= humanoid.BaseLayers.TryGetValue(markingPrototype.BodyPart, out var setting)
&& setting.AllowsMarkings;
for (var j = 0; j < markingPrototype.Sprites.Count; j++)
{
if (markingPrototype.Sprites[j] is not SpriteSpecifier.Rsi rsi)
{
continue;
}
var layerId = $"{markingPrototype.ID}-{rsi.RsiState}";
if (!sprite.LayerMapTryGet(layerId, out _))
{
var layer = sprite.AddLayer(markingPrototype.Sprites[j], targetLayer + j + 1);
sprite.LayerMapSet(layerId, layer);
sprite.LayerSetSprite(layerId, rsi);
}
sprite.LayerSetVisible(layerId, visible);
if (!visible || setting == null) // this is kinda implied
{
continue;
}
if (markingPrototype.FollowSkinColor || colors == null || setting.MarkingsMatchSkin)
{
var skinColor = humanoid.SkinColor;
skinColor.A = setting.LayerAlpha;
sprite.LayerSetColor(layerId, skinColor);
}
else
{
sprite.LayerSetColor(layerId, colors[j]);
}
}
}
private void ApplySkinColor(EntityUid uid,
Color skinColor,
HumanoidComponent humanoid,
SpriteComponent spriteComp)
{
humanoid.SkinColor = skinColor;
foreach (var (layer, spriteInfo) in humanoid.BaseLayers)
{
if (!spriteInfo.MatchSkin)
{
continue;
}
var color = skinColor;
color.A = spriteInfo.LayerAlpha;
SetBaseLayerColor(uid, layer, color, spriteComp);
}
}
private void SetBaseLayerColor(EntityUid uid, HumanoidVisualLayers layer, Color color,
SpriteComponent sprite)
{
if (!sprite.LayerMapTryGet(layer, out var index))
{
return;
}
sprite[index].Color = color;
}
private bool MergeCustomBaseSprites(EntityUid uid, Dictionary<HumanoidVisualLayers, string> baseSprites,
Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo>? customBaseSprites,
HumanoidComponent humanoid)
{
var newBaseLayers = new Dictionary<HumanoidVisualLayers, HumanoidSpeciesSpriteLayer>();
foreach (var (key, id) in baseSprites)
{
var sexMorph = humanoid.Sex switch
{
Sex.Male when HumanoidVisualLayersExtension.HasSexMorph(key) => $"{id}Male",
Sex.Female when HumanoidVisualLayersExtension.HasSexMorph(key) => $"{id}Female",
_ => id
};
if (!_prototypeManager.TryIndex(sexMorph, out HumanoidSpeciesSpriteLayer? baseLayer))
{
continue;
}
if (!newBaseLayers.TryAdd(key, baseLayer))
{
newBaseLayers[key] = baseLayer;
}
}
if (customBaseSprites == null)
{
return IsDirty(newBaseLayers);
}
foreach (var (key, info) in customBaseSprites)
{
if (!_prototypeManager.TryIndex(info.ID, out HumanoidSpeciesSpriteLayer? baseLayer))
{
continue;
}
if (!newBaseLayers.TryAdd(key, baseLayer))
{
newBaseLayers[key] = baseLayer;
}
}
bool IsDirty(Dictionary<HumanoidVisualLayers, HumanoidSpeciesSpriteLayer> newBaseLayers)
{
var dirty = false;
if (humanoid.BaseLayers.Count != newBaseLayers.Count)
{
dirty = true;
humanoid.BaseLayers = newBaseLayers;
return dirty;
}
foreach (var (key, info) in humanoid.BaseLayers)
{
if (!newBaseLayers.TryGetValue(key, out var newInfo))
{
dirty = true;
break;
}
if (info.ID != newInfo.ID)
{
dirty = true;
break;
}
}
if (dirty)
{
humanoid.BaseLayers = newBaseLayers;
}
return dirty;
}
return IsDirty(newBaseLayers);
}
private void ApplyBaseSprites(EntityUid uid,
HumanoidComponent humanoid,
SpriteComponent spriteComp)
{
foreach (var (layer, spriteInfo) in humanoid.BaseLayers)
{
if (spriteInfo.BaseSprite != null && spriteComp.LayerMapTryGet(layer, out var index))
{
switch (spriteInfo.BaseSprite)
{
case SpriteSpecifier.Rsi rsi:
spriteComp.LayerSetRSI(index, rsi.RsiPath);
spriteComp.LayerSetState(index, rsi.RsiState);
break;
case SpriteSpecifier.Texture texture:
spriteComp.LayerSetTexture(index, texture.TexturePath);
break;
}
}
}
}
}

View File

@@ -0,0 +1,463 @@
using System.Linq;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Client.Utility;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using static Robust.Client.UserInterface.Controls.BoxContainer;
namespace Content.Client.Humanoid;
[GenerateTypedNameReferences]
public sealed partial class MarkingPicker : Control
{
[Dependency] private readonly MarkingManager _markingManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public Action<MarkingSet>? OnMarkingAdded;
public Action<MarkingSet>? OnMarkingRemoved;
public Action<MarkingSet>? OnMarkingColorChange;
public Action<MarkingSet>? OnMarkingRankChange;
private List<Color> _currentMarkingColors = new();
private ItemList.Item? _selectedMarking;
private ItemList.Item? _selectedUnusedMarking;
private MarkingCategories _selectedMarkingCategory = MarkingCategories.Chest;
private MarkingSet _currentMarkings = new();
private List<MarkingCategories> _markingCategories = Enum.GetValues<MarkingCategories>().ToList();
private string _currentSpecies = SharedHumanoidSystem.DefaultSpecies;
public Color CurrentSkinColor = Color.White;
private readonly HashSet<MarkingCategories> _ignoreCategories = new();
public string IgnoreCategories
{
get => string.Join(',', _ignoreCategories);
set
{
_ignoreCategories.Clear();
var split = value.Split(',');
foreach (var category in split)
{
if (!Enum.TryParse(category, out MarkingCategories categoryParse))
{
continue;
}
_ignoreCategories.Add(categoryParse);
}
SetupCategoryButtons();
}
}
public bool Forced { get; set; }
private bool _ignoreSpecies;
public bool IgnoreSpecies
{
get => _ignoreSpecies;
set
{
_ignoreSpecies = value;
Populate();
}
}
public void SetData(List<Marking> newMarkings, string species, Color skinColor)
{
var pointsProto = _prototypeManager
.Index<SpeciesPrototype>(species).MarkingPoints;
_currentMarkings = new(newMarkings, pointsProto, _markingManager);
if (!IgnoreSpecies)
{
_currentMarkings.FilterSpecies(species); // should be validated server-side but it can't hurt
}
_currentSpecies = species;
CurrentSkinColor = skinColor;
Populate();
PopulateUsed();
}
public void SetData(MarkingSet set, string species, Color skinColor)
{
_currentMarkings = set;
if (!IgnoreSpecies)
{
_currentMarkings.FilterSpecies(species); // should be validated server-side but it can't hurt
}
_currentSpecies = species;
CurrentSkinColor = skinColor;
Populate();
PopulateUsed();
}
public void SetSkinColor(Color color) => CurrentSkinColor = color;
public MarkingPicker()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
SetupCategoryButtons();
CMarkingCategoryButton.OnItemSelected += OnCategoryChange;
CMarkingsUnused.OnItemSelected += item =>
_selectedUnusedMarking = CMarkingsUnused[item.ItemIndex];
CMarkingAdd.OnPressed += args =>
MarkingAdd();
CMarkingsUsed.OnItemSelected += OnUsedMarkingSelected;
CMarkingRemove.OnPressed += args =>
MarkingRemove();
CMarkingRankUp.OnPressed += _ => SwapMarkingUp();
CMarkingRankDown.OnPressed += _ => SwapMarkingDown();
}
private void SetupCategoryButtons()
{
CMarkingCategoryButton.Clear();
for (var i = 0; i < _markingCategories.Count; i++)
{
if (_ignoreCategories.Contains(_markingCategories[i]))
{
continue;
}
CMarkingCategoryButton.AddItem(Loc.GetString($"markings-category-{_markingCategories[i].ToString()}"), i);
}
CMarkingCategoryButton.SelectId(_markingCategories.IndexOf(_selectedMarkingCategory));
}
private string GetMarkingName(MarkingPrototype marking) => Loc.GetString($"marking-{marking.ID}");
private List<string> GetMarkingStateNames(MarkingPrototype marking)
{
List<string> result = new();
foreach (var markingState in marking.Sprites)
{
switch (markingState)
{
case SpriteSpecifier.Rsi rsi:
result.Add(Loc.GetString($"marking-{marking.ID}-{rsi.RsiState}"));
break;
case SpriteSpecifier.Texture texture:
result.Add(Loc.GetString($"marking-{marking.ID}-{texture.TexturePath.Filename}"));
break;
}
}
return result;
}
public void Populate()
{
CMarkingsUnused.Clear();
_selectedUnusedMarking = null;
var markings = IgnoreSpecies
? _markingManager.MarkingsByCategory(_selectedMarkingCategory)
: _markingManager.MarkingsByCategoryAndSpecies(_selectedMarkingCategory, _currentSpecies);
foreach (var marking in markings.Values)
{
if (_currentMarkings.TryGetCategory(_selectedMarkingCategory, out var listing)
&& listing.Contains(marking.AsMarking()))
{
continue;
}
var item = CMarkingsUnused.AddItem($"{GetMarkingName(marking)}", marking.Sprites[0].Frame0());
item.Metadata = marking;
}
CMarkingPoints.Visible = _currentMarkings.PointsLeft(_selectedMarkingCategory) != -1;
}
// Populate the used marking list. Returns a list of markings that weren't
// valid to add to the marking list.
public void PopulateUsed()
{
CMarkingsUsed.Clear();
CMarkingColors.Visible = false;
_selectedMarking = null;
if (!IgnoreSpecies)
{
_currentMarkings.FilterSpecies(_currentSpecies, _markingManager);
}
// walk backwards through the list for visual purposes
foreach (var marking in _currentMarkings.GetReverseEnumerator(_selectedMarkingCategory))
{
if (!_markingManager.TryGetMarking(marking, out var newMarking))
{
continue;
}
var text = Loc.GetString(marking.Forced ? "marking-used-forced" : "marking-used", ("marking-name", $"{GetMarkingName(newMarking)}"),
("marking-category", Loc.GetString($"markings-category-{newMarking.MarkingCategory}")));
var _item = new ItemList.Item(CMarkingsUsed)
{
Text = text,
Icon = newMarking.Sprites[0].Frame0(),
Selectable = true,
Metadata = newMarking,
IconModulate = marking.MarkingColors[0]
};
CMarkingsUsed.Add(_item);
}
// since all the points have been processed, update the points visually
UpdatePoints();
}
private void SwapMarkingUp()
{
if (_selectedMarking == null)
{
return;
}
var i = CMarkingsUsed.IndexOf(_selectedMarking);
if (ShiftMarkingRank(i, -1))
{
OnMarkingRankChange?.Invoke(_currentMarkings);
}
}
private void SwapMarkingDown()
{
if (_selectedMarking == null)
{
return;
}
var i = CMarkingsUsed.IndexOf(_selectedMarking);
if (ShiftMarkingRank(i, 1))
{
OnMarkingRankChange?.Invoke(_currentMarkings);
}
}
private bool ShiftMarkingRank(int src, int places)
{
if (src + places >= CMarkingsUsed.Count || src + places < 0)
{
return false;
}
var visualDest = src + places; // what it would visually look like
var visualTemp = CMarkingsUsed[visualDest];
CMarkingsUsed[visualDest] = CMarkingsUsed[src];
CMarkingsUsed[src] = visualTemp;
switch (places)
{
// i.e., we're going down in rank
case < 0:
_currentMarkings.ShiftRankDownFromEnd(_selectedMarkingCategory, src);
break;
// i.e., we're going up in rank
case > 0:
_currentMarkings.ShiftRankUpFromEnd(_selectedMarkingCategory, src);
break;
// do nothing?
default:
break;
}
return true;
}
// repopulate in case markings are restricted,
// and also filter out any markings that are now invalid
// attempt to preserve any existing markings as well:
// it would be frustrating to otherwise have all markings
// cleared, imo
public void SetSpecies(string species)
{
_currentSpecies = species;
var markingList = _currentMarkings.GetForwardEnumerator().ToList();
var speciesPrototype = _prototypeManager.Index<SpeciesPrototype>(species);
_currentMarkings = new(markingList, speciesPrototype.MarkingPoints, _markingManager, _prototypeManager);
_currentMarkings.FilterSpecies(species);
Populate();
PopulateUsed();
}
private void UpdatePoints()
{
var count = _currentMarkings.PointsLeft(_selectedMarkingCategory);
if (count > -1)
{
CMarkingPoints.Text = Loc.GetString("marking-points-remaining", ("points", count));
}
}
private void OnCategoryChange(OptionButton.ItemSelectedEventArgs category)
{
CMarkingCategoryButton.SelectId(category.Id);
_selectedMarkingCategory = _markingCategories[category.Id];
Populate();
PopulateUsed();
UpdatePoints();
}
// TODO: This should be using ColorSelectorSliders once that's merged, so
private void OnUsedMarkingSelected(ItemList.ItemListSelectedEventArgs item)
{
_selectedMarking = CMarkingsUsed[item.ItemIndex];
var prototype = (MarkingPrototype) _selectedMarking.Metadata!;
if (prototype.FollowSkinColor)
{
CMarkingColors.Visible = false;
return;
}
var stateNames = GetMarkingStateNames(prototype);
_currentMarkingColors.Clear();
CMarkingColors.DisposeAllChildren();
List<ColorSelectorSliders> colorSliders = new();
for (int i = 0; i < prototype.Sprites.Count; i++)
{
var colorContainer = new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
};
CMarkingColors.AddChild(colorContainer);
ColorSelectorSliders colorSelector = new ColorSelectorSliders();
colorSliders.Add(colorSelector);
colorContainer.AddChild(new Label { Text = $"{stateNames[i]} color:" });
colorContainer.AddChild(colorSelector);
var listing = _currentMarkings[_selectedMarkingCategory];
var currentColor = new Color(
listing[listing.Count - 1 - item.ItemIndex].MarkingColors[i].RByte,
listing[listing.Count - 1 - item.ItemIndex].MarkingColors[i].GByte,
listing[listing.Count - 1 - item.ItemIndex].MarkingColors[i].BByte
);
colorSelector.Color = currentColor;
_currentMarkingColors.Add(currentColor);
var colorIndex = _currentMarkingColors.Count - 1;
Action<Color> colorChanged = _ =>
{
_currentMarkingColors[colorIndex] = colorSelector.Color;
ColorChanged(colorIndex);
};
colorSelector.OnColorChanged += colorChanged;
}
CMarkingColors.Visible = true;
}
private void ColorChanged(int colorIndex)
{
if (_selectedMarking is null) return;
var markingPrototype = (MarkingPrototype) _selectedMarking.Metadata!;
int markingIndex = _currentMarkings.FindIndexOf(_selectedMarkingCategory, markingPrototype.ID);
if (markingIndex < 0) return;
_selectedMarking.IconModulate = _currentMarkingColors[colorIndex];
var marking = new Marking(_currentMarkings[_selectedMarkingCategory][markingIndex]);
marking.SetColor(colorIndex, _currentMarkingColors[colorIndex]);
_currentMarkings.Replace(_selectedMarkingCategory, markingIndex, marking);
OnMarkingColorChange?.Invoke(_currentMarkings);
}
private void MarkingAdd()
{
if (_selectedUnusedMarking is null) return;
if (_currentMarkings.PointsLeft(_selectedMarkingCategory) == 0 && !Forced)
{
return;
}
var marking = (MarkingPrototype) _selectedUnusedMarking.Metadata!;
var markingObject = marking.AsMarking();
for (var i = 0; i < markingObject.MarkingColors.Count; i++)
{
markingObject.SetColor(i, CurrentSkinColor);
}
markingObject.Forced = Forced;
_currentMarkings.AddBack(_selectedMarkingCategory, markingObject);
UpdatePoints();
CMarkingsUnused.Remove(_selectedUnusedMarking);
var item = new ItemList.Item(CMarkingsUsed)
{
Text = Loc.GetString("marking-used", ("marking-name", $"{GetMarkingName(marking)}"), ("marking-category", Loc.GetString($"markings-category-{marking.MarkingCategory}"))),
Icon = marking.Sprites[0].Frame0(),
Selectable = true,
Metadata = marking,
};
CMarkingsUsed.Insert(0, item);
_selectedUnusedMarking = null;
OnMarkingAdded?.Invoke(_currentMarkings);
}
private void MarkingRemove()
{
if (_selectedMarking is null) return;
var marking = (MarkingPrototype) _selectedMarking.Metadata!;
_currentMarkings.Remove(_selectedMarkingCategory, marking.ID);
UpdatePoints();
CMarkingsUsed.Remove(_selectedMarking);
if (marking.MarkingCategory == _selectedMarkingCategory)
{
var item = CMarkingsUnused.AddItem($"{GetMarkingName(marking)}", marking.Sprites[0].Frame0());
item.Metadata = marking;
}
_selectedMarking = null;
CMarkingColors.Visible = false;
OnMarkingRemoved?.Invoke(_currentMarkings);
}
}

View File

@@ -0,0 +1,22 @@
<BoxContainer xmlns="https://spacestation14.io"
Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True">
<!-- "Slot" selection -->
<Label Name="CategoryName" />
<BoxContainer Name="SlotSelectorContainer" HorizontalExpand="True">
<OptionButton Name="SlotSelector" HorizontalExpand="True" />
<Button Name="AddButton" Text="{Loc 'marking-slot-add'}"/>
<Button Name="RemoveButton" Text="{Loc 'marking-slot-remove'}"/>
</BoxContainer>
<!-- Item list -->
<BoxContainer Name="MarkingSelectorContainer" Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
<ScrollContainer MinHeight="500" VerticalExpand="True" HorizontalExpand="True">
<ItemList Name="MarkingList" VerticalExpand="True" />
</ScrollContainer>
<!-- Color sliders -->
<ScrollContainer MinHeight="200" HorizontalExpand="True">
<BoxContainer Name="ColorSelectorContainer" HorizontalExpand="True" />
</ScrollContainer>
</BoxContainer>
</BoxContainer>

View File

@@ -0,0 +1,283 @@
using System.Linq;
using Content.Shared.Humanoid.Markings;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Client.Utility;
namespace Content.Client.Humanoid;
[GenerateTypedNameReferences]
public sealed partial class SingleMarkingPicker : BoxContainer
{
[Dependency] private MarkingManager _markingManager = default!;
/// <summary>
/// What happens if a marking is selected.
/// It will send the 'slot' (marking index)
/// and the selected marking's ID.
/// </summary>
public Action<(int slot, string id)>? OnMarkingSelect;
/// <summary>
/// What happens if a slot is removed.
/// This will send the 'slot' (marking index).
/// </summary>
public Action<int>? OnSlotRemove;
/// <summary>
/// What happens when a slot is added.
/// </summary>
public Action? OnSlotAdd;
/// <summary>
/// What happens if a marking's color is changed.
/// Sends a 'slot' number, and the marking in question.
/// </summary>
public Action<(int slot, Marking marking)>? OnColorChanged;
// current selected slot
private int _slot = -1;
private int Slot
{
get
{
if (_markings == null || _markings.Count == 0)
{
_slot = -1;
}
else if (_slot == -1)
{
_slot = 0;
}
return _slot;
}
set
{
if (_markings == null || _markings.Count == 0)
{
_slot = -1;
return;
}
_slot = value;
_ignoreItemSelected = true;
foreach (var item in MarkingList)
{
item.Selected = (string) item.Metadata! == _markings[_slot].MarkingId;
}
_ignoreItemSelected = false;
PopulateColors();
}
}
// amount of slots to show
private int _totalPoints;
private bool _ignoreItemSelected;
private MarkingCategories _category;
public MarkingCategories Category
{
get => _category;
set
{
_category = value;
CategoryName.Text = Loc.GetString($"markings-category-{_category}");
if (!string.IsNullOrEmpty(_species))
{
PopulateList();
}
}
}
private IReadOnlyDictionary<string, MarkingPrototype>? _markingPrototypeCache;
private string? _species;
private List<Marking>? _markings;
private int PointsLeft
{
get
{
if (_markings == null)
{
return 0;
}
if (_totalPoints < 0)
{
return -1;
}
return _totalPoints - _markings.Count;
}
}
private int PointsUsed => _markings?.Count ?? 0;
public SingleMarkingPicker()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
MarkingList.OnItemSelected += SelectMarking;
AddButton.OnPressed += _ =>
{
OnSlotAdd!();
};
SlotSelector.OnItemSelected += args =>
{
Slot = args.Button.SelectedId;
};
RemoveButton.OnPressed += _ =>
{
OnSlotRemove!(_slot);
};
}
public void UpdateData(List<Marking> markings, string species, int totalPoints)
{
_markings = markings;
_species = species;
_totalPoints = totalPoints;
_markingPrototypeCache = _markingManager.MarkingsByCategoryAndSpecies(Category, _species);
Visible = _markingPrototypeCache.Count != 0;
if (_markingPrototypeCache.Count == 0)
{
return;
}
PopulateList();
PopulateColors();
PopulateSlotSelector();
}
public void PopulateList()
{
if (string.IsNullOrEmpty(_species))
{
throw new ArgumentException("Tried to populate marking list without a set species!");
}
_markingPrototypeCache ??= _markingManager.MarkingsByCategoryAndSpecies(Category, _species);
MarkingSelectorContainer.Visible = _markings != null && _markings.Count != 0;
if (_markings == null || _markings.Count == 0)
{
return;
}
MarkingList.Clear();
foreach (var (id, marking) in _markingPrototypeCache)
{
var item = MarkingList.AddItem(Loc.GetString($"marking-{id}"), marking.Sprites[0].Frame0());
item.Metadata = marking.ID;
if (_markings[Slot].MarkingId == id)
{
_ignoreItemSelected = true;
item.Selected = true;
_ignoreItemSelected = false;
}
}
}
private void PopulateColors()
{
if (_markings == null
|| _markings.Count == 0
|| !_markingManager.TryGetMarking(_markings[Slot], out var proto))
{
return;
}
var marking = _markings[Slot];
ColorSelectorContainer.DisposeAllChildren();
ColorSelectorContainer.RemoveAllChildren();
if (marking.MarkingColors.Count != proto.Sprites.Count)
{
marking = new Marking(marking.MarkingId, proto.Sprites.Count);
}
for (var i = 0; i < marking.MarkingColors.Count; i++)
{
var selector = new ColorSelectorSliders
{
HorizontalExpand = true
};
selector.Color = marking.MarkingColors[i];
var colorIndex = i;
selector.OnColorChanged += color =>
{
marking.SetColor(colorIndex, color);
OnColorChanged!((_slot, marking));
};
ColorSelectorContainer.AddChild(selector);
}
}
private void SelectMarking(ItemList.ItemListSelectedEventArgs args)
{
if (_ignoreItemSelected)
{
return;
}
var id = (string) MarkingList[args.ItemIndex].Metadata!;
if (!_markingManager.Markings.TryGetValue(id, out var proto))
{
throw new ArgumentException("Attempted to select non-existent marking.");
}
var oldMarking = _markings![Slot];
_markings[Slot] = proto.AsMarking();
for (var i = 0; i < _markings[Slot].MarkingColors.Count && i < oldMarking.MarkingColors.Count; i++)
{
_markings[Slot].SetColor(i, oldMarking.MarkingColors[i]);
}
PopulateColors();
OnMarkingSelect!((_slot, id));
}
// Slot logic
private void PopulateSlotSelector()
{
SlotSelector.Visible = Slot >= 0;
AddButton.HorizontalExpand = Slot < 0;
RemoveButton.HorizontalExpand = Slot < 0;
AddButton.Disabled = PointsLeft == 0 && _totalPoints > -1 ;
RemoveButton.Disabled = PointsUsed == 0;
SlotSelector.Clear();
if (Slot < 0)
{
return;
}
for (var i = 0; i < PointsUsed; i++)
{
SlotSelector.AddItem($"Slot {i + 1}", i);
if (i == _slot)
{
SlotSelector.SelectId(i);
}
}
}
}

View File

@@ -1,12 +1,14 @@
using System.Linq;
using Content.Client.HUD.UI;
using Content.Client.Humanoid;
using Content.Client.Inventory;
using Content.Client.Preferences;
using Content.Client.UserInterface.Controls;
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.GameTicking;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Inventory;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Species;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
@@ -127,7 +129,7 @@ namespace Content.Client.Lobby.UI
_viewBox.AddChild(viewWest);
_viewBox.AddChild(viewEast);
_summaryLabel.Text = selectedCharacter.Summary;
EntitySystem.Get<SharedHumanoidAppearanceSystem>().UpdateFromProfile(_previewDummy.Value, selectedCharacter);
EntitySystem.Get<HumanoidSystem>().LoadProfile(_previewDummy.Value, selectedCharacter);
GiveDummyJobClothes(_previewDummy.Value, selectedCharacter);
}
}

View File

@@ -0,0 +1,67 @@
using Content.Shared.Humanoid.Markings;
using Content.Shared.MagicMirror;
using Robust.Client.GameObjects;
namespace Content.Client.MagicMirror;
public sealed class MagicMirrorBoundUserInterface : BoundUserInterface
{
private MagicMirrorWindow? _window;
public MagicMirrorBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new();
_window.OnHairSelected += tuple => SelectHair(MagicMirrorCategory.Hair, tuple.id, tuple.slot);
_window.OnHairColorChanged += args => ChangeColor(MagicMirrorCategory.Hair, args.marking, args.slot);
_window.OnHairSlotAdded += delegate() { AddSlot(MagicMirrorCategory.Hair); };
_window.OnHairSlotRemoved += args => RemoveSlot(MagicMirrorCategory.Hair, args);
_window.OnFacialHairSelected += tuple => SelectHair(MagicMirrorCategory.FacialHair, tuple.id, tuple.slot);
_window.OnFacialHairColorChanged +=
args => ChangeColor(MagicMirrorCategory.FacialHair, args.marking, args.slot);
_window.OnFacialHairSlotAdded += delegate() { AddSlot(MagicMirrorCategory.FacialHair); };
_window.OnFacialHairSlotRemoved += args => RemoveSlot(MagicMirrorCategory.FacialHair, args);
_window.OpenCentered();
}
private void SelectHair(MagicMirrorCategory category, string marking, int slot)
{
SendMessage(new MagicMirrorSelectMessage(category, marking, slot));
}
private void ChangeColor(MagicMirrorCategory category, Marking marking, int slot)
{
SendMessage(new MagicMirrorChangeColorMessage(category, new(marking.MarkingColors), slot));
}
private void RemoveSlot(MagicMirrorCategory category, int slot)
{
SendMessage(new MagicMirrorRemoveSlotMessage(category, slot));
}
private void AddSlot(MagicMirrorCategory category)
{
SendMessage(new MagicMirrorAddSlotMessage(category));
}
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
{
base.ReceiveMessage(message);
if (message is not MagicMirrorUiData data || _window == null)
{
return;
}
_window.UpdateState(data);
}
}

View File

@@ -0,0 +1,9 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:humanoid="clr-namespace:Content.Client.Humanoid"
Title="{Loc 'magic-mirror-window-title'}"
MinSize="600 400">
<BoxContainer>
<humanoid:SingleMarkingPicker Name="HairPicker" Category="Hair" />
<humanoid:SingleMarkingPicker Name="FacialHairPicker" Category="FacialHair" />
</BoxContainer>
</DefaultWindow>

View File

@@ -0,0 +1,52 @@
using Content.Shared.Humanoid.Markings;
using Content.Shared.MagicMirror;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.MagicMirror;
[GenerateTypedNameReferences]
public sealed partial class MagicMirrorWindow : DefaultWindow
{
// MMMMMMM
public Action<(int slot, string id)>? OnHairSelected;
public Action<(int slot, Marking marking)>? OnHairColorChanged;
public Action<int>? OnHairSlotRemoved;
public Action? OnHairSlotAdded;
public Action<(int slot, string id)>? OnFacialHairSelected;
public Action<(int slot, Marking marking)>? OnFacialHairColorChanged;
public Action<int>? OnFacialHairSlotRemoved;
public Action? OnFacialHairSlotAdded;
private bool _noHair;
public MagicMirrorWindow()
{
RobustXamlLoader.Load(this);
HairPicker.OnMarkingSelect += args => OnHairSelected!(args);
HairPicker.OnColorChanged += args => OnHairColorChanged!(args);
HairPicker.OnSlotRemove += args => OnHairSlotRemoved!(args);
HairPicker.OnSlotAdd += delegate { OnHairSlotAdded!(); };
FacialHairPicker.OnMarkingSelect += args => OnFacialHairSelected!(args);
FacialHairPicker.OnColorChanged += args => OnFacialHairColorChanged!(args);
FacialHairPicker.OnSlotRemove += args => OnFacialHairSlotRemoved!(args);
FacialHairPicker.OnSlotAdd += delegate { OnFacialHairSlotAdded!(); };
}
public void UpdateState(MagicMirrorUiData state)
{
HairPicker.UpdateData(state.Hair, state.Species, state.HairSlotTotal);
FacialHairPicker.UpdateData(state.FacialHair, state.Species, state.FacialHairSlotTotal);
if (!HairPicker.Visible && !FacialHairPicker.Visible && !_noHair)
{
AddChild(new Label { Text = Loc.GetString("magic-mirror-component-activate-user-has-no-hair") });
_noHair = true;
}
}
}

View File

@@ -1,449 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Content.Client.CharacterAppearance;
using Content.Client.Stylesheets;
using Content.Shared.CharacterAppearance;
using Content.Shared.Markings;
using Content.Shared.Species;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Client.Utility;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using static Robust.Client.UserInterface.Controls.BoxContainer;
namespace Content.Client.Markings
{
[GenerateTypedNameReferences]
public sealed partial class MarkingPicker : Control
{
[Dependency] private readonly MarkingManager _markingManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public Action<MarkingsSet>? OnMarkingAdded;
public Action<MarkingsSet>? OnMarkingRemoved;
public Action<MarkingsSet>? OnMarkingColorChange;
public Action<MarkingsSet>? OnMarkingRankChange;
private List<Color> _currentMarkingColors = new();
private Dictionary<MarkingCategories, MarkingPoints> PointLimits = new();
private Dictionary<MarkingCategories, MarkingPoints> PointsUsed = new();
private ItemList.Item? _selectedMarking;
private ItemList.Item? _selectedUnusedMarking;
private MarkingCategories _selectedMarkingCategory = MarkingCategories.Chest;
private MarkingsSet _currentMarkings = new();
private List<MarkingCategories> _markingCategories = Enum.GetValues<MarkingCategories>().ToList();
private string _currentSpecies = SpeciesManager.DefaultSpecies;
public Color CurrentSkinColor = Color.White;
public void SetData(MarkingsSet newMarkings, string species, Color skinColor)
{
_currentMarkings = newMarkings;
_currentSpecies = species;
CurrentSkinColor = skinColor;
// Should marking limits be dependent on species prototypes,
// or should it be dependent on the entity the
// species contains? Having marking points as a part of
// the component allows for any arbitrary thing to have
// a marking (at this point, it's practically a sprite decoration),
// but having it as a part of a species makes markings instead
// be dependent on humanoid variants for constraints
SpeciesPrototype speciesPrototype = _prototypeManager.Index<SpeciesPrototype>(species);
EntityPrototype body = _prototypeManager.Index<EntityPrototype>(speciesPrototype.Prototype);
body.TryGetComponent("Markings", out MarkingsComponent? markingsComponent);
PointLimits = markingsComponent!.LayerPoints;
PointsUsed = MarkingPoints.CloneMarkingPointDictionary(PointLimits);
Populate();
PopulateUsed();
}
public void SetSkinColor(Color color) => CurrentSkinColor = color;
public MarkingPicker()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
for (int i = 0; i < _markingCategories.Count; i++)
{
CMarkingCategoryButton.AddItem(Loc.GetString($"markings-category-{_markingCategories[i].ToString()}"), i);
}
CMarkingCategoryButton.SelectId(_markingCategories.IndexOf(MarkingCategories.Chest));
CMarkingCategoryButton.OnItemSelected += OnCategoryChange;
CMarkingsUnused.OnItemSelected += item =>
_selectedUnusedMarking = CMarkingsUnused[item.ItemIndex];
CMarkingAdd.OnPressed += args =>
MarkingAdd();
CMarkingsUsed.OnItemSelected += OnUsedMarkingSelected;
CMarkingRemove.OnPressed += args =>
MarkingRemove();
CMarkingRankUp.OnPressed += _ => SwapMarkingUp();
CMarkingRankDown.OnPressed += _ => SwapMarkingDown();
}
private string GetMarkingName(MarkingPrototype marking) => Loc.GetString($"marking-{marking.ID}");
private List<string> GetMarkingStateNames(MarkingPrototype marking)
{
List<string> result = new();
foreach (var markingState in marking.Sprites)
{
switch (markingState)
{
case SpriteSpecifier.Rsi rsi:
result.Add(Loc.GetString($"marking-{marking.ID}-{rsi.RsiState}"));
break;
case SpriteSpecifier.Texture texture:
result.Add(Loc.GetString($"marking-{marking.ID}-{texture.TexturePath.Filename}"));
break;
}
}
return result;
}
public void Populate()
{
CMarkingsUnused.Clear();
_selectedUnusedMarking = null;
var markings = _markingManager.CategorizedMarkings();
foreach (var marking in markings[_selectedMarkingCategory])
{
if (_currentMarkings.Contains(marking.AsMarking())) continue;
if (marking.SpeciesRestrictions != null && !marking.SpeciesRestrictions.Contains(_currentSpecies)) continue;
var item = CMarkingsUnused.AddItem($"{GetMarkingName(marking)}", marking.Sprites[0].Frame0());
item.Metadata = marking;
}
if (PointsUsed.ContainsKey(_selectedMarkingCategory))
{
CMarkingPoints.Visible = true;
}
else
{
CMarkingPoints.Visible = false;
}
}
// Populate the used marking list. Returns a list of markings that weren't
// valid to add to the marking list.
public void PopulateUsed()
{
CMarkingsUsed.Clear();
CMarkingColors.Visible = false;
_selectedMarking = null;
// a little slower than the original process
// (the original method here had the logic
// tied with the presentation, which did it all
// in one go including display)
//
// BUT
//
// it's all client side
// so does it really matter???
//
// actual validation/filtering occurs server side, but
// it might be better to just have a Process function
// that just iterates through all the markings with
// a species and points dict to ensure that all markings
// that were given are valid?
//
// one of the larger issues is that this doesn't
// necessarily use the existing backing list, but rather it
// allocates entirely new lists instead to perform
// their functions, making a 'Process' function
// more desirable imo, since this isn't *really* used
// outside of this specific niche
var markings = new MarkingsSet(_currentMarkings);
// ensures all markings are valid
markings = MarkingsSet.EnsureValid(_currentMarkings, _markingManager);
// filters out all non-valid species markings
markings = MarkingsSet.FilterSpecies(_currentMarkings, _currentSpecies);
// processes all the points currently available
markings = MarkingsSet.ProcessPoints(_currentMarkings, PointsUsed);
// if the marking set has changed, invoke the event that involves changed marking sets
if (markings != _currentMarkings)
{
Logger.DebugS("Markings", "Marking set is different, resetting markings on dummy now");
_currentMarkings = markings;
OnMarkingRemoved?.Invoke(_currentMarkings);
}
IEnumerator markingEnumerator = _currentMarkings.GetReverseEnumerator();
// walk backwards through the list for visual purposes
while (markingEnumerator.MoveNext())
{
Marking marking = (Marking) markingEnumerator.Current;
var newMarking = _markingManager.Markings()[marking.MarkingId];
var _item = new ItemList.Item(CMarkingsUsed)
{
Text = Loc.GetString("marking-used", ("marking-name", $"{GetMarkingName(newMarking)}"), ("marking-category", Loc.GetString($"markings-category-{newMarking.MarkingCategory}"))),
Icon = newMarking.Sprites[0].Frame0(),
Selectable = true,
Metadata = newMarking,
IconModulate = marking.MarkingColors[0]
};
CMarkingsUsed.Add(_item);
}
// since all the points have been processed, update the points visually
UpdatePoints();
}
private void SwapMarkingUp()
{
if (_selectedMarking == null)
{
return;
}
var i = CMarkingsUsed.IndexOf(_selectedMarking);
if (ShiftMarkingRank(i, -1))
{
OnMarkingRankChange?.Invoke(_currentMarkings);
}
}
private void SwapMarkingDown()
{
if (_selectedMarking == null)
{
return;
}
var i = CMarkingsUsed.IndexOf(_selectedMarking);
if (ShiftMarkingRank(i, 1))
{
OnMarkingRankChange?.Invoke(_currentMarkings);
}
}
private bool ShiftMarkingRank(int src, int places)
{
if (src + places >= CMarkingsUsed.Count || src + places < 0)
{
return false;
}
var visualDest = src + places; // what it would visually look like
var visualTemp = CMarkingsUsed[visualDest];
CMarkingsUsed[visualDest] = CMarkingsUsed[src];
CMarkingsUsed[src] = visualTemp;
switch (places)
{
// i.e., we're going down in rank
case < 0:
_currentMarkings.ShiftRankDownFromEnd(src);
break;
// i.e., we're going up in rank
case > 0:
_currentMarkings.ShiftRankUpFromEnd(src);
break;
// do nothing?
default:
break;
}
return true;
}
// repopulate in case markings are restricted,
// and also filter out any markings that are now invalid
// attempt to preserve any existing markings as well:
// it would be frustrating to otherwise have all markings
// cleared, imo
public void SetSpecies(string species)
{
_currentSpecies = species;
var markingCount = _currentMarkings.Count;
SpeciesPrototype speciesPrototype = _prototypeManager.Index<SpeciesPrototype>(species);
EntityPrototype body = _prototypeManager.Index<EntityPrototype>(speciesPrototype.Prototype);
body.TryGetComponent("Markings", out MarkingsComponent? markingsComponent);
PointLimits = markingsComponent!.LayerPoints;
PointsUsed = MarkingPoints.CloneMarkingPointDictionary(PointLimits);
Populate();
PopulateUsed();
}
private void UpdatePoints()
{
if (PointsUsed.TryGetValue(_selectedMarkingCategory, out var pointsRemaining))
{
CMarkingPoints.Text = Loc.GetString("marking-points-remaining", ("points", pointsRemaining.Points));
}
}
private void OnCategoryChange(OptionButton.ItemSelectedEventArgs category)
{
CMarkingCategoryButton.SelectId(category.Id);
_selectedMarkingCategory = _markingCategories[category.Id];
Populate();
UpdatePoints();
}
// TODO: This should be using ColorSelectorSliders once that's merged, so
private void OnUsedMarkingSelected(ItemList.ItemListSelectedEventArgs item)
{
_selectedMarking = CMarkingsUsed[item.ItemIndex];
var prototype = (MarkingPrototype) _selectedMarking.Metadata!;
if (prototype.FollowSkinColor)
{
CMarkingColors.Visible = false;
return;
}
var stateNames = GetMarkingStateNames(prototype);
_currentMarkingColors.Clear();
CMarkingColors.DisposeAllChildren();
List<ColorSelectorSliders> colorSliders = new();
for (int i = 0; i < prototype.Sprites.Count; i++)
{
var colorContainer = new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
};
CMarkingColors.AddChild(colorContainer);
ColorSelectorSliders colorSelector = new ColorSelectorSliders();
colorSliders.Add(colorSelector);
colorContainer.AddChild(new Label { Text = $"{stateNames[i]} color:" });
colorContainer.AddChild(colorSelector);
var currentColor = new Color(
_currentMarkings[_currentMarkings.Count - 1 - item.ItemIndex].MarkingColors[i].RByte,
_currentMarkings[_currentMarkings.Count - 1 - item.ItemIndex].MarkingColors[i].GByte,
_currentMarkings[_currentMarkings.Count - 1 - item.ItemIndex].MarkingColors[i].BByte
);
colorSelector.Color = currentColor;
_currentMarkingColors.Add(currentColor);
var colorIndex = _currentMarkingColors.Count - 1;
Action<Color> colorChanged = _ =>
{
_currentMarkingColors[colorIndex] = colorSelector.Color;
ColorChanged(colorIndex);
};
colorSelector.OnColorChanged += colorChanged;
}
CMarkingColors.Visible = true;
}
private void ColorChanged(int colorIndex)
{
if (_selectedMarking is null) return;
var markingPrototype = (MarkingPrototype) _selectedMarking.Metadata!;
int markingIndex = _currentMarkings.FindIndexOf(markingPrototype.ID);
if (markingIndex < 0) return;
_selectedMarking.IconModulate = _currentMarkingColors[colorIndex];
_currentMarkings[markingIndex].SetColor(colorIndex, _currentMarkingColors[colorIndex]);
OnMarkingColorChange?.Invoke(_currentMarkings);
}
private void MarkingAdd()
{
if (_selectedUnusedMarking is null) return;
MarkingPrototype marking = (MarkingPrototype) _selectedUnusedMarking.Metadata!;
if (PointsUsed.TryGetValue(marking.MarkingCategory, out var points))
{
if (points.Points == 0)
{
return;
}
points.Points--;
}
UpdatePoints();
var markingObject = marking.AsMarking();
for (var i = 0; i < markingObject.MarkingColors.Count; i++)
{
markingObject.SetColor(i, CurrentSkinColor);
}
_currentMarkings.AddBack(markingObject);
CMarkingsUnused.Remove(_selectedUnusedMarking);
var item = new ItemList.Item(CMarkingsUsed)
{
Text = Loc.GetString("marking-used", ("marking-name", $"{GetMarkingName(marking)}"), ("marking-category", Loc.GetString($"markings-category-{marking.MarkingCategory}"))),
Icon = marking.Sprites[0].Frame0(),
Selectable = true,
Metadata = marking,
};
CMarkingsUsed.Insert(0, item);
_selectedUnusedMarking = null;
OnMarkingAdded?.Invoke(_currentMarkings);
}
private void MarkingRemove()
{
if (_selectedMarking is null) return;
MarkingPrototype marking = (MarkingPrototype) _selectedMarking.Metadata!;
if (PointsUsed.TryGetValue(marking.MarkingCategory, out var points))
{
points.Points++;
}
UpdatePoints();
_currentMarkings.Remove(marking.AsMarking());
CMarkingsUsed.Remove(_selectedMarking);
if (marking.MarkingCategory == _selectedMarkingCategory)
{
var item = CMarkingsUnused.AddItem($"{GetMarkingName(marking)}", marking.Sprites[0].Frame0());
item.Metadata = marking;
}
_selectedMarking = null;
CMarkingColors.Visible = false;
OnMarkingRemoved?.Invoke(_currentMarkings);
}
}
}

View File

@@ -1,173 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using Content.Client.CharacterAppearance.Systems;
using Content.Shared.Markings;
using Content.Shared.CharacterAppearance;
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.Preferences;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Utility;
namespace Content.Client.Markings
{
public sealed class MarkingsSystem : EntitySystem
{
[Dependency] private readonly MarkingManager _markingManager = default!;
public override void Initialize()
{
SubscribeLocalEvent<MarkingsComponent, SharedHumanoidAppearanceSystem.ChangedHumanoidAppearanceEvent>(UpdateMarkings);
}
public void ToggleMarkingVisibility(EntityUid uid, SpriteComponent body, HumanoidVisualLayers layer, bool toggle)
{
if(!EntityManager.TryGetComponent(uid, out MarkingsComponent? markings)) return;
if (markings.ActiveMarkings.TryGetValue(layer, out List<Marking>? layerMarkings))
foreach (Marking activeMarking in layerMarkings)
body.LayerSetVisible(activeMarking.MarkingId, toggle);
}
public void SetActiveMarkings(EntityUid uid, MarkingsSet markingList, MarkingsComponent? markings = null)
{
if (!Resolve(uid, ref markings))
{
return;
}
markings.ActiveMarkings.Clear();
foreach (HumanoidVisualLayers layer in HumanoidAppearanceSystem.BodyPartLayers)
{
markings.ActiveMarkings.Add(layer, new List<Marking>());
}
foreach (var marking in markingList)
{
if (_markingManager.Markings().TryGetValue(marking.MarkingId, out var markingProto))
{
markings.ActiveMarkings[markingProto.BodyPart].Add(marking);
}
}
}
public void UpdateMarkings(EntityUid uid, MarkingsComponent markings, SharedHumanoidAppearanceSystem.ChangedHumanoidAppearanceEvent args)
{
var appearance = args.Appearance;
if (!EntityManager.TryGetComponent(uid, out SpriteComponent? sprite)) return;
MarkingsSet totalMarkings = new MarkingsSet(appearance.Markings);
Dictionary<MarkingCategories, MarkingPoints> usedPoints = MarkingPoints.CloneMarkingPointDictionary(markings.LayerPoints);
var markingsEnumerator = appearance.Markings.GetReverseEnumerator();
// Reverse ordering
while (markingsEnumerator.MoveNext())
{
var marking = (Marking) markingsEnumerator.Current;
if (!_markingManager.IsValidMarking(marking, out MarkingPrototype? markingPrototype))
{
continue;
}
// if the given marking isn't correctly formed, we need to
// instead just allocate a new marking based on the old one
if (marking.MarkingColors.Count != markingPrototype.Sprites.Count)
{
marking = new Marking(marking.MarkingId, markingPrototype.Sprites.Count);
}
if (usedPoints.TryGetValue(markingPrototype.MarkingCategory, out MarkingPoints? points))
{
if (points.Points == 0)
{
continue;
}
points.Points--;
}
if (!sprite.LayerMapTryGet(markingPrototype.BodyPart, out int targetLayer))
{
continue;
}
for (int j = 0; j < markingPrototype.Sprites.Count(); j++)
{
var rsi = (SpriteSpecifier.Rsi) markingPrototype.Sprites[j];
string layerId = $"{markingPrototype.ID}-{rsi.RsiState}";
if (sprite.LayerMapTryGet(layerId, out var existingLayer))
{
sprite.RemoveLayer(existingLayer);
sprite.LayerMapRemove(marking.MarkingId);
}
int layer = sprite.AddLayer(markingPrototype.Sprites[j], targetLayer + j + 1);
sprite.LayerMapSet(layerId, layer);
if (markingPrototype.FollowSkinColor)
{
sprite.LayerSetColor(layerId, appearance.SkinColor);
}
else
{
sprite.LayerSetColor(layerId, marking.MarkingColors[j]);
}
}
}
// for each layer, check if it's required and
// if the points are greater than zero
//
// if so, then we start applying default markings
// until the point requirement is satisfied -
// this can also mean that a specific set of markings
// is applied on top of existing markings
//
// All default markings will follow the skin color of
// the current body.
foreach (var (layerType, points) in usedPoints)
{
if (points.Required && points.Points > 0)
{
while (points.Points > 0)
{
// this all has to be checked, continues shouldn't occur because
// points.Points needs to be subtracted
if (points.DefaultMarkings.TryGetValue(points.Points - 1, out var marking)
&& _markingManager.Markings().TryGetValue(marking, out var markingPrototype)
&& markingPrototype.MarkingCategory == layerType // check if this actually belongs on this layer, too
&& sprite.LayerMapTryGet(markingPrototype.BodyPart, out int targetLayer))
{
for (int j = 0; j < markingPrototype.Sprites.Count(); j++)
{
var rsi = (SpriteSpecifier.Rsi) markingPrototype.Sprites[j];
string layerId = $"{markingPrototype.ID}-{rsi.RsiState}";
if (sprite.LayerMapTryGet(layerId, out var existingLayer))
{
sprite.RemoveLayer(existingLayer);
sprite.LayerMapRemove(markingPrototype.ID);
}
int layer = sprite.AddLayer(markingPrototype.Sprites[j], targetLayer + j + 1);
sprite.LayerMapSet(layerId, layer);
sprite.LayerSetColor(layerId, appearance.SkinColor);
}
totalMarkings.AddBack(markingPrototype.AsMarking());
}
points.Points--;
}
}
}
SetActiveMarkings(uid, totalMarkings, markings);
}
}
}

View File

@@ -1,11 +1,12 @@
using System.Linq;
using Content.Client.Humanoid;
using Content.Client.Info;
using Content.Client.Lobby.UI;
using Content.Client.Resources;
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Species;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
@@ -165,10 +166,10 @@ namespace Content.Client.Preferences.UI
}
else
{
_previewDummy = entityManager.SpawnEntity(prototypeManager.Index<SpeciesPrototype>(SpeciesManager.DefaultSpecies).DollPrototype, MapCoordinates.Nullspace);
_previewDummy = entityManager.SpawnEntity(prototypeManager.Index<SpeciesPrototype>(SharedHumanoidSystem.DefaultSpecies).DollPrototype, MapCoordinates.Nullspace);
}
EntitySystem.Get<SharedHumanoidAppearanceSystem>().UpdateFromProfile(_previewDummy, profile);
EntitySystem.Get<HumanoidSystem>().LoadProfile(_previewDummy, (HumanoidCharacterProfile) profile);
if (humanoid != null)
{

View File

@@ -1,5 +1,5 @@
using Content.Shared.CharacterAppearance;
using Content.Shared.Dataset;
using Content.Shared.Humanoid;
using Content.Shared.Preferences;
using Content.Shared.Random.Helpers;
using Robust.Shared.Prototypes;
@@ -15,15 +15,8 @@ namespace Content.Client.Preferences.UI
private void RandomizeEverything()
{
Profile = HumanoidCharacterProfile.Random();
UpdateSexControls();
UpdateGenderControls();
UpdateClothingControls();
UpdateAgeEdit();
UpdateNameEdit();
UpdateHairPickers();
UpdateEyePickers();
_skinColor.Value = _random.Next(0, 100);
UpdateControls();
IsDirty = true;
}
private void RandomizeName()

View File

@@ -1,8 +1,7 @@
<Control xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:magicmirror="clr-namespace:Content.Client.CharacterAppearance"
xmlns:prefUi="clr-namespace:Content.Client.Preferences.UI"
xmlns:markings="clr-namespace:Content.Client.Markings">
xmlns:humanoid="clr-namespace:Content.Client.Humanoid">
<BoxContainer Orientation="Horizontal">
<!-- Left side -->
<BoxContainer Orientation="Vertical" Margin="10 10 10 10">
@@ -98,8 +97,8 @@
<!-- Hair -->
<prefUi:HighlightedContainer>
<BoxContainer Orientation="Horizontal">
<magicmirror:HairStylePicker Name="CHairStylePicker" HorizontalAlignment="Center" />
<magicmirror:HairStylePicker Name="CFacialHairPicker" />
<humanoid:SingleMarkingPicker Name="CHairStylePicker" Category="Hair" />
<humanoid:SingleMarkingPicker Name="CFacialHairPicker" Category="FacialHair" />
</BoxContainer>
</prefUi:HighlightedContainer>
<!-- Clothing -->
@@ -120,7 +119,7 @@
<prefUi:HighlightedContainer>
<BoxContainer Orientation="Vertical">
<Label Text="{Loc 'humanoid-profile-editor-eyes-label'}" />
<magicmirror:EyeColorPicker Name="CEyeColorPicker" />
<humanoid:EyeColorPicker Name="CEyeColorPicker" />
</BoxContainer>
</prefUi:HighlightedContainer>
</BoxContainer>
@@ -148,7 +147,7 @@
<BoxContainer Name="CMarkingsTab" Orientation="Vertical" Margin="10">
<!-- Markings -->
<ScrollContainer VerticalExpand="True">
<markings:MarkingPicker Name="CMarkings" />
<humanoid:MarkingPicker Name="CMarkings" IgnoreCategories="Hair,FacialHair" />
</ScrollContainer>
</BoxContainer>
</TabContainer>

View File

@@ -1,18 +1,18 @@
using System.Linq;
using Content.Client.CharacterAppearance;
using Content.Client.HUD.UI;
using Content.Client.Humanoid;
using Content.Client.Lobby.UI;
using Content.Client.Message;
using Content.Client.Players.PlayTimeTracking;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls;
using Content.Shared.CCVar;
using Content.Shared.CharacterAppearance;
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.GameTicking;
using Content.Shared.Markings;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Species;
using Content.Shared.Traits;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
@@ -53,6 +53,7 @@ namespace Content.Client.Preferences.UI
private readonly IClientPreferencesManager _preferencesManager;
private readonly IEntityManager _entMan;
private readonly IConfigurationManager _configurationManager;
private readonly MarkingManager _markingManager;
private LineEdit _ageEdit => CAgeEdit;
private LineEdit _nameEdit => CNameEdit;
@@ -67,8 +68,8 @@ namespace Content.Client.Preferences.UI
private Slider _skinColor => CSkin;
private OptionButton _clothingButton => CClothingButton;
private OptionButton _backpackButton => CBackpackButton;
private HairStylePicker _hairPicker => CHairStylePicker;
private HairStylePicker _facialHairPicker => CFacialHairPicker;
private SingleMarkingPicker _hairPicker => CHairStylePicker;
private SingleMarkingPicker _facialHairPicker => CFacialHairPicker;
private EyeColorPicker _eyesPicker => CEyeColorPicker;
private TabContainer _tabContainer => CTabContainer;
@@ -103,6 +104,7 @@ namespace Content.Client.Preferences.UI
private bool _needsDummyRebuild;
public int CharacterSlot;
public HumanoidCharacterProfile? Profile;
private MarkingSet _markingSet = new(); // storing this here feels iffy but a few things need it this high up
public event Action<HumanoidCharacterProfile, int>? OnProfileChanged;
@@ -115,6 +117,7 @@ namespace Content.Client.Preferences.UI
_entMan = entityManager;
_preferencesManager = preferencesManager;
_configurationManager = configurationManager;
_markingManager = IoCManager.Resolve<MarkingManager>();
#region Left
@@ -203,6 +206,7 @@ namespace Content.Client.Preferences.UI
{
CSpeciesButton.SelectId(args.Id);
SetSpecies(_speciesList[args.Id].ID);
UpdateHairPickers();
OnSkinColorOnValueChanged();
};
@@ -210,14 +214,7 @@ namespace Content.Client.Preferences.UI
#region Skin
// 0 - 100, 0 being gold/yellowish and 100 being dark
// HSV based
//
// 0 - 20 changes the hue
// 20 - 100 changes the value
// 0 is 45 - 20 - 100
// 20 is 25 - 20 - 100
// 100 is 25 - 100 - 20
_skinColor.OnValueChanged += _ =>
{
OnSkinColorOnValueChanged();
@@ -233,43 +230,101 @@ namespace Content.Client.Preferences.UI
#region Hair
_hairPicker.Populate();
_hairPicker.OnHairStylePicked += newStyle =>
_hairPicker.OnMarkingSelect += newStyle =>
{
if (Profile is null)
return;
Profile = Profile.WithCharacterAppearance(
Profile.Appearance.WithHairStyleName(newStyle));
Profile.Appearance.WithHairStyleName(newStyle.id));
IsDirty = true;
};
_hairPicker.OnHairColorPicked += newColor =>
_hairPicker.OnColorChanged += newColor =>
{
if (Profile is null)
return;
Profile = Profile.WithCharacterAppearance(
Profile.Appearance.WithHairColor(newColor));
Profile.Appearance.WithHairColor(newColor.marking.MarkingColors[0]));
IsDirty = true;
};
_facialHairPicker.Populate();
_facialHairPicker.OnHairStylePicked += newStyle =>
_facialHairPicker.OnMarkingSelect += newStyle =>
{
if (Profile is null)
return;
Profile = Profile.WithCharacterAppearance(
Profile.Appearance.WithFacialHairStyleName(newStyle));
Profile.Appearance.WithFacialHairStyleName(newStyle.id));
IsDirty = true;
};
_facialHairPicker.OnHairColorPicked += newColor =>
_facialHairPicker.OnColorChanged += newColor =>
{
if (Profile is null)
return;
Profile = Profile.WithCharacterAppearance(
Profile.Appearance.WithFacialHairColor(newColor));
Profile.Appearance.WithFacialHairColor(newColor.marking.MarkingColors[0]));
IsDirty = true;
};
_hairPicker.OnSlotRemove += _ =>
{
if (Profile is null)
return;
Profile = Profile.WithCharacterAppearance(
Profile.Appearance.WithHairStyleName(HairStyles.DefaultHairStyle)
);
UpdateHairPickers();
IsDirty = true;
};
_facialHairPicker.OnSlotRemove += _ =>
{
if (Profile is null)
return;
Profile = Profile.WithCharacterAppearance(
Profile.Appearance.WithFacialHairStyleName(HairStyles.DefaultFacialHairStyle)
);
UpdateHairPickers();
IsDirty = true;
};
_hairPicker.OnSlotAdd += delegate()
{
if (Profile is null)
return;
var hair = _markingManager.MarkingsByCategoryAndSpecies(MarkingCategories.Hair, Profile.Species).Keys
.FirstOrDefault();
if (string.IsNullOrEmpty(hair))
return;
Profile = Profile.WithCharacterAppearance(
Profile.Appearance.WithHairStyleName(hair)
);
UpdateHairPickers();
IsDirty = true;
};
_facialHairPicker.OnSlotAdd += delegate()
{
if (Profile is null)
return;
var hair = _markingManager.MarkingsByCategoryAndSpecies(MarkingCategories.FacialHair, Profile.Species).Keys
.FirstOrDefault();
if (string.IsNullOrEmpty(hair))
return;
Profile = Profile.WithCharacterAppearance(
Profile.Appearance.WithFacialHairStyleName(hair)
);
UpdateHairPickers();
IsDirty = true;
};
@@ -519,6 +574,38 @@ namespace Content.Client.Preferences.UI
#endregion FlavorText
#region Dummy
var species = Profile?.Species ?? SharedHumanoidSystem.DefaultSpecies;
var dollProto = _prototypeManager.Index<SpeciesPrototype>(species).DollPrototype;
if (_previewDummy != null)
_entMan.DeleteEntity(_previewDummy!.Value);
_previewDummy = _entMan.SpawnEntity(dollProto, MapCoordinates.Nullspace);
_lastSpecies = species;
var sprite = _entMan.GetComponent<SpriteComponent>(_previewDummy!.Value);
_previewSprite = new SpriteView
{
Sprite = sprite,
Scale = (6, 6),
OverrideDirection = Direction.South,
VerticalAlignment = VAlignment.Center,
SizeFlagsStretchRatio = 1
};
_previewSpriteControl.AddChild(_previewSprite);
_previewSpriteSide = new SpriteView
{
Sprite = sprite,
Scale = (6, 6),
OverrideDirection = Direction.East,
VerticalAlignment = VAlignment.Center,
SizeFlagsStretchRatio = 1
};
_previewSpriteSideControl.AddChild(_previewSpriteSide);
#endregion Dummy
#endregion Left
if (preferencesManager.ServerDataLoaded)
@@ -541,17 +628,17 @@ namespace Content.Client.Preferences.UI
IsDirty = true;
}
private void OnMarkingChange(MarkingsSet markings)
private void OnMarkingChange(MarkingSet markings)
{
if (Profile is null)
return;
Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithMarkings(markings));
Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithMarkings(markings.GetForwardEnumerator().ToList()));
NeedsDummyRebuild = true;
IsDirty = true;
}
private void OnMarkingColorChange(MarkingsSet markings)
private void OnMarkingColorChange(List<Marking> markings)
{
if (Profile is null)
return;
@@ -569,38 +656,21 @@ namespace Content.Client.Preferences.UI
switch (skin)
{
case SpeciesSkinColor.HumanToned:
case HumanoidSkinColor.HumanToned:
{
var range = _skinColor.Value;
if (!_skinColor.Visible)
{
_skinColor.Visible = true;
_rgbSkinColorContainer.Visible = false;
}
var rangeOffset = (int) range - 20;
float hue = 25;
float sat = 20;
float val = 100;
if (rangeOffset <= 0)
{
hue += Math.Abs(rangeOffset);
}
else
{
sat += rangeOffset;
val -= rangeOffset;
}
var color = Color.FromHsv(new Vector4(hue / 360, sat / 100, val / 100, 1.0f));
var color = SkinColor.HumanSkinTone((int) _skinColor.Value);
CMarkings.CurrentSkinColor = color;
Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(color));
break;
}
case SpeciesSkinColor.Hues:
case HumanoidSkinColor.Hues:
{
if (!_rgbSkinColorContainer.Visible)
{
@@ -608,13 +678,11 @@ namespace Content.Client.Preferences.UI
_rgbSkinColorContainer.Visible = true;
}
var color = new Color(_rgbSkinColorSelector.Color.R, _rgbSkinColorSelector.Color.G, _rgbSkinColorSelector.Color.B);
CMarkings.CurrentSkinColor = color;
Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(color));
CMarkings.CurrentSkinColor = _rgbSkinColorSelector.Color;
Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(_rgbSkinColorSelector.Color));
break;
}
case SpeciesSkinColor.TintedHues:
case HumanoidSkinColor.TintedHues:
{
if (!_rgbSkinColorContainer.Visible)
{
@@ -622,11 +690,7 @@ namespace Content.Client.Preferences.UI
_rgbSkinColorContainer.Visible = true;
}
// a little hacky in order to convert rgb --> hsv --> rgb
var color = new Color(_rgbSkinColorSelector.Color.R, _rgbSkinColorSelector.Color.G, _rgbSkinColorSelector.Color.B);
var newColor = Color.ToHsv(color);
newColor.Y = .1f;
color = Color.FromHsv(newColor);
var color = SkinColor.TintedHues(_rgbSkinColorSelector.Color);
CMarkings.CurrentSkinColor = color;
Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(color));
@@ -652,7 +716,7 @@ namespace Content.Client.Preferences.UI
private void RebuildSpriteView()
{
var species = Profile?.Species ?? SpeciesManager.DefaultSpecies;
var species = Profile?.Species ?? SharedHumanoidSystem.DefaultSpecies;
var dollProto = _prototypeManager.Index<SpeciesPrototype>(species).DollPrototype;
if (_previewDummy != null)
@@ -820,7 +884,7 @@ namespace Content.Client.Preferences.UI
switch (skin)
{
case SpeciesSkinColor.HumanToned:
case HumanoidSkinColor.HumanToned:
{
if (!_skinColor.Visible)
{
@@ -828,23 +892,11 @@ namespace Content.Client.Preferences.UI
_rgbSkinColorContainer.Visible = false;
}
var color = Color.ToHsv(Profile.Appearance.SkinColor);
// check for hue/value first, if hue is lower than this percentage
// and value is 1.0
// then it'll be hue
if (Math.Clamp(color.X, 25f / 360f, 1) > 25f / 360f
&& color.Z == 1.0)
{
_skinColor.Value = Math.Abs(45 - (color.X * 360));
}
// otherwise it'll directly be the saturation
else
{
_skinColor.Value = color.Y * 100;
}
_skinColor.Value = SkinColor.HumanSkinToneFromColor(Profile.Appearance.SkinColor);
break;
}
case SpeciesSkinColor.Hues:
case HumanoidSkinColor.Hues:
{
if (!_rgbSkinColorContainer.Visible)
{
@@ -856,7 +908,7 @@ namespace Content.Client.Preferences.UI
_rgbSkinColorSelector.Color = Profile.Appearance.SkinColor;
break;
}
case SpeciesSkinColor.TintedHues:
case HumanoidSkinColor.TintedHues:
{
if (!_rgbSkinColorContainer.Visible)
{
@@ -929,16 +981,26 @@ namespace Content.Client.Preferences.UI
return;
}
_hairPicker.SetData(
Profile.Appearance.HairColor,
Profile.Appearance.HairStyleId,
SpriteAccessoryCategories.HumanHair,
true);
_facialHairPicker.SetData(
Profile.Appearance.FacialHairColor,
Profile.Appearance.FacialHairStyleId,
SpriteAccessoryCategories.HumanFacialHair,
true);
var hairMarking = Profile.Appearance.HairStyleId switch
{
HairStyles.DefaultHairStyle => new List<Marking>(),
_ => new() { new(Profile.Appearance.HairStyleId, new List<Color>() { Profile.Appearance.HairColor }) },
};
var facialHairMarking = Profile.Appearance.FacialHairStyleId switch
{
HairStyles.DefaultFacialHairStyle => new List<Marking>(),
_ => new() { new(Profile.Appearance.FacialHairStyleId, new List<Color>() { Profile.Appearance.FacialHairColor }) },
};
_hairPicker.UpdateData(
hairMarking,
Profile.Species,
1);
_facialHairPicker.UpdateData(
facialHairMarking,
Profile.Species,
1);
}
private void UpdateEyePickers()
@@ -961,13 +1023,15 @@ namespace Content.Client.Preferences.UI
if (Profile is null)
return;
/* dear fuck this needs to not happen ever again
if (_needsDummyRebuild)
{
RebuildSpriteView(); // Species change also requires sprite rebuild, so we'll do that now.
_needsDummyRebuild = false;
}
*/
EntitySystem.Get<SharedHumanoidAppearanceSystem>().UpdateFromProfile(_previewDummy!.Value, Profile);
EntitySystem.Get<HumanoidSystem>().LoadProfile(_previewDummy!.Value, Profile);
LobbyCharacterPreviewPanel.GiveDummyJobClothes(_previewDummy!.Value, Profile);
}

View File

@@ -1,6 +1,8 @@
using Content.Server.Humanoid;
using Content.Shared.Audio;
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
using Content.Shared.Humanoid;
using Content.Shared.Random.Helpers;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
@@ -29,6 +31,16 @@ namespace Content.Server.Body.Components
base.OnAddPart(slot, part);
_partContainer.Insert(part.Owner);
if (_entMan.TryGetComponent<HumanoidComponent>(Owner, out var humanoid))
{
var layer = part.ToHumanoidLayers();
if (layer != null)
{
var layers = HumanoidVisualLayersExtension.Sublayers(layer.Value);
_entMan.System<HumanoidSystem>().SetLayersVisibility(Owner, layers, true, true, humanoid);
}
}
}
protected override void OnRemovePart(BodyPartSlot slot, SharedBodyPartComponent part)
@@ -37,6 +49,16 @@ namespace Content.Server.Body.Components
_partContainer.ForceRemove(part.Owner);
part.Owner.RandomOffset(0.25f);
if (_entMan.TryGetComponent<HumanoidComponent>(Owner, out var humanoid))
{
var layer = part.ToHumanoidLayers();
if (layer != null)
{
var layers = HumanoidVisualLayersExtension.Sublayers(layer.Value);
_entMan.System<HumanoidSystem>().SetLayersVisibility(Owner, layers, false, true, humanoid);
}
}
}
protected override void Initialize()

View File

@@ -1,90 +0,0 @@
using Content.Server.CharacterAppearance.Systems;
using Content.Server.UserInterface;
using Content.Shared.CharacterAppearance;
using Content.Shared.CharacterAppearance.Components;
using Robust.Server.GameObjects;
namespace Content.Server.CharacterAppearance.Components
{
[RegisterComponent]
public sealed class MagicMirrorComponent : SharedMagicMirrorComponent
{
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly SpriteAccessoryManager _spriteAccessoryManager = default!;
[ViewVariables] public BoundUserInterface? UserInterface => Owner.GetUIOrNull(MagicMirrorUiKey.Key);
protected override void Initialize()
{
base.Initialize();
if (UserInterface != null)
{
UserInterface.OnReceiveMessage += OnUiReceiveMessage;
}
}
protected override void OnRemove()
{
if (UserInterface != null)
{
UserInterface.OnReceiveMessage -= OnUiReceiveMessage;
}
base.OnRemove();
}
private void OnUiReceiveMessage(ServerBoundUserInterfaceMessage obj)
{
if (obj.Session.AttachedEntity is not {Valid: true} player)
{
return;
}
if (!_entities.TryGetComponent(player, out HumanoidAppearanceComponent? looks))
{
return;
}
switch (obj.Message)
{
case HairSelectedMessage msg:
var cat = msg.IsFacialHair
? looks.CategoriesFacialHair
: looks.CategoriesHair;
if (!_spriteAccessoryManager.IsValidAccessoryInCategory(msg.HairId, cat))
return;
looks.Appearance = msg.IsFacialHair
? looks.Appearance.WithFacialHairStyleName(msg.HairId)
: looks.Appearance.WithHairStyleName(msg.HairId);
break;
case HairColorSelectedMessage msg:
if (msg.IsFacialHair ? !looks.CanColorFacialHair : !looks.CanColorHair)
return;
var (r, g, b) = msg.HairColor;
var color = new Color(r, g, b);
looks.Appearance = msg.IsFacialHair
? looks.Appearance.WithFacialHairColor(color)
: looks.Appearance.WithHairColor(color);
break;
case EyeColorSelectedMessage msg:
var (eyeR, eyeG, eyeB) = msg.EyeColor;
var eyeColor = new Color(eyeR, eyeG, eyeB);
looks.Appearance = looks.Appearance.WithEyeColor(eyeColor);
break;
}
EntitySystem.Get<HumanoidAppearanceSystem>().ForceAppearanceUpdate(player);
}
}
}

View File

@@ -1,8 +0,0 @@
namespace Content.Server.CharacterAppearance.Components;
[RegisterComponent]
public sealed class RandomHumanoidAppearanceComponent : Component
{
[DataField("randomizeName")]
public bool RandomizeName = true;
}

View File

@@ -1,31 +0,0 @@
using Content.Shared.Body.Components;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.CharacterAppearance.Systems;
using Robust.Server.GameObjects;
namespace Content.Server.CharacterAppearance.Systems
{
public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HumanoidAppearanceComponent, ChangedHumanoidAppearanceEvent>(UpdateSkinColor);
}
private void UpdateSkinColor(EntityUid uid, HumanoidAppearanceComponent component, ChangedHumanoidAppearanceEvent _)
{
if (EntityManager.TryGetComponent<SharedBodyComponent>(uid, out SharedBodyComponent? body))
{
foreach (var (part, _) in body.Parts)
{
if (EntityManager.TryGetComponent(part.Owner, out SpriteComponent? sprite))
{
sprite!.Color = component.Appearance.SkinColor;
}
}
}
}
}
}

View File

@@ -1,42 +0,0 @@
using Content.Server.CharacterAppearance.Components;
using Content.Server.UserInterface;
using Content.Shared.CharacterAppearance.Components;
using Robust.Server.GameObjects;
namespace Content.Server.CharacterAppearance.Systems
{
public sealed class MagicMirrorSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MagicMirrorComponent, ActivatableUIOpenAttemptEvent>(OnOpenUIAttempt);
SubscribeLocalEvent<MagicMirrorComponent, AfterActivatableUIOpenEvent>(AfterUIOpen);
}
private void OnOpenUIAttempt(EntityUid uid, MagicMirrorComponent mirror, ActivatableUIOpenAttemptEvent args)
{
if (!HasComp<HumanoidAppearanceComponent>(args.User))
args.Cancel();
}
private void AfterUIOpen(EntityUid uid, MagicMirrorComponent component, AfterActivatableUIOpenEvent args)
{
var looks = Comp<HumanoidAppearanceComponent>(args.User);
var actor = Comp<ActorComponent>(args.User);
var appearance = looks.Appearance;
var msg = new MagicMirrorComponent.MagicMirrorInitialDataMessage(
appearance.HairColor,
appearance.FacialHairColor,
appearance.HairStyleId,
appearance.FacialHairStyleId,
appearance.EyeColor,
looks.CategoriesHair,
looks.CategoriesFacialHair,
looks.CanColorHair,
looks.CanColorFacialHair);
component.UserInterface?.SendMessage(msg, actor.PlayerSession);
}
}
}

View File

@@ -1,33 +0,0 @@
using Content.Server.CharacterAppearance.Components;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.Preferences;
namespace Content.Server.CharacterAppearance.Systems;
public sealed class RandomHumanoidAppearanceSystem : EntitySystem
{
[Dependency] private readonly SharedHumanoidAppearanceSystem _humanoidAppearance = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RandomHumanoidAppearanceComponent, MapInitEvent>(OnMapInit);
}
private void OnMapInit(EntityUid uid, RandomHumanoidAppearanceComponent component, MapInitEvent args)
{
if (TryComp<HumanoidAppearanceComponent>(uid, out var appearance))
{
var profile = HumanoidCharacterProfile.Random();
_humanoidAppearance.UpdateFromProfile(uid, profile, appearance);
if (component.RandomizeName)
{
var meta = MetaData(uid);
meta.EntityName = profile.Name;
}
}
}
}

View File

@@ -1,7 +1,4 @@
using Content.Shared.GameTicking;
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.Species;
using Content.Shared.Damage;
using Content.Shared.Stacks;
using Content.Shared.Examine;
@@ -13,6 +10,7 @@ using Content.Server.Mind.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Atmos.EntitySystems;
using Content.Server.EUI;
using Content.Server.Humanoid;
using Content.Server.MachineLinking.System;
using Content.Server.MachineLinking.Events;
using Content.Server.MobState;
@@ -23,7 +21,7 @@ using Content.Server.Construction.Components;
using Content.Server.Materials;
using Content.Server.Stack;
using Content.Server.Jobs;
using Content.Shared.Materials;
using Content.Shared.Humanoid.Prototypes;
using Robust.Server.GameObjects;
using Robust.Server.Containers;
using Robust.Server.Player;
@@ -43,7 +41,7 @@ namespace Content.Server.Cloning.Systems
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly EuiManager _euiManager = null!;
[Dependency] private readonly CloningConsoleSystem _cloningConsoleSystem = default!;
[Dependency] private readonly SharedHumanoidAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly HumanoidSystem _humanoidSystem = default!;
[Dependency] private readonly ContainerSystem _containerSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
@@ -168,7 +166,7 @@ namespace Content.Server.Cloning.Systems
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<HumanoidAppearanceComponent>(bodyToClone, out var humanoid))
if (!TryComp<HumanoidComponent>(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))
@@ -215,7 +213,7 @@ namespace Content.Server.Cloning.Systems
// end of genetic damage checks
var mob = Spawn(speciesPrototype.Prototype, Transform(clonePod.Owner).MapPosition);
_appearanceSystem.UpdateAppearance(mob, humanoid.Appearance, humanoid.Sex, humanoid.Gender, humanoid.Species, humanoid.Age);
_humanoidSystem.CloneAppearance(bodyToClone, mob);
MetaData(mob).EntityName = MetaData(bodyToClone).EntityName;

View File

@@ -0,0 +1,39 @@
using Content.Server.Humanoid;
using Content.Shared.Clothing.Components;
using Content.Shared.Humanoid;
using Content.Shared.Inventory.Events;
using Content.Shared.Tag;
namespace Content.Server.Clothing;
public sealed class ServerClothingSystem : EntitySystem
{
[Dependency] private readonly HumanoidSystem _humanoidSystem = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
public override void Initialize()
{
SubscribeLocalEvent<SharedClothingComponent, GotEquippedEvent>(OnGotEquipped);
SubscribeLocalEvent<SharedClothingComponent, GotUnequippedEvent>(OnGotUnequipped);
}
private void OnGotEquipped(EntityUid uid, SharedClothingComponent component, GotEquippedEvent args)
{
if (args.Slot == "head"
&& _tagSystem.HasTag(args.Equipment, "HidesHair"))
{
_humanoidSystem.SetLayersVisibility(args.Equipee,
HumanoidVisualLayersExtension.Sublayers(HumanoidVisualLayers.Head), false);
}
}
private void OnGotUnequipped(EntityUid uid, SharedClothingComponent component, GotUnequippedEvent args)
{
if (args.Slot == "head"
&& _tagSystem.HasTag(args.Equipment, "HidesHair"))
{
_humanoidSystem.SetLayersVisibility(args.Equipee,
HumanoidVisualLayersExtension.Sublayers(HumanoidVisualLayers.Head), true);
}
}
}

View File

@@ -6,8 +6,8 @@ using System.Threading;
using System.Threading.Tasks;
using Content.Server.Administration.Logs;
using Content.Shared.Administration.Logs;
using Content.Shared.CharacterAppearance;
using Content.Shared.Markings;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Preferences;
using Microsoft.EntityFrameworkCore;
using Robust.Shared.Enums;
@@ -190,7 +190,6 @@ namespace Content.Server.Database
markings.Add(parsed);
}
}
var markingsSet = new MarkingsSet(markings);
return new HumanoidCharacterProfile(
profile.CharacterName,
@@ -207,7 +206,7 @@ namespace Content.Server.Database
Color.FromHex(profile.FacialHairColor),
Color.FromHex(profile.EyeColor),
Color.FromHex(profile.SkinColor),
markingsSet
markings
),
clothing,
backpack,

View File

@@ -2,7 +2,6 @@ using Content.Server.Body.Systems;
using Content.Server.DoAfter;
using Content.Server.Popups;
using Content.Shared.Actions;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.Chemistry.Components;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
@@ -12,6 +11,7 @@ using System.Threading;
using Content.Server.Chat.Systems;
using Content.Server.GameTicking;
using Content.Server.GameTicking.Rules;
using Content.Server.Humanoid;
using Content.Server.NPC;
using Content.Shared.Damage;
using Content.Shared.Dragon;
@@ -302,7 +302,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<HumanoidAppearanceComponent>(args.Target))
if (!EntityManager.HasComponent<HumanoidComponent>(args.Target))
{
ichorInjection.ScaleSolution(0.5f);
}

View File

@@ -9,7 +9,7 @@ using Content.Server.Spawners.Components;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared.CCVar;
using Content.Shared.CharacterAppearance;
using Content.Shared.Humanoid;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Robust.Server.Maps;

View File

@@ -2,6 +2,8 @@ using System.Linq;
using Content.Server.Actions;
using Content.Server.Chat.Managers;
using Content.Server.Disease;
using Content.Server.GameTicking.Rules.Configurations;
using Content.Server.Humanoid;
using Content.Server.Mind.Components;
using Content.Server.MobState;
using Content.Server.Players;
@@ -12,7 +14,7 @@ using Content.Server.Traitor;
using Content.Server.Zombies;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.CCVar;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.FixedPoint;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Preferences;
@@ -146,7 +148,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem
private void CheckRoundEnd(EntityUid target)
{
//we only care about players, not monkeys and such.
if (!HasComp<HumanoidAppearanceComponent>(target))
if (!HasComp<HumanoidComponent>(target))
return;
var percent = GetInfectedPercentage(out var num);
@@ -195,7 +197,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem
private float GetInfectedPercentage(out List<EntityUid> livingHumans)
{
var allPlayers = EntityQuery<HumanoidAppearanceComponent, MobStateComponent>(true);
var allPlayers = EntityQuery<HumanoidComponent, MobStateComponent>(true);
var allZombers = GetEntityQuery<ZombieComponent>();
var totalPlayers = new List<EntityUid>();

View File

@@ -0,0 +1,38 @@
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Preferences;
using Robust.Shared.Enums;
namespace Content.Server.Humanoid;
[RegisterComponent]
public sealed class HumanoidComponent : SharedHumanoidComponent
{
public MarkingSet CurrentMarkings = new();
/// <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>
[ViewVariables(VVAccess.ReadOnly)]
public Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> CustomBaseLayers = new();
public HashSet<HumanoidVisualLayers> PermanentlyHidden = new();
public HashSet<HumanoidVisualLayers> AllHiddenLayers
{
get
{
var result = new HashSet<HumanoidVisualLayers>(HiddenLayers);
result.UnionWith(PermanentlyHidden);
return result;
}
}
// Couldn't these be somewhere else?
[ViewVariables] public Gender Gender = default!;
[ViewVariables] public int Age = HumanoidCharacterProfile.MinimumAge;
}

View File

@@ -0,0 +1,13 @@
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
namespace Content.Server.CharacterAppearance.Components;
[RegisterComponent]
public sealed class RandomHumanoidAppearanceComponent : Component
{
[DataField("randomizeName")] public bool RandomizeName = true;
[DataField("ignoredSpecies", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<SpeciesPrototype>))]
public readonly HashSet<string> IgnoredSpecies = new();
}

View File

@@ -0,0 +1,96 @@
using Content.Server.Administration.Managers;
using Content.Shared.Administration;
using Content.Shared.Humanoid;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
using Robust.Server.Player;
namespace Content.Server.Humanoid;
public sealed partial class HumanoidSystem
{
[Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
private void OnVerbsRequest(EntityUid uid, HumanoidComponent component, GetVerbsEvent<Verb> args)
{
if (!TryComp<ActorComponent>(args.User, out var actor))
{
return;
}
if (!_adminManager.HasAdminFlag(actor.PlayerSession, AdminFlags.Fun))
{
return;
}
args.Verbs.Add(new Verb
{
Text = "Modify markings",
Category = VerbCategory.Tricks,
IconTexture = "/Textures/Mobs/Customization/reptilian_parts.rsi/tail_smooth.png",
Act = () =>
{
_uiSystem.TryOpen(uid, HumanoidMarkingModifierKey.Key, actor.PlayerSession);
_uiSystem.TrySetUiState(
uid,
HumanoidMarkingModifierKey.Key,
new HumanoidMarkingModifierState(component.CurrentMarkings, component.Species, component.SkinColor, component.CustomBaseLayers));
}
});
}
private void OnBaseLayersSet(EntityUid uid, HumanoidComponent component,
HumanoidMarkingModifierBaseLayersSetMessage message)
{
if (message.Session is not IPlayerSession player
|| !_adminManager.HasAdminFlag(player, AdminFlags.Fun))
{
return;
}
if (message.Info == null)
{
component.CustomBaseLayers.Remove(message.Layer);
}
else
{
if (!component.CustomBaseLayers.TryAdd(message.Layer, message.Info))
{
component.CustomBaseLayers[message.Layer] = message.Info;
}
}
Synchronize(uid, component);
if (message.ResendState)
{
_uiSystem.TrySetUiState(
uid,
HumanoidMarkingModifierKey.Key,
new HumanoidMarkingModifierState(component.CurrentMarkings, component.Species, component.SkinColor, component.CustomBaseLayers));
}
}
private void OnMarkingsSet(EntityUid uid, HumanoidComponent component,
HumanoidMarkingModifierMarkingSetMessage message)
{
if (message.Session is not IPlayerSession player
|| !_adminManager.HasAdminFlag(player, AdminFlags.Fun))
{
return;
}
component.CurrentMarkings = message.MarkingSet;
Synchronize(uid, component);
if (message.ResendState)
{
_uiSystem.TrySetUiState(
uid,
HumanoidMarkingModifierKey.Key,
new HumanoidMarkingModifierState(component.CurrentMarkings, component.Species, component.SkinColor, component.CustomBaseLayers));
}
}
}

View File

@@ -0,0 +1,476 @@
using System.Linq;
using Content.Server.GameTicking;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes;
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
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly MarkingManager _markingManager = default!;
public override void Initialize()
{
SubscribeLocalEvent<HumanoidComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<HumanoidComponent, HumanoidMarkingModifierMarkingSetMessage>(OnMarkingsSet);
SubscribeLocalEvent<HumanoidComponent, HumanoidMarkingModifierBaseLayersSetMessage>(OnBaseLayersSet);
SubscribeLocalEvent<HumanoidComponent, GetVerbsEvent<Verb>>(OnVerbsRequest);
}
private void Synchronize(EntityUid uid, HumanoidComponent? component = null)
{
if (!Resolve(uid, ref component))
{
return;
}
SetAppearance(uid,
component.Species,
component.CustomBaseLayers,
component.SkinColor,
component.AllHiddenLayers.ToList(),
component.CurrentMarkings.GetForwardEnumerator().ToList());
}
private void OnInit(EntityUid uid, HumanoidComponent humanoid, ComponentInit args)
{
if (string.IsNullOrEmpty(humanoid.Species))
{
return;
}
SetSpecies(uid, humanoid.Species, false, humanoid);
if (!string.IsNullOrEmpty(humanoid.Initial)
&& _prototypeManager.TryIndex(humanoid.Initial, out HumanoidProfilePrototype? startingSet))
{
// 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);
}
}
/// <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, HumanoidComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid))
{
return;
}
SetSpecies(uid, profile.Species, false, humanoid);
humanoid.Sex = profile.Sex;
SetSkinColor(uid, profile.Appearance.SkinColor, false);
SetBaseLayerColor(uid, HumanoidVisualLayers.Eyes, profile.Appearance.EyeColor, false);
humanoid.CurrentMarkings.Clear();
// Hair/facial hair - this may eventually be deprecated.
AddMarking(uid, profile.Appearance.HairStyleId, profile.Appearance.HairColor, false);
AddMarking(uid, profile.Appearance.FacialHairStyleId, profile.Appearance.FacialHairColor, false);
foreach (var marking in profile.Appearance.Markings)
{
AddMarking(uid, marking.MarkingId, marking.MarkingColors, false);
}
EnsureDefaultMarkings(uid, humanoid);
humanoid.Gender = profile.Gender;
if (TryComp<GrammarComponent>(uid, out var grammar))
{
grammar.Gender = profile.Gender;
}
humanoid.Age = profile.Age;
Synchronize(uid);
}
// 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, HumanoidComponent? sourceHumanoid = null,
HumanoidComponent? targetHumanoid = null)
{
if (!Resolve(source, ref sourceHumanoid) || !Resolve(target, ref targetHumanoid))
{
return;
}
targetHumanoid.Species = sourceHumanoid.Species;
targetHumanoid.SkinColor = sourceHumanoid.SkinColor;
targetHumanoid.Sex = sourceHumanoid.Sex;
targetHumanoid.CustomBaseLayers = new(sourceHumanoid.CustomBaseLayers);
targetHumanoid.CurrentMarkings = new(sourceHumanoid.CurrentMarkings);
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))
{
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);
}
/// <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, HumanoidComponent? 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.CurrentMarkings.AddBack(prototype.MarkingCategory, markingObject);
if (sync)
Synchronize(uid, 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, HumanoidComponent? 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.CurrentMarkings.AddBack(prototype.MarkingCategory, markingObject);
if (sync)
Synchronize(uid, humanoid);
}
/// <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, HumanoidComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid)
|| !_markingManager.Markings.TryGetValue(marking, out var prototype))
{
return;
}
humanoid.CurrentMarkings.Remove(prototype.MarkingCategory, marking);
if (sync)
Synchronize(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, HumanoidComponent? humanoid = null)
{
if (index < 0
|| !Resolve(uid, ref humanoid)
|| !humanoid.CurrentMarkings.TryGetCategory(category, out var markings)
|| index >= markings.Count)
{
return;
}
humanoid.CurrentMarkings.Remove(category, index);
Synchronize(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, HumanoidComponent? humanoid = null)
{
if (index < 0
|| !_markingManager.MarkingsByCategory(category).TryGetValue(markingId, out var markingPrototype)
|| !Resolve(uid, ref humanoid)
|| !humanoid.CurrentMarkings.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.CurrentMarkings.Replace(category, index, marking);
Synchronize(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,
HumanoidComponent? humanoid = null)
{
if (index < 0
|| !Resolve(uid, ref humanoid)
|| !humanoid.CurrentMarkings.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]);
}
Synchronize(uid, humanoid);
}
private void EnsureDefaultMarkings(EntityUid uid, HumanoidComponent? humanoid)
{
if (!Resolve(uid, ref humanoid))
{
return;
}
humanoid.CurrentMarkings.EnsureDefault(humanoid.SkinColor, _markingManager);
}
}

View File

@@ -0,0 +1,35 @@
using Content.Server.CharacterAppearance.Components;
using Content.Shared.Preferences;
namespace Content.Server.Humanoid.Systems;
public sealed class RandomHumanoidAppearanceSystem : EntitySystem
{
[Dependency] private readonly HumanoidSystem _humanoid = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RandomHumanoidAppearanceComponent, MapInitEvent>(OnMapInit);
}
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))
{
return;
}
var profile = HumanoidCharacterProfile.Random(component.IgnoredSpecies);
_humanoid.LoadProfile(uid, profile);
if (component.RandomizeName)
{
var meta = MetaData(uid);
meta.EntityName = profile.Name;
}
}
}

View File

@@ -1,6 +1,6 @@
using Content.Server.Access.Systems;
using Content.Server.Administration.Logs;
using Content.Shared.CharacterAppearance.Components;
using Content.Server.Humanoid;
using Content.Shared.Database;
using Content.Shared.Hands;
using Content.Shared.IdentityManagement;
@@ -119,7 +119,7 @@ public class IdentitySystem : SharedIdentitySystem
/// </summary>
private IdentityRepresentation GetIdentityRepresentation(EntityUid target,
InventoryComponent? inventory=null,
HumanoidAppearanceComponent? appearance=null)
HumanoidComponent? appearance=null)
{
int age = HumanoidCharacterProfile.MinimumAge;
Gender gender = Gender.Neuter;

View File

@@ -0,0 +1,6 @@
namespace Content.Server.MagicMirror;
[RegisterComponent]
public sealed class MagicMirrorComponent : Component
{
}

View File

@@ -0,0 +1,179 @@
using System.Linq;
using Content.Server.Humanoid;
using Content.Server.UserInterface;
using Content.Shared.Humanoid.Markings;
using Content.Shared.MagicMirror;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Players;
namespace Content.Server.MagicMirror;
public sealed class MagicMirrorSystem : EntitySystem
{
[Dependency] private readonly MarkingManager _markings = default!;
[Dependency] private readonly HumanoidSystem _humanoid = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MagicMirrorComponent, ActivatableUIOpenAttemptEvent>(OnOpenUIAttempt);
SubscribeLocalEvent<MagicMirrorComponent, AfterActivatableUIOpenEvent>(AfterUIOpen);
SubscribeLocalEvent<MagicMirrorComponent, MagicMirrorSelectMessage>(OnMagicMirrorSelect);
SubscribeLocalEvent<MagicMirrorComponent, MagicMirrorChangeColorMessage>(OnMagicMirrorChangeColor);
SubscribeLocalEvent<MagicMirrorComponent, MagicMirrorAddSlotMessage>(OnMagicMirrorAddSlot);
SubscribeLocalEvent<MagicMirrorComponent, MagicMirrorRemoveSlotMessage>(OnMagicMirrorRemoveSlot);
}
private void OnOpenUIAttempt(EntityUid uid, MagicMirrorComponent mirror, ActivatableUIOpenAttemptEvent args)
{
if (!HasComp<HumanoidComponent>(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))
{
return;
}
var category = MarkingCategories.Hair;
switch (message.Category)
{
case MagicMirrorCategory.Hair:
category = MarkingCategories.Hair;
break;
case MagicMirrorCategory.FacialHair:
category = MarkingCategories.FacialHair;
break;
default:
return;
}
_humanoid.SetMarkingId(message.Session.AttachedEntity.Value, category, message.Slot, message.Marking);
UpdateInterface(uid, message.Session.AttachedEntity.Value, message.Session);
}
private void OnMagicMirrorChangeColor(EntityUid uid, MagicMirrorComponent component,
MagicMirrorChangeColorMessage message)
{
if (message.Session.AttachedEntity == null || !TryComp<HumanoidComponent>(message.Session.AttachedEntity.Value, out var humanoid))
{
return;
}
var category = MarkingCategories.Hair;
switch (message.Category)
{
case MagicMirrorCategory.Hair:
category = MarkingCategories.Hair;
break;
case MagicMirrorCategory.FacialHair:
category = MarkingCategories.FacialHair;
break;
default:
return;
}
_humanoid.SetMarkingColor(message.Session.AttachedEntity.Value, category, message.Slot, message.Colors);
// using this makes the UI feel like total ass
// UpdateInterface(uid, message.Session.AttachedEntity.Value, message.Session);
}
private void OnMagicMirrorRemoveSlot(EntityUid uid, MagicMirrorComponent component,
MagicMirrorRemoveSlotMessage message)
{
if (message.Session.AttachedEntity == null || !TryComp<HumanoidComponent>(message.Session.AttachedEntity.Value, out var humanoid))
{
return;
}
var category = MarkingCategories.Hair;
switch (message.Category)
{
case MagicMirrorCategory.Hair:
category = MarkingCategories.Hair;
break;
case MagicMirrorCategory.FacialHair:
category = MarkingCategories.FacialHair;
break;
default:
return;
}
_humanoid.RemoveMarking(message.Session.AttachedEntity.Value, category, message.Slot);
UpdateInterface(uid, message.Session.AttachedEntity.Value, message.Session);
}
private void OnMagicMirrorAddSlot(EntityUid uid, MagicMirrorComponent component,
MagicMirrorAddSlotMessage message)
{
if (message.Session.AttachedEntity == null || !TryComp<HumanoidComponent>(message.Session.AttachedEntity.Value, out var humanoid))
{
return;
}
var category = MarkingCategories.Hair;
switch (message.Category)
{
case MagicMirrorCategory.Hair:
category = MarkingCategories.Hair;
break;
case MagicMirrorCategory.FacialHair:
category = MarkingCategories.FacialHair;
break;
default:
return;
}
var marking = _markings.MarkingsByCategoryAndSpecies(category, humanoid.Species).Keys.FirstOrDefault();
if (string.IsNullOrEmpty(marking))
{
return;
}
_humanoid.AddMarking(message.Session.AttachedEntity.Value, marking, Color.Black);
UpdateInterface(uid, message.Session.AttachedEntity.Value, message.Session);
}
private void UpdateInterface(EntityUid uid, EntityUid playerUid, ICommonSession session, HumanoidComponent? humanoid = null)
{
if (!Resolve(playerUid, ref humanoid) || session is not IPlayerSession player)
{
return;
}
var hair = humanoid.CurrentMarkings.TryGetCategory(MarkingCategories.Hair, out var hairMarkings)
? new List<Marking>(hairMarkings)
: new();
var facialHair = humanoid.CurrentMarkings.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,
facialHair,
humanoid.CurrentMarkings.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 actor = Comp<ActorComponent>(args.User);
UpdateInterface(uid, args.User, args.Session);
}
}

View File

@@ -10,13 +10,13 @@ using Content.Shared.Nutrition.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.CCVar;
using Content.Shared.Database;
using Content.Shared.CharacterAppearance.Components;
using Content.Server.MobState;
using Content.Server.Power.Components;
using Content.Server.Fluids.EntitySystems;
using Content.Server.Body.Components;
using Content.Server.Climbing;
using Content.Server.DoAfter;
using Content.Server.Humanoid;
using Content.Server.Mind.Components;
using Content.Server.Stack;
using Robust.Shared.Player;
@@ -210,7 +210,7 @@ namespace Content.Server.Medical.BiomassReclaimer
return false;
// Reject souled bodies in easy mode.
if (_configManager.GetCVar(CCVars.BiomassEasyMode) && HasComp<HumanoidAppearanceComponent>(dragged) &&
if (_configManager.GetCVar(CCVars.BiomassEasyMode) && HasComp<HumanoidComponent>(dragged) &&
TryComp<MindComponent>(dragged, out var mindComp))
{
if (mindComp.Mind?.UserId != null && _playerManager.TryGetSessionById(mindComp.Mind.UserId.Value, out var client))

View File

@@ -1,13 +1,12 @@
using Content.Server.Actions;
using Content.Server.Buckle.Components;
using Content.Server.Humanoid;
using Content.Server.Inventory;
using Content.Server.Mind.Commands;
using Content.Server.Mind.Components;
using Content.Server.Polymorph.Components;
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.Damage;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Polymorph;
@@ -29,7 +28,7 @@ namespace Content.Server.Polymorph.Systems
[Dependency] private readonly SharedHandsSystem _sharedHands = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly SharedHumanoidAppearanceSystem _sharedHuApp = default!;
[Dependency] private readonly HumanoidSystem _humanoid = default!;
[Dependency] private readonly ContainerSystem _container = default!;
public override void Initialize()
@@ -145,12 +144,9 @@ namespace Content.Server.Polymorph.Systems
childMeta.EntityName = targetMeta.EntityName;
}
if (proto.TransferHumanoidAppearance &&
TryComp<HumanoidAppearanceComponent>(target, out var targetHuApp) &&
TryComp<HumanoidAppearanceComponent>(child, out var childHuApp))
if (proto.TransferHumanoidAppearance)
{
_sharedHuApp.UpdateAppearance(child, targetHuApp.Appearance);
_sharedHuApp.ForceAppearanceUpdate(child);
_humanoid.CloneAppearance(target, child);
}
if (TryComp<MindComponent>(target, out var mind) && mind.Mind != null)

View File

@@ -3,10 +3,11 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Content.Server.Database;
using Content.Server.Humanoid;
using Content.Shared.CCVar;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Species;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Network;
@@ -275,7 +276,7 @@ namespace Content.Server.Preferences.Managers
case HumanoidCharacterProfile hp:
{
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var selectedSpecies = SpeciesManager.DefaultSpecies;
var selectedSpecies = HumanoidSystem.DefaultSpecies;
if (prototypeManager.TryIndex<SpeciesPrototype>(hp.Species, out var species) && species.RoundStart)
{

View File

@@ -23,8 +23,8 @@ using Content.Shared.MobState;
using Content.Server.Explosion.EntitySystems;
using System.Linq;
using Content.Server.Emag;
using Content.Server.Humanoid;
using Content.Server.Store.Components;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.FixedPoint;
using Robust.Shared.Physics.Components;
using Robust.Shared.Utility;
@@ -68,7 +68,7 @@ public sealed partial class RevenantSystem : EntitySystem
return;
}
if (!HasComp<MobStateComponent>(target) || !HasComp<HumanoidAppearanceComponent>(target) || HasComp<RevenantComponent>(target))
if (!HasComp<MobStateComponent>(target) || !HasComp<HumanoidComponent>(target) || HasComp<RevenantComponent>(target))
return;
if (!_interact.InRangeUnobstructed(uid, target))

View File

@@ -1,9 +1,9 @@
using Content.Server.Humanoid;
using Content.Server.Speech.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.CharacterAppearance;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.Humanoid;
using Robust.Shared.Audio;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
@@ -68,7 +68,7 @@ public sealed class VocalSystem : EntitySystem
return false;
var sex = Sex.Male; //the default is male because requiring humanoid appearance for this is dogshit
if (TryComp(uid, out HumanoidAppearanceComponent? humanoid))
if (TryComp(uid, out HumanoidComponent? humanoid))
sex = humanoid.Sex;
if (_random.Prob(component.WilhelmProbability))

View File

@@ -1,8 +1,8 @@
using Content.Server.Access.Systems;
using Content.Server.CharacterAppearance.Systems;
using Content.Server.DetailExaminable;
using Content.Server.Hands.Components;
using Content.Server.Hands.Systems;
using Content.Server.Humanoid;
using Content.Server.IdentityManagement;
using Content.Server.PDA;
using Content.Server.Roles;
@@ -10,11 +10,11 @@ using Content.Server.Station.Components;
using Content.Server.Mind.Commands;
using Content.Shared.Access.Systems;
using Content.Shared.CCVar;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Inventory;
using Content.Shared.PDA;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Species;
using JetBrains.Annotations;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
@@ -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 HumanoidAppearanceSystem _humanoidAppearanceSystem = default!;
[Dependency] private readonly HumanoidSystem _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 ?? SpeciesManager.DefaultSpecies).Prototype,
_prototypeManager.Index<SpeciesPrototype>(profile?.Species ?? HumanoidSystem.DefaultSpecies).Prototype,
coordinates);
if (job?.StartingGear != null)
@@ -119,7 +119,7 @@ public sealed class StationSpawningSystem : EntitySystem
if (profile != null)
{
_humanoidAppearanceSystem.UpdateFromProfile(entity, profile);
_humanoidSystem.LoadProfile(entity, profile);
EntityManager.GetComponent<MetaDataComponent>(entity).EntityName = profile.Name;
if (profile.FlavorText != "" && _configurationManager.GetCVar(CCVars.FlavorText))
{

View File

@@ -1,6 +1,6 @@
using Content.Server.Humanoid;
using Content.Shared.Store;
using Content.Shared.Species;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
namespace Content.Server.Store.Conditions;
@@ -27,7 +27,7 @@ public sealed class BuyerSpeciesCondition : ListingCondition
{
var ent = args.EntityManager;
if (!ent.TryGetComponent<HumanoidAppearanceComponent>(args.Buyer, out var appearance) || appearance.Species == null)
if (!ent.TryGetComponent<HumanoidComponent>(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

@@ -1,7 +1,5 @@
using Content.Shared.Damage;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.CharacterAppearance.Systems;
using Content.Server.Disease.Components;
using Content.Server.Body.Components;
using Content.Server.Atmos.Components;
@@ -27,7 +25,9 @@ using Content.Server.Traitor;
using Content.Shared.Zombies;
using Content.Shared.Popups;
using Content.Server.Atmos.Miasma;
using Content.Server.Humanoid;
using Content.Server.IdentityManagement;
using Content.Shared.Humanoid;
using Content.Shared.Movement.Systems;
using Robust.Shared.Audio;
@@ -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 SharedHumanoidAppearanceSystem _sharedHuApp = default!;
[Dependency] private readonly HumanoidSystem _sharedHuApp = default!;
[Dependency] private readonly IdentitySystem _identity = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!;
[Dependency] private readonly IChatManager _chatMan = default!;
@@ -123,13 +123,16 @@ namespace Content.Server.Zombies
melee.Range = 0.75f;
//We have specific stuff for humanoid zombies because they matter more
if (TryComp<HumanoidAppearanceComponent>(target, out var huApComp)) //huapcomp
if (TryComp<HumanoidComponent>(target, out var huApComp)) //huapcomp
{
//this bs is done because you can't directly update humanoid appearances
var appearance = huApComp.Appearance;
appearance = appearance.WithSkinColor(zombiecomp.SkinColor).WithEyeColor(zombiecomp.EyeColor);
_sharedHuApp.UpdateAppearance(target, appearance, huApComp);
_sharedHuApp.ForceAppearanceUpdate(target, huApComp);
_sharedHuApp.SetSkinColor(target, zombiecomp.SkinColor, humanoid: huApComp);
_sharedHuApp.SetBaseLayerColor(target, HumanoidVisualLayers.Eyes, zombiecomp.EyeColor, humanoid: huApComp);
// this might not resync on clone?
_sharedHuApp.SetBaseLayerId(target, HumanoidVisualLayers.Tail, zombiecomp.BaseLayerExternal, humanoid: huApComp);
_sharedHuApp.SetBaseLayerId(target, HumanoidVisualLayers.HeadSide, zombiecomp.BaseLayerExternal, humanoid: huApComp);
_sharedHuApp.SetBaseLayerId(target, HumanoidVisualLayers.HeadTop, zombiecomp.BaseLayerExternal, humanoid: huApComp);
_sharedHuApp.SetBaseLayerId(target, HumanoidVisualLayers.Snout, zombiecomp.BaseLayerExternal, humanoid: huApComp);
//This is done here because non-humanoids shouldn't get baller damage
//lord forgive me for the hardcoded damage

View File

@@ -2,7 +2,6 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.Body.Part;
using Content.Shared.Body.Prototypes;
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Standing;
@@ -135,7 +134,8 @@ namespace Content.Shared.Body.Components
var argsAdded = new BodyPartAddedEventArgs(slot.Id, part);
EntitySystem.Get<SharedHumanoidAppearanceSystem>().BodyPartAdded(Owner, argsAdded);
// TODO: Body refactor. Somebody is doing it
// EntitySystem.Get<SharedHumanoidAppearanceSystem>().BodyPartAdded(Owner, argsAdded);
foreach (var component in IoCManager.Resolve<IEntityManager>().GetComponents<IBodyPartAdded>(Owner).ToArray())
{
component.BodyPartAdded(argsAdded);
@@ -163,7 +163,8 @@ namespace Content.Shared.Body.Components
var args = new BodyPartRemovedEventArgs(slot.Id, part);
EntitySystem.Get<SharedHumanoidAppearanceSystem>().BodyPartRemoved(Owner, args);
// TODO: Body refactor. Somebody is doing it
// EntitySystem.Get<SharedHumanoidAppearanceSystem>().BodyPartRemoved(Owner, args);
foreach (var component in IoCManager.Resolve<IEntityManager>().GetComponents<IBodyPartRemoved>(Owner))
{
component.BodyPartRemoved(args);

View File

@@ -1,77 +0,0 @@
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.Preferences;
using Content.Shared.Species;
using Robust.Shared.Enums;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.CharacterAppearance.Components
{
[RegisterComponent]
[Access(typeof(SharedHumanoidAppearanceSystem), typeof(SharedMagicMirrorComponent))]
[NetworkedComponent]
public sealed class HumanoidAppearanceComponent : Component
{
[ViewVariables]
public HumanoidCharacterAppearance Appearance { get; set; } = HumanoidCharacterAppearance.Default();
[ViewVariables(VVAccess.ReadWrite)]
public Sex Sex { get; set; } = default!;
[ViewVariables(VVAccess.ReadWrite)]
public Gender Gender { get; set; } = default!;
[ViewVariables]
public string Species { get; set; } = SpeciesManager.DefaultSpecies;
[ViewVariables(VVAccess.ReadWrite)]
public int Age { get; set; } = HumanoidCharacterProfile.MinimumAge;
[DataField("categoriesHair")]
[ViewVariables]
public SpriteAccessoryCategories CategoriesHair { get; set; } = SpriteAccessoryCategories.HumanHair;
[DataField("categoriesFacialHair")]
[ViewVariables]
public SpriteAccessoryCategories CategoriesFacialHair { get; set; } = SpriteAccessoryCategories.HumanFacialHair;
[ViewVariables]
[DataField("canColorHair")]
public bool CanColorHair { get; set; } = true;
[ViewVariables]
[DataField("canColorFacialHair")]
public bool CanColorFacialHair { get; set; } = true;
[ViewVariables]
[DataField("hairMatchesSkin")]
public bool HairMatchesSkin { get; set; } = false;
[ViewVariables]
[DataField("hairAlpha")]
public float HairAlpha { get; set; } = 1.0f;
}
[Serializable, NetSerializable]
public sealed class HumanoidAppearanceComponentState : ComponentState
{
public HumanoidCharacterAppearance Appearance { get; }
public Sex Sex { get; }
public Gender Gender { get; }
public string Species { get; }
public int Age { get; }
public HumanoidAppearanceComponentState(HumanoidCharacterAppearance appearance,
Sex sex,
Gender gender,
string species,
int age)
{
Appearance = appearance;
Sex = sex;
Gender = gender;
Species = species;
Age = age;
}
}
}

View File

@@ -1,78 +0,0 @@
using Robust.Shared.Serialization;
namespace Content.Shared.CharacterAppearance.Components
{
[Virtual]
public class SharedMagicMirrorComponent : Component
{
[Serializable, NetSerializable]
public enum MagicMirrorUiKey
{
Key
}
[Serializable, NetSerializable]
public sealed class HairSelectedMessage : BoundUserInterfaceMessage
{
public readonly string HairId;
public readonly bool IsFacialHair;
public HairSelectedMessage(string id, bool isFacialHair)
{
HairId = id;
IsFacialHair = isFacialHair;
}
}
[Serializable, NetSerializable]
public sealed class HairColorSelectedMessage : BoundUserInterfaceMessage
{
public (byte r, byte g, byte b) HairColor;
public readonly bool IsFacialHair;
public HairColorSelectedMessage((byte r, byte g, byte b) color, bool isFacialHair)
{
HairColor = color;
IsFacialHair = isFacialHair;
}
}
[Serializable, NetSerializable]
public sealed class EyeColorSelectedMessage : BoundUserInterfaceMessage
{
public (byte r, byte g, byte b) EyeColor;
public EyeColorSelectedMessage((byte r, byte g, byte b) color)
{
EyeColor = color;
}
}
[Serializable, NetSerializable]
public sealed class MagicMirrorInitialDataMessage : BoundUserInterfaceMessage
{
public readonly Color HairColor;
public readonly Color FacialHairColor;
public readonly string HairId;
public readonly string FacialHairId;
public readonly Color EyeColor;
public readonly SpriteAccessoryCategories CategoriesHair;
public readonly SpriteAccessoryCategories CategoriesFacialHair;
public readonly bool CanColorHair;
public readonly bool CanColorFacialHair;
public MagicMirrorInitialDataMessage(Color hairColor, Color facialHairColor, string hairId, string facialHairId, Color eyeColor, SpriteAccessoryCategories categoriesHair, SpriteAccessoryCategories categoriesFacialHair, bool canColorHair, bool canColorFacialHair)
{
HairColor = hairColor;
FacialHairColor = facialHairColor;
HairId = hairId;
FacialHairId = facialHairId;
EyeColor = eyeColor;
CategoriesHair = categoriesHair;
CategoriesFacialHair = categoriesFacialHair;
CanColorHair = canColorHair;
CanColorFacialHair = canColorFacialHair;
}
}
}
}

View File

@@ -1,31 +0,0 @@
namespace Content.Shared.CharacterAppearance
{
public static class HairStyles
{
public const string DefaultHairStyle = "HairBald";
public const string DefaultFacialHairStyle = "FacialHairShaved";
public static readonly IReadOnlyList<Color> RealisticHairColors = new List<Color>
{
Color.Yellow,
Color.Black,
Color.SandyBrown,
Color.Brown,
Color.Wheat,
Color.Gray
};
// These comparers put the default hair style (shaved/bald) at the very top.
// For in the hair style pickers.
public static readonly IComparer<SpriteAccessoryPrototype> SpriteAccessoryComparer =
Comparer<SpriteAccessoryPrototype>.Create((a, b) =>
{
var cmp = -a.Priority.CompareTo(b.Priority);
if (cmp != 0)
return cmp;
return string.Compare(a.Name, b.Name, StringComparison.CurrentCulture);
});
}
}

View File

@@ -1,95 +0,0 @@
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
namespace Content.Shared.CharacterAppearance
{
public static class HumanoidVisualLayersExtension
{
public static IEnumerable<HumanoidVisualLayers> ToHumanoidLayers(this SharedBodyPartComponent part)
{
switch (part.PartType)
{
case BodyPartType.Other:
yield break;
case BodyPartType.Torso:
yield return HumanoidVisualLayers.Chest;
break;
case BodyPartType.Tail:
yield return HumanoidVisualLayers.Tail;
break;
case BodyPartType.Head:
yield return HumanoidVisualLayers.Head;
yield return HumanoidVisualLayers.Snout;
yield return HumanoidVisualLayers.HeadSide;
yield return HumanoidVisualLayers.HeadTop;
yield return HumanoidVisualLayers.Eyes;
yield return HumanoidVisualLayers.FacialHair;
yield return HumanoidVisualLayers.Hair;
yield return HumanoidVisualLayers.StencilMask;
break;
case BodyPartType.Arm:
switch (part.Symmetry)
{
case BodyPartSymmetry.None:
yield break;
case BodyPartSymmetry.Left:
yield return HumanoidVisualLayers.LArm;
break;
case BodyPartSymmetry.Right:
yield return HumanoidVisualLayers.RArm;
break;
default:
yield break;
}
yield break;
case BodyPartType.Hand:
switch (part.Symmetry)
{
case BodyPartSymmetry.None:
yield break;
case BodyPartSymmetry.Left:
yield return HumanoidVisualLayers.LHand;
break;
case BodyPartSymmetry.Right:
yield return HumanoidVisualLayers.RHand;
break;
default:
yield break;
}
yield break;
case BodyPartType.Leg:
switch (part.Symmetry)
{
case BodyPartSymmetry.None:
yield break;
case BodyPartSymmetry.Left:
yield return HumanoidVisualLayers.LLeg;
break;
case BodyPartSymmetry.Right:
yield return HumanoidVisualLayers.RLeg;
break;
default:
yield break;
}
yield break;
case BodyPartType.Foot:
switch (part.Symmetry)
{
case BodyPartSymmetry.None:
yield break;
case BodyPartSymmetry.Left:
yield return HumanoidVisualLayers.LFoot;
break;
case BodyPartSymmetry.Right:
yield return HumanoidVisualLayers.RFoot;
break;
default:
yield break;
}
yield break;
default:
yield break;
}
}
}
}

View File

@@ -1,15 +0,0 @@
using Robust.Shared.Serialization;
namespace Content.Shared.CharacterAppearance
{
[Flags]
[Serializable, NetSerializable]
public enum SpriteAccessoryCategories
{
None = 0,
HumanHair = 1 << 0,
HumanFacialHair = 1 << 1,
VoxHair = 1 << 2,
VoxFacialHair = 1 << 3
}
}

View File

@@ -1,64 +0,0 @@
using Robust.Shared.Prototypes;
namespace Content.Shared.CharacterAppearance
{
public sealed class SpriteAccessoryManager
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private readonly Dictionary<SpriteAccessoryCategories, List<SpriteAccessoryPrototype>> _index = new();
public void Initialize()
{
_prototypeManager.PrototypesReloaded += OnPrototypesReloaded;
foreach (var category in Enum.GetValues<SpriteAccessoryCategories>())
{
_index.Add(category, new List<SpriteAccessoryPrototype>());
}
foreach (var prototype in _prototypeManager.EnumeratePrototypes<SpriteAccessoryPrototype>())
{
AddToIndexes(prototype);
}
}
public IReadOnlyList<SpriteAccessoryPrototype> AccessoriesForCategory(SpriteAccessoryCategories categories)
{
return _index[categories];
}
public bool IsValidAccessoryInCategory(string accessory, SpriteAccessoryCategories categories)
{
return _prototypeManager.TryIndex(accessory, out SpriteAccessoryPrototype? accessoryPrototype)
&& (accessoryPrototype.Categories & categories) != 0;
}
private void OnPrototypesReloaded(PrototypesReloadedEventArgs eventArgs)
{
if (!eventArgs.ByType.TryGetValue(typeof(SpriteAccessoryPrototype), out var set))
return;
foreach (var list in _index.Values)
{
list.RemoveAll(a => set.Modified.ContainsKey(a.ID));
}
foreach (var prototype in set.Modified.Values)
{
var accessoryPrototype = (SpriteAccessoryPrototype) prototype;
AddToIndexes(accessoryPrototype);
}
}
private void AddToIndexes(SpriteAccessoryPrototype accessoryPrototype)
{
for (var i = 0; i < sizeof(SpriteAccessoryCategories) * 8; i++)
{
var flag = (SpriteAccessoryCategories) (1 << i);
if ((accessoryPrototype.Categories & flag) != 0)
_index[flag].Add(accessoryPrototype);
}
}
}
}

View File

@@ -1,31 +0,0 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Shared.CharacterAppearance
{
/// <summary>
/// Contains data for a single hair style
/// </summary>
[Prototype("spriteAccessory")]
public sealed class SpriteAccessoryPrototype : IPrototype, ISerializationHooks
{
[IdDataFieldAttribute]
public string ID { get; } = default!;
[DataField("categories", required: true)]
public SpriteAccessoryCategories Categories { get; } = default!;
public string Name { get; private set; } = default!;
[DataField("sprite", required: true)]
public SpriteSpecifier Sprite { get; } = default!;
[DataField("priority")] public int Priority { get; } = 0;
void ISerializationHooks.AfterDeserialization()
{
Name = Loc.GetString($"accessory-{ID}");
}
}
}

View File

@@ -1,189 +0,0 @@
using Content.Shared.Body.Part;
using Content.Shared.Examine;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.Preferences;
using Content.Shared.IdentityManagement;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects.Components.Localization;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Prototypes;
using Content.Shared.Species;
namespace Content.Shared.CharacterAppearance.Systems
{
public abstract class SharedHumanoidAppearanceSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override void Initialize()
{
SubscribeLocalEvent<HumanoidAppearanceComponent, ComponentGetState>(OnAppearanceGetState);
SubscribeLocalEvent<HumanoidAppearanceComponent, ComponentHandleState>(OnAppearanceHandleState);
SubscribeLocalEvent<HumanoidAppearanceComponent, ExaminedEvent>(OnExamined);
}
public void UpdateFromProfile(EntityUid uid, ICharacterProfile profile, HumanoidAppearanceComponent? appearance=null)
{
var humanoid = (HumanoidCharacterProfile) profile;
UpdateAppearance(uid, humanoid.Appearance, humanoid.Sex, humanoid.Gender, humanoid.Species, humanoid.Age, appearance);
}
// The magic mirror otherwise wouldn't work. (it directly modifies the component server-side)
public void ForceAppearanceUpdate(EntityUid uid, HumanoidAppearanceComponent? component = null)
{
if (!Resolve(uid, ref component)) return;
component.Dirty();
}
public void UpdateAppearance(EntityUid uid, HumanoidCharacterAppearance appearance, Sex sex, Gender gender, string species, int age, HumanoidAppearanceComponent? component = null)
{
if (!Resolve(uid, ref component)) return;
component.Appearance = appearance;
component.Sex = sex;
component.Gender = gender;
component.Species = species;
component.Age = age;
if (EntityManager.TryGetComponent(uid, out GrammarComponent? g))
g.Gender = gender;
component.Dirty();
RaiseLocalEvent(uid, new ChangedHumanoidAppearanceEvent(appearance, sex, gender, species), true);
}
public void UpdateAppearance(EntityUid uid, HumanoidCharacterAppearance appearance, HumanoidAppearanceComponent? component = null)
{
if (!Resolve(uid, ref component)) return;
component.Appearance = appearance;
component.Dirty();
RaiseLocalEvent(uid, new ChangedHumanoidAppearanceEvent(appearance, component.Sex, component.Gender, component.Species), true);
}
public void UpdateSexGender(EntityUid uid, Sex sex, Gender gender, HumanoidAppearanceComponent? component = null)
{
if (!Resolve(uid, ref component)) return;
component.Sex = sex;
component.Gender = gender;
component.Dirty();
RaiseLocalEvent(uid, new ChangedHumanoidAppearanceEvent(component.Appearance, component.Sex, component.Gender, component.Species), true);
}
/// <summary>
/// Takes ID of the species prototype, returns UI-friendly name of the species.
/// </summary>
public string GetSpeciesRepresentation(string speciesId)
{
if (_prototypeManager.TryIndex<SpeciesPrototype>(speciesId, out var species))
{
return Loc.GetString(species.Name);
}
else
{
return Loc.GetString("humanoid-appearance-component-unknown-species");
}
}
public string GetAgeRepresentation(int age)
{
return age switch
{
<= 30 => Loc.GetString("identity-age-young"),
> 30 and <= 60 => Loc.GetString("identity-age-middle-aged"),
> 60 => Loc.GetString("identity-age-old")
};
}
private void OnAppearanceGetState(EntityUid uid, HumanoidAppearanceComponent component, ref ComponentGetState args)
{
args.State = new HumanoidAppearanceComponentState(component.Appearance, component.Sex, component.Gender, component.Species, component.Age);
}
private void OnAppearanceHandleState(EntityUid uid, HumanoidAppearanceComponent component, ref ComponentHandleState args)
{
if (args.Current is not HumanoidAppearanceComponentState state)
return;
UpdateAppearance(uid, state.Appearance, state.Sex, state.Gender, state.Species, state.Age);
}
// Scaffolding until Body is moved to ECS.
public void BodyPartAdded(EntityUid uid, BodyPartAddedEventArgs args)
{
RaiseLocalEvent(new HumanoidAppearanceBodyPartAddedEvent(uid, args));
}
public void BodyPartRemoved(EntityUid uid, BodyPartRemovedEventArgs args)
{
RaiseLocalEvent(new HumanoidAppearanceBodyPartRemovedEvent(uid, args));
}
// Scaffolding until Body is moved to ECS.
[Serializable, NetSerializable]
public sealed class HumanoidAppearanceBodyPartAddedEvent : EntityEventArgs
{
public EntityUid Uid { get; }
public BodyPartAddedEventArgs Args { get; }
public HumanoidAppearanceBodyPartAddedEvent(EntityUid uid, BodyPartAddedEventArgs args)
{
Uid = uid;
Args = args;
}
}
[Serializable, NetSerializable]
public sealed class HumanoidAppearanceBodyPartRemovedEvent : EntityEventArgs
{
public EntityUid Uid { get; }
public BodyPartRemovedEventArgs Args { get; }
public HumanoidAppearanceBodyPartRemovedEvent(EntityUid uid, BodyPartRemovedEventArgs args)
{
Uid = uid;
Args = args;
}
}
[Serializable, NetSerializable]
public sealed class ChangedHumanoidAppearanceEvent : EntityEventArgs
{
public HumanoidCharacterAppearance Appearance { get; }
public Sex Sex { get; }
public Gender Gender { get; }
public string Species { get; }
public ChangedHumanoidAppearanceEvent(HumanoidCharacterProfile profile)
{
Appearance = profile.Appearance;
Sex = profile.Sex;
Gender = profile.Gender;
Species = profile.Species;
}
public ChangedHumanoidAppearanceEvent(HumanoidCharacterAppearance appearance, Sex sex, Gender gender, string species)
{
Appearance = appearance;
Sex = sex;
Gender = gender;
Species = species;
}
}
private void OnExamined(EntityUid uid, HumanoidAppearanceComponent component, ExaminedEvent args)
{
var identity = Identity.Entity(component.Owner, EntityManager);
var species = GetSpeciesRepresentation(component.Species).ToLower();
var age = GetAgeRepresentation(component.Age);
args.PushText(Loc.GetString("humanoid-appearance-component-examine", ("user", identity), ("age", age), ("species", species)));
}
}
}

View File

@@ -1,10 +1,9 @@
using Content.Shared.CharacterAppearance;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Humanoid.Markings;
using Content.Shared.IoC;
using Content.Shared.Localizations;
using Content.Shared.Maps;
using Content.Shared.Markings;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
@@ -35,7 +34,6 @@ namespace Content.Shared.Entry
base.PostInit();
InitTileDefinitions();
IoCManager.Resolve<SpriteAccessoryManager>().Initialize();
IoCManager.Resolve<MarkingManager>().Initialize();
var configMan = IoCManager.Resolve<IConfigurationManager>();

View File

@@ -0,0 +1,18 @@
namespace Content.Shared.Humanoid
{
public static class HairStyles
{
public const string DefaultHairStyle = "HairBald";
public const string DefaultFacialHairStyle = "FacialHairShaved";
public static readonly IReadOnlyList<Color> RealisticHairColors = new List<Color>
{
Color.Yellow,
Color.Black,
Color.SandyBrown,
Color.Brown,
Color.Wheat,
Color.Gray
};
}
}

View File

@@ -1,9 +1,13 @@
using Content.Shared.Markings;
using System.Linq;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
namespace Content.Shared.CharacterAppearance
namespace Content.Shared.Humanoid
{
[DataDefinition]
[Serializable, NetSerializable]
public sealed class HumanoidCharacterAppearance : ICharacterAppearance
{
@@ -13,7 +17,7 @@ namespace Content.Shared.CharacterAppearance
Color facialHairColor,
Color eyeColor,
Color skinColor,
MarkingsSet markings)
List<Marking> markings)
{
HairStyleId = hairStyleId;
HairColor = ClampColor(hairColor);
@@ -24,13 +28,26 @@ namespace Content.Shared.CharacterAppearance
Markings = markings;
}
[DataField("hair")]
public string HairStyleId { get; }
[DataField("hairColor")]
public Color HairColor { get; }
[DataField("facialHair")]
public string FacialHairStyleId { get; }
[DataField("facialHairColor")]
public Color FacialHairColor { get; }
[DataField("eyeColor")]
public Color EyeColor { get; }
[DataField("skinColor")]
public Color SkinColor { get; }
public MarkingsSet Markings { get; }
[DataField("markings")]
public List<Marking> Markings { get; }
public HumanoidCharacterAppearance WithHairStyleName(string newName)
{
@@ -62,7 +79,7 @@ namespace Content.Shared.CharacterAppearance
return new(HairStyleId, HairColor, FacialHairStyleId, FacialHairColor, EyeColor, newColor, Markings);
}
public HumanoidCharacterAppearance WithMarkings(MarkingsSet newMarkings)
public HumanoidCharacterAppearance WithMarkings(List<Marking> newMarkings)
{
return new(HairStyleId, HairColor, FacialHairStyleId, FacialHairColor, EyeColor, SkinColor, newMarkings);
}
@@ -75,23 +92,34 @@ namespace Content.Shared.CharacterAppearance
HairStyles.DefaultFacialHairStyle,
Color.Black,
Color.Black,
Color.FromHex("#C0967F"),
new MarkingsSet()
Humanoid.SkinColor.ValidHumanSkinTone,
new ()
);
}
public static HumanoidCharacterAppearance Random(Sex sex)
private static IReadOnlyList<Color> RealisticEyeColors = new List<Color>
{
Color.Brown,
Color.Gray,
Color.Azure,
Color.SteelBlue,
Color.Black
};
public static HumanoidCharacterAppearance Random(string species, Sex sex)
{
var random = IoCManager.Resolve<IRobustRandom>();
var prototypes = IoCManager.Resolve<SpriteAccessoryManager>();
var hairStyles = prototypes.AccessoriesForCategory(SpriteAccessoryCategories.HumanHair);
var facialHairStyles = prototypes.AccessoriesForCategory(SpriteAccessoryCategories.HumanHair);
var markingManager = IoCManager.Resolve<MarkingManager>();
var hairStyles = markingManager.MarkingsByCategoryAndSpecies(MarkingCategories.Hair, species).Keys.ToList();
var facialHairStyles = markingManager.MarkingsByCategoryAndSpecies(MarkingCategories.FacialHair, species).Keys.ToList();
var newHairStyle = random.Pick(hairStyles).ID;
var newHairStyle = hairStyles.Count > 0
? random.Pick(hairStyles)
: HairStyles.DefaultHairStyle;
var newFacialHairStyle = sex == Sex.Female
var newFacialHairStyle = facialHairStyles.Count == 0 || sex == Sex.Female
? HairStyles.DefaultFacialHairStyle
: random.Pick(facialHairStyles).ID;
: random.Pick(facialHairStyles);
var newHairColor = random.Pick(HairStyles.RealisticHairColors);
newHairColor = newHairColor
@@ -99,8 +127,34 @@ namespace Content.Shared.CharacterAppearance
.WithGreen(RandomizeColor(newHairColor.G))
.WithBlue(RandomizeColor(newHairColor.B));
// TODO: Add random eye and skin color
return new HumanoidCharacterAppearance(newHairStyle, newHairColor, newFacialHairStyle, newHairColor, Color.Black, Color.FromHex("#C0967F"), new MarkingsSet());
// TODO: Add random markings
var newEyeColor = random.Pick(RealisticEyeColors);
var skinType = IoCManager.Resolve<IPrototypeManager>().Index<SpeciesPrototype>(species).SkinColoration;
var newSkinColor = Humanoid.SkinColor.ValidHumanSkinTone;
switch (skinType)
{
case HumanoidSkinColor.HumanToned:
var tone = random.Next(0, 100);
newSkinColor = Humanoid.SkinColor.HumanSkinTone(tone);
break;
case HumanoidSkinColor.Hues:
case HumanoidSkinColor.TintedHues:
var rbyte = random.Next(0, 255);
var gbyte = random.Next(0, 255);
var bbyte = random.Next(0, 255);
newSkinColor = new Color(rbyte, gbyte, bbyte);
break;
}
if (skinType == HumanoidSkinColor.TintedHues)
{
newSkinColor = Humanoid.SkinColor.ValidTintedHuesSkinTone(newSkinColor);
}
return new HumanoidCharacterAppearance(newHairStyle, newHairColor, newFacialHairStyle, newHairColor, newEyeColor, newSkinColor, new ());
float RandomizeColor(float channel)
{
@@ -115,26 +169,52 @@ namespace Content.Shared.CharacterAppearance
public static HumanoidCharacterAppearance EnsureValid(HumanoidCharacterAppearance appearance, string species)
{
var mgr = IoCManager.Resolve<SpriteAccessoryManager>();
var hairStyleId = appearance.HairStyleId;
if (!mgr.IsValidAccessoryInCategory(hairStyleId, SpriteAccessoryCategories.HumanHair))
{
hairStyleId = HairStyles.DefaultHairStyle;
}
var facialHairStyleId = appearance.FacialHairStyleId;
if (!mgr.IsValidAccessoryInCategory(facialHairStyleId, SpriteAccessoryCategories.HumanFacialHair))
{
facialHairStyleId = HairStyles.DefaultFacialHairStyle;
}
var hairColor = ClampColor(appearance.HairColor);
var facialHairColor = ClampColor(appearance.FacialHairColor);
var eyeColor = ClampColor(appearance.EyeColor);
var skinColor = ClampColor(appearance.SkinColor);
var validMarkingsSet = MarkingsSet.EnsureValid(appearance.Markings);
validMarkingsSet = MarkingsSet.FilterSpecies(validMarkingsSet, species);
var proto = IoCManager.Resolve<IPrototypeManager>();
var markingManager = IoCManager.Resolve<MarkingManager>();
if (!markingManager.MarkingsByCategory(MarkingCategories.Hair).ContainsKey(hairStyleId))
{
hairStyleId = HairStyles.DefaultHairStyle;
}
if (!markingManager.MarkingsByCategory(MarkingCategories.FacialHair).ContainsKey(facialHairStyleId))
{
facialHairStyleId = HairStyles.DefaultFacialHairStyle;
}
var markingSet = new MarkingSet();
var skinColor = appearance.SkinColor;
if (proto.TryIndex(species, out SpeciesPrototype? speciesProto))
{
markingSet = new MarkingSet(appearance.Markings, speciesProto.MarkingPoints, markingManager, proto);
markingSet.EnsureValid(markingManager);
markingSet.FilterSpecies(species, markingManager);
switch (speciesProto.SkinColoration)
{
case HumanoidSkinColor.HumanToned:
if (!Humanoid.SkinColor.VerifyHumanSkinTone(skinColor))
{
skinColor = Humanoid.SkinColor.ValidHumanSkinTone;
}
break;
case HumanoidSkinColor.TintedHues:
if (!Humanoid.SkinColor.VerifyTintedHues(skinColor))
{
skinColor = Humanoid.SkinColor.ValidTintedHuesSkinTone(skinColor);
}
break;
}
}
return new HumanoidCharacterAppearance(
hairStyleId,
@@ -143,7 +223,7 @@ namespace Content.Shared.CharacterAppearance
facialHairColor,
eyeColor,
skinColor,
validMarkingsSet);
markingSet.GetForwardEnumerator().ToList());
}
public bool MemberwiseEquals(ICharacterAppearance maybeOther)
@@ -155,7 +235,7 @@ namespace Content.Shared.CharacterAppearance
if (!FacialHairColor.Equals(other.FacialHairColor)) return false;
if (!EyeColor.Equals(other.EyeColor)) return false;
if (!SkinColor.Equals(other.SkinColor)) return false;
if (!Markings.Equals(other.Markings)) return false;
if (!Markings.SequenceEqual(other.Markings)) return false;
return true;
}
}

View File

@@ -1,6 +1,6 @@
using Robust.Shared.Serialization;
namespace Content.Shared.CharacterAppearance
namespace Content.Shared.Humanoid
{
[Serializable, NetSerializable]
public enum HumanoidVisualLayers : byte

View File

@@ -0,0 +1,127 @@
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
namespace Content.Shared.Humanoid
{
public static class HumanoidVisualLayersExtension
{
public static bool HasSexMorph(HumanoidVisualLayers layer)
{
return layer switch
{
HumanoidVisualLayers.Chest => true,
HumanoidVisualLayers.Head => true,
_ => false
};
}
/// <summary>
/// Sublayers. Any other layers that may visually depend on this layer existing.
/// For example, the head has layers such as eyes, hair, etc. depending on it.
/// </summary>
/// <param name="layer"></param>
/// <returns>Enumerable of layers that depend on that given layer. Empty, otherwise.</returns>
/// <remarks>This could eventually be replaced by a body system implementation.</remarks>
public static IEnumerable<HumanoidVisualLayers> Sublayers(HumanoidVisualLayers layer)
{
switch (layer)
{
case HumanoidVisualLayers.Head:
yield return HumanoidVisualLayers.Head;
yield return HumanoidVisualLayers.Eyes;
yield return HumanoidVisualLayers.HeadSide;
yield return HumanoidVisualLayers.HeadTop;
yield return HumanoidVisualLayers.Hair;
yield return HumanoidVisualLayers.FacialHair;
yield return HumanoidVisualLayers.Snout;
break;
case HumanoidVisualLayers.LArm:
yield return HumanoidVisualLayers.LArm;
yield return HumanoidVisualLayers.LHand;
break;
case HumanoidVisualLayers.RArm:
yield return HumanoidVisualLayers.RArm;
yield return HumanoidVisualLayers.RHand;
break;
case HumanoidVisualLayers.LLeg:
yield return HumanoidVisualLayers.LLeg;
yield return HumanoidVisualLayers.LFoot;
break;
case HumanoidVisualLayers.RLeg:
yield return HumanoidVisualLayers.RLeg;
yield return HumanoidVisualLayers.RFoot;
break;
case HumanoidVisualLayers.Chest:
yield return HumanoidVisualLayers.Chest;
yield return HumanoidVisualLayers.Tail;
break;
default:
yield break;
}
}
public static HumanoidVisualLayers? ToHumanoidLayers(this SharedBodyPartComponent part)
{
switch (part.PartType)
{
case BodyPartType.Other:
break;
case BodyPartType.Torso:
return HumanoidVisualLayers.Chest;
case BodyPartType.Tail:
return HumanoidVisualLayers.Tail;
case BodyPartType.Head:
// use the Sublayers method to hide the rest of the parts,
// if that's what you're looking for
return HumanoidVisualLayers.Head;
break;
case BodyPartType.Arm:
switch (part.Symmetry)
{
case BodyPartSymmetry.None:
break;
case BodyPartSymmetry.Left:
return HumanoidVisualLayers.LArm;
case BodyPartSymmetry.Right:
return HumanoidVisualLayers.RArm;
}
break;
case BodyPartType.Hand:
switch (part.Symmetry)
{
case BodyPartSymmetry.None:
break;
case BodyPartSymmetry.Left:
return HumanoidVisualLayers.LHand;
case BodyPartSymmetry.Right:
return HumanoidVisualLayers.RHand;
}
break;
case BodyPartType.Leg:
switch (part.Symmetry)
{
case BodyPartSymmetry.None:
break;
case BodyPartSymmetry.Left:
return HumanoidVisualLayers.LLeg;
case BodyPartSymmetry.Right:
return HumanoidVisualLayers.RLeg;
}
break;
case BodyPartType.Foot:
switch (part.Symmetry)
{
case BodyPartSymmetry.None:
break;
case BodyPartSymmetry.Left:
return HumanoidVisualLayers.LFoot;
case BodyPartSymmetry.Right:
return HumanoidVisualLayers.RFoot;
}
break;
}
return null;
}
}
}

View File

@@ -0,0 +1,34 @@
using Content.Shared.Humanoid.Markings;
using Robust.Shared.Serialization;
namespace Content.Shared.Humanoid;
[Serializable, NetSerializable]
public enum HumanoidVisualizerKey
{
Key
}
[Serializable, NetSerializable]
public sealed class HumanoidVisualizerData : ICloneable
{
public HumanoidVisualizerData(string species, Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> customBaseLayerInfo, Color skinColor, List<HumanoidVisualLayers> layerVisibility, List<Marking> markings)
{
Species = species;
CustomBaseLayerInfo = customBaseLayerInfo;
SkinColor = skinColor;
LayerVisibility = layerVisibility;
Markings = markings;
}
public string Species { get; }
public Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> CustomBaseLayerInfo { get; }
public Color SkinColor { get; }
public List<HumanoidVisualLayers> LayerVisibility { get; }
public List<Marking> Markings { get; }
public object Clone()
{
return new HumanoidVisualizerData(Species, new(CustomBaseLayerInfo), SkinColor, new(LayerVisibility), new(Markings));
}
}

View File

@@ -1,5 +1,5 @@
namespace Content.Shared.CharacterAppearance
namespace Content.Shared.Humanoid
{
public interface ICharacterAppearance
{

View File

@@ -1,10 +1,12 @@
using System.Linq;
using Robust.Shared.Serialization;
namespace Content.Shared.Markings
namespace Content.Shared.Humanoid.Markings
{
[Serializable, NetSerializable]
public sealed class Marking : IEquatable<Marking>, IComparable<Marking>, IComparable<string>
{
[DataField("markingColor")]
private List<Color> _markingColors = new();
private Marking(string markingId,
@@ -20,13 +22,6 @@ namespace Content.Shared.Markings
{
}
/*
public Marking(string markingId)
: this(markingId, new List<Color>())
{
}
*/
public Marking(string markingId, int colorCount)
{
MarkingId = markingId;
@@ -36,35 +31,76 @@ namespace Content.Shared.Markings
_markingColors = colors;
}
public Marking(Marking other)
{
MarkingId = other.MarkingId;
_markingColors = new(other.MarkingColors);
Visible = other.Visible;
Forced = other.Forced;
}
/// <summary>
/// ID of the marking prototype.
/// </summary>
[DataField("markingId")]
[ViewVariables]
public string MarkingId { get; } = default!;
[DataField("markingColor")]
/// <summary>
/// All colors currently on this marking.
/// </summary>
[ViewVariables]
public IReadOnlyList<Color> MarkingColors => _markingColors;
/// <summary>
/// If this marking is currently visible.
/// </summary>
[ViewVariables]
public bool Visible = true;
/// <summary>
/// If this marking should be forcefully applied, regardless of points.
/// </summary>
[ViewVariables]
public bool Forced;
public void SetColor(int colorIndex, Color color) =>
_markingColors[colorIndex] = color;
public int CompareTo(Marking? marking)
{
if (marking == null) return 1;
else return this.MarkingId.CompareTo(marking.MarkingId);
if (marking == null)
{
return 1;
}
return MarkingId.CompareTo(marking.MarkingId);
}
public int CompareTo(string? markingId)
{
if (markingId == null) return 1;
return this.MarkingId.CompareTo(markingId);
if (markingId == null)
{
return 1;
}
return MarkingId.CompareTo(markingId);
}
public bool Equals(Marking? other)
{
if (other == null) return false;
return (this.MarkingId.Equals(other.MarkingId));
if (other == null)
{
return false;
}
return MarkingId.Equals(other.MarkingId)
&& _markingColors.SequenceEqual(other._markingColors)
&& Visible.Equals(other.Visible)
&& Forced.Equals(other.Forced);
}
// VERY BIG TODO: TURN THIS INTO JSONSERIALIZER IMPLEMENTATION
// look this could be better but I don't think serializing
// colors is the correct thing to do

View File

@@ -0,0 +1,47 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Humanoid.Markings
{
[Serializable, NetSerializable]
public enum MarkingCategories : byte
{
Hair,
FacialHair,
Head,
HeadTop,
HeadSide,
Snout,
Chest,
Arms,
Legs,
Tail,
Overlay
}
public static class MarkingCategoriesConversion
{
public static MarkingCategories FromHumanoidVisualLayers(HumanoidVisualLayers layer)
{
return layer switch
{
HumanoidVisualLayers.Hair => MarkingCategories.Hair,
HumanoidVisualLayers.FacialHair => MarkingCategories.FacialHair,
HumanoidVisualLayers.Head => MarkingCategories.Head,
HumanoidVisualLayers.HeadTop => MarkingCategories.HeadTop,
HumanoidVisualLayers.HeadSide => MarkingCategories.HeadSide,
HumanoidVisualLayers.Snout => MarkingCategories.Snout,
HumanoidVisualLayers.Chest => MarkingCategories.Chest,
HumanoidVisualLayers.RArm => MarkingCategories.Arms,
HumanoidVisualLayers.LArm => MarkingCategories.Arms,
HumanoidVisualLayers.RHand => MarkingCategories.Arms,
HumanoidVisualLayers.LHand => MarkingCategories.Arms,
HumanoidVisualLayers.LLeg => MarkingCategories.Legs,
HumanoidVisualLayers.RLeg => MarkingCategories.Legs,
HumanoidVisualLayers.LFoot => MarkingCategories.Legs,
HumanoidVisualLayers.RFoot => MarkingCategories.Legs,
HumanoidVisualLayers.Tail => MarkingCategories.Tail,
_ => MarkingCategories.Overlay
};
}
}
}

View File

@@ -0,0 +1,124 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Prototypes;
namespace Content.Shared.Humanoid.Markings
{
public sealed class MarkingManager
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private readonly List<MarkingPrototype> _index = new();
private readonly Dictionary<MarkingCategories, Dictionary<string, MarkingPrototype>> _markingDict = new();
private readonly Dictionary<string, MarkingPrototype> _markings = new();
public void Initialize()
{
_prototypeManager.PrototypesReloaded += OnPrototypeReload;
foreach (var category in Enum.GetValues<MarkingCategories>())
{
_markingDict.Add(category, new Dictionary<string, MarkingPrototype>());
}
foreach (var prototype in _prototypeManager.EnumeratePrototypes<MarkingPrototype>())
{
_index.Add(prototype);
_markingDict[prototype.MarkingCategory].Add(prototype.ID, prototype);
_markings.Add(prototype.ID, prototype);
}
}
public IReadOnlyDictionary<string, MarkingPrototype> Markings => _markings;
public IReadOnlyDictionary<MarkingCategories, Dictionary<string, MarkingPrototype>> CategorizedMarkings => _markingDict;
public IReadOnlyDictionary<string, MarkingPrototype> MarkingsByCategory(MarkingCategories category)
{
// all marking categories are guaranteed to have a dict entry
return _markingDict[category];
}
/// <summary>
/// Markings by category and species.
/// </summary>
/// <param name="category"></param>
/// <param name="species"></param>
/// <remarks>
/// This is done per category, as enumerating over every single marking by species isn't useful.
/// Please make a pull request if you find a use case for that behavior.
/// </remarks>
/// <returns></returns>
public IReadOnlyDictionary<string, MarkingPrototype> MarkingsByCategoryAndSpecies(MarkingCategories category,
string species)
{
var speciesProto = _prototypeManager.Index<SpeciesPrototype>(species);
var onlyWhitelisted = _prototypeManager.Index<MarkingPointsPrototype>(speciesProto.MarkingPoints).OnlyWhitelisted;
var res = new Dictionary<string, MarkingPrototype>();
foreach (var (key, marking) in MarkingsByCategory(category))
{
if (onlyWhitelisted && marking.SpeciesRestrictions == null)
{
continue;
}
if (marking.SpeciesRestrictions != null && !marking.SpeciesRestrictions.Contains(species))
{
continue;
}
res.Add(key, marking);
}
return res;
}
public bool TryGetMarking(Marking marking, [NotNullWhen(true)] out MarkingPrototype? markingResult)
{
return _markings.TryGetValue(marking.MarkingId, out markingResult);
}
/// <summary>
/// Check if a marking is valid according to the category, species, and current data this marking has.
/// </summary>
/// <param name="marking"></param>
/// <param name="category"></param>
/// <param name="species"></param>
/// <returns></returns>
public bool IsValidMarking(Marking marking, MarkingCategories category, string species)
{
if (!TryGetMarking(marking, out var proto))
{
return false;
}
if (proto.MarkingCategory != category ||
proto.SpeciesRestrictions != null && !proto.SpeciesRestrictions.Contains(species))
{
return false;
}
if (marking.MarkingColors.Count != proto.Sprites.Count)
{
return false;
}
return true;
}
private void OnPrototypeReload(PrototypesReloadedEventArgs args)
{
if(!args.ByType.TryGetValue(typeof(MarkingPrototype), out var set))
return;
_index.RemoveAll(i => set.Modified.ContainsKey(i.ID));
foreach (var prototype in set.Modified.Values)
{
var markingPrototype = (MarkingPrototype) prototype;
_index.Add(markingPrototype);
}
}
}
}

View File

@@ -0,0 +1,51 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
namespace Content.Shared.Humanoid.Markings;
[DataDefinition]
[Serializable, NetSerializable]
public sealed class MarkingPoints
{
[DataField("points", required: true)]
public int Points = 0;
[DataField("required", required: true)]
public bool Required = false;
// Default markings for this layer.
[DataField("defaultMarkings", customTypeSerializer:typeof(PrototypeIdListSerializer<MarkingPrototype>))]
public List<string> DefaultMarkings = new();
public static Dictionary<MarkingCategories, MarkingPoints> CloneMarkingPointDictionary(Dictionary<MarkingCategories, MarkingPoints> self)
{
var clone = new Dictionary<MarkingCategories, MarkingPoints>();
foreach (var (category, points) in self)
{
clone[category] = new MarkingPoints()
{
Points = points.Points,
Required = points.Required,
DefaultMarkings = points.DefaultMarkings
};
}
return clone;
}
}
[Prototype("markingPoints")]
public sealed class MarkingPointsPrototype : IPrototype
{
[IdDataField] public string ID { get; } = default!;
/// <summary>
/// If the user of this marking point set is only allowed to
/// use whitelisted markings, and not globally usable markings.
/// Only used for validation and profile construction. Ignored anywhere else.
/// </summary>
[DataField("onlyWhitelisted")] public bool OnlyWhitelisted;
[DataField("points", required: true)]
public Dictionary<MarkingCategories, MarkingPoints> Points { get; } = default!;
}

View File

@@ -1,8 +1,7 @@
using Content.Shared.CharacterAppearance;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.Markings
namespace Content.Shared.Humanoid.Markings
{
[Prototype("marking")]
public sealed class MarkingPrototype : IPrototype

View File

@@ -0,0 +1,26 @@
namespace Content.Shared.Humanoid.Markings
{
[RegisterComponent]
public sealed class MarkingsComponent : Component
{
public Dictionary<HumanoidVisualLayers, List<Marking>> ActiveMarkings = new();
// Layer points for the attached mob. This is verified client side (but should be verified server side, eventually as well),
// but upon render for the given entity with this component, it will start subtracting
// points from this set. Upon depletion, no more sprites in this layer will be
// rendered. If an entry is null, however, it is considered 'unlimited points' for
// that layer.
//
// Layer points are useful for restricting the amount of markings a specific layer can use
// for specific mobs (i.e., a lizard should only use one set of horns and maybe two frills),
// and all species with selectable tails should have exactly one tail)
//
// If something is required, then something must be selected in that category. Otherwise,
// the first instance of a marking in that category will be added to a character
// upon round start.
[DataField("layerPoints")]
public Dictionary<MarkingCategories, MarkingPoints> LayerPoints = new();
}
}

View File

@@ -0,0 +1,778 @@
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.Humanoid.Markings;
// the better version of MarkingsSet
// This one should ensure that a set is valid. Dependency retrieval is
// probably not a good idea, and any dependency references should last
// only for the length of a call, and not the lifetime of the set itself.
//
// Compared to MarkingsSet, this should allow for server-side authority.
// Instead of sending the set over, we can instead just send the dictionary
// and build the set from there. We can also just send a list and rebuild
// the set without validating points (we're assuming that the server
/// <summary>
/// Marking set. For humanoid markings.
/// </summary>
/// <remarks>
/// This is serializable for the admin panel that sets markings on demand for a player.
/// Most APIs that accept a set of markings usually use a List of type Marking instead.
/// </remarks>
[Serializable, NetSerializable]
public sealed class MarkingSet
{
/// <summary>
/// Every single marking in this set.
/// </summary>
/// <remarks>
/// The original version of MarkingSet preserved ordering across all
/// markings - this one should instead preserve ordering across all
/// categories, but not marking categories themselves. This is because
/// the layers that markings appear in are guaranteed to be in the correct
/// order. This is here to make lookups slightly faster, even if the n of
/// a marking set is relatively small, and to encapsulate another important
/// feature of markings, which is the limit of markings you can put on a
/// humanoid.
/// </remarks>
private Dictionary<MarkingCategories, List<Marking>> _markings = new();
// why i didn't encapsulate this in the first place, i won't know
/// <summary>
/// Marking points for each category.
/// </summary>
private Dictionary<MarkingCategories, MarkingPoints> _points = new();
public IReadOnlyList<Marking> this[MarkingCategories category] => _markings[category];
public MarkingSet()
{}
/// <summary>
/// Construct a MarkingSet using a list of markings, and a points
/// dictionary. This will set up the points dictionary, and
/// process the list, truncating if necessary. Markings that
/// do not exist as a prototype will be removed.
/// </summary>
/// <param name="markings">The lists of markings to use.</param>
/// <param name="pointsPrototype">The ID of the points dictionary prototype.</param>
public MarkingSet(List<Marking> markings, string pointsPrototype, MarkingManager? markingManager = null, IPrototypeManager? prototypeManager = null)
{
IoCManager.Resolve(ref markingManager, ref prototypeManager);
if (!prototypeManager.TryIndex(pointsPrototype, out MarkingPointsPrototype? points))
{
return;
}
_points = MarkingPoints.CloneMarkingPointDictionary(points.Points);
foreach (var marking in markings)
{
if (!markingManager.TryGetMarking(marking, out var prototype))
{
continue;
}
AddBack(prototype.MarkingCategory, marking);
}
}
/// <summary>
/// Construct a MarkingSet using a dictionary of markings,
/// without point validation. This will still validate every
/// marking, to ensure that it can be placed into the set.
/// </summary>
/// <param name="markings">The list of markings to use.</param>
public MarkingSet(List<Marking> markings, MarkingManager? markingManager = null)
{
IoCManager.Resolve(ref markingManager);
foreach (var marking in markings)
{
if (!markingManager.TryGetMarking(marking, out var prototype))
{
continue;
}
AddBack(prototype.MarkingCategory, marking);
}
}
/// <summary>
/// Construct a MarkingSet by deep cloning another set.
/// </summary>
/// <param name="other">The other marking set.</param>
public MarkingSet(MarkingSet other)
{
foreach (var (key, list) in other._markings)
{
foreach (var marking in list)
{
AddBack(key, new(marking));
}
}
_points = MarkingPoints.CloneMarkingPointDictionary(other._points);
}
/// <summary>
/// Filters markings based on species restrictions in the marking's prototype from this marking set.
/// </summary>
/// <param name="species">The species to filter.</param>
/// <param name="markingManager">Marking manager.</param>
/// <param name="prototypeManager">Prototype manager.</param>
public void FilterSpecies(string species, MarkingManager? markingManager = null, IPrototypeManager? prototypeManager = null)
{
IoCManager.Resolve(ref markingManager);
IoCManager.Resolve(ref prototypeManager);
var toRemove = new List<(MarkingCategories category, string id)>();
var speciesProto = prototypeManager.Index<SpeciesPrototype>(species);
var onlyWhitelisted = prototypeManager.Index<MarkingPointsPrototype>(speciesProto.MarkingPoints).OnlyWhitelisted;
foreach (var (category, list) in _markings)
{
foreach (var marking in list)
{
if (!markingManager.TryGetMarking(marking, out var prototype))
{
toRemove.Add((category, marking.MarkingId));
continue;
}
if (onlyWhitelisted && prototype.SpeciesRestrictions == null)
{
toRemove.Add((category, marking.MarkingId));
}
if (prototype.SpeciesRestrictions != null
&& !prototype.SpeciesRestrictions.Contains(species))
{
toRemove.Add((category, marking.MarkingId));
}
}
}
foreach (var remove in toRemove)
{
Remove(remove.category, remove.id);
}
}
/// <summary>
/// Ensures that all markings in this set are valid.
/// </summary>
/// <param name="markingManager">Marking manager.</param>
public void EnsureValid(MarkingManager? markingManager = null)
{
IoCManager.Resolve(ref markingManager);
var toRemove = new List<int>();
foreach (var (category, list) in _markings)
{
for (var i = 0; i < list.Count; i++)
{
if (!markingManager.TryGetMarking(list[i], out var marking))
{
toRemove.Add(i);
continue;
}
if (marking.Sprites.Count != list[i].MarkingColors.Count)
{
list[i] = new Marking(marking.ID, marking.Sprites.Count);
}
}
foreach (var i in toRemove)
{
Remove(category, i);
}
}
}
/// <summary>
/// Ensures that the default markings as defined by the marking point set in this marking set are applied.
/// </summary>
/// <param name="skinColor">Color to apply.</param>
/// <param name="markingManager">Marking manager.</param>
public void EnsureDefault(Color? skinColor = null, MarkingManager? markingManager = null)
{
IoCManager.Resolve(ref markingManager);
foreach (var (category, points) in _points)
{
if (points.Points <= 0 || points.DefaultMarkings.Count <= 0)
{
continue;
}
var index = 0;
while (points.Points > 0 || index < points.DefaultMarkings.Count)
{
if (markingManager.Markings.TryGetValue(points.DefaultMarkings[index], out var prototype))
{
Marking marking;
if (skinColor == null)
{
marking = new Marking(points.DefaultMarkings[index], prototype.Sprites.Count);
}
else
{
var colors = new List<Color>();
for (var i = 0; i < prototype.Sprites.Count; i++)
{
colors.Add(skinColor.Value);
}
marking = new Marking(points.DefaultMarkings[index], colors);
}
AddBack(category, marking);
}
index++;
}
}
}
/// <summary>
/// How many points are left in this marking set's category
/// </summary>
/// <param name="category">The category to check</param>
/// <returns>A number equal or greater than zero if the category exists, -1 otherwise.</returns>
public int PointsLeft(MarkingCategories category)
{
if (!_points.TryGetValue(category, out var points))
{
return -1;
}
return points.Points;
}
/// <summary>
/// Add a marking to the front of the category's list of markings.
/// </summary>
/// <param name="category">Category to add the marking to.</param>
/// <param name="marking">The marking instance in question.</param>
public void AddFront(MarkingCategories category, Marking marking)
{
if (!marking.Forced && _points.TryGetValue(category, out var points))
{
if (points.Points <= 0)
{
return;
}
points.Points--;
}
if (!_markings.TryGetValue(category, out var markings))
{
markings = new();
_markings[category] = markings;
}
markings.Insert(0, marking);
}
/// <summary>
/// Add a marking to the back of the category's list of markings.
/// </summary>
/// <param name="category"></param>
/// <param name="marking"></param>
public void AddBack(MarkingCategories category, Marking marking)
{
if (!marking.Forced && _points.TryGetValue(category, out var points))
{
if (points.Points <= 0)
{
return;
}
points.Points--;
}
if (!_markings.TryGetValue(category, out var markings))
{
markings = new();
_markings[category] = markings;
}
markings.Add(marking);
}
/// <summary>
/// Adds a category to this marking set.
/// </summary>
/// <param name="category"></param>
/// <returns></returns>
public List<Marking> AddCategory(MarkingCategories category)
{
var markings = new List<Marking>();
_markings.Add(category, markings);
return markings;
}
/// <summary>
/// Replace a marking at a given index in a marking category with another marking.
/// </summary>
/// <param name="category">The category to replace the marking in.</param>
/// <param name="index">The index of the marking.</param>
/// <param name="marking">The marking to insert.</param>
public void Replace(MarkingCategories category, int index, Marking marking)
{
if (index < 0 || !_markings.TryGetValue(category, out var markings)
|| index >= markings.Count)
{
return;
}
markings[index] = marking;
}
/// <summary>
/// Remove a marking by category and ID.
/// </summary>
/// <param name="category">The category that contains the marking.</param>
/// <param name="id">The marking's ID.</param>
/// <returns>True if removed, false otherwise.</returns>
public bool Remove(MarkingCategories category, string id)
{
if (!_markings.TryGetValue(category, out var markings))
{
return false;
}
for (var i = 0; i < markings.Count; i++)
{
if (markings[i].MarkingId != id)
{
continue;
}
if (!markings[i].Forced && _points.TryGetValue(category, out var points))
{
points.Points++;
}
markings.RemoveAt(i);
return true;
}
return false;
}
/// <summary>
/// Remove a marking by category and index.
/// </summary>
/// <param name="category">The category that contains the marking.</param>
/// <param name="idx">The marking's index.</param>
/// <returns>True if removed, false otherwise.</returns>
public void Remove(MarkingCategories category, int idx)
{
if (!_markings.TryGetValue(category, out var markings))
{
return;
}
if (idx < 0 || idx >= markings.Count)
{
return;
}
if (!markings[idx].Forced && _points.TryGetValue(category, out var points))
{
points.Points++;
}
markings.RemoveAt(idx);
}
/// <summary>
/// Remove an entire category from this marking set.
/// </summary>
/// <param name="category">The category to remove.</param>
/// <returns>True if removed, false otherwise.</returns>
public bool RemoveCategory(MarkingCategories category)
{
if (!_markings.TryGetValue(category, out var markings))
{
return false;
}
if (_points.TryGetValue(category, out var points))
{
foreach (var marking in markings)
{
if (marking.Forced)
{
continue;
}
points.Points++;
}
}
_markings.Remove(category);
return true;
}
/// <summary>
/// Clears all markings from this marking set.
/// </summary>
public void Clear()
{
foreach (var category in Enum.GetValues<MarkingCategories>())
{
RemoveCategory(category);
}
}
/// <summary>
/// Attempt to find the index of a marking in a category by ID.
/// </summary>
/// <param name="category">The category to search in.</param>
/// <param name="id">The ID to search for.</param>
/// <returns>The index of the marking, otherwise a negative number.</returns>
public int FindIndexOf(MarkingCategories category, string id)
{
if (!_markings.TryGetValue(category, out var markings))
{
return -1;
}
return markings.FindIndex(m => m.MarkingId == id);
}
/// <summary>
/// Tries to get an entire category from this marking set.
/// </summary>
/// <param name="category">The category to fetch.</param>
/// <param name="markings">A read only list of the all markings in that category.</param>
/// <returns>True if successful, false otherwise.</returns>
public bool TryGetCategory(MarkingCategories category, [NotNullWhen(true)] out IReadOnlyList<Marking>? markings)
{
markings = null;
if (_markings.TryGetValue(category, out var list))
{
markings = list;
return true;
}
return false;
}
/// <summary>
/// Tries to get a marking from this marking set, by category.
/// </summary>
/// <param name="category">The category to search in.</param>
/// <param name="id">The ID to search for.</param>
/// <param name="marking">The marking, if it was retrieved.</param>
/// <returns>True if successful, false otherwise.</returns>
public bool TryGetMarking(MarkingCategories category, string id, [NotNullWhen(true)] out Marking? marking)
{
marking = null;
if (!_markings.TryGetValue(category, out var markings))
{
return false;
}
foreach (var m in markings)
{
if (m.MarkingId == id)
{
marking = m;
return true;
}
}
return false;
}
/// <summary>
/// Shifts a marking's rank towards the front of the list
/// </summary>
/// <param name="category">The category to shift in.</param>
/// <param name="idx">Index of the marking.</param>
public void ShiftRankUp(MarkingCategories category, int idx)
{
if (!_markings.TryGetValue(category, out var markings))
{
return;
}
if (idx < 0 || idx >= markings.Count || idx - 1 < 0)
{
return;
}
(markings[idx - 1], markings[idx]) = (markings[idx], markings[idx - 1]);
}
/// <summary>
/// Shifts a marking's rank upwards from the end of the list
/// </summary>
/// <param name="category">The category to shift in.</param>
/// <param name="idx">Index of the marking from the end</param>
public void ShiftRankUpFromEnd(MarkingCategories category, int idx)
{
if (!_markings.TryGetValue(category, out var markings))
{
return;
}
ShiftRankUp(category, markings.Count - idx - 1);
}
/// <summary>
/// Shifts a marking's rank towards the end of the list
/// </summary>
/// <param name="category">The category to shift in.</param>
/// <param name="idx">Index of the marking.</param>
public void ShiftRankDown(MarkingCategories category, int idx)
{
if (!_markings.TryGetValue(category, out var markings))
{
return;
}
if (idx < 0 || idx >= markings.Count || idx + 1 >= markings.Count)
{
return;
}
(markings[idx + 1], markings[idx]) = (markings[idx], markings[idx + 1]);
}
/// <summary>
/// Shifts a marking's rank downwards from the end of the list
/// </summary>
/// <param name="category">The category to shift in.</param>
/// <param name="idx">Index of the marking from the end</param>
public void ShiftRankDownFromEnd(MarkingCategories category, int idx)
{
if (!_markings.TryGetValue(category, out var markings))
{
return;
}
ShiftRankDown(category, markings.Count - idx - 1);
}
/// <summary>
/// Gets all markings in this set as an enumerator. Lists will be organized, but categories may be in any order.
/// </summary>
/// <returns>An enumerator of <see cref="Marking"/>s.</returns>
public ForwardMarkingEnumerator GetForwardEnumerator()
{
var markings = new List<Marking>();
foreach (var (_, list) in _markings)
{
markings.AddRange(list);
}
return new ForwardMarkingEnumerator(markings);
}
/// <summary>
/// Gets an enumerator of markings in this set, but only for one category.
/// </summary>
/// <param name="category">The category to fetch.</param>
/// <returns>An enumerator of <see cref="Marking"/>s in that category.</returns>
public ForwardMarkingEnumerator GetForwardEnumerator(MarkingCategories category)
{
var markings = new List<Marking>();
if (_markings.TryGetValue(category, out var listing))
{
markings = new(listing);
}
return new ForwardMarkingEnumerator(markings);
}
/// <summary>
/// Gets all markings in this set as an enumerator, but in reverse order. Lists will be in reverse order, but categories may be in any order.
/// </summary>
/// <returns>An enumerator of <see cref="Marking"/>s in reverse.</returns>
public ReverseMarkingEnumerator GetReverseEnumerator()
{
var markings = new List<Marking>();
foreach (var (_, list) in _markings)
{
markings.AddRange(list);
}
return new ReverseMarkingEnumerator(markings);
}
/// <summary>
/// Gets an enumerator of markings in this set in reverse order, but only for one category.
/// </summary>
/// <param name="category">The category to fetch.</param>
/// <returns>An enumerator of <see cref="Marking"/>s in that category, in reverse order.</returns>
public ReverseMarkingEnumerator GetReverseEnumerator(MarkingCategories category)
{
var markings = new List<Marking>();
if (_markings.TryGetValue(category, out var listing))
{
markings = new(listing);
}
return new ReverseMarkingEnumerator(markings);
}
public bool CategoryEquals(MarkingCategories category, MarkingSet other)
{
if (!_markings.TryGetValue(category, out var markings)
|| !other._markings.TryGetValue(category, out var markingsOther))
{
return false;
}
return markings.SequenceEqual(markingsOther);
}
public bool Equals(MarkingSet other)
{
foreach (var (category, _) in _markings)
{
if (!CategoryEquals(category, other))
{
return false;
}
}
return true;
}
/// <summary>
/// Gets a difference of marking categories between two marking sets
/// </summary>
/// <param name="other">The other marking set.</param>
/// <returns>Enumerator of marking categories that were different between the two.</returns>
public IEnumerable<MarkingCategories> CategoryDifference(MarkingSet other)
{
foreach (var (category, _) in _markings)
{
if (!CategoryEquals(category, other))
{
yield return category;
}
}
}
}
public sealed class ForwardMarkingEnumerator : IEnumerable<Marking>
{
private List<Marking> _markings;
public ForwardMarkingEnumerator(List<Marking> markings)
{
_markings = markings;
}
public IEnumerator<Marking> GetEnumerator()
{
return new MarkingsEnumerator(_markings, false);
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
public sealed class ReverseMarkingEnumerator : IEnumerable<Marking>
{
private List<Marking> _markings;
public ReverseMarkingEnumerator(List<Marking> markings)
{
_markings = markings;
}
public IEnumerator<Marking> GetEnumerator()
{
return new MarkingsEnumerator(_markings, true);
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
public sealed class MarkingsEnumerator : IEnumerator<Marking>
{
private List<Marking> _markings;
private bool _reverse;
int position;
public MarkingsEnumerator(List<Marking> markings, bool reverse)
{
_markings = markings;
_reverse = reverse;
if (_reverse)
{
position = _markings.Count;
}
else
{
position = -1;
}
}
public bool MoveNext()
{
if (_reverse)
{
position--;
return (position >= 0);
}
else
{
position++;
return (position < _markings.Count);
}
}
public void Reset()
{
if (_reverse)
{
position = _markings.Count;
}
else
{
position = -1;
}
}
public void Dispose()
{}
object IEnumerator.Current
{
get => _markings[position];
}
public Marking Current
{
get => _markings[position];
}
}

View File

@@ -0,0 +1,17 @@
using Content.Shared.Preferences;
using Robust.Shared.Prototypes;
namespace Content.Shared.Humanoid.Prototypes;
[Prototype("humanoidProfile")]
public sealed class HumanoidProfilePrototype : IPrototype
{
[IdDataField]
public string ID { get; } = default!;
[DataField("customBaseLayers")]
public Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> CustomBaseLayers = new();
[DataField("profile")]
public HumanoidCharacterProfile Profile { get; } = HumanoidCharacterProfile.Default();
}

View File

@@ -0,0 +1,76 @@
using Content.Shared.Humanoid.Markings;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.Humanoid.Prototypes;
/// <summary>
/// Base sprites for a species (e.g., what replaces the empty tagged layer,
/// or settings per layer)
/// </summary>
[Prototype("speciesBaseSprites")]
public sealed class HumanoidSpeciesBaseSpritesPrototype : IPrototype
{
[IdDataField]
public string ID { get; } = default!;
/// <summary>
/// Sprites that this species will use on the given humanoid
/// visual layer. If a key entry is empty, it is assumed that the
/// visual layer will not be in use on this species, and will
/// be ignored.
/// </summary>
[DataField("sprites", required: true)]
public Dictionary<HumanoidVisualLayers, string> Sprites = new();
}
/// <summary>
/// Humanoid species sprite layer. This is what defines the base layer of
/// a humanoid species sprite, and also defines how markings can appear over
/// that sprite (or at least, the layer this sprite is on).
/// </summary>
[Prototype("humanoidBaseSprite")]
public sealed class HumanoidSpeciesSpriteLayer : IPrototype
{
[IdDataField]
public string ID { get; } = default!;
/// <summary>
/// The base sprite for this sprite layer. This is what
/// will replace the empty layer tagged by the enum
/// tied to this layer.
///
/// If this is null, no sprite will be displayed, and the
/// layer will be invisible until otherwise set.
/// </summary>
[DataField("baseSprite")]
public SpriteSpecifier? BaseSprite { get; }
/// <summary>
/// The alpha of this layer. Ensures that
/// this layer will start with this percentage
/// of alpha.
/// </summary>
[DataField("layerAlpha")]
public float LayerAlpha { get; } = 1.0f;
/// <summary>
/// If this sprite layer should allow markings or not.
/// </summary>
[DataField("allowsMarkings")]
public bool AllowsMarkings { get; } = true;
/// <summary>
/// If this layer should always match the
/// skin tone in a character profile.
/// </summary>
[DataField("matchSkin")]
public bool MatchSkin { get; } = true;
/// <summary>
/// If any markings that go on this layer should
/// match the skin tone of this part, including
/// alpha.
/// </summary>
[DataField("markingsMatchSkin")]
public bool MarkingsMatchSkin { get; }
}

View File

@@ -1,7 +1,7 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.Species;
namespace Content.Shared.Humanoid.Prototypes;
[Prototype("species")]
public sealed class SpeciesPrototype : IPrototype
@@ -9,7 +9,7 @@ public sealed class SpeciesPrototype : IPrototype
/// <summary>
/// Prototype ID of the species.
/// </summary>
[IdDataFieldAttribute]
[IdDataField]
public string ID { get; } = default!;
/// <summary>
@@ -18,14 +18,40 @@ public sealed class SpeciesPrototype : IPrototype
[DataField("name", required: true)]
public string Name { get; } = default!;
/// <summary>
/// Descriptor. Unused...? This is intended
/// for an eventual integration into IdentitySystem
/// (i.e., young human person, young lizard person, etc.)
/// </summary>
[DataField("descriptor")]
public string Descriptor { get; } = "humanoid";
/// <summary>
/// Whether the species is available "at round start" (In the character editor)
/// </summary>
[DataField("roundStart", required: true)]
public bool RoundStart { get; } = false;
// The below two are to avoid fetching information about the species from the entity
// prototype.
// This one here is a utility field, and is meant to *avoid* having to duplicate
// the massive SpriteComponent found in every species.
// Species implementors can just override SpriteComponent if they want a custom
// sprite layout, and leave this null. Keep in mind that this will disable
// sprite accessories.
[DataField("sprites")]
public string SpriteSet { get; } = default!;
/// <summary>
/// Prototype used by the species as a body.
/// The limit of body markings that you can place on this species.
/// </summary>
[DataField("markingLimits")]
public string MarkingPoints { get; } = default!;
/// <summary>
/// Humanoid species variant used by this entity.
/// </summary>
[DataField("prototype", required: true, customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string Prototype { get; } = default!;
@@ -40,7 +66,7 @@ public sealed class SpeciesPrototype : IPrototype
/// Method of skin coloration used by the species.
/// </summary>
[DataField("skinColoration", required: true)]
public SpeciesSkinColor SkinColoration { get; }
public HumanoidSkinColor SkinColoration { get; }
[DataField("maleFirstNames")]
public string MaleFirstNames { get; } = "names_first_male";
@@ -55,13 +81,6 @@ public sealed class SpeciesPrototype : IPrototype
public SpeciesNaming Naming { get; } = SpeciesNaming.FirstLast;
}
public enum SpeciesSkinColor : byte
{
HumanToned,
Hues,
TintedHues, //This gives a color tint to a humanoid's skin (10% saturation with full hue range).
}
public enum SpeciesNaming : byte
{
FirstLast,

View File

@@ -1,9 +1,9 @@
using Content.Shared.Dataset;
using Content.Shared.Species;
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Shared.CharacterAppearance
namespace Content.Shared.Humanoid
{
public enum Sex : byte
{

View File

@@ -0,0 +1,62 @@
using System.Linq;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Preferences;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.Humanoid;
public abstract class SharedHumanoidComponent : Component
{
/// <summary>
/// Current species. Dictates things like base body sprites,
/// base humanoid to spawn, etc.
/// </summary>
[DataField("species", customTypeSerializer: typeof(PrototypeIdSerializer<SpeciesPrototype>))]
public string Species { get; set; } = default!;
/// <summary>
/// The initial profile and base layers to apply to this humanoid.
/// </summary>
[DataField("initial", customTypeSerializer: typeof(PrototypeIdSerializer<HumanoidProfilePrototype>))]
public string Initial { get; } = default!;
/// <summary>
/// Skin color of this humanoid.
/// </summary>
[DataField("skinColor")]
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>
[ViewVariables] public readonly HashSet<HumanoidVisualLayers> HiddenLayers = new();
[DataField("sex")] public Sex Sex = Sex.Male;
}
[DataDefinition]
[Serializable, NetSerializable]
public sealed class CustomBaseLayerInfo
{
public CustomBaseLayerInfo(string id, Color color)
{
ID = id;
Color = color;
}
/// <summary>
/// ID of this custom base layer. Must be a <see cref="HumanoidSpeciesSpriteLayer"/>.
/// </summary>
[DataField("id")]
public string ID { get; }
/// <summary>
/// Color of this custom base layer.
/// </summary>
[DataField("color")]
public Color Color { get; }
}

View File

@@ -0,0 +1,55 @@
using Content.Shared.Humanoid.Markings;
using Robust.Shared.Serialization;
namespace Content.Shared.Humanoid;
[Serializable, NetSerializable]
public enum HumanoidMarkingModifierKey
{
Key
}
[Serializable, NetSerializable]
public sealed class HumanoidMarkingModifierMarkingSetMessage : BoundUserInterfaceMessage
{
public MarkingSet MarkingSet { get; }
public bool ResendState { get; }
public HumanoidMarkingModifierMarkingSetMessage(MarkingSet set, bool resendState)
{
MarkingSet = set;
ResendState = resendState;
}
}
[Serializable, NetSerializable]
public sealed class HumanoidMarkingModifierBaseLayersSetMessage : BoundUserInterfaceMessage
{
public HumanoidMarkingModifierBaseLayersSetMessage(HumanoidVisualLayers layer, CustomBaseLayerInfo? info, bool resendState)
{
Layer = layer;
Info = info;
ResendState = resendState;
}
public HumanoidVisualLayers Layer { get; }
public CustomBaseLayerInfo? Info { get; }
public bool ResendState { get; }
}
[Serializable, NetSerializable]
public sealed class HumanoidMarkingModifierState : BoundUserInterfaceState
{
public HumanoidMarkingModifierState(MarkingSet markingSet, string species, Color skinColor, Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> customBaseLayers)
{
MarkingSet = markingSet;
Species = species;
SkinColor = skinColor;
CustomBaseLayers = customBaseLayers;
}
public MarkingSet MarkingSet { get; }
public string Species { get; }
public Color SkinColor { get; }
public Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> CustomBaseLayers { get; }
}

View File

@@ -0,0 +1,45 @@
using Content.Shared.Humanoid.Markings;
using Content.Shared.Preferences;
namespace Content.Shared.Humanoid;
/// <summary>
/// HumanoidSystem. Primarily deals with the appearance and visual data
/// of a humanoid entity. HumanoidVisualizer is what deals with actually
/// organizing the sprites and setting up the sprite component's layers.
///
/// This is a shared system, because while it is server authoritative,
/// you still need a local copy so that players can set up their
/// characters.
/// </summary>
public abstract class SharedHumanoidSystem : EntitySystem
{
[Dependency] private SharedAppearanceSystem _appearance = default!;
public const string DefaultSpecies = "Human";
public void SetAppearance(EntityUid uid,
string species,
Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> customBaseLayer,
Color skinColor,
List<HumanoidVisualLayers> visLayers,
List<Marking> markings)
{
var data = new HumanoidVisualizerData(species, customBaseLayer, skinColor, visLayers, markings);
// Locally raise an event for this, because there might be some systems interested
// in this.
RaiseLocalEvent(uid, new HumanoidAppearanceUpdateEvent(data), true);
_appearance.SetData(uid, HumanoidVisualizerKey.Key, data);
}
}
public sealed class HumanoidAppearanceUpdateEvent : EntityEventArgs
{
public HumanoidVisualizerData Data { get; }
public HumanoidAppearanceUpdateEvent(HumanoidVisualizerData data)
{
Data = data;
}
}

View File

@@ -0,0 +1,147 @@
namespace Content.Shared.Humanoid;
public static class SkinColor
{
public static Color ValidHumanSkinTone => Color.FromHsv(new Vector4(0.25f, 0.2f, 1f, 1f));
/// <summary>
/// Turn a color into a valid tinted hue skin tone.
/// </summary>
/// <param name="color">The color to validate</param>
/// <returns>Validated tinted hue skin tone</returns>
public static Color ValidTintedHuesSkinTone(Color color)
{
return TintedHues(color);
}
/// <summary>
/// Get a human skin tone based on a scale of 0 to 100.
/// </summary>
/// <param name="tone">Skin tone. Valid range is 0 to 100, inclusive. 0 is gold/yellowish, 100 is dark brown.</param>
/// <returns>A human skin tone.</returns>
/// <exception cref="ArgumentException">Exception if the value is under 0 or over 100.</exception>
public static Color HumanSkinTone(int tone)
{
// 0 - 100, 0 being gold/yellowish and 100 being dark
// HSV based
//
// 0 - 20 changes the hue
// 20 - 100 changes the value
// 0 is 45 - 20 - 100
// 20 is 25 - 20 - 100
// 100 is 25 - 100 - 20
if (tone < 0 || tone > 100)
{
throw new ArgumentException("Skin tone value was under 0 or over 100.");
}
var rangeOffset = tone - 20;
float hue = 25;
float sat = 20;
float val = 100;
if (rangeOffset <= 0)
{
hue += Math.Abs(rangeOffset);
}
else
{
sat += rangeOffset;
val -= rangeOffset;
}
var color = Color.FromHsv(new Vector4(hue / 360, sat / 100, val / 100, 1.0f));
return color;
}
/// <summary>
/// Gets a human skin tone from a given color.
/// </summary>
/// <param name="color"></param>
/// <returns></returns>
/// <remarks>
/// Does not cause an exception if the color is not originally from the human color range.
/// Instead, it will return the approximation of the skin tone value.
/// </remarks>
public static float HumanSkinToneFromColor(Color color)
{
var hsv = Color.ToHsv(color);
// check for hue/value first, if hue is lower than this percentage
// and value is 1.0
// then it'll be hue
if (Math.Clamp(hsv.X, 25f / 360f, 1) > 25f / 360f
&& hsv.Z == 1.0)
{
return Math.Abs(45 - (hsv.X * 360));
}
// otherwise it'll directly be the saturation
else
{
return hsv.Y * 100;
}
}
/// <summary>
/// Verify if a color is in the human skin tone range.
/// </summary>
/// <param name="color">The color to verify</param>
/// <returns>True if valid, false otherwise.</returns>
public static bool VerifyHumanSkinTone(Color color)
{
var colorValues = Color.ToHsv(color);
var hue = colorValues.X * 360f;
var sat = colorValues.Y * 100f;
var val = colorValues.Z * 100f;
// rangeOffset makes it so that this value
// is 25 <= hue <= 45
if (hue < 25 || hue > 45)
{
return false;
}
// rangeOffset makes it so that these two values
// are 20 <= sat <= 100 and 20 <= val <= 100
// where saturation increases to 100 and value decreases to 20
if (sat < 20 || val < 20)
{
return false;
}
return true;
}
/// <summary>
/// Convert a color to the 'tinted hues' skin tone type.
/// </summary>
/// <param name="color">Color to convert</param>
/// <returns>Tinted hue color</returns>
public static Color TintedHues(Color color)
{
var newColor = Color.ToHsv(color);
newColor.Y = .1f;
return Color.FromHsv(newColor);
}
/// <summary>
/// Verify if this color is a valid tinted hue color type, or not.
/// </summary>
/// <param name="color">The color to verify</param>
/// <returns>True if valid, false otherwise</returns>
public static bool VerifyTintedHues(Color color)
{
// tinted hues just ensures saturation is always .1, or 10% saturation at all times
return Color.ToHsv(color).Y != .1f;
}
}
public enum HumanoidSkinColor : byte
{
HumanToned,
Hues,
TintedHues, //This gives a color tint to a humanoid's skin (10% saturation with full hue range).
}

View File

@@ -1,5 +1,4 @@
using Content.Shared.CharacterAppearance;
using Content.Shared.Markings;
using Content.Shared.Humanoid.Markings;
namespace Content.Shared.IoC
{
@@ -7,7 +6,6 @@ namespace Content.Shared.IoC
{
public static void Register()
{
IoCManager.Register<SpriteAccessoryManager, SpriteAccessoryManager>();
IoCManager.Register<MarkingManager, MarkingManager>();
}
}

View File

@@ -0,0 +1,106 @@
using Content.Shared.Humanoid.Markings;
using Robust.Shared.Serialization;
namespace Content.Shared.MagicMirror;
[Serializable, NetSerializable]
public enum MagicMirrorUiKey
{
Key
}
[Serializable, NetSerializable]
public enum MagicMirrorCategory
{
Hair,
FacialHair
}
[Serializable, NetSerializable]
public sealed class MagicMirrorSelectMessage : BoundUserInterfaceMessage
{
public MagicMirrorSelectMessage(MagicMirrorCategory category, string marking, int slot)
{
Category = category;
Marking = marking;
Slot = slot;
}
public MagicMirrorCategory Category { get; }
public string Marking { get; }
public int Slot { get; }
}
[Serializable, NetSerializable]
public sealed class MagicMirrorChangeColorMessage : BoundUserInterfaceMessage
{
public MagicMirrorChangeColorMessage(MagicMirrorCategory category, List<Color> colors, int slot)
{
Category = category;
Colors = colors;
Slot = slot;
}
public MagicMirrorCategory Category { get; }
public List<Color> Colors { get; }
public int Slot { get; }
}
[Serializable, NetSerializable]
public sealed class MagicMirrorRemoveSlotMessage : BoundUserInterfaceMessage
{
public MagicMirrorRemoveSlotMessage(MagicMirrorCategory category, int slot)
{
Category = category;
Slot = slot;
}
public MagicMirrorCategory Category { get; }
public int Slot { get; }
}
[Serializable, NetSerializable]
public sealed class MagicMirrorSelectSlotMessage : BoundUserInterfaceMessage
{
public MagicMirrorSelectSlotMessage(MagicMirrorCategory category, int slot)
{
Category = category;
Slot = slot;
}
public MagicMirrorCategory Category { get; }
public int Slot { get; }
}
[Serializable, NetSerializable]
public sealed class MagicMirrorAddSlotMessage : BoundUserInterfaceMessage
{
public MagicMirrorAddSlotMessage(MagicMirrorCategory category)
{
Category = category;
}
public MagicMirrorCategory Category { get; }
}
[Serializable, NetSerializable]
public sealed class MagicMirrorUiData : BoundUserInterfaceMessage
{
public MagicMirrorUiData(string species, List<Marking> hair, int hairSlotTotal, List<Marking> facialHair, int facialHairSlotTotal)
{
Species = species;
Hair = hair;
HairSlotTotal = hairSlotTotal;
FacialHair = facialHair;
FacialHairSlotTotal = facialHairSlotTotal;
}
public string Species { get; }
public List<Marking> Hair { get; }
public int HairSlotTotal { get; }
public List<Marking> FacialHair { get; }
public int FacialHairSlotTotal { get; }
}

View File

@@ -1,18 +0,0 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Markings
{
[Serializable, NetSerializable]
public enum MarkingCategories : byte
{
Head,
HeadTop,
HeadSide,
Snout,
Chest,
Arms,
Legs,
Tail,
Overlay
}
}

View File

@@ -1,64 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.Prototypes;
namespace Content.Shared.Markings
{
public sealed class MarkingManager
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private readonly List<MarkingPrototype> _index = new();
private readonly Dictionary<MarkingCategories, List<MarkingPrototype>> _markingDict = new();
private readonly Dictionary<string, MarkingPrototype> _markings = new();
public void Initialize()
{
_prototypeManager.PrototypesReloaded += OnPrototypeReload;
foreach (var category in Enum.GetValues<MarkingCategories>())
_markingDict.Add(category, new List<MarkingPrototype>());
foreach (var prototype in _prototypeManager.EnumeratePrototypes<MarkingPrototype>())
{
_index.Add(prototype);
_markingDict[prototype.MarkingCategory].Add(prototype);
_markings.Add(prototype.ID, prototype);
}
}
public IReadOnlyDictionary<string, MarkingPrototype> Markings() => _markings;
public IReadOnlyDictionary<MarkingCategories, List<MarkingPrototype>> CategorizedMarkings() => _markingDict;
public IReadOnlyDictionary<MarkingCategories, List<MarkingPrototype>> MarkingsBySpecies(string species)
{
var result = new Dictionary<MarkingCategories, List<MarkingPrototype>>(_markingDict);
foreach (var list in result.Values)
{
list.RemoveAll(marking => marking.SpeciesRestrictions != null && marking.SpeciesRestrictions.Contains(species));
}
return result;
}
public bool IsValidMarking(Marking marking, [NotNullWhen(true)] out MarkingPrototype? markingResult)
{
return _markings.TryGetValue(marking.MarkingId, out markingResult);
}
private void OnPrototypeReload(PrototypesReloadedEventArgs args)
{
if(!args.ByType.TryGetValue(typeof(MarkingPrototype), out var set))
return;
_index.RemoveAll(i => set.Modified.ContainsKey(i.ID));
foreach (var prototype in set.Modified.Values)
{
var markingPrototype = (MarkingPrototype) prototype;
_index.Add(markingPrototype);
}
}
}
}

View File

@@ -1,57 +0,0 @@
using Content.Shared.CharacterAppearance;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
namespace Content.Shared.Markings
{
[RegisterComponent]
public sealed class MarkingsComponent : Component
{
public Dictionary<HumanoidVisualLayers, List<Marking>> ActiveMarkings = new();
// Layer points for the attached mob. This is verified client side (but should be verified server side, eventually as well),
// but upon render for the given entity with this component, it will start subtracting
// points from this set. Upon depletion, no more sprites in this layer will be
// rendered. If an entry is null, however, it is considered 'unlimited points' for
// that layer.
//
// Layer points are useful for restricting the amount of markings a specific layer can use
// for specific mobs (i.e., a lizard should only use one set of horns and maybe two frills),
// and all species with selectable tails should have exactly one tail)
//
// If something is required, then something must be selected in that category. Otherwise,
// the first instance of a marking in that category will be added to a character
// upon round start.
[DataField("layerPoints")]
public Dictionary<MarkingCategories, MarkingPoints> LayerPoints = new();
}
[DataDefinition]
public sealed class MarkingPoints
{
[DataField("points", required: true)]
public int Points = 0;
[DataField("required", required: true)]
public bool Required = false;
// Default markings for this layer.
[DataField("defaultMarkings", customTypeSerializer:typeof(PrototypeIdListSerializer<MarkingPrototype>))]
public List<string> DefaultMarkings = new();
public static Dictionary<MarkingCategories, MarkingPoints> CloneMarkingPointDictionary(Dictionary<MarkingCategories, MarkingPoints> self)
{
var clone = new Dictionary<MarkingCategories, MarkingPoints>();
foreach (var (category, points) in self)
{
clone[category] = new MarkingPoints()
{
Points = points.Points,
Required = points.Required,
DefaultMarkings = points.DefaultMarkings
};
}
return clone;
}
}
}

View File

@@ -1,291 +0,0 @@
using System.Collections;
using System.Linq;
using Robust.Shared.Serialization;
namespace Content.Shared.Markings;
// TODO: Maybe put points logic into here too? It would make some sense
// but it would have to be a template loaded in, otherwise clients could
// send really invalid points sets that would have to be verified on the
// server/client every time
//
// currently marking point constraints are just validated upon data send
// from the client's UI (which might be a nono, means that connections
// can just send garbage marking sets and it will save on the server)
// and when an entity is rendered, (which is OK enough)
//
// equally, we'd need to access references every time we wanted to get
// the managers required, which... not *terrible* if we do null default
// params
[Serializable, NetSerializable]
public class MarkingsSet : IEnumerable, IEquatable<MarkingsSet>
{
// if you want a rust style VecDeque, you're looking at
// the wrong place, i just wanted a similar API + some
// markings specific functions
private List<Marking> _markings = new();
public int Count
{
get => _markings.Count;
}
public MarkingsSet()
{
}
public MarkingsSet(List<Marking> markings)
{
_markings = markings;
}
public MarkingsSet(MarkingsSet other)
{
_markings = new(other._markings);
}
public Marking this[int idx] => Index(idx);
public Marking Index(int idx)
{
return _markings[idx];
}
// Gets a marking idx spaces from the back of the list.
public Marking IndexReverse(int idx)
{
return _markings[_markings.Count - 1 - idx];
}
public void AddFront(Marking marking)
{
_markings.Insert(0, marking);
}
public void AddBack(Marking marking)
{
_markings.Add(marking);
}
public bool Remove(Marking marking)
{
return _markings.Remove(marking);
}
public bool Contains(Marking marking)
{
return _markings.Contains(marking);
}
public int FindIndexOf(string id)
{
return _markings.FindIndex(m => m.MarkingId == id);
}
// Shifts a marking's rank upwards (i.e., towards the front of the list)
public void ShiftRankUp(int idx)
{
if (idx < 0 || idx >= _markings.Count || idx - 1 < 0)
{
return;
}
var temp = _markings[idx - 1];
_markings[idx - 1] = _markings[idx];
_markings[idx] = temp;
}
// Shifts up from the back (i.e., 2nd position from end)
public void ShiftRankUpFromEnd(int idx)
{
ShiftRankUp(Count - idx - 1);
}
// Ditto, but the opposite direction.
public void ShiftRankDown(int idx)
{
if (idx < 0 || idx >= _markings.Count || idx + 1 >= _markings.Count)
{
return;
}
var temp = _markings[idx + 1];
_markings[idx + 1] = _markings[idx];
_markings[idx] = temp;
}
// Ditto as above.
public void ShiftRankDownFromEnd(int idx)
{
ShiftRankDown(Count - idx - 1);
}
// Ensures that all markings in a set are valid.
public static MarkingsSet EnsureValid(MarkingsSet set, MarkingManager? manager = null)
{
IoCManager.Resolve(ref manager);
for (var i = set._markings.Count - 1; i >= 0; i--)
{
var marking = set._markings[i];
if (manager.IsValidMarking(marking, out var markingProto))
{
if (marking.MarkingColors.Count != markingProto.Sprites.Count)
{
set._markings[i] = new Marking(marking.MarkingId, markingProto.Sprites.Count);
}
}
else
{
set._markings.RemoveAt(i);
}
}
return set;
}
// Filters out markings based on species.
public static MarkingsSet FilterSpecies(MarkingsSet set, string species, MarkingManager? manager = null)
{
IoCManager.Resolve(ref manager);
var newList = set._markings.Where(marking =>
{
if (!manager.Markings().TryGetValue(marking.MarkingId, out MarkingPrototype? prototype))
{
return false;
}
if (prototype.SpeciesRestrictions != null)
{
if (!prototype.SpeciesRestrictions.Contains(species))
{
return false;
}
}
return true;
}).ToList();
set._markings = newList;
return set;
}
// Processes a MarkingsSet using the given dictionary of MarkingPoints.
public static MarkingsSet ProcessPoints(MarkingsSet set, Dictionary<MarkingCategories, MarkingPoints> points, MarkingManager? manager = null)
{
IoCManager.Resolve(ref manager);
var finalSet = new List<Marking>();
foreach (var marking in set)
{
if (manager.Markings().TryGetValue(marking.MarkingId, out MarkingPrototype? markingPrototype))
{
if (points.TryGetValue(markingPrototype.MarkingCategory, out var pointsRemaining))
{
if (pointsRemaining.Points == 0)
{
continue;
}
pointsRemaining.Points--;
finalSet.Add(marking);
}
else
{
// points don't exist otherwise
finalSet.Add(marking);
}
}
}
set._markings = finalSet;
return set;
}
IEnumerator IEnumerable.GetEnumerator()
{
return (IEnumerator) GetEnumerator();
}
public MarkingsEnumerator GetEnumerator()
{
return new MarkingsEnumerator(_markings, false);
}
public IEnumerator GetReverseEnumerator()
{
return (IEnumerator) new MarkingsEnumerator(_markings, true);
}
public bool Equals(MarkingsSet? set)
{
if (set == null)
{
return false;
}
return _markings.SequenceEqual(set._markings);
}
}
public class MarkingsEnumerator : IEnumerator
{
private List<Marking> _markings;
private bool _reverse;
int position;
public MarkingsEnumerator(List<Marking> markings, bool reverse)
{
_markings = markings;
_reverse = reverse;
if (_reverse)
{
position = _markings.Count;
}
else
{
position = -1;
}
}
public bool MoveNext()
{
if (_reverse)
{
position--;
return (position >= 0);
}
else
{
position++;
return (position < _markings.Count);
}
}
public void Reset()
{
if (_reverse)
{
position = _markings.Count;
}
else
{
position = -1;
}
}
object IEnumerator.Current
{
get => _markings[position];
}
public Marking Current
{
get => _markings[position];
}
}

View File

@@ -2,11 +2,11 @@ using System.Linq;
using System.Globalization;
using System.Text.RegularExpressions;
using Content.Shared.CCVar;
using Content.Shared.CharacterAppearance;
using Content.Shared.GameTicking;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Random.Helpers;
using Content.Shared.Roles;
using Content.Shared.Species;
using Content.Shared.Traits;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
@@ -20,6 +20,7 @@ namespace Content.Shared.Preferences
/// <summary>
/// Character profile. Looks immutable, but uses non-immutable semantics internally for serialization/code sanity purposes.
/// </summary>
[DataDefinition]
[Serializable, NetSerializable]
public sealed class HumanoidCharacterProfile : ICharacterProfile
{
@@ -103,7 +104,7 @@ namespace Content.Shared.Preferences
return new(
"John Doe",
"",
SpeciesManager.DefaultSpecies,
SharedHumanoidSystem.DefaultSpecies,
MinimumAge,
Sex.Male,
Gender.Male,
@@ -119,20 +120,23 @@ namespace Content.Shared.Preferences
new List<string>());
}
public static HumanoidCharacterProfile Random()
public static HumanoidCharacterProfile Random(HashSet<string>? ignoredSpecies = null)
{
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var random = IoCManager.Resolve<IRobustRandom>();
var species = random.Pick(prototypeManager
.EnumeratePrototypes<SpeciesPrototype>().Where(x => x.RoundStart).ToArray()).ID;
.EnumeratePrototypes<SpeciesPrototype>()
.Where(x => ignoredSpecies == null ? x.RoundStart : x.RoundStart && !ignoredSpecies.Contains(x.ID))
.ToArray()
).ID;
var sex = random.Prob(0.5f) ? Sex.Male : Sex.Female;
var gender = sex == Sex.Male ? Gender.Male : Gender.Female;
var name = sex.GetName(species, prototypeManager, random);
var age = random.Next(MinimumAge, MaximumAge);
return new HumanoidCharacterProfile(name, "", species, age, sex, gender, HumanoidCharacterAppearance.Random(sex), ClothingPreference.Jumpsuit, BackpackPreference.Backpack,
return new HumanoidCharacterProfile(name, "", species, age, sex, gender, HumanoidCharacterAppearance.Random(species, sex), ClothingPreference.Jumpsuit, BackpackPreference.Backpack,
new Dictionary<string, JobPriority>
{
{SharedGameTicker.FallbackOverflowJob, JobPriority.High},
@@ -142,10 +146,19 @@ namespace Content.Shared.Preferences
public string Name { get; private set; }
public string FlavorText { get; private set; }
public string Species { get; private set; }
[DataField("age")]
public int Age { get; private set; }
[DataField("sex")]
public Sex Sex { get; private set; }
[DataField("gender")]
public Gender Gender { get; private set; }
public ICharacterAppearance CharacterAppearance => Appearance;
[DataField("appearance")]
public HumanoidCharacterAppearance Appearance { get; private set; }
public ClothingPreference Clothing { get; private set; }
public BackpackPreference Backpack { get; private set; }

View File

@@ -1,4 +1,4 @@
using Content.Shared.CharacterAppearance;
using Content.Shared.Humanoid;
namespace Content.Shared.Preferences
{

View File

@@ -1,6 +0,0 @@
namespace Content.Shared.Species;
public sealed class SpeciesManager
{
public const string DefaultSpecies = "Human";
}

View File

@@ -43,6 +43,12 @@ namespace Content.Shared.Zombies
[DataField("eyeColor")]
public Color EyeColor = new(0.96f, 0.13f, 0.24f);
/// <summary>
/// The base layer to apply to any 'external' humanoid layers upon zombification.
/// </summary>
[DataField("baseLayerExternal")]
public string BaseLayerExternal = "MobHumanoidMarkingMatchSkin";
/// <summary>
/// The attack arc of the zombie
/// </summary>

View File

@@ -4,9 +4,8 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Content.Server.Database;
using Content.Shared.CharacterAppearance;
using Content.Shared.GameTicking;
using Content.Shared.Markings;
using Content.Shared.Humanoid;
using Content.Shared.Preferences;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
@@ -55,7 +54,7 @@ namespace Content.Tests.Server.Preferences
Color.Aquamarine,
Color.Azure,
Color.Beige,
new MarkingsSet()
new ()
),
ClothingPreference.Jumpskirt,
BackpackPreference.Backpack,

View File

@@ -1,2 +0,0 @@
accessory-HairBald = Bald
accessory-FacialHairShaved = Shaved

View File

@@ -1,35 +1,35 @@
accessory-HumanFacialHairAbe = Beard (Abraham Lincoln)
accessory-HumanFacialHairBrokenman = Beard (Broken Man)
accessory-HumanFacialHairChin = Beard (Chinstrap)
accessory-HumanFacialHairDwarf = Beard (Dwarf)
accessory-HumanFacialHairFullbeard = Beard (Full)
accessory-HumanFacialHairCroppedfullbeard = Beard (Cropped Fullbeard)
accessory-HumanFacialHairGt = Beard (Goatee)
accessory-HumanFacialHairHip = Beard (Hipster)
accessory-HumanFacialHairJensen = Beard (Jensen)
accessory-HumanFacialHairNeckbeard = Beard (Neckbeard)
accessory-HumanFacialHairWise = Beard (Very Long)
accessory-HumanFacialHairMuttonmus = Beard (Muttonmus)
accessory-HumanFacialHairMartialartist = Beard (Martial Artist)
accessory-HumanFacialHairChinlessbeard = Beard (Chinless Beard)
accessory-HumanFacialHairMoonshiner = Beard (Moonshiner)
accessory-HumanFacialHairLongbeard = Beard (Long)
accessory-HumanFacialHairVolaju = Beard (Volaju)
accessory-HumanFacialHair3oclock = Beard (Three o Clock Shadow)
accessory-HumanFacialHairFiveoclock = Beard (Five o Clock Shadow)
accessory-HumanFacialHair5oclockmoustache = Beard (Five o Clock Moustache)
accessory-HumanFacialHair7oclock = Beard (Seven o Clock Shadow)
accessory-HumanFacialHair7oclockmoustache = Beard (Seven o Clock Moustache)
accessory-HumanFacialHairMoustache = Moustache
accessory-HumanFacialHairPencilstache = Moustache (Pencilstache)
accessory-HumanFacialHairSmallstache = Moustache (Smallstache)
accessory-HumanFacialHairWalrus = Moustache (Walrus)
accessory-HumanFacialHairFumanchu = Moustache (Fu Manchu)
accessory-HumanFacialHairHogan = Moustache (Hulk Hogan)
accessory-HumanFacialHairSelleck = Moustache (Selleck)
accessory-HumanFacialHairChaplin = Moustache (Square)
accessory-HumanFacialHairVandyke = Moustache (Van Dyke)
accessory-HumanFacialHairWatson = Moustache (Watson)
accessory-HumanFacialHairElvis = Sideburns (Elvis)
accessory-HumanFacialHairMutton = Sideburns (Mutton Chops)
accessory-HumanFacialHairSideburn = Sideburns
marking-HumanFacialHairAbe = Beard (Abraham Lincoln)
marking-HumanFacialHairBrokenman = Beard (Broken Man)
marking-HumanFacialHairChin = Beard (Chinstrap)
marking-HumanFacialHairDwarf = Beard (Dwarf)
marking-HumanFacialHairFullbeard = Beard (Full)
marking-HumanFacialHairCroppedfullbeard = Beard (Cropped Fullbeard)
marking-HumanFacialHairGt = Beard (Goatee)
marking-HumanFacialHairHip = Beard (Hipster)
marking-HumanFacialHairJensen = Beard (Jensen)
marking-HumanFacialHairNeckbeard = Beard (Neckbeard)
marking-HumanFacialHairWise = Beard (Very Long)
marking-HumanFacialHairMuttonmus = Beard (Muttonmus)
marking-HumanFacialHairMartialartist = Beard (Martial Artist)
marking-HumanFacialHairChinlessbeard = Beard (Chinless Beard)
marking-HumanFacialHairMoonshiner = Beard (Moonshiner)
marking-HumanFacialHairLongbeard = Beard (Long)
marking-HumanFacialHairVolaju = Beard (Volaju)
marking-HumanFacialHair3oclock = Beard (Three o Clock Shadow)
marking-HumanFacialHairFiveoclock = Beard (Five o Clock Shadow)
marking-HumanFacialHair5oclockmoustache = Beard (Five o Clock Moustache)
marking-HumanFacialHair7oclock = Beard (Seven o Clock Shadow)
marking-HumanFacialHair7oclockmoustache = Beard (Seven o Clock Moustache)
marking-HumanFacialHairMoustache = Moustache
marking-HumanFacialHairPencilstache = Moustache (Pencilstache)
marking-HumanFacialHairSmallstache = Moustache (Smallstache)
marking-HumanFacialHairWalrus = Moustache (Walrus)
marking-HumanFacialHairFumanchu = Moustache (Fu Manchu)
marking-HumanFacialHairHogan = Moustache (Hulk Hogan)
marking-HumanFacialHairSelleck = Moustache (Selleck)
marking-HumanFacialHairChaplin = Moustache (Square)
marking-HumanFacialHairVandyke = Moustache (Van Dyke)
marking-HumanFacialHairWatson = Moustache (Watson)
marking-HumanFacialHairElvis = Sideburns (Elvis)
marking-HumanFacialHairMutton = Sideburns (Mutton Chops)
marking-HumanFacialHairSideburn = Sideburns

View File

@@ -1,174 +1,174 @@
accessory-HumanHairAfro = Afro
accessory-HumanHairAfro2 = Afro 2
accessory-HumanHairBigafro = Afro (Large)
accessory-HumanHairAntenna = Ahoge
accessory-HumanHairBalding = Balding Hair
accessory-HumanHairBedhead = Bedhead
accessory-HumanHairBedheadv2 = Bedhead 2
accessory-HumanHairBedheadv3 = Bedhead 3
accessory-HumanHairLongBedhead = Long Bedhead
accessory-HumanHairFloorlengthBedhead = Floorlength Bedhead
accessory-HumanHairBeehive = Beehive
accessory-HumanHairBeehivev2 = Beehive 2
accessory-HumanHairBob = Bob Hair
accessory-HumanHairBob2 = Bob Hair 2
accessory-HumanHairBobcut = Bob Hair 3
accessory-HumanHairBob4 = Bob Hair 4
accessory-HumanHairBobcurl = Bobcurl
accessory-HumanHairBoddicker = Boddicker
accessory-HumanHairBowlcut = Bowlcut
accessory-HumanHairBowlcut2 = Bowlcut 2
accessory-HumanHairBraid = Braid (Floorlength)
accessory-HumanHairBraided = Braided
accessory-HumanHairBraidfront = Braided Front
accessory-HumanHairBraid2 = Braid (High)
accessory-HumanHairHbraid = Braid (Low)
accessory-HumanHairShortbraid = Braid (Short)
accessory-HumanHairBraidtail = Braided Tail
accessory-HumanHairBun = Bun Head
accessory-HumanHairBunhead2 = Bun Head 2
accessory-HumanHairBun3 = Bun Head 3
accessory-HumanHairLargebun = Bun (Large)
accessory-HumanHairManbun = Bun (Manbun)
accessory-HumanHairTightbun = Bun (Tight)
accessory-HumanHairBusiness = Business Hair
accessory-HumanHairBusiness2 = Business Hair 2
accessory-HumanHairBusiness3 = Business Hair 3
accessory-HumanHairBusiness4 = Business Hair 4
accessory-HumanHairBuzzcut = Buzzcut
accessory-HumanHairCia = CIA
accessory-HumanHairCoffeehouse = Coffee House
accessory-HumanHairCombover = Combover
accessory-HumanHairCornrows = Cornrows
accessory-HumanHairCornrows2 = Cornrows 2
accessory-HumanHairCornrowbun = Cornrow Bun
accessory-HumanHairCornrowbraid = Cornrow Braid
accessory-HumanHairCornrowtail = Cornrow Tail
accessory-HumanHairCrewcut = Crewcut
accessory-HumanHairCurls = Curls
accessory-HumanHairC = Cut Hair
accessory-HumanHairDandypompadour = Dandy Pompadour
accessory-HumanHairDevilock = Devil Lock
accessory-HumanHairDoublebun = Double Bun
accessory-HumanHairDreads = Dreadlocks
accessory-HumanHairDrillruru = Drillruru
accessory-HumanHairDrillhairextended = Drill Hair (Extended)
accessory-HumanHairEmo = Emo
accessory-HumanHairEmofringe = Emo Fringe
accessory-HumanHairNofade = Fade (None)
accessory-HumanHairHighfade = Fade (High)
accessory-HumanHairMedfade = Fade (Medium)
accessory-HumanHairLowfade = Fade (Low)
accessory-HumanHairBaldfade = Fade (Bald)
accessory-HumanHairFeather = Feather
accessory-HumanHairFather = Father
accessory-HumanHairSargeant = Flat Top
accessory-HumanHairFlair = Flair
accessory-HumanHairBigflattop = Flat Top (Big)
accessory-HumanHairFlow = Flow Hair
accessory-HumanHairGelled = Gelled Back
accessory-HumanHairGentle = Gentle
accessory-HumanHairHalfbang = Half-banged Hair
accessory-HumanHairHalfbang2 = Half-banged Hair 2
accessory-HumanHairHalfshaved = Half-shaved
accessory-HumanHairHedgehog = Hedgehog Hair
accessory-HumanHairHimecut = Hime Cut
accessory-HumanHairHimecut2 = Hime Cut 2
accessory-HumanHairShorthime = Hime Cut (Short)
accessory-HumanHairHimeup = Hime Updo
accessory-HumanHairHitop = Hitop
accessory-HumanHairJade = Jade
accessory-HumanHairJensen = Jensen Hair
accessory-HumanHairJoestar = Joestar
accessory-HumanHairKeanu = Keanu Hair
accessory-HumanHairKusanagi = Kusanagi Hair
accessory-HumanHairLong = Long Hair 1
accessory-HumanHairLong2 = Long Hair 2
accessory-HumanHairLong3 = Long Hair 3
accessory-HumanHairLongovereye = Long Over Eye
accessory-HumanHairLbangs = Long Bangs
accessory-HumanHairLongemo = Long Emo
accessory-HumanHairLongfringe = Long Fringe
accessory-HumanHairLongsidepart = Long Side Part
accessory-HumanHairMegaeyebrows = Mega Eyebrows
accessory-HumanHairMessy = Messy
accessory-HumanHairModern = Modern
accessory-HumanHairMohawk = Mohawk
accessory-HumanHairNitori = Nitori
accessory-HumanHairReversemohawk = Mohawk (Reverse)
accessory-HumanHairUnshavenMohawk = Mohawk (Unshaven)
accessory-HumanHairMulder = Mulder
accessory-HumanHairOdango = Odango
accessory-HumanHairOmbre = Ombre
accessory-HumanHairOneshoulder = One Shoulder
accessory-HumanHairShortovereye = Over Eye
accessory-HumanHairOxton = Oxton
accessory-HumanHairParted = Parted
accessory-HumanHairPart = Parted (Side)
accessory-HumanHairKagami = Pigtails
accessory-HumanHairPigtails = Pigtails 2
accessory-HumanHairPigtails2 = Pigtails 3
accessory-HumanHairPixie = Pixie Cut
accessory-HumanHairPompadour = Pompadour
accessory-HumanHairBigpompadour = Pompadour (Big)
accessory-HumanHairPonytail = Ponytail
accessory-HumanHairPonytail2 = Ponytail 2
accessory-HumanHairPonytail3 = Ponytail 3
accessory-HumanHairPonytail4 = Ponytail 4
accessory-HumanHairPonytail5 = Ponytail 5
accessory-HumanHairPonytail6 = Ponytail 6
accessory-HumanHairPonytail7 = Ponytail 7
accessory-HumanHairHighponytail = Ponytail (High)
accessory-HumanHairStail = Ponytail (Short)
accessory-HumanHairLongstraightponytail = Ponytail (Long)
accessory-HumanHairCountry = Ponytail (Country)
accessory-HumanHairFringetail = Ponytail (Fringe)
accessory-HumanHairSidetail = Ponytail (Side)
accessory-HumanHairSidetail2 = Ponytail (Side) 2
accessory-HumanHairSidetail3 = Ponytail (Side) 3
accessory-HumanHairSidetail4 = Ponytail (Side) 4
accessory-HumanHairSpikyponytail = Ponytail (Spiky)
accessory-HumanHairPoofy = Poofy
accessory-HumanHairQuiff = Quiff
accessory-HumanHairRonin = Ronin
accessory-HumanHairShaved = Shaved
accessory-HumanHairShavedpart = Shaved Part
accessory-HumanHairShortbangs = Short Bangs
accessory-HumanHairA = Short Hair
accessory-HumanHairShorthair2 = Short Hair 2
accessory-HumanHairShorthair3 = Short Hair 3
accessory-HumanHairD = Short Hair 4
accessory-HumanHairE = Short Hair 5
accessory-HumanHairF = Short Hair 6
accessory-HumanHairShorthairg = Short Hair 7
accessory-HumanHair80s = Short Hair 80s
accessory-HumanHairRosa = Short Hair Rosa
accessory-HumanHairB = Shoulder-length Hair
accessory-HumanHairSidecut = Sidecut
accessory-HumanHairSkinhead = Skinhead
accessory-HumanHairProtagonist = Slightly Long Hair
accessory-HumanHairSpikey = Spiky
accessory-HumanHairSpiky = Spiky 2
accessory-HumanHairSpiky2 = Spiky 3
accessory-HumanHairSwept = Swept Back Hair
accessory-HumanHairSwept2 = Swept Back Hair 2
accessory-HumanHairThinning = Thinning
accessory-HumanHairThinningfront = Thinning (Front)
accessory-HumanHairThinningrear = Thinning (Rear)
accessory-HumanHairTopknot = Topknot
accessory-HumanHairTressshoulder = Tress Shoulder
accessory-HumanHairTrimmed = Trimmed
accessory-HumanHairTrimflat = Trim Flat
accessory-HumanHairTwintail = Twintails
accessory-HumanHairUndercut = Undercut
accessory-HumanHairUndercutleft = Undercut Left
accessory-HumanHairUndercutright = Undercut Right
accessory-HumanHairUnkept = Unkept
accessory-HumanHairUpdo = Updo
accessory-HumanHairVlong = Very Long Hair
accessory-HumanHairLongest = Very Long Hair 2
accessory-HumanHairLongest2 = Very Long Over Eye
accessory-HumanHairVeryshortovereyealternate = Very Short Over Eye
accessory-HumanHairVlongfringe = Very Long with Fringe
accessory-HumanHairVolaju = Volaju
accessory-HumanHairWisp = Wisp
marking-HumanHairAfro = Afro
marking-HumanHairAfro2 = Afro 2
marking-HumanHairBigafro = Afro (Large)
marking-HumanHairAntenna = Ahoge
marking-HumanHairBalding = Balding Hair
marking-HumanHairBedhead = Bedhead
marking-HumanHairBedheadv2 = Bedhead 2
marking-HumanHairBedheadv3 = Bedhead 3
marking-HumanHairLongBedhead = Long Bedhead
marking-HumanHairFloorlengthBedhead = Floorlength Bedhead
marking-HumanHairBeehive = Beehive
marking-HumanHairBeehivev2 = Beehive 2
marking-HumanHairBob = Bob Hair
marking-HumanHairBob2 = Bob Hair 2
marking-HumanHairBobcut = Bob Hair 3
marking-HumanHairBob4 = Bob Hair 4
marking-HumanHairBobcurl = Bobcurl
marking-HumanHairBoddicker = Boddicker
marking-HumanHairBowlcut = Bowlcut
marking-HumanHairBowlcut2 = Bowlcut 2
marking-HumanHairBraid = Braid (Floorlength)
marking-HumanHairBraided = Braided
marking-HumanHairBraidfront = Braided Front
marking-HumanHairBraid2 = Braid (High)
marking-HumanHairHbraid = Braid (Low)
marking-HumanHairShortbraid = Braid (Short)
marking-HumanHairBraidtail = Braided Tail
marking-HumanHairBun = Bun Head
marking-HumanHairBunhead2 = Bun Head 2
marking-HumanHairBun3 = Bun Head 3
marking-HumanHairLargebun = Bun (Large)
marking-HumanHairManbun = Bun (Manbun)
marking-HumanHairTightbun = Bun (Tight)
marking-HumanHairBusiness = Business Hair
marking-HumanHairBusiness2 = Business Hair 2
marking-HumanHairBusiness3 = Business Hair 3
marking-HumanHairBusiness4 = Business Hair 4
marking-HumanHairBuzzcut = Buzzcut
marking-HumanHairCia = CIA
marking-HumanHairCoffeehouse = Coffee House
marking-HumanHairCombover = Combover
marking-HumanHairCornrows = Cornrows
marking-HumanHairCornrows2 = Cornrows 2
marking-HumanHairCornrowbun = Cornrow Bun
marking-HumanHairCornrowbraid = Cornrow Braid
marking-HumanHairCornrowtail = Cornrow Tail
marking-HumanHairCrewcut = Crewcut
marking-HumanHairCurls = Curls
marking-HumanHairC = Cut Hair
marking-HumanHairDandypompadour = Dandy Pompadour
marking-HumanHairDevilock = Devil Lock
marking-HumanHairDoublebun = Double Bun
marking-HumanHairDreads = Dreadlocks
marking-HumanHairDrillruru = Drillruru
marking-HumanHairDrillhairextended = Drill Hair (Extended)
marking-HumanHairEmo = Emo
marking-HumanHairEmofringe = Emo Fringe
marking-HumanHairNofade = Fade (None)
marking-HumanHairHighfade = Fade (High)
marking-HumanHairMedfade = Fade (Medium)
marking-HumanHairLowfade = Fade (Low)
marking-HumanHairBaldfade = Fade (Bald)
marking-HumanHairFeather = Feather
marking-HumanHairFather = Father
marking-HumanHairSargeant = Flat Top
marking-HumanHairFlair = Flair
marking-HumanHairBigflattop = Flat Top (Big)
marking-HumanHairFlow = Flow Hair
marking-HumanHairGelled = Gelled Back
marking-HumanHairGentle = Gentle
marking-HumanHairHalfbang = Half-banged Hair
marking-HumanHairHalfbang2 = Half-banged Hair 2
marking-HumanHairHalfshaved = Half-shaved
marking-HumanHairHedgehog = Hedgehog Hair
marking-HumanHairHimecut = Hime Cut
marking-HumanHairHimecut2 = Hime Cut 2
marking-HumanHairShorthime = Hime Cut (Short)
marking-HumanHairHimeup = Hime Updo
marking-HumanHairHitop = Hitop
marking-HumanHairJade = Jade
marking-HumanHairJensen = Jensen Hair
marking-HumanHairJoestar = Joestar
marking-HumanHairKeanu = Keanu Hair
marking-HumanHairKusanagi = Kusanagi Hair
marking-HumanHairLong = Long Hair 1
marking-HumanHairLong2 = Long Hair 2
marking-HumanHairLong3 = Long Hair 3
marking-HumanHairLongovereye = Long Over Eye
marking-HumanHairLbangs = Long Bangs
marking-HumanHairLongemo = Long Emo
marking-HumanHairLongfringe = Long Fringe
marking-HumanHairLongsidepart = Long Side Part
marking-HumanHairMegaeyebrows = Mega Eyebrows
marking-HumanHairMessy = Messy
marking-HumanHairModern = Modern
marking-HumanHairMohawk = Mohawk
marking-HumanHairNitori = Nitori
marking-HumanHairReversemohawk = Mohawk (Reverse)
marking-HumanHairUnshavenMohawk = Mohawk (Unshaven)
marking-HumanHairMulder = Mulder
marking-HumanHairOdango = Odango
marking-HumanHairOmbre = Ombre
marking-HumanHairOneshoulder = One Shoulder
marking-HumanHairShortovereye = Over Eye
marking-HumanHairOxton = Oxton
marking-HumanHairParted = Parted
marking-HumanHairPart = Parted (Side)
marking-HumanHairKagami = Pigtails
marking-HumanHairPigtails = Pigtails 2
marking-HumanHairPigtails2 = Pigtails 3
marking-HumanHairPixie = Pixie Cut
marking-HumanHairPompadour = Pompadour
marking-HumanHairBigpompadour = Pompadour (Big)
marking-HumanHairPonytail = Ponytail
marking-HumanHairPonytail2 = Ponytail 2
marking-HumanHairPonytail3 = Ponytail 3
marking-HumanHairPonytail4 = Ponytail 4
marking-HumanHairPonytail5 = Ponytail 5
marking-HumanHairPonytail6 = Ponytail 6
marking-HumanHairPonytail7 = Ponytail 7
marking-HumanHairHighponytail = Ponytail (High)
marking-HumanHairStail = Ponytail (Short)
marking-HumanHairLongstraightponytail = Ponytail (Long)
marking-HumanHairCountry = Ponytail (Country)
marking-HumanHairFringetail = Ponytail (Fringe)
marking-HumanHairSidetail = Ponytail (Side)
marking-HumanHairSidetail2 = Ponytail (Side) 2
marking-HumanHairSidetail3 = Ponytail (Side) 3
marking-HumanHairSidetail4 = Ponytail (Side) 4
marking-HumanHairSpikyponytail = Ponytail (Spiky)
marking-HumanHairPoofy = Poofy
marking-HumanHairQuiff = Quiff
marking-HumanHairRonin = Ronin
marking-HumanHairShaved = Shaved
marking-HumanHairShavedpart = Shaved Part
marking-HumanHairShortbangs = Short Bangs
marking-HumanHairA = Short Hair
marking-HumanHairShorthair2 = Short Hair 2
marking-HumanHairShorthair3 = Short Hair 3
marking-HumanHairD = Short Hair 4
marking-HumanHairE = Short Hair 5
marking-HumanHairF = Short Hair 6
marking-HumanHairShorthairg = Short Hair 7
marking-HumanHair80s = Short Hair 80s
marking-HumanHairRosa = Short Hair Rosa
marking-HumanHairB = Shoulder-length Hair
marking-HumanHairSidecut = Sidecut
marking-HumanHairSkinhead = Skinhead
marking-HumanHairProtagonist = Slightly Long Hair
marking-HumanHairSpikey = Spiky
marking-HumanHairSpiky = Spiky 2
marking-HumanHairSpiky2 = Spiky 3
marking-HumanHairSwept = Swept Back Hair
marking-HumanHairSwept2 = Swept Back Hair 2
marking-HumanHairThinning = Thinning
marking-HumanHairThinningfront = Thinning (Front)
marking-HumanHairThinningrear = Thinning (Rear)
marking-HumanHairTopknot = Topknot
marking-HumanHairTressshoulder = Tress Shoulder
marking-HumanHairTrimmed = Trimmed
marking-HumanHairTrimflat = Trim Flat
marking-HumanHairTwintail = Twintails
marking-HumanHairUndercut = Undercut
marking-HumanHairUndercutleft = Undercut Left
marking-HumanHairUndercutright = Undercut Right
marking-HumanHairUnkept = Unkept
marking-HumanHairUpdo = Updo
marking-HumanHairVlong = Very Long Hair
marking-HumanHairLongest = Very Long Hair 2
marking-HumanHairLongest2 = Very Long Over Eye
marking-HumanHairVeryshortovereyealternate = Very Short Over Eye
marking-HumanHairVlongfringe = Very Long with Fringe
marking-HumanHairVolaju = Volaju
marking-HumanHairWisp = Wisp

View File

@@ -1,5 +1,5 @@
accessory-VoxFacialHairColonel = Vox Colonel
accessory-VoxFacialHairFu = Quill Fu
accessory-VoxFacialHairNeck = Neck Quills
accessory-VoxFacialHairBeard = Quill Beard
accessory-VoxFacialHairRuffBeard = Ruff Beard
marking-VoxFacialHairColonel = Vox Colonel
marking-VoxFacialHairFu = Quill Fu
marking-VoxFacialHairNeck = Neck Quills
marking-VoxFacialHairBeard = Quill Beard
marking-VoxFacialHairRuffBeard = Ruff Beard

Some files were not shown because too many files have changed in this diff Show More