protected bool CheckContractGroup(ConfiguredContract contract, ContractGroup group)
        {
            if (group != null)
            {
                // Check the group is enabled
                if (!ContractConfiguratorSettings.IsEnabled(group))
                {
                    throw new ContractRequirementException("Contract group " + group.name + " is not enabled.");
                }

                IEnumerable <ConfiguredContract> contractList = ConfiguredContract.CurrentContracts.
                                                                Where(c => c.contractType != null && c != contract);

                // Check the group active limit
                int activeContracts = contractList.Count(c => c.contractType != null && group.BelongsToGroup(c.contractType));
                if (group.maxSimultaneous != 0 && activeContracts >= group.maxSimultaneous)
                {
                    throw new ContractRequirementException("Too many active contracts in group (" + group.name + ").");
                }

                // Check the group completed limit
                if (group.maxCompletions != 0)
                {
                    int finishedContracts = ConfiguredContract.CompletedContracts.Count(c => c.contractType != null && group.BelongsToGroup(c.contractType));
                    if (finishedContracts + activeContracts >= maxCompletions)
                    {
                        throw new ContractRequirementException("Too many completed contracts in group (" + group.name + ").");
                    }
                }

                return(CheckContractGroup(contract, group.parent));
            }

            return(true);
        }
        public ContractConfiguratorSettings()
        {
            Instance = this;
            if (closeIcon == null)
            {
                closeIcon = GameDatabase.Instance.GetTexture("ContractConfigurator/icons/close", false);
                toolbarIcon = GameDatabase.Instance.GetTexture("ContractConfigurator/icons/toolbar", false);
            }

            SeedStockContractDetails();
        }
예제 #3
0
        public ContractConfiguratorSettings()
        {
            Instance = this;
            if (closeIcon == null)
            {
                closeIcon   = GameDatabase.Instance.GetTexture("ContractConfigurator/icons/close", false);
                toolbarIcon = GameDatabase.Instance.GetTexture("ContractConfigurator/icons/toolbar", false);
            }

            SeedStockContractDetails();

            DisplayOfferedOrbits    = ContractDefs.DisplayOfferedOrbits;
            DisplayOfferedWaypoints = ContractDefs.DisplayOfferedWaypoints;
        }