Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SCRAM implant not working while cuffed. Incidentally fix freedom implant working while dead/crit #25978

Merged
merged 6 commits into from
Mar 18, 2024
Merged
1 change: 1 addition & 0 deletions Content.Client/Actions/ActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ private void BaseHandleState<T>(EntityUid uid, BaseActionComponent component, Ba
component.Container = EnsureEntity<T>(state.Container, uid);
component.EntityIcon = EnsureEntity<T>(state.EntityIcon, uid);
component.CheckCanInteract = state.CheckCanInteract;
component.CheckMobState = state.CheckMobState;
component.ClientExclusive = state.ClientExclusive;
component.Priority = state.Priority;
component.AttachedEntity = EnsureEntity<T>(state.AttachedEntity, uid);
Expand Down
10 changes: 9 additions & 1 deletion Content.Shared/Actions/BaseActionComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Robust.Shared.Audio;
using Content.Shared.Mobs;
using Robust.Shared.Audio;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;

Expand Down Expand Up @@ -118,6 +119,11 @@ public EntityUid? EntityIcon
/// </summary>
[DataField("checkCanInteract")] public bool CheckCanInteract = true;

/// <summary>
/// If not null, determines whether the action system should block this action if the user is not in the correct MobState
/// </summary>
[DataField] public MobState? CheckMobState;

/// <summary>
/// If true, this will cause the action to only execute locally without ever notifying the server.
/// </summary>
Expand Down Expand Up @@ -177,6 +183,7 @@ public abstract class BaseActionComponentState : ComponentState
public NetEntity? Container;
public NetEntity? EntityIcon;
public bool CheckCanInteract;
public MobState? CheckMobState;
public bool ClientExclusive;
public int Priority;
public NetEntity? AttachedEntity;
Expand Down Expand Up @@ -204,6 +211,7 @@ protected BaseActionComponentState(BaseActionComponent component, IEntityManager
MaxCharges = component.MaxCharges;
RenewCharges = component.RenewCharges;
CheckCanInteract = component.CheckCanInteract;
CheckMobState = component.CheckMobState;
ClientExclusive = component.ClientExclusive;
Priority = component.Priority;
AutoPopulate = component.AutoPopulate;
Expand Down
8 changes: 8 additions & 0 deletions Content.Shared/Actions/SharedActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Content.Shared.Interaction;
using Content.Shared.Inventory.Events;
using Content.Shared.Mind;
using Content.Shared.Mobs.Components;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
Expand Down Expand Up @@ -370,6 +371,13 @@ private void OnActionRequest(RequestPerformActionEvent ev, EntitySessionEventArg

BaseActionEvent? performEvent = null;

if (action.CheckMobState != null)
{
if (!TryComp<MobStateComponent>(user, out var mobState) ||
mobState.CurrentState != action.CheckMobState)
return;
}

// Validate request by checking action blockers and the like:
switch (action)
{
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Actions/types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
- type: InstantAction
charges: 3
checkCanInteract: false
checkMobState: Alive
itemIconStyle: BigAction
priority: -20
icon:
Expand Down Expand Up @@ -143,6 +144,8 @@
noSpawn: true
components:
- type: InstantAction
checkCanInteract: false
checkMobState: Alive
charges: 2
useDelay: 5
itemIconStyle: BigAction
Expand Down
Loading