Improve throwing precision (#29726)

* improve throwing precision

* remove debugging logs

* minor fixes

* f

* Update Content.Shared/Throwing/LandAtCursorComponent.cs

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
slarticodefast
2024-07-08 11:03:53 +02:00
committed by GitHub
parent c8a87ceaab
commit 92e2980534
18 changed files with 93 additions and 39 deletions

View File

@@ -207,13 +207,13 @@ namespace Content.Server.Hands.Systems
var length = direction.Length();
var distance = Math.Clamp(length, minDistance, hands.ThrowRange);
direction *= distance/length;
direction *= distance / length;
var throwStrength = hands.ThrowForceMultiplier;
var throwSpeed = hands.BaseThrowspeed;
// Let other systems change the thrown entity (useful for virtual items)
// or the throw strength.
var ev = new BeforeThrowEvent(throwEnt, direction, throwStrength, player);
var ev = new BeforeThrowEvent(throwEnt, direction, throwSpeed, player);
RaiseLocalEvent(player, ref ev);
if (ev.Cancelled)
@@ -223,7 +223,7 @@ namespace Content.Server.Hands.Systems
if (IsHolding(player, throwEnt, out _, hands) && !TryDrop(player, throwEnt, handsComp: hands))
return false;
_throwingSystem.TryThrow(ev.ItemUid, ev.Direction, ev.ThrowStrength, ev.PlayerUid);
_throwingSystem.TryThrow(ev.ItemUid, ev.Direction, ev.ThrowSpeed, ev.PlayerUid, compensateFriction: !HasComp<LandAtCursorComponent>(ev.ItemUid));
return true;
}