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;
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))
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)
return ev.Laws;
}
- public void NotifyLawsChanged(EntityUid uid)
+ public void NotifyLawsChanged(EntityUid uid, SoundSpecifier? cue = null)
{
if (!TryComp<ActorComponent>(uid, out var actor))
return;
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>
/// <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;
component.Lawset = new SiliconLawset();
component.Lawset.Laws = newLaws;
- NotifyLawsChanged(target);
+ NotifyLawsChanged(target, cue);
}
protected override void OnUpdaterInsert(Entity<SiliconLawUpdaterComponent> ent, ref EntInsertedIntoContainerMessage args)
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);
}
}
}