示例#1
0
 public BillFC(SettlementFC settlement)
 {
     SetUniqueLoadID();
     this.settlement = settlement;
     dueTick         = Find.TickManager.TicksGame + 300000;
     taxes           = new TaxesFC(this);
 }
        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];
        }
示例#3
0
        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.
        }
示例#4
0
        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);
            }
        }
示例#5
0
        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);
        }
 private List <FloatMenuOption> DeploymentOptions(SettlementFC settlement) => new List <FloatMenuOption>
 {
     new FloatMenuOption("walkIntoMapDeploymentOption".Translate(), delegate
     {
         FactionColonies.CallinAlliedForces(settlement, false);
     }), DropPodDeploymentOption(settlement)
 };
示例#7
0
 public FCWindow_Confirm(SettlementFC settlement)
 {
     this.forcePause          = false;
     this.draggable           = true;
     this.doCloseX            = true;
     this.preventCameraMotion = false;
     this.settlement          = settlement;
 }
        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);
        }
示例#9
0
 public militaryForce(double militaryLevel, double militaryEfficiency, SettlementFC homeSettlement, Faction homeFaction)
 {
     this.militaryLevel      = militaryLevel;
     this.militaryEfficiency = militaryEfficiency;
     this.homeSettlement     = homeSettlement;
     this.homeFaction        = homeFaction;
     forceRemaining          = Math.Round(militaryLevel * militaryEfficiency);
 }
 public FCWindow_Confirm_TaxBreak(SettlementFC settlement) : base(settlement)
 {
     this.forcePause          = false;
     this.draggable           = true;
     this.doCloseX            = true;
     this.preventCameraMotion = false;
     this.settlement          = settlement;
     this.stringConfirm       = "FCConfirmTaxBreak".Translate();
 }
示例#11
0
 public FCWindow_Pay_Silver(SettlementFC settlement)
 {
     this.forcePause          = false;
     this.draggable           = true;
     this.doCloseX            = true;
     this.preventCameraMotion = false;
     this.silverCount         = PaymentUtil.getSilver();
     this.settlement          = settlement;
     this.selectedSilver      = 0;
 }
示例#12
0
 public TaxesFC(BillFC bill)
 {
     SetUniqueLoadID();
     this.bill           = bill;
     settlement          = bill.settlement;
     silverAmount        = 0;
     itemTithes          = new List <Thing>();
     electricityAllotted = 0;
     researchCompleted   = 0;
 }
示例#13
0
        public static militaryForce createMilitaryForceFromSettlement(SettlementFC settlement)
        {
            //get efficiency from traits and settlement efficiency.
            double        militaryLevel = settlement.settlementMilitaryLevel;
            double        efficiency    = traitUtilsFC.cycleTraits(new double(), "militaryMultiplierCombatEfficiency", Find.World.GetComponent <FactionFC>().traits, "multiply") * traitUtilsFC.cycleTraits(new double(), "militaryMultiplierCombatEfficiency", settlement.traits, "multiply");
            militaryForce returnForce   = new militaryForce(militaryLevel, efficiency, settlement, FactionColonies.getPlayerColonyFaction());

            return(returnForce);
            //create and return force.
        }
示例#14
0
 public FCPrisoner(Pawn pawn, SettlementFC settlement)
 {
     this.prisoner      = pawn;
     this.settlement    = settlement;
     this.unrest        = 0;
     this.healthTracker = new Pawn_HealthTracker(pawn);
     this.healthTracker = pawn.health;
     this.health        = (float)Math.Round(this.prisoner.health.summaryHealth.SummaryHealthPercent * 100);
     this.isReturning   = false;
     this.loadID        = Find.World.GetComponent <FactionFC>().GetNextPrisonerID();
 }
 public FCWindow_Pay_Silver_Loyalty(SettlementFC settlement) : base(settlement)
 {
     this.forcePause          = false;
     this.draggable           = true;
     this.doCloseX            = true;
     this.preventCameraMotion = false;
     this.silverCount         = PaymentUtil.getSilver();
     this.settlement          = settlement;
     this.selectedSilver      = 0;
     this.stringEffect        = "SettlementGainsXLoyalty";
 }
 public SettlementCustomizeWindowFc(SettlementFC settlement)
 {
     this.forcePause          = false;
     this.draggable           = true;
     this.doCloseX            = true;
     this.preventCameraMotion = false;
     this.settlement          = settlement;
     this.header = "CustomizeSettlement".Translate();
     this.name   = settlement.name;
     //this.title = faction.title;
 }
示例#17
0
 public settlementUpgradeWindowFC(SettlementFC settlement)
 {
     this.forcePause          = false;
     this.draggable           = true;
     this.doCloseX            = true;
     this.preventCameraMotion = false;
     this.header                = "UpgradeSettlement".Translate();
     this.settlement            = settlement;
     this.settlementUpgradeCost = Convert.ToInt32(LoadedModManager.GetMod <FactionColoniesMod>().GetSettings <FactionColonies>().settlementBaseUpgradeCost) + (settlement.settlementLevel * 1000);
     this.desc = settlement.name + " " + "CanBeUpgraded".Translate() + " " + this.settlementUpgradeCost + " " + "Silver".Translate().ToLower() + ". " + "UpgradeColonyDesc".Translate();
 }
 public SettlementCustomizeWindowFc(SettlementFC settlement)
 {
     forcePause          = false;
     draggable           = true;
     doCloseX            = true;
     preventCameraMotion = false;
     this.settlement     = settlement;
     name          = settlement.name;
     shortName     = settlement.ShortName;
     doCloseButton = true;
     doCloseX      = false;
 }
示例#19
0
 public FCPrisoner(Pawn pawn, SettlementFC settlement)
 {
     prisoner        = pawn;
     this.settlement = settlement;
     unrest          = 0;
     healthTracker   = new Pawn_HealthTracker(pawn);
     healthTracker   = pawn.health;
     health          = (float)Math.Round(prisoner.health.summaryHealth.SummaryHealthPercent * 100);
     isReturning     = false;
     loadID          = Find.World.GetComponent <FactionFC>().GetNextPrisonerID();
     pawn.guest.SetGuestStatus(FactionColonies.getPlayerColonyFaction(), GuestStatus.Prisoner);
 }
示例#20
0
        public SettlementFC settlement;          //Don't expose

        public settlementWindowFC(SettlementFC settlement)
        {
            if (settlement == null)
            {
                this.Close();
            }
            this.settlement          = settlement;
            this.forcePause          = false;
            this.draggable           = true;
            this.doCloseX            = true;
            this.preventCameraMotion = false;
        }
示例#21
0
 public FCPrisoner(Pawn pawn, SettlementFC settlement)
 {
     this.prisoner      = pawn;
     this.settlement    = settlement;
     this.unrest        = 0;
     this.health        = 100;
     this.isReturning   = false;
     this.loadID        = Find.World.GetComponent <FactionFC>().GetNextPrisonerID();
     this.workload      = FCWorkLoad.Light;
     this.healthTracker = new Pawn_HealthTracker(pawn);
     this.healthTracker = pawn.health;
     HealthUtility.HealNonPermanentInjuriesAndRestoreLegs(this.prisoner);
 }
 public SettlementUpgradeWindowFc(SettlementFC settlement)
 {
     forcePause          = false;
     draggable           = true;
     doCloseX            = true;
     preventCameraMotion = false;
     header                = "UpgradeSettlement".Translate();
     this.settlement       = settlement;
     settlementUpgradeCost = Convert.ToInt32(LoadedModManager.GetMod <FactionColoniesMod>().GetSettings <FactionColonies>().settlementBaseUpgradeCost) + (settlement.settlementLevel * 1000);
     desc               = settlement.name + " " + "CanBeUpgraded".Translate() + " " + settlementUpgradeCost + " " + "Silver".Translate().ToLower() + ". " + "UpgradeColonyDesc".Translate();
     factionfc          = Find.World.GetComponent <FactionFC>();
     maxSettlementLevel = LoadedModManager.GetMod <FactionColoniesMod>().GetSettings <FactionColonies>().settlementMaxLevel;
 }
示例#23
0
        public SettlementFC settlement; //Don't expose

        public SettlementWindowFc(SettlementFC settlement)
        {
            if (settlement == null)
            {
                Close();
            }

            this.settlement     = settlement;
            forcePause          = false;
            draggable           = true;
            doCloseX            = true;
            preventCameraMotion = false;
        }
示例#24
0
        public static void changeDefendingMilitaryForce(FCEvent evt, SettlementFC settlementOfMilitaryForce)
        {
            FactionFC     factionfc        = Find.World.GetComponent <FactionFC>();
            militaryForce tmpMilitaryForce = null;
            SettlementFC  homeSettlement   = factionfc.returnSettlementByLocation(evt.location, evt.planetName);

            if (settlementOfMilitaryForce == evt.militaryForceDefending.homeSettlement)
            {
                Messages.Message("militaryAlreadyDefendingSettlement".Translate(), MessageTypeDefOf.RejectInput);
                return;
            }

            WorldSettlementFC target = Find.World.worldObjects.WorldObjectAt <WorldSettlementFC>(evt.location);

            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);
            }

            if (settlementOfMilitaryForce != homeSettlement)
            {
                tmpMilitaryForce =
                    militaryForce.createMilitaryForceFromSettlement(
                        factionfc.returnSettlementByLocation(evt.location, evt.planetName), true);
            }

            factionfc.militaryTargets.Remove(evt.location);
            evt.militaryForceDefending =
                militaryForce.createMilitaryForceFromSettlement(settlementOfMilitaryForce,
                                                                homeDefendingForce: tmpMilitaryForce);

            target.defenderForce = evt.militaryForceDefending;

            if (settlementOfMilitaryForce == homeSettlement)
            {
                //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,
                                                       util.MilitaryJob.DefendFriendlySettlement, -1, evt.militaryForceAttackingFaction);
                Find.LetterStack.ReceiveLetter("Military Action", "ForeignMilitarySwitch"
                                               .Translate(settlementOfMilitaryForce.name,
                                                          factionfc.returnSettlementByLocation(evt.location, evt.planetName).name,
                                                          evt.militaryForceDefending.militaryLevel), LetterDefOf.NeutralEvent);
            }
        }
示例#25
0
        public override void Notify_PawnLost(Pawn pawn, PawnLostCondition condition)
        {
            if (condition == PawnLostCondition.ChangedFaction || condition == PawnLostCondition.ExitedMap)
            {
                lord.AddPawn(pawn);
                return;
            }
            pawn.SetFaction(FactionColonies.getPlayerColonyFaction());
            FactionFC faction = Find.World.GetComponent <FactionFC>();
            //Check if a settlement battle ended
            SettlementFC settlement = faction.getSettlement(pawn.Tile, Find.World.info.name);

            settlement?.worldSettlement.removeDefender(pawn);
        }
示例#26
0
        public static void attackPlayerSettlement(militaryForce attackingForce, SettlementFC settlement,
                                                  Faction enemyFaction)
        {
            FactionFC factionfc = Find.World.GetComponent <FactionFC>();

            FCEvent tmp = FCEventMaker.MakeEvent(FCEventDefOf.settlementBeingAttacked);

            tmp.hasCustomDescription = true;
            tmp.timeTillTrigger      = Find.TickManager.TicksGame + 60000;
            tmp.location             = settlement.mapLocation;
            tmp.planetName           = settlement.planetName;
            tmp.hasDestination       = true;
            tmp.customDescription    = "settlementAboutToBeAttacked"
                                       .Translate(settlement.name, enemyFaction.Name);
            tmp.militaryForceDefending        = militaryForce.createMilitaryForceFromSettlement(settlement);
            tmp.militaryForceDefendingFaction = FactionColonies.getPlayerColonyFaction();
            tmp.militaryForceAttacking        = attackingForce;
            tmp.militaryForceAttackingFaction = enemyFaction;
            tmp.settlementFCDefending         = settlement;

            SettlementFC highest = null;

            foreach (SettlementFC settlementCompare in factionfc.settlements)
            {
                if (settlementCompare.autoDefend && settlementCompare.militaryBusy == false &&
                    settlementCompare.settlementMilitaryLevel > settlement.settlementMilitaryLevel &&
                    (highest == null || settlementCompare.settlementMilitaryLevel > highest.settlementMilitaryLevel))
                {
                    highest = settlementCompare;
                }
            }

            if (highest != null)
            {
                changeDefendingMilitaryForce(tmp, highest);
            }

            settlement.worldSettlement.defenderForce = tmp.militaryForceDefending;
            settlement.worldSettlement.attackerForce = tmp.militaryForceAttacking;

            Find.World.GetComponent <FactionFC>().addEvent(tmp);

            tmp.customDescription += "\n\nThe estimated attacking force's power is: " +
                                     tmp.militaryForceAttacking.forceRemaining;
            settlement.isUnderAttack = true;

            Find.LetterStack.ReceiveLetter("settlementInDanger".Translate(), tmp.customDescription,
                                           LetterDefOf.ThreatBig, new LookTargets(Find.WorldObjects.WorldObjectAt <WorldSettlementFC>(settlement.mapLocation)));
        }
示例#27
0
 public ResourceFC(double baseProduction, ResourceType type, SettlementFC settlement = null)
 {
     name  = type.ToString().ToLower();
     label = type.ToString();
     this.baseProduction = baseProduction;
     endProduction       = baseProduction;
     amount = 0;
     baseProductionMultiplier = 1;
     baseProductionAdditives.Add(new ProductionAdditive("", 0, ""));
     baseProductionMultipliers.Add(new ProductionMultiplier("", 0, ""));
     this.settlement = settlement;
     filter          = new ThingFilter();
     if (settlement != null)
     {
         PaymentUtil.resetThingFilter(settlement, type);
     }
 }
示例#28
0
 public ResourceFC(string name, string label, double baseProduction, SettlementFC settlement = null, int i = -1)
 {
     this.name                     = name;
     this.label                    = label;
     this.baseProduction           = baseProduction;
     this.endProduction            = baseProduction;
     this.amount                   = 0;
     this.baseProductionMultiplier = 1;
     this.baseProductionAdditives.Add(new ProductionAdditive("", 0, ""));
     this.baseProductionMultipliers.Add(new ProductionMultiplier("", 0, ""));
     this.settlement = settlement;
     this.filter     = new ThingFilter();
     if (settlement != null)
     {
         PaymentUtil.resetThingFilter(settlement, i);
     }
 }
示例#29
0
        public override void ScatterAt(IntVec3 c, Map map, GenStepParams parms, int stackCount = 1)
        {
            if (Settlement == null)
            {
                FactionFC settlementFaction = Find.World.GetComponent <FactionFC>();
                Settlement = settlementFaction.getSettlement(map.Tile, Find.World.info.name);
            }

            int      middle         = 36 + Settlement.settlementLevel * 2;
            IntRange range          = new IntRange(middle - 2, middle + 2);
            int      randomInRange1 = range.RandomInRange;
            int      randomInRange2 = range.RandomInRange;
            CellRect cellRect       = new CellRect(c.x - randomInRange1 / 2, c.z - randomInRange2 / 2, randomInRange1,
                                                   randomInRange2);
            Faction faction = Faction.OfPlayer;

            cellRect.ClipInsideMap(map);
            ResolveParams resolveParams = new ResolveParams();

            if (Settlement.settlementLevel >= 7)
            {
                resolveParams.filthDef = null;
            }
            else
            {
                resolveParams.filthDensity =
                    new FloatRange(Settlement.settlementLevel / 10f, (Settlement.settlementLevel + 3) / 10f);
            }

            resolveParams.chanceToSkipFloor = Math.Min(0, 100 - Settlement.settlementLevel * 10);
            resolveParams.rect                 = cellRect;
            resolveParams.faction              = faction;
            BaseGen.globalSettings.map         = map;
            resolveParams.stockpileMarketValue = (float)Settlement.totalProfit;
            double defenseBuildings = Settlement.weapons.endProduction;

            int defenseCount = (int)(CurveFactor * Math.Log(defenseBuildings + 1));

            resolveParams.edgeDefenseMortarsCount = (int)Math.Ceiling(defenseCount / 3f);
            resolveParams.edgeDefenseTurretsCount = defenseCount;
            BaseGen.globalSettings.minBuildings   = Settlement.settlementLevel;
            BaseGen.globalSettings.minBarracks    = Settlement.settlementLevel;
            BaseGen.symbolStack.Push("colony", resolveParams);
            BaseGen.Generate();
        }
示例#30
0
        private FloatMenuOption DropPodDeploymentOption(SettlementFC settlement)
        {
            bool medievalOnly = LoadedModManager.GetMod <FactionColoniesMod>().GetSettings <FactionColonies>()
                                .medievalTechOnly;

            if (!medievalOnly && (DefDatabase <ResearchProjectDef> .GetNamed("TransportPod", false)?.IsFinished ?? false))
            {
                return(new FloatMenuOption("dropPodDeploymentOption".Translate(),
                                           delegate { FactionColonies.CallinAlliedForces(settlement, true); }));
            }

            return(new FloatMenuOption(
                       "dropPodDeploymentOption".Translate() + (medievalOnly
                    ? "dropPodDeploymentOptionUnavailableReasonMedieval".Translate()
                    : "dropPodDeploymentOptionUnavailableReasonTech".Translate(
                                                                    DefDatabase <ResearchProjectDef> .GetNamed("TransportPod", false)?.label ??
                                                                    "errorDropPodResearchCouldNotBeFound".Translate())), null));
        }