Gravity "Inherent" property for planet maps (#16695)
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user