Fix ThrownItemComponent's Thrower not being synced with the client.

- Fixes throwing banana peels making people become horizontal... On the client only.
This commit is contained in:
Vera Aguilera Puerto
2021-10-12 21:58:11 +02:00
parent 26c77a0d0b
commit 95c78020f6
4 changed files with 38 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ using Content.Shared.Physics.Pull;
using Robust.Shared.Configuration;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Maths;
@@ -32,9 +33,25 @@ namespace Content.Shared.Throwing
SubscribeLocalEvent<ThrownItemComponent, StartCollideEvent>(HandleCollision);
SubscribeLocalEvent<ThrownItemComponent, PreventCollideEvent>(PreventCollision);
SubscribeLocalEvent<ThrownItemComponent, ThrownEvent>(ThrowItem);
SubscribeLocalEvent<ThrownItemComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<ThrownItemComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<PullStartedMessage>(HandlePullStarted);
}
private void OnGetState(EntityUid uid, ThrownItemComponent component, ref ComponentGetState args)
{
args.State = new ThrownItemComponentState(component.Thrower?.Uid);
}
private void OnHandleState(EntityUid uid, ThrownItemComponent component, ref ComponentHandleState args)
{
if (args.Current is not ThrownItemComponentState state || state.Thrower == null)
return;
if(EntityManager.TryGetEntity(state.Thrower.Value, out var entity))
component.Thrower = entity;
}
private void ThrowItem(EntityUid uid, ThrownItemComponent component, ThrownEvent args)
{
if (!component.Owner.TryGetComponent(out PhysicsComponent? physicsComponent) ||