Add Silicon Law cues to Every method a Silicon can have their laws change (#32887)
* Silicon Law Sound cue refactor - Added CueEntityMind to Silicon Law system to more uniformally send sounds to minds - Switch all previous MindPlaySound to instead call to the new method * Change SiliconLawEui to cue the mind * CR: TryGetComponent and Change the Documentation - Remove GetComponentOrNull for _entityManager.TryGetComponent - Change SiliconLawProviderComponent.LawUploadSound to be more general rather than just referencing lawboards * Update Content.Server/Silicons/Laws/SiliconLawEui.cs * Update Content.Shared/Silicons/Laws/Components/SiliconLawProviderComponent.cs * Silicon-law-cue-refactor - CR: - Roll the cuing into NotifyLawsChanged via an optional variable for the cue - Modify "SetLaws" to take in an optional soundProvider for the cue - modify Emagged, Ion, Eui and SetLaws to instead send the sound cue via NotifyLawsChanged --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.EUI;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Eui;
|
||||
@@ -52,8 +52,8 @@ public sealed class SiliconLawEui : BaseEui
|
||||
return;
|
||||
|
||||
var player = _entityManager.GetEntity(message.Target);
|
||||
|
||||
_siliconLawSystem.SetLaws(message.Laws, player);
|
||||
if (_entityManager.TryGetComponent<SiliconLawProviderComponent>(player, out var playerProviderComp))
|
||||
_siliconLawSystem.SetLaws(message.Laws, player, playerProviderComp.LawUploadSound);
|
||||
}
|
||||
|
||||
private bool IsAllowed()
|
||||
|
||||
@@ -21,6 +21,8 @@ using Robust.Shared.Containers;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Toolshed;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Silicons.Laws;
|
||||
|
||||
@@ -113,7 +115,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
component.Lawset = args.Lawset;
|
||||
|
||||
// gotta tell player to check their laws
|
||||
NotifyLawsChanged(uid);
|
||||
NotifyLawsChanged(uid, component.LawUploadSound);
|
||||
|
||||
// new laws may allow antagonist behaviour so make it clear for admins
|
||||
if (TryComp<EmagSiliconLawComponent>(uid, out var emag))
|
||||
@@ -149,14 +151,11 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
return;
|
||||
|
||||
base.OnGotEmagged(uid, component, ref args);
|
||||
NotifyLawsChanged(uid);
|
||||
NotifyLawsChanged(uid, component.EmaggedSound);
|
||||
EnsureEmaggedRole(uid, component);
|
||||
|
||||
_stunSystem.TryParalyze(uid, component.StunTime, true);
|
||||
|
||||
if (!_mind.TryGetMind(uid, out var mindId, out _))
|
||||
return;
|
||||
_roles.MindPlaySound(mindId, component.EmaggedSound);
|
||||
}
|
||||
|
||||
private void OnEmagMindAdded(EntityUid uid, EmagSiliconLawComponent component, MindAddedMessage args)
|
||||
@@ -237,7 +236,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
return ev.Laws;
|
||||
}
|
||||
|
||||
public void NotifyLawsChanged(EntityUid uid)
|
||||
public void NotifyLawsChanged(EntityUid uid, SoundSpecifier? cue = null)
|
||||
{
|
||||
if (!TryComp<ActorComponent>(uid, out var actor))
|
||||
return;
|
||||
@@ -245,6 +244,9 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
var msg = Loc.GetString("laws-update-notify");
|
||||
var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", msg));
|
||||
_chatManager.ChatMessageToOne(ChatChannel.Server, msg, wrappedMessage, default, false, actor.PlayerSession.Channel, colorOverride: Color.Red);
|
||||
|
||||
if (cue != null && _mind.TryGetMind(uid, out var mindId, out _))
|
||||
_roles.MindPlaySound(mindId, cue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -269,7 +271,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
/// <summary>
|
||||
/// Set the laws of a silicon entity while notifying the player.
|
||||
/// </summary>
|
||||
public void SetLaws(List<SiliconLaw> newLaws, EntityUid target)
|
||||
public void SetLaws(List<SiliconLaw> newLaws, EntityUid target, SoundSpecifier? cue = null)
|
||||
{
|
||||
if (!TryComp<SiliconLawProviderComponent>(target, out var component))
|
||||
return;
|
||||
@@ -278,7 +280,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
component.Lawset = new SiliconLawset();
|
||||
|
||||
component.Lawset.Laws = newLaws;
|
||||
NotifyLawsChanged(target);
|
||||
NotifyLawsChanged(target, cue);
|
||||
}
|
||||
|
||||
protected override void OnUpdaterInsert(Entity<SiliconLawUpdaterComponent> ent, ref EntInsertedIntoContainerMessage args)
|
||||
@@ -292,9 +294,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
|
||||
while (query.MoveNext(out var update))
|
||||
{
|
||||
SetLaws(lawset, update);
|
||||
if (provider.LawUploadSound != null && _mind.TryGetMind(update, out var mindId, out _))
|
||||
_roles.MindPlaySound(mindId, provider.LawUploadSound);
|
||||
SetLaws(lawset, update, provider.LawUploadSound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public sealed partial class SiliconLawProviderComponent : Component
|
||||
|
||||
/// <summary>
|
||||
/// The sound that plays for the Silicon player
|
||||
/// when the particular lawboard has been inserted.
|
||||
/// when the law change is processed for the provider.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public SoundSpecifier? LawUploadSound = new SoundPathSpecifier("/Audio/Misc/cryo_warning.ogg");
|
||||
|
||||
Reference in New Issue
Block a user