public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            EntryCostDatabase.Load(node.GetNode("Unlocks"));

            EntryCostDatabase.UpdatePartEntryCosts();

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                foreach (ConfigNode n in node.GetNodes("TLUpgrade"))
                {
                    TLUpgrade tU = null;
                    if (n.HasValue("name"))
                    {
                        string tlName = n.GetValue("name");
                        if (techLevelUpgrades.TryGetValue(tlName, out tU))
                        {
                            tU.Load(n);
                        }
                        else
                        {
                            tU = new TLUpgrade(n);
                            techLevelUpgrades[tlName] = tU;
                        }
                    }
                }
            }
        }
        public bool PurchaseConfig(string cfgName)
        {
            if (ConfigUnlocked(cfgName))
            {
                return(false);
            }

            double cfgCost = ConfigEntryCost(cfgName);

            if (!HighLogic.CurrentGame.Parameters.Difficulty.BypassEntryPurchaseAfterResearch)
            {
                if (Funding.Instance.Funds < cfgCost)
                {
                    return(false);
                }

                Funding.Instance.AddFunds(-cfgCost, TransactionReasons.RnDPartPurchase);
            }

            EntryCostDatabase.SetUnlocked(cfgName);

            EntryCostDatabase.UpdatePartEntryCosts();

            return(true);
        }
Exemple #3
0
        public void Start()
        {
            EntryCostManager.FillUpgrades();

            EntryCostDatabase.Initialize();

            EntryCostDatabase.UpdatePartEntryCosts();
        }
        public void Start()
        {
            EntryCostManager.FillUpgrades();

            EntryCostDatabase.Initialize();

            EntryCostDatabase.UpdatePartEntryCosts();

            // KSP's Funding binds to the same event and is used for deducting funds for entry purchases.
            // RF will need to bind to the event before KSP itself does to process ECMs right after KSP has updated the funding.
            // Note that KSP fires events in a reverse while loop.
            GameEvents.OnPartPurchased.Add(OnPartPurchased);
        }
        protected IEnumerator updatePartEntryCosts()
        {
            yield return(new WaitForEndOfFrame());

            EntryCostDatabase.UpdatePartEntryCosts();
        }