public static void Prefix(ref IncidentParms parms) { if (parms.target is Map && (parms.target as Map).IsPlayerHome) { Faction faction = parms.faction; HiveFactionEvolutionTracker evolutionTracker = Find.World.GetComponent <HiveFactionEvolutionTracker>(); HiveFactionExtension hive = faction?.def.GetModExtension <HiveFactionExtension>(); if (faction != null) { // Log.Message("faction not null"); if ((parms.target is Map map)) { // Log.Message("target is map"); if (evolutionTracker != null && hive != null) { // Log.Message("evolutionTracker & hive"); if (evolutionTracker.HiveFactionStages.TryGetValue(faction.ToString(), out int stage)) { float mult = hive.CurStage.pointMultipler; // Log.Message("IncidentWorker_RaidEnemy HiveFaction Stage: " + stage + " Multiplier: " + mult + " Result: " + (parms.points * mult)); parms.points *= mult; } } } } } }
public static void Prefix(ref IncidentParms parms) { if (parms.target is Map && (parms.target as Map).IsPlayerHome) { if (parms.faction != null && (parms.faction.def.HasModExtension <HiveFactionExtension>())) { float mult = 1f; int stage = 0; HiveFactionEvolutionTracker evolutionTracker = Find.World.GetComponent <HiveFactionEvolutionTracker>(); HiveFactionExtension hive = parms.faction.def.GetModExtension <HiveFactionExtension>(); if (evolutionTracker != null) { if (evolutionTracker.HiveFactionStages.TryGetValue(parms.faction.ToString(), out stage)) { mult = hive.CurStage.pointMultipler; } else { stage = hive.ActiveStage; evolutionTracker.HiveFactionStages.SetOrAdd(parms.faction.ToString(), stage); mult = hive.CurStage.pointMultipler; } // Log.Message("IncidentWorker_RaidEnemy HiveFaction Stage: " + stage + " Multiplier: " + mult + " Result: " + (parms.points * mult)); } parms.points = parms.points * mult; } } }
public static void Prefix(PawnGroupMakerParms parms, ref PawnGroupMaker pawnGroupMaker) { Faction faction = parms.faction; HiveFactionEvolutionTracker evolutionTracker = Find.World.GetComponent <HiveFactionEvolutionTracker>(); if (faction != null) { HiveFactionExtension hive = faction.def.GetModExtension <HiveFactionExtension>(); if (evolutionTracker != null && hive != null) { if (evolutionTracker.HiveFactionStages.TryGetValue(faction.ToString(), out int stage)) { if (parms.seed != null) { Rand.PushState(parms.seed.Value); } if (!hive.CurStage.pawnGroupMakers.NullOrEmpty()) { string li = string.Empty; // Log.Message("TryGetRandomPawnGroupMaker HiveFaction using pawnGroupMaker from Stage: " + stage); } bool result = (from gm in hive.CurStage.pawnGroupMakers ?? parms.faction.def.pawnGroupMakers where gm.kindDef == parms.groupKind && gm.CanGenerateFrom(parms) select gm).TryRandomElementByWeight((PawnGroupMaker gm) => gm.commonality, out pawnGroupMaker); if (parms.seed != null) { Rand.PopState(); } // Log.Message("TryGetRandomPawnGroupMaker HiveFaction Stage: " + stage + " pawnGroupMaker: " + pawnGroupMaker.kindDef); } } } }
public static bool Prefix(Faction faction, float totalPoints, RaidStrategyDef raidStrategy, PawnGroupKindDef groupKind, ref float __result) { HiveFactionEvolutionTracker evolutionTracker = Find.World.GetComponent <HiveFactionEvolutionTracker>(); HiveFactionExtension hive = faction.def.GetModExtension <HiveFactionExtension>(); if (faction != null) { if (evolutionTracker != null && hive != null) { if (evolutionTracker.HiveFactionStages.TryGetValue(faction.ToString(), out int stage)) { SimpleCurve curves = hive.CurStage.maxPawnCostPerTotalPointsCurve ?? faction.def.maxPawnCostPerTotalPointsCurve; float num = curves.Evaluate(totalPoints); if (raidStrategy != null) { num = Mathf.Min(num, totalPoints / raidStrategy.minPawns); } num = Mathf.Max(num, faction.def.MinPointsToGeneratePawnGroup(groupKind) * 1.2f); if (raidStrategy != null) { num = Mathf.Max(num, raidStrategy.Worker.MinMaxAllowedPawnGenOptionCost(faction, groupKind) * 1.2f); } __result = num; return(false); } } } return(true); }
public static void Prefix(int tile, ref IntVec3 size, WorldObjectDef suggestedMapParentDef) { Map map = Current.Game.FindMap(tile); Faction faction = null; if (map != null) { if (map.ParentFaction != null) { faction = map.ParentFaction; } } else { MapParent mapParent = Find.WorldObjects.MapParentAt(tile); if (mapParent?.Faction != null) { faction = mapParent.Faction; } } if (faction == null) { return; } HiveFactionEvolutionTracker evolutionTracker = Find.World.GetComponent <HiveFactionEvolutionTracker>(); HiveFactionExtension hive = faction.def.GetModExtension <HiveFactionExtension>(); if (evolutionTracker != null && hive != null) { int sizemod = 0; // Log.Message("GetOrGenerateMap for " + faction + " Default: " + size.x + " Max Hive size: " + hive.CurStage.sizeRange.max); for (int i = 0; i < 10; i++) { if (hive.CurStage.sizeRange.max >= ((size.x + sizemod) / 2) * 0.75f) { sizemod = (int)(size.x * 0.25f); } else { break; } } if (sizemod > 0) { size.x += sizemod; size.z += sizemod; // Log.Message("GetOrGenerateMap for " + faction +" applied sizemod: "+ sizemod +" resulting: "+ size); } } else { // Log.Message("GetOrGenerateMap evolutionTracker: "+ (evolutionTracker != null) + " hiveext: " + (hive != null)); } }
public static void Prefix(ref ResolveParams rp) { if (rp.faction != null) { Faction faction = rp.faction; HiveFactionEvolutionTracker evolutionTracker = Find.World.GetComponent <HiveFactionEvolutionTracker>(); HiveFactionExtension hive = faction.def.GetModExtension <HiveFactionExtension>(); if (evolutionTracker != null && hive != null) { if (evolutionTracker.HiveFactionStages.TryGetValue(faction.ToString(), out int stage)) { float mult = hive.CurStage.pointMultipler; if (rp.pawnGroupMakerParams != null) { // Log.Message("SymbolResolver_PawnHiveGroup HiveFaction Stage: " + stage + " Multiplier: "+ mult+" Result: "+ (rp.pawnGroupMakerParams.points * mult)); rp.pawnGroupMakerParams.points *= mult; } } } } }
public static void Postfix(OgsOld_ExtraHives.GenStuff.SymbolResolver_Hivebase __instance, ref ResolveParams rp) { Map map = BaseGen.globalSettings.map; if (rp.faction.def.HasModExtension <HiveFactionExtension>()) { float mult = 1f; HiveFactionEvolutionTracker evolutionTracker = Find.World.GetComponent <HiveFactionEvolutionTracker>(); HiveFactionExtension hive = rp.faction.def.GetModExtension <HiveFactionExtension>(); if (evolutionTracker != null) { if (evolutionTracker.HiveFactionStages.TryGetValue(rp.faction.ToString(), out int stage)) { mult = hive.CurStage.pointMultipler; // Log.Message("SymbolResolver_Hivebase HiveFaction Stage: " + stage + " Multiplier: " + mult + " Result: " + ((rp.settlementPawnGroupPoints ?? SymbolResolver_Settlement.DefaultPawnsPoints.RandomInRange) * mult)); } } /* * rp.rect.Width = (int)(rp.rect.Width / sizemod); * rp.rect.Height = (int)(rp.rect.Height / sizemod); */ if (rp.pawnGroupMakerParams != null) { rp.pawnGroupMakerParams.points = (rp.settlementPawnGroupPoints ?? SymbolResolver_Settlement.DefaultPawnsPoints.RandomInRange) * mult; } else { rp.pawnGroupMakerParams = new PawnGroupMakerParms(); rp.pawnGroupMakerParams.tile = map.Tile; rp.pawnGroupMakerParams.faction = rp.faction; rp.pawnGroupMakerParams.points = (rp.settlementPawnGroupPoints ?? SymbolResolver_Settlement.DefaultPawnsPoints.RandomInRange) * mult; rp.pawnGroupMakerParams.inhabitants = true; rp.pawnGroupMakerParams.seed = rp.settlementPawnGroupSeed; } } }