public static int[] GetContractDifficultyVariances(SimGameState.SimGameType gameMode, TagSet companyTags) { //Logger.Info("[Utilities.GetMaxAllowedContractDifficultyVariance] companyTags: " + companyTags); // For CAREER mode ContractDifficulty is based on starsystem difficulty atm... if (gameMode == SimGameState.SimGameType.CAREER) { return(new int[] { 1, 1 }); } // To be able to play low difficulty contracts during/after KAMEA_CAMPAIGN the lower variance value slowly rises... if (companyTags.Contains("story_complete")) { return(new int[] { 5, 2 }); } else if (companyTags.Contains("oc09_post_damage_report")) { return(new int[] { 3, 1 }); } else if (companyTags.Contains("oc04_post_argo")) { return(new int[] { 2, 1 }); } else { return(new int[] { 1, 1 }); } }
public bool IsThisType(MechDef mechdef) { if (mechdef?.Chassis == null) { return(false); } TagSet tags = new TagSet(); if (mechdef.MechTags != null) { tags.UnionWith(mechdef.MechTags); } if (mechdef.Chassis.ChassisTags != null) { tags.UnionWith(mechdef.Chassis.ChassisTags); } if (RequiredTags != null && RequiredTags.Length > 0) { foreach (var tag in RequiredTags) { if (!tags.Contains(tag)) { return(false); } } } if (ForbiddenTags != null && ForbiddenTags.Length > 0) { foreach (var tag in ForbiddenTags) { if (tags.Contains(tag)) { return(false); } } } if (AnyTags == null || AnyTags.Length == 0) { return(true); } return(AnyTags.Any(i => tags.Contains(i))); }
public static float GetTonnage(ICombatant combatant) { float tonnage = 0f; if (combatant == null) { Mod.Log.Debug?.Write($"Combatant is null, using tonnage of 0!"); } else if (combatant is BattleTech.Building) { Mod.Log.Debug?.Write($"Using virtual tonnage: {Mod.Config.VirtualTonnage.Building} for building: {combatant.DistinctId()}"); return(Mod.Config.VirtualTonnage.Building); } else if (combatant is Turret turret) { TagSet actorTags = turret.GetTags(); if (actorTags != null && actorTags.Contains("unit_light")) { tonnage = Mod.Config.VirtualTonnage.LightTurret; } else if (actorTags != null && actorTags.Contains("unit_medium")) { tonnage = Mod.Config.VirtualTonnage.MediumTurret; } else if (actorTags != null && actorTags.Contains("unit_heavy")) { tonnage = Mod.Config.VirtualTonnage.HeavyTurret; } else { tonnage = Mod.Config.VirtualTonnage.DefaultTurret; } Mod.Log.Debug?.Write($"Using virtual tonnage: {tonnage} for turret: {turret.DistinctId()}"); return(tonnage > Mod.Config.TonnageCap ? Mod.Config.TonnageCap : tonnage); } else if (combatant is Mech mech) { Mod.Log.Debug?.Write($"Using tonnage: {mech.tonnage} for mech: {mech.DistinctId()}"); return(mech.tonnage > Mod.Config.TonnageCap ? Mod.Config.TonnageCap : mech.tonnage); } else if (combatant is Vehicle vehicle) { Mod.Log.Debug?.Write($"Using tonnage: {vehicle.tonnage} for vehicle: {vehicle.DistinctId()}"); return(vehicle.tonnage > Mod.Config.TonnageCap ? Mod.Config.TonnageCap : vehicle.tonnage); } return(tonnage > Mod.Config.TonnageCap ? Mod.Config.TonnageCap : tonnage); }
// If the wielder does not have a group ID that is compatible with this effect, discriminate private static GameEffectActorMethod CreateMethod_WeaponClassism(string tag, float damageScaleModifier) { return(delegate(EffectContext context, Actor targetActor) { Actor wielder = context.sourceActor; TagSet wielderTags = wielder.ActorDef.tags; WeaponBody sourceWeapon = context.sourceWeapon; damageScaleModifier *= 0.1f; // If this weapon is being used by an actor of the proper class... if (wielderTags.Contains(tag)) { // Beneficiate... Debug.Log("You are the one! Applied damage scale modifier of " + damageScaleModifier.ToString()); targetActor.ApplyHitDamage(context, 1f + damageScaleModifier); } // If this weapon is being used by an actor of the proper class... else { // Discriminate... Debug.Log("You are NOT the one. Applied damage scale modifier of " + damageScaleModifier.ToString()); targetActor.ApplyHitDamage(context, 1f + (-damageScaleModifier)); } }); }
public static void Postfix(SimGameState __instance, TagSet ___companyTags) { try { Logger.Debug($"[SimGameState_OnAttachUXComplete_POSTFIX] Called"); bool heavyMetalCompleted = ___companyTags.Contains("flashpoint_HM7_showdown_complete"); TagSet heavyMetalTagSet = new TagSet(___companyTags.ToArray().Where(tag => tag.Contains("HM")).ToList()); Logger.Debug($"[SimGameState_OnAttachUXComplete_POSTFIX] SimGameState.companyTags: {___companyTags}"); Logger.Debug($"[SimGameState_OnAttachUXComplete_POSTFIX] heavyMetalTagSet: {heavyMetalTagSet}"); Logger.Debug($"[SimGameState_OnAttachUXComplete_POSTFIX] SimGameState.completedFlashpoints: {string.Join(",", __instance.completedFlashpoints.ToArray())}"); if (heavyMetalCompleted) { ___companyTags.RemoveRange(heavyMetalTagSet); __instance.completedFlashpoints.RemoveAll(item => item.Contains("fp_HM")); // Items are hashed, cannot extract HM-specific ones... just kill em all __instance.AlreadyClickedConversationResponses.Clear(); } Logger.Debug("---"); Logger.Debug($"[SimGameState_OnAttachUXComplete_POSTFIX] SimGameState.companyTags: {___companyTags}"); Logger.Debug($"[SimGameState_OnAttachUXComplete_POSTFIX] SimGameState.completedFlashpoints: {string.Join(",", __instance.completedFlashpoints.ToArray())}"); } catch (Exception e) { Logger.Error(e); } }
public void Dispose() { if (_items.Contains(Value)) { _items.Remove(Value); } }
public static void Postfix(ref List <TagSet_MDD> __result, TagSetType tagSetType, TagSet requiredTags, TagSet excludedTags) { try { //MAD: string overrideBlacklistedTag = ("ignoreTag-BLACKLISTED").ToLower(); if (!requiredTags.Contains(overrideBlacklistedTag)) { return; } //:DAM MetadataDatabase mdd = MetadataDatabase.Instance; TagSet tags = new TagSet(requiredTags); TagSet tagSet = new TagSet(excludedTags); if (!tagSet.Contains(Tags_MDDExtenstions.BLACKLISTED_TAG)) { tagSet.Add(Tags_MDDExtenstions.BLACKLISTED_TAG); } //MAD: if (tags.Contains(overrideBlacklistedTag)) { Logger.Debug($"[Tags_MDDExtenstions_GetTagSetWithRequiredTags_PREFIX] Request has ignoreTag-BLACKLISTED tag set. Removing BLACKLISTED tag"); tagSet.Remove(Tags_MDDExtenstions.BLACKLISTED_TAG); // Need to remove the custom tag too, otherwise the query below will include it as required -> no result -> fallback unit (cicada) tags.Remove(overrideBlacklistedTag); Logger.Info($"[SimGameState_ResolveCompleteContract_PREFIX] requiredTags: {String.Join(", ", tags.ToArray())}"); Logger.Info($"[SimGameState_ResolveCompleteContract_PREFIX] excludedTags: {String.Join(", ", tagSet.ToArray())}"); } //:DAM List <Tag_MDD> orCreateTagsInTagSet = mdd.GetOrCreateTagsInTagSet(tags); List <Tag_MDD> orCreateTagsInTagSet2 = mdd.GetOrCreateTagsInTagSet(tagSet); string text = "SELECT ts.* FROM TagSet ts "; string text2 = string.Empty; string text3 = string.Format("WHERE ts.TagSetTypeId = {0} ", (int)tagSetType); for (int i = 0; i < orCreateTagsInTagSet.Count; i++) { text2 += string.Format(Tags_MDDExtenstions.GTSWRT_RequiredInnerJoinFormat, i); text3 += string.Format(Tags_MDDExtenstions.GTSWRT_RequiredWhereClauseFormat, i, orCreateTagsInTagSet[i].Name); } for (int j = 0; j < orCreateTagsInTagSet2.Count; j++) { text2 += string.Format(Tags_MDDExtenstions.GTSWRT_ExcludedLeftJoinFormat, j, orCreateTagsInTagSet2[j].Name); text3 += string.Format(Tags_MDDExtenstions.GTSWRT_ExcludedWhereClauseFormat, j); } text = text + text2 + text3 + " COLLATE NOCASE "; __result = mdd.Query <TagSet_MDD>(text, null, null, true, null, null).ToList <TagSet_MDD>(); } catch (Exception e) { Logger.Error(e); } }
public static int GetPilotSkillLevel(TagSet pilotTagSet) { if (pilotTagSet.Contains("pilot_npc_d10")) { return(10); } if (pilotTagSet.Contains("pilot_npc_d9")) { return(9); } if (pilotTagSet.Contains("pilot_npc_d8")) { return(8); } if (pilotTagSet.Contains("pilot_npc_d7")) { return(7); } if (pilotTagSet.Contains("pilot_npc_d6")) { return(6); } if (pilotTagSet.Contains("pilot_npc_d5")) { return(5); } if (pilotTagSet.Contains("pilot_npc_d4")) { return(4); } if (pilotTagSet.Contains("pilot_npc_d3")) { return(3); } if (pilotTagSet.Contains("pilot_npc_d2")) { return(2); } if (pilotTagSet.Contains("pilot_npc_d1")) { return(1); } // Default return(7); }
public static void Postfix(Weapon __instance, ref float __result) { if (ModInit.Settings.UsePlanetGravityTags == true && !combat.ActiveContract.ContractTypeValue.IsSkirmish) { if (ModInit.Settings.LetGravityAffectEnergyWeps != true && __instance.WeaponCategoryValue.IsEnergy) { return; } TagSet CurrentSystem = sim.CurSystem.Tags; if (CurrentSystem.Contains("planet_size_small")) { WeaponRangeMultiplier = ModInit.Settings.lowgravWeaponOverride; } else if (CurrentSystem.Contains("planet_size_large")) { WeaponRangeMultiplier = ModInit.Settings.highgravWeaponOverride; } else { WeaponRangeMultiplier = 1.0f; } __result *= WeaponRangeMultiplier; } else { if (ModInit.Settings.LetGravityAffectEnergyWeps != true && __instance.WeaponCategoryValue.IsEnergy) { return; } if (combat.MapMetaData.biomeSkin == Biome.BIOMESKIN.lunarVacuum) { WeaponRangeMultiplier = ModInit.Settings.LunarWeaponOverride; } else if (combat.MapMetaData.biomeSkin == Biome.BIOMESKIN.martianVacuum) { WeaponRangeMultiplier = ModInit.Settings.MartianWeaponOverride; } else { WeaponRangeMultiplier = 1.0f; } __result *= WeaponRangeMultiplier; } }
public static int GetThreatLevelByTag(TagSet mechTags) { if (mechTags.Contains("unit_components_plusplusplus")) { return(3); } else if (mechTags.Contains("unit_components_plusplus")) { return(2); } else if (mechTags.Contains("unit_components_plus")) { return(1); } else { return(0); } }
public static float MeleeTonnage(this Turret turret) { float tonnage = Mod.Config.Melee.Turrets.DefaultTonnage; TagSet actorTags = turret.GetTags(); if (actorTags != null && actorTags.Contains(ModConsts.Turret_Tag_Class_Light)) { tonnage = Mod.Config.Melee.Turrets.LightTonnage; } else if (actorTags != null && actorTags.Contains(ModConsts.Turret_Tag_Class_Medium)) { tonnage = Mod.Config.Melee.Turrets.LightTonnage; } else if (actorTags != null && actorTags.Contains(ModConsts.Turret_tag_Class_Heavy)) { tonnage = Mod.Config.Melee.Turrets.LightTonnage; } return(tonnage); }
public static void Postfix(Turret __instance) { int init = Mod.Config.TurretPhases.UnitNone; TagSet actorTags = __instance.GetTags(); if (actorTags != null && actorTags.Contains("unit_light")) { init = Mod.Config.TurretPhases.UnitLight; } else if (actorTags != null && actorTags.Contains("unit_medium")) { init = Mod.Config.TurretPhases.UnitMedium; } else if (actorTags != null && actorTags.Contains("unit_heavy")) { init = Mod.Config.TurretPhases.UnitHeavy; } Mod.Log.Debug?.Write($"Setting baseInit for turret: {CombatantUtils.Label(__instance)} to {init}"); __instance.StatCollection.Set <int>(ModStats.BaseInitiative, init); }
public static object EvaluateTagForCurrentSystem(TsEnvironment env, object[] inputs) { bool flag = env.ToBool(inputs[0]); string value = env.ToString(inputs[1]); Main.Logger.Log($"[EvaluateTagForCurrentSystem] Triggered with flag {flag} and value {value}."); TagSet currentSystemTags = UnityGameInstance.BattleTechGame.Simulation.CurSystem.Tags; bool flag2 = currentSystemTags.Contains(value) == flag; Main.Logger.Log("[EvaluateTagForCurrentSystem] Finished with result of " + flag2); return(flag2); }
public static void Postfix(HBSTagView __instance, TagSet tagSet, GameContext context) { if (!Pre_Control.settings.MechBonding) { return; } if (tagSet.Contains("PQ_Mech_Mastery")) { bool HasTattoo = PilotHolder.pilotDef.PilotTags.Any(x => x.StartsWith("PQ_Pilot_GUID")); if (!HasTattoo) { return; } string PilotTattoo = PilotHolder.pilotDef.PilotTags.First(x => x.StartsWith("PQ_Pilot_GUID")); if (!MechBonding.PilotsAndMechs.Keys.Contains(PilotTattoo) || MechBonding.PilotsAndMechs[PilotTattoo].Count() == 0) { return; } var MechExperience = MechBonding.PilotsAndMechs[PilotTattoo]; var BondedMech = MechExperience.Aggregate((l, r) => l.Value > r.Value ? l : r).Key; string MasteryTier = ""; if (MechExperience[BondedMech] >= Pre_Control.settings.Tier4) { MasteryTier = "Elite "; } else if (MechExperience[BondedMech] >= Pre_Control.settings.Tier3) { MasteryTier = "Veteran "; } else if (MechExperience[BondedMech] >= Pre_Control.settings.Tier2) { MasteryTier = "Regular "; } else if (MechExperience[BondedMech] >= Pre_Control.settings.Tier1) { MasteryTier = "Green "; } string DescriptionName = MasteryTier + " 'Mech Pilot"; var item = new TagDataStruct("HACK_GENCON_UNIT", true, true, "name", DescriptionName, "description"); string contextItem = string.Format("{0}[{1}]", "TDSF", item.Tag); string friendlyName = item.FriendlyName; var itemTT = TooltipUtilities.GetGameContextTooltipString(contextItem, friendlyName); __instance.AddTag(itemTT, item.FriendlyName); } }
public static void Postfix(Mech __instance, ref float __result) { if (ModInit.Settings.UsePlanetGravityTags == true && !combat.ActiveContract.ContractTypeValue.IsSkirmish) { TagSet CurrentSystem = sim.CurSystem.Tags; if (CurrentSystem.Contains("planet_size_small")) { JumpMultiplier = ModInit.Settings.lowgravJumpOverride; } else if (CurrentSystem.Contains("planet_size_large")) { JumpMultiplier = ModInit.Settings.highgravJumpOverride; } else { JumpMultiplier = 1.0f; } __result *= JumpMultiplier; } else { string currentMask = __instance.Combat.MapMetaData.biomeDesignMask.Id; if (currentMask.Contains("DesignMaskBiomeLunarVacuum")) { JumpMultiplier = ModInit.Settings.LunarJumpOverride; } else if (currentMask.Contains("DesignMaskBiomeMartianVacuum")) { JumpMultiplier = ModInit.Settings.MartianJumpOverride; } else { JumpMultiplier = 1.0f; } __result *= JumpMultiplier; } }
public static float GetUnitTonnage(AbstractActor actor) { float tonnage = DefaultTonnage; if (actor.GetType() == typeof(Mech)) { tonnage = ((Mech)actor).tonnage; } else if (actor.GetType() == typeof(Vehicle)) { tonnage = ((Vehicle)actor).tonnage; } else { tonnage = TurretTonnage; TagSet actorTags = actor.GetTags(); if (actorTags != null && actorTags.Contains("unit_light")) { tonnage = Mod.Config.TurretTonnageTagUnitLight; } else if (actorTags != null && actorTags.Contains("unit_medium")) { tonnage = Mod.Config.TurretTonnageTagUnitMedium; } else if (actorTags != null && actorTags.Contains("unit_heavy")) { tonnage = Mod.Config.TurretTonnageTagUnitHeavy; } else { tonnage = Mod.Config.TurretTonnageTagUnitNone; } } return(tonnage); }
public static bool meetsNewReqs(StarSystem instance, TagSet reqTags, TagSet exTags, TagSet curTags) { try { if (!curTags.ContainsAny(exTags, true)) { foreach (string item in reqTags) { if (!curTags.Contains(item)) { if (item.StartsWith("time")) { string[] times = item.Split('_'); if (!(instance.Sim.DaysPassed >= int.Parse(times[1]))) { return(false); } } else if (item.StartsWith("rep")) { string[] reps = item.Split('_'); int test = instance.Sim.GetRawReputation(Helper.getfaction(reps[1])); if (!(test >= int.Parse(reps[2]))) { return(false); } } else { return(false); } } } Logger.LogLine("Return true"); return(true); } return(false); } catch (Exception e) { Logger.LogError(e); return(false); } }
/* * Take the BaseInitiative value from all components on the unit, remove the * normal phase modifiers HBS applies from SimGameConstants (-2 for light, etc), * then invert the value. Because HBS defines bonuses as negative modifiers, * invert this value to have it make sense elsewhere in the code. */ // TODO: Should this use the MechDef call below? public static int GetNormalizedComponentModifier(AbstractActor actor) { int unitInit = 0; WeightClass weightClass; if (actor.GetType() == typeof(Mech)) { weightClass = ((Mech)actor).weightClass; } else if (actor.GetType() == typeof(Vehicle)) { var vehicle = (Vehicle)actor; weightClass = ((Vehicle)actor).weightClass; } else // turret { TagSet actorTags = actor.GetTags(); if (actorTags != null && actorTags.Contains("unit_light")) { weightClass = WeightClass.LIGHT; } else if (actorTags != null && actorTags.Contains("unit_medium")) { weightClass = WeightClass.MEDIUM; } else if (actorTags != null && actorTags.Contains("unit_heavy")) { weightClass = WeightClass.HEAVY; } else { weightClass = WeightClass.ASSAULT; } } // TODO: Validate that vehicles are normalized properly - looks like HBS adjusts the phases, may not be working properly // TODO: Validate that turret are normalized properly - looks like HBS adjusts the phases, may not be working properly /* * HBS VALUES * "PhaseSpecial": 1, * "PhaseLight": 2, * "PhaseMedium": 3, * "PhaseHeavy": 4, * "PhaseAssault": 5, * "PhaseLightVehicle": 3, * "PhaseMediumVehicle": 4, * "PhaseHeavyVehicle": 5, * "PhaseAssaultVehicle": 5, * "PhaseLightTurret": 5, * "PhaseMediumTurret": 5, * "PhaseHeavyTurret": 5, * "PhaseAssaultTurret": 5 * * RT VALUE * "PhaseSpecial": 1, * "PhaseLight": 2, * "PhaseMedium": 3, * "PhaseHeavy": 4, * "PhaseAssault": 5, * "PhaseLightVehicle": 2, * "PhaseMediumVehicle": 3, * "PhaseHeavyVehicle": 4, * "PhaseAssaultVehicle": 5, * "PhaseLightTurret": 3, * "PhaseMediumTurret": 4, * "PhaseHeavyTurret": 5, * "PhaseAssaultTurret": 5 */ if (actor.StatCollection != null && actor.StatCollection.ContainsStatistic("BaseInitiative")) { int baseMod = actor.StatCollection.GetValue <int>("BaseInitiative"); // Normalize the value // TODO: These should come from CombatGameDef.PhaseConstantsDef, but I can't find a reference to pull // those values. May have to load at mod start and cache them. switch (weightClass) { case WeightClass.LIGHT: baseMod -= 2; break; case WeightClass.MEDIUM: baseMod -= 3; break; case WeightClass.HEAVY: baseMod -= 4; break; case WeightClass.ASSAULT: baseMod -= 5; break; default: Mod.Log.Debug($"Actor:{actor.DisplayName}_{actor.GetPilot().Name}" + $" has unknown or undefined weight class:{weightClass}!"); break; } // Because HBS init values were from 2-5, bonuses will be negative at this point and penalties positive. Invert these. unitInit = baseMod * -1; Mod.Log.Debug($"Normalized BaseInit for Actor:{actor.DisplayName}_{actor.GetPilot().Name}" + $" from {actor.StatCollection.GetValue<int>("BaseInitiative")} to unitInit:{unitInit}"); } return(unitInit); }
public static void TagSetQueryExtensions_GetMatchingUnitDefs_Postfix(MetadataDatabase __instance, TagSet requiredTags, DateTime?currentDate, ref List <UnitDef_MDD> __result) { Logger.Debug($"Executing [{nameof(TagSetQueryExtensions_GetMatchingUnitDefs_Postfix)}],\r\n" + $"RequiredTags = [{string.Join(", ", requiredTags)}]\r\n" + $"MatchingDataByTagSet = [{string.Join("\r\n", __result.Select(defMdd => defMdd.UnitDefID))}]..."); if (requiredTags.Contains("unit_vehicle") || requiredTags.Contains("unit_turret")) { Logger.Debug($"Bypassing lance spawn morph as required tags are not looking for mechs..."); return; } else if (__result.Count == 0) { Logger.Debug($"Bypassing lance spawn morph as initial result is empty..."); return; } // Alias the keywords for readability... var mdd = __instance; var matchingDataByTagSet = __result; var simGameState = UnityGameInstance.BattleTechGame.Simulation; var filteredList = new List <UnitDef_MDD>(); // Group matching unitDef_MDD records by their associated prefabIdentifier var unitsGroupedByPrefab = matchingDataByTagSet .Select(defMdd => new { unitDefMdd = defMdd, mechDef = simGameState.DataManager.MechDefs.First(pair => pair.Key == defMdd.UnitDefID).Value }) .GroupBy(arg => arg.mechDef.Chassis.PrefabIdentifier, arg => arg, (s, enumerable) => new { Base = s, Units = enumerable }) .ToList(); Logger.Debug($"Grouped result list into [\r\n" + $"{string.Join("\r\n", unitsGroupedByPrefab.Select(arg => $"[{arg.Base}] -> {string.Join(", ", arg.Units.Select(arg1 => arg1.unitDefMdd.UnitDefID))}"))}]"); // var prefabVariantsOccuringOnce = unitsGroupedByPrefab.Where(arg => arg.Units.Count() == 1).SelectMany(arg => arg.Units).ToList(); foreach (var prefabGroup in unitsGroupedByPrefab) { Logger.Debug($"Processing units for prefab [{prefabGroup.Base}]..."); var prefabSelectionList = new List <UnitDef_MDD>(); foreach (var unit in prefabGroup.Units) { Logger.Trace($"Processing unit [{unit.mechDef.Description.Id}], CurrentDate = [{currentDate}], MinAppearanceDate = [{unit.mechDef.MinAppearanceDate}]..."); // For mechs with an appearance date (and current date is set, which it should always be) // 1. Each entry gets a rarityWeighting + 1 per 30 days since appearance date has passed // 2. To a maximum of 6 (so mechs that appeared at least 180 days prior to the current date receive the maximum rarity weighting) // These following two variables ought to be set via [Settings] in the mod.json... var rarityWeighting = Myself.Settings.MaxRarityWeighting; if (currentDate != null && unit.mechDef.MinAppearanceDate != null) { // Could do this in only one statement, but that ended up being a little kludgy and hard to read... var rawDays = (currentDate - unit.mechDef.MinAppearanceDate).Value.TotalDays + 1; var roundedDays = Math.Round(rawDays / Myself.Settings.RarityWeightingDaysDivisor, 0); var rawRarity = Convert.ToInt32(roundedDays); rarityWeighting = Math.Min(rawRarity, Myself.Settings.MaxRarityWeighting); if (rarityWeighting <= 0) { Logger.Trace($"Rarity negative for [{unit.unitDefMdd.UnitDefID}], fixing to 1..."); rarityWeighting = 1; } Logger.Trace($"Raw Days = [{rawDays}], " + $"Rounded Days = [{roundedDays}], " + $"Raw Rarity = [{rawRarity}], " + $"Final Rarity Rating = [{rarityWeighting}]"); } // Insert multiple copies of unitDefMdd to influence the RNG selection weighted by rarity, appropriately... for (var i = 0; i < rarityWeighting; i++) { Logger.Trace($"Adding [{unit.unitDefMdd.UnitDefID}] to prefabSelectionList..."); prefabSelectionList.Add(unit.unitDefMdd); } } Logger.Trace($"PrefabSelectionList count = [{prefabSelectionList.Count}]"); var prefabSelectionListGroupByPrefab = prefabSelectionList .Select(defMdd => new { unitDefMdd = defMdd, mechDef = simGameState.DataManager.MechDefs.First(pair => pair.Key == defMdd.UnitDefID).Value }) .GroupBy(arg => arg.unitDefMdd.UnitDefID, arg => arg, (s, enumerable) => new { Base = s, units = enumerable }); Logger.Debug($"Final Prefab Selection List = [\r\n" + $"{string.Join("\r\n", prefabSelectionListGroupByPrefab.Select(arg => $"[{arg.Base}] - Count [{arg.units.Count()}]"))}" + $"]"); // Select one variant of the prefab base to include as an option in the filtered list... Logger.Trace($"Shuffling prefab selection list..."); prefabSelectionList.Shuffle(); var selectedPrefabVariant = prefabSelectionList[0]; Logger.Debug($"Selected [{selectedPrefabVariant.UnitDefID} for inclusion in final filtered list...]"); filteredList.Add(selectedPrefabVariant); } Logger.Debug($"Final filtered list = [\r\n" + $"{string.Join("\r\n", filteredList.Select(defMdd => defMdd.UnitDefID))}" + $"]"); __result = filteredList; }
public static string GetPilotTypeForMechDef(MechDef mechDef, bool random = false) { string pilotType = "lancer"; TagSet mechTags = mechDef.MechTags; List <string> availablePilotTypes = new List <string>() { "skirmisher", "lancer", "sharpshooter", "flanker", "outrider", "recon", "gladiator", "brawler", "sentinel", "striker", "scout", "vanguard" }; List <string> appropiatePilotTypes = new List <string>(); if (random) { System.Random rnd = new System.Random(); int r = rnd.Next(availablePilotTypes.Count); Logger.Info("[Utilities.GetPilotTypeForMechDef] Returning random pilotType: " + availablePilotTypes[r]); return(availablePilotTypes[r]); } if (!mechTags.IsEmpty) { Logger.Info("[Utilities.GetPilotTypeForMechDef] mechTags: " + mechTags); // unit_lance_support, unit_lance_tank, unit_lance_assassin, unit_lance_vanguard // unit_role_brawler, unit_role_sniper, unit_role_scout // skirmisher, lancer, sharpshooter, flanker, outrider, recon, gladiator, brawler, sentinel, striker, scout, vanguard // By logical combination if (mechTags.Contains("unit_lance_support") && mechTags.Contains("unit_role_brawler")) { appropiatePilotTypes.Add("vanguard"); } if (mechTags.Contains("unit_lance_support") && mechTags.Contains("unit_role_sniper")) { appropiatePilotTypes.Add("sharpshooter"); } if (mechTags.Contains("unit_lance_support") && mechTags.Contains("unit_role_scout")) { appropiatePilotTypes.Add("recon"); } if (mechTags.Contains("unit_lance_tank") && mechTags.Contains("unit_role_brawler")) { appropiatePilotTypes.Add("gladiator"); } if (mechTags.Contains("unit_lance_tank") && mechTags.Contains("unit_role_sniper")) { appropiatePilotTypes.Add("lancer"); } if (mechTags.Contains("unit_lance_tank") && mechTags.Contains("unit_role_scout")) { appropiatePilotTypes.Add("outrider"); } if (mechTags.Contains("unit_lance_assassin") && mechTags.Contains("unit_role_brawler")) { appropiatePilotTypes.Add("brawler"); } if (mechTags.Contains("unit_lance_assassin") && mechTags.Contains("unit_role_sniper")) { appropiatePilotTypes.Add("skirmisher"); } if (mechTags.Contains("unit_lance_assassin") && mechTags.Contains("unit_role_scout")) { appropiatePilotTypes.Add("flanker"); } if (mechTags.Contains("unit_lance_vanguard") && mechTags.Contains("unit_role_brawler")) { appropiatePilotTypes.Add("scout"); } if (mechTags.Contains("unit_lance_vanguard") && mechTags.Contains("unit_role_sniper")) { appropiatePilotTypes.Add("striker"); } if (mechTags.Contains("unit_lance_vanguard") && mechTags.Contains("unit_role_scout")) { appropiatePilotTypes.Add("sentinel"); } // Add variety by single roles if (mechTags.Contains("unit_role_brawler")) { appropiatePilotTypes.Add("lancer"); appropiatePilotTypes.Add("skirmisher"); } if (mechTags.Contains("unit_role_sniper")) { appropiatePilotTypes.Add("sharpshooter"); } if (mechTags.Contains("unit_role_scout")) { appropiatePilotTypes.Add("recon"); appropiatePilotTypes.Add("scout"); } // Add variety by special tags if (mechTags.Contains("unit_indirectFire")) { appropiatePilotTypes.Add("vanguard"); appropiatePilotTypes.Add("striker"); } // Add variety by Chassis if (mechDef.ChassisID.Contains("hatchetman") || mechDef.ChassisID.Contains("dragon") || mechDef.ChassisID.Contains("banshee")) { appropiatePilotTypes.Add("brawler"); appropiatePilotTypes.Add("gladiator"); } } if (appropiatePilotTypes.Count > 0) { foreach (string Type in appropiatePilotTypes) { Logger.Info("[Utilities.GetPilotTypeForMechDef] appropiatePilotTypes: " + Type); } appropiatePilotTypes.Shuffle <string>(); pilotType = appropiatePilotTypes[0]; } Logger.Info("[Utilities.GetPilotTypeForMechDef] Selected pilotType: " + pilotType); return(pilotType); }
public static bool MeetsNewReqs(StarSystem instance, TagSet reqTags, TagSet exTags, TagSet curTags) { try { if (!curTags.ContainsAny(exTags, false)) { //Check exclution for time and rep foreach (string item in exTags) { if (item.StartsWith("time")) { string[] times = item.Split('_'); if ((instance.Sim.DaysPassed >= int.Parse(times[1]))) { return(false); } } else if (item.StartsWith("rep")) { string[] reps = item.Split('_'); int test = instance.Sim.GetRawReputation(Helper.getfaction(reps[1])); if ((test >= int.Parse(reps[2]))) { return(false); } } } //Check requirements for time and rep foreach (string item in reqTags) { if (!curTags.Contains(item)) { if (item.StartsWith("time")) { string[] times = item.Split('_'); if (!(instance.Sim.DaysPassed >= int.Parse(times[1]))) { return(false); } } else if (item.StartsWith("rep")) { string[] reps = item.Split('_'); int test = instance.Sim.GetRawReputation(Helper.getfaction(reps[1])); if (!(test >= int.Parse(reps[2]))) { return(false); } } else { return(false); } } } return(true); } return(false); } catch (Exception e) { PersistentMapClient.Logger.LogError(e); return(false); } }