Add moon boots (#29009)
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Clothing;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Serialization;
|
||||
@@ -15,7 +13,6 @@ namespace Content.Shared.Gravity
|
||||
{
|
||||
[Dependency] protected readonly IGameTiming Timing = default!;
|
||||
[Dependency] private readonly AlertsSystem _alerts = default!;
|
||||
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||
|
||||
[ValidatePrototypeId<AlertPrototype>]
|
||||
public const string WeightlessAlert = "Weightless";
|
||||
@@ -30,6 +27,11 @@ namespace Content.Shared.Gravity
|
||||
if (TryComp<MovementIgnoreGravityComponent>(uid, out var ignoreGravityComponent))
|
||||
return ignoreGravityComponent.Weightless;
|
||||
|
||||
var ev = new IsWeightlessEvent(uid);
|
||||
RaiseLocalEvent(uid, ref ev);
|
||||
if (ev.Handled)
|
||||
return ev.IsWeightless;
|
||||
|
||||
if (!Resolve(uid, ref xform))
|
||||
return true;
|
||||
|
||||
@@ -40,18 +42,6 @@ namespace Content.Shared.Gravity
|
||||
return false;
|
||||
}
|
||||
|
||||
var hasGrav = gravity != null || mapGravity != null;
|
||||
|
||||
// Check for something holding us down
|
||||
// If the planet has gravity component and no gravity it will still give gravity
|
||||
// If there's no gravity comp at all (i.e. space) then they don't work.
|
||||
if (hasGrav && _inventory.TryGetSlotEntity(uid, "shoes", out var ent))
|
||||
{
|
||||
// TODO this should just be a event that gets relayed instead of a specific slot & component check.
|
||||
if (TryComp<MagbootsComponent>(ent, out var boots) && boots.On)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -74,9 +64,11 @@ namespace Content.Shared.Gravity
|
||||
|
||||
private void OnHandleState(EntityUid uid, GravityComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not GravityComponentState state) return;
|
||||
if (args.Current is not GravityComponentState state)
|
||||
return;
|
||||
|
||||
if (component.EnabledVV == state.Enabled) return;
|
||||
if (component.EnabledVV == state.Enabled)
|
||||
return;
|
||||
component.EnabledVV = state.Enabled;
|
||||
var ev = new GravityChangedEvent(uid, component.EnabledVV);
|
||||
RaiseLocalEvent(uid, ref ev, true);
|
||||
@@ -90,9 +82,10 @@ namespace Content.Shared.Gravity
|
||||
private void OnGravityChange(ref GravityChangedEvent ev)
|
||||
{
|
||||
var alerts = AllEntityQuery<AlertsComponent, TransformComponent>();
|
||||
while(alerts.MoveNext(out var uid, out var comp, out var xform))
|
||||
while(alerts.MoveNext(out var uid, out _, out var xform))
|
||||
{
|
||||
if (xform.GridUid != ev.ChangedGridIndex) continue;
|
||||
if (xform.GridUid != ev.ChangedGridIndex)
|
||||
continue;
|
||||
|
||||
if (!ev.HasGravity)
|
||||
{
|
||||
@@ -145,4 +138,10 @@ namespace Content.Shared.Gravity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ByRefEvent]
|
||||
public record struct IsWeightlessEvent(EntityUid Entity, bool IsWeightless = false, bool Handled = false) : IInventoryRelayEvent
|
||||
{
|
||||
SlotFlags IInventoryRelayEvent.TargetSlots => ~SlotFlags.POCKET;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user