mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-21 18:40:03 +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>
|
public class QSBElevator : WorldObject<Elevator>
|
||||||
{
|
{
|
||||||
private OWTriggerVolume _elevatorTrigger;
|
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 Vector3 originalAttachPosition;
|
||||||
|
|
||||||
public override async UniTask Init(CancellationToken ct)
|
public override async UniTask Init(CancellationToken ct)
|
||||||
{
|
{
|
||||||
var boxShape = AttachedObject.gameObject.GetAddComponent<BoxShape>();
|
var boxShape = AttachedObject.gameObject.GetAddComponent<BoxShape>();
|
||||||
boxShape.center = new Vector3(0, 1.75f, 0.25f);
|
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>();
|
_elevatorTrigger = AttachedObject.gameObject.GetAddComponent<OWTriggerVolume>();
|
||||||
originalAttachPosition = AttachedObject._attachPoint.transform.localPosition;
|
originalAttachPosition = AttachedObject._attachPoint.transform.localPosition;
|
||||||
@ -41,11 +48,7 @@ public class QSBElevator : WorldObject<Elevator>
|
|||||||
if (_elevatorTrigger.IsTrackingObject(Locator.GetPlayerDetector()))
|
if (_elevatorTrigger.IsTrackingObject(Locator.GetPlayerDetector()))
|
||||||
{
|
{
|
||||||
var attachPoint = AttachedObject._attachPoint;
|
var attachPoint = AttachedObject._attachPoint;
|
||||||
if (IsLogLift)
|
attachPoint.transform.position = Locator.GetPlayerTransform().position;
|
||||||
{
|
|
||||||
attachPoint.transform.position = Locator.GetPlayerTransform().position;
|
|
||||||
QSBCore.Helper.Console.WriteLine($"Moved the anchor point to {attachPoint.transform.position}");
|
|
||||||
}
|
|
||||||
|
|
||||||
attachPoint.AttachPlayer();
|
attachPoint.AttachPlayer();
|
||||||
if (Locator.GetPlayerSuit().IsWearingSuit() && Locator.GetPlayerSuit().IsTrainingSuit())
|
if (Locator.GetPlayerSuit().IsWearingSuit() && Locator.GetPlayerSuit().IsTrainingSuit())
|
||||||
@ -56,15 +59,13 @@ public class QSBElevator : WorldObject<Elevator>
|
|||||||
|
|
||||||
AttachedObject.StartLift();
|
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.
|
AttachedObject._attachPoint.transform.localPosition = originalAttachPosition;
|
||||||
// Reset the position of the attach point.
|
});
|
||||||
Delay.RunWhen(() => !AttachedObject.enabled, () =>
|
|
||||||
{
|
|
||||||
AttachedObject._attachPoint.transform.localPosition = originalAttachPosition;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetDirection(bool isGoingUp)
|
private void SetDirection(bool isGoingUp)
|
||||||
@ -76,9 +77,6 @@ public class QSBElevator : WorldObject<Elevator>
|
|||||||
|
|
||||||
public override void DisplayLines()
|
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;
|
var boxShape = (BoxShape)_elevatorTrigger._shape;
|
||||||
Popcron.Gizmos.Cube(
|
Popcron.Gizmos.Cube(
|
||||||
ShapeUtil.Box.CalcWorldSpaceCenter(boxShape),
|
ShapeUtil.Box.CalcWorldSpaceCenter(boxShape),
|
||||||
|
@ -104,10 +104,9 @@ public class QSBSectorManager : WorldObjectManager
|
|||||||
// just create a sphere at the attach point lol
|
// just create a sphere at the attach point lol
|
||||||
// since players will be moved there when riding the elevator
|
// 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.
|
// sync player attachment properly.
|
||||||
var go = elevator.name == "LogLift" ? elevator.gameObject : elevator._attachPoint.gameObject;
|
FakeSector.Create(elevator.gameObject,
|
||||||
FakeSector.Create(go,
|
|
||||||
elevator.GetComponentInParent<Sector>(),
|
elevator.GetComponentInParent<Sector>(),
|
||||||
x =>
|
x =>
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user