mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* Nubody (#42419) * Nubody * fix test fails * gibbing * lung test returns * doc comment * hand organ test * giblet test * yaml formatting * returning * relocate * trimming * re-smite * oops thusd tweak * arachnids have slower metabolism i guess * never mind the old behaviour is bad actually * rider whyyy * style changes and allat * fix collision --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * C# files done * Visual nubody (humanoid appearance refactor) (#42476) * initial visual nubody * oops overlay * im so pheeming rn * conversion... * tests * comeback of the underwear * oops eyes * blabbl * zeds * yaml linted * search and visible count constraints * reordering * preserve previously selected markings colors * fix test * some ui niceties * ordering * make DB changes backwards-compatible/downgrade-friendly * fix things again * fix migration * vulpkanin markings limit increase * wrapping * code cleanup and more code cleanup and more code cleanup and more code cleanup and * fix slop ports * better sampling API * make filter work + use the method i made for its intended purpose * fix test fails real quick * magic mirror cleanup, remove TODO * don't 0-init the organ profile data * remove deltastates --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Let vox eat trash again (#42503) * C# complete port * Getting closer * Harpy Nubody Port * Port Feroxi, Kitsune. Fix some yml typos and remove ipcs stuff * Port Oni * Port Rest, except Motorkind * Port Motorkind * Remove more surgery, restore too much deleted stuff * Fix Typos and change some organ names. Need to split eyes next * Harpy HAve Wings again * Some fixes, More Surgeyr Removal, Copying of eye organs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use correct Body imports * Markings Refactoring, Harpy Layering * Motorkind doesn't crash anymore. Some layer remappings. * Allow Organs to have Markings Displacements again. (#43604) * first shtep * readd markings support --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Fix STalk eyes and several layerings * Fix sexed organs (#42554) * Fix markings for several species, fit them for sexed organs and rename some files to fit them for it * Additional IPC-related removals * Vulpkanin eyes are now correct again * Fix Subtle Cultist Marks on species * Fix Asakim Sprites (sexed) and make CD imports work * Migration, error fixes, and Height * Fix humanoid profile voice being broken (#42550) Fix humanoid appearance voice being broken * Change Kitsune SexChanged Event to with ref * Fix asakim issue, Respirator fix * Simplify hands UI code (#42534) * Simplify hands UI code * i remembered about SortedHands in the component * minor cleanup --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Set size of Analyzer back to 350, Kitsune can't gib themselves no more. Migration * yml linter errors and an rudimentary onAdd Organ Functionality * Fixing it trying to remove nothing * midpoint migration * Why do you put so many organs everywhere * More missing prototypes * Migration of more organs * Forgot lungs * Move character preview handling into a specialized control (#41252) * Move character preview handling into a specialized control Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> * Restore job name that I accidentally removed from character picker buttons * Just resolve dependencies the standard way --------- Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Co-authored-by: Janet Blackquill <uhhadd@gmail.com> * Drop ICharacterProfile/ICharacterAppearance interfaces (#42661) * Ensure profile loading only returns valid species (#42842) (Stable merge) (#42865) Co-authored-by: pathetic meowmeow <uhhadd@gmail.com> * Changes to make it work for us. * No more bald Harpy * OperatingTables instead of null * Adding Delta V Comments, commenting out instead of deleting * Fix broken Height Scale. * Remove HumanoidSilicon Mention * Did an error. Readded, uncommented. * Clean up Marking data structure, add tests for Zombie transformation (#42756) * Clean up Marking data structure, add tests for Zombie transformation * empty * AAAAAAAAAAAAAAAA --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Fix markings colour setting (#42771) * Fix: Markings Color For Downstream * Comment out A Leg. Remove Todo * Revert to original hidden species code --------- Co-authored-by: pathetic meowmeow <uhhadd@gmail.com> Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Co-authored-by: Absotively <jen@jenpollock.ca> Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Co-authored-by: Myra <vasilis@pikachu.systems>
225 lines
8.1 KiB
C#
225 lines
8.1 KiB
C#
using System.Linq;
|
|
using System.Numerics;
|
|
using Content.Shared.Humanoid.Markings;
|
|
using Content.Shared.Humanoid;
|
|
using Content.Shared.Sprite;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Shared.Body;
|
|
|
|
public abstract partial class SharedVisualBodySystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
|
[Dependency] private readonly MarkingManager _marking = default!;
|
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
|
[Dependency] private readonly SharedScaleVisualsSystem _scaleVisualsSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<VisualOrganComponent, BodyRelayedEvent<OrganCopyAppearanceEvent>>(OnVisualOrganCopyAppearance);
|
|
SubscribeLocalEvent<VisualOrganMarkingsComponent, BodyRelayedEvent<OrganCopyAppearanceEvent>>(OnMarkingsOrganCopyAppearance);
|
|
SubscribeLocalEvent<VisualOrganComponent, BodyRelayedEvent<ApplyOrganProfileDataEvent>>(OnVisualOrganApplyProfile);
|
|
SubscribeLocalEvent<VisualOrganMarkingsComponent, BodyRelayedEvent<ApplyOrganMarkingsEvent>>(OnMarkingsOrganApplyMarkings);
|
|
SubscribeLocalEvent<HumanoidProfileComponent, ApplyOrganProfileDataEvent>(OnApplyOrganProfileData); // Delta V - Taking the solution from CD
|
|
|
|
InitializeModifiers();
|
|
InitializeInitial();
|
|
}
|
|
|
|
private List<Marking> ResolveMarkings(List<Marking> markings, Color? skinColor, Color? eyeColor, Dictionary<Enum, MarkingsAppearance> appearances)
|
|
{
|
|
var ret = new List<Marking>();
|
|
var forcedColors = new List<(Marking, MarkingPrototype)>();
|
|
|
|
// This method uses two loops since some marking with constrained colors care about the colors of previous markings.
|
|
// As such we want to ensure we can apply the markings they rely on first.
|
|
foreach (var marking in markings)
|
|
{
|
|
if (!_marking.TryGetMarking(marking, out var proto))
|
|
continue;
|
|
|
|
if (!proto.ForcedColoring && appearances.GetValueOrDefault(proto.BodyPart)?.MatchSkin != true)
|
|
ret.Add(marking);
|
|
else
|
|
forcedColors.Add((marking, proto));
|
|
}
|
|
|
|
foreach (var (marking, prototype) in forcedColors)
|
|
{
|
|
var colors = MarkingColoring.GetMarkingLayerColors(
|
|
prototype,
|
|
skinColor,
|
|
eyeColor,
|
|
ret);
|
|
|
|
var markingWithColor = new Marking(marking.MarkingId, colors)
|
|
{
|
|
Forced = marking.Forced,
|
|
};
|
|
if (appearances.GetValueOrDefault(prototype.BodyPart) is { MatchSkin: true } appearance && skinColor is { } color)
|
|
{
|
|
markingWithColor = markingWithColor.WithColor(color.WithAlpha(appearance.LayerAlpha));
|
|
}
|
|
ret.Add(markingWithColor);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
protected virtual void SetOrganColor(Entity<VisualOrganComponent> ent, Color color)
|
|
{
|
|
ent.Comp.Data.Color = color;
|
|
Dirty(ent);
|
|
}
|
|
|
|
protected virtual void SetOrganAppearance(Entity<VisualOrganComponent> ent, PrototypeLayerData data)
|
|
{
|
|
ent.Comp.Data = data;
|
|
Dirty(ent);
|
|
}
|
|
|
|
protected virtual void SetOrganMarkings(Entity<VisualOrganMarkingsComponent> ent, Dictionary<HumanoidVisualLayers, List<Marking>> markings)
|
|
{
|
|
ent.Comp.Markings = markings;
|
|
Dirty(ent);
|
|
}
|
|
|
|
public void CopyAppearanceFrom(Entity<BodyComponent?> source, Entity<BodyComponent?> target)
|
|
{
|
|
if (!Resolve(source, ref source.Comp) || !Resolve(target, ref target.Comp))
|
|
return;
|
|
|
|
var sourceOrgans = _container.EnsureContainer<Container>(source, BodyComponent.ContainerID);
|
|
|
|
foreach (var sourceOrgan in sourceOrgans.ContainedEntities)
|
|
{
|
|
var evt = new OrganCopyAppearanceEvent(sourceOrgan);
|
|
RaiseLocalEvent(target, ref evt);
|
|
}
|
|
}
|
|
|
|
private void OnVisualOrganCopyAppearance(Entity<VisualOrganComponent> ent, ref BodyRelayedEvent<OrganCopyAppearanceEvent> args)
|
|
{
|
|
if (!TryComp<VisualOrganComponent>(args.Args.Organ, out var other))
|
|
return;
|
|
|
|
if (!other.Layer.Equals(ent.Comp.Layer))
|
|
return;
|
|
|
|
SetOrganAppearance(ent, other.Data);
|
|
}
|
|
|
|
// Delta V - BEGIN CD Solution
|
|
private void OnApplyOrganProfileData(Entity<HumanoidProfileComponent> entity, ref ApplyOrganProfileDataEvent args)
|
|
{
|
|
var speciesPrototype = _prototype.Index(entity.Comp.Species);
|
|
if (args.Base == null)
|
|
return;
|
|
|
|
var height = Math.Clamp(MathF.Round(args.Base.Value.Height, 2), speciesPrototype.MinHeight, speciesPrototype.MaxHeight);
|
|
|
|
_scaleVisualsSystem.SetSpriteScale(
|
|
entity.Owner,
|
|
new Vector2(speciesPrototype.ScaleHeight ? height : 1f, height)
|
|
);
|
|
}
|
|
// Delta V - END
|
|
|
|
private void OnMarkingsOrganCopyAppearance(Entity<VisualOrganMarkingsComponent> ent, ref BodyRelayedEvent<OrganCopyAppearanceEvent> args)
|
|
{
|
|
if (!TryComp<VisualOrganMarkingsComponent>(args.Args.Organ, out var other))
|
|
return;
|
|
|
|
if (!other.MarkingData.Layers.SetEquals(ent.Comp.MarkingData.Layers))
|
|
return;
|
|
|
|
SetOrganMarkings(ent, other.Markings);
|
|
}
|
|
|
|
private void OnVisualOrganApplyProfile(Entity<VisualOrganComponent> ent, ref BodyRelayedEvent<ApplyOrganProfileDataEvent> args)
|
|
{
|
|
if (Comp<OrganComponent>(ent).Category is not { } category)
|
|
return;
|
|
|
|
var relevantData = args.Args.Base;
|
|
if (args.Args.Profiles?.TryGetValue(category, out var profile) == true)
|
|
relevantData = profile;
|
|
|
|
if (relevantData is not { } data)
|
|
return;
|
|
|
|
ent.Comp.Profile = data;
|
|
|
|
if (ent.Comp.Layer.Equals(HumanoidVisualLayers.Eyes))
|
|
SetOrganColor(ent, ent.Comp.Profile.EyeColor);
|
|
else
|
|
SetOrganColor(ent, ent.Comp.Profile.SkinColor);
|
|
|
|
if (ent.Comp.SexStateOverrides is { } overrides && overrides.TryGetValue(data.Sex, out var state))
|
|
{
|
|
ent.Comp.Data.State = state;
|
|
SetOrganAppearance(ent, ent.Comp.Data);
|
|
}
|
|
}
|
|
|
|
private void OnMarkingsOrganApplyMarkings(Entity<VisualOrganMarkingsComponent> ent, ref BodyRelayedEvent<ApplyOrganMarkingsEvent> args)
|
|
{
|
|
if (Comp<OrganComponent>(ent).Category is not { } category)
|
|
return;
|
|
|
|
if (!args.Args.Markings.TryGetValue(category, out var markingSet))
|
|
return;
|
|
|
|
var groupProto = _prototype.Index(ent.Comp.MarkingData.Group);
|
|
var organMarkings = ent.Comp.Markings.ShallowClone();
|
|
|
|
foreach (var layer in ent.Comp.MarkingData.Layers)
|
|
{
|
|
if (!markingSet.TryGetValue(layer, out var markings))
|
|
continue;
|
|
|
|
var okSet = new List<Marking>();
|
|
|
|
foreach (var marking in markings)
|
|
{
|
|
if (!_marking.TryGetMarking(marking, out _))
|
|
continue;
|
|
|
|
okSet.Add(marking);
|
|
}
|
|
|
|
organMarkings[layer] = okSet;
|
|
}
|
|
|
|
var profile = Comp<VisualOrganComponent>(ent).Profile;
|
|
var resolved = organMarkings.ToDictionary(
|
|
kvp => kvp.Key,
|
|
kvp => ResolveMarkings(kvp.Value, profile.SkinColor, profile.EyeColor, groupProto.Appearances));
|
|
|
|
SetOrganMarkings(ent, resolved);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raised on body entity, when an organ is having its appearance copied to it
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public readonly record struct OrganCopyAppearanceEvent(EntityUid Organ);
|
|
|
|
/// <summary>
|
|
/// Raised on body entity when profiles are being applied to it
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public readonly record struct ApplyOrganProfileDataEvent(OrganProfileData? Base, Dictionary<ProtoId<OrganCategoryPrototype>, OrganProfileData>? Profiles);
|
|
|
|
/// <summary>
|
|
/// Raised on body entity when a profile is being applied to it
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public readonly record struct ApplyOrganMarkingsEvent(Dictionary<ProtoId<OrganCategoryPrototype>, Dictionary<HumanoidVisualLayers, List<Marking>>> Markings);
|
|
|