Refactor actions to be entities with components (#19900)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Movement.Components;
|
||||
|
||||
@@ -9,8 +10,10 @@ public sealed partial class JetpackComponent : Component
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("moleUsage")]
|
||||
public float MoleUsage = 0.012f;
|
||||
|
||||
[DataField("toggleAction", required: true)]
|
||||
public InstantAction ToggleAction = new();
|
||||
[DataField("toggleAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string? ToggleAction = "ActionToggleJetpack";
|
||||
|
||||
[DataField("toggleActionEntity")] public EntityUid? ToggleActionEntity;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("acceleration")]
|
||||
public float Acceleration = 1f;
|
||||
|
||||
@@ -132,7 +132,7 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
|
||||
private void OnJetpackGetAction(EntityUid uid, JetpackComponent component, GetItemActionsEvent args)
|
||||
{
|
||||
args.Actions.Add(component.ToggleAction);
|
||||
args.AddAction(ref component.ToggleActionEntity, component.ToggleAction);
|
||||
}
|
||||
|
||||
private bool IsEnabled(EntityUid uid)
|
||||
@@ -182,7 +182,7 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
}
|
||||
|
||||
Appearance.SetData(uid, JetpackVisuals.Enabled, enabled);
|
||||
Dirty(component);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
public bool IsUserFlying(EntityUid uid)
|
||||
|
||||
Reference in New Issue
Block a user