Re-add action prototypes (#7508)
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
@@ -2,8 +2,7 @@ using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Speech.Components;
|
||||
|
||||
@@ -25,19 +24,16 @@ public sealed class VocalComponent : Component
|
||||
[DataField("audioParams")]
|
||||
public AudioParams AudioParams = AudioParams.Default.WithVolume(4f);
|
||||
|
||||
[DataField("wilhelmProbability")]
|
||||
public float WilhelmProbability = 0.01f;
|
||||
|
||||
public const float Variation = 0.125f;
|
||||
|
||||
// Not using the in-build sound support for actions, given that the sound is modified non-prototype specific factors like gender.
|
||||
[DataField("action")]
|
||||
public InstantAction Action = new()
|
||||
{
|
||||
UseDelay = TimeSpan.FromSeconds(10),
|
||||
Icon = new SpriteSpecifier.Texture(new ResourcePath("Interface/Actions/scream.png")),
|
||||
Name = "action-name-scream",
|
||||
Description = "AAAAAAAAAAAAAAAAAAAAAAAAA",
|
||||
Event = new ScreamActionEvent(),
|
||||
CheckCanInteract = false, // system checks a speech related action blocker.
|
||||
};
|
||||
[DataField("actionId", customTypeSerializer:typeof(PrototypeIdSerializer<InstantActionPrototype>))]
|
||||
public string ActionId = "Scream";
|
||||
|
||||
[DataField("action")] // must be a data-field to properly save cooldown when saving game state.
|
||||
public InstantAction? ScreamAction = null;
|
||||
}
|
||||
|
||||
public sealed class ScreamActionEvent : PerformActionEvent { };
|
||||
public sealed class ScreamActionEvent : InstantActionEvent { };
|
||||
|
||||
@@ -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