public static void Postfix(Faction __instance, Faction other) { var currentFactionDefExtension = FactionDefExtension.Get(__instance.def); var otherFactionDefExtension = FactionDefExtension.Get(other.def); var currentToOtherFactionGoodwill = currentFactionDefExtension?.startingGoodwillByFactionDefs?.Find(x => x.factionDef == other.def); var otherToCurrentFactionGoodwill = otherFactionDefExtension?.startingGoodwillByFactionDefs?.Find(x => x.factionDef == __instance.def); // If at least one of the factions references the other via custom values in the FactionDefExtension if (currentToOtherFactionGoodwill != null || otherToCurrentFactionGoodwill != null) { // Get the lowest range of goodwill possible between factions int?currentToOtherFactionGoodwillMin = currentToOtherFactionGoodwill?.Min; int?currentToOtherFactionGoodwillMax = currentToOtherFactionGoodwill?.Max; int?otherToCurrentFactionGoodwillMin = otherToCurrentFactionGoodwill?.Min; int?otherToCurrentFactionGoodwillMax = otherToCurrentFactionGoodwill?.Max; int mutualGoodwillMin = MinOfNullableInts(currentToOtherFactionGoodwillMin, otherToCurrentFactionGoodwillMin); int mutualGoodwillMax = MinOfNullableInts(currentToOtherFactionGoodwillMax, otherToCurrentFactionGoodwillMax); // Generate a random goodwill value within the range int finalMutualGoodWill = Rand.RangeInclusive(mutualGoodwillMin, mutualGoodwillMax); // Assign mutual faction relations FactionRelationKind kind = (finalMutualGoodWill > -10) ? ((finalMutualGoodWill < 75) ? FactionRelationKind.Neutral : FactionRelationKind.Ally) : FactionRelationKind.Hostile; FactionRelation factionRelation = __instance.RelationWith(other, false); factionRelation.baseGoodwill = finalMutualGoodWill; factionRelation.kind = kind; FactionRelation factionRelation2 = other.RelationWith(__instance, false); factionRelation2.baseGoodwill = finalMutualGoodWill; factionRelation2.kind = kind; } }
public static IEnumerable <Blueprint_Build> PlaceBlueprints(LordToilData_SiegeCustom data, Map map, Faction placeFaction) { customParams = FactionDefExtension.Get(placeFaction.def).siegeParameterSetDef; NonPublicFields.SiegeBlueprintPlacer_center.SetValue(null, data.siegeCenter); NonPublicFields.SiegeBlueprintPlacer_faction.SetValue(null, placeFaction); // Cover if (customParams.coverDef != null) { var coverBlueprints = PlaceCoverBlueprints(map).ToList(); for (int i = 0; i < coverBlueprints.Count; i++) { yield return(coverBlueprints[i]); } } // Artillery if (!customParams.artilleryBuildingTags.NullOrEmpty()) { var artilleryBlueprints = PlaceArtilleryBlueprints(data, map).ToList(); for (int i = 0; i < artilleryBlueprints.Count; i++) { yield return(artilleryBlueprints[i]); } } }
public static void Postfix(Faction x, ref bool __result) { // Also factor in our DefModExtension for if a faction can have cities if (__result) { var factionDefExtension = FactionDefExtension.Get(x.def); __result = factionDefExtension.hasCities; } }
private static PawnKindDef FinalisedPawnKindDef(PawnKindDef original, IncidentDef def) { // Finalise stranger in black pawn kind if (def == IncidentDefOf.StrangerInBlackJoin) { var factionDefExtension = FactionDefExtension.Get(Faction.OfPlayer.def); if (factionDefExtension.strangerInBlackReplacement != null) { return(factionDefExtension.strangerInBlackReplacement); } } return(original); }
public static bool Prefix(IncidentParms parms, Map map, List <Pawn> pawns, int raidSeed, ref LordJob __result) { // Conditionally detour the method var faction = parms.faction; var factionDefExtension = FactionDefExtension.Get(faction.def); if (factionDefExtension.siegeParameterSetDef != null) { var entrySpot = (!parms.spawnCenter.IsValid) ? pawns[0].PositionHeld : parms.spawnCenter; var siegeSpot = RCellFinder.FindSiegePositionFrom(entrySpot, map); float blueprintPoints = Mathf.Max(parms.points * Rand.Range(0.2f, 0.3f), factionDefExtension.siegeParameterSetDef.lowestArtilleryBlueprintPoints); __result = new LordJob_SiegeCustom(faction, siegeSpot, blueprintPoints); return(false); } return(true); }
public static void Postfix(PawnGraphicSet __instance) { var faction = __instance.pawn.Faction; // If the pawn's a pack animal and is part of a medieval faction, use medieval pack texture if applicable if (faction != null && __instance.pawn.RaceProps.packAnimal) { var factionDefExtension = FactionDefExtension.Get(faction.def); if (!factionDefExtension.packAnimalTexNameSuffix.NullOrEmpty()) { var medievalPackTexture = ContentFinder <Texture2D> .Get(__instance.nakedGraphic.path + $"{factionDefExtension.packAnimalTexNameSuffix}_south", false); if (medievalPackTexture != null) { __instance.packGraphic = GraphicDatabase.Get <Graphic_Multi>(__instance.nakedGraphic.path + factionDefExtension.packAnimalTexNameSuffix, ShaderDatabase.CutoutComplex, __instance.nakedGraphic.drawSize, __instance.pawn.Faction.Color); } } } }
private static string SettlementGenerationSymbol(string original, Faction faction) { var factionDefExtension = FactionDefExtension.Get(faction.def); return(factionDefExtension.settlementGenerationSymbol ?? original); }