public void Upgrade()
 {
     curLevelDat       = FarFutureTechnologySettings.GetAMFactoryLevelData(factoryLevel + 1);
     factoryLevel      = factoryLevel + 1;
     maxAntimatter     = curLevelDat.maxCapacity;
     curAntimatterRate = curLevelDat.baseRate;
 }
Example #2
0
 public override void OnLoad(ConfigNode node)
 {
     Utils.Log("Persistence: Started Loading");
     base.OnLoad(node);
     FarFutureTechnologySettings.Load();
     DoLoad(node);
     Utils.Log("Persistence: Done Loading");
 }
 public float GetNextLevelCost()
 {
     if (factoryLevel >= FarFutureTechnologySettings.factoryLevels.Count - 1)
     {
         return(0f);
     }
     else
     {
         return((float)FarFutureTechnologySettings.GetAMFactoryLevelData(factoryLevel + 1).purchaseCost);
     }
 }
 protected void Start()
 {
     FarFutureTechnologySettings.Load();
 }
        public void Initialize(int loadedLevel, double loadedStorage, double deferredConsumption)
        {
            factoryLevel             = loadedLevel;
            curAntimatter            = loadedStorage;
            deferredAntimatterAmount = deferredConsumption;

            // If game mode is sandbox, set the level to max immediately and begin production
            if (HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX)
            {
                Utils.Log("Detected Sandbox, setting AM factory to max and activating");
                researched   = true;
                factoryLevel = FarFutureTechnologySettings.factoryLevels.Count - 1;
                SetProductionStatus(true);
            }
            // If science sandbox, check for the needed technology first
            else if (HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
            {
                Utils.Log("Detected Science Sandbox, setting AM factory to max, detecting tech");
                bool isResearched = Utils.CheckTechPresence(FarFutureTechnologySettings.antimatterFactoryUnlockTech);
                if (isResearched)
                {
                    researched   = true;
                    factoryLevel = FarFutureTechnologySettings.factoryLevels.Count - 1;
                    SetProductionStatus(true);
                }
                else
                {
                    researched = false;
                    SetProductionStatus(false);
                }
            }
            else
            {
                Utils.Log("Detected Career, setting AM factory to stored level, detecting tech");
                bool isResearched = Utils.CheckTechPresence(FarFutureTechnologySettings.antimatterFactoryUnlockTech);
                if (isResearched)
                {
                    researched   = true;
                    factoryLevel = loadedLevel;
                    SetProductionStatus(true);
                }
                else
                {
                    researched = false;
                    SetProductionStatus(false);
                }
            }

            Utils.Log("Completed data load, setting up factory for level " + factoryLevel.ToString());
            curLevelDat = FarFutureTechnologySettings.GetAMFactoryLevelData(factoryLevel);

            maxAntimatter     = curLevelDat.maxCapacity;
            curAntimatterRate = curLevelDat.baseRate;

            if (curAntimatter > maxAntimatter)
            {
                curAntimatter = maxAntimatter;
            }

            if (HighLogic.LoadedSceneIsFlight && DeferredAntimatterAmount > 0d)
            {
                ConsumeAntimatter(deferredAntimatterAmount);
                deferredAntimatterAmount = 0d;
            }
        }