Fix foldable mispredict (#14919)
This commit is contained in:
@@ -3,7 +3,6 @@ using Content.Server.Buckle.Systems;
|
|||||||
using Content.Server.Storage.Components;
|
using Content.Server.Storage.Components;
|
||||||
using Content.Shared.Buckle.Components;
|
using Content.Shared.Buckle.Components;
|
||||||
using Content.Shared.Foldable;
|
using Content.Shared.Foldable;
|
||||||
using Content.Shared.Storage.Components;
|
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
@@ -21,18 +20,9 @@ namespace Content.Server.Foldable
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<FoldableComponent, StorageOpenAttemptEvent>(OnFoldableOpenAttempt);
|
|
||||||
SubscribeLocalEvent<FoldableComponent, GetVerbsEvent<AlternativeVerb>>(AddFoldVerb);
|
SubscribeLocalEvent<FoldableComponent, GetVerbsEvent<AlternativeVerb>>(AddFoldVerb);
|
||||||
SubscribeLocalEvent<FoldableComponent, StoreMobInItemContainerAttemptEvent>(OnStoreThisAttempt);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFoldableOpenAttempt(EntityUid uid, FoldableComponent component, ref StorageOpenAttemptEvent args)
|
|
||||||
{
|
|
||||||
if (component.IsFolded)
|
|
||||||
args.Cancelled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TryToggleFold(EntityUid uid, FoldableComponent comp)
|
public bool TryToggleFold(EntityUid uid, FoldableComponent comp)
|
||||||
{
|
{
|
||||||
return TrySetFolded(uid, comp, !comp.IsFolded);
|
return TrySetFolded(uid, comp, !comp.IsFolded);
|
||||||
@@ -78,6 +68,7 @@ namespace Content.Server.Foldable
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the folded state of the given <see cref="FoldableComponent"/>
|
/// Set the folded state of the given <see cref="FoldableComponent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="uid"></param>
|
||||||
/// <param name="component"></param>
|
/// <param name="component"></param>
|
||||||
/// <param name="folded">If true, the component will become folded, else unfolded</param>
|
/// <param name="folded">If true, the component will become folded, else unfolded</param>
|
||||||
public override void SetFolded(EntityUid uid, FoldableComponent component, bool folded)
|
public override void SetFolded(EntityUid uid, FoldableComponent component, bool folded)
|
||||||
@@ -88,14 +79,6 @@ namespace Content.Server.Foldable
|
|||||||
_buckle.StrapSetEnabled(uid, !component.IsFolded);
|
_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
|
#region Verb
|
||||||
|
|
||||||
private void AddFoldVerb(EntityUid uid, FoldableComponent component, GetVerbsEvent<AlternativeVerb> args)
|
private void AddFoldVerb(EntityUid uid, FoldableComponent component, GetVerbsEvent<AlternativeVerb> args)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Content.Shared.Storage.Components;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
@@ -19,6 +20,8 @@ public abstract class SharedFoldableSystem : EntitySystem
|
|||||||
|
|
||||||
SubscribeLocalEvent<FoldableComponent, ComponentInit>(OnFoldableInit);
|
SubscribeLocalEvent<FoldableComponent, ComponentInit>(OnFoldableInit);
|
||||||
SubscribeLocalEvent<FoldableComponent, ContainerGettingInsertedAttemptEvent>(OnInsertEvent);
|
SubscribeLocalEvent<FoldableComponent, ContainerGettingInsertedAttemptEvent>(OnInsertEvent);
|
||||||
|
SubscribeLocalEvent<FoldableComponent, StoreMobInItemContainerAttemptEvent>(OnStoreThisAttempt);
|
||||||
|
SubscribeLocalEvent<FoldableComponent, StorageOpenAttemptEvent>(OnFoldableOpenAttempt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGetState(EntityUid uid, FoldableComponent component, ref ComponentGetState args)
|
private void OnGetState(EntityUid uid, FoldableComponent component, ref ComponentGetState args)
|
||||||
@@ -40,6 +43,20 @@ public abstract class SharedFoldableSystem : EntitySystem
|
|||||||
SetFolded(uid, component, component.IsFolded);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the folded state of the given <see cref="FoldableComponent"/>
|
/// Set the folded state of the given <see cref="FoldableComponent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user