Skip to content

Commit

Permalink
Block telepathy on death (#2419)
Browse files Browse the repository at this point in the history
* Block telepathy on death

* Return BOM
  • Loading branch information
stalengd authored Dec 28, 2024
1 parent b928cc5 commit 1d6f31c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Content.Server/SS220/Telepathy/TelepathySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ private void OnTelepathyAnnouncementSend(Entity<TelepathyComponent> ent, ref Tel

private void OnTelepathySend(Entity<TelepathyComponent> ent, ref TelepathySendEvent args)
{
if (ent.Comp.TelepathyChannelPrototype is { } telepathyChannel)
SendMessageToEveryoneWithRightChannel(telepathyChannel, args.Message, ent);
if (ent.Comp.TelepathyChannelPrototype is not { } telepathyChannel)
return;

if (!CanSendTelepathy(ent))
return;

SendMessageToEveryoneWithRightChannel(telepathyChannel, args.Message, ent);
}

/// <summary>
Expand Down Expand Up @@ -166,4 +171,11 @@ private string GetSenderName(EntityUid? senderUid)
var name = Name(nameEv.Sender);
return name;
}

private bool CanSendTelepathy(EntityUid sender)
{
var args = new TelepathySendAttemptEvent(sender, false);
RaiseLocalEvent(sender, ref args);
return !args.Cancelled;
}
}
10 changes: 10 additions & 0 deletions Content.Shared/Administration/SharedAdminFrozenSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Content.Shared.Movement.Pulling.Events;
using Content.Shared.Movement.Pulling.Systems;
using Content.Shared.Speech;
using Content.Shared.SS220.Telepathy;
using Content.Shared.Throwing;

namespace Content.Shared.Administration;
Expand All @@ -33,6 +34,7 @@ public override void Initialize()
SubscribeLocalEvent<AdminFrozenComponent, ChangeDirectionAttemptEvent>(OnAttempt);
SubscribeLocalEvent<AdminFrozenComponent, EmoteAttemptEvent>(OnEmoteAttempt);
SubscribeLocalEvent<AdminFrozenComponent, SpeakAttemptEvent>(OnSpeakAttempt);
SubscribeLocalEvent<AdminFrozenComponent, TelepathySendAttemptEvent>(OnTelepathyAttempt); // SS220 Block telepathy on death
}

private void OnInteractAttempt(Entity<AdminFrozenComponent> ent, ref InteractionAttemptEvent args)
Expand Down Expand Up @@ -86,4 +88,12 @@ private void OnEmoteAttempt(EntityUid uid, AdminFrozenComponent component, Emote
if (component.Muted)
args.Cancel();
}

// SS220 Block telepathy on death begin
private void OnTelepathyAttempt(Entity<AdminFrozenComponent> entity, ref TelepathySendAttemptEvent args)
{
if (entity.Comp.Muted)
args.Cancelled = true;
}
// SS220 Block telepathy on death end
}
9 changes: 9 additions & 0 deletions Content.Shared/Bed/Sleep/SleepingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Content.Shared.Emoting;
using Content.Shared.SS220.Telepathy;

namespace Content.Shared.Bed.Sleep;

Expand Down Expand Up @@ -64,6 +65,7 @@ public override void Initialize()
SubscribeLocalEvent<ForcedSleepingComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<SleepingComponent, UnbuckleAttemptEvent>(OnUnbuckleAttempt);
SubscribeLocalEvent<SleepingComponent, EmoteAttemptEvent>(OnEmoteAttempt);
SubscribeLocalEvent<SleepingComponent, TelepathySendAttemptEvent>(OnTelepathyAttempt); // SS220 Block telepathy on death
}

private void OnUnbuckleAttempt(Entity<SleepingComponent> ent, ref UnbuckleAttemptEvent args)
Expand Down Expand Up @@ -318,6 +320,13 @@ public void OnEmoteAttempt(Entity<SleepingComponent> ent, ref EmoteAttemptEvent
{
args.Cancel();
}

// SS220 Block telepathy on death begin
public void OnTelepathyAttempt(Entity<SleepingComponent> ent, ref TelepathySendAttemptEvent args)
{
args.Cancelled = true;
}
// SS220 Block telepathy on death end
}


Expand Down
15 changes: 15 additions & 0 deletions Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Content.Shared.Pointing;
using Content.Shared.Pulling.Events;
using Content.Shared.Speech;
using Content.Shared.SS220.Telepathy;
using Content.Shared.Standing;
using Content.Shared.Strip.Components;
using Content.Shared.Throwing;
Expand All @@ -32,6 +33,7 @@ private void SubscribeEvents()
SubscribeLocalEvent<MobStateComponent, ConsciousAttemptEvent>(CheckConcious);
SubscribeLocalEvent<MobStateComponent, ThrowAttemptEvent>(CheckAct);
SubscribeLocalEvent<MobStateComponent, SpeakAttemptEvent>(OnSpeakAttempt);
SubscribeLocalEvent<MobStateComponent, TelepathySendAttemptEvent>(OnTelepathyAttempt); // SS220 Block telepathy on death
SubscribeLocalEvent<MobStateComponent, IsEquippingAttemptEvent>(OnEquipAttempt);
SubscribeLocalEvent<MobStateComponent, EmoteAttemptEvent>(CheckAct);
SubscribeLocalEvent<MobStateComponent, IsUnequippingAttemptEvent>(OnUnequipAttempt);
Expand Down Expand Up @@ -148,6 +150,19 @@ private void OnSpeakAttempt(EntityUid uid, MobStateComponent component, SpeakAtt
CheckAct(uid, component, args);
}

// SS220 Block telepathy on death begin
private void OnTelepathyAttempt(Entity<MobStateComponent> entity, ref TelepathySendAttemptEvent args)
{
switch (entity.Comp.CurrentState)
{
case MobState.Dead:
case MobState.Critical:
args.Cancelled = true;
break;
}
}
// SS220 Block telepathy on death end

private void CheckAct(EntityUid target, MobStateComponent component, CancellableEntityEventArgs args)
{
switch (component.CurrentState)
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/SS220/Telepathy/TelepathyComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ public TelepathyAnnouncementSendEvent(string message, string telepathyChannel)
TelepathyChannel = telepathyChannel;
}
}

[ByRefEvent]
public record struct TelepathySendAttemptEvent(EntityUid Sender, bool Cancelled);

0 comments on commit 1d6f31c

Please sign in to comment.