/* * Method for generating ContractParameter objects. This will call the Generate() method * on the sub-class, load all common parameters and load child parameters. */ public virtual ContractParameter Generate(Contract contract, IContractParameterHost contractParamHost) { // Generate a parameter using the sub-class logic ContractParameter parameter = Generate(contract); if (parameter == null) { throw new Exception(GetType().FullName + ".Generate() returned a null ContractParameter!"); } // Add ContractParameter to the host contractParamHost.AddParameter(parameter); // Set the funds/science/reputation parameters parameter.SetFunds(rewardFunds, failureFunds, targetBody); parameter.SetReputation(rewardReputation, failureReputation, targetBody); parameter.SetScience(rewardScience, targetBody); // Set other flags parameter.Optional = optional; if (disableOnStateChange != null) { parameter.DisableOnStateChange = (bool)disableOnStateChange; } return(parameter); }
/// <summary> /// Method for generating ContractParameter objects. This will call the Generate() method /// on the sub-class, load all common parameters and load child parameters. /// </summary> /// <param name="contract">Contract to generate for</param> /// <param name="contractParamHost">Parent object for the ContractParameter</param> /// <returns>Generated ContractParameter</returns> public virtual ContractParameter Generate(ConfiguredContract contract, IContractParameterHost contractParamHost) { // First check any requirements if (!ContractRequirement.RequirementsMet(contract, contract.contractType, requirements)) { LoggingUtil.LogVerbose(typeof(ParameterFactory), "Returning null for " + contract.contractType.name + "." + name + ": requirements not met."); return(null); } // Generate a parameter using the sub-class logic ContractParameter parameter = Generate(contract); if (parameter == null) { LoggingUtil.LogWarning(this, GetType().FullName + ".Generate() returned a null ContractParameter!"); return(null); } // Add ContractParameter to the host contractParamHost.AddParameter(parameter); // Set the funds/science/reputation parameters parameter.SetFunds(rewardFunds, failureFunds, targetBody); parameter.SetReputation(rewardReputation, failureReputation, targetBody); parameter.SetScience(rewardScience, targetBody); // Set other flags parameter.Optional = optional; if (disableOnStateChange != null) { parameter.DisableOnStateChange = (bool)disableOnStateChange; } parameter.ID = name; // Special stuff for contract configurator parameters ContractConfiguratorParameter ccParam = parameter as ContractConfiguratorParameter; if (ccParam != null) { ccParam.completeInSequence = completeInSequence; ccParam.notes = notes; ccParam.completedMessage = completedMessage; ccParam.hidden = hidden; ccParam.hideChildren = hideChildren; } return(parameter); }