protected override void Perform(BooterHelper.BootFile file, XmlDbRow row) { BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile; if (dataFile == null) { return; } mIndex++; string personalityName = row.GetString("Name"); if (string.IsNullOrEmpty(personalityName)) { BooterLogger.AddError(file + " : Method " + mIndex + " Unnamed"); return; } BooterLogger.AddTrace("Found " + personalityName); if (GetPersonality(personalityName) != null) { BooterLogger.AddError(personalityName + " Name already in use"); return; } Type classType = row.GetClassType("FullClassName"); if (classType == null) { BooterLogger.AddError(personalityName + " No Class"); return; } SimPersonality personality = null; try { personality = classType.GetConstructor(new Type[0]).Invoke(new object[0]) as SimPersonality; } catch { } if (personality == null) { BooterLogger.AddError(personalityName + ": Constructor Fail " + row.GetString("FullClassName")); } else { XmlDbTable optionTable = dataFile.GetTable(personalityName); if (personality.Parse(row, optionTable)) { sLookup.Add(personalityName.ToLower(), personality); } else { BooterLogger.AddError(personalityName + ": Parsing Fail"); } } }
protected void LoadStage(BooterHelper.BootFile file, XmlDbRow row) { Type type = row.GetClassType("FullClassName"); if (type == null) { BooterLogger.AddError("Invalid FullClassName: " + row.GetString("FullClassName")); return; } Stage stage = null; try { stage = type.GetConstructor(new Type[] { typeof(XmlDbRow) }).Invoke(new object[] { row }) as Stage; } catch (Exception e) { BooterLogger.AddError("Contructor Fail: " + row.GetString("FullClassName")); Common.Exception(file + Common.NewLine + row.GetString("FullClassName") + " Fail", e); } if (stage != null) { mStages.Add(stage); } }
protected override void Perform(BooterHelper.BootFile file, XmlDbRow row) { string toneName = row.GetString("ToneName"); if (string.IsNullOrEmpty(toneName)) { BooterLogger.AddError("Tone found with no name"); return; } Type classType = row.GetClassType("FullClassName"); if (classType == null) { BooterLogger.AddError("Tone: " + toneName + " FullClassName no match"); return; } string guid = row.GetString("CareerGuid"); OccupationNames careerGuid = OccupationNames.Undefined; ParserFunctions.TryParseEnum<OccupationNames>(guid, out careerGuid, OccupationNames.Undefined); if (careerGuid == OccupationNames.Undefined) { careerGuid = unchecked((OccupationNames)ResourceUtils.HashString64(guid)); } Career staticCareer = CareerManager.GetStaticCareer (careerGuid); if (staticCareer == null) { BooterLogger.AddError("Tone: " + toneName + " CareerGuid no match"); return; } staticCareer.SharedData.ToneDefinitions.Add(new CareerBooterToneDefinition(row, classType)); }
protected override void Perform(BooterHelper.BootFile file, XmlDbRow row) { BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile; if (dataFile == null) return; mIndex++; string personalityName = row.GetString("Name"); if (string.IsNullOrEmpty(personalityName)) { BooterLogger.AddError(file + " : Method " + mIndex + " Unnamed"); return; } BooterLogger.AddTrace("Found " + personalityName); if (GetPersonality(personalityName) != null) { BooterLogger.AddError(personalityName + " Name already in use"); return; } Type classType = row.GetClassType("FullClassName"); if (classType == null) { BooterLogger.AddError(personalityName + " No Class"); return; } SimPersonality personality = null; try { personality = classType.GetConstructor(new Type[0]).Invoke(new object[0]) as SimPersonality; } catch { } if (personality == null) { BooterLogger.AddError(personalityName + ": Constructor Fail " + row.GetString("FullClassName")); } else { XmlDbTable optionTable = dataFile.GetTable(personalityName); if (personality.Parse(row, optionTable)) { sLookup.Add(personalityName.ToLower(), personality); } else { BooterLogger.AddError(personalityName + ": Parsing Fail"); } } }
protected override void Perform(BooterHelper.BootFile file, XmlDbRow row) { Type type = row.GetClassType("Type"); if (type == null) { BooterLogger.AddError("Invalid Type: " + row.GetString("Type")); return; } sData.Add(type, true); BooterLogger.AddTrace(" Discount Type: " + row.GetString("Type")); }
public bool Parse(XmlDbRow row, Origin origin, string prefix, ref string error) { if ((!string.IsNullOrEmpty(prefix)) && (!Parse(row, origin, null, ref error))) { return(false); } if (row.Exists(prefix + "PropagateFullClassName")) { Type scenarioType = row.GetClassType(prefix + "PropagateFullClassName"); if (scenarioType == null) { error = prefix + "PropagateFullClassName invalid"; return(false); } mScenario = null; try { mScenario = scenarioType.GetConstructor(new Type[0]).Invoke(new object[0]) as PropagateBuffScenario; } catch { } if (mScenario == null) { error = prefix + "PropagateFullClassName constructor fail"; return(false); } mScenario.Origin = origin; if (!mScenario.Parse(row, prefix, true, ref error)) { return(false); } if (!mScenario.PostParse(ref error)) { return(false); } } return(true); }
public virtual bool Parse(XmlDbRow row) { mParentType = row.GetClassType("FullClassName"); if (mParentType == null) { BooterLogger.AddError("Unknown FullClassName: " + row.GetString("FullClassName")); return(false); } mFieldName = row.GetString("FieldName"); if (string.IsNullOrEmpty(mFieldName)) { BooterLogger.AddError("FieldName missing for " + mParentType.ToString()); return(false); } return(true); }
protected override void Perform(BooterHelper.BootFile file, XmlDbRow row) { string guid = row.GetString("GUID"); if (string.IsNullOrEmpty(guid)) { BooterLogger.AddError("Invalid GUID: " + guid); return; } else if (sInstigators.ContainsKey(guid)) { BooterLogger.AddError("Duplicate GUID: " + guid); return; } Type type = row.GetClassType("FullClassName"); if (type == null) { BooterLogger.AddError(guid + " Invalid FullClassName: " + row.GetString("FullClassName")); return; } Data symptom = null; try { symptom = type.GetConstructor(new Type[] { typeof(XmlDbRow) }).Invoke(new object[] { row }) as Data; } catch (Exception e) { BooterLogger.AddError("Contructor Fail: " + row.GetString("FullClassName")); Common.Exception(guid + Common.NewLine + row.GetString("FullClassName") + " Fail", e); } if (symptom != null) { sInstigators.Add(guid, symptom); } }
protected override void Perform(BooterHelper.BootFile file, XmlDbRow row) { string toneName = row.GetString("ToneName"); if (string.IsNullOrEmpty(toneName)) { BooterLogger.AddError("Tone found with no name"); return; } Type classType = row.GetClassType("FullClassName"); if (classType == null) { BooterLogger.AddError("Tone: " + toneName + " FullClassName no match"); return; } string guid = row.GetString("CareerGuid"); OccupationNames careerGuid = OccupationNames.Undefined; ParserFunctions.TryParseEnum <OccupationNames>(guid, out careerGuid, OccupationNames.Undefined); if (careerGuid == OccupationNames.Undefined) { careerGuid = unchecked ((OccupationNames)ResourceUtils.HashString64(guid)); } Career staticCareer = CareerManager.GetStaticCareer(careerGuid); if (staticCareer == null) { BooterLogger.AddError("Tone: " + toneName + " CareerGuid no match"); return; } staticCareer.SharedData.ToneDefinitions.Add(new CareerBooterToneDefinition(row, classType)); }
public override bool Parse(XmlDbRow row, SimPersonality personality, ref string error) { ProductVersion productVersion; if (!ParserFunctions.TryParseEnum <ProductVersion>(row.GetString("ProductVersion"), out productVersion, ProductVersion.BaseGame)) { error = "ProductVersion missing"; return(false); } if (!GameUtils.IsInstalled(productVersion)) { return(true); } string module = row.GetString("Module"); if ((!string.IsNullOrEmpty(module)) && (!Common.AssemblyCheck.IsInstalled(module))) { return(true); } // Must be after the product version checks, but before everything else if (!base.Parse(row, personality, ref error)) { return(false); } if (!row.Exists("Scenario")) { error = "Scenario missing"; return(false); } else if (!row.Exists("Weight")) { error = "Weight missing"; return(false); } else if (!row.Exists("Name")) { error = "Name missing"; return(false); } mName = new NameOption(row); Type classType = row.GetClassType("Scenario"); if (classType == null) { error = "Scenario class not found"; return(false); } int weight = row.GetInt("Weight"); if (weight > 0) { mVisible = true; } else { weight = 1; if (!row.Exists("ShouldPush")) { error = "ShouldPush missing"; return(false); } } SetValue(weight); try { mScenario = classType.GetConstructor(new Type[0]).Invoke(new object[0]) as Scenario; } catch {} if (mScenario == null) { error = "Scenario constructor fail"; return(false); } mScenario.Manager = personality; if (!mScenario.Parse(row, ref error)) { return(false); } if (!mScenario.PostParse(ref error)) { return(false); } IViolentScenario violentScenario = mScenario as IViolentScenario; if ((violentScenario != null) && (violentScenario.IsViolent)) { PushDeathChanceOption.Installed = true; } return(true); }
public void LoadCareer(BooterHelper.BootFile file, XmlDbRow row) { BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile; if (dataFile == null) { return; } string careerName = row.GetString("CareerName"); if (careerName == null) { BooterLogger.AddError(file.ToString() + ": No CareerName"); } else { Type classType = row.GetClassType("FullClassName"); if (classType != null) { string key = row.GetString("TableName"); XmlDbTable levelTable = dataFile.GetTable(key); if (levelTable != null) { foreach (XmlDbRow levelRow in levelTable.Rows) { XmlDbData.XmlDbRowFast level = levelRow as XmlDbData.XmlDbRowFast; if (level == null) { continue; } if (!level.Exists("DowntownWakeupTime")) { level.mData.Add("DowntownWakeupTime", level.GetString("WakeupTime")); } if (!level.Exists("DowntownStartTime")) { level.mData.Add("DowntownStartTime", level.GetString("StartTime")); } if (!level.Exists("DowntownDayLength")) { level.mData.Add("DowntownDayLength", level.GetString("DayLength")); } } Type[] types = new Type[] { typeof(XmlDbRow), typeof(XmlDbTable), typeof(XmlDbTable) }; Career career = null; try { career = classType.GetConstructor(types).Invoke(new object[] { row, levelTable, null }) as Career; } catch (Exception e) { BooterLogger.AddError(careerName + ": Constructor Fail " + row.GetString("FullClassName")); Common.Exception(careerName + ": Constructor Fail " + row.GetString("FullClassName"), e); return; } if (career != null) { if (mCareerEventsFile.IsValid) { XmlDbTable table3 = mCareerEventsFile.GetTable(key); if (table3 != null) { LoadCareerEvents(career, mCareerEventsFile, table3); } } career.mCareerGuid = unchecked ((OccupationNames)ResourceUtils.HashString64(row.GetString("AltGuid"))); if (career.Guid == OccupationNames.Undefined) { BooterLogger.AddError(careerName + ": No AltGuid"); } else if (CareerManager.GetStaticCareer(career.mCareerGuid) != null) { BooterLogger.AddError(careerName + ": Duplicate GUID"); } else { RabbitHoleType type = RabbitHoleType.None; ParserFunctions.TryParseEnum <RabbitHoleType>(row.GetString("RabbitholeType"), out type, RabbitHoleType.None); if (type != RabbitHoleType.None) { sCareers.Add(new CareerBooterElement(career.Guid, type)); CareerManager.AddStaticOccupation(career); BooterLogger.AddTrace(careerName + ": Added to Rabbithole " + type); } else { BooterLogger.AddError(careerName + ": Unknown Rabbithole"); } } } else { BooterLogger.AddError(careerName + ": Constructor Fail " + row.GetString("FullClassName")); } } else { BooterLogger.AddError(careerName + ": No TableName"); } } else { BooterLogger.AddError(careerName + ": Invalid FullClassName " + row.GetString("FullClassName")); } } }
public virtual bool Parse(XmlDbRow row) { mParentType = row.GetClassType("FullClassName"); if (mParentType == null) { BooterLogger.AddError("Unknown FullClassName: " + row.GetString("FullClassName")); return false; } mFieldName = row.GetString("FieldName"); if (string.IsNullOrEmpty(mFieldName)) { BooterLogger.AddError("FieldName missing for " + mParentType.ToString()); return false; } return true; }
protected override void Perform(BooterHelper.BootFile file, XmlDbRow row) { BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile; if (dataFile == null) return; bool success = false; mIndex++; try { string methodName = row.GetString("Name"); if (string.IsNullOrEmpty(methodName)) { BooterLogger.AddError(file + " : Method " + mIndex + " Unnamed"); } else if (ScoringLookup.GetScoring(methodName, false) != null) { BooterLogger.AddError(methodName + " Name already in use"); return; } else { Type classType = row.GetClassType("FullClassName"); if (classType == null) { BooterLogger.AddError(methodName + " Unknown FullClassName: " + row.GetString("FullClassName")); } else { IListedScoringMethod scoring = null; try { scoring = classType.GetConstructor(new Type[0]).Invoke(new object[0]) as IListedScoringMethod; } catch { } if (scoring == null) { BooterLogger.AddError(methodName + ": Constructor Fail " + row.GetString("FullClassName")); } else { XmlDbTable scoringTable = dataFile.GetTable(methodName); if (scoringTable == null) { BooterLogger.AddError(methodName + ": Table Missing"); } else { if (scoring.Parse(row, scoringTable)) { BooterLogger.AddTrace("Added Scoring : " + methodName); ScoringLookup.AddScoring(methodName, scoring); success = true; } else { BooterLogger.AddError(methodName + ": Parsing Fail"); } } } } } } finally { if (!success) { foreach (string column in row.ColumnNames) { BooterLogger.AddError(column + "= " + row[column]); } } } }
protected override void Perform(BooterHelper.BootFile file, XmlDbRow row) { BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile; if (dataFile == null) { return; } bool success = false; mIndex++; try { string methodName = row.GetString("Name"); if (string.IsNullOrEmpty(methodName)) { BooterLogger.AddError(file + " : Method " + mIndex + " Unnamed"); } else if (ScoringLookup.GetScoring(methodName, false) != null) { BooterLogger.AddError(methodName + " Name already in use"); return; } else { Type classType = row.GetClassType("FullClassName"); if (classType == null) { BooterLogger.AddError(methodName + " Unknown FullClassName: " + row.GetString("FullClassName")); } else { IListedScoringMethod scoring = null; try { scoring = classType.GetConstructor(new Type[0]).Invoke(new object[0]) as IListedScoringMethod; } catch { } if (scoring == null) { BooterLogger.AddError(methodName + ": Constructor Fail " + row.GetString("FullClassName")); } else { XmlDbTable scoringTable = dataFile.GetTable(methodName); if (scoringTable == null) { BooterLogger.AddError(methodName + ": Table Missing"); } else { if (scoring.Parse(row, scoringTable)) { BooterLogger.AddTrace("Added Scoring : " + methodName); ScoringLookup.AddScoring(methodName, scoring); success = true; } else { BooterLogger.AddError(methodName + ": Parsing Fail"); } } } } } } finally { if (!success) { foreach (string column in row.ColumnNames) { BooterLogger.AddError(column + "= " + row[column]); } } } }
public static ArrayList ParseRewards(XmlDbRow dr, string[] columnKeys, int numRewards) { try { ArrayList list = new ArrayList(); for (int i = 0; i < numRewards; i++) { bool flag = false; List<string> entry = dr.GetStringList(columnKeys[i], ',', false); if (entry.Count > 0) { RewardType type; for (int j = 0; j < entry.Count; j++) { entry[j] = entry[j].Trim(); } if (ParserFunctions.TryParseEnum<RewardType>(entry[0], out type, RewardType.Undefined)) { RewardInfo info = null; switch (type) { case RewardType.BookSkill: info = RewardsManager.ParseBookSkillRewardInfo(entry); flag = info != null; break; case RewardType.Buff: info = RewardsManager.ParseBuffRewardInfo(entry); flag = info != null; break; case RewardType.CareerDemotion: case RewardType.CareerFired: case RewardType.CareerPromotion: case RewardType.UnknownRecipe: case RewardType.UnlearnedComposition: case RewardType.CompedMeal: case RewardType.BookQualityIncrease: case RewardType.ConcertsPerformed: info = new RewardInfo(); info.mType = type; flag = true; break; case RewardType.Ingredient: info = RewardsManager.ParseIngredientRewardInfo(entry); flag = info != null; break; case RewardType.Money: info = RewardsManager.ParseMoneyRewardInfo(entry); flag = info != null; break; case RewardType.RandomGroupMeal: info = RewardsManager.ParseRandomGroupMealRewardInfo(entry); flag = info != null; break; case RewardType.RandomPlantable: info = RewardsManager.ParseRandomPlantableRewardInfo(entry); flag = info != null; break; case RewardType.RandomObject: info = RewardsManager.ParseRandomObjectReward(entry); flag = info != null; break; case RewardType.SkillPercentage: info = ParseSkillRewardInfo(entry); flag = info != null; break; case RewardType.RandomFish: info = RewardsManager.ParseRandomFishRewardInfo(entry); flag = info != null; break; case RewardType.PaintingValueBoost: info = RewardsManager.ParsePaintingValueBoostRewardInfo(entry); flag = info != null; break; case RewardType.GroupMeal: info = RewardsManager.ParseGroupMealReward(entry); flag = info != null; break; case RewardType.ObjectInMail: info = RewardsManager.ParseObjectInMailReward(entry); flag = info != null; break; case RewardType.Harvestable: info = RewardsManager.ParseHarvestableRewardInfo(entry); flag = info != null; break; case RewardType.OmniPlantSeeds: info = RewardsManager.ParseOmniPlantSeedsRewardInfo(entry); flag = info != null; break; case RewardType.AncientCoin: info = RewardsManager.ParseAncientCoinInfo(entry); flag = info != null; break; case RewardType.VisaPoints: info = RewardsManager.ParseVisaPointsInfo(entry); flag = info != null; break; case RewardType.TreasureComponentRow: info = RewardsManager.ParseTreasureComponentRow(entry); flag = info != null; break; default: info = new RewardInfo(); info.mType = type; if (entry.Count == 0x2) { flag = int.TryParse(entry[0x1], out info.mAmount); } break; } if (flag) { list.Add(info); } } else { Type rewardType = dr.GetClassType(columnKeys[i]); if (rewardType != null) { RewardInfoEx reward = (RewardInfoEx)rewardType.GetConstructor(new Type[0]).Invoke(new object[0]); if (reward != null) { list.Add(reward); } else { BooterLogger.AddError("Unknown reward: " + dr.GetString(columnKeys[i])); } } else { BooterLogger.AddError("Unknown reward: " + dr.GetString(columnKeys[i])); } } } } if (list.Count != 0) { return list; } } catch (Exception e) { Common.Exception("ParseRewards", e); } return null; }
public void LoadCareer(BooterHelper.BootFile file, XmlDbRow row) { BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile; if (dataFile == null) return; string careerName = row.GetString("CareerName"); if (careerName == null) { BooterLogger.AddError(file.ToString() + ": No CareerName"); } else { Type classType = row.GetClassType("FullClassName"); if (classType != null) { string key = row.GetString("TableName"); XmlDbTable levelTable = dataFile.GetTable(key); if (levelTable != null) { foreach (XmlDbRow levelRow in levelTable.Rows) { XmlDbData.XmlDbRowFast level = levelRow as XmlDbData.XmlDbRowFast; if (level == null) continue; if (!level.Exists("DowntownWakeupTime")) { level.mData.Add("DowntownWakeupTime", level.GetString("WakeupTime")); } if (!level.Exists("DowntownStartTime")) { level.mData.Add("DowntownStartTime", level.GetString("StartTime")); } if (!level.Exists("DowntownDayLength")) { level.mData.Add("DowntownDayLength", level.GetString("DayLength")); } } Type[] types = new Type[] { typeof(XmlDbRow), typeof(XmlDbTable), typeof(XmlDbTable) }; Career career = null; try { career = classType.GetConstructor(types).Invoke(new object[] { row, levelTable, null }) as Career; } catch (Exception e) { BooterLogger.AddError(careerName + ": Constructor Fail " + row.GetString("FullClassName")); Common.Exception(careerName + ": Constructor Fail " + row.GetString("FullClassName"), e); return; } if (career != null) { if (mCareerEventsFile.IsValid) { XmlDbTable table3 = mCareerEventsFile.GetTable(key); if (table3 != null) { LoadCareerEvents(career, mCareerEventsFile, table3); } } career.mCareerGuid = unchecked((OccupationNames)ResourceUtils.HashString64(row.GetString("AltGuid"))); if (career.Guid == OccupationNames.Undefined) { BooterLogger.AddError(careerName + ": No AltGuid"); } else if (CareerManager.GetStaticCareer(career.mCareerGuid) != null) { BooterLogger.AddError(careerName + ": Duplicate GUID"); } else { RabbitHoleType type = RabbitHoleType.None; ParserFunctions.TryParseEnum<RabbitHoleType>(row.GetString("RabbitholeType"), out type, RabbitHoleType.None); if (type != RabbitHoleType.None) { sCareers.Add(new CareerBooterElement(career.Guid, type)); CareerManager.AddStaticOccupation(career); BooterLogger.AddTrace(careerName + ": Added to Rabbithole " + type); } else { BooterLogger.AddError(careerName + ": Unknown Rabbithole"); } } } else { BooterLogger.AddError(careerName + ": Constructor Fail " + row.GetString("FullClassName")); } } else { BooterLogger.AddError(careerName + ": No TableName"); } } else { BooterLogger.AddError(careerName + ": Invalid FullClassName " + row.GetString("FullClassName")); } } }
public override bool Parse(XmlDbRow row, SimPersonality personality, ref string error) { ProductVersion productVersion; if (!ParserFunctions.TryParseEnum<ProductVersion>(row.GetString("ProductVersion"), out productVersion, ProductVersion.BaseGame)) { error = "ProductVersion missing"; return false; } if (!GameUtils.IsInstalled(productVersion)) { return true; } string module = row.GetString("Module"); if ((!string.IsNullOrEmpty(module)) && (!Common.AssemblyCheck.IsInstalled(module))) { return true; } // Must be after the product version checks, but before everything else if (!base.Parse(row, personality, ref error)) return false; if (!row.Exists("Scenario")) { error = "Scenario missing"; return false; } else if (!row.Exists("Weight")) { error = "Weight missing"; return false; } else if (!row.Exists("Name")) { error = "Name missing"; return false; } mName = new NameOption(row); Type classType = row.GetClassType("Scenario"); if (classType == null) { error = "Scenario class not found"; return false; } int weight = row.GetInt("Weight"); if (weight > 0) { mVisible = true; } else { weight = 1; if (!row.Exists("ShouldPush")) { error = "ShouldPush missing"; return false; } } SetValue (weight); try { mScenario = classType.GetConstructor(new Type[0]).Invoke(new object[0]) as Scenario; } catch {} if (mScenario == null) { error = "Scenario constructor fail"; return false; } mScenario.Manager = personality; if (!mScenario.Parse(row, ref error)) { return false; } if (!mScenario.PostParse(ref error)) { return false; } IViolentScenario violentScenario = mScenario as IViolentScenario; if ((violentScenario != null) && (violentScenario.IsViolent)) { PushDeathChanceOption.Installed = true; } return true; }