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,10 +1,9 @@
using Content.Server.Actions;
using Content.Server.Chat.Systems;
using Content.Server.Humanoid;
using Content.Server.Speech.Components;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Humanoid;
using Content.Shared.Speech;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
@@ -32,21 +31,16 @@ public sealed class VocalSystem : EntitySystem
private void OnMapInit(EntityUid uid, VocalComponent component, MapInitEvent args)
{
// try to add scream action when vocal comp added
if (_proto.TryIndex(component.ScreamActionId, out InstantActionPrototype? proto))
{
component.ScreamAction = new InstantAction(proto);
_actions.AddAction(uid, component.ScreamAction, null);
}
_actions.AddAction(uid, ref component.ScreamActionEntity, component.ScreamAction);
LoadSounds(uid, component);
}
private void OnShutdown(EntityUid uid, VocalComponent component, ComponentShutdown args)
{
// remove scream action when component removed
if (component.ScreamAction != null)
if (component.ScreamActionEntity != null)
{
_actions.RemoveAction(uid, component.ScreamAction);
_actions.RemoveAction(uid, component.ScreamActionEntity);
}
}
@@ -76,7 +70,7 @@ public sealed class VocalSystem : EntitySystem
if (args.Handled)
return;
_chat.TryEmoteWithChat(uid, component.ScreamActionId);
_chat.TryEmoteWithChat(uid, component.ScreamId);
args.Handled = true;
}