Re-add action prototypes (#7508)
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
@@ -11,6 +11,7 @@ using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using System.Linq;
|
||||
|
||||
@@ -99,7 +100,7 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
#region Execution
|
||||
/// <summary>
|
||||
/// When receiving a request to perform an action, this validates whether the action is allowed. If it is, it
|
||||
/// will raise the relevant <see cref="PerformActionEvent"/>
|
||||
/// will raise the relevant <see cref="InstantActionEvent"/>
|
||||
/// </summary>
|
||||
private void OnActionRequest(RequestPerformActionEvent ev, EntitySessionEventArgs args)
|
||||
{
|
||||
@@ -124,7 +125,7 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
if (act.Cooldown.HasValue && act.Cooldown.Value.End > curTime)
|
||||
return;
|
||||
|
||||
PerformActionEvent? performEvent = null;
|
||||
BaseActionEvent? performEvent = null;
|
||||
|
||||
// Validate request by checking action blockers and the like:
|
||||
var name = Loc.GetString(act.Name);
|
||||
@@ -273,7 +274,7 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
return _interactionSystem.InRangeUnobstructed(user, coords, range: action.Range);
|
||||
}
|
||||
|
||||
protected void PerformAction(ActionsComponent component, ActionType action, PerformActionEvent? actionEvent, TimeSpan curTime)
|
||||
protected void PerformAction(ActionsComponent component, ActionType action, BaseActionEvent? actionEvent, TimeSpan curTime)
|
||||
{
|
||||
var handled = false;
|
||||
|
||||
@@ -356,6 +357,13 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
/// <param name="provider">The entity that enables these actions (e.g., flashlight). May be null (innate actions).</param>
|
||||
public virtual void AddAction(EntityUid uid, ActionType action, EntityUid? provider, ActionsComponent? comp = null, bool dirty = true)
|
||||
{
|
||||
// Because action classes have state data, e.g. cooldowns and uses-remaining, people should not be adding prototypes directly
|
||||
if (action is IPrototype)
|
||||
{
|
||||
Logger.Error("Attempted to directly add a prototype action. You need to clone a prototype in order to use it.");
|
||||
return;
|
||||
}
|
||||
|
||||
comp ??= EnsureComp<ActionsComponent>(uid);
|
||||
action.Provider = provider;
|
||||
action.AttachedEntity = comp.Owner;
|
||||
@@ -426,7 +434,7 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
#region EquipHandlers
|
||||
private void OnDidEquip(EntityUid uid, ActionsComponent component, DidEquipEvent args)
|
||||
{
|
||||
var ev = new GetActionsEvent();
|
||||
var ev = new GetItemActionsEvent(args.SlotFlags);
|
||||
RaiseLocalEvent(args.Equipment, ev, false);
|
||||
|
||||
if (ev.Actions.Count == 0)
|
||||
@@ -437,7 +445,7 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
|
||||
private void OnHandEquipped(EntityUid uid, ActionsComponent component, DidEquipHandEvent args)
|
||||
{
|
||||
var ev = new GetActionsEvent();
|
||||
var ev = new GetItemActionsEvent();
|
||||
RaiseLocalEvent(args.Equipped, ev, false);
|
||||
|
||||
if (ev.Actions.Count == 0)
|
||||
|
||||
Reference in New Issue
Block a user