_componentFactory.IgnoreMissingComponents();
// Do not add to these, they are legacy.
- _componentFactory.RegisterClass<SharedGravityGeneratorComponent>();
_componentFactory.RegisterClass<SharedAmeControllerComponent>();
// Do not add to the above, they are legacy
--- /dev/null
+using Content.Shared.Gravity;
+
+namespace Content.Client.Gravity;
+
+public sealed class GravityGeneratorSystem : SharedGravityGeneratorSystem
+{
+
+}
public override void Initialize()
{
base.Initialize();
- SubscribeLocalEvent<SharedGravityGeneratorComponent, AppearanceChangeEvent>(OnAppearanceChange);
+ SubscribeLocalEvent<GravityGeneratorComponent, AppearanceChangeEvent>(OnAppearanceChange);
InitializeShake();
}
/// <summary>
/// Ensures that the visible state of gravity generators are synced with their sprites.
/// </summary>
- private void OnAppearanceChange(EntityUid uid, SharedGravityGeneratorComponent comp, ref AppearanceChangeEvent args)
+ private void OnAppearanceChange(EntityUid uid, GravityGeneratorComponent comp, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
-using Content.Server.Gravity;
using Content.Server.Power.Components;
using Content.Shared.Gravity;
using Robust.Shared.GameObjects;
+++ /dev/null
-using Content.Shared.Gravity;
-using Content.Shared.Construction.Prototypes;
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
-
-namespace Content.Server.Gravity
-{
- [RegisterComponent]
- [Access(typeof(GravityGeneratorSystem))]
- public sealed partial class GravityGeneratorComponent : SharedGravityGeneratorComponent
- {
- [DataField("lightRadiusMin")] public float LightRadiusMin { get; set; }
- [DataField("lightRadiusMax")] public float LightRadiusMax { get; set; }
-
- /// <summary>
- /// Is the gravity generator currently "producing" gravity?
- /// </summary>
- [ViewVariables]
- public bool GravityActive { get; set; } = false;
- }
-}
namespace Content.Server.Gravity;
-public sealed class GravityGeneratorSystem : EntitySystem
+public sealed class GravityGeneratorSystem : SharedGravityGeneratorSystem
{
[Dependency] private readonly GravitySystem _gravitySystem = default!;
[Dependency] private readonly SharedPointLightSystem _lights = default!;
private void OnActivated(Entity<GravityGeneratorComponent> ent, ref ChargedMachineActivatedEvent args)
{
ent.Comp.GravityActive = true;
+ Dirty(ent, ent.Comp);
var xform = Transform(ent);
private void OnDeactivated(Entity<GravityGeneratorComponent> ent, ref ChargedMachineDeactivatedEvent args)
{
ent.Comp.GravityActive = false;
+ Dirty(ent, ent.Comp);
var xform = Transform(ent);
namespace Content.Shared.Gravity;
-[NetworkedComponent()]
-[Virtual]
-public partial class SharedGravityGeneratorComponent : Component
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+public sealed partial class GravityGeneratorComponent : Component
{
+ [DataField] public float LightRadiusMin { get; set; }
+ [DataField] public float LightRadiusMax { get; set; }
+
/// <summary>
/// A map of the sprites used by the gravity generator given its status.
/// </summary>
- [DataField("spriteMap")]
- [Access(typeof(SharedGravitySystem))]
- public Dictionary<PowerChargeStatus, string> SpriteMap = new();
+ [DataField, Access(typeof(SharedGravitySystem))]
+ public Dictionary<PowerChargeStatus, string> SpriteMap = [];
/// <summary>
/// The sprite used by the core of the gravity generator when the gravity generator is starting up.
/// </summary>
- [DataField("coreStartupState")]
- [ViewVariables(VVAccess.ReadWrite)]
+ [DataField]
public string CoreStartupState = "startup";
/// <summary>
/// The sprite used by the core of the gravity generator when the gravity generator is idle.
/// </summary>
- [DataField("coreIdleState")]
- [ViewVariables(VVAccess.ReadWrite)]
+ [DataField]
public string CoreIdleState = "idle";
/// <summary>
/// The sprite used by the core of the gravity generator when the gravity generator is activating.
/// </summary>
- [DataField("coreActivatingState")]
- [ViewVariables(VVAccess.ReadWrite)]
+ [DataField]
public string CoreActivatingState = "activating";
/// <summary>
/// The sprite used by the core of the gravity generator when the gravity generator is active.
/// </summary>
- [DataField("coreActivatedState")]
- [ViewVariables(VVAccess.ReadWrite)]
+ [DataField]
public string CoreActivatedState = "activated";
+
+ /// <summary>
+ /// Is the gravity generator currently "producing" gravity?
+ /// </summary>
+ [DataField, AutoNetworkedField, Access(typeof(SharedGravityGeneratorSystem))]
+ public bool GravityActive = false;
}
--- /dev/null
+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();
+ }
+}
-station-anchor-unanchoring-failed = Can't unanchor an active station anchor
+station-anchor-unanchoring-failed = Can't unanchor an active station anchor.
station-anchor-window-title = Station Anchor
### Gravity Generator
## UI
-
gravity-generator-window-title = Gravity Generator
## UI field names
-
gravity-generator-window-status = Status:
gravity-generator-window-power = Power:
gravity-generator-window-eta = ETA:
gravity-generator-window-power-label = { $draw } / { $max } W
## UI ETA label
-
gravity-generator-window-eta-none = N/A
gravity-generator-window-eta-value = { TOSTRING($left, "m\\:ss") }
+
+## Popup
+gravity-generator-unanchoring-failed = Can't unanchor an active gravity generator.