internal static string paramTypeCheck(ContractParameter param) { if (param.GetType() == typeof(PartTest)) { return("partTest"); } if (contractAssembly.MCELoaded) { if (param.GetType() == contractAssembly._MCEType) { return("MCEScience"); } } if (contractAssembly.DMLoaded) { if (param.GetType() == contractAssembly._DMCType) { return("DMcollectScience"); } } if (contractAssembly.DMALoaded) { if (param.GetType() == contractAssembly._DMAType) { return("DManomalyScience"); } else { return(""); } } if (contractAssembly.DMAstLoaded) { if (param.GetType() == contractAssembly._DMAstType) { return("DMasteroidScience"); } else { return(""); } } return(""); }
private void onContractParamModified(Contract c, ContractParameter p) { if (p.GetType() == typeof(KerbalDestinationParameter)) { touristUpdate(); } }
void SetupChildParameters() { if (!hiddenParameters.Any()) { return; } bool foundIncomplete = false; int i = 0; foreach (ContractParameter child in ChildParameterIterator()) { ContractParameter param = child; InvisibleWrapper wrapper = null; // Already wrapped if (param.GetType() == typeof(InvisibleWrapper)) { wrapper = param as InvisibleWrapper; param = wrapper.GetParameter(0); } // Need to potentially hide if (foundIncomplete) { if (hiddenParameters.Contains(param.ID) && wrapper == null) { wrapper = new InvisibleWrapper(); wrapper.AddParameter(param); RemoveParameter(i); paramRemoved = true; AddParameter(wrapper); } } // Need to potentially unhide else { if (hiddenParameters.Contains(param.ID) && wrapper != null) { RemoveParameter(i); paramRemoved = true; AddParameter(param); } } // Check on the state if (param.State != ParameterState.Complete) { foundIncomplete = true; } i++; } if (paramRemoved) { ContractConfigurator.OnParameterChange.Fire(Root, this); } }
public parameterContainer(contractContainer Root, ContractParameter cP, int Level) { root = Root; cParam = cP; cParamType = cParam.GetType(); try { title = cParam.Title; } catch (Exception e) { Debug.LogError("[Contract Parser] Contract Parameter Title not set, using type name...\n" + e); title = cParam.GetType().Name; } try { notes = cParam.Notes; } catch (Exception e) { Debug.LogError("[Contract Parser] Contract Parameter Notes not set, blank notes used...\n" + e); notes = ""; } level = Level; paramRewards(); paramPenalties(); waypoint = checkForWaypoint(); customNotes = setCustomNotes(); if (level < 4) { for (int i = 0; i < cParam.ParameterCount; i++) { ContractParameter param = cParam.GetParameter(i); addSubParam(param, level + 1); } } }
/// <summary> /// Used externally to return the name of the requested part /// </summary> /// <param name="cP">Instance of the requested Contract Parameter</param> /// <returns>Available Part name string</returns> public static string PartName(ContractParameter cP) { if (cP == null || cP.GetType() != typeof(DMCollectScience)) { return(""); } DMCollectScience Instance = (DMCollectScience)cP; return(Instance.partName); }
/// <summary> /// Used externally to return the name of the requested part /// </summary> /// <param name="cP">Instance of the requested Contract Parameter</param> /// <returns>Available Part name string</returns> public static string PartName(ContractParameter cP) { if (cP == null || cP.GetType() != typeof(DMAnomalyParameter)) { return(""); } DMAnomalyParameter aP = (DMAnomalyParameter)cP; return(aP.partName); }
/// <summary> /// Used externally to return the name of the requested part /// </summary> /// <param name="cP">Instance of the requested Contract Parameter</param> /// <returns>Available Part name string</returns> public static string PartName(ContractParameter cP) { if (cP == null || cP.GetType() != typeof(DMAsteroidParameter)) { return(""); } DMAsteroidParameter Instance = (DMAsteroidParameter)cP; return(Instance.partName); }
protected override void OnParameterStateChange(ContractParameter contractParameter) { if (System.Object.ReferenceEquals(contractParameter.Parent, this) || System.Object.ReferenceEquals(contractParameter, this)) { LoggingUtil.LogVerbose(this, "OnParameterStateChange"); if (AllChildParametersComplete()) { LoggingUtil.LogVerbose(this, " AllChildParametersComplete (waiting = {0})", waiting); if (!waiting && trackedVessel != null) { LoggingUtil.LogVerbose(this, " set waiting"); waiting = true; completionTime = Planetarium.GetUniversalTime() + duration; // Set the tracked vessel association if (!string.IsNullOrEmpty(define)) { LoggingUtil.LogVerbose(this, "setting {0} as {1}", define, trackedVessel.vesselName); ContractVesselTracker.Instance.AssociateVessel(define, trackedVessel); } } } else { LoggingUtil.LogVerbose(this, " not all params complete"); waiting = false; if (state == ParameterState.Complete) { SetState(ParameterState.Incomplete); } // Set the tracked vessel association if (!string.IsNullOrEmpty(define)) { LoggingUtil.LogVerbose(this, "setting {0} as null", define); ContractVesselTracker.Instance.AssociateVessel(define, null); } // Find any failed non-VesselParameter parameters for (int i = 0; i < ParameterCount; i++) { ContractParameter param = GetParameter(i); if (!param.GetType().IsSubclassOf(typeof(VesselParameter)) && param.State == ParameterState.Failed) { SetState(ParameterState.Failed); break; } } } } }
private Waypoint checkForWaypoint() { Waypoint p = null; if (cParam.GetType() == typeof(SurveyWaypointParameter)) { SurveyWaypointParameter s = (SurveyWaypointParameter)cParam; if (s.State != ParameterState.Incomplete) { return(p); } return(s.wp); } else if (cParam.GetType() == typeof(StationaryPointParameter)) { StationaryPointParameter s = (StationaryPointParameter)cParam; if (s.State != ParameterState.Incomplete) { return(p); } try { var field = (typeof(StationaryPointParameter)).GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0]; p = (Waypoint)field.GetValue(s); } catch (Exception e) { Debug.Log(string.Format("[Contract Parser] Error While Assigning FinePrint Stationary Waypoint Object\n{0}", e)); } } return(p); }
protected override void OnParameterStateChange(ContractParameter contractParameter) { if (System.Object.ReferenceEquals(contractParameter.Parent, this) || System.Object.ReferenceEquals(contractParameter, this)) { if (AllChildParametersComplete()) { if (!waiting) { waiting = true; completionTime = Planetarium.GetUniversalTime() + duration; // Set the tracked vessel association if (!string.IsNullOrEmpty(define)) { ContractVesselTracker.Instance.AssociateVessel(define, trackedVessel); } } } else { waiting = false; if (state == ParameterState.Complete) { SetState(ParameterState.Incomplete); // Set the tracked vessel association if (!string.IsNullOrEmpty(define)) { ContractVesselTracker.Instance.AssociateVessel(define, trackedVessel); } } // Find any failed non-VesselParameter parameters for (int i = 0; i < ParameterCount; i++) { ContractParameter param = GetParameter(i); if (!param.GetType().IsSubclassOf(typeof(VesselParameter)) && param.State == ParameterState.Failed) { SetState(ParameterState.Failed); break; } } } } }
public parameterContainer(contractContainer Root, ContractParameter cP, int Level) { root = Root; cParam = cP; try { title = cParam.Title; } catch (Exception e) { Debug.LogError("[Contract Parser] Contract Parameter Title not set, using type name...\n" + e); title = cParam.GetType().Name; } try { notes = cParam.Notes; } catch (Exception e) { Debug.LogError("[Contract Parser] Contract Parameter Notes not set, blank notes used...\n" + e); notes = ""; } level = Level; paramRewards(); paramPenalties(); waypoint = checkForWaypoint(); customNotes = setCustomNotes(); if (level < 4) { for (int i = 0; i < cParam.ParameterCount; i++) { ContractParameter param = cParam.GetParameter(i); addSubParam(param, level + 1); } } }
internal static string paramTypeCheck(ContractParameter param) { if (param.GetType() == typeof(PartTest)) return "partTest"; if (contractAssembly.FPLoaded) { if (param.GetType() == contractAssembly._FPType) return "FinePrint"; } if (contractAssembly.MCELoaded) { if (param.GetType() == contractAssembly._MCEType) return "MCEScience"; } if (contractAssembly.DMLoaded) { if (param.GetType() == contractAssembly._DMCType) return "DMcollectScience"; } if (contractAssembly.DMALoaded) { if (param.GetType() == contractAssembly._DMAType) return "DManomalyScience"; else return ""; } if (contractAssembly.DMAstLoaded) { if (param.GetType() == contractAssembly._DMAstType) return "DMasteroidScience"; else return ""; } return ""; }
private static bool handleContractsForCrew(Vessel vessel, bool arrive, bool depart, ProtoCrewMember crew) { //print("handling crew"); foreach (Contract con in Contracts.ContractSystem.Instance.Contracts) { if (con.ContractState == Contract.State.Active) { if (ReferenceEquals(con.GetType(), typeof(FinePrint.Contracts.TourismContract))) { for (int i = 0; i < con.ParameterCount; i++) { ContractParameter conpara1 = con.GetParameter(i); if (ReferenceEquals(conpara1.GetType(), typeof(FinePrint.Contracts.Parameters.KerbalTourParameter)) && conpara1.State != Contracts.ParameterState.Complete) { FinePrint.Contracts.Parameters.KerbalTourParameter ktp = (FinePrint.Contracts.Parameters.KerbalTourParameter)conpara1; if (crew.name == ktp.kerbalName) { // complete destinations parameters on arrive for kerbals on vessel if (arrive) { for (int u = 0; u < conpara1.ParameterCount; u++) { ContractParameter conpara2 = conpara1.GetParameter(u); if (ReferenceEquals(conpara2.GetType(), typeof(FinePrint.Contracts.Parameters.KerbalDestinationParameter)) && conpara2.State != Contracts.ParameterState.Complete) { FinePrint.Contracts.Parameters.KerbalDestinationParameter kds = (FinePrint.Contracts.Parameters.KerbalDestinationParameter)conpara2; if (RmmUtil.AllowedBody(vessel.mainBody.name)) { if (RmmUtil.HomeBody(kds.targetBody.name) && (kds.targetType == FlightLog.EntryType.Orbit || kds.targetType == FlightLog.EntryType.Suborbit)) { //print("complete1"); CompleteContractParameter(kds); return(false); } } if (RmmUtil.AllowedBody(vessel.mainBody.name) && !RmmUtil.HomeBody(vessel.mainBody.name)) { if (kds.targetBody.name == vessel.mainBody.name && (kds.targetType == FlightLog.EntryType.Orbit || kds.targetType == FlightLog.EntryType.Flyby)) { //print("complete2"); CompleteContractParameter(kds); return(false); } } } } } // complete kerbaltour parameters on depart which have all their destinations completed if (depart) { if (conpara1.State != Contracts.ParameterState.Complete) { bool allDestinationsSucceeded = true; for (int u = 0; u < conpara1.ParameterCount; u++) { ContractParameter conpara2 = conpara1.GetParameter(u); if (conpara2.State != Contracts.ParameterState.Complete) { allDestinationsSucceeded = false; } } if (depart && allDestinationsSucceeded) { //print("complete3"); CompleteContractParameter(ktp); HighLogic.CurrentGame.CrewRoster.Remove(crew); return(false); } } } } } } } } } return(true); }
/// <summary> /// Used externally to return the name of the requested part /// </summary> /// <param name="cP">Instance of the requested Contract Parameter</param> /// <returns>Available Part name string</returns> public static string PartName(ContractParameter cP) { if (cP == null || cP.GetType() != typeof(DMAnomalyParameter)) return ""; DMAnomalyParameter aP = (DMAnomalyParameter)cP; return aP.partName; }