public void DrawProductionHeader(int x, int y) { FactionFC faction = Find.World.GetComponent <FactionFC>(); double egalitarianTaxBoost = 0; if (faction.hasPolicy(FCPolicyDefOf.egalitarian)) { egalitarianTaxBoost = Math.Floor(settlement.happiness / 10); if (settlement.trait_Egalitarian_TaxBreak_Enabled) { egalitarianTaxBoost -= 30; } } double isolationistTaxBoost = 0; if (faction.hasPolicy(FCPolicyDefOf.isolationist)) { isolationistTaxBoost = 10; } Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.UpperLeft; Widgets.Label(new Rect(x, y, 400, 30), "Production".Translate()); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Widgets.Label(new Rect(x + 5, y + 60, 150, 20), "TaxBase".Translate() + ": " + (((100 + egalitarianTaxBoost + isolationistTaxBoost) + TraitUtilsFC.cycleTraits("taxBasePercentage", settlement.traits, Operation.Addition) + TraitUtilsFC.cycleTraits("taxBasePercentage", Find.World.GetComponent <FactionFC>().traits, Operation.Addition))).ToString() + "%"); }
public void CheckForTechChanges() { FactionFC faction = Find.World.GetComponent <FactionFC>(); RoadDef def = this.roadDef; if (DefDatabase <ResearchProjectDef> .GetNamed("FCRoadBuildingHighway", false).IsFinished) { def = RoadDefOf.AncientAsphaltHighway; } else if (DefDatabase <ResearchProjectDef> .GetNamed("FCRoadBuildingRoad", false).IsFinished) { def = RoadDefOf.AncientAsphaltRoad; } else if (DefDatabase <ResearchProjectDef> .GetNamed("FCRoadBuildingDirt", false).IsFinished) { def = RoadDefOf.DirtRoad; } if (this.roadDef != def) { this.roadDef = def; foreach (FCPlanetRoadQueue queue in this.roadQueues) { queue.RoadDef = def; } } }
public void UpdateSettlementsToProcess() { if (Find.World.info.name != this.planetName) { Log.Error("Empire - Attempt to UpdateSettlementsToProcess on wrong planet. Report this."); return; } this.settlementsFromTiles.Clear(); this.settlementsToTiles.Clear(); FactionFC fC = Find.World.GetComponent <FactionFC>(); foreach (SettlementFC settlement in fC.settlements) { if (settlement.planetName == this.planetName) { this.settlementsFromTiles.Add(settlement.mapLocation); } } foreach (Settlement settlement in Find.World.worldObjects.Settlements) { if (FCRoadBuilder.IsValidRoadTarget(settlement)) { this.settlementsToTiles.Add(settlement.Tile); } } this.roadPathIterator = ProcessPath(); }
public override void PreOpen() { base.PreOpen(); stats = stats_tab_0; statSize = 25; buttons = buttons_tab_0; resourceSize = 40; faction = Find.World.GetComponent <FactionFC>(); settlementList = faction.settlements; faction.updateAverages(); //Initial release - Autocreate faction //Faction faction = FactionColonies.getPlayerColonyFaction(); //if (faction == null) //{ // FactionColonies.createPlayerColonyFaction(); //} //if (faction.capitalLocation == -1) //{ // faction.setCapital(); //} faction.updateTotalProfit(); }
public static void updateFactionOnPlanet() { FactionFC worldcomp = Find.World.GetComponent <FactionFC>(); Faction faction1 = FactionColonies.getPlayerColonyFaction(); //Log.Message((faction1 != null).ToString()); if (faction1 == null && worldcomp.factionCreated == true) { Log.Message("Moved to new planet - Adding faction copy"); //FactionColonies.createPlayerColonyFaction(); FactionColonies.copyPlayerColonyFaction(); faction1 = FactionColonies.getPlayerColonyFaction(); } //Log.Message(((bool)(faction1 != null)).ToString()); foreach (Faction factionOther in Find.FactionManager.AllFactionsListForReading) { //Log.Message(factionOther.def.defName); if (factionOther != faction1 && faction1.RelationWith(factionOther, true) == null) { faction1.TryMakeInitialRelationsWith(factionOther); } } worldcomp.updateFactionIcon(ref faction1, "FactionIcons/" + worldcomp.factionIconPath); worldcomp.factionUpdated = true; //foreach (SettlementFC settlement in worldcomp.settlements) //{ // Settlement obj = Find.WorldObjects.SettlementAt(settlement.mapLocation); // if (obj != null && obj.Faction != faction1) // { // obj.SetFaction(faction1); // } //} }
public FCPrisonerMenu(SettlementFC settlement) { //Window Information this.faction = Find.World.GetComponent <FactionFC>(); this.settlement = settlement; this.prisoners = settlement.prisonerList; this.scroll = 0; this.maxScroll = (prisoners.Count() * optionHeight) - scrollBoxHeight; //Window Properties this.forcePause = false; this.draggable = true; this.doCloseX = true; this.preventCameraMotion = false; optionBox = new Rect(0, 0, 500, optionHeight); //rect for pawn image optionPawnIcon = new Rect(optionBox.x, optionBox.y + 10, 50, 50); //rect for pawn name optionPawnName = new Rect(optionBox.x + 50, optionBox.y + 5, 300, 20); //rect for pawn health optionPawnHealth = new Rect(optionPawnName.x, optionPawnName.y + 20, 300, 20); //rect for pawn unrest optionPawnUnrest = new Rect(optionPawnHealth.x, optionPawnHealth.y + 20, 300, 20); //rect for pawn workload optionPawnWorkload = new Rect(optionPawnUnrest.x, optionPawnUnrest.y + 20, 150, 20); //rect for info button optionButtonInfo = new Rect(optionBox.x + optionBox.width - 150 - 10, optionPawnHealth.y + 20, 150, 20); //rect for action button optionButtonAction = new Rect(optionBox.x + optionBox.width - 150 - 10, optionPawnUnrest.y + 20, 150, 20); }
public override void PreOpen() { base.PreOpen(); stats = statsTab0; statSize = 25; buttons = buttonsTab0; resourceSize = 40; faction = Find.World.GetComponent <FactionFC>(); if (faction != null) { settlementList = faction.settlements; faction.updateAverages(); //Initial release - Autocreate faction //Faction faction = FactionColonies.getPlayerColonyFaction(); //if (faction == null) //{ // FactionColonies.createPlayerColonyFaction(); //} //if (faction.capitalLocation == -1) //{ // faction.setCapital(); //} faction.updateTotalProfit(); } else { Log.Message("WorldComp FactionFC is null - Something is wrong! Empire Mod"); } }
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 FCBuildingWindow(SettlementFC settlement, int buildingSlot) { factionfc = Find.World.GetComponent <FactionFC>(); buildingList = new List <BuildingFCDef>(); foreach (BuildingFCDef building in DefDatabase <BuildingFCDef> .AllDefsListForReading.Where(def => def.RequiredModsLoaded)) { if (building.defName != "Empty" && building.defName != "Construction") { //If not a building that shouldn't appear on the list if (building.techLevel <= factionfc.techLevel) { //If building techlevel requirement is met if (building.applicableBiomes.Count == 0 || building.applicableBiomes.Any() && building.applicableBiomes.Contains(settlement.biome)) { //If building meets the biome requirements buildingList.Add(building); } } } } buildingList.Sort(FactionColonies.CompareBuildingDef); forcePause = false; draggable = true; doCloseX = true; preventCameraMotion = false; this.settlement = settlement; this.buildingSlot = buildingSlot; buildingDef = settlement.buildings[buildingSlot]; }
public static void changeDefendingMilitaryForce(FCEvent evt, SettlementFC settlementOfMilitaryForce) { FactionFC factionfc = Find.World.GetComponent <FactionFC>(); if (settlementOfMilitaryForce == evt.militaryForceDefending.homeSettlement) { Messages.Message("militaryAlreadyDefendingSettlement".Translate(), MessageTypeDefOf.RejectInput); return; } if (evt.militaryForceDefending.homeSettlement != factionfc.returnSettlementByLocation(evt.location, evt.planetName)) { //if the forces defending aren't the forces belonging to the settlement evt.militaryForceDefending.homeSettlement.returnMilitary(false); } factionfc.militaryTargets.Remove(evt.location); evt.militaryForceDefending = militaryForce.createMilitaryForceFromSettlement(settlementOfMilitaryForce); if (settlementOfMilitaryForce == factionfc.returnSettlementByLocation(evt.location, evt.planetName)) { //if home settlement is reseting to defense Messages.Message("defendingMilitaryReset".Translate(), MessageTypeDefOf.NeutralEvent); } else { //if settlement is foreign settlementOfMilitaryForce.sendMilitary(evt.settlementFCDefending.mapLocation, evt.planetName, "defendFriendlySettlement", -1, evt.militaryForceAttackingFaction); } }
public bool attemptResolve() { FactionFC factionfc = Find.World.GetComponent <FactionFC>(); if (PaymentUtil.getSilver() >= -1 * this.taxes.silverAmount || this.taxes.silverAmount >= 0) { //if have enough silver on the current map to pay & map belongs to player FCEventMaker.createTaxEvent(this); if (this.taxes.researchCompleted != 0) { factionfc.researchPointPool += this.taxes.researchCompleted; Messages.Message(TranslatorFormattedStringExtensions.Translate("PointsAddedToResearchPool", this.taxes.researchCompleted), MessageTypeDefOf.PositiveEvent); } if (this.taxes.electricityAllotted != 0) { factionfc.powerPool += this.taxes.electricityAllotted; } return(true); } else { return(false); } }
public FCPolicy(FCPolicyDef def) { FactionFC faction = Find.World.GetComponent <FactionFC>(); this.def = def; timeEnacted = Find.TickManager.TicksGame; //Road Builder Trait if (def == FCPolicyDefOf.roadBuilders) { ResearchProjectDef researchdef = DefDatabase <ResearchProjectDef> .GetNamed("FCRoadBuildingDirt", false); if (researchdef == null) { Log.Message("Empire Error - Road research returned Null"); } if (!(Find.ResearchManager.GetProgress(researchdef) == researchdef.baseCost)) { Find.ResearchManager.FinishProject(researchdef); } } //Mercantile Trait if (def == FCPolicyDefOf.mercantile) { faction.resetTraitMercantileCaravanTime(); } }
static bool Prefix(ref Faction __instance, Pawn member, DamageInfo?dinfo, bool wasWorldPawn, Map map) { if (member.Faction.def.defName == "PColony" && !wasWorldPawn && !PawnGenerator.IsBeingGenerated(member) && map != null && map.IsPlayerHome && !__instance.HostileTo(Faction.OfPlayer)) { FactionFC faction = Find.World.GetComponent <FactionFC>(); if (!faction.hasPolicy(FCPolicyDefOf.pacifist) && dinfo != null) { if (dinfo.Value.Category == DamageInfo.SourceCategory.Collapse) { faction.GainUnrestForReason(new Message("DeathOfFactionPawn".Translate(), MessageTypeDefOf.PawnDeath), 5d); faction.GainHappiness(-5d); } else if (dinfo.Value.Instigator?.Faction == Find.FactionManager.OfPlayer) { faction.GainUnrestForReason(new Message("DeathOfFactionPawn".Translate(), MessageTypeDefOf.PawnDeath), 5d); faction.GainHappiness(-5d); } } //return false to stop from continuing method return(false); } return(true); }
public FCBillWindow() { //Window Information this.faction = Find.World.GetComponent <FactionFC>(); this.bills = faction.Bills; this.scroll = 0; this.maxScroll = (bills.Count() * billHeight) - scrollBoxHeight; //Window Properties this.forcePause = false; this.draggable = true; this.doCloseX = true; this.preventCameraMotion = false; //rect for title //Rect titleBox = new Rect(0, 0, 300, 60); //rect for box outline billsBox = new Rect(0, 30, 590, 212); //rect for bill name billNameBase = new Rect(0, 0, 200, billHeight); //rect for description billDescBase = new Rect(billNameBase.width, 0, 80, billHeight); //rect for source button billLocationBase = new Rect(billDescBase.x + billDescBase.width, 0, 80, billHeight); //rect time time remaining billTimeRemaining = new Rect(billLocationBase.x + billLocationBase.width, 0, 90, billHeight); //rect for bill resolve button billResolveBase = new Rect(billTimeRemaining.x + billTimeRemaining.width, 0, 140, billHeight); }
public bool resolve() { FactionFC factionfc = Find.World.GetComponent <FactionFC>(); if (PaymentUtil.getSilver() >= -1 * taxes.silverAmount || taxes.silverAmount >= 0) { //if have enough silver on the current map to pay & map belongs to player FCEventMaker.createTaxEvent(this); if (taxes.researchCompleted != 0) { factionfc.researchPointPool += taxes.researchCompleted; Messages.Message("PointsAddedToResearchPool".Translate(taxes.researchCompleted), MessageTypeDefOf.PositiveEvent); } if (taxes.electricityAllotted != 0) { factionfc.powerPool += taxes.electricityAllotted; } return(true); } string messageString = "NotEnoughSilverForBill".Translate() + " " + settlement.name + ". " + "ConfiscatedTithes".Translate() + "." + " " + "UnpaidTitheEffect".Translate(); settlement.GainUnrestWithReason(new Message(messageString, MessageTypeDefOf.NegativeEvent), 10d); settlement.GainHappiness(-10d); factionfc.Bills.Remove(this); return(false); }
public bool resolve() { FactionFC factionfc = Find.World.GetComponent <FactionFC>(); if (PaymentUtil.getSilver() >= -1 * taxes.silverAmount || taxes.silverAmount >= 0) { //if have enough silver on the current map to pay & map belongs to player FCEventMaker.createTaxEvent(this); if (taxes.researchCompleted != 0) { factionfc.researchPointPool += taxes.researchCompleted; Messages.Message("PointsAddedToResearchPool".Translate(taxes.researchCompleted), MessageTypeDefOf.PositiveEvent); } if (taxes.electricityAllotted != 0) { factionfc.powerPool += taxes.electricityAllotted; } return(true); } Messages.Message("NotEnoughSilverForBill".Translate() + " " + settlement.name + ". " + "ConfiscatedTithes".Translate() + "." + " " + "UnpaidTitheEffect".Translate(), MessageTypeDefOf.NegativeEvent); settlement.unrest += 10 * TraitUtilsFC.cycleTraits(new double(), "unrestGainedMultiplier", settlement.traits, "multiply") * TraitUtilsFC.cycleTraits(new double(), "unrestGainedMultiplier", factionfc.traits, "multiply"); settlement.happiness -= 10 * TraitUtilsFC.cycleTraits(new double(), "happinessLostMultiplier", settlement.traits, "multiply") * TraitUtilsFC.cycleTraits(new double(), "happinessLostMultiplier", factionfc.traits, "multiply"); factionfc.Bills.Remove(this); return(false); }
public MilSquadFC CreateMilSquad() { MilSquadFC squad = new MilSquadFC(true); squad.name = name; squad.isCivilian = isCivilian; squad.isTraderCaravan = isTraderCaravan; FactionFC fc = Find.World.GetComponent <FactionFC>(); var milUnits = unitTemplates.Select(unit => unit.CreateMilUnit()).ToList(); foreach (int i in units) { if (i == -1) { squad.units.Add(fc.militaryCustomizationUtil.blankUnit); } else { squad.units.Add(milUnits[i]); } } return(squad); }
public FCEventWindow() { //Window Information this.faction = Find.World.GetComponent <FactionFC>(); this.events = faction.events; this.scroll = 0; this.maxScroll = (events.Count() * eventHeight) - scrollBoxHeight; //Window Properties this.forcePause = false; this.draggable = true; this.doCloseX = true; this.preventCameraMotion = false; //rect for title //Rect titleBox = new Rect(0, 0, 300, 60); //rect for box outline eventsBox = new Rect(0, 30, 590, 212); //rect for event name eventNameBase = new Rect(0, 0, 250, eventHeight); //rect for description eventDescBase = new Rect(eventNameBase.width, 0, 100, eventHeight); //rect for source button eventLocationBase = new Rect(eventDescBase.x + eventDescBase.width, 0, 100, eventHeight); //rect time time remaining eventTimeRemaining = new Rect(eventLocationBase.x + eventLocationBase.width, 0, 140, eventHeight); }
public MilUnitFC Import() { FactionFC fc = Find.World.GetComponent <FactionFC>(); MilUnitFC unit = this.CreateMilUnit(); fc.militaryCustomizationUtil.units.Add(unit); return(unit); }
public override void Notify_PawnLost(Pawn pawn, PawnLostCondition condition) { FactionFC faction = Find.World.GetComponent <FactionFC>(); //Check if a settlement battle ended SettlementFC settlement = faction.getSettlement(pawn.Tile, Find.World.info.name); settlement?.worldSettlement.removeAttacker(pawn); }
public override void PreOpen() { base.PreOpen(); settlement.updateDescription(); settlement.updateProfitAndProduction(); maxScroll = (ResourceUtils.resourceTypes.Length * ScrollSpacing) - ScrollHeight; //settlement.update description factionfc = Find.World.GetComponent <FactionFC>(); }
public CreateColonyWindowFc() { forcePause = false; draggable = false; preventCameraMotion = false; doCloseX = true; windowRect = new Rect(UI.screenWidth - InitialSize.x, (UI.screenHeight - InitialSize.y) / 2f - (UI.screenHeight / 8f), InitialSize.x, InitialSize.y); faction = Find.World.GetComponent <FactionFC>(); }
public DesignUnitsWindow(MilitaryCustomizationUtil util, FactionFC faction) { this.util = util; this.faction = faction; selectedText = "Select A Unit"; util.checkMilitaryUtilForErrors(); }
public DesignUnitsWindow(MilitaryCustomizationUtil util, FactionFC faction) { this.util = util; this.faction = faction; selectedText = "Select A Unit"; coveragePanel = new Panel_ShowCoverage(this); util.checkMilitaryUtilForErrors(); }
public AssignSquadsWindow(MilitaryCustomizationUtil util, FactionFC faction) { this.util = util; this.faction = faction; settlementHeight = 120; settlementYSpacing = 5; settlementMaxScroll = (Find.World.GetComponent <FactionFC>().settlements.Count *(settlementYSpacing + settlementHeight) - settlementWindowHeight); }
public MilitaryCustomizationWindowFc() { forcePause = false; draggable = true; doCloseX = true; preventCameraMotion = false; util = Find.World.GetComponent <FactionFC>().militaryCustomizationUtil; faction = Find.World.GetComponent <FactionFC>(); }
public void FinalizeInit(FactionFC factionFc) { this.factionFc = factionFc; militaryUtil = factionFc.militaryCustomizationUtil; faction = DefDatabase <FactionDef> .GetNamed("PColony"); faction.pawnGroupMakers = emptyList.ListFullCopy(); WorldSettlementTraderTracker.reloadTraderKind(); }
public factionCustomizeWindowFC(FactionFC faction) { this.forcePause = false; this.draggable = true; this.doCloseX = true; this.preventCameraMotion = false; this.faction = faction; this.header = "CustomizeFaction".Translate(); this.name = faction.name; this.title = faction.title; }
static void Postfix(ref TradeDeal __instance, ref bool __result) { if (TradeSession.trader.TraderKind.defName == "FCResearchTrader") { FactionFC faction = Find.World.GetComponent <FactionFC>(); if (__result == true && faction.tradedAmount != 0) { Find.LetterStack.ReceiveLetter("FCFactionResearch".Translate(), TranslatorFormattedStringExtensions.Translate("PointsAddedToResearchPool", faction.tradedAmount), LetterDefOf.PositiveEvent); faction.tradedAmount = 0; } } }
public MilSquadFC Import() { FactionFC fc = Find.World.GetComponent <FactionFC>(); MilSquadFC squad = this.CreateMilSquad(); foreach (MilUnitFC unit in squad.units.Distinct().Where(unit => !unit.isBlank)) { fc.militaryCustomizationUtil.units.Add(unit); } fc.militaryCustomizationUtil.squads.Add(squad); return(squad); }