Gravity "Inherent" property for planet maps (#16695)

This commit is contained in:
20kdc
2023-07-16 20:01:54 +01:00
committed by GitHub
parent 99e6f8f0bc
commit 69ff0ae2e6
3 changed files with 17 additions and 1 deletions

View File

@@ -22,6 +22,9 @@ namespace Content.Server.Gravity
if (!Resolve(uid, ref gravity)) if (!Resolve(uid, ref gravity))
return; return;
if (gravity.Inherent)
return;
var enabled = false; var enabled = false;
foreach (var (comp, xform) in EntityQuery<GravityGeneratorComponent, TransformComponent>(true)) foreach (var (comp, xform) in EntityQuery<GravityGeneratorComponent, TransformComponent>(true))
@@ -52,12 +55,17 @@ namespace Content.Server.Gravity
RefreshGravity(uid); RefreshGravity(uid);
} }
/// <summary>
/// Enables gravity. Note that this is a fast-path for GravityGeneratorSystem.
/// This means it does nothing if Inherent is set and it might be wiped away with a refresh
/// if you're not supposed to be doing whatever you're doing.
/// </summary>
public void EnableGravity(EntityUid uid, GravityComponent? gravity = null) public void EnableGravity(EntityUid uid, GravityComponent? gravity = null)
{ {
if (!Resolve(uid, ref gravity)) if (!Resolve(uid, ref gravity))
return; return;
if (gravity.Enabled) if (gravity.Enabled || gravity.Inherent)
return; return;
gravity.Enabled = true; gravity.Enabled = true;

View File

@@ -71,6 +71,7 @@ public sealed class PlanetCommand : IConsoleCommand
var gravity = _entManager.EnsureComponent<GravityComponent>(mapUid); var gravity = _entManager.EnsureComponent<GravityComponent>(mapUid);
gravity.Enabled = true; gravity.Enabled = true;
gravity.Inherent = true;
_entManager.Dirty(gravity, metadata); _entManager.Dirty(gravity, metadata);
// Day lighting // Day lighting

View File

@@ -27,5 +27,12 @@ namespace Content.Shared.Gravity
[DataField("enabled")] [DataField("enabled")]
public bool Enabled; public bool Enabled;
/// <summary>
/// Inherent gravity ensures GravitySystem won't change Enabled according to the gravity generators attached to this entity.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("inherent")]
public bool Inherent;
} }
} }