mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-19 03:39:50 +00:00
Player attachment now works on all TH elevators.
Originally, all players in elevators (such as the launch lift and the zero G cave elevator) would merge into one spot. Now, players who did not initiate the elevator remain in their positions.
This commit is contained in:
parent
c16f7b60e2
commit
270af9a58f
@ -12,16 +12,23 @@ namespace QSB.ElevatorSync.WorldObjects;
|
||||
public class QSBElevator : WorldObject<Elevator>
|
||||
{
|
||||
private OWTriggerVolume _elevatorTrigger;
|
||||
private bool IsLogLift => Name == "LogLift";
|
||||
|
||||
// Used by log lift to reset attach position
|
||||
// Used to reset attach position. This is in local space.
|
||||
public Vector3 originalAttachPosition;
|
||||
|
||||
public override async UniTask Init(CancellationToken ct)
|
||||
{
|
||||
var boxShape = AttachedObject.gameObject.GetAddComponent<BoxShape>();
|
||||
boxShape.center = new Vector3(0, 1.75f, 0.25f);
|
||||
boxShape.size = new Vector3(3, 3.5f, 3);
|
||||
|
||||
if (Name == "LogLift")
|
||||
{
|
||||
boxShape.size = new Vector3(5, 3.5f, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
boxShape.size = new Vector3(3, 3.5f, 3);
|
||||
}
|
||||
|
||||
_elevatorTrigger = AttachedObject.gameObject.GetAddComponent<OWTriggerVolume>();
|
||||
originalAttachPosition = AttachedObject._attachPoint.transform.localPosition;
|
||||
@ -41,11 +48,7 @@ public class QSBElevator : WorldObject<Elevator>
|
||||
if (_elevatorTrigger.IsTrackingObject(Locator.GetPlayerDetector()))
|
||||
{
|
||||
var attachPoint = AttachedObject._attachPoint;
|
||||
if (IsLogLift)
|
||||
{
|
||||
attachPoint.transform.position = Locator.GetPlayerTransform().position;
|
||||
QSBCore.Helper.Console.WriteLine($"Moved the anchor point to {attachPoint.transform.position}");
|
||||
}
|
||||
attachPoint.transform.position = Locator.GetPlayerTransform().position;
|
||||
|
||||
attachPoint.AttachPlayer();
|
||||
if (Locator.GetPlayerSuit().IsWearingSuit() && Locator.GetPlayerSuit().IsTrainingSuit())
|
||||
@ -55,16 +58,14 @@ public class QSBElevator : WorldObject<Elevator>
|
||||
}
|
||||
|
||||
AttachedObject.StartLift();
|
||||
|
||||
if (IsLogLift)
|
||||
|
||||
// Runs when the lift/elevator is done moving.
|
||||
// Reset the position of the attach point.
|
||||
Delay.RunWhen(() => !AttachedObject.enabled, () =>
|
||||
{
|
||||
// Runs when the lift is done moving.
|
||||
// Reset the position of the attach point.
|
||||
Delay.RunWhen(() => !AttachedObject.enabled, () =>
|
||||
{
|
||||
AttachedObject._attachPoint.transform.localPosition = originalAttachPosition;
|
||||
});
|
||||
}
|
||||
AttachedObject._attachPoint.transform.localPosition = originalAttachPosition;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void SetDirection(bool isGoingUp)
|
||||
@ -76,9 +77,6 @@ public class QSBElevator : WorldObject<Elevator>
|
||||
|
||||
public override void DisplayLines()
|
||||
{
|
||||
//Popcron.Gizmos.Sphere(AttachedObject._attachPoint.transform.position, 0.5f, Color.blue);
|
||||
//Popcron.Gizmos.Sphere(originalAttachPosition, 0.5f, Color.magenta);
|
||||
|
||||
var boxShape = (BoxShape)_elevatorTrigger._shape;
|
||||
Popcron.Gizmos.Cube(
|
||||
ShapeUtil.Box.CalcWorldSpaceCenter(boxShape),
|
||||
|
@ -104,10 +104,9 @@ public class QSBSectorManager : WorldObjectManager
|
||||
// just create a sphere at the attach point lol
|
||||
// since players will be moved there when riding the elevator
|
||||
// --
|
||||
// The log lift needs the attach point on the game object itself to
|
||||
// The attach point on the game object itself to
|
||||
// sync player attachment properly.
|
||||
var go = elevator.name == "LogLift" ? elevator.gameObject : elevator._attachPoint.gameObject;
|
||||
FakeSector.Create(go,
|
||||
FakeSector.Create(elevator.gameObject,
|
||||
elevator.GetComponentInParent<Sector>(),
|
||||
x =>
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user