public void Update() { if (HighLogic.LoadedSceneIsFlight) { // refreshes prices if station moves to another area CelestialBody loc = FlightGlobals.ActiveVessel.mainBody; if (loc != currentOrbit) { basePrices = new List <double>(); currentOrbit = loc; string strOr2 = currentOrbit.displayName; GrapeUtils priceModifier = new GrapeUtils(); modCost = priceModifier.DistanceCalculator(strOr2); basePrices = priceModifier.BaseRates(); lfoCost = Math.Round(basePrices[0] * modCost, 2); lfCost = Math.Round(basePrices[1] * modCost, 2); oCost = Math.Round(basePrices[2] * modCost, 2); mCost = Math.Round(basePrices[3] * modCost, 2); xCost = Math.Round(basePrices[4] * modCost, 2); batCost = Math.Round(basePrices[5] * modCost, 2); repCost = Math.Round(basePrices[6] * modCost, 2); } } }
// handles timer event after player refuels (simulates waiting for redelivery) public static void TimerEvent() { // in seconds... useful... double thisTime = Planetarium.fetch.time; // a week double fixedStdTime = 151200; CelestialBody loc = FlightGlobals.ActiveVessel.mainBody; GrapeUtils gU = new GrapeUtils(); double timeModifier = gU.TimeCalculator(loc.displayName); double revisedTime = fixedStdTime * timeModifier; double timeOfNextDelivery = thisTime + revisedTime; double timeAsDays = Math.Round((timeOfNextDelivery / 21600), 0); Instance.timeTillNextDel = timeAsDays; Instance.timerEnd = timeOfNextDelivery; }
public void Start() { if (!HighLogic.LoadedSceneIsFlight) { return; } else if (HighLogic.LoadedSceneIsFlight) { Instance = this; try { basePrices = new List <double>(); currentOrbit = FlightGlobals.ActiveVessel.mainBody; string strOrbit = currentOrbit.displayName; GrapeUtils priceModifier = new GrapeUtils(); modCost = priceModifier.DistanceCalculator(strOrbit); basePrices = priceModifier.BaseRates(); lfoCost = Math.Round(basePrices[0] * modCost, 2); lfCost = Math.Round(basePrices[1] * modCost, 2); oCost = Math.Round(basePrices[2] * modCost, 2); mCost = Math.Round(basePrices[3] * modCost, 2); xCost = Math.Round(basePrices[4] * modCost, 2); batCost = Math.Round(basePrices[5] * modCost, 2); repCost = Math.Round(basePrices[6] * modCost, 2); totalPrice = 0; } catch { // internal error } } }