Reset speed when buckling (#19846)
This commit is contained in:
@@ -29,7 +29,7 @@ internal sealed class BuckleSystem : SharedBuckleSystem
|
||||
component.LastEntityBuckledTo = EnsureEntity<BuckleComponent>(state.LastEntityBuckledTo, uid);
|
||||
component.DontCollide = state.DontCollide;
|
||||
|
||||
ActionBlockerSystem.UpdateCanMove(uid);
|
||||
ActionBlocker.UpdateCanMove(uid);
|
||||
|
||||
if (!TryComp<SpriteComponent>(uid, out var ownerSprite))
|
||||
return;
|
||||
@@ -65,8 +65,8 @@ internal sealed class BuckleSystem : SharedBuckleSystem
|
||||
if (!TryComp<RotationVisualsComponent>(uid, out var rotVisuals))
|
||||
return;
|
||||
|
||||
if (!AppearanceSystem.TryGetData<int>(uid, StrapVisuals.RotationAngle, out var angle, args.Component) ||
|
||||
!AppearanceSystem.TryGetData<bool>(uid, BuckleVisuals.Buckled, out var buckled, args.Component) ||
|
||||
if (!Appearance.TryGetData<int>(uid, StrapVisuals.RotationAngle, out var angle, args.Component) ||
|
||||
!Appearance.TryGetData<bool>(uid, BuckleVisuals.Buckled, out var buckled, args.Component) ||
|
||||
!buckled ||
|
||||
args.Sprite == null)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ using Content.Shared.Throwing;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -71,7 +72,7 @@ public abstract partial class SharedBuckleSystem
|
||||
return;
|
||||
|
||||
var strapPosition = Transform(strapUid).Coordinates;
|
||||
if (ev.NewPosition.InRange(EntityManager, _transformSystem, strapPosition, strapComp.MaxBuckleDistance))
|
||||
if (ev.NewPosition.InRange(EntityManager, _transform, strapPosition, strapComp.MaxBuckleDistance))
|
||||
return;
|
||||
|
||||
TryUnbuckle(uid, uid, true, component);
|
||||
@@ -181,18 +182,18 @@ public abstract partial class SharedBuckleSystem
|
||||
/// <param name="strapComp"> strap component of the thing we are strapping to </param>
|
||||
private void UpdateBuckleStatus(EntityUid uid, BuckleComponent buckleComp, StrapComponent? strapComp = null)
|
||||
{
|
||||
AppearanceSystem.SetData(uid, StrapVisuals.State, buckleComp.Buckled);
|
||||
Appearance.SetData(uid, StrapVisuals.State, buckleComp.Buckled);
|
||||
if (buckleComp.BuckledTo != null)
|
||||
{
|
||||
if (!Resolve(buckleComp.BuckledTo.Value, ref strapComp))
|
||||
return;
|
||||
|
||||
var alertType = strapComp.BuckledAlertType;
|
||||
_alertsSystem.ShowAlert(uid, alertType);
|
||||
_alerts.ShowAlert(uid, alertType);
|
||||
}
|
||||
else
|
||||
{
|
||||
_alertsSystem.ClearAlertCategory(uid, AlertCategory.Buckled);
|
||||
_alerts.ClearAlertCategory(uid, AlertCategory.Buckled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +217,7 @@ public abstract partial class SharedBuckleSystem
|
||||
buckleComp.BuckleTime = _gameTiming.CurTime;
|
||||
}
|
||||
|
||||
ActionBlockerSystem.UpdateCanMove(buckleUid);
|
||||
ActionBlocker.UpdateCanMove(buckleUid);
|
||||
UpdateBuckleStatus(buckleUid, buckleComp, strapComp);
|
||||
Dirty(buckleComp);
|
||||
}
|
||||
@@ -252,24 +253,24 @@ public abstract partial class SharedBuckleSystem
|
||||
!strapComp.AllowedEntities.IsValid(userUid, EntityManager))
|
||||
{
|
||||
if (_netManager.IsServer)
|
||||
_popupSystem.PopupEntity(Loc.GetString("buckle-component-cannot-fit-message"), userUid, buckleUid, PopupType.Medium);
|
||||
_popup.PopupEntity(Loc.GetString("buckle-component-cannot-fit-message"), userUid, buckleUid, PopupType.Medium);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is it within range
|
||||
bool Ignored(EntityUid entity) => entity == buckleUid || entity == userUid || entity == strapUid;
|
||||
|
||||
if (!_interactionSystem.InRangeUnobstructed(buckleUid, strapUid, buckleComp.Range, predicate: Ignored,
|
||||
if (!_interaction.InRangeUnobstructed(buckleUid, strapUid, buckleComp.Range, predicate: Ignored,
|
||||
popup: true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If in a container
|
||||
if (_containerSystem.TryGetContainingContainer(buckleUid, out var ownerContainer))
|
||||
if (_container.TryGetContainingContainer(buckleUid, out var ownerContainer))
|
||||
{
|
||||
// And not in the same container as the strap
|
||||
if (!_containerSystem.TryGetContainingContainer(strapUid, out var strapContainer) ||
|
||||
if (!_container.TryGetContainingContainer(strapUid, out var strapContainer) ||
|
||||
ownerContainer != strapContainer)
|
||||
{
|
||||
return false;
|
||||
@@ -280,7 +281,7 @@ public abstract partial class SharedBuckleSystem
|
||||
{
|
||||
// PopupPredicted when
|
||||
if (_netManager.IsServer)
|
||||
_popupSystem.PopupEntity(Loc.GetString("buckle-component-no-hands-message"), userUid, userUid);
|
||||
_popup.PopupEntity(Loc.GetString("buckle-component-no-hands-message"), userUid, userUid);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -291,7 +292,7 @@ public abstract partial class SharedBuckleSystem
|
||||
: "buckle-component-other-already-buckled-message",
|
||||
("owner", Identity.Entity(buckleUid, EntityManager)));
|
||||
if (_netManager.IsServer)
|
||||
_popupSystem.PopupEntity(message, userUid, userUid);
|
||||
_popup.PopupEntity(message, userUid, userUid);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -305,7 +306,7 @@ public abstract partial class SharedBuckleSystem
|
||||
? "buckle-component-cannot-buckle-message"
|
||||
: "buckle-component-other-cannot-buckle-message", ("owner", Identity.Entity(buckleUid, EntityManager)));
|
||||
if (_netManager.IsServer)
|
||||
_popupSystem.PopupEntity(message, userUid, userUid);
|
||||
_popup.PopupEntity(message, userUid, userUid);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -319,7 +320,7 @@ public abstract partial class SharedBuckleSystem
|
||||
? "buckle-component-cannot-fit-message"
|
||||
: "buckle-component-other-cannot-fit-message", ("owner", Identity.Entity(buckleUid, EntityManager)));
|
||||
if (_netManager.IsServer)
|
||||
_popupSystem.PopupEntity(message, userUid, userUid);
|
||||
_popup.PopupEntity(message, userUid, userUid);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -357,18 +358,18 @@ public abstract partial class SharedBuckleSystem
|
||||
? "buckle-component-cannot-buckle-message"
|
||||
: "buckle-component-other-cannot-buckle-message", ("owner", Identity.Entity(buckleUid, EntityManager)));
|
||||
if (_netManager.IsServer)
|
||||
_popupSystem.PopupEntity(message, userUid, userUid);
|
||||
_popup.PopupEntity(message, userUid, userUid);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TryComp<AppearanceComponent>(buckleUid, out var appearance))
|
||||
AppearanceSystem.SetData(buckleUid, BuckleVisuals.Buckled, true, appearance);
|
||||
Appearance.SetData(buckleUid, BuckleVisuals.Buckled, true, appearance);
|
||||
|
||||
ReAttach(buckleUid, strapUid, buckleComp, strapComp);
|
||||
SetBuckledTo(buckleUid, strapUid, strapComp, buckleComp);
|
||||
// TODO user is currently set to null because if it isn't the sound fails to play in some situations, fix that
|
||||
var audioSourceUid = userUid == buckleUid ? userUid : strapUid;
|
||||
_audioSystem.PlayPredicted(strapComp.BuckleSound, strapUid, audioSourceUid);
|
||||
_audio.PlayPredicted(strapComp.BuckleSound, strapUid, audioSourceUid);
|
||||
|
||||
var ev = new BuckleChangeEvent(strapUid, buckleUid, true);
|
||||
RaiseLocalEvent(ev.BuckledEntity, ref ev);
|
||||
@@ -378,16 +379,21 @@ public abstract partial class SharedBuckleSystem
|
||||
{
|
||||
if (ownerPullable.Puller != null)
|
||||
{
|
||||
_pullingSystem.TryStopPull(ownerPullable);
|
||||
_pulling.TryStopPull(ownerPullable);
|
||||
}
|
||||
}
|
||||
|
||||
if (TryComp<PhysicsComponent>(buckleUid, out var physics))
|
||||
{
|
||||
_physics.ResetDynamics(physics);
|
||||
}
|
||||
|
||||
if (!buckleComp.PullStrap && TryComp<SharedPullableComponent>(strapUid, out var toPullable))
|
||||
{
|
||||
if (toPullable.Puller == buckleUid)
|
||||
{
|
||||
// can't pull it and buckle to it at the same time
|
||||
_pullingSystem.TryStopPull(toPullable);
|
||||
_pulling.TryStopPull(toPullable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +437,7 @@ public abstract partial class SharedBuckleSystem
|
||||
if (_gameTiming.CurTime < buckleComp.BuckleTime + buckleComp.UnbuckleDelay)
|
||||
return false;
|
||||
|
||||
if (!_interactionSystem.InRangeUnobstructed(userUid, strapUid, buckleComp.Range, popup: true))
|
||||
if (!_interaction.InRangeUnobstructed(userUid, strapUid, buckleComp.Range, popup: true))
|
||||
return false;
|
||||
|
||||
if (HasComp<SleepingComponent>(buckleUid) && buckleUid == userUid)
|
||||
@@ -459,32 +465,32 @@ public abstract partial class SharedBuckleSystem
|
||||
|
||||
if (buckleXform.ParentUid == strapUid && !Terminating(buckleXform.ParentUid))
|
||||
{
|
||||
_containerSystem.AttachParentToContainerOrGrid(buckleXform);
|
||||
_container.AttachParentToContainerOrGrid(buckleXform);
|
||||
|
||||
var oldBuckledToWorldRot = _transformSystem.GetWorldRotation(strapUid);
|
||||
_transformSystem.SetWorldRotation(buckleXform, oldBuckledToWorldRot);
|
||||
var oldBuckledToWorldRot = _transform.GetWorldRotation(strapUid);
|
||||
_transform.SetWorldRotation(buckleXform, oldBuckledToWorldRot);
|
||||
|
||||
if (strapComp.UnbuckleOffset != Vector2.Zero)
|
||||
buckleXform.Coordinates = oldBuckledXform.Coordinates.Offset(strapComp.UnbuckleOffset);
|
||||
}
|
||||
|
||||
if (TryComp(buckleUid, out AppearanceComponent? appearance))
|
||||
AppearanceSystem.SetData(buckleUid, BuckleVisuals.Buckled, false, appearance);
|
||||
Appearance.SetData(buckleUid, BuckleVisuals.Buckled, false, appearance);
|
||||
|
||||
if (TryComp<MobStateComponent>(buckleUid, out var mobState)
|
||||
&& _mobStateSystem.IsIncapacitated(buckleUid, mobState)
|
||||
&& _mobState.IsIncapacitated(buckleUid, mobState)
|
||||
|| HasComp<KnockedDownComponent>(buckleUid))
|
||||
{
|
||||
_standingSystem.Down(buckleUid);
|
||||
_standing.Down(buckleUid);
|
||||
}
|
||||
else
|
||||
{
|
||||
_standingSystem.Stand(buckleUid);
|
||||
_standing.Stand(buckleUid);
|
||||
}
|
||||
|
||||
if (_mobStateSystem.IsIncapacitated(buckleUid, mobState))
|
||||
if (_mobState.IsIncapacitated(buckleUid, mobState))
|
||||
{
|
||||
_standingSystem.Down(buckleUid);
|
||||
_standing.Down(buckleUid);
|
||||
}
|
||||
if (strapComp.BuckledEntities.Remove(buckleUid))
|
||||
{
|
||||
@@ -494,9 +500,9 @@ public abstract partial class SharedBuckleSystem
|
||||
}
|
||||
|
||||
_joints.RefreshRelay(buckleUid);
|
||||
AppearanceSystem.SetData(strapUid, StrapVisuals.State, strapComp.BuckledEntities.Count != 0);
|
||||
Appearance.SetData(strapUid, StrapVisuals.State, strapComp.BuckledEntities.Count != 0);
|
||||
var audioSourceUid = userUid != buckleUid ? userUid : strapUid;
|
||||
_audioSystem.PlayPredicted(strapComp.UnbuckleSound, strapUid, audioSourceUid);
|
||||
_audio.PlayPredicted(strapComp.UnbuckleSound, strapUid, audioSourceUid);
|
||||
|
||||
var ev = new BuckleChangeEvent(strapUid, buckleUid, false);
|
||||
RaiseLocalEvent(buckleUid, ref ev);
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract partial class SharedBuckleSystem
|
||||
|
||||
private void OnStrapStartup(EntityUid uid, StrapComponent component, ComponentStartup args)
|
||||
{
|
||||
AppearanceSystem.SetData(uid, StrapVisuals.State, component.BuckledEntities.Count != 0);
|
||||
Appearance.SetData(uid, StrapVisuals.State, component.BuckledEntities.Count != 0);
|
||||
}
|
||||
|
||||
private void OnStrapShutdown(EntityUid uid, StrapComponent component, ComponentShutdown args)
|
||||
@@ -90,8 +90,8 @@ public abstract partial class SharedBuckleSystem
|
||||
!Resolve(strapUid, ref strapComp, false))
|
||||
return;
|
||||
|
||||
var contained = _containerSystem.TryGetContainingContainer(buckleUid, out var ownContainer);
|
||||
var strapContained = _containerSystem.TryGetContainingContainer(strapUid, out var strapContainer);
|
||||
var contained = _container.TryGetContainingContainer(buckleUid, out var ownContainer);
|
||||
var strapContained = _container.TryGetContainingContainer(strapUid, out var strapContainer);
|
||||
|
||||
if (contained != strapContained || ownContainer != strapContainer)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ public abstract partial class SharedBuckleSystem
|
||||
{
|
||||
var buckledComp = Comp<BuckleComponent>(entity);
|
||||
|
||||
if (!_interactionSystem.InRangeUnobstructed(args.User, args.Target, range: buckledComp.Range))
|
||||
if (!_interaction.InRangeUnobstructed(args.User, args.Target, range: buckledComp.Range))
|
||||
continue;
|
||||
|
||||
var verb = new InteractionVerb()
|
||||
@@ -158,7 +158,7 @@ public abstract partial class SharedBuckleSystem
|
||||
buckle.BuckledTo != uid &&
|
||||
args.User != uid &&
|
||||
StrapHasSpace(uid, buckle, component) &&
|
||||
_interactionSystem.InRangeUnobstructed(args.User, args.Target, range: buckle.Range))
|
||||
_interaction.InRangeUnobstructed(args.User, args.Target, range: buckle.Range))
|
||||
{
|
||||
InteractionVerb verb = new()
|
||||
{
|
||||
@@ -173,11 +173,11 @@ public abstract partial class SharedBuckleSystem
|
||||
if (args.Using is {Valid: true} @using &&
|
||||
TryComp<BuckleComponent>(@using, out var usingBuckle) &&
|
||||
StrapHasSpace(uid, usingBuckle, component) &&
|
||||
_interactionSystem.InRangeUnobstructed(@using, args.Target, range: usingBuckle.Range))
|
||||
_interaction.InRangeUnobstructed(@using, args.Target, range: usingBuckle.Range))
|
||||
{
|
||||
// Check that the entity is unobstructed from the target (ignoring the user).
|
||||
bool Ignored(EntityUid entity) => entity == args.User || entity == args.Target || entity == @using;
|
||||
if (!_interactionSystem.InRangeUnobstructed(@using, args.Target, usingBuckle.Range, predicate: Ignored))
|
||||
if (!_interaction.InRangeUnobstructed(@using, args.Target, usingBuckle.Range, predicate: Ignored))
|
||||
return;
|
||||
|
||||
var isPlayer = _playerManager.TryGetSessionByEntity(@using, out var _);
|
||||
@@ -269,7 +269,7 @@ public abstract partial class SharedBuckleSystem
|
||||
|
||||
bool Ignored(EntityUid entity) => entity == userUid || entity == buckleUid || entity == targetUid;
|
||||
|
||||
return _interactionSystem.InRangeUnobstructed(targetUid, buckleUid, buckleComp.Range, predicate: Ignored);
|
||||
return _interaction.InRangeUnobstructed(targetUid, buckleUid, buckleComp.Range, predicate: Ignored);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -312,9 +312,9 @@ public abstract partial class SharedBuckleSystem
|
||||
|
||||
strapComp.OccupiedSize += buckleComp.Size;
|
||||
|
||||
AppearanceSystem.SetData(buckleUid, StrapVisuals.RotationAngle, strapComp.Rotation);
|
||||
Appearance.SetData(buckleUid, StrapVisuals.RotationAngle, strapComp.Rotation);
|
||||
|
||||
AppearanceSystem.SetData(strapUid, StrapVisuals.State, true);
|
||||
Appearance.SetData(strapUid, StrapVisuals.State, true);
|
||||
|
||||
Dirty(strapUid, strapComp);
|
||||
return true;
|
||||
|
||||
@@ -23,18 +23,20 @@ public abstract partial class SharedBuckleSystem : EntitySystem
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;
|
||||
|
||||
[Dependency] protected readonly ActionBlockerSystem ActionBlockerSystem = default!;
|
||||
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
||||
[Dependency] protected readonly SharedAppearanceSystem AppearanceSystem = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||
[Dependency] protected readonly ActionBlockerSystem ActionBlocker = default!;
|
||||
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
|
||||
|
||||
[Dependency] private readonly AlertsSystem _alerts = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
|
||||
[Dependency] private readonly SharedJointSystem _joints = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly SharedPullingSystem _pullingSystem = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly StandingStateSystem _standingSystem = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly SharedPullingSystem _pulling = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly StandingStateSystem _standing = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
@@ -63,16 +65,16 @@ public abstract partial class SharedBuckleSystem : EntitySystem
|
||||
|| !Resolve(buckleUid, ref buckleComp, false))
|
||||
return;
|
||||
|
||||
var buckleTransform = Transform(buckleUid);
|
||||
_transform.SetCoordinates(buckleUid, new EntityCoordinates(strapUid, strapComp.BuckleOffset));
|
||||
|
||||
buckleTransform.Coordinates = new EntityCoordinates(strapUid, strapComp.BuckleOffset);
|
||||
var buckleTransform = Transform(buckleUid);
|
||||
|
||||
// Buckle subscribes to move for <reasons> so this might fail.
|
||||
// TODO: Make buckle not do that.
|
||||
if (buckleTransform.ParentUid != strapUid)
|
||||
return;
|
||||
|
||||
_transformSystem.SetLocalRotation(buckleUid, Angle.Zero, buckleTransform);
|
||||
_transform.SetLocalRotation(buckleUid, Angle.Zero, buckleTransform);
|
||||
_joints.RefreshRelay(buckleUid, strapUid);
|
||||
|
||||
switch (strapComp.Position)
|
||||
@@ -80,10 +82,10 @@ public abstract partial class SharedBuckleSystem : EntitySystem
|
||||
case StrapPosition.None:
|
||||
break;
|
||||
case StrapPosition.Stand:
|
||||
_standingSystem.Stand(buckleUid);
|
||||
_standing.Stand(buckleUid);
|
||||
break;
|
||||
case StrapPosition.Down:
|
||||
_standingSystem.Down(buckleUid, false, false);
|
||||
_standing.Down(buckleUid, false, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user