Re-add action prototypes (#7508)
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.CharacterAppearance;
|
||||
using Content.Shared.CharacterAppearance.Components;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Speech;
|
||||
@@ -18,6 +20,7 @@ namespace Content.Server.Speech;
|
||||
public sealed class VocalSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
|
||||
@@ -32,12 +35,20 @@ public sealed class VocalSystem : EntitySystem
|
||||
|
||||
private void OnStartup(EntityUid uid, VocalComponent component, ComponentStartup args)
|
||||
{
|
||||
_actions.AddAction(uid, component.Action, null);
|
||||
if (component.ScreamAction == null
|
||||
&& _proto.TryIndex(component.ActionId, out InstantActionPrototype? act))
|
||||
{
|
||||
component.ScreamAction = new(act);
|
||||
}
|
||||
|
||||
if (component.ScreamAction != null)
|
||||
_actions.AddAction(uid, component.ScreamAction, null);
|
||||
}
|
||||
|
||||
private void OnShutdown(EntityUid uid, VocalComponent component, ComponentShutdown args)
|
||||
{
|
||||
_actions.RemoveAction(uid, component.Action);
|
||||
if (component.ScreamAction != null)
|
||||
_actions.RemoveAction(uid, component.ScreamAction);
|
||||
}
|
||||
|
||||
private void OnActionPerform(EntityUid uid, VocalComponent component, ScreamActionEvent args)
|
||||
@@ -60,7 +71,7 @@ public sealed class VocalSystem : EntitySystem
|
||||
if (!TryComp(uid, out HumanoidAppearanceComponent? humanoid))
|
||||
return false;
|
||||
|
||||
if (_random.Prob(.01f))
|
||||
if (_random.Prob(component.WilhelmProbability))
|
||||
{
|
||||
SoundSystem.Play(Filter.Pvs(uid), component.Wilhelm.GetSound(), uid, component.AudioParams);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user