From 926e3cd38b67914d3f639ed8d9e12644d8d60460 Mon Sep 17 00:00:00 2001 From: MODERN <87994977+modern-nm@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:46:40 +0300 Subject: [PATCH 1/5] fix --- .../Administration/Systems/AdminVerbSystem.Antags.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs b/Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs index 925ddcb4708..a76869736dd 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs @@ -132,9 +132,9 @@ private void AddAntagVerbs(GetVerbsEvent args) Icon = new SpriteSpecifier.Rsi(new ResPath("/Textures/Objects/Weapons/Melee/armblade.rsi"), "icon"), Act = () => { - if (!TryComp(args.Target, out var targetMindComp)) + if (!_minds.TryGetMind(args.Target, out var _, out var targetMindComp)) return; - if(targetMindComp.Session == null) + if (targetMindComp.Session == null) return; // if its not a humanoid dont make it a changeling From bec70b48f674265f53fed37a4d9b4b83d2a05685 Mon Sep 17 00:00:00 2001 From: MODERN <87994977+modern-nm@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:26:45 +0300 Subject: [PATCH 2/5] it works --- .../ADT/Changeling/ChangelingPanelSystem.cs | 147 +++++++++++ .../EntitySystems/ChangelingSystem.cs | 230 +++++++++++++++--- .../ADT/Changeling/SharedChangeling.cs | 50 ++++ .../Polymorph/PolymorphPrototype.cs | 14 +- 4 files changed, 395 insertions(+), 46 deletions(-) create mode 100644 Content.Client/ADT/Changeling/ChangelingPanelSystem.cs diff --git a/Content.Client/ADT/Changeling/ChangelingPanelSystem.cs b/Content.Client/ADT/Changeling/ChangelingPanelSystem.cs new file mode 100644 index 00000000000..2223a42ef54 --- /dev/null +++ b/Content.Client/ADT/Changeling/ChangelingPanelSystem.cs @@ -0,0 +1,147 @@ +/// Made for Adventure Time Project by ModerN. https://github.com/modern-nm mailto:modern-nm@yandex.by +/// see also https://github.com/DocNITE/liebendorf-station/tree/feature/emote-radial-panel +using Content.Client.Language.Systems; +using Content.Client.UserInterface.Systems.Radial; +using Content.Client.UserInterface.Systems.Radial.Controls; +using Content.Shared.Changeling; +using Content.Shared.Changeling.Components; +using Content.Shared.Polymorph; +using FastAccessors; +using Robust.Client.GameObjects; +using Robust.Client.Player; +using Robust.Client.UserInterface; +using Robust.Shared.Player; +using Robust.Shared.Prototypes; +using Robust.Shared.Random; +using Robust.Shared.Utility; + +namespace Content.Client.ADT.Language; + +public sealed class ChangelingPanelSystem : EntitySystem +{ + [Dependency] private readonly IPrototypeManager _proto = default!; + [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!; + [Dependency] private readonly IPlayerManager _playerMan = default!; + [Dependency] private readonly SpriteSystem _spriteSystem = default!; + + /// + /// We should enable radial for single target + /// + private RadialContainer? _openedMenu; + + private const string DefaultIcon = "/Textures/Interface/AdminActions/play.png"; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnPlayerAttached); + SubscribeLocalEvent(OnPlayerDetached); + + SubscribeNetworkEvent(HandleChangelingFormsMenuEvent); + } + + private void HandleChangelingFormsMenuEvent(RequestChangelingFormsMenuEvent args) + { + if (_openedMenu != null) + return; + if (_playerMan.LocalEntity == null) + { + return; + } + + //if (!TryComp(_playerMan.LocalEntity.Value, out var changelingComponent)) // нет на клиенте + // return; + + _openedMenu = _userInterfaceManager.GetUIController() + .CreateRadialContainer(); + + foreach (var humanoid in args.HumanoidData) + { + //var humanoidEntityUid = GetEntity(humanoid); // Entities on the client outside of the FOV are nonexistant. You can see that if you zoom out. //So it'll give you UID 0 which is EntityUid.Invalid. + + // foreach (var humanoidData in args.ChangelingComponent.StoredDNA) + // { + // if (humanoidData.EntityUid == humanoidEntityUid) + // { + // + var actionName = humanoid.Name; + var texturePath = _spriteSystem.Frame0(new SpriteSpecifier.Texture(new ResPath(DefaultIcon))); + + var emoteButton = _openedMenu.AddButton(actionName, texturePath); + emoteButton.Opacity = 210; + emoteButton.Tooltip = null; + emoteButton.Controller.OnPressed += (_) => + { + var ev = new SelectChangelingFormEvent(args.Target, entitySelected: humanoid.NetEntity); + RaiseNetworkEvent(ev); + _openedMenu.Dispose(); + }; + // } + // } + } + _openedMenu.OnClose += (_) => + { + _openedMenu = null; + }; + if (_playerMan.LocalEntity != null) + _openedMenu.OpenAttached(_playerMan.LocalEntity.Value); + + } + + // private void HandleLanguageMenuEvent(RequestLanguageMenuEvent args) + // { + // if (_openedMenu != null) + // return; + // if (_playerMan.LocalEntity == null) + // { + // return; + // } + // TryComp(_playerMan.LocalEntity.Value, out var languageSpeakerComponent); + + // _openedMenu = _userInterfaceManager.GetUIController() + // .CreateRadialContainer(); + + // foreach (var protoId in args.Languages) + // { + // var prototype = _languageSystem.GetLanguage(protoId); + // if (prototype == null) + // { + // continue; + // } + // var actionName = prototype.LocalizedName; + // var texturePath = _spriteSystem.Frame0(new SpriteSpecifier.Texture(new ResPath(DefaultIcon))); + // if (prototype.Icon != null) + // texturePath = _spriteSystem.Frame0(prototype.Icon); + + // var languageButton = _openedMenu.AddButton(actionName, texturePath); + // languageButton.Opacity = 210; + // languageButton.Tooltip = null; + // languageButton.Controller.OnPressed += (_) => + // { + // var ev = new SelectLanguageEvent(args.Target, protoId); + // RaiseNetworkEvent(ev); + // _openedMenu.Dispose(); + // }; + // } + + // _openedMenu.OnClose += (_) => + // { + // _openedMenu = null; + // }; + // if (_playerMan.LocalEntity != null) + // _openedMenu.OpenAttached(_playerMan.LocalEntity.Value); + + // } + + private void OnPlayerAttached(PlayerAttachedEvent args) + { + _openedMenu?.Dispose(); + } + + private void OnPlayerDetached(PlayerDetachedEvent args) + { + _openedMenu?.Dispose(); + } +} diff --git a/Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs b/Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs index fcbe163324e..b8dc5d28f6c 100644 --- a/Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs +++ b/Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs @@ -37,6 +37,8 @@ using Content.Shared.Weapons.Melee; using Content.Shared.Sirena.CollectiveMind; using Content.Shared.Effects; +using System.Linq; +using Content.Shared.Weapons.Ranged.Events; namespace Content.Server.Changeling.EntitySystems; @@ -77,9 +79,21 @@ public override void Initialize() SubscribeLocalEvent(OnCycleDNA); SubscribeLocalEvent(OnTransform); + SubscribeNetworkEvent(OnSelectChangelingForm); + InitializeLingAbilities(); } + private void OnSelectChangelingForm(SelectChangelingFormEvent ev) + { + var uid = GetEntity(ev.Target); + + if (!TryComp(uid, out var comp)) + return; + + TransformChangeling(uid, comp, ev); + } + private void OnStartup(EntityUid uid, ChangelingComponent component, ComponentStartup args) { //RemComp(uid); // TODO: Исправить проблему с волосами слаймов @@ -282,30 +296,169 @@ public bool StealDNA(EntityUid uid, EntityUid target, ChangelingComponent compon return true; } - public void OnCycleDNA(EntityUid uid, ChangelingComponent component, ChangelingCycleDNAActionEvent args) + public void OnCycleDNA(EntityUid uid, ChangelingComponent component, ChangelingCycleDNAActionEvent args) ///radial-menu { if (args.Handled) return; - args.Handled = true; + // args.Handled = true; - component.SelectedDNA += 1; + // component.SelectedDNA += 1; - if (component.StoredDNA.Count >= component.DNAStrandCap || component.SelectedDNA >= component.StoredDNA.Count) - component.SelectedDNA = 0; + // if (component.StoredDNA.Count >= component.DNAStrandCap || component.SelectedDNA >= component.StoredDNA.Count) + // component.SelectedDNA = 0; - var selectedHumanoidData = component.StoredDNA[component.SelectedDNA]; - if (selectedHumanoidData.MetaDataComponent == null) + // var selectedHumanoidData = component.StoredDNA[component.SelectedDNA]; + // if (selectedHumanoidData.MetaDataComponent == null) + // { + // var selfFailMessage = Loc.GetString("changeling-nodna-saved"); + // _popup.PopupEntity(selfFailMessage, uid, uid); + // return; + // } + + // var selfMessage = Loc.GetString("changeling-dna-switchdna", ("target", selectedHumanoidData.MetaDataComponent.EntityName)); + // _popup.PopupEntity(selfMessage, uid, uid); + + if (EntityManager.TryGetComponent(uid, out var actorComponent)) { - var selfFailMessage = Loc.GetString("changeling-nodna-saved"); - _popup.PopupEntity(selfFailMessage, uid, uid); - return; - } + var ev = new RequestChangelingFormsMenuEvent(GetNetEntity(uid)); - var selfMessage = Loc.GetString("changeling-dna-switchdna", ("target", selectedHumanoidData.MetaDataComponent.EntityName)); - _popup.PopupEntity(selfMessage, uid, uid); + foreach (var item in component.StoredDNA) + { + var netEntity = GetNetEntity(item.EntityUid); + if (netEntity == null) + continue; + if(item.EntityUid ==null) + continue; + //ev.HumanoidData.Add(netEntity.Value); + ev.HumanoidData.Add(new() + { + NetEntity = netEntity.Value, + Name = Name(item.EntityUid.Value) + }); + } + + //ev.HumanoidData.Sort(); реализовать сортировку + RaiseNetworkEvent(ev, actorComponent.PlayerSession); + } + args.Handled = true; } + public void TransformChangeling(EntityUid uid, ChangelingComponent component, SelectChangelingFormEvent ev) + { + int i = 0; + var selectedEntity = GetEntity(ev.EntitySelected); + foreach (var item in component.StoredDNA) + { + if (item.EntityUid == selectedEntity) + { + // transform + //var selectedHumanoidData = component.StoredDNA[component.SelectedDNA]; + var selectedHumanoidData = component.StoredDNA[i]; + if (ev.Handled) + return; + + var dnaComp = EnsureComp(uid); + + if (selectedHumanoidData.EntityPrototype == null) + { + var selfFailMessage = Loc.GetString("changeling-nodna-saved"); + _popup.PopupEntity(selfFailMessage, uid, uid); + return; + } + if (selectedHumanoidData.HumanoidAppearanceComponent == null) + { + var selfFailMessage = Loc.GetString("changeling-nodna-saved"); + _popup.PopupEntity(selfFailMessage, uid, uid); + return; + } + if (selectedHumanoidData.MetaDataComponent == null) + { + var selfFailMessage = Loc.GetString("changeling-nodna-saved"); + _popup.PopupEntity(selfFailMessage, uid, uid); + return; + } + if (selectedHumanoidData.DNA == null) + { + var selfFailMessage = Loc.GetString("changeling-nodna-saved"); + _popup.PopupEntity(selfFailMessage, uid, uid); + return; + } + + if (selectedHumanoidData.DNA == dnaComp.DNA) + { + var selfMessage = Loc.GetString("changeling-transform-fail-already", ("target", selectedHumanoidData.MetaDataComponent.EntityName)); + _popup.PopupEntity(selfMessage, uid, uid); + } + + else if (component.ArmBladeActive) + { + var selfMessage = Loc.GetString("changeling-transform-fail-mutation"); + _popup.PopupEntity(selfMessage, uid, uid); + } + else if (component.LingArmorActive) + { + var selfMessage = Loc.GetString("changeling-transform-fail-mutation"); + _popup.PopupEntity(selfMessage, uid, uid); + } + else if (component.ChameleonSkinActive) + { + var selfMessage = Loc.GetString("changeling-transform-fail-mutation"); + _popup.PopupEntity(selfMessage, uid, uid); + } + else if (component.MusclesActive) + { + var selfMessage = Loc.GetString("changeling-transform-fail-mutation"); + _popup.PopupEntity(selfMessage, uid, uid); + } + else if (component.LesserFormActive) + { + var selfMessage = Loc.GetString("changeling-transform-fail-lesser-form"); + _popup.PopupEntity(selfMessage, uid, uid); + } + + else + { + if (!TryUseAbility(uid, component, component.ChemicalsCostFive)) + return; + + ev.Handled = true; + + var transformedUid = _polymorph.PolymorphEntityAsHumanoid(uid, selectedHumanoidData); + if (transformedUid == null) + return; + + var selfMessage = Loc.GetString("changeling-transform-activate", ("target", selectedHumanoidData.MetaDataComponent.EntityName)); + _popup.PopupEntity(selfMessage, transformedUid.Value, transformedUid.Value); + + var newLingComponent = EnsureComp(transformedUid.Value); + newLingComponent.Chemicals = component.Chemicals; + newLingComponent.ChemicalsPerSecond = component.ChemicalsPerSecond; + newLingComponent.StoredDNA = component.StoredDNA; + newLingComponent.SelectedDNA = component.SelectedDNA; + newLingComponent.ArmBladeActive = component.ArmBladeActive; + newLingComponent.ChameleonSkinActive = component.ChameleonSkinActive; + newLingComponent.LingArmorActive = component.LingArmorActive; + newLingComponent.CanRefresh = component.CanRefresh; + newLingComponent.AbsorbedDnaModifier = component.AbsorbedDnaModifier; + RemComp(uid, component); + + if (TryComp(uid, out StoreComponent? storeComp)) + { + var copiedStoreComponent = (Component) _serialization.CreateCopy(storeComp, notNullableOverride: true); + RemComp(transformedUid.Value); + EntityManager.AddComponent(transformedUid.Value, copiedStoreComponent); + } + + _actionContainer.TransferAllActionsWithNewAttached(uid, transformedUid.Value, transformedUid.Value); + + if (!TryComp(transformedUid.Value, out InventoryComponent? inventory)) + return; + } + } + i++; + } + } public void OnTransform(EntityUid uid, ChangelingComponent component, ChangelingTransformActionEvent args) { var selectedHumanoidData = component.StoredDNA[component.SelectedDNA]; @@ -373,42 +526,41 @@ public void OnTransform(EntityUid uid, ChangelingComponent component, Changeling else { - if (!TryUseAbility(uid, component, component.ChemicalsCostFive)) - return; + if (!TryUseAbility(uid, component, component.ChemicalsCostFive)) + return; - args.Handled = true; + args.Handled = true; - var transformedUid = _polymorph.PolymorphEntityAsHumanoid(uid, selectedHumanoidData); - if (transformedUid == null) - return; - - var selfMessage = Loc.GetString("changeling-transform-activate", ("target", selectedHumanoidData.MetaDataComponent.EntityName)); - _popup.PopupEntity(selfMessage, transformedUid.Value, transformedUid.Value); + var transformedUid = _polymorph.PolymorphEntityAsHumanoid(uid, selectedHumanoidData); + if (transformedUid == null) + return; - var newLingComponent = EnsureComp(transformedUid.Value); - newLingComponent.Chemicals = component.Chemicals; - newLingComponent.ChemicalsPerSecond = component.ChemicalsPerSecond; - newLingComponent.StoredDNA = component.StoredDNA; - newLingComponent.SelectedDNA = component.SelectedDNA; - newLingComponent.ArmBladeActive = component.ArmBladeActive; - newLingComponent.ChameleonSkinActive = component.ChameleonSkinActive; - newLingComponent.LingArmorActive = component.LingArmorActive; - newLingComponent.CanRefresh = component.CanRefresh; - newLingComponent.AbsorbedDnaModifier = component.AbsorbedDnaModifier; + var selfMessage = Loc.GetString("changeling-transform-activate", ("target", selectedHumanoidData.MetaDataComponent.EntityName)); + _popup.PopupEntity(selfMessage, transformedUid.Value, transformedUid.Value); + + var newLingComponent = EnsureComp(transformedUid.Value); + newLingComponent.Chemicals = component.Chemicals; + newLingComponent.ChemicalsPerSecond = component.ChemicalsPerSecond; + newLingComponent.StoredDNA = component.StoredDNA; + newLingComponent.SelectedDNA = component.SelectedDNA; + newLingComponent.ArmBladeActive = component.ArmBladeActive; + newLingComponent.ChameleonSkinActive = component.ChameleonSkinActive; + newLingComponent.LingArmorActive = component.LingArmorActive; + newLingComponent.CanRefresh = component.CanRefresh; + newLingComponent.AbsorbedDnaModifier = component.AbsorbedDnaModifier; RemComp(uid, component); - if (TryComp(uid, out StoreComponent? storeComp)) - { - var copiedStoreComponent = (Component) _serialization.CreateCopy(storeComp, notNullableOverride: true); - RemComp(transformedUid.Value); - EntityManager.AddComponent(transformedUid.Value, copiedStoreComponent); - } + if (TryComp(uid, out StoreComponent? storeComp)) + { + var copiedStoreComponent = (Component) _serialization.CreateCopy(storeComp, notNullableOverride: true); + RemComp(transformedUid.Value); + EntityManager.AddComponent(transformedUid.Value, copiedStoreComponent); + } _actionContainer.TransferAllActionsWithNewAttached(uid, transformedUid.Value, transformedUid.Value); if (!TryComp(transformedUid.Value, out InventoryComponent? inventory)) return; - } } public bool BlindSting(EntityUid uid, EntityUid target, ChangelingComponent component) /// Ослепление diff --git a/Content.Shared/ADT/Changeling/SharedChangeling.cs b/Content.Shared/ADT/Changeling/SharedChangeling.cs index c13d6d266e9..1365299290f 100644 --- a/Content.Shared/ADT/Changeling/SharedChangeling.cs +++ b/Content.Shared/ADT/Changeling/SharedChangeling.cs @@ -1,5 +1,8 @@ using Content.Shared.Actions; +using Content.Shared.Changeling.Components; using Content.Shared.DoAfter; +using Content.Shared.Humanoid; +using Robust.Shared.Prototypes; using Robust.Shared.Serialization; namespace Content.Shared.Changeling; @@ -124,3 +127,50 @@ public sealed partial class LingBiodegradeActionEvent : InstantActionEvent public sealed partial class LingResonantShriekEvent : InstantActionEvent { } + +[Serializable, NetSerializable] +public sealed partial class RequestChangelingFormsMenuEvent : EntityEventArgs +{ + //public List HumanoidData = new(); + public List HumanoidData = new(); + + public NetEntity Target; + + [Serializable] + public struct HDATA + { + public NetEntity NetEntity; + public string Name; + + public string Species; + } + public RequestChangelingFormsMenuEvent(NetEntity target) + { + Target = target; + } +} + + +/// +/// This event carries prototype-id of emote, which was selected. This class is a part of code which is responsible for using RadialUiController. +/// +[Serializable, NetSerializable] +public sealed partial class SelectChangelingFormEvent : EntityEventArgs +{ + public NetEntity EntitySelected; + + public NetEntity Target; + + public bool Handled = false; + + public SelectChangelingFormEvent(NetEntity target, NetEntity entitySelected) + { + Target = target; + EntitySelected = entitySelected; + } +} +// public sealed partial class OpenEmotesActionEvent : InstantActionEvent +// { +// } +////////////ChangelingCycleDNAActionEvent///////////////// +/// diff --git a/Content.Shared/Polymorph/PolymorphPrototype.cs b/Content.Shared/Polymorph/PolymorphPrototype.cs index a5ac32154c6..33b01956b3b 100644 --- a/Content.Shared/Polymorph/PolymorphPrototype.cs +++ b/Content.Shared/Polymorph/PolymorphPrototype.cs @@ -127,10 +127,10 @@ public enum PolymorphInventoryChange : byte } public struct PolymorphHumanoidData - { - public EntityPrototype? EntityPrototype; - public MetaDataComponent? MetaDataComponent; - public HumanoidAppearanceComponent? HumanoidAppearanceComponent; - public string? DNA; - public EntityUid? EntityUid; - } +{ + public EntityPrototype? EntityPrototype; + public MetaDataComponent? MetaDataComponent; + public HumanoidAppearanceComponent? HumanoidAppearanceComponent; + public string? DNA; + public EntityUid? EntityUid; +} From cf07e22841c6cf8cdec731c07b15fcc30a42cc33 Mon Sep 17 00:00:00 2001 From: MODERN <87994977+modern-nm@users.noreply.github.com> Date: Sat, 4 May 2024 21:21:28 +0300 Subject: [PATCH 3/5] radial container modified --- .../ADT/Changeling/ChangelingPanelSystem.cs | 70 ++++--------------- .../Radial/Controls/RadialContainer.xaml.cs | 17 ++--- .../Systems/Radial/Controls/RadialItem.xaml | 4 ++ .../Radial/Controls/RadialItem.xaml.cs | 1 + .../EntitySystems/ChangelingSystem.cs | 22 +++++- .../ADT/Changeling/SharedChangeling.cs | 3 +- 6 files changed, 49 insertions(+), 68 deletions(-) diff --git a/Content.Client/ADT/Changeling/ChangelingPanelSystem.cs b/Content.Client/ADT/Changeling/ChangelingPanelSystem.cs index 2223a42ef54..60b9414c775 100644 --- a/Content.Client/ADT/Changeling/ChangelingPanelSystem.cs +++ b/Content.Client/ADT/Changeling/ChangelingPanelSystem.cs @@ -1,19 +1,21 @@ /// Made for Adventure Time Project by ModerN. https://github.com/modern-nm mailto:modern-nm@yandex.by /// see also https://github.com/DocNITE/liebendorf-station/tree/feature/emote-radial-panel -using Content.Client.Language.Systems; +using Content.Client.Humanoid; using Content.Client.UserInterface.Systems.Radial; using Content.Client.UserInterface.Systems.Radial.Controls; using Content.Shared.Changeling; -using Content.Shared.Changeling.Components; -using Content.Shared.Polymorph; +using Content.Shared.Humanoid.Prototypes; using FastAccessors; using Robust.Client.GameObjects; using Robust.Client.Player; using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; +using Robust.Shared.Map; using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Utility; +using System.Numerics; namespace Content.Client.ADT.Language; @@ -24,6 +26,8 @@ public sealed class ChangelingPanelSystem : EntitySystem [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!; [Dependency] private readonly IPlayerManager _playerMan = default!; [Dependency] private readonly SpriteSystem _spriteSystem = default!; + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly HumanoidAppearanceSystem _appearanceSystem = default!; /// /// We should enable radial for single target @@ -59,17 +63,16 @@ private void HandleChangelingFormsMenuEvent(RequestChangelingFormsMenuEvent args foreach (var humanoid in args.HumanoidData) { + var dummy = _entManager.SpawnEntity(_proto.Index(humanoid.Species).DollPrototype, MapCoordinates.Nullspace); //var humanoidEntityUid = GetEntity(humanoid); // Entities on the client outside of the FOV are nonexistant. You can see that if you zoom out. //So it'll give you UID 0 which is EntityUid.Invalid. + _appearanceSystem.LoadProfile(dummy, humanoid.Profile); + var face = new SpriteView(); + face.SetEntity(dummy); - // foreach (var humanoidData in args.ChangelingComponent.StoredDNA) - // { - // if (humanoidData.EntityUid == humanoidEntityUid) - // { - // var actionName = humanoid.Name; var texturePath = _spriteSystem.Frame0(new SpriteSpecifier.Texture(new ResPath(DefaultIcon))); - var emoteButton = _openedMenu.AddButton(actionName, texturePath); + var emoteButton = _openedMenu.AddButton(actionName, texturePath, face); emoteButton.Opacity = 210; emoteButton.Tooltip = null; emoteButton.Controller.OnPressed += (_) => @@ -78,8 +81,6 @@ private void HandleChangelingFormsMenuEvent(RequestChangelingFormsMenuEvent args RaiseNetworkEvent(ev); _openedMenu.Dispose(); }; - // } - // } } _openedMenu.OnClose += (_) => { @@ -90,51 +91,6 @@ private void HandleChangelingFormsMenuEvent(RequestChangelingFormsMenuEvent args } - // private void HandleLanguageMenuEvent(RequestLanguageMenuEvent args) - // { - // if (_openedMenu != null) - // return; - // if (_playerMan.LocalEntity == null) - // { - // return; - // } - // TryComp(_playerMan.LocalEntity.Value, out var languageSpeakerComponent); - - // _openedMenu = _userInterfaceManager.GetUIController() - // .CreateRadialContainer(); - - // foreach (var protoId in args.Languages) - // { - // var prototype = _languageSystem.GetLanguage(protoId); - // if (prototype == null) - // { - // continue; - // } - // var actionName = prototype.LocalizedName; - // var texturePath = _spriteSystem.Frame0(new SpriteSpecifier.Texture(new ResPath(DefaultIcon))); - // if (prototype.Icon != null) - // texturePath = _spriteSystem.Frame0(prototype.Icon); - - // var languageButton = _openedMenu.AddButton(actionName, texturePath); - // languageButton.Opacity = 210; - // languageButton.Tooltip = null; - // languageButton.Controller.OnPressed += (_) => - // { - // var ev = new SelectLanguageEvent(args.Target, protoId); - // RaiseNetworkEvent(ev); - // _openedMenu.Dispose(); - // }; - // } - - // _openedMenu.OnClose += (_) => - // { - // _openedMenu = null; - // }; - // if (_playerMan.LocalEntity != null) - // _openedMenu.OpenAttached(_playerMan.LocalEntity.Value); - - // } - private void OnPlayerAttached(PlayerAttachedEvent args) { _openedMenu?.Dispose(); @@ -142,6 +98,6 @@ private void OnPlayerAttached(PlayerAttachedEvent args) private void OnPlayerDetached(PlayerDetachedEvent args) { - _openedMenu?.Dispose(); + _openedMenu?.Dispose(); } } diff --git a/Content.Client/UserInterface/Systems/Radial/Controls/RadialContainer.xaml.cs b/Content.Client/UserInterface/Systems/Radial/Controls/RadialContainer.xaml.cs index 0901d6515e2..844726f6c4e 100644 --- a/Content.Client/UserInterface/Systems/Radial/Controls/RadialContainer.xaml.cs +++ b/Content.Client/UserInterface/Systems/Radial/Controls/RadialContainer.xaml.cs @@ -136,7 +136,7 @@ public void OpenCentered() if (Parent == null) return; - LayoutContainer.SetPosition(this, (Parent.Size/2) - (Size/2)); + LayoutContainer.SetPosition(this, (Parent.Size / 2) - (Size / 2)); UpdateButtons(); } @@ -156,7 +156,7 @@ public void OpenCenteredAt(Vector2 position) if (Parent == null) return; - LayoutContainer.SetPosition(this, (Parent.Size * position) - (Size/2)); + LayoutContainer.SetPosition(this, (Parent.Size * position) - (Size / 2)); UpdateButtons(); } @@ -211,12 +211,13 @@ public RadialItem AddButton(string action, string? texturePath = null) /// Item content text /// Item's icon texture /// - public RadialItem AddButton(string action, Texture? texture) + public RadialItem AddButton(string action, Texture? texture, SpriteView spriteView = default!) { var button = new RadialItem(); button.Content = action; button.Controller.TexturePath = ItemBackgroundTexturePath; - + if (spriteView != null) + button.EntityView.SetEntity(spriteView.NetEnt != null ? spriteView.NetEnt.Value : NetEntity.Invalid); if (texture != null) button.Icon.Texture = texture; @@ -229,13 +230,13 @@ private void UpdateButtons() { Visible = true; - var angleDegrees = 360/Layout.ChildCount; + var angleDegrees = 360 / Layout.ChildCount; var stepAngle = -angleDegrees + -90; var distance = GetDistance(); foreach (var child in Layout.Children) { - var button = (RadialItem)child; + var button = (RadialItem) child; button.ButtonSize = new Vector2(NormalSize, NormalSize); stepAngle += angleDegrees; var pos = GetPointFromPolar(stepAngle, distance); @@ -329,8 +330,8 @@ protected override void Draw(DrawingHandleScreen handle) foreach (var child in Layout.Children) { - var button = (RadialItem)child; - LayoutContainer.SetPosition(child, button.Offset - (button.Size/2)); + var button = (RadialItem) child; + LayoutContainer.SetPosition(child, button.Offset - (button.Size / 2)); } // FIXME: We use item's offset like "local item position" for animation. Need make some better way to do it; diff --git a/Content.Client/UserInterface/Systems/Radial/Controls/RadialItem.xaml b/Content.Client/UserInterface/Systems/Radial/Controls/RadialItem.xaml index 1edfc504a25..e3af6fb2b8a 100644 --- a/Content.Client/UserInterface/Systems/Radial/Controls/RadialItem.xaml +++ b/Content.Client/UserInterface/Systems/Radial/Controls/RadialItem.xaml @@ -6,6 +6,10 @@ Access="Public" VerticalExpand="True" HorizontalExpand="True"> + + Date: Wed, 15 May 2024 18:43:05 +0300 Subject: [PATCH 4/5] skin, hair, facial hair --- .../ADT/Changeling/ChangelingPanelSystem.cs | 5 +-- .../EntitySystems/ChangelingSystem.cs | 33 +++++++++++++----- .../Components/ChangelingComponent.cs | 4 +-- .../Interface/AdminActions/emptyIcon.png | Bin 0 -> 123 bytes 4 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 Resources/Textures/Interface/AdminActions/emptyIcon.png diff --git a/Content.Client/ADT/Changeling/ChangelingPanelSystem.cs b/Content.Client/ADT/Changeling/ChangelingPanelSystem.cs index 60b9414c775..e0e8bd60e19 100644 --- a/Content.Client/ADT/Changeling/ChangelingPanelSystem.cs +++ b/Content.Client/ADT/Changeling/ChangelingPanelSystem.cs @@ -5,7 +5,6 @@ using Content.Client.UserInterface.Systems.Radial.Controls; using Content.Shared.Changeling; using Content.Shared.Humanoid.Prototypes; -using FastAccessors; using Robust.Client.GameObjects; using Robust.Client.Player; using Robust.Client.UserInterface; @@ -36,6 +35,8 @@ public sealed class ChangelingPanelSystem : EntitySystem private const string DefaultIcon = "/Textures/Interface/AdminActions/play.png"; + private const string EmptyIcon = "/Textures/Interface/AdminActions/emptyIcon.png"; + public override void Initialize() { base.Initialize(); @@ -70,7 +71,7 @@ private void HandleChangelingFormsMenuEvent(RequestChangelingFormsMenuEvent args face.SetEntity(dummy); var actionName = humanoid.Name; - var texturePath = _spriteSystem.Frame0(new SpriteSpecifier.Texture(new ResPath(DefaultIcon))); + var texturePath = _spriteSystem.Frame0(new SpriteSpecifier.Texture(new ResPath(EmptyIcon))); var emoteButton = _openedMenu.AddButton(actionName, texturePath, face); emoteButton.Opacity = 210; diff --git a/Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs b/Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs index afe098959d3..208c3c642a3 100644 --- a/Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs +++ b/Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs @@ -42,6 +42,10 @@ using Content.Shared.Preferences; using Content.Server.Database; using Content.Server.Humanoid; +using FastAccessors; +using Content.Shared.Humanoid.Prototypes; +using Robust.Shared.Utility; +using Content.Shared.Humanoid.Markings; namespace Content.Server.Changeling.EntitySystems; @@ -338,15 +342,28 @@ public void OnCycleDNA(EntityUid uid, ChangelingComponent component, ChangelingC HumanoidCharacterAppearance hca = new(); if (item.HumanoidAppearanceComponent == null) continue; - hca.WithEyeColor(item.HumanoidAppearanceComponent.EyeColor) - .WithSkinColor(item.HumanoidAppearanceComponent.SkinColor) - .WithHairColor(item.HumanoidAppearanceComponent.CachedHairColor != null ? item.HumanoidAppearanceComponent.CachedHairColor.Value : Color.Black); - foreach (var layer in item.HumanoidAppearanceComponent.BaseLayers) - { + // if (item.HumanoidAppearanceComponent.CustomBaseLayers.TryGetValue(HumanoidVisualLayers.FacialHair, out var facialHair)) + // if (facialHair.Id != null) + // hca = hca.WithFacialHairStyleName(facialHair.Id.Value.Id); + + // if (item.HumanoidAppearanceComponent.BaseLayers.TryGetValue(HumanoidVisualLayers.FacialHair, out var facialHair)) + // hca = hca.WithFacialHairStyleName(facialHair.ID); + + if (item.HumanoidAppearanceComponent.MarkingSet.Markings.TryGetValue(Shared.Humanoid.Markings.MarkingCategories.FacialHair, out var facialHair)) + if (facialHair.TryGetValue(0, out var marking)) + { + hca = hca.WithFacialHairStyleName(marking.MarkingId); + hca = hca.WithFacialHairColor(marking.MarkingColors.First()); + } + if (item.HumanoidAppearanceComponent.MarkingSet.Markings.TryGetValue(Shared.Humanoid.Markings.MarkingCategories.Hair, out var hair)) + if (hair.TryGetValue(0, out var marking)) + { + hca = hca.WithHairStyleName(marking.MarkingId); + hca = hca.WithHairColor(marking.MarkingColors.First()); + } + + hca = hca.WithSkinColor(item.HumanoidAppearanceComponent.SkinColor); - } - // WithHairColor(item.HumanoidAppearanceComponent.BaseLayers.) - // WithFacialHairColor(item.HumanoidAppearanceComponent.CachedFacialHairColor) ev.HumanoidData.Add(new() { NetEntity = netEntity.Value, diff --git a/Content.Shared/ADT/Changeling/Components/ChangelingComponent.cs b/Content.Shared/ADT/Changeling/Components/ChangelingComponent.cs index 30098ed512e..eb9f5733509 100644 --- a/Content.Shared/ADT/Changeling/Components/ChangelingComponent.cs +++ b/Content.Shared/ADT/Changeling/Components/ChangelingComponent.cs @@ -447,8 +447,8 @@ public sealed partial class ChangelingComponent : Component [DataField] public int BiodegradeDuration = 3; - - [DataField] + + [DataField] public string HiveMind = "ChangelingCollectiveMind"; [DataField] diff --git a/Resources/Textures/Interface/AdminActions/emptyIcon.png b/Resources/Textures/Interface/AdminActions/emptyIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..98d35d502ef72f147880121c6082361043db1b68 GIT binary patch literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz4Nn)xkO Date: Sun, 19 May 2024 19:31:29 +0300 Subject: [PATCH 5/5] =?UTF-8?q?=D1=83=D0=B1=D0=BE=D1=80=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EntitySystems/ChangelingSystem.cs | 30 +------------------ .../Components/ChangelingComponent.cs | 6 ---- .../ADT/Changeling/SharedChangeling.cs | 9 ++---- .../Prototypes/ADT/changeling/changeling.yml | 28 ++++++++--------- 4 files changed, 18 insertions(+), 55 deletions(-) diff --git a/Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs b/Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs index 208c3c642a3..90d76bb8a05 100644 --- a/Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs +++ b/Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs @@ -178,8 +178,6 @@ private void OnMapInit(EntityUid uid, ChangelingComponent component, MapInitEven _action.AddAction(uid, ref component.ChangelingAbsorbActionEntity, component.ChangelingAbsorbAction); _action.AddAction(uid, ref component.ChangelingDNAStingActionEntity, component.ChangelingDNAStingAction); _action.AddAction(uid, ref component.ChangelingDNACycleActionEntity, component.ChangelingDNACycleAction); - _action.AddAction(uid, ref component.ChangelingTransformActionEntity, component.ChangelingTransformAction); - _action.AddAction(uid, ref component.ChangelingStasisDeathActionEntity, component.ChangelingStasisDeathAction); EnsureComp(uid); var collectiveMind = EnsureComp(uid); @@ -196,7 +194,6 @@ private void OnShutdown(EntityUid uid, ChangelingComponent component, ComponentS _action.RemoveAction(uid, component.ChangelingAbsorbActionEntity); _action.RemoveAction(uid, component.ChangelingDNAStingActionEntity); _action.RemoveAction(uid, component.ChangelingDNACycleActionEntity); - _action.RemoveAction(uid, component.ChangelingTransformActionEntity); _action.RemoveAction(uid, component.ChangelingStasisDeathActionEntity); RemComp(uid); @@ -309,23 +306,6 @@ public void OnCycleDNA(EntityUid uid, ChangelingComponent component, ChangelingC if (args.Handled) return; - // args.Handled = true; - - // component.SelectedDNA += 1; - - // if (component.StoredDNA.Count >= component.DNAStrandCap || component.SelectedDNA >= component.StoredDNA.Count) - // component.SelectedDNA = 0; - - // var selectedHumanoidData = component.StoredDNA[component.SelectedDNA]; - // if (selectedHumanoidData.MetaDataComponent == null) - // { - // var selfFailMessage = Loc.GetString("changeling-nodna-saved"); - // _popup.PopupEntity(selfFailMessage, uid, uid); - // return; - // } - - // var selfMessage = Loc.GetString("changeling-dna-switchdna", ("target", selectedHumanoidData.MetaDataComponent.EntityName)); - // _popup.PopupEntity(selfMessage, uid, uid); if (EntityManager.TryGetComponent(uid, out var actorComponent)) { @@ -338,16 +318,9 @@ public void OnCycleDNA(EntityUid uid, ChangelingComponent component, ChangelingC continue; if (item.EntityUid == null) continue; - //ev.HumanoidData.Add(netEntity.Value); HumanoidCharacterAppearance hca = new(); if (item.HumanoidAppearanceComponent == null) continue; - // if (item.HumanoidAppearanceComponent.CustomBaseLayers.TryGetValue(HumanoidVisualLayers.FacialHair, out var facialHair)) - // if (facialHair.Id != null) - // hca = hca.WithFacialHairStyleName(facialHair.Id.Value.Id); - - // if (item.HumanoidAppearanceComponent.BaseLayers.TryGetValue(HumanoidVisualLayers.FacialHair, out var facialHair)) - // hca = hca.WithFacialHairStyleName(facialHair.ID); if (item.HumanoidAppearanceComponent.MarkingSet.Markings.TryGetValue(Shared.Humanoid.Markings.MarkingCategories.FacialHair, out var facialHair)) if (facialHair.TryGetValue(0, out var marking)) @@ -373,7 +346,7 @@ public void OnCycleDNA(EntityUid uid, ChangelingComponent component, ChangelingC }); } - //ev.HumanoidData.Sort(); реализовать сортировку + // реализовать сортировку RaiseNetworkEvent(ev, actorComponent.PlayerSession); } args.Handled = true; @@ -388,7 +361,6 @@ public void TransformChangeling(EntityUid uid, ChangelingComponent component, Se if (item.EntityUid == selectedEntity) { // transform - //var selectedHumanoidData = component.StoredDNA[component.SelectedDNA]; var selectedHumanoidData = component.StoredDNA[i]; if (ev.Handled) return; diff --git a/Content.Shared/ADT/Changeling/Components/ChangelingComponent.cs b/Content.Shared/ADT/Changeling/Components/ChangelingComponent.cs index eb9f5733509..39091175eec 100644 --- a/Content.Shared/ADT/Changeling/Components/ChangelingComponent.cs +++ b/Content.Shared/ADT/Changeling/Components/ChangelingComponent.cs @@ -112,12 +112,6 @@ public sealed partial class ChangelingComponent : Component [DataField, AutoNetworkedField] public EntityUid? ChangelingDNACycleActionEntity; - [DataField] - public EntProtoId ChangelingTransformAction = "ActionChangelingTransform"; - - [DataField, AutoNetworkedField] - public EntityUid? ChangelingTransformActionEntity; - [DataField] public EntProtoId ChangelingRefreshAction = "ActionLingRefresh"; diff --git a/Content.Shared/ADT/Changeling/SharedChangeling.cs b/Content.Shared/ADT/Changeling/SharedChangeling.cs index fb29ddeab77..9f1f3094f60 100644 --- a/Content.Shared/ADT/Changeling/SharedChangeling.cs +++ b/Content.Shared/ADT/Changeling/SharedChangeling.cs @@ -129,10 +129,12 @@ public sealed partial class LingResonantShriekEvent : InstantActionEvent { } +/// +/// This event carries humanoid information list of entities, which DNA were stolen. Used for radial UI of "The genestealer". +/// [Serializable, NetSerializable] public sealed partial class RequestChangelingFormsMenuEvent : EntityEventArgs { - //public List HumanoidData = new(); public List HumanoidData = new(); public NetEntity Target; @@ -170,8 +172,3 @@ public SelectChangelingFormEvent(NetEntity target, NetEntity entitySelected) EntitySelected = entitySelected; } } -// public sealed partial class OpenEmotesActionEvent : InstantActionEvent -// { -// } -////////////ChangelingCycleDNAActionEvent///////////////// -/// diff --git a/Resources/Prototypes/ADT/changeling/changeling.yml b/Resources/Prototypes/ADT/changeling/changeling.yml index 5a14ad82538..05dea795b86 100644 --- a/Resources/Prototypes/ADT/changeling/changeling.yml +++ b/Resources/Prototypes/ADT/changeling/changeling.yml @@ -43,20 +43,20 @@ useDelay: 1 priority: -69 -- type: entity - id: ActionChangelingTransform - name: action-transform - description: action-transform-desc - noSpawn: true - components: - - type: InstantAction - icon: - sprite: Interface/Actions/actions_ling.rsi - state: transform - itemIconStyle: BigAction - event: !type:ChangelingTransformActionEvent - useDelay: 5 - priority: -68 +# - type: entity ### это действие удалено всвязи с заменой UI выбора формы и трансформации генокрада. +# id: ActionChangelingTransform +# name: action-transform +# description: action-transform-desc +# noSpawn: true +# components: +# - type: InstantAction +# icon: +# sprite: Interface/Actions/actions_ling.rsi +# state: transform +# itemIconStyle: BigAction +# event: !type:ChangelingTransformActionEvent +# useDelay: 5 +# priority: -68 - type: entity id: ActionLingRegenerate