Skip to content

Commit

Permalink
automatic ui update
Browse files Browse the repository at this point in the history
  • Loading branch information
Lgibb18 committed Jun 24, 2024
1 parent 36bf867 commit 3ede987
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Content.Server/_Sunrise/ERP/Systems/InteractionEui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
27 changes: 27 additions & 0 deletions Content.Server/_Sunrise/ERP/Systems/InteractionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,33 @@ public override void Initialize()
SubscribeLocalEvent<GetVerbsEvent<Verb>>(AddVerbs);
}

public (Sex, bool, Sex, bool, bool)? RequestMenu(EntityUid User, EntityUid Target)
{
if (TryComp<InteractionComponent>(Target, out var targetInteraction) && TryComp<InteractionComponent>(User, out var userInteraction))
{
if (TryComp<HumanoidAppearanceComponent>(Target, out var targetHumanoid) && TryComp<HumanoidAppearanceComponent>(User, out var userHumanoid))
{
bool erp = true;
bool userClothing = false;
bool targetClothing = false;
if (!targetInteraction.Erp || !userInteraction.Erp) erp = false;
if (TryComp<ContainerManagerComponent>(User, out var container))
{
if (container.Containers["jumpsuit"].ContainedEntities.Count != 0) userClothing = true;
if (container.Containers["outerClothing"].ContainedEntities.Count != 0) userClothing = true;
}

if (TryComp<ContainerManagerComponent>(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<EntityUid> ents = new();
Expand Down
32 changes: 32 additions & 0 deletions Content.Shared/_Sunrise/ERP/SharedInteractionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public override void Initialize()
}



[Serializable, NetSerializable]
public sealed class SetInteractionEuiState : EuiStateBase
{
Expand Down Expand Up @@ -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;
}
}

}


0 comments on commit 3ede987

Please sign in to comment.