mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-29 10:20:37 +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>())
|
foreach (var elevator in QSBWorldSync.GetUnityObjects<Elevator>())
|
||||||
{
|
{
|
||||||
radius = float.MinValue;
|
var colliders = elevator.GetComponentsInChildren<Collider>();
|
||||||
foreach (var collider in 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);
|
var extents = collider.bounds.extents;
|
||||||
radius = Mathf.Max(radius, collider.bounds.extents.magnitude);
|
return Mathf.Max(extents.x, extents.y, extents.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeSector.CreateOn(elevator.gameObject,
|
var largestCollider = colliders.MaxBy(Size);
|
||||||
radius,
|
FakeSector.CreateOn(largestCollider.gameObject,
|
||||||
elevator.GetComponentInParent<Sector>());
|
Size(largestCollider),
|
||||||
|
largestCollider.GetComponentInParent<Sector>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user