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); } } }
private bool IsOutpostCaptured() { Building_OutpostCommandConsole commandConsole = OG_Util.FindOutpostCommandConsole(OG_Util.FactionOfMiningCo); if ((commandConsole == null) || (commandConsole.Faction != OG_Util.FactionOfMiningCo)) { return(true); } return(false); }
/// <summary> /// Find the outpost command console building if it exists. /// </summary> public static Building_OutpostCommandConsole FindOutpostCommandConsole(Faction faction) { List <Thing> commandConsoleList = Find.ListerThings.ThingsOfDef(OG_Util.OutpostCommandConsoleDef); foreach (Thing potentialCommandConsole in commandConsoleList) { Building_OutpostCommandConsole commandConsole = potentialCommandConsole as Building_OutpostCommandConsole; if ((commandConsole != null) && (commandConsole.Faction != null) && (commandConsole.Faction == faction)) { return(commandConsole); } } return(null); }
public static Building_OutpostCommandConsole GenerateCommandRoomZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 cardinal, Rot4 linkedZoneRelativeRotation, ref OG_OutpostData outpostData) { Building_OutpostCommandConsole CommandConsole = null; IntVec3 origin = Zone.GetZoneOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd); IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, cardinal); OG_Common.GenerateEmptyRoomAt(rotatedOrigin + new IntVec3(smallRoomWallOffset, 0, smallRoomWallOffset).RotatedBy(cardinal), Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, cardinal, TerrainDefOf.Concrete, null, ref outpostData); // Spawn command console. CommandConsole = OG_Common.TrySpawnThingAt(OG_Util.OutpostCommandConsoleDef, null, rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset + 2).RotatedBy(cardinal), true, new Rot4(Rot4.South.AsInt + cardinal.AsInt), ref outpostData) as Building_OutpostCommandConsole; // Generate vertical alley. for (int zOffset = smallRoomWallOffset; zOffset < Genstep_GenerateOutpost.zoneSideCenterOffset; zOffset++) { Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, zOffset).RotatedBy(cardinal), TerrainDef.Named("PavedTile")); } // Generate horizontal alley, door and lamp. if (linkedZoneRelativeRotation == Rot4.West) { for (int xOffset = smallRoomWallOffset - 2; xOffset <= Genstep_GenerateOutpost.zoneSideCenterOffset; xOffset++) { Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(cardinal), TerrainDef.Named("PavedTile")); } OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(smallRoomWallOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(cardinal), ref outpostData); } else if (linkedZoneRelativeRotation == Rot4.East) { for (int xOffset = Genstep_GenerateOutpost.zoneSideCenterOffset; xOffset <= Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset + 1; xOffset++) { Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(cardinal), TerrainDef.Named("PavedTile")); } OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset - 1, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(cardinal), ref outpostData); } OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 1).RotatedBy(cardinal), Color.red, ref outpostData); OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 1).RotatedBy(cardinal), Color.red, ref outpostData); return(CommandConsole); }
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); }
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)); }
// ######## Zone generation functions ######## // static void GenerateOutpostZones(IntVec3 areaSouthWestOrigin) { for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++) { for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++) { ZoneProperties zone = zoneMap[zoneOrd, zoneAbs]; switch (zone.zoneType) { // Standard big rooms. case ZoneType.BigRoomLivingRoom: OG_ZoneBigRoom.GenerateBigRoomLivingRoom(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData); break; case ZoneType.BigRoomWarehouse: OG_ZoneBigRoom.GenerateBigRoomWarehouse(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData); break; case ZoneType.BigRoomPrison: OG_ZoneBigRoom.GenerateBigRoomPrison(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData); break; // Standard small rooms. case ZoneType.SmallRoomBarracks: OG_ZoneSmallRoom.GenerateSmallRoomBarracks(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData); break; case ZoneType.SmallRoomMedibay: OG_ZoneSmallRoom.GenerateSmallRoomMedibay(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData); break; case ZoneType.SmallRoomWeaponRoom: OG_ZoneSmallRoom.GenerateSmallRoomWeaponRoom(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData); break; // Special small rooms. case ZoneType.SmallRoomBatteryRoom: OG_ZoneSmallRoomSpecial.GenerateBatteryRoomZone(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, zone.linkedZoneRelativeRotation, ref outpostData); break; case ZoneType.SmallRoomCommandRoom: commandConsole = OG_ZoneSmallRoomSpecial.GenerateCommandRoomZone(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, zone.linkedZoneRelativeRotation, ref outpostData); break; // Special zones. case ZoneType.SolarPanelZone: OG_ZoneSpecial.GenerateSolarPanelZone(areaSouthWestOrigin, zoneAbs, zoneOrd, ref outpostData); break; case ZoneType.DropZone: OG_ZoneSpecial.GenerateDropZone(areaSouthWestOrigin, zoneAbs, zoneOrd, ref outpostData); break; // Other zones. case ZoneType.Empty: // Nothing to do; break; case ZoneType.SecondaryEntrance: OG_ZoneOther.GenerateSecondaryEntranceZone(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData); break; } } } }