Replace IClickAlert with events (#30728)

* Replace IAlertClick with events

* whoop

* eek!
This commit is contained in:
Nemanja
2024-08-07 01:15:35 -04:00
committed by GitHub
parent 2dabf33d46
commit ce97225c2d
33 changed files with 177 additions and 270 deletions

View File

@@ -195,7 +195,7 @@ public abstract class AlertsSystem : EntitySystem
SubscribeLocalEvent<AlertAutoRemoveComponent, EntityUnpausedEvent>(OnAutoRemoveUnPaused);
SubscribeNetworkEvent<ClickAlertEvent>(HandleClickAlert);
SubscribeAllEvent<ClickAlertEvent>(HandleClickAlert);
SubscribeLocalEvent<PrototypesReloadedEventArgs>(HandlePrototypesReloaded);
LoadPrototypes();
}
@@ -328,7 +328,20 @@ public abstract class AlertsSystem : EntitySystem
return;
}
alert.OnClick?.AlertClicked(player.Value);
ActivateAlert(player.Value, alert);
}
public bool ActivateAlert(EntityUid user, AlertPrototype alert)
{
if (alert.ClickEvent is not { } clickEvent)
return false;
clickEvent.Handled = false;
clickEvent.User = user;
clickEvent.AlertId = alert.ID;
RaiseLocalEvent(user, (object) clickEvent, true);
return clickEvent.Handled;
}
private void OnPlayerAttached(EntityUid uid, AlertsComponent component, PlayerAttachedEvent args)