mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
29 lines
850 B
C#
29 lines
850 B
C#
using Content.Shared.Popups;
|
|
using Content.Shared.Construction.Components;
|
|
|
|
namespace Content.Shared.Gravity;
|
|
|
|
public abstract partial class SharedGravityGeneratorSystem : EntitySystem
|
|
{
|
|
[Dependency] private SharedPopupSystem _popupSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<GravityGeneratorComponent, UnanchorAttemptEvent>(OnUnanchorAttempt);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Prevent unanchoring when gravity is active
|
|
/// </summary>
|
|
private void OnUnanchorAttempt(Entity<GravityGeneratorComponent> ent, ref UnanchorAttemptEvent args)
|
|
{
|
|
if (!ent.Comp.GravityActive)
|
|
return;
|
|
|
|
_popupSystem.PopupClient(Loc.GetString("gravity-generator-unanchoring-failed"), ent.Owner, args.User, PopupType.Medium);
|
|
|
|
args.Cancel();
|
|
}
|
|
}
|