protected override IntVec3 GetExactWanderDest(Pawn pawn) { Area outpostArea = OG_Util.FindOutpostArea(); if ((outpostArea != null) && outpostArea.ActiveCells.Contains(pawn.Position)) { return(RCellFinder.RandomWanderDestFor(pawn, pawn.Position, this.wanderRadius, this.wanderDestValidator, PawnUtility.ResolveMaxDanger(pawn, this.maxDanger))); } else { Building_OutpostCommandConsole console = OG_Util.FindOutpostCommandConsole(OG_Util.FactionOfMiningCo); if (console != null) { IntVec3 cell1 = WanderUtility.BestCloseWanderRoot(console.Position, pawn); return(cell1); } else { for (int cellIndex = 0; cellIndex < 50; cellIndex++) { IntVec3 cell2 = outpostArea.ActiveCells.RandomElement(); if (pawn.CanReserveAndReach(cell2, PathEndMode.Touch, Danger.Some)) { return(cell2); } } IntVec3 cell3 = WanderUtility.BestCloseWanderRoot(pawn.Position, pawn); return(cell3); } } }
public static void GenerateLaserFence(ZoneProperties[,] zoneMap, ref OG_OutpostData outpostData) { if (OG_Util.IsModActive("MiningCo. LaserFence") == false) { Log.Warning("MiningCo. OutpostGenerator: MiningCo. LaserFence mod is not active. Cannot generate laser fences."); return; } int horizontalZonesNumber = 0; int verticalZonesNumber = 0; if (outpostData.size == OG_OutpostSize.SmallOutpost) { horizontalZonesNumber = OG_SmallOutpost.horizontalZonesNumber; verticalZonesNumber = OG_SmallOutpost.verticalZonesNumber; GenerateLaseFenceForSmallOutpost(zoneMap, horizontalZonesNumber, verticalZonesNumber, ref outpostData); } else { horizontalZonesNumber = OG_BigOutpost.horizontalZonesNumber; verticalZonesNumber = OG_BigOutpost.verticalZonesNumber; GenerateLaseFenceForBigOutpost(zoneMap, horizontalZonesNumber, verticalZonesNumber, ref outpostData); } }
private static void UnforbidItemsToLoadInCargoBay() { // Unforbid any weapon, apparel, raw food or corpse in the outpost area so it can be carried to a cargo bay. if (OG_Util.FindOutpostArea() != null) { foreach (IntVec3 cell in OG_Util.FindOutpostArea().ActiveCells) { foreach (Thing thing in cell.GetThingList()) { if (thing.def.thingCategories == null) { continue; } if (thing.def.thingCategories.Contains(ThingCategoryDefOf.Apparel) || thing.def.thingCategories.Contains(ThingCategoryDef.Named("Headgear")) || thing.def.thingCategories.Contains(ThingCategoryDef.Named("WeaponsMelee")) || thing.def.thingCategories.Contains(ThingCategoryDef.Named("WeaponsRanged")) || thing.def.thingCategories.Contains(ThingCategoryDef.Named("CorpsesHumanlike")) || thing.def.thingCategories.Contains(ThingCategoryDef.Named("Textiles")) || (thing.def == ThingDef.Named("RawHops")) || (thing.def.thingCategories.Contains(ThingCategoryDef.Named("PlantFoodRaw")) && (thing.def != ThingDef.Named("Hay")))) { thing.SetForbidden(false); } } } } }
public override void Tick() { base.Tick(); if (this.ticksToTakeOff == maxTicksToTakeOff) { // Only spawn reinforcement pawns and supply once. SpawnRequestedReinforcements(); SpawnNecessarySupply(); UnforbidItemsToLoadInCargoBay(); } this.ticksToTakeOff--; if (this.ticksToTakeOff <= 0) { // Update requested reinforcements. Building_OrbitalRelay orbitalRelay = OG_Util.FindOrbitalRelay(OG_Util.FactionOfMAndCo); if (orbitalRelay != null) { orbitalRelay.UpdateRequestedReinforcements(); } // Spawn taking off supply ship. SupplyShipTakingOff supplyShip = ThingMaker.MakeThing(OG_Util.SupplyShipTakingOffDef) as SupplyShipTakingOff; supplyShip.InitializeLandingData(this.Position, this.Rotation); supplyShip.SetFaction(this.Faction); GenSpawn.Spawn(supplyShip, this.Position); this.Destroy(); } }
private void SpawnNecessarySupply() { const int mealsInStockTarget = 80; const int beersInStockTarget = 100; const int componentsInStockTarget = 20; int mealsInOutpost = 0; int beersInOutpost = 0; int componentsInOutpost = 0; int mealsToSupply = 0; int beersToSupply = 0; int componentsToSupply = 0; if (OG_Util.FindOutpostArea() == null) { // Outpost has been captured, do not resupply. return; } CountResourcesInOutpost(out mealsInOutpost, out beersInOutpost, out componentsInOutpost); mealsToSupply = mealsInStockTarget - mealsInOutpost; beersToSupply = beersInStockTarget - beersInOutpost; componentsToSupply = componentsInStockTarget - componentsInOutpost; SpawnSupplyNearPosition(ThingDefOf.MealSurvivalPack, mealsToSupply, this.Position); SpawnSupplyNearPosition(ThingDefOf.Beer, beersToSupply, this.Position); SpawnSupplyNearPosition(ThingDefOf.Components, componentsToSupply, this.Position); }
private static void CountResourcesInOutpost(out int meals, out int beers, out int components) { meals = 0; beers = 0; components = 0; if (OG_Util.FindOutpostArea() != null) { foreach (IntVec3 cell in OG_Util.FindOutpostArea().ActiveCells) { foreach (Thing thing in cell.GetThingList()) { if (thing.def == ThingDefOf.MealSurvivalPack) { meals += thing.stackCount; } if (thing.def == ThingDefOf.Beer) { beers += thing.stackCount; } if (thing.def == ThingDefOf.Components) { components += thing.stackCount; } } } } }
public override bool HasJobOnThing(Pawn pawn, Thing t) { Fire fire = t as Fire; if (fire == null) { return(false); } Pawn pawn2 = fire.parent as Pawn; if (pawn2 != null) { if (pawn2 == pawn) { return(false); } if ((pawn2.Faction == pawn.Faction || pawn2.HostFaction == pawn.Faction || pawn2.HostFaction == pawn.HostFaction) && ((OG_Util.FindOutpostArea() == null) || (OG_Util.FindOutpostArea().ActiveCells.Contains(t.Position) == false)) && Gen.ManhattanDistanceFlat(pawn.Position, pawn2.Position) > 15) { return(false); } } else if ((OG_Util.FindOutpostArea() == null) || (OG_Util.FindOutpostArea().ActiveCells.Contains(t.Position) == false)) { return(false); } return(((pawn.Position - fire.Position).LengthHorizontalSquared <= 225f || pawn.CanReserve(fire, 1)) && !WorkGiver_FightFiresOutpost.FireIsBeingHandled(fire, pawn)); }
private void SpawnRequestedReinforcements() { Building_OrbitalRelay orbitalRelay = OG_Util.FindOrbitalRelay(this.Faction); if (orbitalRelay != null) { for (int pawnIndex = 0; pawnIndex < orbitalRelay.requestedOfficersNumber; pawnIndex++) { Pawn pawn = OG_Inhabitants.GeneratePawn(OG_Util.OutpostOfficerDef); GenSpawn.Spawn(pawn, this.Position); } for (int pawnIndex = 0; pawnIndex < orbitalRelay.requestedHeavyGuardsNumber; pawnIndex++) { Pawn pawn = OG_Inhabitants.GeneratePawn(OG_Util.OutpostHeavyGuardDef); GenSpawn.Spawn(pawn, this.Position); } for (int pawnIndex = 0; pawnIndex < orbitalRelay.requestedGuardsNumber; pawnIndex++) { Pawn pawn = OG_Inhabitants.GeneratePawn(OG_Util.OutpostGuardDef); GenSpawn.Spawn(pawn, this.Position); } for (int pawnIndex = 0; pawnIndex < orbitalRelay.requestedScoutsNumber; pawnIndex++) { Pawn pawn = OG_Inhabitants.GeneratePawn(OG_Util.OutpostScoutDef); GenSpawn.Spawn(pawn, this.Position); } for (int pawnIndex = 0; pawnIndex < orbitalRelay.requestedTechniciansNumber; pawnIndex++) { Pawn pawn = OG_Inhabitants.GeneratePawn(OG_Util.OutpostTechnicianDef); GenSpawn.Spawn(pawn, this.Position + Vector3Utility.RandomHorizontalOffset(4f).ToIntVec3()); } } }
/// <summary> /// Destroy the outpost area if it exists. /// </summary> public static void DestroyOutpostArea() { if (OG_Util.FindOutpostArea() != null) { OG_Util.FindOutpostArea().Delete(); } }
private static void GenerateOneShootingLine(IntVec3 shootingPosition, Rot4 rotation, ref OG_OutpostData outpostData) { // Spawn floor. for (int xOffset = -1; xOffset <= 1; xOffset++) { for (int zOffset = -1; zOffset <= 9; zOffset++) { Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete); } } Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(0, 0, 2).RotatedBy(rotation), TerrainDef.Named("MetalTile")); Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(0, 0, 3).RotatedBy(rotation), TerrainDef.Named("PavedTile")); Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(0, 0, 4).RotatedBy(rotation), TerrainDef.Named("MetalTile")); Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(0, 0, 5).RotatedBy(rotation), TerrainDef.Named("PavedTile")); Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(0, 0, 6).RotatedBy(rotation), TerrainDef.Named("MetalTile")); Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(0, 0, 7).RotatedBy(rotation), TerrainDef.Named("PavedTile")); // Spawn sandbags. OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, shootingPosition + new IntVec3(-1, 0, 0).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, shootingPosition + new IntVec3(-1, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, shootingPosition + new IntVec3(0, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, shootingPosition + new IntVec3(1, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, shootingPosition + new IntVec3(1, 0, 0).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); // Spawn target. if (OG_Util.IsModActive("Misc. Training")) { OG_Common.TrySpawnThingAt(ThingDef.Named("ShootingRangeTarget"), null, shootingPosition + new IntVec3(0, 0, 8).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData); } else { OG_Common.TrySpawnWallAt(shootingPosition + new IntVec3(0, 0, 8).RotatedBy(rotation), ref outpostData); } }
public override void Destroy(DestroyMode mode = DestroyMode.Vanish) { base.Destroy(mode); this.outpostThingList = OG_Util.RefreshThingList(this.outpostThingList); string eventTitle = "Coralie out"; string eventText = " M&Co. system maintenance request\n\n" + "Request author: Coralie\n" + "Function: M&Co. outpost AI\n\n" + "Defect description:\n" + "Coralie here. I detect several severe dysfunctions.\n" + "- video sensors: LINK DAMAGED\n" + "- threat sensors: NO RESPONSE\n" + "- security systems: OFFLINE\n" + "- power status: INTERNAL BAT LVL CRITICAL\n\n" + "I urgently request the sending of a repair tea-\n\n" + "*Grrz*... *Pchii*... *Fzzt*\n\n" + "---- End of transmision ---"; if (this.Faction == Faction.OfColony) { Find.LetterStack.ReceiveLetter(eventTitle, eventText, LetterType.BadUrgent); } else { ChangeOutpostThingsFaction(null); LaunchSecurityDropPods(4, OG_Util.OutpostScoutDef, false); Find.LetterStack.ReceiveLetter(eventTitle, eventText, LetterType.BadNonUrgent); } ChangeOutpostTurretsFaction(null, true); ChangeOutpostDoorsFaction(null, true); Thing coralie = ThingMaker.MakeThing(ThingDef.Named("AIPersonaCore")); GenSpawn.Spawn(coralie, this.Position); }
public override void ExposeData() { base.ExposeData(); this.outpostThingList = OG_Util.RefreshThingList(this.outpostThingList); Scribe_Collections.LookList <Thing>(ref this.outpostThingList, "outpostThingList", LookMode.MapReference); Scribe_Values.LookValue <IntVec3>(ref this.dropZoneCenter, "dropZoneCenter"); }
protected override Job TryGiveTerminalJob(Pawn pawn) { if (OG_Util.FindOutpostArea() == null) { return(null); } return(base.TryGiveTerminalJob(pawn)); }
public override Job JobOnThing(Pawn pawn, Thing t) { if ((OG_Util.FindOutpostArea() != null) && (OG_Util.FindOutpostArea().ActiveCells.Contains(t.Position))) { return(base.JobOnThing(pawn, t)); } return(null); }
public override bool HasJobOnThing(Pawn pawn, Thing t) { Filth filth = t as Filth; return(filth != null && (OG_Util.FindOutpostArea() != null) && OG_Util.FindOutpostArea().ActiveCells.Contains(t.Position) && pawn.CanReserveAndReach(t, PathEndMode.ClosestTouch, pawn.NormalMaxDanger(), 1) && filth.TicksSinceThickened >= this.MinTicksSinceThickened); }
private bool IsOutpostCaptured() { Building_OutpostCommandConsole commandConsole = OG_Util.FindOutpostCommandConsole(OG_Util.FactionOfMiningCo); if ((commandConsole == null) || (commandConsole.Faction != OG_Util.FactionOfMiningCo)) { return(true); } return(false); }
public JobGiver_WanderOutpost() { this.wanderRadius = 10f; this.ticksBetweenWandersRange = new IntRange(125, 200); this.locomotionUrgency = LocomotionUrgency.Walk; this.wanderDestValidator = delegate(Pawn pawn, IntVec3 loc) { Area outpostArea = OG_Util.FindOutpostArea(); return((outpostArea != null) && outpostArea.ActiveCells.Contains(loc)); }; }
public void TryToCaptureOutpost(string eventTitle, string eventText, LetterType letterType, Faction turretsNewFaction, bool deactivateTurrets, Faction doorsNewFaction, bool deactivateDoors, int dropPodsNumber, PawnKindDef securityForcesDef) { SetOutpostSecurityForcesHostileToColony(); this.outpostThingList = OG_Util.RefreshThingList(this.outpostThingList); ChangeOutpostThingsFaction(null); ChangeOutpostTurretsFaction(turretsNewFaction, deactivateTurrets); ChangeOutpostDoorsFaction(doorsNewFaction, deactivateDoors); LaunchSecurityDropPods(dropPodsNumber, securityForcesDef, true); OG_Util.DestroyOutpostArea(); Find.LetterStack.ReceiveLetter(eventTitle, eventText, letterType, new TargetInfo(this.Position)); }
protected override Job TryGiveJob(Pawn pawn) { Area outpostArea = OG_Util.FindOutpostArea(); if (outpostArea == null) { return(null); } if (outpostArea.ActiveCells.Count() == 0) { return(null); } return(base.TryGiveJob(pawn)); }
public JobGiver_WanderOutpost() { this.wanderRadius = 10f; this.ticksBetweenWandersRange = new IntRange(125, 200); this.locomotionUrgency = LocomotionUrgency.Amble; this.wanderDestValidator = delegate(Pawn pawn, IntVec3 loc) { if ((OG_Util.FindOutpostArea() != null) && (OG_Util.FindOutpostArea().ActiveCells.Contains(loc))) { return(true); } return(false); }; }
public override Job JobOnThing(Pawn pawn, Thing t) { Area outpostArea = OG_Util.FindOutpostArea(); if ((outpostArea != null) && (outpostArea.ActiveCells.Contains(t.Position))) { Building_Grave bestGrave = FindBestGrave(pawn, t as Corpse); if ((bestGrave != null) && outpostArea.ActiveCells.Contains(bestGrave.Position)) { return(base.JobOnThing(pawn, t)); } } return(null); }
public override void LordToilTick() { base.LordToilTick(); if (this.lord.ticksInToil > GenTicks.TickRareInterval) { Building_OrbitalRelay orbitalRelay = OG_Util.FindOrbitalRelay(OG_Util.FactionOfMiningCo); if (orbitalRelay != null) { IntVec3 hostilePosition = orbitalRelay.FindHostileInPerimeter(); if ((hostilePosition == IntVec3.Invalid) || (IntVec3Utility.ManhattanDistanceFlat(hostilePosition, this.FlagLoc) > 60)) // If an hostile is still in the perimeter, a new lord will be generated. { this.lord.ReceiveMemo("ThreatIsFinished"); } } } }
public override AcceptanceReport CanDesignateCell(IntVec3 c) { if (c.InBounds() && (c.Fogged() == false)) { Area outpostArea = OG_Util.FindOutpostArea(); if ((outpostArea != null) && outpostArea.ActiveCells.Contains(c)) { return("You cannot manage MiningCo. Outpost roof. This area does not belong to your colony."); } if (Find.RoofGrid.RoofAt(c) == OG_Util.IronedRoofDef) { return(true); } } return(base.CanDesignateCell(c)); }
public static void GenerateWaterPoolZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData) { IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation); IntVec3 firstPatchCenter = rotatedOrigin + new IntVec3(4, 0, 4).RotatedBy(rotation); IntVec3 secondPatchCenter = rotatedOrigin + new IntVec3(7, 0, 7).RotatedBy(rotation); IntVec3 thirdPatchCenter = rotatedOrigin + new IntVec3(6, 0, 6).RotatedBy(rotation); // Generate water patches. foreach (IntVec3 cell in GenRadial.RadialCellsAround(firstPatchCenter, 4.2f, true)) { Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Soil); } foreach (IntVec3 cell in GenRadial.RadialCellsAround(secondPatchCenter, 3.2f, true)) { Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Soil); } foreach (IntVec3 cell in GenRadial.RadialCellsAround(firstPatchCenter, 3.2f, true)) { Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("WaterShallow")); } foreach (IntVec3 cell in GenRadial.RadialCellsAround(secondPatchCenter, 2f, true)) { Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("WaterShallow")); } foreach (IntVec3 cell in GenRadial.RadialCellsAround(firstPatchCenter, 2f, true)) { Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("WaterDeep")); } foreach (IntVec3 cell in GenRadial.RadialCellsAround(secondPatchCenter, 1f, true)) { Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("WaterDeep")); } foreach (IntVec3 cell in GenRadial.RadialCellsAround(thirdPatchCenter, 1f, true)) { Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("WaterDeep")); } // Spawn fishing pier. if (OG_Util.IsModActive("FishIndustry")) { OG_Common.TrySpawnThingAt(ThingDef.Named("FishingPier"), null, rotatedOrigin + new IntVec3(4, 0, 1).RotatedBy(rotation), true, rotation, ref outpostData); } }
protected override Job TryGiveJob(Pawn pawn) { Building_SupplyShip supplyShip = OG_Util.FindSupplyShip(pawn.Faction); if (supplyShip == null) { return(null); } // Outpost has been captured or pawn has no weapon or an apparel in bad conditions. if (IsOutpostCaptured() || IsLackingWeapon(pawn) || IsWearingDamagedApparel(pawn) || IsLackingPant(pawn)) { if (pawn.CanReserveAndReach(supplyShip, PathEndMode.OnCell, Danger.Deadly)) { return(new Job(DefDatabase <JobDef> .GetNamed(OG_Util.JobDefName_BoardSupplyShip), supplyShip)); } } return(null); }
public override Job JobOnThing(Pawn pawn, Thing t) { if (!(t is Corpse)) { return(null); } Area outpostArea = OG_Util.FindOutpostArea(); if ((outpostArea != null) && (outpostArea.ActiveCells.Contains(t.Position))) { // Get potential storage cell and check it is in the outpost area. StoragePriority currentPriority = HaulAIUtility.StoragePriorityAtFor(t.Position, t); IntVec3 storeCell; if (StoreUtility.TryFindBestBetterStoreCellFor(t, pawn, currentPriority, pawn.Faction, out storeCell, true)) { if (outpostArea.ActiveCells.Contains(storeCell)) { return(base.JobOnThing(pawn, t)); } } } return(null); }
public static Building_OutpostCommandConsole GenerateBigRoomCommandRoom(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData) { Building_OutpostCommandConsole commandConsole = null; IntVec3 origin = Zone.GetZoneOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd); IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation); OG_Common.GenerateEmptyRoomAt(rotatedOrigin, Genstep_GenerateOutpost.zoneSideSize, Genstep_GenerateOutpost.zoneSideSize, rotation, TerrainDefOf.Concrete, TerrainDef.Named("CarpetDark"), ref outpostData); // Spawn doors. OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 10).RotatedBy(rotation), ref outpostData); OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(10, 0, 5).RotatedBy(rotation), ref outpostData); OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 0).RotatedBy(rotation), ref outpostData); OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(0, 0, 5).RotatedBy(rotation), ref outpostData); // Spawn weapon racks. Building_Storage rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; OG_Common.TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(1, 0, 3).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; OG_Common.TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; // Spawn lamps. OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), Color.white, ref outpostData); OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(9, 0, 9).RotatedBy(rotation), Color.white, ref outpostData); // Spawn table and stools. OG_Common.TrySpawnThingAt(ThingDef.Named("Stool"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(7, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData); OG_Common.TrySpawnThingAt(ThingDef.Named("Stool"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(8, 0, 3).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData); OG_Common.TrySpawnThingAt(ThingDef.Named("TableShort"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(8, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData); // Spawn outpost command console, battery and spare parts cabinet. OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(1, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData); OG_Common.TrySpawnThingAt(OG_Util.SparePartsCabinetDef, null, rotatedOrigin + new IntVec3(1, 0, 7).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData); OG_Common.SpawnResourceAt(ThingDefOf.Component, 10, rotatedOrigin + new IntVec3(1, 0, 7).RotatedBy(rotation), true); OG_Common.SpawnResourceAt(ThingDefOf.Component, 10, rotatedOrigin + new IntVec3(1, 0, 6).RotatedBy(rotation), true); commandConsole = OG_Common.TrySpawnThingAt(OG_Util.OutpostCommandConsoleDef, null, rotatedOrigin + new IntVec3(3, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData) as Building_OutpostCommandConsole; // Spawn workbenches. OG_Common.TrySpawnThingAt(ThingDef.Named("TableMachining"), null, rotatedOrigin + new IntVec3(7, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData); OG_Common.TrySpawnThingAt(ThingDef.Named("ElectricSmithy"), null, rotatedOrigin + new IntVec3(9, 0, 7).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData); // Spawn heaters and coolers. OG_Common.TrySpawnHeaterAt(rotatedOrigin + new IntVec3(1, 0, 4).RotatedBy(rotation), ref outpostData); OG_Common.TrySpawnHeaterAt(rotatedOrigin + new IntVec3(4, 0, 1).RotatedBy(rotation), ref outpostData); OG_Common.SpawnCoolerAt(rotatedOrigin + new IntVec3(0, 0, 1).RotatedBy(rotation), new Rot4(Rot4.West.AsInt + rotation.AsInt), ref outpostData); OG_Common.SpawnCoolerAt(rotatedOrigin + new IntVec3(1, 0, 0).RotatedBy(rotation), new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData); // Spawn floor and tactical computer. for (int xOffset = 0; xOffset <= 10; xOffset++) { Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, 5).RotatedBy(rotation), TerrainDef.Named("PavedTile")); } for (int zOffset = 0; zOffset <= 10; zOffset++) { Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile")); } CellRect rect = new CellRect(origin.x + 3, origin.z + 3, 5, 5); foreach (IntVec3 cell in rect) { Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("PavedTile")); } foreach (IntVec3 cell in rect.ContractedBy(1)) { Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("CarpetRed")); } if (OG_Util.IsModActive("Misc. Incidents")) { OG_Common.TrySpawnThingAt(ThingDef.Named("TacticalComputer"), null, rotatedOrigin + new IntVec3(5, 0, 5).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData); } return(commandConsole); }
private void UpdateLord() { IntVec3 rallyPoint = IntVec3.Invalid; Log.Message("UpdateLord1"); // Check there is no already existing defense lord. if ((Find.LordManager.lords != null) && (Find.LordManager.lords.Count > 0)) { foreach (Lord lord in Find.LordManager.lords) { if ((lord.faction != null) && (lord.faction == OG_Util.FactionOfMiningCo)) { return; } } } Log.Message("UpdateLord2"); // Look for hostile in outpost perimeter. IntVec3 hostilePosition = FindHostileInPerimeter(); if (hostilePosition.IsValid) { Log.Message("UpdateLord2"); Area outpostArea = OG_Util.FindOutpostArea(); if ((outpostArea != null) && (outpostArea.ActiveCells.Contains(hostilePosition))) { Log.Message("UpdateLord4"); // Ennemy is inside outpost area. rallyPoint = hostilePosition; } else { Log.Message("UpdateLord5"); const int sectionsNumber = 100; Vector3 sectionVector = (this.outpostCenter - hostilePosition).ToVector3(); sectionVector = sectionVector / sectionsNumber; // Default value if OutpostArea does not exist (should not occur, just a safety...). rallyPoint = (hostilePosition.ToVector3() + sectionVector * 0.2f * (float)sectionsNumber).ToIntVec3(); for (int i = 1; i <= sectionsNumber; i++) { Vector3 potentialRallyPoint = hostilePosition.ToVector3() + sectionVector * i; if ((outpostArea != null) && (outpostArea.ActiveCells.Contains(potentialRallyPoint.ToIntVec3()))) { // Ensure rallyPoint is completely inside the outpost area. rallyPoint = (potentialRallyPoint + sectionVector * 0.1f * (float)sectionsNumber).ToIntVec3(); break; } } } } else { Log.Message("UpdateLord6"); // Look for damaged turret to defend. Rot4 turretRotation = Rot4.Invalid; IntVec3 turretPosition = IntVec3.Invalid; FindDamagedTurret(out turretPosition, out turretRotation); if (turretPosition.IsValid) { if (OG_Util.IsModActive("MiningCo. ForceField")) { // Look for nearest force field to cover behind. foreach (Thing thing in Find.ListerThings.ThingsOfDef(OG_Util.ForceFieldGeneratorDef)) { if (thing.Position.InHorDistOf(turretPosition, 23f)) { rallyPoint = thing.Position + new IntVec3(0, 0, -2).RotatedBy(thing.Rotation); break; } } } else { // Just go near the attacked turret. rallyPoint = turretPosition + new IntVec3(0, 0, -5).RotatedBy(turretRotation); } } } Log.Message("UpdateLord7"); if (rallyPoint.IsValid) { Log.Message("rallyPoint = " + rallyPoint.ToString()); // Generate defense lord. LordJob_Joinable_DefendOutpost lordJob = new LordJob_Joinable_DefendOutpost(rallyPoint); LordMaker.MakeNewLord(OG_Util.FactionOfMiningCo, lordJob); SoundDef soundDef = SoundDefOf.MessageSeriousAlert; // TODO: add a siren like in alert speaker! soundDef.PlayOneShot(rallyPoint); // Stop all pawns job. foreach (Pawn pawn in Find.MapPawns.AllPawns) { if ((pawn.Faction != null) && (pawn.Faction == OG_Util.FactionOfMiningCo) && (pawn.kindDef != OG_Util.OutpostTechnicianDef)) { pawn.ClearMind(); } } } }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Reserve.Reserve(outpostCommandConsoleTarget)); yield return(Toils_Goto.GotoCell(outpostCommandConsoleTarget, PathEndMode.InteractionCell).FailOnDestroyedOrNull(outpostCommandConsoleTarget)); yield return(Toils_General.Wait(800).FailOnDestroyedOrNull(outpostCommandConsoleTarget).WithProgressBarToilDelay(outpostCommandConsoleTarget)); Toil outpostCaptureResultToil = new Toil() { initAction = () => { const float chanceToSucceedPerSkillLevel = 6f; string eventTitle = "Outpost capture"; string eventText = ""; LetterType letterType = LetterType.Good; Faction turretsNewFaction = null; bool deactivateTurrets = false; Faction doorsNewFaction = null; bool deactivateDoors = false; PawnKindDef securityForcesDef = null; int dropPodsNumber = 0; Building_OutpostCommandConsole outpostCommandConsole = this.TargetThingA as Building_OutpostCommandConsole; eventText = " MiningCo. security systems report\n\n" + "Coralie here.\n" + "I have treated your security parameters change request. Here is the result:\n\n"; HackingResult hackingresult = ComputeHackResult(this.pawn, SkillDefOf.Research, SkillDefOf.Crafting, chanceToSucceedPerSkillLevel); if (hackingresult == HackingResult.MajorFail) { eventText += " - defense systems: ACCESS DENIED => set mode to aggressive.\n" + " - door access control: ACCESS DENIED => security locks engaged.\n" + " - request checksum: FORMAT ERROR => Security systems hacking detected...\n" + " => Shock support team requested!\n\n" + "--- End of transmission ---\n\n\n\n"; eventText += this.pawn.Name.ToStringShort + " failed to hack the outpost command console and triggered the internal securities.\n"; letterType = LetterType.BadUrgent; turretsNewFaction = OG_Util.FactionOfMiningCo; deactivateTurrets = false; doorsNewFaction = OG_Util.FactionOfMiningCo; deactivateDoors = false; if (OG_Util.FindOrbitalRelay(OG_Util.FactionOfMiningCo) == null) { eventText += "Be prepared to welcome the incoming MiningCo. shock security forces!"; securityForcesDef = OG_Util.OutpostGuardDef; dropPodsNumber = 8; } } else if (hackingresult == HackingResult.MinorFail) { eventText += " - defense systems: ACCESS DENIED => set mode to aggressive.\n" + " - door access control: ERROR => emergency open activated.\n" + " - request checksum: WRONG CRC => Security systems hacking detected...\n" + " => Patrol support team requested!\n\n" + "--- End of transmission ---\n\n\n\n"; eventText += this.pawn.Name.ToStringShort + " has some knowledge in the field of security system but did not managed to hack properly the outpost command console.\n\n"; letterType = LetterType.BadUrgent; turretsNewFaction = OG_Util.FactionOfMiningCo; deactivateTurrets = false; doorsNewFaction = null; deactivateDoors = true; if (OG_Util.FindOrbitalRelay(OG_Util.FactionOfMiningCo) == null) { eventText += "Be prepared to welcome the incoming MiningCo. patrol security forces."; securityForcesDef = OG_Util.OutpostScoutDef; dropPodsNumber = 4; } } else if (hackingresult == HackingResult.MinorSuccess) { eventText += " - defense systems: ERROR => systems deactivated.\n" + " - door access control: ACCESS GRANTED\n" + " - request checksum: CRC OK\n" + " => Unexpected error, technician team requested.\n\n" + "--- End of transmission ---\n\n\n\n"; eventText += "Your colonist managed to bypass most of the command console securities. However, " + this.pawn.Name.ToStringShort + " was not able to avoid the sending of a maintenance status report to the nearby MiningCo. comms satellite!\n\n"; letterType = LetterType.BadNonUrgent; turretsNewFaction = null; deactivateTurrets = true; doorsNewFaction = Faction.OfPlayer; deactivateDoors = true; if (OG_Util.FindOrbitalRelay(OG_Util.FactionOfMiningCo) == null) { eventText += "You will soon have to welcome a technician team."; securityForcesDef = OG_Util.OutpostTechnicianDef; dropPodsNumber = 2; } } else if (hackingresult == HackingResult.MajorSuccess) { eventText += " - defense systems: ACCESS GRANTED\n" + " - door access control: ACCESS GRANTED\n" + " - request checksum: CRC OK\n" + " => All parameters are valid.\n\n" + "--- End of transmission ---\n\n\n\n"; eventText += "Hacking the outpost command console was a child's play for " + this.pawn.Name.ToStringShort + ".\n The outpost is now fully under your control!"; letterType = LetterType.Good; turretsNewFaction = Faction.OfPlayer; deactivateTurrets = false; doorsNewFaction = Faction.OfPlayer; deactivateDoors = true; if (OG_Util.FindOrbitalRelay(OG_Util.FactionOfMiningCo) == null) { securityForcesDef = null; dropPodsNumber = 0; } } outpostCommandConsole.TryToCaptureOutpost(eventTitle, eventText, letterType, turretsNewFaction, deactivateTurrets, doorsNewFaction, deactivateDoors, dropPodsNumber, securityForcesDef); outpostCommandConsole.SetFaction(Faction.OfPlayer); }, defaultCompleteMode = ToilCompleteMode.Instant }; yield return(outpostCaptureResultToil); yield return(Toils_Reserve.Release(outpostCommandConsoleTarget)); }
public static void GenerateEntranchedZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData) { IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation); IntVec3 cell = rotatedOrigin; // Generate south west battery shelter. OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(0, 0, 0).RotatedBy(rotation), ref outpostData); OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(3, 0, 0).RotatedBy(rotation), ref outpostData); OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(0, 0, 3).RotatedBy(rotation), ref outpostData); OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(3, 0, 3).RotatedBy(rotation), ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData); for (int xOffset = 0; xOffset < 4; xOffset++) { for (int zOffset = 0; zOffset < 4; zOffset++) { cell = rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation); Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete); Find.RoofGrid.SetRoof(cell, OG_Util.IronedRoofDef); } } // Generate south east battery shelter. OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(7, 0, 0).RotatedBy(rotation), ref outpostData); OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(10, 0, 0).RotatedBy(rotation), ref outpostData); OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(7, 0, 3).RotatedBy(rotation), ref outpostData); OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(10, 0, 3).RotatedBy(rotation), ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(8, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(9, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData); for (int xOffset = 7; xOffset < 11; xOffset++) { for (int zOffset = 0; zOffset < 4; zOffset++) { cell = rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation); Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete); Find.RoofGrid.SetRoof(cell, OG_Util.IronedRoofDef); } } // Generate central paved alley. for (int xOffset = 4; xOffset <= 6; xOffset++) { for (int zOffset = 0; zOffset < 7; zOffset++) { Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete); } } for (int zOffset = 0; zOffset < 7; zOffset++) { Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile")); } // Generate north west force field. IntVec3 northWestOrigin = rotatedOrigin + new IntVec3(0, 0, 6).RotatedBy(rotation); for (int xOffset = 0; xOffset < 5; xOffset++) { for (int zOffset = 0; zOffset < 2; zOffset++) { Find.TerrainGrid.SetTerrain(northWestOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete); } } for (int xOffset = 1; xOffset <= 3; xOffset++) { Find.TerrainGrid.SetTerrain(northWestOrigin + new IntVec3(xOffset, 0, 2).RotatedBy(rotation), TerrainDefOf.Concrete); } OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(0, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(1, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(2, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(3, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(3, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(4, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); for (int zOffset = -3; zOffset <= 3; zOffset++) { if ((zOffset == 1) && OG_Util.IsModActive("MiningCo. ForceField")) { // Do not spawn power conduit under force field as it generates a warning message. continue; } OG_Common.SpawnFireproofPowerConduitAt(northWestOrigin + new IntVec3(2, 0, zOffset).RotatedBy(rotation), ref outpostData); } if (OG_Util.IsModActive("MiningCo. ForceField")) { OG_Common.TrySpawnThingAt(OG_Util.ForceFieldGeneratorDef, null, northWestOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData); } // Generate central sandbag. cell = rotatedOrigin + new IntVec3(5, 0, 7).RotatedBy(rotation); Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, cell, false, Rot4.Invalid, ref outpostData); // Generate north east force field. IntVec3 northEastOrigin = rotatedOrigin + new IntVec3(6, 0, 6).RotatedBy(rotation); for (int xOffset = 0; xOffset < 5; xOffset++) { for (int zOffset = 0; zOffset < 2; zOffset++) { Find.TerrainGrid.SetTerrain(northEastOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete); } } for (int xOffset = 1; xOffset <= 3; xOffset++) { Find.TerrainGrid.SetTerrain(northEastOrigin + new IntVec3(xOffset, 0, 2).RotatedBy(rotation), TerrainDefOf.Concrete); } OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(0, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(1, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(2, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(3, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(3, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(4, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData); for (int zOffset = -3; zOffset <= 3; zOffset++) { if ((zOffset == 1) && OG_Util.IsModActive("MiningCo. ForceField")) { // Do not spawn power conduit under force field as it generates a warning message. continue; } OG_Common.SpawnFireproofPowerConduitAt(northEastOrigin + new IntVec3(2, 0, zOffset).RotatedBy(rotation), ref outpostData); } if (OG_Util.IsModActive("MiningCo. ForceField")) { OG_Common.TrySpawnThingAt(OG_Util.ForceFieldGeneratorDef, null, northEastOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData); } }