Fix action-granting items not being predicted (#20778)
* Ensure actions are predicted * Fix test fail
This commit is contained in:
@@ -3,21 +3,22 @@ using Content.Shared.Ninja.Systems;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Ninja.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Adds an action to dash, teleport to clicked position, when this item is held.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(DashAbilitySystem))]
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(DashAbilitySystem)), AutoGenerateComponentState]
|
||||
public sealed partial class DashAbilityComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The action id for dashing.
|
||||
/// </summary>
|
||||
[DataField("dashAction", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>)), ViewVariables(VVAccess.ReadWrite)]
|
||||
public string DashAction = string.Empty;
|
||||
[DataField]
|
||||
public EntProtoId DashAction = "ActionEnergyKatanaDash";
|
||||
|
||||
[DataField("dashActionEntity")]
|
||||
[DataField, AutoNetworkedField]
|
||||
public EntityUid? DashActionEntity;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -31,7 +31,7 @@ public sealed partial class NinjaGlovesComponent : Component
|
||||
[DataField("toggleAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string ToggleAction = "ActionToggleNinjaGloves";
|
||||
|
||||
[DataField("toggleActionEntity")]
|
||||
[DataField, AutoNetworkedField]
|
||||
public EntityUid? ToggleActionEntity;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -47,7 +47,7 @@ public sealed partial class NinjaSuitComponent : Component
|
||||
[DataField("createThrowingStarAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string CreateThrowingStarAction = "ActionCreateThrowingStar";
|
||||
|
||||
[DataField("createThrowingStarActionEntity")]
|
||||
[DataField, AutoNetworkedField]
|
||||
public EntityUid? CreateThrowingStarActionEntity;
|
||||
|
||||
/// <summary>
|
||||
@@ -68,7 +68,7 @@ public sealed partial class NinjaSuitComponent : Component
|
||||
[DataField("recallKatanaAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string RecallKatanaAction = "ActionRecallKatana";
|
||||
|
||||
[DataField("recallKatanaActionEntity")]
|
||||
[DataField, AutoNetworkedField]
|
||||
public EntityUid? RecallKatanaActionEntity;
|
||||
|
||||
/// <summary>
|
||||
@@ -84,7 +84,7 @@ public sealed partial class NinjaSuitComponent : Component
|
||||
[DataField("empAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string EmpAction = "ActionNinjaEmp";
|
||||
|
||||
[DataField("empActionEntity")]
|
||||
[DataField, AutoNetworkedField]
|
||||
public EntityUid? EmpActionEntity;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,8 +6,6 @@ using Content.Shared.Interaction;
|
||||
using Content.Shared.Ninja.Components;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Ninja.Systems;
|
||||
@@ -24,6 +22,7 @@ public sealed class DashAbilitySystem : EntitySystem
|
||||
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -31,6 +30,13 @@ public sealed class DashAbilitySystem : EntitySystem
|
||||
|
||||
SubscribeLocalEvent<DashAbilityComponent, GetItemActionsEvent>(OnGetItemActions);
|
||||
SubscribeLocalEvent<DashAbilityComponent, DashEvent>(OnDash);
|
||||
SubscribeLocalEvent<DashAbilityComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, DashAbilityComponent component, MapInitEvent args)
|
||||
{
|
||||
_actionContainer.EnsureAction(uid, ref component.DashActionEntity, component.DashAction);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
private void OnGetItemActions(EntityUid uid, DashAbilityComponent comp, GetItemActionsEvent args)
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Communications;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Ninja.Components;
|
||||
@@ -14,7 +11,6 @@ using Content.Shared.Research.Components;
|
||||
using Content.Shared.Timing;
|
||||
using Content.Shared.Toggleable;
|
||||
using Robust.Shared.Timing;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Content.Shared.Ninja.Systems;
|
||||
|
||||
@@ -26,11 +22,10 @@ public abstract class SharedNinjaGlovesSystem : EntitySystem
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
|
||||
[Dependency] private readonly SharedCombatModeSystem _combatMode = default!;
|
||||
[Dependency] protected readonly SharedDoAfterSystem _doAfter = default!;
|
||||
[Dependency] protected readonly SharedInteractionSystem Interaction = default!;
|
||||
[Dependency] private readonly SharedSpaceNinjaSystem _ninja = default!;
|
||||
[Dependency] protected readonly SharedPopupSystem Popup = default!;
|
||||
[Dependency] private readonly UseDelaySystem _useDelay = default!;
|
||||
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -39,6 +34,13 @@ public abstract class SharedNinjaGlovesSystem : EntitySystem
|
||||
SubscribeLocalEvent<NinjaGlovesComponent, GetItemActionsEvent>(OnGetItemActions);
|
||||
SubscribeLocalEvent<NinjaGlovesComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<NinjaGlovesComponent, GotUnequippedEvent>(OnUnequipped);
|
||||
SubscribeLocalEvent<NinjaGlovesComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, NinjaGlovesComponent component, MapInitEvent args)
|
||||
{
|
||||
_actionContainer.EnsureAction(uid, ref component.ToggleActionEntity, component.ToggleAction);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -4,10 +4,6 @@ using Content.Shared.Clothing.EntitySystems;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Ninja.Components;
|
||||
using Content.Shared.Timing;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Ninja.Systems;
|
||||
|
||||
@@ -21,6 +17,7 @@ public abstract class SharedNinjaSuitSystem : EntitySystem
|
||||
[Dependency] protected readonly SharedSpaceNinjaSystem _ninja = default!;
|
||||
[Dependency] protected readonly StealthClothingSystem StealthClothing = default!;
|
||||
[Dependency] protected readonly UseDelaySystem UseDelay = default!;
|
||||
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -30,6 +27,15 @@ public abstract class SharedNinjaSuitSystem : EntitySystem
|
||||
SubscribeLocalEvent<NinjaSuitComponent, GetItemActionsEvent>(OnGetItemActions);
|
||||
SubscribeLocalEvent<NinjaSuitComponent, AddStealthActionEvent>(OnAddStealthAction);
|
||||
SubscribeLocalEvent<NinjaSuitComponent, GotUnequippedEvent>(OnUnequipped);
|
||||
SubscribeLocalEvent<NinjaSuitComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, NinjaSuitComponent component, MapInitEvent args)
|
||||
{
|
||||
_actionContainer.EnsureAction(uid, ref component.RecallKatanaActionEntity, component.RecallKatanaAction);
|
||||
_actionContainer.EnsureAction(uid, ref component.CreateThrowingStarActionEntity, component.CreateThrowingStarAction);
|
||||
_actionContainer.EnsureAction(uid, ref component.EmpActionEntity, component.EmpAction);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user