public override void OnAwake() { instance = this; points = new List <SupplyPoint>(); links = new List <SupplyLink>(); trackedVessels = new List <VesselData>(); activeActions = new List <SupplyChainAction>(); vesselsAtPoint = new Dictionary <SupplyPoint, List <Vessel> >(); lastUpdated = Planetarium.GetUniversalTime(); GameEvents.onFlightReady.Add(doPeriodicUpdate); GameEvents.OnFlightGlobalsReady.Add((bool data) => { doPeriodicUpdate(); }); GameEvents.onTimeWarpRateChanged.Add(doPeriodicUpdate); SupplyBaseWindow.initAllWindows(); }
public void FixedUpdate() { if ((Planetarium.GetUniversalTime() - lastUpdated) > SupplyChainController.updateInterval) { List <SupplyChainAction> finished = new List <SupplyChainAction>(); // can't modify the active actions list while iterating through it foreach (SupplyChainAction act in activeActions) { if (Planetarium.GetUniversalTime() >= act.timeComplete && act.canFinish()) { act.finishAction(); finished.Add(act); if (act.onComplete != null) { foreach (Action <SupplyChainAction> callback in act.onComplete) { callback(act); } } } } foreach (SupplyChainAction act in finished) { activeActions.Remove(act); } doPeriodicUpdate(); SupplyBaseWindow.updateAllWindows(); foreach (SupplyChainProcess proc in allProcesses) { proc.schedulerUpdate(); } lastUpdated = Planetarium.GetUniversalTime(); } }