Remove speech & popups from actions (#15747)

This commit is contained in:
Leon Friedrich
2023-04-26 16:04:44 +12:00
committed by GitHub
parent beacaed0bb
commit 4e7cea96de
22 changed files with 89 additions and 126 deletions

View File

@@ -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);
}
}