public FactionDef ResolveHorrorFaction(float points) { List <CosmicHorrorFaction> factionList = new List <CosmicHorrorFaction> { new CosmicHorrorFaction("ROM_DeepOne", 4) }; if (points > 1400f) { factionList.Add(new CosmicHorrorFaction("ROM_StarSpawn", 1)); } if (points > 700f) { factionList.Add(new CosmicHorrorFaction("ROM_Shoggoth", 2)); } if (points > 350f) { factionList.Add(new CosmicHorrorFaction("ROM_MiGo", 4)); } CosmicHorrorFaction f = GenCollection.RandomElementByWeight <CosmicHorrorFaction>(factionList, GetWeight); Faction resolvedFaction = Find.FactionManager.FirstFactionOfDef(FactionDef.Named(f.DefName)); //This is a special case. //If the player has the Cults mod. //If they are working with Dagon. //Then let's do something different... if (Cthulhu.Utility.IsCultsLoaded() && f.DefName == "ROM_DeepOne") { if (resolvedFaction.RelationWith(Faction.OfPlayer, false).hostile == false) { //Do MiGo instead. Cthulhu.Utility.DebugReport("Cosmic Horror Raid Report: Special Cult Case Handled"); resolvedFaction = Find.FactionManager.FirstFactionOfDef(FactionDef.Named("ROM_MiGo")); } } this.attackingFaction = resolvedFaction.def; Cthulhu.Utility.DebugReport("Cosmic Horror Raid Report: " + this.attackingFaction.ToString() + "selected"); return(FactionDef.Named(this.attackingFaction.defName)); }
public static float GetWeight(CosmicHorrorFaction f) => f.Weight;