From 3ede9879576e7015bddad520ba97e03988fa7ecf Mon Sep 17 00:00:00 2001 From: Lgibb18 <65973111+Lgibb18@users.noreply.github.com> Date: Mon, 24 Jun 2024 13:03:56 +0500 Subject: [PATCH] automatic ui update --- .../_Sunrise/ERP/Systems/InteractionEui.cs | 6 ++++ .../_Sunrise/ERP/Systems/InteractionSystem.cs | 27 ++++++++++++++++ .../_Sunrise/ERP/SharedInteractionSystem.cs | 32 +++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/Content.Server/_Sunrise/ERP/Systems/InteractionEui.cs b/Content.Server/_Sunrise/ERP/Systems/InteractionEui.cs index 29364ce7f3..362c84195b 100644 --- a/Content.Server/_Sunrise/ERP/Systems/InteractionEui.cs +++ b/Content.Server/_Sunrise/ERP/Systems/InteractionEui.cs @@ -52,6 +52,12 @@ public override void HandleMessage(EuiMessageBase msg) Close(); } break; + case RequestInteractionState req: + var res = _interaction.RequestMenu(_entManager.GetEntity(req.User), _entManager.GetEntity(req.Target)); + if (!res.HasValue) return; + var resVal = res.Value; + SendMessage(new ResponseInteractionState(resVal.Item1, resVal.Item3, resVal.Item2, resVal.Item4, resVal.Item5)); + break; } } diff --git a/Content.Server/_Sunrise/ERP/Systems/InteractionSystem.cs b/Content.Server/_Sunrise/ERP/Systems/InteractionSystem.cs index d0b1e16dd6..96c88c8d5f 100644 --- a/Content.Server/_Sunrise/ERP/Systems/InteractionSystem.cs +++ b/Content.Server/_Sunrise/ERP/Systems/InteractionSystem.cs @@ -27,6 +27,33 @@ public override void Initialize() SubscribeLocalEvent>(AddVerbs); } + public (Sex, bool, Sex, bool, bool)? RequestMenu(EntityUid User, EntityUid Target) + { + if (TryComp(Target, out var targetInteraction) && TryComp(User, out var userInteraction)) + { + if (TryComp(Target, out var targetHumanoid) && TryComp(User, out var userHumanoid)) + { + bool erp = true; + bool userClothing = false; + bool targetClothing = false; + if (!targetInteraction.Erp || !userInteraction.Erp) erp = false; + if (TryComp(User, out var container)) + { + if (container.Containers["jumpsuit"].ContainedEntities.Count != 0) userClothing = true; + if (container.Containers["outerClothing"].ContainedEntities.Count != 0) userClothing = true; + } + + if (TryComp(Target, out var targetContainer)) + { + if (targetContainer.Containers["jumpsuit"].ContainedEntities.Count != 0) targetClothing = true; + if (targetContainer.Containers["outerClothing"].ContainedEntities.Count != 0) targetClothing = true; + } + return (userHumanoid.Sex, userClothing, targetHumanoid.Sex, targetClothing, erp); + } + } + return null; + } + public void AddLove(NetEntity entity, NetEntity target, int percent) { List ents = new(); diff --git a/Content.Shared/_Sunrise/ERP/SharedInteractionSystem.cs b/Content.Shared/_Sunrise/ERP/SharedInteractionSystem.cs index 4b2f330583..f117b1436b 100644 --- a/Content.Shared/_Sunrise/ERP/SharedInteractionSystem.cs +++ b/Content.Shared/_Sunrise/ERP/SharedInteractionSystem.cs @@ -14,6 +14,7 @@ public override void Initialize() } + [Serializable, NetSerializable] public sealed class SetInteractionEuiState : EuiStateBase { @@ -53,6 +54,37 @@ public ResponseLoveMessage(float percent) } } + [NetSerializable, Serializable] + public sealed class RequestInteractionState : EuiMessageBase + { + public NetEntity User; + public NetEntity Target; + public RequestInteractionState(NetEntity user, NetEntity target) + { + User = user; + Target = target; + } + } + + [Serializable, NetSerializable] + public sealed class ResponseInteractionState : EuiMessageBase + { + public Sex UserSex; + public Sex TargetSex; + public bool UserHasClothing; + public bool TargetHasClothing; + public bool ErpAllowed; + + public ResponseInteractionState(Sex userSex, Sex targetSex, bool userHasClothing, bool targetHasClothing, bool erp) + { + UserSex = userSex; + TargetSex = targetSex; + UserHasClothing = userHasClothing; + TargetHasClothing = targetHasClothing; + ErpAllowed = erp; + } + } + }