private void onFinished(Contract c) { if (c == null) { Debug.Log("[Contract Parser] Error in loading null finished contract"); return; } contractContainer cc = contractParser.getActiveContract(c.ContractGuid); if (cc == null) { cc = contractParser.getOfferedContract(c.ContractGuid); } if (cc == null) { return; } cc.updateTimeValues(); contractParser.removeOfferedContract(cc); contractParser.removeActiveContract(cc); if (c.ContractState == Contract.State.Completed) { contractParser.addCompletedContract(cc, true); } contractParser.onContractStateChange.Fire(c); }
public static bool addFailedContract(contractContainer c, bool warn = false) { if (!failedContracts.Contains(c.ID)) { failedContracts.Add(c.ID, c); return(true); } else if (warn) { Debug.Log(string.Format("[Contract Parser] Failed Contract List Already Has Contract [{0} ; ID: {1}]", c.Title, c.ID)); } return(false); }
public static bool removeFailedContract(contractContainer c, bool warn = false) { if (failedContracts.Contains(c.ID)) { failedContracts.Remove(c.ID); return(true); } else if (warn) { Debug.Log(string.Format("[Contract Parser] Contract Not Found In Failed Contract List [{0} ; ID: {1}]", c.Title, c.ID)); } return(false); }
private void onParamChange(Contract c, ContractParameter p) { contractContainer cc = contractParser.getActiveContract(c.ContractGuid); if (cc == null) { return; } if (c.AllParameters.Count() > cc.ParameterCount) { cc.updateFullParamInfo(); contractParser.onParameterAdded.Fire(c, p); } }
private void onOffered(Contract c) { if (c == null) { Debug.Log("[Contract Parser] Error in loading null offered contract"); return; } contractContainer cc = new contractContainer(c); if (cc == null) { return; } contractParser.addOfferedContract(cc, true); contractParser.onContractStateChange.Fire(c); }
private void onDeclined(Contract c) { if (c == null) { Debug.Log("Error in loading null declined contract"); return; } contractContainer cc = contractParser.getOfferedContract(c.ContractGuid, true); if (cc == null) { return; } contractParser.removeOfferedContract(cc, true); contractParser.onContractStateChange.Fire(c); }
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); } } }
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); } } }
public static void RefreshCCOfferedContracts() { if (contractReflection.CCLoaded) { List <Contract> ccPending = new List <Contract>(); ccPending = contractReflection.pendingContracts(); if (ccPending != null) { int l = ccPending.Count; for (int i = 0; i < l; i++) { Contract c = ccPending[i]; if (c == null) { continue; } if (c.ContractState != Contract.State.Offered) { continue; } contractContainer cc = new contractContainer(c); if (cc == null) { continue; } addOfferedContract(cc); } } } }
private void onAccepted(Contract c) { if (c == null) { Debug.Log("[Contract Parser] Error in loading null accepted contract"); return; } contractContainer cc = contractParser.getOfferedContract(c.ContractGuid, true); if (cc == null) { return; } cc.updateTimeValues(); contractParser.removeOfferedContract(cc, true); contractParser.addActiveContract(cc, true); contractParser.onContractStateChange.Fire(c); }
private void onOffered(Contract c) { if (c == null) { Debug.Log("[Contract Parser] Error in loading null offered contract"); return; } contractContainer cc = new contractContainer(c); if (cc == null) return; contractParser.addOfferedContract(cc, true); contractParser.onContractStateChange.Fire(c); }
public Notes_ContractShell(contractContainer c, Notes_ContractContainer r) { contract = c; root = r; }
public static IEnumerator loadContracts() { if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER) yield break; loaded = false; int i = 0; //Agency modifiers don't seem to work unless I wait a few frames before loading contracts while (i < 5) { i++; yield return null; } Debug.Log("[Contract Parser] Loading All Contracts..."); activeContracts.Clear(); offeredContracts.Clear(); completedContracts.Clear(); failedContracts.Clear(); declinedContracts.Clear(); for (int j = 0; j < ContractSystem.Instance.Contracts.Count; j++) { Contract c = ContractSystem.Instance.Contracts[j]; if (c == null) { Debug.Log("[Contract Parser] Error in loading null contract from master list"); continue; } contractContainer cc = new contractContainer(c); if (cc.Root == null) { Debug.Log(string.Format("[Contract Parser] Error while loading contract of type {0}; skipping", c.GetType().Name)); continue; } switch (cc.Root.ContractState) { case Contract.State.Active: addActiveContract(cc); continue; case Contract.State.Offered: addOfferedContract(cc); continue; case Contract.State.Completed: addCompletedContract(cc); continue; case Contract.State.Cancelled: case Contract.State.DeadlineExpired: case Contract.State.Failed: addFailedContract(cc); continue; default: continue; } } for (int j = 0; j < ContractSystem.Instance.ContractsFinished.Count; j++) { Contract c = ContractSystem.Instance.ContractsFinished[j]; if (c == null) { Debug.Log("[Contract Parser] Error in loading contract from finished list"); continue; } contractContainer cc = new contractContainer(c); if (cc.Root == null) { Debug.Log(string.Format("[Contract Parser] Error while loading finished contract of type {0}; skipping", c.GetType().Name)); continue; } switch (cc.Root.ContractState) { case Contract.State.Active: addActiveContract(cc); continue; case Contract.State.Offered: addOfferedContract(cc); continue; case Contract.State.Completed: addCompletedContract(cc); continue; case Contract.State.Cancelled: case Contract.State.DeadlineExpired: case Contract.State.Failed: addFailedContract(cc); continue; default: continue; } } if (contractReflection.CCLoaded) RefreshCCOfferedContracts(); loaded = true; onContractsParsed.Fire(); Debug.Log("[Contract Parser] Finished Loading All Contracts"); }
public static bool removeFailedContract(contractContainer c, bool warn = false) { if (failedContracts.Contains(c.ID)) { failedContracts.Remove(c.ID); return true; } else if (warn) Debug.Log(string.Format("[Contract Parser] Contract Not Found In Failed Contract List [{0} ; ID: {1}]", c.Title, c.ID)); return false; }
public static bool addFailedContract(contractContainer c, bool warn = false) { if (!failedContracts.Contains(c.ID)) { failedContracts.Add(c.ID, c); return true; } else if (warn) Debug.Log(string.Format("[Contract Parser] Failed Contract List Already Has Contract [{0} ; ID: {1}]", c.Title, c.ID)); return false; }
public static void RefreshCCOfferedContracts() { if (contractReflection.CCLoaded) { List<Contract> ccPending = new List<Contract>(); ccPending = contractReflection.pendingContracts(); if (ccPending != null) { int l = ccPending.Count; for (int i = 0; i < l; i++) { Contract c = ccPending[i]; if (c == null) continue; if (c.ContractState != Contract.State.Offered) continue; contractContainer cc = new contractContainer(c); if (cc == null) continue; addOfferedContract(cc); } } } }
public static IEnumerator loadContracts() { if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER) { yield break; } loaded = false; int i = 0; //Agency modifiers don't seem to work unless I wait a few frames before loading contracts while (i < 5) { i++; yield return(null); } Debug.Log("[Contract Parser] Loading All Contracts..."); activeContracts.Clear(); offeredContracts.Clear(); completedContracts.Clear(); failedContracts.Clear(); declinedContracts.Clear(); for (int j = 0; j < ContractSystem.Instance.Contracts.Count; j++) { Contract c = ContractSystem.Instance.Contracts[j]; if (c == null) { Debug.Log("[Contract Parser] Error in loading null contract from master list"); continue; } contractContainer cc = new contractContainer(c); if (cc.Root == null) { Debug.Log(string.Format("[Contract Parser] Error while loading contract of type {0}; skipping", c.GetType().Name)); continue; } switch (cc.Root.ContractState) { case Contract.State.Active: addActiveContract(cc); continue; case Contract.State.Offered: addOfferedContract(cc); continue; case Contract.State.Completed: addCompletedContract(cc); continue; case Contract.State.Cancelled: case Contract.State.DeadlineExpired: case Contract.State.Failed: addFailedContract(cc); continue; default: continue; } } for (int j = 0; j < ContractSystem.Instance.ContractsFinished.Count; j++) { Contract c = ContractSystem.Instance.ContractsFinished[j]; if (c == null) { Debug.Log("[Contract Parser] Error in loading contract from finished list"); continue; } contractContainer cc = new contractContainer(c); if (cc.Root == null) { Debug.Log(string.Format("[Contract Parser] Error while loading finished contract of type {0}; skipping", c.GetType().Name)); continue; } switch (cc.Root.ContractState) { case Contract.State.Active: addActiveContract(cc); continue; case Contract.State.Offered: addOfferedContract(cc); continue; case Contract.State.Completed: addCompletedContract(cc); continue; case Contract.State.Cancelled: case Contract.State.DeadlineExpired: case Contract.State.Failed: addFailedContract(cc); continue; default: continue; } } if (contractReflection.CCLoaded) { RefreshCCOfferedContracts(); } loaded = true; onContractsParsed.Fire(); Debug.Log("[Contract Parser] Finished Loading All Contracts"); }
private void selectContract(int i, bool selectMany = false) { contractIndex = i; if (!selectMany) selectedContracts.Clear(); if (currentContracts.Count > 0) currentContract = currentContracts[contractIndex]; else currentContract = null; if (selectMany && selectedContracts.Contains(currentContract)) selectedContracts.Remove(currentContract); else selectedContracts.Add(currentContract); showAgency = false; }