protected virtual bool loadAstronautRecruitedResult(ConfigNode node) { eventType = BARISEventTypes.astronautRecruited; //Rank is optional if (node.HasValue("rank")) { if (!int.TryParse(node.GetValue("rank"), out rank)) { return(false); } else { return(true); } } //Is badass? if (node.HasValue("isBadass")) { bool isBadass = bool.Parse(node.GetValue("isBadass")); if (isBadass) { statusType = BARISStatusTypes.badS; } } return(true); }
protected virtual bool astronautStatusChange(ConfigNode node) { eventType = BARISEventTypes.astronautStatusChange; //Optional: status if (node.HasValue("status")) { switch (node.GetValue("status")) { case "dead": statusType = BARISStatusTypes.dead; break; case "missing": statusType = BARISStatusTypes.missing; break; default: case "badS": statusType = BARISStatusTypes.badS; break; } } return(true); }
protected virtual bool loadIntegrationPausedResult(ConfigNode node) { eventType = BARISEventTypes.vehicleIntegrationPaused; //Minimum days is required if (node.HasValue("minDays")) { if (!int.TryParse(node.GetValue("minDays"), out minDays)) { return(false); } } else { return(false); } //Max days is optional if (node.HasValue("maxDays")) { if (!int.TryParse(node.GetValue("maxDays"), out maxDays)) { return(false); } else { return(true); } } return(false); }
/// <summary> /// De-serializes the ConfigNode into the event result fields. /// </summary> /// <param name="resultNode">A ConfigNode containing fields to load.</param> /// <returns>True if it can load the ConfigNode, false if not.</returns> public bool Load(ConfigNode resultNode) { bool validNode = false; string type = resultNode.GetValue("type"); debugLog("Type: " + type); switch (type) { case "currencyChange": validNode = loadCurrencyResult(resultNode); break; case "astronautStatusChange": validNode = astronautStatusChange(resultNode); break; case "astronautRecruited": validNode = loadAstronautRecruitedResult(resultNode); break; case "vehicleIntegrationLost": validNode = loadIntegrationLostResult(resultNode); break; case "vehicleIntegrationPaused": validNode = loadIntegrationPausedResult(resultNode); break; case "vehicleIntegrationCompleted": validNode = loadIntegrationCompletedResult(resultNode); break; case "workerPayIncrease": validNode = loadPayIncreaseResult(resultNode); break; case "qualityCheck": validNode = loadQualityCheckResult(resultNode); break; case "facilityDestroyed": validNode = loadFacilityDestroyedResult(resultNode); break; case "astronautRetires": eventType = BARISEventTypes.astronautRetires; validNode = true; break; case "custom": break; default: break; } debugLog("Loading successful: " + validNode); return(validNode); }
protected virtual bool loadCurrencyResult(ConfigNode node) { eventType = BARISEventTypes.currencyChange; //Type of currency change if (node.HasValue("currency")) { switch (node.GetValue("currency")) { case "funds": currencyType = BARISEventCurrencyTypes.funds; break; case "reputation": currencyType = BARISEventCurrencyTypes.reputation; break; case "science": currencyType = BARISEventCurrencyTypes.science; break; default: return(false); } } else { return(false); } //Multiplier takes precedence over modifier if (node.HasValue("multiplier")) { modifierType = BARISEventModifierTypes.multiplier; if (double.TryParse(node.GetValue("multiplier"), out value) == false) { return(false); } value = 1.0f + (value / 100.0f); } else if (node.HasValue("modifier")) { modifierType = BARISEventModifierTypes.modifier; if (double.TryParse(node.GetValue("modifier"), out value) == false) { return(false); } } else { return(false); } return(true); }
protected virtual bool loadPayIncreaseResult(ConfigNode node) { eventType = BARISEventTypes.workerPayIncrease; //worker type is optional if (node.HasValue("workerType")) { switch (node.GetValue("workerType")) { case "astronaut": workerType = BARISWorkerTypes.astronaut; break; case "construction": workerType = BARISWorkerTypes.construction; break; default: workerType = BARISWorkerTypes.both; break; } } else { workerType = BARISWorkerTypes.both; } //Multiplier takes precedence over modifier if (node.HasValue("multiplier")) { modifierType = BARISEventModifierTypes.multiplier; if (double.TryParse(node.GetValue("multiplier"), out value) == false) { return(false); } value = 1.0f + (value / 100.0f); } else if (node.HasValue("modifier")) { modifierType = BARISEventModifierTypes.modifier; if (double.TryParse(node.GetValue("modifier"), out value) == false) { return(false); } } else { return(false); } return(true); }
protected virtual bool loadIntegrationLostResult(ConfigNode node) { eventType = BARISEventTypes.vehicleIntegrationLost; //Should have an isVAB parameter if (node.HasValue("isVAB")) { if (!bool.TryParse(node.GetValue("isVAB"), out isVAB)) { return(false); } else { return(true); } } return(false); }
protected virtual bool loadIntegrationCompletedResult(ConfigNode node) { eventType = BARISEventTypes.vehicleIntegrationCompleted; return(true); }
protected virtual bool loadQualityCheckResult(ConfigNode node) { eventType = BARISEventTypes.qualityCheck; bool boolValue = false; bool isValid = false; //Modifier is optional if (node.HasValue("modifier")) { if (!int.TryParse(node.GetValue("modifier"), out qualityCheckModifier)) { return(false); } else { return(true); } } //isSuccess is optional else if (node.HasValue("isSuccess")) { if (!bool.TryParse(node.GetValue("isSuccess"), out boolValue)) { return(false); } else if (boolValue) { modifierType = BARISEventModifierTypes.success; } else { modifierType = BARISEventModifierTypes.fail; } isValid = true; } //isCriticalFail is optional else if (node.HasValue("isCriticalFail")) { if (!bool.TryParse(node.GetValue("isCriticalFail"), out boolValue)) { return(false); } else if (boolValue) { modifierType = BARISEventModifierTypes.criticalFail; } else { modifierType = BARISEventModifierTypes.criticalSuccess; } isValid = true; } //performImmediately is optional if (node.HasValue("performImmediately")) { if (!bool.TryParse(node.GetValue("performImmediately"), out boolValue)) { return(false); } performImmediately = boolValue; isValid = true; } return(isValid); }
protected virtual bool loadFacilityDestroyedResult(ConfigNode node) { eventType = BARISEventTypes.facilityDestroyed; return(true); }