From 62e5ef8041df339bbb2d4c62ae978dde72509e92 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Tue, 28 Mar 2023 01:43:36 -0400 Subject: [PATCH] Fix foldable mispredict (#14919) --- Content.Server/Foldable/FoldableSystem.cs | 19 +------------------ .../Foldable/SharedFoldableSystem.cs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Content.Server/Foldable/FoldableSystem.cs b/Content.Server/Foldable/FoldableSystem.cs index 13ae06df4a..a7748ccce2 100644 --- a/Content.Server/Foldable/FoldableSystem.cs +++ b/Content.Server/Foldable/FoldableSystem.cs @@ -3,7 +3,6 @@ using Content.Server.Buckle.Systems; using Content.Server.Storage.Components; using Content.Shared.Buckle.Components; using Content.Shared.Foldable; -using Content.Shared.Storage.Components; using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Shared.Containers; @@ -21,18 +20,9 @@ namespace Content.Server.Foldable { base.Initialize(); - SubscribeLocalEvent(OnFoldableOpenAttempt); SubscribeLocalEvent>(AddFoldVerb); - SubscribeLocalEvent(OnStoreThisAttempt); } - - private void OnFoldableOpenAttempt(EntityUid uid, FoldableComponent component, ref StorageOpenAttemptEvent args) - { - if (component.IsFolded) - args.Cancelled = true; - } - public bool TryToggleFold(EntityUid uid, FoldableComponent comp) { return TrySetFolded(uid, comp, !comp.IsFolded); @@ -78,6 +68,7 @@ namespace Content.Server.Foldable /// /// Set the folded state of the given /// + /// /// /// If true, the component will become folded, else unfolded public override void SetFolded(EntityUid uid, FoldableComponent component, bool folded) @@ -88,14 +79,6 @@ namespace Content.Server.Foldable _buckle.StrapSetEnabled(uid, !component.IsFolded); } - public void OnStoreThisAttempt(EntityUid uid, FoldableComponent comp, ref StoreMobInItemContainerAttemptEvent args) - { - args.Handled = true; - - if (comp.IsFolded) - args.Cancelled = true; - } - #region Verb private void AddFoldVerb(EntityUid uid, FoldableComponent component, GetVerbsEvent args) diff --git a/Content.Shared/Foldable/SharedFoldableSystem.cs b/Content.Shared/Foldable/SharedFoldableSystem.cs index dce19d6e82..da94da686d 100644 --- a/Content.Shared/Foldable/SharedFoldableSystem.cs +++ b/Content.Shared/Foldable/SharedFoldableSystem.cs @@ -1,3 +1,4 @@ +using Content.Shared.Storage.Components; using JetBrains.Annotations; using Robust.Shared.Containers; using Robust.Shared.GameStates; @@ -19,6 +20,8 @@ public abstract class SharedFoldableSystem : EntitySystem SubscribeLocalEvent(OnFoldableInit); SubscribeLocalEvent(OnInsertEvent); + SubscribeLocalEvent(OnStoreThisAttempt); + SubscribeLocalEvent(OnFoldableOpenAttempt); } private void OnGetState(EntityUid uid, FoldableComponent component, ref ComponentGetState args) @@ -40,6 +43,20 @@ public abstract class SharedFoldableSystem : EntitySystem SetFolded(uid, component, component.IsFolded); } + private void OnFoldableOpenAttempt(EntityUid uid, FoldableComponent component, ref StorageOpenAttemptEvent args) + { + if (component.IsFolded) + args.Cancelled = true; + } + + public void OnStoreThisAttempt(EntityUid uid, FoldableComponent comp, ref StoreMobInItemContainerAttemptEvent args) + { + args.Handled = true; + + if (comp.IsFolded) + args.Cancelled = true; + } + /// /// Set the folded state of the given /// -- 2.51.2