public void UnlockTechnologies(bool all = true, int maxDepth = 999) { //bool flag = !this.RnDOpen; //if (!flag) if (this.RnDOpen) { this.unlockTechnology = TechnologyUnlock.OFF; float scienceCostLimit = GameVariables.Instance.GetScienceCostLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.ResearchAndDevelopment)); foreach (RDNode current in RDController.Instance.nodes) { if (NodeDepth(current) <= maxDepth) { double currentFunds = 0; if (!all) { currentFunds = Funding.Instance.Funds; Funding.Instance.AddFunds(CareerManager.MONEY_LOCK - Funding.Instance.Funds, TransactionReasons.Cheating); } bool flag2 = current.tech != null && (float)current.tech.scienceCost < scienceCostLimit; if (flag2) { current.tech.UnlockTech(true); } if (!all) { Funding.Instance.AddFunds(-Funding.Instance.Funds, TransactionReasons.Cheating); Funding.Instance.AddFunds(currentFunds, TransactionReasons.Cheating); } } } } }
public void TechnologiesUnlocked(bool state) { if (state) { unlockTechnology = TechnologyUnlock.UNLOCK; if (RnDOpen) { UnlockTechnologies(); ScreenMessages.PostScreenMessage("CareerManager: Technologies unlocked. Close and reopen the R&D screen to see changes."); } else { unlockTechnology = TechnologyUnlock.OFF; CareerManagerGUI.SetOption(CareerOptions.UNLOCKTECH, false); ScreenMessages.PostScreenMessage("CareerManager: Please visit the R&D building to use this feature."); } } else { unlockTechnology = TechnologyUnlock.REVERT; if (RnDOpen) { LockTechnologies(); ScreenMessages.PostScreenMessage("CareerManager: Technologies locked. Close and reopen the R&D screen to see changes."); } else { unlockTechnology = TechnologyUnlock.OFF; CareerManagerGUI.SetOption(CareerOptions.UNLOCKTECH, true); ScreenMessages.PostScreenMessage("CareerManager: Please visit the R&D building to use this feature."); } } }
/* Thanks to Michael Marvin, author of the mod TreeToppler, for showing how UnlockTech is the proper way of unlocking technologies. * Code for TreeToppler is available under GPLv3, http://forum.kerbalspaceprogram.com/threads/107663 * * The code in LockTechnologies() is directly based on his code. */ public void UnlockTechnologies() { if (!RnDOpen) { return; } unlockTechnology = TechnologyUnlock.OFF; float level = GameVariables.Instance.GetScienceCostLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.ResearchAndDevelopment)); foreach (RDNode node in RDController.Instance.nodes) { if (node.tech != null && node.tech.scienceCost < level) { node.tech.UnlockTech(true); //this will trigger an event, but we're not actioning this event for now. } } }
void LockTechnologies() { if (!RnDOpen) { return; } unlockTechnology = TechnologyUnlock.OFF; foreach (RDNode node in RDController.Instance.nodes) { if (node.tech.scienceCost > 0) { ProtoTechNode protoNode = ResearchAndDevelopment.Instance.GetTechState(node.tech.techID); protoNode.state = RDTech.State.Unavailable; protoNode.partsPurchased.Clear(); ResearchAndDevelopment.Instance.SetTechState(node.tech.techID, protoNode); } } }
private void LockTechnologies() { //bool flag = !this.RnDOpen; //if (!flag) if (this.RnDOpen) { this.unlockTechnology = TechnologyUnlock.OFF; foreach (RDNode current in RDController.Instance.nodes) { //bool flag2 = current.tech.scienceCost > 0; //if (flag2) if (current != null && current.tech.scienceCost > 0) { ProtoTechNode techState = ResearchAndDevelopment.Instance.GetTechState(current.tech.techID); techState.state = RDTech.State.Unavailable; techState.partsPurchased.Clear(); ResearchAndDevelopment.Instance.SetTechState(current.tech.techID, techState); } } } }
public void TechnologiesUnlocked(bool state, bool all, int maxDepth) { if (state) { this.unlockTechnology = TechnologyUnlock.UNLOCK; bool rnDOpen = this.RnDOpen; Debug.Log("TechnologiesUnlocked, RnDOpen: " + this.RnDOpen); // rnDOpen = true; if (rnDOpen) { this.UnlockTechnologies(all, maxDepth); ScreenMessages.PostScreenMessage("CareerManager: Technologies unlocked. Close and reopen the R&D screen to see changes."); } else { this.unlockTechnology = TechnologyUnlock.OFF; this.CareerManagerGUI.SetOption(CareerOptions.UNLOCKTECH, false); ScreenMessages.PostScreenMessage("CareerManager: Please visit the R&D building to use this feature."); } } else { this.unlockTechnology = TechnologyUnlock.REVERT; bool rnDOpen2 = this.RnDOpen; Debug.Log("TechnologiesUnlocked, RnDOpen: " + this.RnDOpen); // rnDOpen2 = true; if (rnDOpen2) { this.LockTechnologies(); ScreenMessages.PostScreenMessage("CareerManager: Technologies locked. Close and reopen the R&D screen to see changes."); } else { this.unlockTechnology = TechnologyUnlock.OFF; this.CareerManagerGUI.SetOption(CareerOptions.UNLOCKTECH, true); ScreenMessages.PostScreenMessage("CareerManager: Please visit the R&D building to use this feature."); } } }