Files
tbd-station-14/Content.Shared/Gravity/SharedGravityGeneratorSystem.cs
Justin Pfeifler 4f0b1f377e Gravity Generators cannot be unanchored while active (#41256)
* Add unanchor attempt check

* Combine shared component and server component

- Combines SharedGravityGeneratorComponent and GravityGeneratorComponent
- AutoNetworked the GravityActiveBool

* Remove SharedGravityGeneratorComponent

* Update to SharedGravityGeneratorComponent

* Fix to be a complete sentence

* Dirty GravityActive whenever changed

* Rename component and remove view variables

* Update referenced component name

* Move unanchor attempt to shared system

* Add client system

* Revert popup to PopupEntity

* Fix popup to be PopupClient

* Set access restriction on GravityActive
2025-11-07 00:53:27 +00:00

30 lines
851 B
C#

using Content.Shared.Popups;
using Content.Shared.Construction.Components;
namespace Content.Shared.Gravity;
public abstract class SharedGravityGeneratorSystem : EntitySystem
{
[Dependency] private readonly 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();
}
}