Partial buckling refactor (#29031)

* partial buckling refactor

* git mv test

* change test namespace

* git mv test

* Update test namespace

* Add pulling test

* Network BuckleTime

* Add two more tests

* smelly
This commit is contained in:
Leon Friedrich
2024-06-20 03:14:18 +12:00
committed by GitHub
parent e33f0341ad
commit fa3c89a521
38 changed files with 1053 additions and 890 deletions

View File

@@ -1,7 +1,6 @@
using System.Numerics;
using Content.Shared.ActionBlocker;
using Content.Shared.Buckle.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Rotatable;
using JetBrains.Annotations;
@@ -83,24 +82,21 @@ namespace Content.Shared.Interaction
if (!_actionBlockerSystem.CanChangeDirection(user))
return false;
if (EntityManager.TryGetComponent(user, out BuckleComponent? buckle) && buckle.Buckled)
if (TryComp(user, out BuckleComponent? buckle) && buckle.BuckledTo is {} strap)
{
var suid = buckle.LastEntityBuckledTo;
if (suid != null)
{
// We're buckled to another object. Is that object rotatable?
if (TryComp<RotatableComponent>(suid.Value, out var rotatable) && rotatable.RotateWhileAnchored)
{
// Note the assumption that even if unanchored, user can only do spinnychair with an "independent wheel".
// (Since the user being buckled to it holds it down with their weight.)
// This is logically equivalent to RotateWhileAnchored.
// Barstools and office chairs have independent wheels, while regular chairs don't.
_transform.SetWorldRotation(Transform(suid.Value), diffAngle);
return true;
}
}
// What if a person is strapped to a borg?
// I'm pretty sure this would allow them to be partially ratatouille'd
return false;
// We're buckled to another object. Is that object rotatable?
if (!TryComp<RotatableComponent>(strap, out var rotatable) || !rotatable.RotateWhileAnchored)
return false;
// Note the assumption that even if unanchored, user can only do spinnychair with an "independent wheel".
// (Since the user being buckled to it holds it down with their weight.)
// This is logically equivalent to RotateWhileAnchored.
// Barstools and office chairs have independent wheels, while regular chairs don't.
_transform.SetWorldRotation(Transform(strap), diffAngle);
return true;
}
// user is not buckled in; apply to their transform