committed by
GitHub
parent
5bfdfc9fca
commit
cf86e0de1d
@@ -8,24 +8,27 @@ namespace Content.Shared.Movement.Components;
|
||||
[Access(typeof(FrictionContactsSystem))]
|
||||
public sealed partial class FrictionContactsComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Should this affect airborne mobs?
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public bool AffectAirborne;
|
||||
|
||||
/// <summary>
|
||||
/// Modified mob friction while on FrictionContactsComponent
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
[AutoNetworkedField]
|
||||
[DataField, AutoNetworkedField]
|
||||
public float MobFriction = 0.05f;
|
||||
|
||||
/// <summary>
|
||||
/// Modified mob friction without input while on FrictionContactsComponent
|
||||
/// </summary>
|
||||
[AutoNetworkedField]
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField, AutoNetworkedField]
|
||||
public float? MobFrictionNoInput = 0.05f;
|
||||
|
||||
/// <summary>
|
||||
/// Modified mob acceleration while on FrictionContactsComponent
|
||||
/// </summary>
|
||||
[AutoNetworkedField]
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField, AutoNetworkedField]
|
||||
public float MobAcceleration = 0.1f;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.Gravity;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Events;
|
||||
@@ -7,6 +8,7 @@ namespace Content.Shared.Movement.Systems;
|
||||
|
||||
public sealed class FrictionContactsSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedGravitySystem _gravity = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly MovementSpeedModifierSystem _speedModifierSystem = default!;
|
||||
|
||||
@@ -82,12 +84,19 @@ public sealed class FrictionContactsSystem : EntitySystem
|
||||
var frictionNoInput = 0.0f;
|
||||
var acceleration = 0.0f;
|
||||
|
||||
var isAirborne = physicsComponent.BodyStatus == BodyStatus.InAir || _gravity.IsWeightless(entity, physicsComponent);
|
||||
|
||||
var remove = true;
|
||||
var entries = 0;
|
||||
foreach (var ent in _physics.GetContactingEntities(entity, physicsComponent))
|
||||
{
|
||||
if (!TryComp<FrictionContactsComponent>(ent, out var contacts))
|
||||
continue;
|
||||
|
||||
// Entities that are airborne should not be affected by contact slowdowns that are specified to not affect airborne entities.
|
||||
if (isAirborne && !contacts.AffectAirborne)
|
||||
continue;
|
||||
|
||||
friction += contacts.MobFriction;
|
||||
frictionNoInput += contacts.MobFrictionNoInput ?? contacts.MobFriction;
|
||||
acceleration += contacts.MobAcceleration;
|
||||
|
||||
@@ -260,7 +260,8 @@ public abstract partial class SharedMoverController : VirtualController
|
||||
else
|
||||
{
|
||||
if (MapGridQuery.TryComp(xform.GridUid, out var gridComp)
|
||||
&& _mapSystem.TryGetTileRef(xform.GridUid.Value, gridComp, xform.Coordinates, out var tile))
|
||||
&& _mapSystem.TryGetTileRef(xform.GridUid.Value, gridComp, xform.Coordinates, out var tile)
|
||||
&& physicsComponent.BodyStatus == BodyStatus.OnGround)
|
||||
tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId];
|
||||
|
||||
var walkSpeed = moveSpeedComponent?.CurrentWalkSpeed ?? MovementSpeedModifierComponent.DefaultBaseWalkSpeed;
|
||||
|
||||
Reference in New Issue
Block a user