コード例 #1
0
    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);

        var fellEvent = new FellDownEvent(uid);

        RaiseLocalEvent(uid, fellEvent, false);

        if (!TryComp(uid, out SharedHandsComponent? handsComp))
        {
            return;
        }

        var worldRotation = EntityManager.GetComponent <TransformComponent>(uid).WorldRotation.ToVec();

        foreach (var hand in handsComp.Hands.Values)
        {
            if (hand.HeldEntity is not EntityUid held)
            {
                continue;
            }

            if (!_handsSystem.TryDrop(uid, hand, null, checkActionBlocker: false, handsComp: handsComp))
            {
                continue;
            }

            _throwingSystem.TryThrow(held,
                                     _random.NextAngle().RotateVec(direction / dropAngle + worldRotation / 50),
                                     0.5f * dropAngle * _random.NextFloat(-0.9f, 1.1f),
                                     uid, 0);
        }
    }
コード例 #2
0
 /// <summary>
 /// Kick the rider off the vehicle if they get stunned
 /// </summary>
 private void OnFallDown(EntityUid uid, RiderComponent rider, FellDownEvent args)
 {
     UnbuckleFromVehicle(uid);
 }