2023-05-01 03:04:23 -04:00
|
|
|
using Content.Shared.ActionBlocker;
|
|
|
|
|
using Content.Shared.Administration.Logs;
|
|
|
|
|
using Content.Shared.Alert;
|
|
|
|
|
using Content.Shared.Buckle.Components;
|
|
|
|
|
using Content.Shared.Interaction;
|
|
|
|
|
using Content.Shared.Mobs.Systems;
|
|
|
|
|
using Content.Shared.Popups;
|
|
|
|
|
using Content.Shared.Pulling;
|
2021-06-27 19:02:46 +10:00
|
|
|
using Content.Shared.Standing;
|
2024-04-22 22:14:23 +07:00
|
|
|
using Content.Shared.Standing.Systems;
|
2023-11-27 22:12:34 +11:00
|
|
|
using Robust.Shared.Audio;
|
|
|
|
|
using Robust.Shared.Audio.Systems;
|
2023-05-01 03:04:23 -04:00
|
|
|
using Robust.Shared.Containers;
|
|
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
using Robust.Shared.Network;
|
2023-08-05 04:47:52 +10:00
|
|
|
using Robust.Shared.Physics.Systems;
|
2023-10-28 09:59:53 +11:00
|
|
|
using Robust.Shared.Player;
|
2022-08-22 12:44:37 +12:00
|
|
|
using Robust.Shared.Timing;
|
2024-03-19 14:30:56 +11:00
|
|
|
using PullingSystem = Content.Shared.Movement.Pulling.Systems.PullingSystem;
|
2021-05-30 23:30:44 +10:00
|
|
|
|
2022-11-14 20:30:30 +01:00
|
|
|
namespace Content.Shared.Buckle;
|
|
|
|
|
|
2022-11-18 22:08:28 +01:00
|
|
|
public abstract partial class SharedBuckleSystem : EntitySystem
|
2021-05-30 23:30:44 +10:00
|
|
|
{
|
2023-05-01 03:04:23 -04:00
|
|
|
[Dependency] private readonly INetManager _netManager = default!;
|
|
|
|
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
|
|
|
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
|
|
|
|
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;
|
2022-11-14 20:30:30 +01:00
|
|
|
|
2023-09-16 07:15:05 +03:00
|
|
|
[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!;
|
2024-03-19 14:30:56 +11:00
|
|
|
[Dependency] private readonly PullingSystem _pulling = default!;
|
2023-09-16 07:15:05 +03:00
|
|
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
2024-04-22 22:14:23 +07:00
|
|
|
[Dependency] private readonly SharedStandingStateSystem _standing = default!;
|
2023-09-16 07:15:05 +03:00
|
|
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
2022-11-14 20:30:30 +01:00
|
|
|
|
2023-05-01 03:04:23 -04:00
|
|
|
/// <inheritdoc/>
|
2022-11-14 20:30:30 +01:00
|
|
|
public override void Initialize()
|
2021-05-30 23:30:44 +10:00
|
|
|
{
|
2022-11-14 20:30:30 +01:00
|
|
|
base.Initialize();
|
2022-08-22 12:44:37 +12:00
|
|
|
|
2023-05-01 03:04:23 -04:00
|
|
|
UpdatesAfter.Add(typeof(SharedInteractionSystem));
|
|
|
|
|
UpdatesAfter.Add(typeof(SharedInputSystem));
|
|
|
|
|
|
2022-11-18 22:08:28 +01:00
|
|
|
InitializeBuckle();
|
|
|
|
|
InitializeStrap();
|
2021-05-30 23:30:44 +10:00
|
|
|
}
|
2023-05-01 03:04:23 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reattaches this entity to the strap, modifying its position and rotation.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buckleUid">The entity to reattach.</param>
|
|
|
|
|
/// <param name="strapUid">The entity to reattach the buckleUid entity to.</param>
|
|
|
|
|
private void ReAttach(
|
|
|
|
|
EntityUid buckleUid,
|
|
|
|
|
EntityUid strapUid,
|
|
|
|
|
BuckleComponent? buckleComp = null,
|
|
|
|
|
StrapComponent? strapComp = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(strapUid, ref strapComp, false)
|
|
|
|
|
|| !Resolve(buckleUid, ref buckleComp, false))
|
|
|
|
|
return;
|
|
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
_transform.SetCoordinates(buckleUid, new EntityCoordinates(strapUid, strapComp.BuckleOffsetClamped));
|
2023-05-01 03:04:23 -04:00
|
|
|
|
2023-09-16 07:15:05 +03:00
|
|
|
var buckleTransform = Transform(buckleUid);
|
2023-05-01 03:04:23 -04:00
|
|
|
|
|
|
|
|
// Buckle subscribes to move for <reasons> so this might fail.
|
|
|
|
|
// TODO: Make buckle not do that.
|
|
|
|
|
if (buckleTransform.ParentUid != strapUid)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-09-16 07:15:05 +03:00
|
|
|
_transform.SetLocalRotation(buckleUid, Angle.Zero, buckleTransform);
|
2023-10-22 16:53:15 +11:00
|
|
|
_joints.SetRelay(buckleUid, strapUid);
|
2023-05-01 03:04:23 -04:00
|
|
|
|
|
|
|
|
switch (strapComp.Position)
|
|
|
|
|
{
|
|
|
|
|
case StrapPosition.None:
|
|
|
|
|
break;
|
|
|
|
|
case StrapPosition.Stand:
|
2024-07-25 13:32:56 +00:00
|
|
|
_standing.Stand(buckleUid, unbuckle: false);
|
2023-05-01 03:04:23 -04:00
|
|
|
break;
|
|
|
|
|
case StrapPosition.Down:
|
2024-07-25 13:32:56 +00:00
|
|
|
_standing.Down(buckleUid, false, false, false);
|
2023-05-01 03:04:23 -04:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-30 23:30:44 +10:00
|
|
|
}
|