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

@@ -125,7 +125,7 @@ namespace Content.Shared.Stunnable
if (!_standingStateSystem.Down(uid, standingState:standingState, appearance:appearance))
return;
stunnable.KnockdownTimer = (_gameTiming.CurTime, _gameTiming.CurTime + time);;
stunnable.KnockdownTimer = (_gameTiming.CurTime, _gameTiming.CurTime + time);
SetAlert(uid, stunnable, alerts);
@@ -144,8 +144,8 @@ namespace Content.Shared.Stunnable
// Optional component.
Resolve(uid, ref alerts, false);
Stun(uid, time, stunnable, alerts);
Knockdown(uid, time, stunnable, alerts);
Stun(uid, time, stunnable, alerts);
}
/// <summary>

View File

@@ -1,12 +1,26 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Throwing
{
[RegisterComponent]
[RegisterComponent, NetworkedComponent]
public class ThrownItemComponent : Component
{
public override string Name => "ThrownItem";
public IEntity? Thrower { get; set; }
}
[Serializable, NetSerializable]
public class ThrownItemComponentState : ComponentState
{
public EntityUid? Thrower { get; }
public ThrownItemComponentState(EntityUid? thrower)
{
Thrower = thrower;
}
}
}

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) ||

View File

@@ -0,0 +1,4 @@
author: Zumorica
changes:
- type: Fix # One of the following: Add, Remove, Tweak, Fix
message: Fixes thrown slippery items causing the thrower to become horizontal when they shouldn't.