CatStation/Content.Shared/Gravity/SharedGravityGeneratorSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* 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
2026-05-09 03:29:58 +00:00

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();
}
}