Skip to content

Commit

Permalink
Replace IClickAlert with events (#30728)
Browse files Browse the repository at this point in the history
* Replace IAlertClick with events

* whoop

* eek!
  • Loading branch information
EmoGarbage404 authored and sleepyyapril committed Nov 15, 2024
1 parent df5dbf2 commit 3b0d51d
Show file tree
Hide file tree
Showing 33 changed files with 188 additions and 281 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Alerts/ClientAlertsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ private void OnPlayerDetached(EntityUid uid, AlertsComponent component, LocalPla

public void AlertClicked(ProtoId<AlertPrototype> alertType)
{
RaiseNetworkEvent(new ClickAlertEvent(alertType));
RaisePredictiveEvent(new ClickAlertEvent(alertType));
}
}
20 changes: 20 additions & 0 deletions Content.Server/Abilities/Mime/MimePowersSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Server.Popups;
using Content.Shared.Abilities.Mime;
using Content.Shared.Actions;
using Content.Shared.Actions.Events;
using Content.Shared.Alert;
Expand Down Expand Up @@ -31,6 +32,9 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<MimePowersComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<MimePowersComponent, InvisibleWallActionEvent>(OnInvisibleWall);

SubscribeLocalEvent<MimePowersComponent, BreakVowAlertEvent>(OnBreakVowAlert);
SubscribeLocalEvent<MimePowersComponent, RetakeVowAlertEvent>(OnRetakeVowAlert);
}

public override void Update(float frameTime)
Expand Down Expand Up @@ -104,6 +108,22 @@ private void OnInvisibleWall(EntityUid uid, MimePowersComponent component, Invis
args.Handled = true;
}

private void OnBreakVowAlert(Entity<MimePowersComponent> ent, ref BreakVowAlertEvent args)
{
if (args.Handled)
return;
BreakVow(ent, ent);
args.Handled = true;
}

private void OnRetakeVowAlert(Entity<MimePowersComponent> ent, ref RetakeVowAlertEvent args)
{
if (args.Handled)
return;
RetakeVow(ent, ent);
args.Handled = true;
}

/// <summary>
/// Break this mime's vow to not speak.
/// </summary>
Expand Down
22 changes: 0 additions & 22 deletions Content.Server/Alert/Click/BreakVow.cs

This file was deleted.

21 changes: 0 additions & 21 deletions Content.Server/Alert/Click/RemoveCuffs.cs

This file was deleted.

28 changes: 0 additions & 28 deletions Content.Server/Alert/Click/RemoveEnsnare.cs

This file was deleted.

25 changes: 0 additions & 25 deletions Content.Server/Alert/Click/ResistFire.cs

This file was deleted.

22 changes: 0 additions & 22 deletions Content.Server/Alert/Click/RetakeVow.cs

This file was deleted.

29 changes: 0 additions & 29 deletions Content.Server/Alert/Click/StopBeingPulled.cs

This file was deleted.

26 changes: 0 additions & 26 deletions Content.Server/Alert/Click/StopPiloting.cs

This file was deleted.

27 changes: 0 additions & 27 deletions Content.Server/Alert/Click/StopPulling.cs

This file was deleted.

19 changes: 0 additions & 19 deletions Content.Server/Alert/Click/ToggleInternals.cs

This file was deleted.

19 changes: 0 additions & 19 deletions Content.Server/Alert/Click/Unbuckle.cs

This file was deleted.

10 changes: 10 additions & 0 deletions Content.Server/Atmos/EntitySystems/FlammableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public override void Initialize()
SubscribeLocalEvent<FlammableComponent, IsHotEvent>(OnIsHot);
SubscribeLocalEvent<FlammableComponent, TileFireEvent>(OnTileFire);
SubscribeLocalEvent<FlammableComponent, RejuvenateEvent>(OnRejuvenate);
SubscribeLocalEvent<FlammableComponent, ResistFireAlertEvent>(OnResistFireAlert);

SubscribeLocalEvent<IgniteOnCollideComponent, StartCollideEvent>(IgniteOnCollide);
SubscribeLocalEvent<IgniteOnCollideComponent, LandEvent>(OnIgniteLand);
Expand Down Expand Up @@ -268,6 +269,15 @@ private void OnRejuvenate(EntityUid uid, FlammableComponent component, Rejuvenat
Extinguish(uid, component);
}

private void OnResistFireAlert(Entity<FlammableComponent> ent, ref ResistFireAlertEvent args)
{
if (args.Handled)
return;

Resist(ent, ent);
args.Handled = true;
}

public void UpdateAppearance(EntityUid uid, FlammableComponent? flammable = null, AppearanceComponent? appearance = null)
{
if (!Resolve(uid, ref flammable, ref appearance))
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Body/Components/InternalsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ public sealed partial class InternalsComponent : Component
[DataField]
public ProtoId<AlertPrototype> InternalsAlert = "Internals";
}

}
9 changes: 9 additions & 0 deletions Content.Server/Body/Systems/InternalsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public override void Initialize()
SubscribeLocalEvent<InternalsComponent, ComponentShutdown>(OnInternalsShutdown);
SubscribeLocalEvent<InternalsComponent, GetVerbsEvent<InteractionVerb>>(OnGetInteractionVerbs);
SubscribeLocalEvent<InternalsComponent, InternalsDoAfterEvent>(OnDoAfter);
SubscribeLocalEvent<InternalsComponent, ToggleInternalsAlertEvent>(OnToggleInternalsAlert);

SubscribeLocalEvent<StartingGearEquippedEvent>(OnStartingGear);
}
Expand Down Expand Up @@ -143,6 +144,14 @@ private void OnDoAfter(Entity<InternalsComponent> ent, ref InternalsDoAfterEvent
args.Handled = true;
}

private void OnToggleInternalsAlert(Entity<InternalsComponent> ent, ref ToggleInternalsAlertEvent args)
{
if (args.Handled)
return;
ToggleInternals(ent, ent, false, internals: ent.Comp);
args.Handled = true;
}

private void OnInternalsStartup(Entity<InternalsComponent> ent, ref ComponentStartup args)
{
_alerts.ShowAlert(ent, ent.Comp.InternalsAlert, GetSeverity(ent));
Expand Down
19 changes: 19 additions & 0 deletions Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,32 @@ public void InitializeEnsnaring()
SubscribeLocalEvent<EnsnaringComponent, StepTriggeredOffEvent>(OnStepTrigger);
SubscribeLocalEvent<EnsnaringComponent, ThrowDoHitEvent>(OnThrowHit);
SubscribeLocalEvent<EnsnaringComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
SubscribeLocalEvent<EnsnareableComponent, RemoveEnsnareAlertEvent>(OnRemoveEnsnareAlert);
}

private void OnAttemptPacifiedThrow(Entity<EnsnaringComponent> ent, ref AttemptPacifiedThrowEvent args)
{
args.Cancel("pacified-cannot-throw-snare");
}

private void OnRemoveEnsnareAlert(Entity<EnsnareableComponent> ent, ref RemoveEnsnareAlertEvent args)
{
if (args.Handled)
return;

foreach (var ensnare in ent.Comp.Container.ContainedEntities)
{
if (!TryComp<EnsnaringComponent>(ensnare, out var ensnaringComponent))
return;

TryFree(ent, ent, ensnare, ensnaringComponent);

args.Handled = true;
// Only one snare at a time.
break;
}
}

private void OnComponentRemove(EntityUid uid, EnsnaringComponent component, ComponentRemove args)
{
if (!TryComp<EnsnareableComponent>(component.Ensnared, out var ensnared))
Expand Down
Loading

0 comments on commit 3b0d51d

Please sign in to comment.