quantum-space-buddies/QSB/MeteorSync/MeteorManager.cs

33 lines
1.2 KiB
C#
Raw Normal View History

2022-01-29 04:49:07 +00:00
using Cysharp.Threading.Tasks;
using QSB.MeteorSync.WorldObjects;
using QSB.Utility;
2021-11-11 02:40:02 +00:00
using QSB.WorldSync;
2021-11-25 15:32:34 +00:00
using System.Linq;
2022-01-29 04:49:07 +00:00
using System.Threading;
2021-11-11 02:40:02 +00:00
2022-03-03 03:46:33 +00:00
namespace QSB.MeteorSync;
public class MeteorManager : WorldObjectManager
2021-11-11 02:40:02 +00:00
{
2022-03-03 03:46:33 +00:00
public override WorldObjectScene WorldObjectScene => WorldObjectScene.SolarSystem;
2022-03-03 03:46:33 +00:00
public static WhiteHoleVolume WhiteHoleVolume;
2021-11-11 02:40:02 +00:00
2022-03-03 03:46:33 +00:00
public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct)
{
// wait for all late initializers (which includes meteor launchers) to finish
await UniTask.WaitUntil(() => LateInitializerManager.isDoneInitializing, cancellationToken: ct);
2022-01-29 04:57:17 +00:00
2022-03-03 03:46:33 +00:00
WhiteHoleVolume = QSBWorldSync.GetUnityObjects<WhiteHoleVolume>().First();
QSBWorldSync.Init<QSBFragment, FragmentIntegrity>();
var meteorLaunchers = QSBWorldSync.GetUnityObjects<MeteorLauncher>().SortDeterministic().ToList();
QSBWorldSync.Init<QSBMeteorLauncher, MeteorLauncher>(meteorLaunchers);
// order by pool instead of using SortDeterministic
var meteors = meteorLaunchers.SelectMany(x =>
x._meteorPool.EmptyIfNull().Concat(x._dynamicMeteorPool.EmptyIfNull()));
QSBWorldSync.Init<QSBMeteor, MeteorController>(meteors);
2021-11-11 02:40:02 +00:00
}
}