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
This commit is contained in:
29
Content.Shared/Gravity/SharedGravityGeneratorSystem.cs
Normal file
29
Content.Shared/Gravity/SharedGravityGeneratorSystem.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user