This commit is contained in:
Leon Friedrich
2022-03-17 20:13:31 +13:00
committed by GitHub
parent 7b84362901
commit bfd95c493b
94 changed files with 1454 additions and 2185 deletions

View File

@@ -1,8 +1,6 @@
using Content.Server.Hands.Components;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Standing;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Random;
namespace Content.Server.Standing;
@@ -10,22 +8,26 @@ namespace Content.Server.Standing;
public sealed class StandingStateSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
private void FallOver(EntityUid uid, StandingStateComponent component, DropHandItemsEvent args)
{
var direction = EntityManager.TryGetComponent(uid, out PhysicsComponent? comp) ? comp.LinearVelocity / 50 : Vector2.Zero;
var dropAngle = _random.NextFloat(0.8f, 1.2f);
if (!EntityManager.TryGetComponent(uid, out HandsComponent? hands))
if (!TryComp(uid, out SharedHandsComponent? handsComp))
return;
foreach (var heldItem in hands.GetAllHeldItems())
var worldRotation = EntityManager.GetComponent<TransformComponent>(uid).WorldRotation.ToVec();
foreach (var hand in handsComp.Hands.Values)
{
if (!hands.Drop(heldItem.Owner, false))
if (hand.HeldEntity is not EntityUid held)
continue;
var worldRotation = EntityManager.GetComponent<TransformComponent>(uid).WorldRotation.ToVec();
Throwing.ThrowHelper.TryThrow(heldItem.Owner,
if (!_handsSystem.TryDrop(uid, hand, null, checkActionBlocker: false, handsComp: handsComp))
continue;
Throwing.ThrowHelper.TryThrow(held,
_random.NextAngle().RotateVec(direction / dropAngle + worldRotation / 50),
0.5f * dropAngle * _random.NextFloat(-0.9f, 1.1f),
uid, 0);