Refactor actions to be entities with components (#19900)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user