Make godmode able to be disabled and more accessible to the rest of the code (#2560)
* Make Godmode able to be disabled and more accessible * You got a license for that exclamation mark? * Move restore logic to the entity system * Make MovedByPressureComponent able to be disabled * Add extension that gives you the moved by pressure component * Fix not disabling moved by pressure
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
#nullable enable
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -9,6 +12,8 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
{
|
||||
public override string Name => "MovedByPressure";
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool Enabled { get; set; } = true;
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float PressureResistance { get; set; } = 1f;
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
@@ -19,8 +24,23 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(this, x => x.Enabled, "enabled", true);
|
||||
serializer.DataField(this, x => PressureResistance, "pressureResistance", 1f);
|
||||
serializer.DataField(this, x => MoveResist, "moveResist", 100f);
|
||||
}
|
||||
}
|
||||
|
||||
public static class MovedByPressureExtensions
|
||||
{
|
||||
public static bool IsMovedByPressure(this IEntity entity)
|
||||
{
|
||||
return entity.IsMovedByPressure(out _);
|
||||
}
|
||||
|
||||
public static bool IsMovedByPressure(this IEntity entity, [NotNullWhen(true)] out MovedByPressureComponent? moved)
|
||||
{
|
||||
return entity.TryGetComponent(out moved) &&
|
||||
moved.Enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user