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 (!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); } }
private void MoveSingulo(ServerSingularityComponent singularity, PhysicsComponent physics) { // TODO: Need to make this events instead. if (singularity.Level <= 1) { physics.BodyStatus = BodyStatus.OnGround; return; } // TODO: Could try gradual changes instead var pushAngle = _robustRandom.NextAngle(); var pushStrength = _robustRandom.NextFloat(0.75f, 1.0f); physics.LinearVelocity = Vector2.Zero; physics.BodyStatus = BodyStatus.InAir; physics.ApplyLinearImpulse(pushAngle.ToVec() * (pushStrength + 10f / Math.Min(singularity.Level, 4) * physics.Mass)); // TODO: Speedcap it probably? }
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)) { return; } foreach (var heldItem in hands.GetAllHeldItems()) { if (!hands.Drop(heldItem.Owner)) { continue; } var worldRotation = EntityManager.GetComponent <TransformComponent>(uid).WorldRotation.ToVec(); Throwing.ThrowHelper.TryThrow(heldItem.Owner, _random.NextAngle().RotateVec(direction / dropAngle + worldRotation / 50), 0.5f * dropAngle * _random.NextFloat(-0.9f, 1.1f), uid, 0); } }