* 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
30 lines
851 B
C#
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();
|
|
}
|
|
}
|