Travelling pointing arrows, brains can no longer point (#24864)
* Decoupled from gravity, constant animation time, manual networking, cubic interpolation * Reduced overshoot * Implemented PointAttemptEvent, reacts with mobstate & sleeping * Brains can no longer point, PBs must be inside a chassis * Removed chassis check, made callback more obvious
This commit is contained in:
@@ -2,6 +2,7 @@ using Content.Shared.Actions;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
using Content.Shared.Damage.ForceSay;
|
||||
using Content.Shared.Eye.Blinding.Systems;
|
||||
using Content.Shared.Pointing;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -25,6 +26,7 @@ namespace Content.Server.Bed.Sleep
|
||||
SubscribeLocalEvent<SleepingComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<SleepingComponent, SpeakAttemptEvent>(OnSpeakAttempt);
|
||||
SubscribeLocalEvent<SleepingComponent, CanSeeAttemptEvent>(OnSeeAttempt);
|
||||
SubscribeLocalEvent<SleepingComponent, PointAttemptEvent>(OnPointAttempt);
|
||||
SubscribeLocalEvent<SleepingComponent, EntityUnpausedEvent>(OnSleepUnpaused);
|
||||
}
|
||||
|
||||
@@ -70,6 +72,11 @@ namespace Content.Server.Bed.Sleep
|
||||
if (component.LifeStage <= ComponentLifeStage.Running)
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnPointAttempt(EntityUid uid, SleepingComponent component, PointAttemptEvent args)
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Pointing;
|
||||
using Content.Shared.Pulling.Events;
|
||||
using Content.Shared.Speech;
|
||||
using Content.Shared.Standing;
|
||||
@@ -38,6 +39,7 @@ public partial class MobStateSystem
|
||||
SubscribeLocalEvent<MobStateComponent, StartPullAttemptEvent>(CheckAct);
|
||||
SubscribeLocalEvent<MobStateComponent, UpdateCanMoveEvent>(CheckAct);
|
||||
SubscribeLocalEvent<MobStateComponent, StandAttemptEvent>(CheckAct);
|
||||
SubscribeLocalEvent<MobStateComponent, PointAttemptEvent>(CheckAct);
|
||||
SubscribeLocalEvent<MobStateComponent, TryingToSleepEvent>(OnSleepAttempt);
|
||||
SubscribeLocalEvent<MobStateComponent, CombatModeShouldHandInteractEvent>(OnCombatModeShouldHandInteract);
|
||||
SubscribeLocalEvent<MobStateComponent, AttemptPacifiedAttackEvent>(OnAttemptPacifiedAttack);
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Content.Shared.Pointing.Components;
|
||||
|
||||
[NetworkedComponent]
|
||||
public abstract partial class SharedPointingArrowComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The position of the sender when the point began.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Vector2 StartPosition;
|
||||
|
||||
/// <summary>
|
||||
/// When the pointing arrow ends
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("endTime")]
|
||||
[DataField]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public TimeSpan EndTime;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,36 @@
|
||||
using Robust.Shared.Serialization;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Content.Shared.Pointing;
|
||||
|
||||
public abstract class SharedPointingSystem : EntitySystem
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
protected sealed class PointingArrowComponentState : ComponentState
|
||||
{
|
||||
public TimeSpan EndTime;
|
||||
protected readonly TimeSpan PointDuration = TimeSpan.FromSeconds(4);
|
||||
protected readonly float PointKeyTimeMove = 0.1f;
|
||||
protected readonly float PointKeyTimeHover = 0.5f;
|
||||
|
||||
public PointingArrowComponentState(TimeSpan endTime)
|
||||
{
|
||||
EndTime = endTime;
|
||||
}
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class SharedPointingArrowComponentState : ComponentState
|
||||
{
|
||||
public Vector2 StartPosition { get; init; }
|
||||
public TimeSpan EndTime { get; init; }
|
||||
}
|
||||
|
||||
public bool CanPoint(EntityUid uid)
|
||||
{
|
||||
var ev = new PointAttemptEvent(uid);
|
||||
RaiseLocalEvent(uid, ev, true);
|
||||
|
||||
return !ev.Cancelled;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class PointAttemptEvent : CancellableEntityEventArgs
|
||||
{
|
||||
public PointAttemptEvent(EntityUid uid)
|
||||
{
|
||||
Uid = uid;
|
||||
}
|
||||
|
||||
public EntityUid Uid { get; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user