Remove serverside StandingStateSystem (#35999)

Refactor system
This commit is contained in:
SlamBamActionman
2025-03-22 06:00:21 +01:00
committed by GitHub
parent dacf0d915c
commit 71ae9257f7
3 changed files with 199 additions and 209 deletions

View File

@@ -15,10 +15,12 @@ using Content.Shared.Movement.Pulling.Components;
using Content.Shared.Movement.Pulling.Events;
using Content.Shared.Movement.Pulling.Systems;
using Content.Shared.Stacks;
using Content.Shared.Standing;
using Content.Shared.Throwing;
using Robust.Shared.GameStates;
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Timing;
@@ -53,6 +55,8 @@ namespace Content.Server.Hands.Systems
SubscribeLocalEvent<HandsComponent, BeforeExplodeEvent>(OnExploded);
SubscribeLocalEvent<HandsComponent, DropHandItemsEvent>(OnDropHandItems);
CommandBinds.Builder
.Bind(ContentKeyFunctions.ThrowItemInHand, new PointerInputCmdHandler(HandleThrowItem))
.Register<HandsSystem>();
@@ -228,6 +232,36 @@ namespace Content.Server.Hands.Systems
return true;
}
private void OnDropHandItems(Entity<HandsComponent> entity, ref DropHandItemsEvent args)
{
var direction = EntityManager.TryGetComponent(entity, out PhysicsComponent? comp) ? comp.LinearVelocity / 50 : Vector2.Zero;
var dropAngle = _random.NextFloat(0.8f, 1.2f);
var fellEvent = new FellDownEvent(entity);
RaiseLocalEvent(entity, fellEvent, false);
var worldRotation = TransformSystem.GetWorldRotation(entity).ToVec();
foreach (var hand in entity.Comp.Hands.Values)
{
if (hand.HeldEntity is not EntityUid held)
continue;
var throwAttempt = new FellDownThrowAttemptEvent(entity);
RaiseLocalEvent(hand.HeldEntity.Value, ref throwAttempt);
if (throwAttempt.Cancelled)
continue;
if (!TryDrop(entity, hand, null, checkActionBlocker: false, handsComp: entity.Comp))
continue;
_throwingSystem.TryThrow(held,
_random.NextAngle().RotateVec(direction / dropAngle + worldRotation / 50),
0.5f * dropAngle * _random.NextFloat(-0.9f, 1.1f),
entity, 0);
}
}
#endregion
}
}