Files
OldThink/Content.Client/_Amour/HumanoidProfileEditorExt/HumanoidProfileEditor.Genitals.cs

84 lines
2.2 KiB
C#
Raw Permalink Normal View History

2024-02-16 13:22:43 +03:00
using System.Linq;
2024-02-17 19:03:07 +03:00
using Content.Client._Amour.Hole;
2024-02-16 13:22:43 +03:00
using Content.Client._Amour.HumanoidProfileEditorExt;
using Content.Shared._Amour.Hole;
2024-02-17 19:03:07 +03:00
using Robust.Client.UserInterface.Controls;
2024-02-16 13:22:43 +03:00
namespace Content.Client.Preferences.UI;
public sealed partial class HumanoidProfileEditor
{
private Dictionary<string, Genital> _genitals = new();
2024-02-17 19:03:07 +03:00
private HoleSystem _holeSystem = default!;
2024-02-16 13:22:43 +03:00
private void InitializeGenitals()
{
2024-02-17 19:03:07 +03:00
_holeSystem = _entMan.System<HoleSystem>();
GenitalBoxView.OnExide(OnExide);
}
2024-02-16 13:22:43 +03:00
2024-02-17 19:03:07 +03:00
private void OnExide(BaseButton.ButtonEventArgs obj)
{
2024-02-18 13:23:05 +03:00
if (_previewDummy != null)
_holeSystem.ExideEntity(_previewDummy.Value,obj.Button.Pressed);
2024-02-16 13:22:43 +03:00
}
private void UpdateGenitalsControls()
{
if (Profile is null)
return;
_genitals.Clear();
GenitalBoxView.ClearChilds();
2024-02-16 21:21:19 +03:00
var genitalsList = Profile.Appearance.Genitals.ToList();
2024-02-16 13:22:43 +03:00
foreach (var prototype in _prototypeManager.EnumeratePrototypes<GenitalsGroupPrototype>())
{
2024-02-16 21:21:19 +03:00
var controller = new GenitalController();
2024-02-16 13:22:43 +03:00
var selected = 0;
2024-02-16 21:21:19 +03:00
foreach (var genital in genitalsList)
2024-02-16 13:22:43 +03:00
{
2024-02-16 21:21:19 +03:00
if (!prototype.Prototypes.Contains(genital.GenitalId))
continue;
selected = prototype.Prototypes.IndexOf(genital.GenitalId) + 1;
controller.SetColor(genital.Color);
2024-02-16 13:22:43 +03:00
}
controller.GenitalsCollectionPrototype = prototype;
controller.InChange += ControllerOnInChange;
controller.SelectedId = selected;
GenitalBoxView.AddChild(controller);
}
}
private void ControllerOnInChange(GenitalChangedEventArgs obj)
{
SelectGenital(obj.GenitalId,obj.Group,obj.Color);
}
private void SelectGenital(string? id, string group,Color? color)
{
if(Profile is null)
return;
if (id is null)
{
_genitals.Remove(group);
}
else
{
_genitals[group] = new Genital(id, color);
}
Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithGenitals(_genitals.Values.ToList()));
ShowClothes.Pressed = false;
IsDirty = true;
}
}