Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using System.Globalization;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Radio.EntitySystems;
|
||||
using Content.Shared._White.Announcement;
|
||||
using Content.Shared.Radio;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server._White.Announcement;
|
||||
|
||||
public sealed class ArrivalNotificationSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ChatSystem _chatSystem = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly RadioSystem _radioSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeAllEvent<PlayerSpawnCompleteEvent>(OnPlayerSpawn);
|
||||
}
|
||||
|
||||
private void OnPlayerSpawn(PlayerSpawnCompleteEvent args)
|
||||
{
|
||||
if (args.JobId == null)
|
||||
return;
|
||||
|
||||
if (!_prototypeManager.TryIndex<JobPrototype>(args.JobId, out var jobPrototype))
|
||||
return;
|
||||
|
||||
if (jobPrototype.AnnouncementPrototype == null)
|
||||
return;
|
||||
|
||||
if (!_prototypeManager.TryIndex<ArrivalNotificationPrototype>(jobPrototype.AnnouncementPrototype, out var notification))
|
||||
return;
|
||||
|
||||
var message = GetMessage(args.Mob,
|
||||
jobPrototype,
|
||||
notification.UseGlobalAnnouncement ? notification.GlobalMessage : notification.Message);
|
||||
|
||||
var senderName = Loc.GetString("head-arrived-sender");
|
||||
var source = args.Station;
|
||||
|
||||
if (notification.UseGlobalAnnouncement)
|
||||
_chatSystem.DispatchGlobalAnnouncement(message, senderName, colorOverride: Color.Gold);
|
||||
|
||||
message = GetMessage(args.Mob, jobPrototype, notification.Message); // Changing message type for radio notification
|
||||
|
||||
foreach (var channel in notification.RadioChannelsPrototypes)
|
||||
{
|
||||
if (!_prototypeManager.TryIndex<RadioChannelPrototype>(channel, out _))
|
||||
continue;
|
||||
|
||||
_radioSystem.SendRadioMessage(source, message, channel, args.Mob);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private string GetMessage(EntityUid mob, JobPrototype jobPrototype, string type)
|
||||
{
|
||||
var message = Loc.GetString(type,
|
||||
("character", MetaData(mob).EntityName),
|
||||
("job", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Loc.GetString(jobPrototype.Name))));
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,16 @@
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server._White.Other.DeathGasps;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class DeathGaspsComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public SoundSpecifier DeathSounds = new SoundCollectionSpecifier("deathSounds");
|
||||
|
||||
[DataField]
|
||||
public SoundSpecifier HeartSounds = new SoundCollectionSpecifier("heartSounds");
|
||||
|
||||
[DataField]
|
||||
public bool CanOtherHearDeathSound;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@ public sealed class OnDeath : EntitySystem
|
||||
}
|
||||
|
||||
private readonly Dictionary<EntityUid, EntityUid> _playingStreams = new();
|
||||
private static readonly SoundSpecifier DeathSounds = new SoundCollectionSpecifier("deathSounds");
|
||||
private static readonly SoundSpecifier HeartSounds = new SoundCollectionSpecifier("heartSounds");
|
||||
|
||||
|
||||
private void HandleDeathEvent(EntityUid uid, DeathGaspsComponent component, MobStateChangedEvent args)
|
||||
{
|
||||
@@ -31,23 +30,23 @@ public sealed class OnDeath : EntitySystem
|
||||
StopPlayingStream(uid);
|
||||
break;
|
||||
case MobState.Critical:
|
||||
PlayPlayingStream(uid);
|
||||
PlayPlayingStream(uid, component);
|
||||
break;
|
||||
case MobState.Dead:
|
||||
StopPlayingStream(uid);
|
||||
PlayDeathSound(uid);
|
||||
PlayDeathSound(uid, component);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayPlayingStream(EntityUid uid)
|
||||
private void PlayPlayingStream(EntityUid uid, DeathGaspsComponent component)
|
||||
{
|
||||
if (_playingStreams.TryGetValue(uid, out var currentStream))
|
||||
{
|
||||
_audio.Stop(currentStream);
|
||||
}
|
||||
|
||||
var newStream = _audio.PlayEntity(HeartSounds, uid, uid, AudioParams.Default.WithLoop(true));
|
||||
var newStream = _audio.PlayEntity(component.HeartSounds, uid, uid, AudioParams.Default.WithLoop(true));
|
||||
|
||||
if (newStream.HasValue)
|
||||
{
|
||||
@@ -64,9 +63,12 @@ public sealed class OnDeath : EntitySystem
|
||||
_playingStreams.Remove(uid);
|
||||
}
|
||||
|
||||
private void PlayDeathSound(EntityUid uid)
|
||||
private void PlayDeathSound(EntityUid uid, DeathGaspsComponent component)
|
||||
{
|
||||
_audio.PlayEntity(DeathSounds, uid, uid, AudioParams.Default);
|
||||
if (component.CanOtherHearDeathSound)
|
||||
_audio.PlayPvs(component.DeathSounds, uid, AudioParams.Default);
|
||||
else
|
||||
_audio.PlayEntity(component.DeathSounds, uid, uid, AudioParams.Default);
|
||||
}
|
||||
|
||||
private void OnDetach(EntityUid uid, DeathGaspsComponent component, PlayerDetachedEvent args)
|
||||
|
||||
@@ -63,7 +63,9 @@ public sealed partial class TTSSystem : EntitySystem
|
||||
|
||||
Filter filter;
|
||||
if (ev.Global)
|
||||
{
|
||||
filter = Filter.Broadcast();
|
||||
}
|
||||
else
|
||||
{
|
||||
var station = _stationSystem.GetOwningStation(ev.Source);
|
||||
@@ -132,11 +134,7 @@ public sealed partial class TTSSystem : EntitySystem
|
||||
|
||||
private async void OnEntitySpoke(EntityUid uid, SharedTTSComponent component, EntitySpokeEvent args)
|
||||
{
|
||||
if (!_isEnabled ||
|
||||
args.Message.Length > MaxMessageChars)
|
||||
return;
|
||||
|
||||
if (string.IsNullOrEmpty(_apiUrl))
|
||||
if (!_isEnabled || string.IsNullOrEmpty(_apiUrl) || args.Message.Length > MaxMessageChars)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -154,6 +152,7 @@ public sealed partial class TTSSystem : EntitySystem
|
||||
var soundData = await GenerateTTS(uid, message, protoVoice.Speaker);
|
||||
if (soundData is null)
|
||||
return;
|
||||
|
||||
var ttsEvent = new PlayTTSEvent(GetNetEntity(uid), soundData, false);
|
||||
|
||||
// Say
|
||||
@@ -182,7 +181,6 @@ public sealed partial class TTSSystem : EntitySystem
|
||||
var sourcePos = _xforms.GetWorldPosition(xformQuery.GetComponent(uid), xformQuery);
|
||||
var receptions = Filter.Pvs(uid).Recipients;
|
||||
|
||||
|
||||
foreach (var session in receptions)
|
||||
{
|
||||
if (!session.AttachedEntity.HasValue)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Shared._White.Wizard;
|
||||
using Content.Shared._White.Wizard.Charging;
|
||||
using Content.Shared.Follower;
|
||||
using Content.Shared.Mobs;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Player;
|
||||
@@ -25,10 +26,13 @@ public sealed class ChargingSystem : SharedChargingSystem
|
||||
SubscribeNetworkEvent<RequestSpellChargingAudio>(OnCharging);
|
||||
SubscribeNetworkEvent<RequestSpellChargedAudio>(OnCharged);
|
||||
SubscribeNetworkEvent<RequestAudioSpellStop>(OnStop);
|
||||
|
||||
SubscribeLocalEvent<PlayerDetachedEvent>(OnDetach);
|
||||
SubscribeLocalEvent<MobStateChangedEvent>(OnStateChanged);
|
||||
|
||||
SubscribeNetworkEvent<AddWizardChargeEvent>(Add);
|
||||
SubscribeNetworkEvent<RemoveWizardChargeEvent>(Remove);
|
||||
|
||||
}
|
||||
|
||||
#region Audio
|
||||
@@ -103,40 +107,29 @@ public sealed class ChargingSystem : SharedChargingSystem
|
||||
if (user == null)
|
||||
return;
|
||||
|
||||
if (_chargingLoops.TryGetValue(user.Value, out var currentStream))
|
||||
{
|
||||
_audio.Stop(currentStream);
|
||||
_chargingLoops.Remove(user.Value);
|
||||
}
|
||||
|
||||
if (_chargedLoop.TryGetValue(user.Value, out var chargedLoop))
|
||||
{
|
||||
_audio.Stop(chargedLoop);
|
||||
_chargedLoop.Remove(user.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDetach(PlayerDetachedEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
var user = msg.Entity;
|
||||
|
||||
if (_chargingLoops.TryGetValue(user, out var currentStream))
|
||||
{
|
||||
_audio.Stop(currentStream);
|
||||
_chargingLoops.Remove(user);
|
||||
}
|
||||
|
||||
if (_chargedLoop.TryGetValue(user, out var chargedLoop))
|
||||
{
|
||||
_audio.Stop(chargedLoop);
|
||||
_chargedLoop.Remove(user);
|
||||
}
|
||||
StopAllSounds(user.Value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Charges
|
||||
|
||||
private void OnDetach(PlayerDetachedEvent msg)
|
||||
{
|
||||
var user = msg.Entity;
|
||||
|
||||
RemoveAllCharges(user);
|
||||
StopAllSounds(user);
|
||||
}
|
||||
|
||||
private void OnStateChanged(MobStateChangedEvent ev)
|
||||
{
|
||||
var user = ev.Target;
|
||||
|
||||
RemoveAllCharges(user);
|
||||
StopAllSounds(user);
|
||||
}
|
||||
|
||||
private void Add(AddWizardChargeEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
if (args.SenderSession.AttachedEntity != null)
|
||||
@@ -153,6 +146,21 @@ public sealed class ChargingSystem : SharedChargingSystem
|
||||
|
||||
#region Helpers
|
||||
|
||||
public void StopAllSounds(EntityUid uid)
|
||||
{
|
||||
if (_chargingLoops.TryGetValue(uid, out var currentStream))
|
||||
{
|
||||
_audio.Stop(currentStream);
|
||||
_chargingLoops.Remove(uid);
|
||||
}
|
||||
|
||||
if (_chargedLoop.TryGetValue(uid, out var chargedLoop))
|
||||
{
|
||||
_audio.Stop(chargedLoop);
|
||||
_chargedLoop.Remove(uid);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddCharge(EntityUid uid, string msgChargeProto)
|
||||
{
|
||||
var itemEnt = Spawn(msgChargeProto, Transform(uid).Coordinates);
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Server._White.Cult;
|
||||
using Content.Server._White.IncorporealSystem;
|
||||
using Content.Server._White.Wizard.Charging;
|
||||
using Content.Server._White.Wizard.Magic.Amaterasu;
|
||||
using Content.Server._White.Wizard.Magic.Other;
|
||||
using Content.Server._White.Wizard.Magic.TeslaProjectile;
|
||||
@@ -80,6 +81,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
[Dependency] private readonly EuiManager _euiManager = default!;
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
|
||||
[Dependency] private readonly ChargingSystem _charging = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -125,7 +127,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
msg.Handled = true;
|
||||
Cast(msg);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -143,8 +145,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
var comp = EnsureComp<PreventCollideComponent>(ent);
|
||||
comp.Uid = msg.Performer;
|
||||
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -187,8 +188,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
_standing.TryLieDown(uid);
|
||||
_standing.TryLieDown(target);
|
||||
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
|
||||
SwapComponent<WizardComponent>(uid, target);
|
||||
SwapComponent<RevolutionaryComponent>(uid, target);
|
||||
@@ -213,8 +213,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
_euiManager.OpenEui(eui, actor.PlayerSession);
|
||||
eui.StateDirty();
|
||||
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg, false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -264,8 +263,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
_handsSystem.TryForcePickupAnyHand(msg.Performer, recallComponent.Item.Value);
|
||||
_audio.PlayPvs(recallComponent.RecallSound, msg.Performer);
|
||||
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -293,8 +291,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
|
||||
Spawn("AdminInstantEffectSmoke3", Transform(msg.Target).Coordinates);
|
||||
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -317,8 +314,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
|
||||
Spawn("AdminInstantEffectSmoke3", Transform(msg.Target).Coordinates);
|
||||
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -340,8 +336,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
|
||||
Spawn("AdminInstantEffectSmoke3", Transform(msg.Target).Coordinates);
|
||||
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -357,8 +352,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
|
||||
_empSystem.EmpPulse(coords, 15, 1000000, 60f);
|
||||
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -381,8 +375,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
_statusEffectsSystem.TryAddStatusEffect<IncorporealComponent>(msg.Performer, "Incorporeal",
|
||||
TimeSpan.FromSeconds(10), false);
|
||||
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -434,8 +427,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
Spawn("AdminInstantEffectSmoke3", oldCoords);
|
||||
Spawn("AdminInstantEffectSmoke3", coords);
|
||||
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -460,9 +452,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
break;
|
||||
}
|
||||
|
||||
SetCooldown(msg.Action, msg.ActionUseType);
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
}
|
||||
|
||||
private void ForcewallSpellDefault(ForceWallSpellEvent msg)
|
||||
@@ -533,9 +523,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
SetCooldown(msg.Action, msg.ActionUseType);
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
}
|
||||
|
||||
private void CardsSpellDefault(CardsSpellEvent msg)
|
||||
@@ -638,9 +626,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
SetCooldown(msg.Action, msg.ActionUseType);
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
}
|
||||
|
||||
private void FireballSpellDefault(FireballSpellEvent msg)
|
||||
@@ -725,9 +711,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
SetCooldown(msg.Action, msg.ActionUseType);
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
}
|
||||
|
||||
private bool ForceSpellAlt(ForceSpellEvent msg)
|
||||
@@ -782,9 +766,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
SetCooldown(msg.Action, msg.ActionUseType);
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
Cast(msg);
|
||||
}
|
||||
|
||||
private bool ArcSpellDefault(ArcSpellEvent msg)
|
||||
@@ -844,6 +826,17 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
RaiseLocalEvent(uid, new EnergyDomeClothesTurnOffEvent());
|
||||
}
|
||||
|
||||
public void Cast(BaseActionEvent msg, bool removeAllCharges = true)
|
||||
{
|
||||
SetCooldown(msg.Action, msg.ActionUseType);
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
if (!removeAllCharges)
|
||||
return;
|
||||
_charging.RemoveAllCharges(msg.Performer);
|
||||
_charging.StopAllSounds(msg.Performer);
|
||||
}
|
||||
|
||||
public bool CanCast(BaseActionEvent msg)
|
||||
{
|
||||
return !msg.Handled && CheckRequirements(msg.Action, msg.Performer) &&
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.EUI;
|
||||
using Content.Server._White.Wizard.Charging;
|
||||
using Content.Server.EUI;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared._White.Wizard.Teleport;
|
||||
using Content.Shared.Eui;
|
||||
@@ -15,6 +16,7 @@ public sealed class WizardTeleportSpellEui : BaseEui
|
||||
private readonly TeleportLocationSystem _teleportLocation;
|
||||
private readonly PullingSystem _pulling;
|
||||
private readonly PopupSystem _popupSystem;
|
||||
private readonly ChargingSystem _charging;
|
||||
|
||||
private readonly EntityUid _performer;
|
||||
|
||||
@@ -28,6 +30,7 @@ public sealed class WizardTeleportSpellEui : BaseEui
|
||||
_pulling = _entityManager.System<PullingSystem>();
|
||||
_teleportLocation = _entityManager.System<TeleportLocationSystem>();
|
||||
_popupSystem = _entityManager.System<PopupSystem>();
|
||||
_charging = _entityManager.System<ChargingSystem>();
|
||||
|
||||
_performer = performer;
|
||||
|
||||
@@ -107,6 +110,9 @@ public sealed class WizardTeleportSpellEui : BaseEui
|
||||
_entityManager.SpawnEntity("AdminInstantEffectSmoke10", oldCoords);
|
||||
_entityManager.SpawnEntity("AdminInstantEffectSmoke10", coords);
|
||||
|
||||
_charging.RemoveAllCharges(_performer);
|
||||
_charging.StopAllSounds(_performer);
|
||||
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user