Skip to content

Commit

Permalink
Port UserActivateInWorldEvent and BypassInteractionChecksComponent (#…
Browse files Browse the repository at this point in the history
…1295)

<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

See space-wizards/space-station-14#28393 and
space-wizards/space-station-14#28236 for
breaking changes and extra information
Works perfectly on a downstream of EE. Changes in third commit have been
tested with doors.

---

# Changelog

<!--
You can add an author after the `:cl:` to change the name that appears
in the changelog (ex: `:cl: Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->
nuh uh

---------

Signed-off-by: sleepyyapril <[email protected]>
Co-authored-by: Nemanja <[email protected]>
Co-authored-by: DrSmugleaf <[email protected]>
  • Loading branch information
3 people authored Dec 6, 2024
1 parent 36cd6ca commit 1016a08
Show file tree
Hide file tree
Showing 79 changed files with 466 additions and 241 deletions.
26 changes: 13 additions & 13 deletions Content.Client/Access/UI/AccessOverriderWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public AccessOverriderWindow(AccessOverriderBoundUserInterface owner, IPrototype
{
if (!prototypeManager.TryIndex(access, out var accessLevel))
{
logMill.Error($"Unable to find accesslevel for {access}");
logMill.Error($"Unable to find access level for {access}");
continue;
}

Expand Down Expand Up @@ -66,11 +66,11 @@ public void UpdateState(AccessOverriderBoundUserInterfaceState state)

if (state.MissingPrivilegesList != null && state.MissingPrivilegesList.Any())
{
List<string> missingPrivileges = new List<string>();
var missingPrivileges = new List<string>();

foreach (string tag in state.MissingPrivilegesList)
{
string privilege = Loc.GetString(_prototypeManager.Index<AccessLevelPrototype>(tag)?.Name ?? "generic-unknown");
var privilege = Loc.GetString(_prototypeManager.Index<AccessLevelPrototype>(tag)?.Name ?? "generic-unknown");
missingPrivileges.Add(privilege);
}

Expand All @@ -83,20 +83,20 @@ public void UpdateState(AccessOverriderBoundUserInterfaceState state)
foreach (var (accessName, button) in _accessButtons)
{
button.Disabled = !interfaceEnabled;
if (interfaceEnabled)
{
button.Pressed = state.TargetAccessReaderIdAccessList?.Contains(accessName) ?? false;
button.Disabled = (!state.AllowedModifyAccessList?.Contains(accessName)) ?? true;
}
if (!interfaceEnabled)
return;

button.Pressed = state.TargetAccessReaderIdAccessList?.Contains<ProtoId<AccessLevelPrototype>>(accessName) ?? false;
button.Disabled = (!state.AllowedModifyAccessList?.Contains<ProtoId<AccessLevelPrototype>>(accessName)) ?? true;
}
}

private void SubmitData()
{
private void SubmitData() =>
_owner.SubmitData(

// Iterate over the buttons dictionary, filter by `Pressed`, only get key from the key/value pair
_accessButtons.Where(x => x.Value.Pressed).Select(x => new ProtoId<AccessLevelPrototype>(x.Key)).ToList());
}
_accessButtons.Where(x => x.Value.Pressed)
.Select(x => new ProtoId<AccessLevelPrototype>(x.Key))
.ToList()
);
}
}
2 changes: 1 addition & 1 deletion Content.Client/Guidebook/GuidebookSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private void OnGuidebookControlsTestInteractHand(EntityUid uid, GuidebookControl

public void FakeClientActivateInWorld(EntityUid activated)
{
var activateMsg = new ActivateInWorldEvent(GetGuidebookUser(), activated);
var activateMsg = new ActivateInWorldEvent(GetGuidebookUser(), activated, true);
RaiseLocalEvent(activated, activateMsg);
}

Expand Down
1 change: 1 addition & 0 deletions Content.IntegrationTests/Tests/Buckle/BuckleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public sealed partial class BuckleTest
components:
- type: Buckle
- type: Hands
- type: ComplexInteraction
- type: InputMover
- type: Body
prototype: Human
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public sealed class HandCuffTest
components:
- type: Cuffable
- type: Hands
- type: ComplexInteraction
- type: Body
prototype: Human
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Components;
using Content.Shared.Item;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
Expand Down Expand Up @@ -60,6 +61,7 @@ await server.WaitAssertion(() =>
{
user = sEntities.SpawnEntity(null, coords);
sEntities.EnsureComponent<HandsComponent>(user);
sEntities.EnsureComponent<ComplexInteractionComponent>(user);
handSys.AddHand(user, "hand", HandLocation.Left);
target = sEntities.SpawnEntity(null, coords);
item = sEntities.SpawnEntity(null, coords);
Expand Down Expand Up @@ -193,6 +195,7 @@ await server.WaitAssertion(() =>
{
user = sEntities.SpawnEntity(null, coords);
sEntities.EnsureComponent<HandsComponent>(user);
sEntities.EnsureComponent<ComplexInteractionComponent>(user);
handSys.AddHand(user, "hand", HandLocation.Left);
target = sEntities.SpawnEntity(null, new MapCoordinates(new Vector2(SharedInteractionSystem.InteractionRange - 0.1f, 0), mapId));
item = sEntities.SpawnEntity(null, coords);
Expand Down Expand Up @@ -327,6 +330,7 @@ await server.WaitAssertion(() =>
{
user = sEntities.SpawnEntity(null, coords);
sEntities.EnsureComponent<HandsComponent>(user);
sEntities.EnsureComponent<ComplexInteractionComponent>(user);
handSys.AddHand(user, "hand", HandLocation.Left);
target = sEntities.SpawnEntity(null, coords);
item = sEntities.SpawnEntity(null, coords);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public abstract partial class InteractionTest
prototype: Aghost
- type: DoAfter
- type: Hands
- type: ComplexInteraction
- type: MindContainer
- type: Stripping
- type: Puller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public sealed class VendingMachineRestockTest : EntitySystem
id: HumanVendingDummy
components:
- type: Hands
- type: ComplexInteraction
- type: Body
prototype: Human
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Actions/ActionOnInteractSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void OnMapInit(EntityUid uid, ActionOnInteractComponent component, MapIn

private void OnActivate(EntityUid uid, ActionOnInteractComponent component, ActivateInWorldEvent args)
{
if (args.Handled)
if (args.Handled || !args.Complex)
return;

if (component.ActionEntities is not {} actionEnts)
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Atmos/EntitySystems/FlammableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private void OnInteractUsing(EntityUid uid, FlammableComponent flammable, Intera

private void OnExtinguishActivateInWorld(EntityUid uid, ExtinguishOnInteractComponent component, ActivateInWorldEvent args)
{
if (args.Handled)
if (args.Handled || !args.Complex)
return;

if (!TryComp(uid, out FlammableComponent? flammable))
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ private void OnShutdown(EntityUid uid, AirAlarmComponent component, ComponentShu

private void OnActivate(EntityUid uid, AirAlarmComponent component, ActivateInWorldEvent args)
{
if (!args.Complex)
return;

if (TryComp<WiresPanelComponent>(uid, out var panel) && panel.Open)
{
args.Handled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ private void OnPumpLeaveAtmosphere(EntityUid uid, GasPressurePumpComponent pump,

private void OnPumpActivate(EntityUid uid, GasPressurePumpComponent pump, ActivateInWorldEvent args)
{
if (args.Handled || !args.Complex)
return;

if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ private void OnStartup(EntityUid uid, GasValveComponent component, ComponentStar

private void OnActivate(EntityUid uid, GasValveComponent component, ActivateInWorldEvent args)
{
if (args.Handled || !args.Complex)
return;

Toggle(uid, component);
_audio.PlayPvs(component.ValveSound, uid, AudioParams.Default.WithVariation(0.25f));
args.Handled = true;
}

public void Set(EntityUid uid, GasValveComponent component, bool value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ private void OnVolumePumpLeaveAtmosphere(EntityUid uid, GasVolumePumpComponent p

private void OnPumpActivate(EntityUid uid, GasVolumePumpComponent pump, ActivateInWorldEvent args)
{
if (args.Handled || !args.Complex)
return;

if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ private void OnFilterLeaveAtmosphere(EntityUid uid, GasFilterComponent filter, r

private void OnFilterActivate(EntityUid uid, GasFilterComponent filter, ActivateInWorldEvent args)
{
if (args.Handled || !args.Complex)
return;

if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ private void OnMixerLeaveAtmosphere(EntityUid uid, GasMixerComponent mixer, ref

private void OnMixerActivate(EntityUid uid, GasMixerComponent mixer, ActivateInWorldEvent args)
{
if (args.Handled || !args.Complex)
return;

if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ private void OnCanisterUpdated(EntityUid uid, GasCanisterComponent canister, ref

private void OnCanisterActivate(EntityUid uid, GasCanisterComponent component, ActivateInWorldEvent args)
{
if (!args.Complex)
return;

if (!TryComp<ActorComponent>(args.User, out var actor))
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ private void OnMapInit(EntityUid uid, GasOutletInjectorComponent component, MapI

private void OnActivate(EntityUid uid, GasOutletInjectorComponent component, ActivateInWorldEvent args)
{
if (args.Handled || !args.Complex)
return;

component.Enabled = !component.Enabled;
UpdateAppearance(uid, component);
args.Handled = true;
}

public void UpdateAppearance(EntityUid uid, GasOutletInjectorComponent component, AppearanceComponent? appearance = null)
Expand Down
19 changes: 9 additions & 10 deletions Content.Server/CardboardBox/CardboardBoxSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public override void Initialize()
SubscribeLocalEvent<CardboardBoxComponent, StorageAfterCloseEvent>(AfterStorageClosed);
SubscribeLocalEvent<CardboardBoxComponent, GetAdditionalAccessEvent>(OnGetAdditionalAccess);
SubscribeLocalEvent<CardboardBoxComponent, ActivateInWorldEvent>(OnInteracted);
SubscribeLocalEvent<CardboardBoxComponent, InteractedNoHandEvent>(OnNoHandInteracted);
SubscribeLocalEvent<CardboardBoxComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
SubscribeLocalEvent<CardboardBoxComponent, EntRemovedFromContainerMessage>(OnEntRemoved);

Expand All @@ -45,9 +44,18 @@ public override void Initialize()

private void OnInteracted(EntityUid uid, CardboardBoxComponent component, ActivateInWorldEvent args)
{
if (args.Handled)
return;

if (!TryComp<EntityStorageComponent>(uid, out var box))
return;

if (!args.Complex)
{
if (box.Open || !box.Contents.Contains(args.User))
return;
}

args.Handled = true;
_storage.ToggleOpen(args.User, uid, box);

Expand All @@ -58,15 +66,6 @@ private void OnInteracted(EntityUid uid, CardboardBoxComponent component, Activa
}
}

private void OnNoHandInteracted(EntityUid uid, CardboardBoxComponent component, InteractedNoHandEvent args)
{
//Free the mice please
if (!TryComp<EntityStorageComponent>(uid, out var box) || box.Open || !box.Contents.Contains(args.User))
return;

_storage.OpenStorage(uid);
}

private void OnGetAdditionalAccess(EntityUid uid, CardboardBoxComponent component, ref GetAdditionalAccessEvent args)
{
if (component.Mover == null)
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/DeviceLinking/Systems/SignalSwitchSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private void OnInit(EntityUid uid, SignalSwitchComponent comp, ComponentInit arg

private void OnActivated(EntityUid uid, SignalSwitchComponent comp, ActivateInWorldEvent args)
{
if (args.Handled)
if (args.Handled || !args.Complex)
return;

comp.State = !comp.State;
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Disposal/Mailing/MailingUnitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ private void OnConfigurationUpdated(EntityUid uid, MailingUnitComponent componen

private void HandleActivate(EntityUid uid, MailingUnitComponent component, ActivateInWorldEvent args)
{
if (args.Handled || !args.Complex)
return;

if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ public void ToggleEngage(EntityUid uid, SharedDisposalUnitComponent component)

private void OnActivate(EntityUid uid, SharedDisposalUnitComponent component, ActivateInWorldEvent args)
{
if (args.Handled || !args.Complex)
return;

if (!TryComp(args.User, out ActorComponent? actor))
{
return;
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Doors/Systems/AirlockSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ private void OnPowerChanged(EntityUid uid, AirlockComponent component, ref Power

private void OnActivate(EntityUid uid, AirlockComponent component, ActivateInWorldEvent args)
{
if (args.Handled || !args.Complex)
return;

if (TryComp<WiresPanelComponent>(uid, out var panel) &&
panel.Open &&
TryComp<ActorComponent>(args.User, out var actor))
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Explosion/EntitySystems/TriggerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ private void OnSpawnTriggered(EntityUid uid, TriggerOnSpawnComponent component,

private void OnActivate(EntityUid uid, TriggerOnActivateComponent component, ActivateInWorldEvent args)
{
if (args.Handled || !args.Complex)
return;

Trigger(uid, args.User);
args.Handled = true;
}
Expand Down
8 changes: 4 additions & 4 deletions Content.Server/Fluids/EntitySystems/AbsorbentSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<AbsorbentComponent, ComponentInit>(OnAbsorbentInit);
SubscribeLocalEvent<AbsorbentComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<AbsorbentComponent, InteractNoHandEvent>(OnInteractNoHand);
SubscribeLocalEvent<AbsorbentComponent, UserActivateInWorldEvent>(OnActivateInWorld);
SubscribeLocalEvent<AbsorbentComponent, SolutionContainerChangedEvent>(OnAbsorbentSolutionChange);
}

Expand Down Expand Up @@ -85,12 +85,12 @@ private void UpdateAbsorbent(EntityUid uid, AbsorbentComponent component)
Dirty(uid, component);
}

private void OnInteractNoHand(EntityUid uid, AbsorbentComponent component, InteractNoHandEvent args)
private void OnActivateInWorld(EntityUid uid, AbsorbentComponent component, UserActivateInWorldEvent args)
{
if (args.Handled || args.Target == null)
if (args.Handled)
return;

Mop(uid, args.Target.Value, uid, component);
Mop(uid, args.Target, uid, component);
args.Handled = true;
}

Expand Down
8 changes: 3 additions & 5 deletions Content.Server/Gatherable/GatherableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ private void OnAttacked(Entity<GatherableComponent> gatherable, ref AttackedEven

private void OnActivate(Entity<GatherableComponent> gatherable, ref ActivateInWorldEvent args)
{
if (gatherable.Comp.ToolWhitelist?.IsValid(args.User, EntityManager) != true)
if (args.Handled || !args.Complex)
return;

if (_whitelistSystem.IsWhitelistFailOrNull(gatherable.Comp.ToolWhitelist, args.User))
return;

Gather(gatherable, args.User);
Gather(args.Target, args.User, gatherable.Comp);
args.Handled = true;
}

Expand All @@ -56,9 +56,7 @@ public void Gather(EntityUid gatheredUid, EntityUid? gatherer = null, Gatherable
return;

if (TryComp<SoundOnGatherComponent>(gatheredUid, out var soundComp))
{
_audio.PlayPvs(soundComp.Sound, Transform(gatheredUid).Coordinates);
}

// Complete the gathering process
_destructible.DestroyEntity(gatheredUid);
Expand All @@ -67,7 +65,7 @@ public void Gather(EntityUid gatheredUid, EntityUid? gatherer = null, Gatherable
if (component.Loot == null)
return;

var pos = Transform(gatheredUid).MapPosition;
var pos = _transform.GetMapCoordinates(gatheredUid);

foreach (var (tag, table) in component.Loot)
{
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Interaction/InteractionPopupSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public override void Initialize()

private void OnActivateInWorld(EntityUid uid, InteractionPopupComponent component, ActivateInWorldEvent args)
{
if (!args.Complex)
return;

if (!component.OnActivate)
return;

Expand Down
Loading

0 comments on commit 1016a08

Please sign in to comment.