Fix action-granting items not being predicted (#20778)
* Ensure actions are predicted * Fix test fail
This commit is contained in:
@@ -27,6 +27,7 @@ public sealed partial class BlockingSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
||||
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly FixtureSystem _fixtureSystem = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
@@ -51,11 +52,19 @@ public sealed partial class BlockingSystem : EntitySystem
|
||||
SubscribeLocalEvent<BlockingComponent, ComponentShutdown>(OnShutdown);
|
||||
|
||||
SubscribeLocalEvent<BlockingComponent, GetVerbsEvent<ExamineVerb>>(OnVerbExamine);
|
||||
SubscribeLocalEvent<BlockingComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, BlockingComponent component, MapInitEvent args)
|
||||
{
|
||||
_actionContainer.EnsureAction(uid, ref component.BlockingToggleActionEntity, component.BlockingToggleAction);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
private void OnEquip(EntityUid uid, BlockingComponent component, GotEquippedHandEvent args)
|
||||
{
|
||||
component.User = args.User;
|
||||
Dirty(uid, component);
|
||||
|
||||
//To make sure that this bodytype doesn't get set as anything but the original
|
||||
if (TryComp<PhysicsComponent>(args.User, out var physicsComponent) && physicsComponent.BodyType != BodyType.Static && !HasComp<BlockingUserComponent>(args.User))
|
||||
@@ -201,6 +210,7 @@ public sealed partial class BlockingSystem : EntitySystem
|
||||
}
|
||||
|
||||
component.IsBlocking = true;
|
||||
Dirty(item, component);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -254,6 +264,7 @@ public sealed partial class BlockingSystem : EntitySystem
|
||||
}
|
||||
|
||||
component.IsBlocking = false;
|
||||
Dirty(item, component);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
@@ -9,19 +10,19 @@ namespace Content.Shared.Blocking;
|
||||
/// <summary>
|
||||
/// This component goes on an item that you want to use to block
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class BlockingComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The entity that's blocking
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[ViewVariables, AutoNetworkedField]
|
||||
public EntityUid? User;
|
||||
|
||||
/// <summary>
|
||||
/// Is it currently blocking?
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[ViewVariables, AutoNetworkedField]
|
||||
public bool IsBlocking;
|
||||
|
||||
/// <summary>
|
||||
@@ -50,7 +51,7 @@ public sealed partial class BlockingComponent : Component
|
||||
[DataField("blockingToggleAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string BlockingToggleAction = "ActionToggleBlock";
|
||||
|
||||
[DataField("blockingToggleActionEntity")]
|
||||
[DataField, AutoNetworkedField]
|
||||
public EntityUid? BlockingToggleActionEntity;
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user