Files
tbd-station-14/Content.Shared/Movement/Components/MobCollisionComponent.cs
metalgearsloth 593804b517 Mob collisions (#34580)
* Conveyor optimisations

- Optimise movement for moving stuff. Better flags + less resolves + slapped parallelrobustjob on it.
- Sleeping for entities getting conveyed into walls.

* Blocker version

* Finish

* Final

* Mob collisions

* impulses

* Collision smoothing

* Locked in

* 30tps working

* r

* fixes

* Best

* Fixes + CVars

* CVars in place

* Pushies

* Opt attempt 1

* Revert "Opt attempt 1"

This reverts commit 5ccd72dcbea09261a992aa1f7f05df169a1ce676.

* Fix mispredicts

* Ready-ish

* better

* Cleanup

* Fix conveyor power mispredict

* Forgetting to actually do deltas

* Fix buckle pushes

* Bagel save

* Revert "Bagel save"

This reverts commit 1b93fda81fb852d89b89b0beae0b80f8a61165f2.

* Conveyor resave

* Fix prediction

* Mob movement rewrite

* Bandaid

* Working version

* Tentatively working

* Friction to fix cornering

* More fixes

* Revert bagel

* Revert this

* Bad parity

* Working

* Fixes

* Woops

* Doc comments

* Pen cap cvar

* StandingState cleanup and sub

* Fix downed mobs

* fish

* client

* Disable pushing on tests

* More variables

* Movement mods

* Mass diff

* 1 more tweak

* Cvar
2025-04-05 00:33:52 +11:00

61 lines
2.4 KiB
C#

using System.Numerics;
using Content.Shared.Movement.Systems;
using Robust.Shared.GameStates;
namespace Content.Shared.Movement.Components;
/// <summary>
/// Handles mobs pushing against each other.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(fieldDeltas: true)]
public sealed partial class MobCollisionComponent : Component
{
// If you want to tweak the feel of the pushing use SpeedModifier and Strength.
// Strength goes both ways and affects how much the other mob is pushed by so controls static pushing a lot.
// Speed mod affects your own mob primarily.
/// <summary>
/// Is this mob currently colliding? Used for SpeedModifier.
/// </summary>
[DataField, AutoNetworkedField]
public bool Colliding;
// TODO: I hate this but also I couldn't quite figure out a way to avoid having to dirty it every tick.
// The issue is it's a time target that changes constantly so we can't just use a timespan.
// However that doesn't mean it should be modified every tick if we're still colliding.
/// <summary>
/// Buffer time for <see cref="SpeedModifier"/> to keep applying after the entities are no longer colliding.
/// Without this you will get jittering unless you are very specific with your values.
/// </summary>
[DataField, AutoNetworkedField]
public float BufferAccumulator = SharedMobCollisionSystem.BufferTime;
/// <summary>
/// The speed modifier for mobs currently pushing.
/// By setting this low you can ensure you don't have to set the push-strength too high if you can push static entities.
/// </summary>
[DataField, AutoNetworkedField]
public float SpeedModifier = 1f;
[DataField, AutoNetworkedField]
public float MinimumSpeedModifier = 0.35f;
/// <summary>
/// Strength of the pushback for entities. This is combined between the 2 entities being pushed.
/// </summary>
[DataField, AutoNetworkedField]
public float Strength = 50f;
// Yes I know, I will deal with it if I ever refactor collision layers due to misuse.
// If anything it probably needs some assurance on mobcollisionsystem for it.
/// <summary>
/// Fixture to listen to for mob collisions.
/// </summary>
[DataField, AutoNetworkedField]
public string FixtureId = "flammable";
[DataField, AutoNetworkedField]
public Vector2 Direction;
}