Ejemplo n.º 1
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            foreach (ConfigNode n in node.GetNodes("LOGPERIODS"))
            {
                foreach (ConfigNode pn in n.GetNodes("LOGPERIOD"))
                {
                    var    lp          = new LogPeriod(pn);
                    double periodStart = lp.StartUT;
                    try
                    {
                        _periodDict.Add(periodStart, lp);
                    }
                    catch
                    {
                        Debug.LogError($"[LRTR] LOGPERIOD for {periodStart} already exists, skipping...");
                    }
                }
            }

            foreach (ConfigNode n in node.GetNodes("CONTRACTS"))
            {
                foreach (ConfigNode cn in n.GetNodes("CONTRACT"))
                {
                    var c = new ContractEvent(cn);
                    _contractDict.Add(c);
                }
            }

            foreach (ConfigNode n in node.GetNodes("LAUNCHEVENTS"))
            {
                foreach (ConfigNode ln in n.GetNodes("LAUNCHEVENT"))
                {
                    var l = new LaunchEvent(ln);
                    _launchedVessels.Add(l);
                }
            }

            foreach (ConfigNode n in node.GetNodes("FACILITYCONSTRUCTIONS"))
            {
                foreach (ConfigNode fn in n.GetNodes("FACILITYCONSTRUCTION"))
                {
                    var fc = new FacilityConstructionEvent(fn);
                    _facilityConstructions.Add(fc);
                }
            }

            foreach (ConfigNode n in node.GetNodes("TECHS"))
            {
                foreach (ConfigNode tn in n.GetNodes("TECH"))
                {
                    var te = new TechResearchEvent(tn);
                    _techEvents.Add(te);
                }
            }
        }
Ejemplo n.º 2
0
 private LogPeriod GetOrCreatePeriod(double periodStartUt)
 {
     if (!_periodDict.TryGetValue(periodStartUt, out LogPeriod period))
     {
         DateTime dtNextPeriod    = UTToDate(periodStartUt).AddMonths(LogPeriodMonths);
         double   nextPeriodStart = (dtNextPeriod - _epoch).TotalSeconds;
         period = new LogPeriod(periodStartUt, nextPeriodStart);
         _periodDict.Add(periodStartUt, period);
     }
     return(period);
 }
Ejemplo n.º 3
0
        private CareerLogDto CreateLogDto(LogPeriod logPeriod)
        {
            double advanceFunds = _contractDict
                                  .Where(c => c.Type == ContractEventType.Accept && c.IsInPeriod(logPeriod))
                                  .Select(c => c.FundsChange)
                                  .Sum();

            double rewardFunds = _contractDict
                                 .Where(c => c.Type == ContractEventType.Complete && c.IsInPeriod(logPeriod))
                                 .Select(c => c.FundsChange)
                                 .Sum();

            double failureFunds = -_contractDict.Where(c =>
                                                       (c.Type == ContractEventType.Cancel || c.Type == ContractEventType.Fail) && c.IsInPeriod(logPeriod))
                                  .Select(c => c.FundsChange)
                                  .Sum();

            double constructionFees = _facilityConstructions
                                      .Where(f => f.State == ConstructionState.Started && f.IsInPeriod(logPeriod))
                                      .Select(c => c.Cost)
                                      .Sum();

            return(new CareerLogDto
            {
                careerUuid = SystemInfo.deviceUniqueIdentifier,
                startDate = UTToDate(logPeriod.StartUT).ToString("o"),
                endDate = UTToDate(logPeriod.EndUT).ToString("o"),
                vabUpgrades = logPeriod.VABUpgrades,
                sphUpgrades = logPeriod.SPHUpgrades,
                rndUpgrades = logPeriod.RnDUpgrades,
                currentFunds = logPeriod.CurrentFunds,
                currentSci = logPeriod.CurrentSci,
                scienceEarned = logPeriod.ScienceEarned,
                advanceFunds = advanceFunds,
                rewardFunds = rewardFunds,
                failureFunds = failureFunds,
                otherFundsEarned = logPeriod.OtherFundsEarned,
                launchFees = logPeriod.LaunchFees,
                maintenanceFees = logPeriod.MaintenanceFees,
                entryCosts = logPeriod.EntryCosts,
                constructionFees = logPeriod.OtherFees,
                otherFees = logPeriod.OtherFees - constructionFees,
                fundsGainMult = logPeriod.FundsGainMult
            });
        }
Ejemplo n.º 4
0
        private void SwitchToNextPeriod()
        {
            LogPeriod _prevPeriod = _currentPeriod ?? GetOrCreatePeriod(CurPeriodStart);

            if (_prevPeriod != null)
            {
                _prevPeriod.CurrentFunds  = Funding.Instance.Funds;
                _prevPeriod.CurrentSci    = ResearchAndDevelopment.Instance.Science;
                _prevPeriod.VABUpgrades   = GetKCTUpgradeCounts(SpaceCenterFacility.VehicleAssemblyBuilding);
                _prevPeriod.SPHUpgrades   = GetKCTUpgradeCounts(SpaceCenterFacility.SpaceplaneHangar);
                _prevPeriod.RnDUpgrades   = GetKCTUpgradeCounts(SpaceCenterFacility.ResearchAndDevelopment);
                _prevPeriod.ScienceEarned = GetSciPointTotalFromKCT();
                _prevPeriod.FundsGainMult = HighLogic.CurrentGame.Parameters.Career.FundsGainMultiplier;
            }

            _currentPeriod  = GetOrCreatePeriod(NextPeriodStart);
            CurPeriodStart  = NextPeriodStart;
            NextPeriodStart = _currentPeriod.EndUT;
        }
Ejemplo n.º 5
0
 public bool IsInPeriod(LogPeriod p)
 {
     return(UT >= p.StartUT && UT < p.EndUT);
 }