public static militaryForce createMilitaryForceFromSettlement(SettlementFC settlement, bool isAttacking = false, militaryForce homeDefendingForce = null) { FactionFC faction = Find.World.GetComponent <FactionFC>(); int militaryLevelBonus = 0; if (faction.hasTrait(FCPolicyDefOf.defenseInDepth) && isAttacking == false) { militaryLevelBonus += 2; } double homeForceLevel = 0; if (homeDefendingForce != null) { homeForceLevel = homeDefendingForce.militaryLevel; } double militaryLevel = settlement.settlementMilitaryLevel + militaryLevelBonus + homeForceLevel; double efficiency = TraitUtilsFC.cycleTraits("militaryMultiplierCombatEfficiency", faction.traits, Operation.Multiplication) * TraitUtilsFC.cycleTraits("militaryMultiplierCombatEfficiency", settlement.traits, Operation.Multiplication); if (isAttacking && faction.hasPolicy(FCPolicyDefOf.militaristic)) { efficiency *= 1.2; } militaryForce returnForce = new militaryForce(militaryLevel, efficiency, settlement, FactionColonies.getPlayerColonyFaction()); return(returnForce); //create and return force. }
public void RoadTick() { if (this.roadDef == null || !this.roadBuildingEnabled) { this.wasRoadBuildingDisabled = true; return; } // Every 20 ticks causes a slight stutter, but the game is still playable // TODO: Make this a config option if (Find.TickManager.TicksGame % 20 == 0) { FactionFC faction = Find.World.GetComponent <FactionFC>(); FCPlanetRoadQueue queue = this.GetRoadQueue(Find.World.info.name); if (!roadBuilders && faction.hasTrait(FCPolicyDefOf.roadBuilders)) { foreach (FCPlanetRoadQueue prq in this.roadQueues) { prq.shouldUpdateSettlementsToProcess = true; prq.daysBetweenTicks = 1; } this.roadBuilders = true; this.daysBetweenTicks = 1; } // If road building was disabled, then set the next tick to make a road // to the correct time if (this.wasRoadBuildingDisabled) { this.wasRoadBuildingDisabled = false; foreach (FCPlanetRoadQueue prq in this.roadQueues) { prq.nextRoadTick = Find.TickManager.TicksGame + GenDate.TicksPerDay * prq.daysBetweenTicks; } } queue.ProcessOnePath(); queue.BuildRoadSegments(); } }
// Returns whether or not a settlement would be built to. public static bool IsValidRoadTarget(Settlement settlement) { FactionFC fC = Find.World.GetComponent <FactionFC>(); // If faction exists and is either player or player has roadBuilders and the faction is an ally if (settlement.Faction != null) { if (settlement.Faction.IsPlayer || (fC.hasTrait(FCPolicyDefOf.roadBuilders) && settlement.Faction.PlayerRelationKind == FactionRelationKind.Ally)) { return(true); } } foreach (SettlementFC settlementFC in fC.settlements) { if (settlementFC.planetName == Find.World.info.name && settlementFC.mapLocation == settlement.Tile) { return(true); } } return(false); }
public static List <Thing> generateRaidLoot(int lootLevel, TechLevel techLevel) { FactionFC faction = Find.World.GetComponent <FactionFC>(); float trait_LootMulitplier = 1f; if (faction.hasTrait(FCPolicyDefOf.raiders)) { trait_LootMulitplier = 1.2f; } List <Thing> things = new List <Thing>(); ThingSetMaker thingSetMaker = new ThingSetMaker_MarketValue(); ThingSetMakerParams param = new ThingSetMakerParams(); param.totalMarketValueRange = new FloatRange((500 + (lootLevel * 200)) * trait_LootMulitplier, (1000 + (lootLevel * 500)) * trait_LootMulitplier); param.filter = new ThingFilter(); param.techLevel = techLevel; param.countRange = new IntRange(3, 20); //set allow param.filter.SetAllow(ThingCategoryDefOf.Weapons, true); param.filter.SetAllow(ThingCategoryDefOf.Apparel, true); param.filter.SetAllow(ThingCategoryDefOf.BuildingsArt, true); param.filter.SetAllow(ThingCategoryDefOf.Drugs, true); param.filter.SetAllow(ThingCategoryDefOf.Items, true); param.filter.SetAllow(ThingCategoryDefOf.Medicine, true); param.filter.SetAllow(ThingCategoryDefOf.Techprints, true); param.filter.SetAllow(ThingCategoryDefOf.Buildings, true); //set disallow param.filter.SetAllow(DefDatabase <ThingDef> .GetNamedSilentFail("Teachmat"), false); things = thingSetMaker.Generate(param); return(things); }
List <FCPolicyDef> availableTraitsList() { List <FCPolicyDef> list = new List <FCPolicyDef>(); if (!faction.hasTrait(FCPolicyDefOf.resilient)) { list.Add(FCPolicyDefOf.resilient); } if (!faction.hasTrait(FCPolicyDefOf.raiders)) { list.Add(FCPolicyDefOf.raiders); } if (!faction.hasTrait(FCPolicyDefOf.defenseInDepth)) { list.Add(FCPolicyDefOf.defenseInDepth); } if (!faction.hasTrait(FCPolicyDefOf.industrious)) { list.Add(FCPolicyDefOf.industrious); } if (!faction.hasTrait(FCPolicyDefOf.roadBuilders)) { list.Add(FCPolicyDefOf.roadBuilders); } if (!faction.hasTrait(FCPolicyDefOf.mercantile)) { list.Add(FCPolicyDefOf.mercantile); } if (!faction.hasTrait(FCPolicyDefOf.innovative)) { list.Add(FCPolicyDefOf.innovative); } //if (!faction.hasTrait(FCPolicyDefOf.lucky)) //list.Add(FCPolicyDefOf.lucky); return(list); }