From 420f50f155b2ebc5bc73a18eb84447117d9f2b0c Mon Sep 17 00:00:00 2001 From: BongoCatGamer Date: Sun, 17 Nov 2024 09:14:47 +0500 Subject: [PATCH 01/12] AccessWeaponBlockerComponent --- .../AccessWeaponBlockerComponent.cs | 13 ++++ .../AccessWeaponBlockerSystem.cs | 64 ++++++++++++++++ .../AccessWeaponBlockerComponent.cs | 20 +++++ .../AccessWeaponBlockerSystem.cs | 74 +++++++++++++++++++ .../SharedAccessWeaponBlockerComponent.cs | 17 +++++ .../SharedFactionWeaponBlockerSystem.cs | 6 ++ 6 files changed, 194 insertions(+) create mode 100644 Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs create mode 100644 Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs create mode 100644 Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs create mode 100644 Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs create mode 100644 Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs create mode 100644 Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedFactionWeaponBlockerSystem.cs diff --git a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs new file mode 100644 index 00000000000..134b2f8f80d --- /dev/null +++ b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs @@ -0,0 +1,13 @@ +using Content.Shared.Backmen.AccessGunBlockerSystem; + +namespace Content.Client.Backmen.AccessWeaponBlockerSystem; + +[RegisterComponent] +public sealed partial class AccessWeaponBlockerComponent : SharedAccessWeaponBlockerComponent +{ + [ViewVariables(VVAccess.ReadWrite)] + public bool CanUse; + + [ViewVariables(VVAccess.ReadWrite)] + public string AlertText = ""; +} diff --git a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs new file mode 100644 index 00000000000..c1ef008b1c3 --- /dev/null +++ b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs @@ -0,0 +1,64 @@ +using Content.Shared.Interaction.Events; +using Content.Shared.Backmen.AccessGunBlockerSystem; +using Content.Shared.Weapons.Melee.Events; +using Content.Shared.Weapons.Ranged.Systems; +using Robust.Shared.GameStates; + +namespace Content.Client.Backmen.AccessWeaponBlockerSystem; + +public sealed class AccessWeaponBlockerSystem : EntitySystem +{ + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnShootAttempt); + SubscribeLocalEvent(OnMeleeAttempt); + SubscribeLocalEvent(OnUseAttempt); + SubscribeLocalEvent(OnInteractAttempt); + SubscribeLocalEvent(OnFactionWeaponBlockerHandleState); + } + + private void OnUseAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref UseAttemptEvent args) + { + if (component.CanUse) + return; + + args.Cancel(); + } + + private void OnInteractAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref InteractionAttemptEvent args) + { + if (component.CanUse) + return; + + args.Cancelled = true; + } + + private void OnFactionWeaponBlockerHandleState(EntityUid uid, AccessWeaponBlockerComponent component, ref ComponentHandleState args) + { + if (args.Current is not AccessWeaponBlockerComponentState state) + return; + + component.CanUse = state.CanUse; + component.AlertText = state.AlertText; + } + + private void OnMeleeAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref AttemptMeleeEvent args) + { + if (component.CanUse) + return; + + args.Cancelled = true; + args.Message = component.AlertText; + } + + private void OnShootAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref AttemptShootEvent args) + { + if (component.CanUse) + return; + + args.Cancelled = true; + args.Message = component.AlertText; + } +} diff --git a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs new file mode 100644 index 00000000000..821ad23dd01 --- /dev/null +++ b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs @@ -0,0 +1,20 @@ +using Content.Shared.Access; +using Content.Shared.Backmen.AccessGunBlockerSystem; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set; + +namespace Content.Server.Backmen.AccessWeaponBlockerSystem; + +[RegisterComponent] +public sealed partial class AccessWeaponBlockerComponent : SharedAccessWeaponBlockerComponent +{ + [ViewVariables(VVAccess.ReadWrite)] + public bool CanUse; + + [ViewVariables(VVAccess.ReadWrite)] + [DataField("alertText")] + public string AlertText = ""; + + [ViewVariables(VVAccess.ReadWrite), + DataField("access", customTypeSerializer: typeof(PrototypeIdHashSetSerializer))] + public HashSet Access = new(); +} diff --git a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs new file mode 100644 index 00000000000..0ad6ee95167 --- /dev/null +++ b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs @@ -0,0 +1,74 @@ +using Content.Shared.Hands; +using Content.Shared.Access.Components; +using Content.Shared.Backmen.AccessGunBlockerSystem; +using Content.Shared.Weapons.Melee.Events; +using Content.Shared.Weapons.Ranged.Systems; +using Robust.Shared.GameStates; +using Content.Shared.Inventory; +using Content.Shared.PDA; + +namespace Content.Server.Backmen.AccessWeaponBlockerSystem; + +public sealed class AccessWeaponBlockerSystem : EntitySystem +{ + [Dependency] private readonly InventorySystem _inventorySystem = default!; + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnShootAttempt); + SubscribeLocalEvent(OnMeleeAttempt); + SubscribeLocalEvent(OnGetState); + SubscribeLocalEvent(OnGotEquippedHand); + } + + + private void OnGotEquippedHand(Entity accessBlocker, ref GotEquippedHandEvent args) + { + if (!_inventorySystem.TryGetSlotEntity(args.User, "id", out var slotCardUid)) + return; + var accessEntity = TryComp(slotCardUid, out var pda) && pda.ContainedId is { } pdaSlot + ? pdaSlot + : slotCardUid.Value; + accessBlocker.Comp.CanUse = IsAnyAccess(accessEntity, accessBlocker); + Dirty(accessBlocker); + } + + private bool IsAnyAccess(EntityUid accessEntity, Entity accessBlocker) + { + if (!TryComp(accessEntity, out var access)) + return false; + foreach (var accessTag in access.Tags) + { + if (accessBlocker.Comp.Access.Contains(accessTag)) + return true; + } + return false; + } + private void OnGetState(EntityUid uid, AccessWeaponBlockerComponent component, ref ComponentGetState args) + { + args.State = new AccessWeaponBlockerComponentState() + { + CanUse = component.CanUse, + AlertText = component.AlertText + }; + } + + private void OnMeleeAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref AttemptMeleeEvent args) + { + if (component.CanUse) + return; + + args.Cancelled = true; + args.Message = component.AlertText; + } + + private void OnShootAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref AttemptShootEvent args) + { + if (component.CanUse) + return; + + args.Cancelled = true; + args.Message = component.AlertText; + } +} diff --git a/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs b/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs new file mode 100644 index 00000000000..55a8c772e3a --- /dev/null +++ b/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs @@ -0,0 +1,17 @@ +using Robust.Shared.GameStates; +using Robust.Shared.Serialization; + +namespace Content.Shared.Backmen.AccessGunBlockerSystem; + +[NetworkedComponent] +public abstract partial class SharedAccessWeaponBlockerComponent : Component +{ + +} + +[Serializable, NetSerializable] +public sealed class AccessWeaponBlockerComponentState : ComponentState +{ + public bool CanUse; + public string AlertText = ""; +} diff --git a/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedFactionWeaponBlockerSystem.cs b/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedFactionWeaponBlockerSystem.cs new file mode 100644 index 00000000000..ea49d93ae10 --- /dev/null +++ b/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedFactionWeaponBlockerSystem.cs @@ -0,0 +1,6 @@ +namespace Content.Shared.Backmen.AccessWeaponBlockerSystem; + +public sealed class SharedFactionWeaponBlockerSystem : EntitySystem +{ + +} From a1c3a2c77c4f77c9ba68834c157f0547f2c209e6 Mon Sep 17 00:00:00 2001 From: Cat <115424457+CatBackGround@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:06:30 +0500 Subject: [PATCH 02/12] Update AccessWeaponBlockerSystem.cs --- .../AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs index c1ef008b1c3..50d785b9b89 100644 --- a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs +++ b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs @@ -35,7 +35,7 @@ private void OnInteractAttempt(EntityUid uid, AccessWeaponBlockerComponent compo args.Cancelled = true; } - private void OnFactionWeaponBlockerHandleState(EntityUid uid, AccessWeaponBlockerComponent component, ref ComponentHandleState args) + private void OnAccessWeaponBlockerHandleState(EntityUid uid, AccessWeaponBlockerComponent component, ref ComponentHandleState args) { if (args.Current is not AccessWeaponBlockerComponentState state) return; From b4b94482c32ba06cac96476202fb521e823bb241 Mon Sep 17 00:00:00 2001 From: Cat <115424457+CatBackGround@users.noreply.github.com> Date: Mon, 18 Nov 2024 22:24:45 +0500 Subject: [PATCH 03/12] Update AccessWeaponBlockerSystem.cs --- .../AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs index 0ad6ee95167..3fce4913a14 100644 --- a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs +++ b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs @@ -47,7 +47,7 @@ private bool IsAnyAccess(EntityUid accessEntity, Entity Date: Mon, 18 Nov 2024 22:30:35 +0500 Subject: [PATCH 04/12] FIX --- .../AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs | 2 +- .../AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs index 50d785b9b89..0eb6b7123b7 100644 --- a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs +++ b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs @@ -16,7 +16,7 @@ public override void Initialize() SubscribeLocalEvent(OnMeleeAttempt); SubscribeLocalEvent(OnUseAttempt); SubscribeLocalEvent(OnInteractAttempt); - SubscribeLocalEvent(OnFactionWeaponBlockerHandleState); + SubscribeLocalEvent(OnAccessWeaponBlockerHandleState); } private void OnUseAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref UseAttemptEvent args) diff --git a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs index 3fce4913a14..0ad6ee95167 100644 --- a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs +++ b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs @@ -47,7 +47,7 @@ private bool IsAnyAccess(EntityUid accessEntity, Entity Date: Sun, 24 Nov 2024 15:30:10 +0500 Subject: [PATCH 05/12] upd --- .../AccessWeaponBlockerSystem.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs index 0ad6ee95167..bec5d587b6c 100644 --- a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs +++ b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs @@ -23,24 +23,24 @@ public override void Initialize() } - private void OnGotEquippedHand(Entity accessBlocker, ref GotEquippedHandEvent args) + private void OnGotEquippedHand(EntityUid uid, AccessWeaponBlockerComponent component, ref GotEquippedHandEvent args) { if (!_inventorySystem.TryGetSlotEntity(args.User, "id", out var slotCardUid)) return; var accessEntity = TryComp(slotCardUid, out var pda) && pda.ContainedId is { } pdaSlot ? pdaSlot : slotCardUid.Value; - accessBlocker.Comp.CanUse = IsAnyAccess(accessEntity, accessBlocker); - Dirty(accessBlocker); + component.CanUse = IsAnyAccess(accessEntity, component); + Dirty(uid, component); } - private bool IsAnyAccess(EntityUid accessEntity, Entity accessBlocker) + private bool IsAnyAccess(EntityUid accessEntity, AccessWeaponBlockerComponent component) { if (!TryComp(accessEntity, out var access)) return false; foreach (var accessTag in access.Tags) { - if (accessBlocker.Comp.Access.Contains(accessTag)) + if (component.Access.Contains(accessTag)) return true; } return false; From 85bfd8ed837b46ec4e624bec7d41b62720c0f325 Mon Sep 17 00:00:00 2001 From: BongoCatGamer Date: Sun, 24 Nov 2024 15:33:31 +0500 Subject: [PATCH 06/12] upd x2 --- .../SharedAccessWeaponBlockerComponent.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs b/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs index 55a8c772e3a..1e01ae7d30e 100644 --- a/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs +++ b/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs @@ -1,7 +1,7 @@ using Robust.Shared.GameStates; using Robust.Shared.Serialization; -namespace Content.Shared.Backmen.AccessGunBlockerSystem; +namespace Content.Shared.Backmen.AccessWeaponBlockerSystem;; [NetworkedComponent] public abstract partial class SharedAccessWeaponBlockerComponent : Component From 78e5a1bf993a9cba2cf552a8e365632c1a08bd5f Mon Sep 17 00:00:00 2001 From: BongoCatGamer Date: Sun, 24 Nov 2024 15:44:28 +0500 Subject: [PATCH 07/12] FIX --- .../AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs | 2 +- .../SharedAccessWeaponBlockerComponent.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs index bec5d587b6c..592a314394b 100644 --- a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs +++ b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs @@ -1,6 +1,6 @@ using Content.Shared.Hands; using Content.Shared.Access.Components; -using Content.Shared.Backmen.AccessGunBlockerSystem; +using Content.Shared.Backmen.AccessWeaponBlockerSystem; using Content.Shared.Weapons.Melee.Events; using Content.Shared.Weapons.Ranged.Systems; using Robust.Shared.GameStates; diff --git a/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs b/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs index 1e01ae7d30e..47a14ec401e 100644 --- a/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs +++ b/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs @@ -1,7 +1,7 @@ using Robust.Shared.GameStates; using Robust.Shared.Serialization; -namespace Content.Shared.Backmen.AccessWeaponBlockerSystem;; +namespace Content.Shared.Backmen.AccessWeaponBlockerSystem; [NetworkedComponent] public abstract partial class SharedAccessWeaponBlockerComponent : Component From 34af9b3b4df98a4d4d63a4f04590320345afcb95 Mon Sep 17 00:00:00 2001 From: BongoCatGamer Date: Sun, 24 Nov 2024 17:34:00 +0500 Subject: [PATCH 08/12] FIX x2 --- .../AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs index 0eb6b7123b7..823cf8b7df7 100644 --- a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs +++ b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs @@ -1,5 +1,5 @@ using Content.Shared.Interaction.Events; -using Content.Shared.Backmen.AccessGunBlockerSystem; +using Content.Shared.Backmen.AccessWeaponBlockerSystem; using Content.Shared.Weapons.Melee.Events; using Content.Shared.Weapons.Ranged.Systems; using Robust.Shared.GameStates; From b27c26b7c251d04ca1330c9edc3d9f5ec9dbf161 Mon Sep 17 00:00:00 2001 From: BongoCatGamer Date: Sun, 24 Nov 2024 17:37:14 +0500 Subject: [PATCH 09/12] Fix... --- .../AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs index 821ad23dd01..49bf7e87044 100644 --- a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs +++ b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs @@ -1,5 +1,5 @@ using Content.Shared.Access; -using Content.Shared.Backmen.AccessGunBlockerSystem; +using Content.Shared.Backmen.AccessWeaponBlockerSystem; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set; namespace Content.Server.Backmen.AccessWeaponBlockerSystem; From 641e5ad0d3243538fb686de4c59dced75e3acbff Mon Sep 17 00:00:00 2001 From: BongoCatGamer Date: Sun, 24 Nov 2024 17:52:59 +0500 Subject: [PATCH 10/12] FIX x3 --- .../AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs index 134b2f8f80d..83e96b0450a 100644 --- a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs +++ b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs @@ -1,4 +1,4 @@ -using Content.Shared.Backmen.AccessGunBlockerSystem; +using Content.Shared.Backmen.AccessWeaponBlockerSystem; namespace Content.Client.Backmen.AccessWeaponBlockerSystem; From 6c93971a852aa3ae4456ca4fd829d42524da870b Mon Sep 17 00:00:00 2001 From: no_mad Date: Sat, 30 Nov 2024 23:51:11 +0900 Subject: [PATCH 11/12] faction access --- .../SharedAccessWeaponBlockerSystem.cs | 6 ++++++ .../SharedFactionWeaponBlockerSystem.cs | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerSystem.cs delete mode 100644 Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedFactionWeaponBlockerSystem.cs diff --git a/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerSystem.cs b/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerSystem.cs new file mode 100644 index 00000000000..43a1a9c1f80 --- /dev/null +++ b/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerSystem.cs @@ -0,0 +1,6 @@ +namespace Content.Shared.Backmen.AccessWeaponBlockerSystem; + +public sealed class SharedAccessWeaponBlockerSystem : EntitySystem +{ + +} diff --git a/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedFactionWeaponBlockerSystem.cs b/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedFactionWeaponBlockerSystem.cs deleted file mode 100644 index ea49d93ae10..00000000000 --- a/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedFactionWeaponBlockerSystem.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Content.Shared.Backmen.AccessWeaponBlockerSystem; - -public sealed class SharedFactionWeaponBlockerSystem : EntitySystem -{ - -} From 7e8c0702d52932bec9a8dc92cd329d061b62afd8 Mon Sep 17 00:00:00 2001 From: Zack Backmen Date: Sat, 7 Dec 2024 04:42:46 +0300 Subject: [PATCH 12/12] cleaup --- .../AccessWeaponBlockerComponent.cs | 13 ---- .../AccessWeaponBlockerSystem.cs | 64 ----------------- .../AccessWeaponBlockerComponent.cs | 20 ------ .../AccessWeaponBlockerComponent.cs | 20 ++++++ .../AccessWeaponBlockerSystem.cs | 71 ++++++++++--------- .../SharedAccessWeaponBlockerComponent.cs | 17 ----- .../SharedAccessWeaponBlockerSystem.cs | 6 -- 7 files changed, 59 insertions(+), 152 deletions(-) delete mode 100644 Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs delete mode 100644 Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs delete mode 100644 Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs create mode 100644 Content.Shared/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs rename {Content.Server => Content.Shared}/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs (75%) delete mode 100644 Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs delete mode 100644 Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerSystem.cs diff --git a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs deleted file mode 100644 index 83e96b0450a..00000000000 --- a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Content.Shared.Backmen.AccessWeaponBlockerSystem; - -namespace Content.Client.Backmen.AccessWeaponBlockerSystem; - -[RegisterComponent] -public sealed partial class AccessWeaponBlockerComponent : SharedAccessWeaponBlockerComponent -{ - [ViewVariables(VVAccess.ReadWrite)] - public bool CanUse; - - [ViewVariables(VVAccess.ReadWrite)] - public string AlertText = ""; -} diff --git a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs b/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs deleted file mode 100644 index 823cf8b7df7..00000000000 --- a/Content.Client/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Content.Shared.Interaction.Events; -using Content.Shared.Backmen.AccessWeaponBlockerSystem; -using Content.Shared.Weapons.Melee.Events; -using Content.Shared.Weapons.Ranged.Systems; -using Robust.Shared.GameStates; - -namespace Content.Client.Backmen.AccessWeaponBlockerSystem; - -public sealed class AccessWeaponBlockerSystem : EntitySystem -{ - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnShootAttempt); - SubscribeLocalEvent(OnMeleeAttempt); - SubscribeLocalEvent(OnUseAttempt); - SubscribeLocalEvent(OnInteractAttempt); - SubscribeLocalEvent(OnAccessWeaponBlockerHandleState); - } - - private void OnUseAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref UseAttemptEvent args) - { - if (component.CanUse) - return; - - args.Cancel(); - } - - private void OnInteractAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref InteractionAttemptEvent args) - { - if (component.CanUse) - return; - - args.Cancelled = true; - } - - private void OnAccessWeaponBlockerHandleState(EntityUid uid, AccessWeaponBlockerComponent component, ref ComponentHandleState args) - { - if (args.Current is not AccessWeaponBlockerComponentState state) - return; - - component.CanUse = state.CanUse; - component.AlertText = state.AlertText; - } - - private void OnMeleeAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref AttemptMeleeEvent args) - { - if (component.CanUse) - return; - - args.Cancelled = true; - args.Message = component.AlertText; - } - - private void OnShootAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref AttemptShootEvent args) - { - if (component.CanUse) - return; - - args.Cancelled = true; - args.Message = component.AlertText; - } -} diff --git a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs b/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs deleted file mode 100644 index 49bf7e87044..00000000000 --- a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Content.Shared.Access; -using Content.Shared.Backmen.AccessWeaponBlockerSystem; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set; - -namespace Content.Server.Backmen.AccessWeaponBlockerSystem; - -[RegisterComponent] -public sealed partial class AccessWeaponBlockerComponent : SharedAccessWeaponBlockerComponent -{ - [ViewVariables(VVAccess.ReadWrite)] - public bool CanUse; - - [ViewVariables(VVAccess.ReadWrite)] - [DataField("alertText")] - public string AlertText = ""; - - [ViewVariables(VVAccess.ReadWrite), - DataField("access", customTypeSerializer: typeof(PrototypeIdHashSetSerializer))] - public HashSet Access = new(); -} diff --git a/Content.Shared/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs b/Content.Shared/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs new file mode 100644 index 00000000000..0312b88e51d --- /dev/null +++ b/Content.Shared/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerComponent.cs @@ -0,0 +1,20 @@ +using Content.Shared.Access; +using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; + +namespace Content.Shared.Backmen.AccessWeaponBlockerSystem; + +[RegisterComponent,NetworkedComponent,AutoGenerateComponentState] +public sealed partial class AccessWeaponBlockerComponent : Component +{ + [ViewVariables(VVAccess.ReadWrite),AutoNetworkedField] + public bool CanUse; + + [ViewVariables(VVAccess.ReadWrite),AutoNetworkedField] + [DataField("alertText")] + public LocId AlertText = ""; + + [ViewVariables(VVAccess.ReadWrite), + DataField("access")] + public HashSet> Access = new(); +} diff --git a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs b/Content.Shared/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs similarity index 75% rename from Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs rename to Content.Shared/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs index 592a314394b..677887fdcb3 100644 --- a/Content.Server/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs +++ b/Content.Shared/Backmen/AccessWeaponBlockerSystem/AccessWeaponBlockerSystem.cs @@ -1,13 +1,12 @@ -using Content.Shared.Hands; using Content.Shared.Access.Components; -using Content.Shared.Backmen.AccessWeaponBlockerSystem; -using Content.Shared.Weapons.Melee.Events; -using Content.Shared.Weapons.Ranged.Systems; -using Robust.Shared.GameStates; +using Content.Shared.Hands; +using Content.Shared.Interaction.Events; using Content.Shared.Inventory; using Content.Shared.PDA; +using Content.Shared.Weapons.Melee.Events; +using Content.Shared.Weapons.Ranged.Systems; -namespace Content.Server.Backmen.AccessWeaponBlockerSystem; +namespace Content.Shared.Backmen.AccessWeaponBlockerSystem; public sealed class AccessWeaponBlockerSystem : EntitySystem { @@ -18,40 +17,25 @@ public override void Initialize() SubscribeLocalEvent(OnShootAttempt); SubscribeLocalEvent(OnMeleeAttempt); - SubscribeLocalEvent(OnGetState); + SubscribeLocalEvent(OnUseAttempt); + SubscribeLocalEvent(OnInteractAttempt); SubscribeLocalEvent(OnGotEquippedHand); } - - private void OnGotEquippedHand(EntityUid uid, AccessWeaponBlockerComponent component, ref GotEquippedHandEvent args) + private void OnUseAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref UseAttemptEvent args) { - if (!_inventorySystem.TryGetSlotEntity(args.User, "id", out var slotCardUid)) + if (component.CanUse) return; - var accessEntity = TryComp(slotCardUid, out var pda) && pda.ContainedId is { } pdaSlot - ? pdaSlot - : slotCardUid.Value; - component.CanUse = IsAnyAccess(accessEntity, component); - Dirty(uid, component); - } - private bool IsAnyAccess(EntityUid accessEntity, AccessWeaponBlockerComponent component) - { - if (!TryComp(accessEntity, out var access)) - return false; - foreach (var accessTag in access.Tags) - { - if (component.Access.Contains(accessTag)) - return true; - } - return false; + args.Cancel(); } - private void OnGetState(EntityUid uid, AccessWeaponBlockerComponent component, ref ComponentGetState args) + + private void OnInteractAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref InteractionAttemptEvent args) { - args.State = new AccessWeaponBlockerComponentState() - { - CanUse = component.CanUse, - AlertText = component.AlertText - }; + if (component.CanUse) + return; + + args.Cancelled = true; } private void OnMeleeAttempt(EntityUid uid, AccessWeaponBlockerComponent component, ref AttemptMeleeEvent args) @@ -71,4 +55,27 @@ private void OnShootAttempt(EntityUid uid, AccessWeaponBlockerComponent componen args.Cancelled = true; args.Message = component.AlertText; } + + private void OnGotEquippedHand(EntityUid uid, AccessWeaponBlockerComponent component, ref GotEquippedHandEvent args) + { + if (!_inventorySystem.TryGetSlotEntity(args.User, "id", out var slotCardUid)) + return; + var accessEntity = TryComp(slotCardUid, out var pda) && pda.ContainedId is { } pdaSlot + ? pdaSlot + : slotCardUid.Value; + component.CanUse = IsAnyAccess(accessEntity, component); + Dirty(uid, component); + } + + private bool IsAnyAccess(EntityUid accessEntity, AccessWeaponBlockerComponent component) + { + if (!TryComp(accessEntity, out var access)) + return false; + foreach (var accessTag in access.Tags) + { + if (component.Access.Contains(accessTag)) + return true; + } + return false; + } } diff --git a/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs b/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs deleted file mode 100644 index 47a14ec401e..00000000000 --- a/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerComponent.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Robust.Shared.GameStates; -using Robust.Shared.Serialization; - -namespace Content.Shared.Backmen.AccessWeaponBlockerSystem; - -[NetworkedComponent] -public abstract partial class SharedAccessWeaponBlockerComponent : Component -{ - -} - -[Serializable, NetSerializable] -public sealed class AccessWeaponBlockerComponentState : ComponentState -{ - public bool CanUse; - public string AlertText = ""; -} diff --git a/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerSystem.cs b/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerSystem.cs deleted file mode 100644 index 43a1a9c1f80..00000000000 --- a/Content.Shared/Backmen/AccessWeaponBlockerSystem/SharedAccessWeaponBlockerSystem.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Content.Shared.Backmen.AccessWeaponBlockerSystem; - -public sealed class SharedAccessWeaponBlockerSystem : EntitySystem -{ - -}