mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-20 13:20:46 +00:00
fake elevator sectors: attach to the collider gameobjects in case they're in a different position from the elevator
This commit is contained in:
parent
e0a7bc3f23
commit
9dcd2e06c9
@ -97,16 +97,20 @@ public class QSBSectorManager : WorldObjectManager
|
||||
|
||||
foreach (var elevator in QSBWorldSync.GetUnityObjects<Elevator>())
|
||||
{
|
||||
radius = float.MinValue;
|
||||
foreach (var collider in elevator.GetComponentsInChildren<Collider>())
|
||||
var colliders = elevator.GetComponentsInChildren<Collider>();
|
||||
await colliders.Select(x =>
|
||||
UniTask.WaitUntil(() => x.bounds.extents != Vector3.zero, cancellationToken: ct));
|
||||
|
||||
static float Size(Collider collider)
|
||||
{
|
||||
await UniTask.WaitUntil(() => collider.bounds.extents != Vector3.zero, cancellationToken: ct);
|
||||
radius = Mathf.Max(radius, collider.bounds.extents.magnitude);
|
||||
var extents = collider.bounds.extents;
|
||||
return Mathf.Max(extents.x, extents.y, extents.z);
|
||||
}
|
||||
|
||||
FakeSector.CreateOn(elevator.gameObject,
|
||||
radius,
|
||||
elevator.GetComponentInParent<Sector>());
|
||||
var largestCollider = colliders.MaxBy(Size);
|
||||
FakeSector.CreateOn(largestCollider.gameObject,
|
||||
Size(largestCollider),
|
||||
largestCollider.GetComponentInParent<Sector>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user