Replace IClickAlert with events (#30728)
* Replace IAlertClick with events * whoop * eek!
This commit is contained in:
@@ -93,6 +93,6 @@ public sealed class ClientAlertsSystem : AlertsSystem
|
||||
|
||||
public void AlertClicked(ProtoId<AlertPrototype> alertType)
|
||||
{
|
||||
RaiseNetworkEvent(new ClickAlertEvent(alertType));
|
||||
RaisePredictiveEvent(new ClickAlertEvent(alertType));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -29,6 +30,9 @@ namespace Content.Server.Abilities.Mime
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<MimePowersComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<MimePowersComponent, InvisibleWallActionEvent>(OnInvisibleWall);
|
||||
|
||||
SubscribeLocalEvent<MimePowersComponent, BreakVowAlertEvent>(OnBreakVowAlert);
|
||||
SubscribeLocalEvent<MimePowersComponent, RetakeVowAlertEvent>(OnRetakeVowAlert);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
@@ -99,6 +103,22 @@ namespace Content.Server.Abilities.Mime
|
||||
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>
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Server.Abilities.Mime;
|
||||
|
||||
namespace Content.Server.Alert.Click
|
||||
{
|
||||
///<summary>
|
||||
/// Break your mime vows
|
||||
///</summary>
|
||||
[DataDefinition]
|
||||
public sealed partial class BreakVow : IAlertClick
|
||||
{
|
||||
public void AlertClicked(EntityUid player)
|
||||
{
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (entManager.TryGetComponent(player, out MimePowersComponent? mimePowers))
|
||||
{
|
||||
entManager.System<MimePowersSystem>().BreakVow(player, mimePowers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using Content.Server.Cuffs;
|
||||
using Content.Shared.Alert;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Alert.Click
|
||||
{
|
||||
/// <summary>
|
||||
/// Try to remove handcuffs from yourself
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed partial class RemoveCuffs : IAlertClick
|
||||
{
|
||||
public void AlertClicked(EntityUid player)
|
||||
{
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var cuffableSys = entityManager.System<CuffableSystem>();
|
||||
cuffableSys.TryUncuff(player, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using Content.Server.Ensnaring;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Ensnaring.Components;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Alert.Click;
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed partial class RemoveEnsnare : IAlertClick
|
||||
{
|
||||
public void AlertClicked(EntityUid player)
|
||||
{
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
if (entManager.TryGetComponent(player, out EnsnareableComponent? ensnareableComponent))
|
||||
{
|
||||
foreach (var ensnare in ensnareableComponent.Container.ContainedEntities)
|
||||
{
|
||||
if (!entManager.TryGetComponent(ensnare, out EnsnaringComponent? ensnaringComponent))
|
||||
return;
|
||||
|
||||
entManager.EntitySysManager.GetEntitySystem<EnsnareableSystem>().TryFree(player, player, ensnare, ensnaringComponent);
|
||||
|
||||
// Only one snare at a time.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Alert;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Alert.Click
|
||||
{
|
||||
/// <summary>
|
||||
/// Resist fire
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed partial class ResistFire : IAlertClick
|
||||
{
|
||||
public void AlertClicked(EntityUid player)
|
||||
{
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (entManager.TryGetComponent(player, out FlammableComponent? flammable))
|
||||
{
|
||||
entManager.System<FlammableSystem>().Resist(player, flammable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Server.Abilities.Mime;
|
||||
|
||||
namespace Content.Server.Alert.Click
|
||||
{
|
||||
///<summary>
|
||||
/// Retake your mime vows
|
||||
///</summary>
|
||||
[DataDefinition]
|
||||
public sealed partial class RetakeVow : IAlertClick
|
||||
{
|
||||
public void AlertClicked(EntityUid player)
|
||||
{
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (entManager.TryGetComponent(player, out MimePowersComponent? mimePowers))
|
||||
{
|
||||
entManager.System<MimePowersSystem>().RetakeVow(player, mimePowers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Movement.Pulling.Components;
|
||||
using Content.Shared.Movement.Pulling.Systems;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Alert.Click
|
||||
{
|
||||
/// <summary>
|
||||
/// Stop pulling something
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed partial class StopBeingPulled : IAlertClick
|
||||
{
|
||||
public void AlertClicked(EntityUid player)
|
||||
{
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!entityManager.System<ActionBlockerSystem>().CanInteract(player, null))
|
||||
return;
|
||||
|
||||
if (entityManager.TryGetComponent(player, out PullableComponent? playerPullable))
|
||||
{
|
||||
entityManager.System<PullingSystem>().TryStopPull(player, playerPullable, user: player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using Content.Server.Shuttles.Systems;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Alert.Click
|
||||
{
|
||||
/// <summary>
|
||||
/// Stop piloting shuttle
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed partial class StopPiloting : IAlertClick
|
||||
{
|
||||
public void AlertClicked(EntityUid player)
|
||||
{
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (entManager.TryGetComponent(player, out PilotComponent? pilotComponent)
|
||||
&& pilotComponent.Console != null)
|
||||
{
|
||||
entManager.System<ShuttleConsoleSystem>().RemovePilot(player, pilotComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Movement.Pulling.Components;
|
||||
using Content.Shared.Movement.Pulling.Systems;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Alert.Click
|
||||
{
|
||||
/// <summary>
|
||||
/// Stop pulling something
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed partial class StopPulling : IAlertClick
|
||||
{
|
||||
public void AlertClicked(EntityUid player)
|
||||
{
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
var ps = entManager.System<PullingSystem>();
|
||||
|
||||
if (entManager.TryGetComponent(player, out PullerComponent? puller) &&
|
||||
entManager.TryGetComponent(puller.Pulling, out PullableComponent? pullableComp))
|
||||
{
|
||||
ps.TryStopPull(puller.Pulling.Value, pullableComp, user: player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Shared.Alert;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Alert.Click;
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to toggle the internals for a particular entity
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed partial class ToggleInternals : IAlertClick
|
||||
{
|
||||
public void AlertClicked(EntityUid player)
|
||||
{
|
||||
var internalsSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InternalsSystem>();
|
||||
internalsSystem.ToggleInternals(player, player, false);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Buckle;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Alert.Click
|
||||
{
|
||||
/// <summary>
|
||||
/// Unbuckles if player is currently buckled.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed partial class Unbuckle : IAlertClick
|
||||
{
|
||||
public void AlertClicked(EntityUid player)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().System<SharedBuckleSystem>().TryUnbuckle(player, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
SubscribeLocalEvent<FlammableComponent, IsHotEvent>(OnIsHot);
|
||||
SubscribeLocalEvent<FlammableComponent, TileFireEvent>(OnTileFire);
|
||||
SubscribeLocalEvent<FlammableComponent, RejuvenateEvent>(OnRejuvenate);
|
||||
SubscribeLocalEvent<FlammableComponent, ResistFireAlertEvent>(OnResistFireAlert);
|
||||
|
||||
SubscribeLocalEvent<IgniteOnCollideComponent, StartCollideEvent>(IgniteOnCollide);
|
||||
SubscribeLocalEvent<IgniteOnCollideComponent, LandEvent>(OnIgniteLand);
|
||||
@@ -250,6 +251,15 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
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))
|
||||
|
||||
@@ -25,4 +25,5 @@ namespace Content.Server.Body.Components
|
||||
[DataField]
|
||||
public ProtoId<AlertPrototype> InternalsAlert = "Internals";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public sealed class InternalsSystem : EntitySystem
|
||||
SubscribeLocalEvent<InternalsComponent, ComponentShutdown>(OnInternalsShutdown);
|
||||
SubscribeLocalEvent<InternalsComponent, GetVerbsEvent<InteractionVerb>>(OnGetInteractionVerbs);
|
||||
SubscribeLocalEvent<InternalsComponent, InternalsDoAfterEvent>(OnDoAfter);
|
||||
SubscribeLocalEvent<InternalsComponent, ToggleInternalsAlertEvent>(OnToggleInternalsAlert);
|
||||
|
||||
SubscribeLocalEvent<InternalsComponent, StartingGearEquippedEvent>(OnStartingGear);
|
||||
}
|
||||
@@ -161,6 +162,14 @@ public sealed class InternalsSystem : EntitySystem
|
||||
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));
|
||||
|
||||
@@ -28,6 +28,7 @@ public sealed partial class EnsnareableSystem
|
||||
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)
|
||||
@@ -35,6 +36,24 @@ public sealed partial class EnsnareableSystem
|
||||
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))
|
||||
|
||||
@@ -71,6 +71,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
SubscribeLocalEvent<UndockEvent>(OnUndock);
|
||||
|
||||
SubscribeLocalEvent<PilotComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<PilotComponent, StopPilotingAlertEvent>(OnStopPilotingAlert);
|
||||
|
||||
SubscribeLocalEvent<FTLDestinationComponent, ComponentStartup>(OnFtlDestStartup);
|
||||
SubscribeLocalEvent<FTLDestinationComponent, ComponentShutdown>(OnFtlDestShutdown);
|
||||
@@ -196,6 +197,14 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
args.State = new PilotComponentState(GetNetEntity(component.Console));
|
||||
}
|
||||
|
||||
private void OnStopPilotingAlert(Entity<PilotComponent> ent, ref StopPilotingAlertEvent args)
|
||||
{
|
||||
if (ent.Comp.Console != null)
|
||||
{
|
||||
RemovePilot(ent, ent);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the position and angle of all dockingcomponents.
|
||||
/// </summary>
|
||||
|
||||
7
Content.Shared/Abilities/Mime/MimePowers.cs
Normal file
7
Content.Shared/Abilities/Mime/MimePowers.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using Content.Shared.Alert;
|
||||
|
||||
namespace Content.Shared.Abilities.Mime;
|
||||
|
||||
public sealed partial class BreakVowAlertEvent : BaseAlertEvent;
|
||||
|
||||
public sealed partial class RetakeVowAlertEvent : BaseAlertEvent;
|
||||
@@ -76,11 +76,11 @@ public sealed partial class AlertPrototype : IPrototype
|
||||
public bool SupportsSeverity => MaxSeverity != -1;
|
||||
|
||||
/// <summary>
|
||||
/// Defines what to do when the alert is clicked.
|
||||
/// This will always be null on clientside.
|
||||
/// Event raised on the user when they click on this alert.
|
||||
/// Can be null.
|
||||
/// </summary>
|
||||
[DataField(serverOnly: true)]
|
||||
public IAlertClick? OnClick { get; private set; }
|
||||
[DataField]
|
||||
public BaseAlertEvent? ClickEvent;
|
||||
|
||||
/// <param name="severity">severity level, if supported by this alert</param>
|
||||
/// <returns>the icon path to the texture for the provided severity level</returns>
|
||||
@@ -114,3 +114,17 @@ public sealed partial class AlertPrototype : IPrototype
|
||||
return Icons[severity.Value - _minSeverity];
|
||||
}
|
||||
}
|
||||
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
public abstract partial class BaseAlertEvent : HandledEntityEventArgs
|
||||
{
|
||||
public EntityUid User;
|
||||
|
||||
public ProtoId<AlertPrototype> AlertId;
|
||||
|
||||
protected BaseAlertEvent(EntityUid user, ProtoId<AlertPrototype> alertId)
|
||||
{
|
||||
User = user;
|
||||
AlertId = alertId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
namespace Content.Shared.Alert
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines what should happen when an alert is clicked.
|
||||
/// </summary>
|
||||
public interface IAlertClick
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked on server side when user clicks an alert.
|
||||
/// </summary>
|
||||
/// <param name="player"></param>
|
||||
void AlertClicked(EntityUid player);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.Alert;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Shared.Atmos.Components;
|
||||
@@ -27,3 +28,5 @@ public sealed partial class ExtinguishOnInteractComponent : Component
|
||||
[DataField]
|
||||
public LocId ExtinguishFailed = "candle-extinguish-failed";
|
||||
}
|
||||
|
||||
public sealed partial class ResistFireAlertEvent : BaseAlertEvent;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
@@ -79,6 +80,7 @@ public sealed class BuckleState(NetEntity? buckledTo, bool dontCollide, TimeSpan
|
||||
public readonly TimeSpan? BuckleTime = buckleTime;
|
||||
}
|
||||
|
||||
public sealed partial class UnbuckleAlertEvent : BaseAlertEvent;
|
||||
|
||||
/// <summary>
|
||||
/// Event raised directed at a strap entity before some entity gets buckled to it.
|
||||
|
||||
@@ -41,6 +41,7 @@ public abstract partial class SharedBuckleSystem
|
||||
SubscribeLocalEvent<BuckleComponent, StartPullAttemptEvent>(OnPullAttempt);
|
||||
SubscribeLocalEvent<BuckleComponent, BeingPulledAttemptEvent>(OnBeingPulledAttempt);
|
||||
SubscribeLocalEvent<BuckleComponent, PullStartedMessage>(OnPullStarted);
|
||||
SubscribeLocalEvent<BuckleComponent, UnbuckleAlertEvent>(OnUnbuckleAlert);
|
||||
|
||||
SubscribeLocalEvent<BuckleComponent, InsertIntoEntityStorageAttemptEvent>(OnBuckleInsertIntoEntityStorageAttempt);
|
||||
|
||||
@@ -86,6 +87,13 @@ public abstract partial class SharedBuckleSystem
|
||||
Unbuckle(ent!, args.PullerUid);
|
||||
}
|
||||
|
||||
private void OnUnbuckleAlert(Entity<BuckleComponent> ent, ref UnbuckleAlertEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
args.Handled = TryUnbuckle(ent, ent, ent);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Transform
|
||||
|
||||
@@ -46,6 +46,8 @@ public sealed partial class CuffableComponent : Component
|
||||
public ProtoId<AlertPrototype> CuffedAlert = "Handcuffed";
|
||||
}
|
||||
|
||||
public sealed partial class RemoveCuffsAlertEvent : BaseAlertEvent;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CuffableComponentState : ComponentState
|
||||
{
|
||||
|
||||
@@ -66,6 +66,7 @@ namespace Content.Shared.Cuffs
|
||||
SubscribeLocalEvent<CuffableComponent, RejuvenateEvent>(OnRejuvenate);
|
||||
SubscribeLocalEvent<CuffableComponent, ComponentInit>(OnStartup);
|
||||
SubscribeLocalEvent<CuffableComponent, AttemptStopPullingEvent>(HandleStopPull);
|
||||
SubscribeLocalEvent<CuffableComponent, RemoveCuffsAlertEvent>(OnRemoveCuffsAlert);
|
||||
SubscribeLocalEvent<CuffableComponent, UpdateCanMoveEvent>(HandleMoveAttempt);
|
||||
SubscribeLocalEvent<CuffableComponent, IsEquippingAttemptEvent>(OnEquipAttempt);
|
||||
SubscribeLocalEvent<CuffableComponent, IsUnequippingAttemptEvent>(OnUnequipAttempt);
|
||||
@@ -248,6 +249,14 @@ namespace Content.Shared.Cuffs
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
private void OnRemoveCuffsAlert(Entity<CuffableComponent> ent, ref RemoveCuffsAlertEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
TryUncuff(ent, ent, cuffable: ent.Comp);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void AddUncuffVerb(EntityUid uid, CuffableComponent component, GetVerbsEvent<Verb> args)
|
||||
{
|
||||
// Can the user access the cuffs, and is there even anything to uncuff?
|
||||
|
||||
@@ -47,6 +47,8 @@ public sealed partial class EnsnareableComponent : Component
|
||||
public ProtoId<AlertPrototype> EnsnaredAlert = "Ensnared";
|
||||
}
|
||||
|
||||
public sealed partial class RemoveEnsnareAlertEvent : BaseAlertEvent;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class EnsnareableComponentState : ComponentState
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.DoAfter;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Internals;
|
||||
@@ -7,3 +8,5 @@ namespace Content.Shared.Internals;
|
||||
public sealed partial class InternalsDoAfterEvent : SimpleDoAfterEvent
|
||||
{
|
||||
}
|
||||
|
||||
public sealed partial class ToggleInternalsAlertEvent : BaseAlertEvent;
|
||||
|
||||
@@ -42,3 +42,5 @@ public sealed partial class PullableComponent : Component
|
||||
[DataField]
|
||||
public ProtoId<AlertPrototype> PulledAlert = "Pulled";
|
||||
}
|
||||
|
||||
public sealed partial class StopBeingPulledAlertEvent : BaseAlertEvent;
|
||||
|
||||
@@ -44,3 +44,5 @@ public sealed partial class PullerComponent : Component
|
||||
[DataField]
|
||||
public ProtoId<AlertPrototype> PullingAlert = "Pulling";
|
||||
}
|
||||
|
||||
public sealed partial class StopPullingAlertEvent : BaseAlertEvent;
|
||||
|
||||
@@ -58,6 +58,7 @@ public sealed class PullingSystem : EntitySystem
|
||||
SubscribeLocalEvent<PullableComponent, GetVerbsEvent<Verb>>(AddPullVerbs);
|
||||
SubscribeLocalEvent<PullableComponent, EntGotInsertedIntoContainerMessage>(OnPullableContainerInsert);
|
||||
SubscribeLocalEvent<PullableComponent, ModifyUncuffDurationEvent>(OnModifyUncuffDuration);
|
||||
SubscribeLocalEvent<PullableComponent, StopBeingPulledAlertEvent>(OnStopBeingPulledAlert);
|
||||
|
||||
SubscribeLocalEvent<PullerComponent, AfterAutoHandleStateEvent>(OnAfterState);
|
||||
SubscribeLocalEvent<PullerComponent, EntGotInsertedIntoContainerMessage>(OnPullerContainerInsert);
|
||||
@@ -65,6 +66,7 @@ public sealed class PullingSystem : EntitySystem
|
||||
SubscribeLocalEvent<PullerComponent, VirtualItemDeletedEvent>(OnVirtualItemDeleted);
|
||||
SubscribeLocalEvent<PullerComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
|
||||
SubscribeLocalEvent<PullerComponent, DropHandItemsEvent>(OnDropHandItems);
|
||||
SubscribeLocalEvent<PullerComponent, StopPullingAlertEvent>(OnStopPullingAlert);
|
||||
|
||||
SubscribeLocalEvent<PullableComponent, StrappedEvent>(OnBuckled);
|
||||
SubscribeLocalEvent<PullableComponent, BuckledEvent>(OnGotBuckled);
|
||||
@@ -105,6 +107,15 @@ public sealed class PullingSystem : EntitySystem
|
||||
TryStopPull(pullerComp.Pulling.Value, pullableComp, uid);
|
||||
}
|
||||
|
||||
private void OnStopPullingAlert(Entity<PullerComponent> ent, ref StopPullingAlertEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
if (!TryComp<PullableComponent>(ent.Comp.Pulling, out var pullable))
|
||||
return;
|
||||
args.Handled = TryStopPull(ent.Comp.Pulling.Value, pullable, ent);
|
||||
}
|
||||
|
||||
private void OnPullerContainerInsert(Entity<PullerComponent> ent, ref EntGotInsertedIntoContainerMessage args)
|
||||
{
|
||||
if (ent.Comp.Pulling == null)
|
||||
@@ -133,6 +144,14 @@ public sealed class PullingSystem : EntitySystem
|
||||
args.Duration *= 2;
|
||||
}
|
||||
|
||||
private void OnStopBeingPulledAlert(Entity<PullableComponent> ent, ref StopBeingPulledAlertEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
args.Handled = TryStopPull(ent, ent, ent);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
@@ -491,6 +510,9 @@ public sealed class PullingSystem : EntitySystem
|
||||
if (pullerUidNull == null)
|
||||
return true;
|
||||
|
||||
if (user != null && !_blocker.CanInteract(user.Value, pullableUid))
|
||||
return false;
|
||||
|
||||
var msg = new AttemptStopPullingEvent(user);
|
||||
RaiseLocalEvent(pullableUid, msg, true);
|
||||
|
||||
|
||||
@@ -39,4 +39,6 @@ namespace Content.Shared.Shuttles.Components
|
||||
|
||||
public override bool SendOnlyToOwner => true;
|
||||
}
|
||||
|
||||
public sealed partial class StopPilotingAlertEvent : BaseAlertEvent;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
- type: alert
|
||||
id: Fire
|
||||
icons: [ /Textures/Interface/Alerts/Fire/fire.png ]
|
||||
onClick: !type:ResistFire { }
|
||||
clickEvent: !type:ResistFireAlertEvent
|
||||
name: alerts-on-fire-name
|
||||
description: alerts-on-fire-desc
|
||||
|
||||
@@ -136,14 +136,14 @@
|
||||
|
||||
- type: alert
|
||||
id: Handcuffed
|
||||
onClick: !type:RemoveCuffs { }
|
||||
clickEvent: !type:RemoveCuffsAlertEvent
|
||||
icons: [ /Textures/Interface/Alerts/Handcuffed/Handcuffed.png ]
|
||||
name: alerts-handcuffed-name
|
||||
description: alerts-handcuffed-desc
|
||||
|
||||
- type: alert
|
||||
id: Ensnared
|
||||
onClick: !type:RemoveEnsnare { }
|
||||
clickEvent: !type:RemoveEnsnareAlertEvent
|
||||
icons:
|
||||
- sprite: /Textures/Interface/Alerts/ensnared.rsi
|
||||
state: ensnared
|
||||
@@ -153,7 +153,7 @@
|
||||
- type: alert
|
||||
id: Buckled
|
||||
category: Buckled
|
||||
onClick: !type:Unbuckle { }
|
||||
clickEvent: !type:UnbuckleAlertEvent
|
||||
icons: [ /Textures/Interface/Alerts/Buckle/buckled.png ]
|
||||
name: alerts-buckled-name
|
||||
description: alerts-buckled-desc
|
||||
@@ -275,7 +275,7 @@
|
||||
- type: alert
|
||||
id: Internals
|
||||
category: Internals
|
||||
onClick: !type:ToggleInternals {}
|
||||
clickEvent: !type:ToggleInternalsAlertEvent
|
||||
icons:
|
||||
- sprite: /Textures/Interface/Alerts/internals.rsi
|
||||
state: internal0
|
||||
@@ -291,7 +291,7 @@
|
||||
- type: alert
|
||||
id: PilotingShuttle
|
||||
category: Piloting
|
||||
onClick: !type:StopPiloting { }
|
||||
clickEvent: !type:StopPilotingAlertEvent
|
||||
icons: [ /Textures/Interface/Alerts/piloting.png ]
|
||||
name: alerts-piloting-name
|
||||
description: alerts-piloting-desc
|
||||
@@ -365,27 +365,27 @@
|
||||
id: VowOfSilence
|
||||
icons: [ /Textures/Interface/Alerts/Abilities/silenced.png ]
|
||||
name: alerts-vow-silence-name
|
||||
onClick: !type:BreakVow { }
|
||||
clickEvent: !type:BreakVowAlertEvent
|
||||
description: alerts-vow-silence-desc
|
||||
|
||||
- type: alert
|
||||
id: VowBroken
|
||||
icons: [ /Textures/Interface/Actions/scream.png ]
|
||||
name: alerts-vow-broken-name
|
||||
onClick: !type:RetakeVow { }
|
||||
clickEvent: !type:RetakeVowAlertEvent
|
||||
description: alerts-vow-broken-desc
|
||||
|
||||
- type: alert
|
||||
id: Pulled
|
||||
icons: [ /Textures/Interface/Alerts/Pull/pulled.png ]
|
||||
onClick: !type:StopBeingPulled { }
|
||||
clickEvent: !type:StopBeingPulledAlertEvent
|
||||
name: alerts-pulled-name
|
||||
description: alerts-pulled-desc
|
||||
|
||||
- type: alert
|
||||
id: Pulling
|
||||
icons: [ /Textures/Interface/Alerts/Pull/pulling.png ]
|
||||
onClick: !type:StopPulling { }
|
||||
clickEvent: !type:StopPullingAlertEvent
|
||||
name: alerts-pulling-name
|
||||
description: alerts-pulling-desc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user