InAir tweaks & chasm fixes (#19707)
This commit is contained in:
12
Content.Shared/Movement/Components/CanMoveInAirComponent.cs
Normal file
12
Content.Shared/Movement/Components/CanMoveInAirComponent.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Content.Shared.Movement.Components;
|
||||
|
||||
/// <summary>
|
||||
/// On mobs that are allowed to move while their body status is <see cref="BodyStatus.InAir"/>
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class CanMoveInAirComponent : Component
|
||||
{
|
||||
}
|
||||
@@ -6,6 +6,8 @@ using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Movement.Systems;
|
||||
@@ -17,6 +19,7 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
[Dependency] protected readonly SharedContainerSystem Container = default!;
|
||||
[Dependency] private readonly SharedMoverController _mover = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -98,6 +101,10 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
{
|
||||
var userComp = EnsureComp<JetpackUserComponent>(user);
|
||||
_mover.SetRelay(user, jetpackUid);
|
||||
|
||||
if (TryComp<PhysicsComponent>(user, out var physics))
|
||||
_physics.SetBodyStatus(physics, BodyStatus.InAir);
|
||||
|
||||
userComp.Jetpack = jetpackUid;
|
||||
}
|
||||
|
||||
@@ -106,6 +113,9 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
if (!RemComp<JetpackUserComponent>(uid))
|
||||
return;
|
||||
|
||||
if (TryComp<PhysicsComponent>(uid, out var physics))
|
||||
_physics.SetBodyStatus(physics, BodyStatus.OnGround);
|
||||
|
||||
RemComp<RelayInputMoverComponent>(uid);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace Content.Shared.Movement.Systems
|
||||
protected EntityQuery<RelayInputMoverComponent> RelayQuery;
|
||||
protected EntityQuery<SharedPullableComponent> PullableQuery;
|
||||
protected EntityQuery<TransformComponent> XformQuery;
|
||||
protected EntityQuery<CanMoveInAirComponent> CanMoveInAirQuery;
|
||||
|
||||
private const float StepSoundMoveDistanceRunning = 2;
|
||||
private const float StepSoundMoveDistanceWalking = 1.5f;
|
||||
@@ -83,6 +84,7 @@ namespace Content.Shared.Movement.Systems
|
||||
RelayQuery = GetEntityQuery<RelayInputMoverComponent>();
|
||||
PullableQuery = GetEntityQuery<SharedPullableComponent>();
|
||||
XformQuery = GetEntityQuery<TransformComponent>();
|
||||
CanMoveInAirQuery = GetEntityQuery<CanMoveInAirComponent>();
|
||||
|
||||
InitializeFootsteps();
|
||||
InitializeInput();
|
||||
@@ -150,27 +152,16 @@ namespace Content.Shared.Movement.Systems
|
||||
LerpRotation(uid, mover, frameTime);
|
||||
|
||||
if (!canMove
|
||||
|| physicsComponent.BodyStatus != BodyStatus.OnGround
|
||||
|| physicsComponent.BodyStatus != BodyStatus.OnGround && !CanMoveInAirQuery.HasComponent(uid)
|
||||
|| PullableQuery.TryGetComponent(uid, out var pullable) && pullable.BeingPulled)
|
||||
{
|
||||
UsedMobMovement[uid] = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get current tile def for things like speed/weightless mods
|
||||
ContentTileDefinition? tileDef = null;
|
||||
|
||||
if (_mapManager.TryFindGridAt(xform.MapPosition, out var grid, out var gridComp)
|
||||
&& _mapSystem.TryGetTileRef(grid, gridComp, xform.Coordinates, out var tile))
|
||||
{
|
||||
tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId];
|
||||
}
|
||||
|
||||
UsedMobMovement[uid] = true;
|
||||
// Specifically don't use mover.Owner because that may be different to the actual physics body being moved.
|
||||
|
||||
// We differentiate between grav/other sources of weightless for tiles which want to use weightless accel (like ice)
|
||||
// but don't care about requiring touching etc
|
||||
var weightless = _gravity.IsWeightless(physicsUid, physicsComponent, xform);
|
||||
var (walkDir, sprintDir) = GetVelocityInput(mover);
|
||||
var touching = false;
|
||||
@@ -193,6 +184,18 @@ namespace Content.Shared.Movement.Systems
|
||||
}
|
||||
}
|
||||
|
||||
// Get current tile def for things like speed/friction mods
|
||||
ContentTileDefinition? tileDef = null;
|
||||
|
||||
// Don't bother getting the tiledef here if we're weightless or in-air
|
||||
// since no tile-based modifiers should be applying in that situation
|
||||
if (_mapManager.TryFindGridAt(xform.MapPosition, out var grid, out var gridComp)
|
||||
&& _mapSystem.TryGetTileRef(grid, gridComp, xform.Coordinates, out var tile)
|
||||
&& !(weightless || physicsComponent.BodyStatus == BodyStatus.InAir))
|
||||
{
|
||||
tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId];
|
||||
}
|
||||
|
||||
// Regular movement.
|
||||
// Target velocity.
|
||||
// This is relative to the map / grid we're on.
|
||||
|
||||
Reference in New Issue
Block a user