public static void SetContractState(Type contractType, bool enabled) { if (ContractSystem.ContractTypes == null || ContractSystem.Instance == null) { Instance.StartCoroutine(Instance.SetContractStateDeferred(contractType, enabled)); } else { if (!enabled && ContractSystem.ContractTypes.Contains(contractType)) { LoggingUtil.LogDebug(typeof(ContractDisabler), "Disabling ContractType: " + contractType.FullName + " (" + contractType.Module + ")"); do { ContractSystem.ContractTypes.Remove(contractType); } while (ContractSystem.ContractTypes.Contains(contractType)); // Remove Offered and active contracts foreach (Contract contract in ContractSystem.Instance.Contracts.Where(c => c != null && c.GetType() == contractType && (c.ContractState == Contract.State.Offered || c.ContractState == Contract.State.Active))) { contract.Withdraw(); } } else if (enabled && !ContractSystem.ContractTypes.Contains(contractType)) { LoggingUtil.LogDebug(typeof(ContractDisabler), "Enabling ContractType: " + contractType.FullName + " (" + contractType.Module + ")"); ContractSystem.ContractTypes.Add(contractType); } } }
public static void SetContractState(Type contractType, bool enabled) { if (ContractSystem.ContractTypes == null || ContractSystem.Instance == null) { Instance.StartCoroutine(Instance.SetContractStateDeferred(contractType, enabled)); } else { if (!enabled && ContractSystem.ContractTypes.Contains(contractType)) { LoggingUtil.LogInfo(typeof(ContractDisabler), "Disabling ContractType: {0} ({1})", contractType.FullName, contractType.Module); do { ContractSystem.ContractTypes.Remove(contractType); } while (ContractSystem.ContractTypes.Contains(contractType)); while (ContractSystem.MandatoryTypes.Contains(contractType)) { ContractSystem.MandatoryTypes.Remove(contractType); } // Remove Offered and active contracts foreach (Contract contract in ContractSystem.Instance.Contracts.Where(c => c != null && c.GetType() == contractType && (c.ContractState == Contract.State.Offered || c.ContractState == Contract.State.Active))) { contract.Withdraw(); } } else if (enabled && !ContractSystem.ContractTypes.Contains(contractType)) { LoggingUtil.LogInfo(typeof(ContractDisabler), "Enabling ContractType: {0} ({1})", contractType.FullName, contractType.Module); ContractSystem.ContractTypes.Add(contractType); if (contractType == typeof(FinePrint.Contracts.ExplorationContract)) { ContractSystem.MandatoryTypes.Add(contractType); } } } }