InAir tweaks & chasm fixes (#19707)

This commit is contained in:
Kara
2023-09-10 23:03:16 -07:00
committed by GitHub
parent 414755b455
commit 64a29f0d8a
17 changed files with 91 additions and 48 deletions

View File

@@ -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.