Pulling rework v2 (#24936)

* Pulling rework

Fixing up the FOUR systems managing pulling, all the shitcode, and also making it nicer ingame.

* More pulling cleanup

* stats

* More cleanup

* First draft

* More pulling

* weh

* Fix puller

* Pulling working

* Fix merge

* Dunked

* Self-merge time

* Fix hotkey

* Fix container changes

* oop

* Fix multi-pulling

* Move alerts cleanup.

* pulling fixes
This commit is contained in:
metalgearsloth
2024-03-19 14:30:56 +11:00
committed by GitHub
parent f8b54a06b7
commit c584f6444a
53 changed files with 797 additions and 1357 deletions

View File

@@ -20,6 +20,11 @@ public sealed class ThrowingSystem : EntitySystem
{
public const float ThrowAngularImpulse = 5f;
/// <summary>
/// Speed cap on rotation in case of click-spam.
/// </summary>
public const float ThrowAngularCap = 3f * MathF.PI;
public const float PushbackDefault = 2f;
/// <summary>
@@ -42,15 +47,17 @@ public sealed class ThrowingSystem : EntitySystem
float strength = 1.0f,
EntityUid? user = null,
float pushbackRatio = PushbackDefault,
bool recoil = true,
bool animated = true,
bool playSound = true)
{
var thrownPos = Transform(uid).MapPosition;
var mapPos = coordinates.ToMap(EntityManager, _transform);
var thrownPos = _transform.GetMapCoordinates(uid);
var mapPos = _transform.ToMapCoordinates(coordinates);
if (mapPos.MapId != thrownPos.MapId)
return;
TryThrow(uid, mapPos.Position - thrownPos.Position, strength, user, pushbackRatio, playSound);
TryThrow(uid, mapPos.Position - thrownPos.Position, strength, user, pushbackRatio, recoil: recoil, animated: animated, playSound: playSound);
}
/// <summary>
@@ -65,6 +72,8 @@ public sealed class ThrowingSystem : EntitySystem
float strength = 1.0f,
EntityUid? user = null,
float pushbackRatio = PushbackDefault,
bool recoil = true,
bool animated = true,
bool playSound = true)
{
var physicsQuery = GetEntityQuery<PhysicsComponent>();
@@ -72,7 +81,6 @@ public sealed class ThrowingSystem : EntitySystem
return;
var projectileQuery = GetEntityQuery<ProjectileComponent>();
var tagQuery = GetEntityQuery<TagComponent>();
TryThrow(
uid,
@@ -82,8 +90,7 @@ public sealed class ThrowingSystem : EntitySystem
projectileQuery,
strength,
user,
pushbackRatio,
playSound);
pushbackRatio, recoil: recoil, animated: animated, playSound: playSound);
}
/// <summary>
@@ -101,6 +108,8 @@ public sealed class ThrowingSystem : EntitySystem
float strength = 1.0f,
EntityUid? user = null,
float pushbackRatio = PushbackDefault,
bool recoil = true,
bool animated = true,
bool playSound = true)
{
if (strength <= 0 || direction == Vector2Helpers.Infinity || direction == Vector2Helpers.NaN || direction == Vector2.Zero)
@@ -116,12 +125,17 @@ public sealed class ThrowingSystem : EntitySystem
if (projectileQuery.TryGetComponent(uid, out var proj) && !proj.OnlyCollideWhenShot)
return;
var comp = new ThrownItemComponent();
comp.Thrower = user;
var comp = new ThrownItemComponent
{
Thrower = user,
Animate = animated,
};
// Estimate time to arrival so we can apply OnGround status and slow it much faster.
var time = direction.Length() / strength;
comp.ThrownTime = _gameTiming.CurTime;
// TODO: This is a bandaid, don't do this.
// if you want to force landtime have the caller handle it or add a new method.
// did we launch this with something stronger than our hands?
if (TryComp<HandsComponent>(comp.Thrower, out var hands) && strength > hands.ThrowForceMultiplier)
comp.LandTime = comp.ThrownTime + TimeSpan.FromSeconds(time);
@@ -166,7 +180,8 @@ public sealed class ThrowingSystem : EntitySystem
if (user == null)
return;
_recoil.KickCamera(user.Value, -direction * 0.04f);
if (recoil)
_recoil.KickCamera(user.Value, -direction * 0.04f);
// Give thrower an impulse in the other direction
if (pushbackRatio != 0.0f &&