public override ContractParameter Generate(Contract contract)
        {
            ConfiguredContract cc = contract as ConfiguredContract;

            if (!cc.Behaviours.Any(cb => cb is PartTestHandler))
            {
                cc.AddBehaviour(new PartTestHandler());
            }

            System.Random random = new System.Random();
            return(new PartTest(part, notes, PartTestConstraint.TestRepeatability.ONCEPERPART, targetBody, Vessel.Situations.LANDED, random.NextDouble().ToString(), false));
        }
Exemple #2
0
        /*
         * Generates all the ContractBehaviour objects required for the array of ConfigNodes, and
         * adds them to the host object.
         */
        public static void GenerateBehaviours(ConfiguredContract contract, List <BehaviourFactory> behaviourNodes)
        {
            foreach (BehaviourFactory behaviourFactory in behaviourNodes)
            {
                ContractBehaviour behaviour = behaviourFactory.Generate(contract);
                if (behaviour == null)
                {
                    throw new Exception(behaviourFactory.GetType().FullName + ".Generate() returned a null ContractBehaviour!");
                }

                // Add ContractBehaviour to the host
                contract.AddBehaviour(behaviour);
            }
        }
        /// <summary>
        /// Generates all the ContractBehaviour objects required for the array of ConfigNodes, and
        /// adds them to the host object.
        /// </summary>
        /// <param name="contract">Contract to generate behaviours for</param>
        /// <param name="behaviourNodes">The behaviour factories to use</param>
        /// <return>Whether generation was successful or not</return>
        public static bool GenerateBehaviours(ConfiguredContract contract, List<BehaviourFactory> behaviourNodes)
        {
            foreach (BehaviourFactory behaviourFactory in behaviourNodes)
            {
                if (behaviourFactory.enabled)
                {
                    ContractBehaviour behaviour = behaviourFactory.Generate(contract);
                    if (behaviour == null)
                    {
                        throw new Exception(behaviourFactory.GetType().FullName + ".Generate() returned a null ContractBehaviour!");
                    }

                    // Add ContractBehaviour to the host
                    contract.AddBehaviour(behaviour);
                }
            }

            return true;
        }