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;
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);
/// <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);
}
}
buckleComp.BuckleTime = _gameTiming.CurTime;
}
- ActionBlockerSystem.UpdateCanMove(buckleUid);
+ ActionBlocker.UpdateCanMove(buckleUid);
UpdateBuckleStatus(buckleUid, buckleComp, strapComp);
Dirty(buckleComp);
}
!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;
{
// 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;
}
: "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;
}
? "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;
}
? "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;
}
/// <param name="strapUid"> Uid of the owner of strap component </param>
public bool TryBuckle(EntityUid buckleUid, EntityUid userUid, EntityUid strapUid, BuckleComponent? buckleComp = null)
{
- if (!Resolve(buckleUid, ref buckleComp, false))
+ if (!Resolve(buckleUid, ref buckleComp, false))
return false;
- if (!CanBuckle(buckleUid, userUid, strapUid, out var strapComp, buckleComp))
- return false;
+ if (!CanBuckle(buckleUid, userUid, strapUid, out var strapComp, buckleComp))
+ return false;
- if (!StrapTryAdd(strapUid, buckleUid, buckleComp, false, strapComp))
- {
- var message = Loc.GetString(buckleUid == userUid
- ? "buckle-component-cannot-buckle-message"
- : "buckle-component-other-cannot-buckle-message", ("owner", Identity.Entity(buckleUid, EntityManager)));
+ if (!StrapTryAdd(strapUid, buckleUid, buckleComp, false, strapComp))
+ {
+ var message = Loc.GetString(buckleUid == userUid
+ ? "buckle-component-cannot-buckle-message"
+ : "buckle-component-other-cannot-buckle-message", ("owner", Identity.Entity(buckleUid, EntityManager)));
if (_netManager.IsServer)
- _popupSystem.PopupEntity(message, userUid, userUid);
- return false;
- }
-
- if (TryComp<AppearanceComponent>(buckleUid, out var appearance))
- AppearanceSystem.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);
-
- var ev = new BuckleChangeEvent(strapUid, buckleUid, true);
- RaiseLocalEvent(ev.BuckledEntity, ref ev);
- RaiseLocalEvent(ev.StrapEntity, ref ev);
-
- if (TryComp<SharedPullableComponent>(buckleUid, out var ownerPullable))
- {
- if (ownerPullable.Puller != null)
- {
- _pullingSystem.TryStopPull(ownerPullable);
- }
- }
-
- 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);
- }
- }
-
- // Logging
- if (userUid != buckleUid)
- _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(userUid):player} buckled {ToPrettyString(buckleUid)} to {ToPrettyString(strapUid)}");
- else
- _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(userUid):player} buckled themselves to {ToPrettyString(strapUid)}");
-
- return true;
+ _popup.PopupEntity(message, userUid, userUid);
+ return false;
+ }
+
+ if (TryComp<AppearanceComponent>(buckleUid, out var 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;
+ _audio.PlayPredicted(strapComp.BuckleSound, strapUid, audioSourceUid);
+
+ var ev = new BuckleChangeEvent(strapUid, buckleUid, true);
+ RaiseLocalEvent(ev.BuckledEntity, ref ev);
+ RaiseLocalEvent(ev.StrapEntity, ref ev);
+
+ if (TryComp<SharedPullableComponent>(buckleUid, out var ownerPullable))
+ {
+ if (ownerPullable.Puller != null)
+ {
+ _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
+ _pulling.TryStopPull(toPullable);
+ }
+ }
+
+ // Logging
+ if (userUid != buckleUid)
+ _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(userUid):player} buckled {ToPrettyString(buckleUid)} to {ToPrettyString(strapUid)}");
+ else
+ _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(userUid):player} buckled themselves to {ToPrettyString(strapUid)}");
+
+ return true;
}
/// <summary>
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)
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))
{
}
_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);
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)
!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)
{
{
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()
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()
{
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 _);
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>
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;
[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] 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] 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 _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()
|| !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)
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;
}
}