Re-add action prototypes (#7508)

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
Leon Friedrich
2022-04-14 16:17:34 +12:00
committed by GitHub
parent c30b38a476
commit ba75934512
34 changed files with 291 additions and 189 deletions

View File

@@ -0,0 +1,56 @@
using Robust.Shared.Prototypes;
namespace Content.Shared.Actions.ActionTypes;
// These are just prototype definitions for actions. Allows actions to be defined once in yaml and re-used elsewhere.
// Note that you still need to create a new instance of each action to properly track the state (cooldown, toggled,
// enabled, etc). The prototypes should not be modified directly.
//
// If ever action states data is separated from the rest of the data, this might not be required
// anymore.
[Prototype("worldTargetAction")]
public sealed class WorldTargetActionPrototype : WorldTargetAction, IPrototype
{
[IdDataFieldAttribute]
public string ID { get; } = default!;
// This is a shitty hack to get around the fact that action-prototypes should not in general be sever-exclusive
// prototypes, but some actions may need to use server-exclusive events, and there is no way to specify on a
// per-prototype basis whether the client should ignore it when validating yaml.
[DataField("serverEvent", serverOnly: true)]
public WorldTargetActionEvent? ServerEvent
{
get => Event;
set => Event = value;
}
}
[Prototype("entityTargetAction")]
public sealed class EntityTargetActionPrototype : EntityTargetAction, IPrototype
{
[IdDataFieldAttribute]
public string ID { get; } = default!;
[DataField("serverEvent", serverOnly: true)]
public EntityTargetActionEvent? ServerEvent
{
get => Event;
set => Event = value;
}
}
[Prototype("instantAction")]
public sealed class InstantActionPrototype : InstantAction, IPrototype
{
[IdDataFieldAttribute]
public string ID { get; } = default!;
[DataField("serverEvent", serverOnly: true)]
public InstantActionEvent? ServerEvent
{
get => Event;
set => Event = value;
}
}

View File

@@ -3,10 +3,9 @@ using Robust.Shared.Serialization;
namespace Content.Shared.Actions.ActionTypes;
/// <summary>
/// Instantaneous action with no extra targeting information. Will result in <see cref="PerformActionEvent"/> being raised.
/// Instantaneous action with no extra targeting information. Will result in <see cref="InstantActionEvent"/> being raised.
/// </summary>
[Serializable, NetSerializable]
[Friend(typeof(SharedActionsSystem))]
[Virtual]
public class InstantAction : ActionType
{
@@ -15,7 +14,7 @@ public class InstantAction : ActionType
/// </summary>
[DataField("event")]
[NonSerialized]
public PerformActionEvent? Event;
public InstantActionEvent? Event;
public InstantAction() { }
public InstantAction(InstantAction toClone)

View File

@@ -67,10 +67,9 @@ public abstract class TargetedAction : ActionType
}
/// <summary>
/// Action that targets some entity. Will result in <see cref="PerformEntityTargetActionEvent"/> being raised.
/// Action that targets some entity. Will result in <see cref="EntityTargetActionEvent"/> being raised.
/// </summary>
[Serializable, NetSerializable]
[Friend(typeof(SharedActionsSystem))]
[Virtual]
public class EntityTargetAction : TargetedAction
{
@@ -79,7 +78,7 @@ public class EntityTargetAction : TargetedAction
/// </summary>
[NonSerialized]
[DataField("event")]
public PerformEntityTargetActionEvent? Event;
public EntityTargetActionEvent? Event;
[DataField("whitelist")]
public EntityWhitelist? Whitelist;
@@ -115,10 +114,9 @@ public class EntityTargetAction : TargetedAction
}
/// <summary>
/// Action that targets some map coordinates. Will result in <see cref="PerformWorldTargetActionEvent"/> being raised.
/// Action that targets some map coordinates. Will result in <see cref="WorldTargetActionEvent"/> being raised.
/// </summary>
[Serializable, NetSerializable]
[Friend(typeof(SharedActionsSystem))]
[Virtual]
public class WorldTargetAction : TargetedAction
{
@@ -127,7 +125,7 @@ public class WorldTargetAction : TargetedAction
/// </summary>
[DataField("event")]
[NonSerialized]
public PerformWorldTargetActionEvent? Event;
public WorldTargetActionEvent? Event;
public WorldTargetAction() { }
public WorldTargetAction(WorldTargetAction toClone)