Remove speech & popups from actions (#15747)
This commit is contained in:
@@ -6,7 +6,7 @@ namespace Content.Server.Magic.Events;
|
||||
/// <summary>
|
||||
/// Spell that uses the magic of ECS to add & remove components. Components are first removed, then added.
|
||||
/// </summary>
|
||||
public sealed class ChangeComponentsSpellEvent : EntityTargetActionEvent
|
||||
public sealed class ChangeComponentsSpellEvent : EntityTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
// TODO allow it to set component data-fields?
|
||||
// for now a Hackish way to do that is to remove & add, but that doesn't allow you to selectively set specific data fields.
|
||||
@@ -18,4 +18,7 @@ public sealed class ChangeComponentsSpellEvent : EntityTargetActionEvent
|
||||
[DataField("toRemove")]
|
||||
[AlwaysPushInheritance]
|
||||
public HashSet<string> ToRemove = new();
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
}
|
||||
|
||||
10
Content.Server/Magic/Events/ISpeakSpell.cs
Normal file
10
Content.Server/Magic/Events/ISpeakSpell.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public interface ISpeakSpell // The speak n spell interface
|
||||
{
|
||||
/// <summary>
|
||||
/// Localized string spoken by the caster when casting this spell.
|
||||
/// </summary>
|
||||
public string? Speech { get; }
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
||||
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public sealed class InstantSpawnSpellEvent : InstantActionEvent
|
||||
public sealed class InstantSpawnSpellEvent : InstantActionEvent, ISpeakSpell
|
||||
{
|
||||
/// <summary>
|
||||
/// What entity should be spawned.
|
||||
@@ -15,6 +15,9 @@ public sealed class InstantSpawnSpellEvent : InstantActionEvent
|
||||
[DataField("preventCollide")]
|
||||
public bool PreventCollideWithCaster = true;
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the targeted spawn positons; may lead to multiple entities being spawned.
|
||||
/// </summary>
|
||||
|
||||
@@ -3,7 +3,7 @@ using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public sealed class KnockSpellEvent : InstantActionEvent
|
||||
public sealed class KnockSpellEvent : InstantActionEvent, ISpeakSpell
|
||||
{
|
||||
/// <summary>
|
||||
/// The range this spell opens doors in
|
||||
@@ -20,4 +20,7 @@ public sealed class KnockSpellEvent : InstantActionEvent
|
||||
/// </summary>
|
||||
[DataField("knockVolume")]
|
||||
public float KnockVolume = 5f;
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
||||
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public sealed class ProjectileSpellEvent : WorldTargetActionEvent
|
||||
public sealed class ProjectileSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
/// <summary>
|
||||
/// What entity should be spawned.
|
||||
@@ -17,4 +17,7 @@ public sealed class ProjectileSpellEvent : WorldTargetActionEvent
|
||||
/// Gets the targeted spawn positions; may lead to multiple entities being spawned.
|
||||
/// </summary>
|
||||
[DataField("posData")] public MagicSpawnData Pos = new TargetCasterPos();
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public sealed class SmiteSpellEvent : EntityTargetActionEvent
|
||||
public sealed class SmiteSpellEvent : EntityTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
/// <summary>
|
||||
/// Should this smite delete all parts/mechanisms gibbed except for the brain?
|
||||
/// </summary>
|
||||
[DataField("deleteNonBrainParts")]
|
||||
public bool DeleteNonBrainParts = true;
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public sealed class TeleportSpellEvent : WorldTargetActionEvent
|
||||
public sealed class TeleportSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
[DataField("blinkSound")]
|
||||
public SoundSpecifier BlinkSound = new SoundPathSpecifier("/Audio/Magic/blink.ogg");
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Volume control for the spell.
|
||||
|
||||
@@ -3,7 +3,7 @@ using Content.Shared.Storage;
|
||||
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public sealed class WorldSpawnSpellEvent : WorldTargetActionEvent
|
||||
public sealed class WorldSpawnSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
// TODO:This class needs combining with InstantSpawnSpellEvent
|
||||
|
||||
@@ -25,5 +25,8 @@ public sealed class WorldSpawnSpellEvent : WorldTargetActionEvent
|
||||
/// Lifetime to set for the entities to self delete
|
||||
/// </summary>
|
||||
[DataField("lifetime")] public float? Lifetime;
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Coordinates.Helpers;
|
||||
using Content.Server.Doors.Systems;
|
||||
using Content.Server.Magic.Events;
|
||||
@@ -23,6 +24,7 @@ using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
using Robust.Shared.Serialization.Manager.Exceptions;
|
||||
|
||||
namespace Content.Server.Magic;
|
||||
|
||||
@@ -46,6 +48,7 @@ public sealed class MagicSystem : EntitySystem
|
||||
[Dependency] private readonly PhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly ChatSystem _chat = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -144,6 +147,7 @@ public sealed class MagicSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
Speak(args);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
@@ -152,6 +156,9 @@ public sealed class MagicSystem : EntitySystem
|
||||
if (ev.Handled)
|
||||
return;
|
||||
|
||||
ev.Handled = true;
|
||||
Speak(ev);
|
||||
|
||||
var xform = Transform(ev.Performer);
|
||||
var userVelocity = _physics.GetMapLinearVelocity(ev.Performer);
|
||||
|
||||
@@ -170,6 +177,11 @@ public sealed class MagicSystem : EntitySystem
|
||||
|
||||
private void OnChangeComponentsSpell(ChangeComponentsSpellEvent ev)
|
||||
{
|
||||
if (ev.Handled)
|
||||
return;
|
||||
ev.Handled = true;
|
||||
Speak(ev);
|
||||
|
||||
foreach (var toRemove in ev.ToRemove)
|
||||
{
|
||||
if (_compFact.TryGetRegistration(toRemove, out var registration))
|
||||
@@ -263,6 +275,7 @@ public sealed class MagicSystem : EntitySystem
|
||||
_transformSystem.SetCoordinates(args.Performer, args.Target);
|
||||
transform.AttachToGridOrMap();
|
||||
_audio.PlayPvs(args.BlinkSound, args.Performer, AudioParams.Default.WithVolume(args.BlinkVolume));
|
||||
Speak(args);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
@@ -275,6 +288,9 @@ public sealed class MagicSystem : EntitySystem
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
Speak(args);
|
||||
|
||||
//Get the position of the player
|
||||
var transform = Transform(args.Performer);
|
||||
var coords = transform.Coordinates;
|
||||
@@ -290,8 +306,6 @@ public sealed class MagicSystem : EntitySystem
|
||||
if (TryComp<DoorComponent>(entity, out var doorComp) && doorComp.State is not DoorState.Open)
|
||||
_doorSystem.StartOpening(doorComp.Owner);
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnSmiteSpell(SmiteSpellEvent ev)
|
||||
@@ -299,6 +313,9 @@ public sealed class MagicSystem : EntitySystem
|
||||
if (ev.Handled)
|
||||
return;
|
||||
|
||||
ev.Handled = true;
|
||||
Speak(ev);
|
||||
|
||||
var direction = Transform(ev.Target).MapPosition.Position - Transform(ev.Performer).MapPosition.Position;
|
||||
var impulseVector = direction * 10000;
|
||||
|
||||
@@ -337,7 +354,7 @@ public sealed class MagicSystem : EntitySystem
|
||||
var targetMapCoords = args.Target;
|
||||
|
||||
SpawnSpellHelper(args.Contents, targetMapCoords, args.Lifetime, args.Offset);
|
||||
|
||||
Speak(args);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
@@ -373,4 +390,13 @@ public sealed class MagicSystem : EntitySystem
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void Speak(BaseActionEvent args)
|
||||
{
|
||||
if (args is not ISpeakSpell speak || string.IsNullOrWhiteSpace(speak.Speech))
|
||||
return;
|
||||
|
||||
_chat.TrySendInGameICMessage(args.Performer, Loc.GetString(speak.Speech),
|
||||
InGameICChatType.Speak, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user