/* * 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); }
//omg, it's called a big amount of time protected override bool Generate() { //if (base.Prestige != ContractPrestige.Significant) //{ // return false; //} //MerillData.log("camera mission generate"); //TODO use/create 'KTV' (KerbalTV) if (Contracts.Agents.AgentList.Instance != null) { agent = Contracts.Agents.AgentList.Instance.GetAgent(MerillData.str_agent_secretary); } //1 human day in kerbal days //SetDeadlineDays(4); base.deadlineType = DeadlineType.None; base.expiryType = DeadlineType.None; //choose a body this.body2Shoot = MerillUtil.getPlanet("Mun"); //default (erase latter) this.useKerbal = false; this.situationForShoot = ExperimentSituations.InSpaceLow; //check if a contract of this type with a kerbal is already taken bool alreadyHereKerbal = false; bool alreadyHereProbe = false; foreach (MerillContractUseCamera oldContract in ContractSystem.Instance.GetCompletedContracts <MerillContractUseCamera>()) { if (oldContract.body2Shoot == body2Shoot && oldContract.useKerbal) { alreadyHereKerbal = true; MerillData.log("camera mission manned already done / here"); } if (oldContract.body2Shoot == body2Shoot && !oldContract.useKerbal) { alreadyHereProbe = true; MerillData.log("camera mission probe already done / here"); } } //check if it's in available contract if (!alreadyHereKerbal || !alreadyHereProbe) { //MerillData.log("camera mission generated? " + ContractSystem.Instance.Contracts.Count); foreach (Contract tempContract in ContractSystem.Instance.Contracts) { if (tempContract is MerillContractUseCamera) { if (((MerillContractUseCamera)tempContract).body2Shoot == body2Shoot && ((MerillContractUseCamera)tempContract).useKerbal) { MerillData.log("camera mission kerbal generated? true! "); alreadyHereKerbal = true; } if (((MerillContractUseCamera)tempContract).body2Shoot == body2Shoot && !((MerillContractUseCamera)tempContract).useKerbal) { MerillData.log("camera mission probe generated? true! "); alreadyHereProbe = true; } } } } if (!alreadyHereKerbal) { situationForShoot = ExperimentSituations.InSpaceLow; useKerbal = true; ContractParameter parameter = AddParameter(new MerillContractParameterCameraFooting(body2Shoot, situationForShoot, true)); //MerillData.log("camera mission generate manned "+GetTitle()); parameter.SetReputation(20); //advance, reward, failure //BTSM fly by mission:160k total needed: 200k SetFunds(0, 30000, 0); //reward, failure SetReputation(0, 0); } else if (!alreadyHereProbe) { useKerbal = false; //MerillData.log("camera mission generate unmanned"); //is highorbit? //0 : none, 1= HO, 2=LO , 3 = landed //int situation = 0; //foreach (MerillContractUseCamera oldContract in ContractSystem.Instance.GetCompletedContracts<MerillContractUseCamera>()) //{ // if(oldContract.body2Shoot == body2Shoot){ // if(oldContract.situationForShoot == ExperimentSituations.InSpaceHigh) // { // situation = Math.Max(situation, 1); // coeff = 1; // } // else if(oldContract.situationForShoot == ExperimentSituations.InSpaceLow) // { // situation = Math.Max(situation, 2); // coeff = 1; // } // else if(oldContract.situationForShoot == ExperimentSituations.SrfLanded) // { // situation = Math.Max(situation, 3); // coeff = 2; // } // } //} //if(situation == 0){ // situationForShoot = ExperimentSituations.InSpaceHigh; //}else if(situation == 1){ // situationForShoot = ExperimentSituations.InSpaceLow; //}else if(situation == 2){ // situationForShoot = ExperimentSituations.SrfLanded; //}else{ // //all are done // return false; //} ////MerillData.log("camera mission generate UNmanned " + string.Format(GetTitle(), body2Shoot.name, situationForShoot.ToString()) ); ////is already active? //foreach (MerillContractUseCamera currentContract in ContractSystem.Instance.GetCurrentContracts<MerillContractUseCamera>()) //{ // //MerillData.log("camera mission find current " + currentContract.useKerbal + ", " + currentContract.body2Shoot + ", " + currentContract.situationForShoot); // if (!currentContract.useKerbal && currentContract.body2Shoot == body2Shoot && currentContract.situationForShoot == situationForShoot) // { // //MerillData.log("camera mission return false"); // return false; // } //} //all green : generate parameter ContractParameter parameter1 = AddParameter(new MerillContractParameterCameraFooting(body2Shoot, ExperimentSituations.InSpaceHigh, false)); ContractParameter parameter2 = AddParameter(new MerillContractParameterCameraFooting(body2Shoot, ExperimentSituations.InSpaceLow, false)); ContractParameter parameter3 = AddParameter(new MerillContractParameterCameraFooting(body2Shoot, ExperimentSituations.SrfLanded, false)); //130k via btsm "explore body" parameter3.SetFunds(30000); //parameter3.SetReputation(10); //18k for btsm " explore body" -> need 50k parameter1.SetFunds(30000); parameter2.SetFunds(30000); //reputation parameter1.SetReputation(5); parameter2.SetReputation(5); parameter3.SetReputation(10); //already done via "expore body" contract SetFunds(0, 30000, 0); //reward, failure SetReputation(00, 00); } else { MerillData.log(" end generate camera: false"); return(false); } //no science, use experiment for that (and if !=0, need to add "BTSM" at the begining of this class name) SetScience(0); MerillData.log(" end generate camera: true"); return(true); }