public static void GenerateSamSiteZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, ref OG_OutpostData outpostData) { IntVec3 origin = Zone.GetZoneOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd); // Spawn SAM site surrounded by sandbags. IntVec3 samSitePosition = origin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset); OG_Common.TrySpawnThingAt(OG_Util.SamSiteDef, null, samSitePosition, false, Rot4.Invalid, ref outpostData); CellRect sandbagRect = new CellRect(origin.x + 3, origin.z + 3, 5, 5); foreach (IntVec3 cell in sandbagRect.Cells) { if ((cell.x == sandbagRect.minX) || (cell.x == sandbagRect.maxX) || (cell.z == sandbagRect.minZ) || (cell.z == sandbagRect.maxZ)) { OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, cell, false, Rot4.Invalid, ref outpostData); } } for (int rotationAsInt = Rot4.North.AsInt; rotationAsInt <= Rot4.West.AsInt; rotationAsInt++) { IntVec3 sandbagPosition = samSitePosition + new IntVec3(0, 0, 3).RotatedBy(new Rot4(rotationAsInt)); OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, sandbagPosition, false, Rot4.Invalid, ref outpostData); foreach (IntVec3 cell in GenAdj.CellsAdjacent8Way(sandbagPosition)) { Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete); } } // Generate concrete ground. CellRect concreteRect = new CellRect(origin.x + 2, origin.z + 2, 7, 7); foreach (IntVec3 cell in concreteRect.Cells) { Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete); } }
// Token: 0x060029EE RID: 10734 RVA: 0x0013DA2C File Offset: 0x0013BE2C private void TrySpawnPawns() { if (!this.parent.Spawned) { return; } if (!Props.allowedKinddefs.NullOrEmpty()) { foreach (PawnKindDef kd in Props.allowedKinddefs) { if (!(from cell in GenAdj.CellsAdjacent8Way(this.parent) where this.CanSpawnPawnAt(cell) select cell).TryRandomElement(out IntVec3 center)) { break; } // Log.Message(string.Format("kindDef: {0}", kind)); PawnGenerationRequest request = new PawnGenerationRequest(kd, Faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, true, false, 1f, false, true, true, false, false, false, false); Pawn pawn = PawnGenerator.GeneratePawn(request); if (!GenPlace.TryPlaceThing(pawn, center, this.parent.Map, ThingPlaceMode.Near, null, null)) { Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); break; } this.lord.AddPawn(pawn); } } this.Spawned = true; SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(this.parent.Map); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Thing thingToIgnore = null) { IEnumerable <IntVec3> cells = GenAdj.CellsAdjacent8Way(loc, rot, checkingDef.Size).Union <IntVec3>(GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size)); foreach (IntVec3 cell in cells) { List <Thing> things = Map.thingGrid.ThingsListAt(cell); foreach (Thing thing in things) { if (thing.TryGetComp <CompRTQuantumStockpile>() != null || thing.TryGetComp <CompRTQuantumChunkSilo>() != null) { return("PlaceWorker_RTNoQSOverlap".Translate()); } else if (thing.def.entityDefToBuild != null) { ThingDef thingDef = thing.def.entityDefToBuild as ThingDef; if (null != thingDef && null != thingDef.comps && null != thingDef.comps.Find(x => typeof(CompRTQuantumStockpile) == x.compClass)) { return("PlaceWorker_RTNoQSOverlap".Translate()); } } } } return(true); }
public static bool TryFindSpawnCell(Thing parent, ThingDef thingToSpawn, int spawnCount, out IntVec3 result) { foreach (IntVec3 intVec in GenAdj.CellsAdjacent8Way(parent).InRandomOrder(null)) { if (intVec.Walkable(parent.Map)) { Building edifice = intVec.GetEdifice(parent.Map); if (edifice == null || !thingToSpawn.IsEdifice()) { Building_Door building_Door = edifice as Building_Door; if ((building_Door == null || building_Door.FreePassage) && (parent.def.passability == Traversability.Impassable || GenSight.LineOfSight(parent.Position, intVec, parent.Map, false, null, 0, 0))) { bool flag = false; List <Thing> thingList = intVec.GetThingList(parent.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category == ThingCategory.Item && (thing.def != thingToSpawn || thing.stackCount > thingToSpawn.stackLimit - spawnCount)) { flag = true; break; } } if (!flag) { result = intVec; return(true); } } } } } result = IntVec3.Invalid; return(false); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { IEnumerable <IntVec3> cells = GenAdj.CellsAdjacent8Way(loc, rot, checkingDef.Size).Union <IntVec3>(GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size)); foreach (IntVec3 cell in cells) { List <Thing> things = Find.ThingGrid.ThingsListAt(cell); foreach (Thing thing in things) { if (thing.TryGetComp <CompRTQuantumStockpile>() != null || thing.TryGetComp <CompRTQuantumChunkSilo>() != null) { return("PlaceWorker_RTNoQSOverlap".Translate()); } else if (thing.def.entityDefToBuild != null) { ThingDef thingDef = thing.def.entityDefToBuild as ThingDef; Thing simThing = ThingMaker.MakeThing(thingDef); if (simThing != null && (simThing.TryGetComp <CompRTQuantumStockpile>() != null || simThing.TryGetComp <CompRTQuantumStockpile>() != null)) { return("PlaceWorker_RTNoQSOverlap".Translate()); } } } } return(true); }
public void GetRocks(Map map, ref List <Thing> rocks, ref List <Thing> processedRocks) { List <Thing> rocksToProcess = new List <Thing>(); foreach (var rock in rocks) { if (!processedRocks.Contains(rock)) { foreach (var pos in GenAdj.CellsAdjacent8Way(rock)) { var things = map.thingGrid.ThingsListAt(pos); if (things != null && things.Count > 0) { foreach (var thing in things) { if (thing is Mineable && !processedRocks.Contains(thing)) { rocksToProcess.Add(thing); } } } } processedRocks.Add(rock); } } if (rocksToProcess.Count > 0) { GetRocks(map, ref rocksToProcess, ref processedRocks); } }
public static IEnumerable <CosmicHorrorPawn> SpawnHorrorsOfCountAt(PawnKindDef kindDef, IntVec3 at, Map map, int count, Faction fac = null, bool berserk = false, bool target = false) { List <CosmicHorrorPawn> pawns = new List <CosmicHorrorPawn>(); for (int i = 1; i <= count; i++) { if ((from cell in GenAdj.CellsAdjacent8Way(new TargetInfo(at, map)) where at.Walkable(map) && !at.Fogged(map) && at.InBounds(map) select cell).TryRandomElement(out at)) { CosmicHorrorPawn pawn = null; if (fac != Faction.OfPlayer) { //PawnGenerationRequest request = new PawnGenerationRequest(kindDef, fac, PawnGenerationContext.NonPlayer, map.Tile); //Pawn item = PawnGenerator.GeneratePawn(request); //list.Add(item); PawnGenerationRequest request = new PawnGenerationRequest(kindDef, fac, PawnGenerationContext.NonPlayer, map.Tile); pawn = (CosmicHorrorPawn)GenSpawn.Spawn(PawnGenerator.GeneratePawn(request), at, map); } else { pawn = (CosmicHorrorPawn)GenSpawn.Spawn(PawnGenerator.GeneratePawn(kindDef, fac), at, map); } pawns.Add(pawn); if (berserk) { pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk); } } } return(pawns.AsEnumerable <CosmicHorrorPawn>()); }
/// <summary> /// Place Worker for Air Intakes. /// /// Checks: /// - Current Cell shouldn't have an Air Flow Pipe (Since they already have a Pipe) /// - Surrounding Cells from Center musn't be Impassable /// </summary> /// <param name="def">The Def Being Built</param> /// <param name="center">Target Location</param> /// <param name="rot">Rotation of the Object to be Placed</param> /// <param name="thingToIgnore">Unused field</param> /// <returns>Boolean/Acceptance Report if we can place the object of not.</returns> public override AcceptanceReport AllowsPlacing(BuildableDef def, IntVec3 center, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { //var thingList = center.GetThingList(map); //if (thingList.OfType<Building_AirPipe>().Any()) if (center.GetThingList(map).OfType <Building_AirPipe>().Any()) { return(AcceptanceReport.WasRejected); } if (def == null) { return(AcceptanceReport.WasRejected); } //var size = def.Size; //var list = GenAdj.CellsAdjacent8Way(center, rot, size); //var list = GenAdj.CellsAdjacent8Way(center, rot, def.Size); //if (list.Any(intVec => intVec.Impassable(map))) if (GenAdj.CellsAdjacent8Way(center, rot, def.Size).Any(intVec => intVec.Impassable(map))) { return("CentralizedClimateControl.Producer.IntakeFanPlaceError".Translate()); } return(true); }
public static void SpawnPawnsOfCountAt(PawnKindDef kindDef, IntVec3 at, Map map, int count, out Pawn returnable, Faction fac = null, bool berserk = false, bool target = false) { Pawn result = null; for (int i = 1; i <= count; i++) { if ((from cell in GenAdj.CellsAdjacent8Way(new TargetInfo(at, map)) where at.Walkable(map) select cell).TryRandomElement(out at)) { Pawn pawn = PawnGenerator.GeneratePawn(kindDef, fac); if (result == null) { result = pawn; } if (GenPlace.TryPlaceThing(pawn, at, map, ThingPlaceMode.Near, null)) { //if (target) Map.GetComponent<MapComponent_SacrificeTracker>().lastLocation = at; //continue; } //Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); if (berserk) { pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk); } } } returnable = result; }
// Token: 0x060029EE RID: 10734 RVA: 0x0013DA2C File Offset: 0x0013BE2C private void TrySpawnPawns() { if (this.pointsLeft <= 0f) { return; } if (!this.parent.Spawned) { return; } if (this.lord == null) { IntVec3 invalid; if (!CellFinder.TryFindRandomCellNear(this.parent.Position, this.parent.Map, 5, (IntVec3 c) => c.Standable(this.parent.Map) && this.parent.Map.reachability.CanReach(c, this.parent, PathEndMode.Touch, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)), out invalid, -1)) { // Log.Error("Found no place for Pawns to defend " + this, false); invalid = IntVec3.Invalid; } LordJob_PawnsDefendShip lordJob = new LordJob_PawnsDefendShip(this.parent, this.parent.Faction, 21f, invalid); this.lord = LordMaker.MakeNewLord(OfFaction, lordJob, this.parent.Map, null); } try { while (this.pointsLeft > 0f) { PawnKindDef kind; if (!(from def in DefDatabase <PawnKindDef> .AllDefs where ((def.defaultFactionType == faction.def && def.defaultFactionType != null) || (def.defaultFactionType == null && faction.def.pawnGroupMakers.Any(pgm => pgm.options.Any(opt => opt.kind == def) && pgm.kindDef != PawnGroupKindDefOf.Trader && pgm.kindDef != PawnGroupKindDefOf.Peaceful))) && def.isFighter && def.combatPower <= this.pointsLeft //where ((def.defaultFactionType == faction.def && def.defaultFactionType != null) || (!faction.def.pawnGroupMakers.All(pgm => pgm.options.Any(opt => opt.kind == def)) && def.defaultFactionType == null)) && def.isFighter && def.combatPower <= this.pointsLeft select def).TryRandomElement(out kind)) { // Log.Message(string.Format("kindDef: {0}", kind)); break; } IntVec3 center; if (!(from cell in GenAdj.CellsAdjacent8Way(this.parent) where this.CanSpawnPawnAt(cell) select cell).TryRandomElement(out center)) { break; } // Log.Message(string.Format("kindDef: {0}", kind)); PawnGenerationRequest request = new PawnGenerationRequest(kind, faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, true, false, 1f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null); Pawn pawn = PawnGenerator.GeneratePawn(request); if (!GenPlace.TryPlaceThing(pawn, center, this.parent.Map, ThingPlaceMode.Near, null, null)) { Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); break; } this.lord.AddPawn(pawn); this.pointsLeft -= pawn.kindDef.combatPower; } } finally { this.pointsLeft = 0f; } SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(this.parent.Map); }
public override IEnumerable <RecipeDef> GetAllRecipes() { return(from IntVec3 c in GenAdj.CellsAdjacent8Way(this) from Thing t in c.GetThingList(Map) let h = t as Building_RecipeHolder where h != null from RecipeDef recipe in h.recipes select recipe); }
public static bool TryFindSpawnCell(this HediffComp_RandySpawnUponDeath comp, Thing refThing, int randomQuantity, Map map, out IntVec3 result) { ThingDef thingDef = comp.ChosenItem.thingToSpawn; if (refThing.Negligible()) { result = IntVec3.Invalid; if (comp.MyDebug) { Log.Warning("TryFindSpawnCell Null - pawn null"); } return(false); } foreach (IntVec3 current in GenAdj.CellsAdjacent8Way(refThing).InRandomOrder(null)) { if (current.Walkable(map)) { Building edifice = current.GetEdifice(map); if (edifice == null || !thingDef.IsEdifice()) { if (!(edifice is Building_Door building_Door) || building_Door.FreePassage) { if (GenSight.LineOfSight(refThing.Position, current, map, false, null, 0, 0)) { bool flag = false; List <Thing> thingList = current.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category == ThingCategory.Item) { if (thing.def != thingDef || thing.stackCount > thingDef.stackLimit - randomQuantity) { flag = true; break; } } } if (!flag) { result = current; return(true); } } } } } } if (comp.MyDebug) { Log.Warning("TryFindSpawnCell Null - no spawn cell found"); } result = IntVec3.Invalid; return(false); }
public override void DrawExtraSelectionOverlays() { base.DrawExtraSelectionOverlays(); GenDraw.DrawFieldEdges(new List <IntVec3>(GenAdj.CellsAdjacent8Way(this))); GenDraw.DrawFieldEdges(new List <IntVec3>() { FuelableCell }, Color.yellow); }
private void TrySpawnMechanoids() { if (this.pointsLeft <= 0f) { return; } if (!this.parent.Spawned) { return; } if (this.lord == null) { IntVec3 invalid; if (!CellFinder.TryFindRandomCellNear(this.parent.Position, this.parent.Map, 5, (IntVec3 c) => c.Standable(this.parent.Map) && this.parent.Map.reachability.CanReach(c, this.parent, PathEndMode.Touch, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)), out invalid, -1)) { Log.Error("Found no place for mechanoids to defend " + this, false); invalid = IntVec3.Invalid; } LordJob_MechanoidsDefendShip lordJob = new LordJob_MechanoidsDefendShip(this.parent, this.parent.Faction, 21f, invalid); this.lord = LordMaker.MakeNewLord(Faction.OfMechanoids, lordJob, this.parent.Map, null); } try { while (this.pointsLeft > 0f) { PawnKindDef kind; if (!(from def in DefDatabase <PawnKindDef> .AllDefs where def.RaceProps.IsMechanoid && def.isFighter && def.combatPower <= this.pointsLeft select def).TryRandomElement(out kind)) { break; } IntVec3 center; if (!(from cell in GenAdj.CellsAdjacent8Way(this.parent) where this.CanSpawnMechanoidAt(cell) select cell).TryRandomElement(out center)) { break; } PawnGenerationRequest request = new PawnGenerationRequest(kind, Faction.OfMechanoids, PawnGenerationContext.NonPlayer, -1, true, false, false, false, true, false, 1f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null); Pawn pawn = PawnGenerator.GeneratePawn(request); if (!GenPlace.TryPlaceThing(pawn, center, this.parent.Map, ThingPlaceMode.Near, null, null)) { Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); break; } this.lord.AddPawn(pawn); this.pointsLeft -= pawn.kindDef.combatPower; } } finally { this.pointsLeft = 0f; } SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(this.parent.Map); }
// Token: 0x060029EE RID: 10734 RVA: 0x0013DA2C File Offset: 0x0013BE2C private void TrySpawnPawns() { if (this.lastSpawnTick > 0) { return; } if (this.pointsLeft <= 0f) { return; } if (!this.parent.Spawned) { return; } if (this.lord == null) { LordJob_AssaultColony lordJob = new LordJob_AssaultColony(this.parent.Faction, false, false, false, false, false); this.lord = LordMaker.MakeNewLord(OfFaction, lordJob, this.parent.Map, null); } try { while (this.pointsLeft > 0f) { if (!(from def in spawnablePawnKinds select def).TryRandomElementByWeight(x => x.selectionWeight, out PawnGenOption kind)) { // Log.Message(string.Format("kindDef: {0}", kind)); break; } if (!(from cell in GenAdj.CellsAdjacent8Way(this.parent) where this.CanSpawnPawnAt(cell) select cell).TryRandomElement(out IntVec3 center)) { break; } // Log.Message(string.Format("kindDef: {0}", kind)); PawnGenerationRequest request = new PawnGenerationRequest(kind.kind, faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, true, false, 1f, false, true, true, false, false, false, false); Pawn pawn = PawnGenerator.GeneratePawn(request); if (!GenPlace.TryPlaceThing(pawn, center, this.parent.Map, ThingPlaceMode.Near, null, null)) { Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); break; } this.lord.AddPawn(pawn); this.pointsLeft -= pawn.kindDef.combatPower; } } finally { this.pointsLeft = 0f; } SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(this.parent.Map); if (Props.minTimeBetween > 0) { this.lastSpawnTick = (int)(this.Props.minTimeBetween * 60000f / Find.Storyteller.difficulty.enemyReproductionRateFactor); } }
public override IEnumerable <RecipeDef> GetAllRecipes() { return(from IntVec3 c in GenAdj.CellsAdjacent8Way(this) from Thing t in c.GetThingList(Map) let h = t as Building_RecipeHolder where h != null from RecipeDef recipe in h.recipes where recipe.skillRequirements == null || recipe.skillRequirements.All(s => s.minLevel <= this.SkillLevel) select recipe); }
public override void PostSpawnSetup(bool respawningAfterLoad) { base.PostSpawnSetup(respawningAfterLoad); this.powerTrader = this.parent.TryGetComp <CompPowerTrader>(); this.network = QNetworkManager.Get(this.parent.Map); this.network.RegisterInput(this.powerTrader, GenAdj.CellsAdjacent8Way(this.parent)); this.network.RegisterStorage(this.powerTrader, GenAdj.CellsOccupiedBy(this.parent)); }
// Token: 0x060029EE RID: 10734 RVA: 0x0013DA2C File Offset: 0x0013BE2C private void TrySpawnPawns() { IEnumerable <PawnGenOption> source = spawnablePawnKinds; if (this.pointsLeft <= 0f) { return; } if (!this.parent.Spawned) { return; } if (this.lord == null) { if (!CellFinder.TryFindRandomCellNear(this.parent.Position, this.parent.Map, 5, (IntVec3 c) => c.Standable(this.parent.Map) && this.parent.Map.reachability.CanReach(c, this.parent, PathEndMode.Touch, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)), out IntVec3 invalid, -1)) { Log.Error("Found no place for Pawns to defend " + this, false); invalid = IntVec3.Invalid; } LordJob_PawnsDefendShip lordJob = new LordJob_PawnsDefendShip(this.parent, this.parent.Faction, 21f, invalid); this.lord = LordMaker.MakeNewLord(OfFaction, lordJob, this.parent.Map, null); } try { while (this.pointsLeft > 0f) { if (!(from def in source select def).TryRandomElementByWeight(x => x.selectionWeight, out PawnGenOption kind)) { // Log.Message(string.Format("kindDef: {0}", kind)); break; } if (!(from cell in GenAdj.CellsAdjacent8Way(this.parent) where this.CanSpawnPawnAt(cell) select cell).TryRandomElement(out IntVec3 center)) { break; } // Log.Message(string.Format("kindDef: {0}", kind)); PawnGenerationRequest request = new PawnGenerationRequest(kind.kind, faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, true, false, 1f, false, true, true, false, false, false, false); Pawn pawn = PawnGenerator.GeneratePawn(request); if (!GenPlace.TryPlaceThing(pawn, center, this.parent.Map, ThingPlaceMode.Near, null, null)) { Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); break; } this.lord.AddPawn(pawn); this.pointsLeft -= pawn.kindDef.combatPower; } } finally { this.pointsLeft = 0f; } SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(this.parent.Map); }
private void TrySpawnMadSailors() { var lordList = new List <Pawn>(); var faction = Find.FactionManager.FirstFactionOfDef(CultsDefOf.Cults_Sailors); Utility.DebugReport(faction.ToString()); //Log.Message("Building_LandedShip LordJob_DefendPoint"); var lordJob = new LordJob_DefendPoint(Position); if (pointsLeft <= 0f) { return; } if (lord == null) { lord = LordMaker.MakeNewLord(faction, lordJob, Map, lordList); } while (pointsLeft > 0f) { if (!(from cell in GenAdj.CellsAdjacent8Way(this) where cell.Walkable(Map) select cell).TryRandomElement(out var center)) { continue; } var request = new PawnGenerationRequest(CultsDefOf.Cults_Sailor, faction, PawnGenerationContext.NonPlayer, Map.Tile, false, false, false, false, true, true, 20f, false, true, true, false, false, false, false, false, 0, 0, null, 0); var pawn = PawnGenerator.GeneratePawn(request); if (!GenPlace.TryPlaceThing(pawn, center, Map, ThingPlaceMode.Near)) { continue; } if (pawn.GetLord() != null) { pawn.GetLord().Cleanup(); pawn.GetLord().CurLordToil.Cleanup(); pawn.GetLord().LordJob.Cleanup(); } lord.AddPawn(pawn); pointsLeft -= pawn.kindDef.combatPower; Utility.ApplySanityLoss(pawn, 1f); //Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); } pointsLeft = 0f; SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(); }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); this.adjacent = GenAdj.CellsAdjacent8Way(this).ToArray(); if (this.GetComp <CompGlowerPulse>() != null) { this.GetComp <CompGlowerPulse>().Glows = false; } }
public override void DrawExtraSelectionOverlays() { base.DrawExtraSelectionOverlays(); GenDraw.DrawFieldEdges(GenAdj.CellsAdjacent8Way(this).ToList()); GenDraw.DrawFieldEdges(new List <IntVec3> { OutputSlot }, Color.green); if (def.hasInteractionCell) { Graphics.DrawMesh(MeshPool.plane10, WorkTableCell.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays), Quaternion.identity, GenDraw.InteractionCellMaterial, 0); } }
private static void ExtendSearchGrid(IntVec3 searchPos, ref List <IntVec3> cells) { List <IntVec3> allcells = GenAdj.CellsAdjacent8Way(searchPos, Rot4.North, new IntVec2(1, 1)).ToList(); foreach (IntVec3 c in allcells) { if (!cells.Contains(c)) { cells.Add(c); } } }
public override void PostSpawnSetup(bool respawningAfterLoad) { base.PostSpawnSetup(respawningAfterLoad); if (Props.SupportDiagonal) { possibleOutputs = new List <IntVec3>(GenAdj.CellsAdjacent8Way(parent)); } else { possibleOutputs = new List <IntVec3>(GenAdj.CellsAdjacentCardinal(parent)); } }
public static bool TryFindSpawnCell(this HediffComp_RandySpawner comp, out IntVec3 result) { Pawn p = comp.Pawn; ThingDef thingDef = comp.CurIP.thingToSpawn; if (p.Negligible()) { result = IntVec3.Invalid; Tools.Warn("TryFindSpawnCell Null - pawn null", comp.MyDebug); return(false); } foreach (IntVec3 current in GenAdj.CellsAdjacent8Way(p).InRandomOrder(null)) { if (current.Walkable(p.Map)) { Building edifice = current.GetEdifice(p.Map); if (edifice == null || !thingDef.IsEdifice()) { if (!(edifice is Building_Door building_Door) || building_Door.FreePassage) { if (GenSight.LineOfSight(p.Position, current, p.Map, false, null, 0, 0)) { bool flag = false; List <Thing> thingList = current.GetThingList(p.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category == ThingCategory.Item) { if (thing.def != thingDef || thing.stackCount > thingDef.stackLimit - comp.calculatedQuantity) { flag = true; break; } } } if (!flag) { result = current; return(true); } } } } } } Tools.Warn("TryFindSpawnCell Null - no spawn cell found", comp.MyDebug); result = IntVec3.Invalid; return(false); }
// Token: 0x06005757 RID: 22359 RVA: 0x001D4668 File Offset: 0x001D2868 public static bool TryFindSpawnCell(Thing parent, CompProperties_SpawnerTerrainDependant PropsSpawner, out IntVec3 result) { ThingDef thingToSpawn = PropsSpawner.thingToSpawn; int spawnCount = PropsSpawner.spawnCount; foreach (IntVec3 intVec in GenAdj.CellsAdjacent8Way(parent).InRandomOrder(null)) { if (intVec.Walkable(parent.Map)) { if (!PropsSpawner.allowedTerrain.NullOrEmpty()) { if (!PropsSpawner.allowedTerrain.Contains(intVec.GetTerrain(parent.Map))) { continue; } } if (!PropsSpawner.allowedAffordances.NullOrEmpty()) { if (!PropsSpawner.allowedAffordances.Any(x => intVec.GetTerrain(parent.Map).affordances.Contains(x))) { continue; } } Building edifice = intVec.GetEdifice(parent.Map); if (edifice == null || !thingToSpawn.IsEdifice()) { Building_Door building_Door = edifice as Building_Door; if ((building_Door == null || building_Door.FreePassage) && (parent.def.passability == Traversability.Impassable || GenSight.LineOfSight(parent.Position, intVec, parent.Map, false, null, 0, 0))) { bool flag = false; List <Thing> thingList = intVec.GetThingList(parent.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category == ThingCategory.Item && (thing.def != thingToSpawn || thing.stackCount > thingToSpawn.stackLimit - spawnCount)) { flag = true; break; } } if (!flag) { result = intVec; return(true); } } } } } result = IntVec3.Invalid; return(false); }
/// <summary> /// Draw Overlay when Selected or Placing. /// /// We draw Air Cells surrounding the Parent Object. /// </summary> /// <param name="def">The Thing's Def</param> /// <param name="center">Location</param> /// <param name="rot">Rotation</param> /// <param name="ghostCol">Ghost Color</param> public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol) { if (def == null) { return; } var size = def.size; var list = GenAdj.CellsAdjacent8Way(center, rot, size); GenDraw.DrawFieldEdges(list.ToList(), Color.white); }
/// <summary> /// Place Worker for Air Vents. /// /// Checks: /// - North Cell from Center musn't be Impassable /// </summary> /// <param name="def">The Def Being Built</param> /// <param name="center">Target Location</param> /// <param name="rot">Rotation of the Object to be Placed</param> /// <param name="thingToIgnore">Unused field</param> /// <returns>Boolean/Acceptance Report if we can place the object of not.</returns> public override AcceptanceReport AllowsPlacing(BuildableDef def, IntVec3 center, Rot4 rot, Map map, Thing thingToIgnore = null) { var size = def.Size; var list = GenAdj.CellsAdjacent8Way(center, rot, size); if (list.Any(intVec => intVec.Impassable(map))) { return("CentralizedClimateControl.Consumer.SurroundAirVentPlaceError".Translate()); } return(true); }
public static Toil DropTheCarriedInCell(TargetIndex StoreCellInd, ThingPlaceMode placeMode, TargetIndex CarrierInd) { Toil toil = new Toil(); toil.initAction = () => { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; Vehicle_Cart carrier = actor.jobs.curJob.GetTarget(CarrierInd).Thing as Vehicle_Cart; if (carrier.storage.Count <= 0) { return; } toil.actor.jobs.curJob.SetTarget(TargetIndex.A, carrier.storage.First()); Thing dropThing = toil.actor.jobs.curJob.targetA.Thing; IntVec3 destLoc = actor.jobs.curJob.GetTarget(StoreCellInd).Cell; Thing dummy; SlotGroup slotGroup = Find.SlotGroupManager.SlotGroupAt(destLoc); // if (destLoc.GetStorable() == null) if (slotGroup != null && slotGroup.Settings.AllowedToAccept(dropThing)) { Find.DesignationManager.RemoveAllDesignationsOn(dropThing); carrier.storage.TryDrop(dropThing, destLoc, placeMode, out dummy); } //Check cell queue is adjacent List <TargetInfo> cells = curJob.GetTargetQueue(StoreCellInd); for (int i = 0; i < cells.Count && i < carrier.storage.Count; i++) { if (destLoc.AdjacentTo8Way(cells[i].Cell) && cells[i].Cell.GetStorable() == null) { Find.DesignationManager.RemoveAllDesignationsOn(carrier.storage[i]); carrier.storage.TryDrop(carrier.storage[i], cells[i].Cell, ThingPlaceMode.Direct, out dummy); cells.RemoveAt(i); i--; } } //Check item queue is valid storage for adjacent cell foreach (IntVec3 adjCell in GenAdj.CellsAdjacent8Way(destLoc)) { if (carrier.storage.Count > 0 && adjCell.GetStorable() == null && adjCell.IsValidStorageFor(carrier.storage.First())) { Find.DesignationManager.RemoveAllDesignationsOn(carrier.storage.First()); carrier.storage.TryDrop(carrier.storage.First(), adjCell, ThingPlaceMode.Direct, out dummy); } } }; toil.FailOnDestroyedOrNull(CarrierInd); return(toil); }
public static bool Notify_ThingAffectingRegionsDespawned(RegionDirtyer __instance, Thing b) { //regionsToDirty.Clear(); List <Region> regionsToDirty = new List <Region>(); Region validRegionAt_NoRebuild = map(__instance).regionGrid.GetValidRegionAt_NoRebuild(b.Position); if (validRegionAt_NoRebuild != null) { map(__instance).temperatureCache.TryCacheRegionTempInfo(b.Position, validRegionAt_NoRebuild); regionsToDirty.Add(validRegionAt_NoRebuild); } foreach (IntVec3 item2 in GenAdj.CellsAdjacent8Way(b)) { if (item2.InBounds(map(__instance))) { Region validRegionAt_NoRebuild2 = map(__instance).regionGrid.GetValidRegionAt_NoRebuild(item2); if (validRegionAt_NoRebuild2 != null) { map(__instance).temperatureCache.TryCacheRegionTempInfo(item2, validRegionAt_NoRebuild2); regionsToDirty.Add(validRegionAt_NoRebuild2); } } } for (int i = 0; i < regionsToDirty.Count; i++) { SetRegionDirty(__instance, regionsToDirty[i]); } regionsToDirty.Clear(); ConcurrentQueue <IntVec3> dirtyCells = get_DirtyCells(__instance); if (b.def.size.x == 1 && b.def.size.z == 1) { dirtyCells.Enqueue(b.Position); return(false); } CellRect cellRect = b.OccupiedRect(); for (int j = cellRect.minZ; j <= cellRect.maxZ; j++) { for (int k = cellRect.minX; k <= cellRect.maxX; k++) { IntVec3 item = new IntVec3(k, 0, j); dirtyCells.Enqueue(item); } } return(false); }
private void TrySpawnMechanoids() { if (this.pointsLeft <= 0f) { return; } if (this.lord == null) { IntVec3 invalid; if (!CellFinder.TryFindRandomCellNear(base.Position, base.Map, 5, (IntVec3 c) => c.Standable(base.Map) && base.Map.reachability.CanReach(c, this, PathEndMode.Touch, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)), out invalid)) { Log.Error("Found no place for mechanoids to defend " + this); invalid = IntVec3.Invalid; } LordJob_MechanoidsDefendShip lordJob = new LordJob_MechanoidsDefendShip(this, base.Faction, 21f, invalid); this.lord = LordMaker.MakeNewLord(Faction.OfMechanoids, lordJob, base.Map, null); } PawnKindDef kindDef; while ((from def in DefDatabase <PawnKindDef> .AllDefs where def.RaceProps.IsMechanoid && def.isFighter && def.combatPower <= this.pointsLeft select def).TryRandomElement(out kindDef)) { IntVec3 center; if ((from cell in GenAdj.CellsAdjacent8Way(this) where this.CanSpawnMechanoidAt(cell) select cell).TryRandomElement(out center)) { Pawn pawn = PawnGenerator.GeneratePawn(kindDef, Faction.OfMechanoids); if (GenPlace.TryPlaceThing(pawn, center, base.Map, ThingPlaceMode.Near, null)) { this.lord.AddPawn(pawn); this.pointsLeft -= pawn.kindDef.combatPower; continue; } Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); } IL_130: this.pointsLeft = 0f; if (base.Map == Find.VisibleMap) { SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(); } return; } this.pointsLeft = 0f; if (base.Map == Find.VisibleMap) { SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(); } }