Refactor actions to be entities with components (#19900)

This commit is contained in:
DrSmugleaf
2023-09-08 18:16:05 -07:00
committed by GitHub
parent e18f731b91
commit c71f97e3a2
210 changed files with 10693 additions and 11714 deletions

View File

@@ -1,8 +1,7 @@
using System.Threading;
using Content.Shared.Actions.ActionTypes;
using Robust.Shared.Utility;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Medical.Components
namespace Content.Server.Medical.Stethoscope.Components
{
/// <summary>
/// Adds an innate verb when equipped to use a stethoscope.
@@ -15,12 +14,9 @@ namespace Content.Server.Medical.Components
[DataField("delay")]
public float Delay = 2.5f;
public EntityTargetAction Action = new()
{
Icon = new SpriteSpecifier.Texture(new ("Clothing/Neck/Misc/stethoscope.rsi/icon.png")),
DisplayName = "stethoscope-verb",
Priority = -1,
Event = new StethoscopeActionEvent(),
};
[DataField("action", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string Action = "ActionStethoscope";
[DataField("actionEntity")] public EntityUid? ActionEntity;
}
}

View File

@@ -1,19 +1,21 @@
using Content.Server.Body.Components;
using Content.Server.Medical.Components;
using Content.Server.Medical.Stethoscope.Components;
using Content.Server.Popups;
using Content.Shared.Actions;
using Content.Shared.Clothing.Components;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
using Content.Shared.FixedPoint;
using Content.Shared.Inventory.Events;
using Content.Shared.Verbs;
using Content.Shared.Medical;
using Content.Shared.Medical.Stethoscope;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.DoAfter;
using Content.Shared.Medical;
using Content.Shared.Verbs;
using Robust.Shared.Utility;
namespace Content.Server.Medical
namespace Content.Server.Medical.Stethoscope
{
public sealed class StethoscopeSystem : EntitySystem
{
@@ -97,7 +99,7 @@ namespace Content.Server.Medical
private void OnGetActions(EntityUid uid, StethoscopeComponent component, GetItemActionsEvent args)
{
args.Actions.Add(component.Action);
args.AddAction(ref component.ActionEntity, component.Action);
}
// construct the doafter and start it
@@ -156,6 +158,4 @@ namespace Content.Server.Medical
return msg;
}
}
public sealed partial class StethoscopeActionEvent : EntityTargetActionEvent {}
}