Files
OldThink/Content.Shared/Buckle/SharedBuckleSystem.cs

97 lines
3.7 KiB
C#
Raw Normal View History

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;
using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
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;
using Robust.Shared.Player;
2022-08-22 12:44:37 +12:00
using Robust.Shared.Timing;
using PullingSystem = Content.Shared.Movement.Pulling.Systems.PullingSystem;
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
{
[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!;
[Dependency] private readonly PullingSystem _pulling = default!;
2023-09-16 07:15:05 +03:00
[Dependency] private readonly SharedTransformSystem _transform = default!;
[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
/// <inheritdoc/>
2022-11-14 20:30:30 +01:00
public override void Initialize()
{
2022-11-14 20:30:30 +01:00
base.Initialize();
2022-08-22 12:44:37 +12:00
UpdatesAfter.Add(typeof(SharedInteractionSystem));
UpdatesAfter.Add(typeof(SharedInputSystem));
2022-11-18 22:08:28 +01:00
InitializeBuckle();
InitializeStrap();
}
/// <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;
_transform.SetCoordinates(buckleUid, new EntityCoordinates(strapUid, strapComp.BuckleOffsetClamped));
2023-09-16 07:15:05 +03:00
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;
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);
switch (strapComp.Position)
{
case StrapPosition.None:
break;
case StrapPosition.Stand:
_standing.Stand(buckleUid, unbuckle: false);
break;
case StrapPosition.Down:
_standing.Down(buckleUid, false, false, false);
break;
}
}
}