コード例 #1
0
 public Arguments(ConfigNode configNode)
 {
     duration        = ConfigNodeUtil.ParseValue(configNode, "duration", new ContractConfigurator.Duration(0.0));
     allowedDowntime = ConfigNodeUtil.ParseValue(configNode, "allowedDowntime", new ContractConfigurator.Duration(0.0));
     waitDuration    = ConfigNodeUtil.ParseValue(configNode, "waitDuration", new ContractConfigurator.Duration(0.0));
     requirementId   = ConfigNodeUtil.ParseValue(configNode, "id", "");
     minVessels      = ConfigNodeUtil.ParseValue(configNode, "minVessels", 1);
     waypointIndex   = ConfigNodeUtil.ParseValue(configNode, "waypointIndex", 0);
     allowReset      = ConfigNodeUtil.ParseValue(configNode, "allowReset", true);
     title           = ConfigNodeUtil.ParseValue(configNode, "title", "");
     hideChildren    = ConfigNodeUtil.ParseValue(configNode, "hideChildren", false);
     durationType    = Lib.ConfigEnum(configNode, "durationType", DurationParameter.DurationType.countdown);
     allowUnpowered  = ConfigNodeUtil.ParseValue(configNode, "allowUnpowered", false);
 }
コード例 #2
0
        public override bool Load(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.Load(configNode);

            // Get type
            string contractType = null;

            valid &= ConfigNodeUtil.ParseValue <string>(configNode, "contractType", x => contractType = x, this);
            if (valid)
            {
                if (ContractType.GetContractType(contractType) != null)
                {
                    ccType = contractType;
                }
                else
                {
                    ccType = null;

                    // Search for the correct type
                    var classes =
                        from assembly in AppDomain.CurrentDomain.GetAssemblies()
                        from type in assembly.GetTypes()
                        where type.IsSubclassOf(typeof(Contract)) && type.Name.Equals(contractType)
                        select type;

                    if (classes.Count() < 1)
                    {
                        valid = false;
                        LoggingUtil.LogError(this.GetType(), "contractType '" + contractType +
                                             "' must either be a Contract sub-class or ContractConfigurator contract type");
                    }
                    else
                    {
                        contractClass = classes.First();
                    }
                }
            }

            valid &= ConfigNodeUtil.ParseValue <uint>(configNode, "minCount", x => minCount = x, this, 1);
            valid &= ConfigNodeUtil.ParseValue <uint>(configNode, "maxCount", x => maxCount = x, this, UInt32.MaxValue);
            valid &= ConfigNodeUtil.ParseValue <Duration>(configNode, "cooldownDuration", x => cooldownDuration = x, this, new Duration(0.0));

            return(valid);
        }