public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; bool @bool = Rand.Bool; ThingDef thingDef = rp.singleThingDef ?? Rand.Element(ThingDefOf.Bed, ThingDefOf.Bedroll, ThingDefOf.SleepingSpot); ThingDef singleThingStuff = rp.singleThingStuff ?? GenStuff.RandomStuffByCommonalityFor(thingDef, (rp.faction != null) ? rp.faction.def.techLevel : TechLevel.Undefined); foreach (IntVec3 item in rp.rect) { IntVec3 current = item; if (@bool) { if (current.x % 3 == 0 && current.z % 2 == 0) { goto IL_00d5; } } else if (current.x % 2 == 0 && current.z % 3 == 0) { goto IL_00d5; } continue; IL_00d5: Rot4 rot = (!@bool) ? Rot4.North : Rot4.West; if (!GenSpawn.WouldWipeAnythingWith(current, rot, thingDef, map, (Thing x) => x.def.category == ThingCategory.Building) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(GenAdj.OccupiedRect(current, rot, thingDef.Size), map)) { ResolveParams resolveParams = rp; resolveParams.rect = GenAdj.OccupiedRect(current, rot, thingDef.size); resolveParams.singleThingDef = thingDef; resolveParams.singleThingStuff = singleThingStuff; resolveParams.thingRot = rot; BaseGen.symbolStack.Push("bed", resolveParams); } } }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; ThingDef thingDef = (rp.singleThingDef != null) ? rp.singleThingDef : ((rp.faction == null || (int)rp.faction.def.techLevel < 3) ? Rand.Element(ThingDefOf.Bed, ThingDefOf.Bedroll, ThingDefOf.SleepingSpot) : ThingDefOf.Bed); ThingDef singleThingStuff = (rp.singleThingStuff == null || !rp.singleThingStuff.stuffProps.CanMake(thingDef)) ? GenStuff.RandomStuffInexpensiveFor(thingDef, rp.faction) : rp.singleThingStuff; bool @bool = Rand.Bool; foreach (IntVec3 item in rp.rect) { if (@bool) { if (item.x % 3 != 0 || item.z % 2 != 0) { continue; } } else if (item.x % 2 != 0 || item.z % 3 != 0) { continue; } Rot4 rot = @bool ? Rot4.West : Rot4.North; if (!GenSpawn.WouldWipeAnythingWith(item, rot, thingDef, map, (Thing x) => x.def.category == ThingCategory.Building) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(GenAdj.OccupiedRect(item, rot, thingDef.Size), map)) { ResolveParams resolveParams = rp; resolveParams.rect = GenAdj.OccupiedRect(item, rot, thingDef.size); resolveParams.singleThingDef = thingDef; resolveParams.singleThingStuff = singleThingStuff; resolveParams.thingRot = rot; BaseGen.symbolStack.Push("bed", resolveParams); } } }
public override void Resolve(ResolveParams rp) { ThingDef stoveElectric = DefDatabase <ThingDef> .GetNamedSilentFail(defName : "ElectricStove"); ThingDef stoveFueled = DefDatabase <ThingDef> .GetNamedSilentFail(defName : "FueledStove"); ThingDef tableButcher = DefDatabase <ThingDef> .GetNamedSilentFail(defName : "TableButcher"); ThingDef spotButcher = DefDatabase <ThingDef> .GetNamedSilentFail(defName : "ButcherSpot"); Map map = BaseGen.globalSettings.map; ThingDef thingDef; if (rp.singleThingDef != null) { thingDef = rp.singleThingDef; } else if (rp.faction != null && rp.faction.def.techLevel >= TechLevel.Medieval) { thingDef = stoveElectric; } else { thingDef = Rand.Element(a: stoveFueled, b: ThingDefOf.Campfire, c: spotButcher); } bool flipACoin = Rand.Bool; foreach (IntVec3 potentialSpot in rp.rect) { if (flipACoin) { if (potentialSpot.x % 3 != 0 || potentialSpot.z % 2 != 0) { continue; } } else if (potentialSpot.x % 2 != 0 || potentialSpot.z % 3 != 0) { continue; } Rot4 rot = (!flipACoin) ? Rot4.North : Rot4.West; if (!GenSpawn.WouldWipeAnythingWith(thingPos: potentialSpot, thingRot: rot, thingDef: thingDef, map: map, predicate: x => x.def.category == ThingCategory.Building)) { IntVec2 dontTouchMe = new IntVec2(thingDef.Size.x + 1, thingDef.Size.z + 1); if (!BaseGenUtility.AnyDoorAdjacentCardinalTo(rect: GenAdj.OccupiedRect(center: potentialSpot, rot: rot, size: dontTouchMe), map: map)) { ResolveParams resolveParams = rp; resolveParams.rect = GenAdj.OccupiedRect(center: potentialSpot, rot: rot, size: thingDef.Size); resolveParams.singleThingDef = (Rand.Element(a: thingDef, b: tableButcher)); resolveParams.thingRot = rot; bool?skipSingleThingIfHasToWipeBuildingOrDoesntFit = rp.skipSingleThingIfHasToWipeBuildingOrDoesntFit; resolveParams.skipSingleThingIfHasToWipeBuildingOrDoesntFit = !skipSingleThingIfHasToWipeBuildingOrDoesntFit.HasValue || skipSingleThingIfHasToWipeBuildingOrDoesntFit.Value; BaseGen.symbolStack.Push(symbol: "thing", resolveParams: resolveParams); } } } }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; ThingDef thingDef; if (rp.singleThingDef != null) { thingDef = rp.singleThingDef; } else if (rp.faction != null && rp.faction.def.techLevel >= TechLevel.Medieval) { thingDef = ThingDefOf.Bed; } else { thingDef = Rand.Element <ThingDef>(ThingDefOf.Bed, ThingDefOf.Bedroll, ThingDefOf.SleepingSpot); } ThingDef singleThingStuff; if (rp.singleThingStuff != null && rp.singleThingStuff.stuffProps.CanMake(thingDef)) { singleThingStuff = rp.singleThingStuff; } else { singleThingStuff = GenStuff.RandomStuffInexpensiveFor(thingDef, rp.faction); } bool @bool = Rand.Bool; foreach (IntVec3 current in rp.rect) { if (@bool) { if (current.x % 3 != 0 || current.z % 2 != 0) { continue; } } else if (current.x % 2 != 0 || current.z % 3 != 0) { continue; } Rot4 rot = (!@bool) ? Rot4.North : Rot4.West; if (!GenSpawn.WouldWipeAnythingWith(current, rot, thingDef, map, (Thing x) => x.def.category == ThingCategory.Building)) { if (!BaseGenUtility.AnyDoorAdjacentCardinalTo(GenAdj.OccupiedRect(current, rot, thingDef.Size), map)) { ResolveParams resolveParams = rp; resolveParams.rect = GenAdj.OccupiedRect(current, rot, thingDef.size); resolveParams.singleThingDef = thingDef; resolveParams.singleThingStuff = singleThingStuff; resolveParams.thingRot = new Rot4?(rot); BaseGen.symbolStack.Push("bed", resolveParams); } } } }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; int num = 0; int num2 = 0; int num3 = -1; if (rp.rect.EdgeCellsCount < (SymbolResolver_EdgeSandbags.LineLengthRange.max + SymbolResolver_EdgeSandbags.GapLengthRange.max) * 2) { num = rp.rect.EdgeCellsCount; } else if (Rand.Bool) { num = SymbolResolver_EdgeSandbags.LineLengthRange.RandomInRange; } else { num2 = SymbolResolver_EdgeSandbags.GapLengthRange.RandomInRange; } foreach (IntVec3 current in rp.rect.EdgeCells) { num3++; if (num2 > 0) { num2--; if (num2 == 0) { if (num3 == rp.rect.EdgeCellsCount - 2) { num2 = 1; } else { num = SymbolResolver_EdgeSandbags.LineLengthRange.RandomInRange; } } } else if (current.Standable(map) && !current.Roofed(map) && current.SupportsStructureType(map, ThingDefOf.Sandbags.terrainAffordanceNeeded)) { if (!GenSpawn.WouldWipeAnythingWith(current, Rot4.North, ThingDefOf.Sandbags, map, (Thing x) => x.def.category == ThingCategory.Building || x.def.category == ThingCategory.Item)) { if (num > 0) { num--; if (num == 0) { num2 = SymbolResolver_EdgeSandbags.GapLengthRange.RandomInRange; } } Thing thing = ThingMaker.MakeThing(ThingDefOf.Sandbags, null); thing.SetFaction(rp.faction, null); GenSpawn.Spawn(thing, current, map); } } } }
private bool TryFindSpawnCell(CellRect rect, ThingDef thingDef, Rot4 rot, out IntVec3 spawnCell) { Map map = BaseGen.globalSettings.map; IntVec3 zero = IntVec3.Zero; IntVec2 size = thingDef.size; GenAdj.AdjustForRotation(ref zero, ref size, rot); CellRect empty = CellRect.Empty; Predicate <CellRect> basePredicate = delegate(CellRect x) { if (x.Cells.All((IntVec3 y) => y.Standable(map))) { if (!GenSpawn.WouldWipeAnythingWith(x, thingDef, map, (Thing z) => z.def.category == ThingCategory.Building)) { return(thingDef.category != ThingCategory.Item || x.CenterCell.GetFirstItem(map) == null); } } return(false); }; bool flag = false; if (thingDef.category == ThingCategory.Building) { flag = rect.TryFindRandomInnerRectTouchingEdge(size, out empty, (CellRect x) => basePredicate(x) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(x, map) && GenConstruct.TerrainCanSupport(x, map, thingDef)); if (!flag) { flag = rect.TryFindRandomInnerRectTouchingEdge(size, out empty, (CellRect x) => basePredicate(x) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(x, map)); } } bool result; if (!flag && !rect.TryFindRandomInnerRectTouchingEdge(size, out empty, basePredicate)) { spawnCell = IntVec3.Invalid; result = false; } else { CellRect.CellRectIterator iterator = empty.GetIterator(); while (!iterator.Done()) { if (GenAdj.OccupiedRect(iterator.Current, rot, thingDef.size) == empty) { spawnCell = iterator.Current; return(true); } iterator.MoveNext(); } Log.Error("We found a valid rect but we couldn't find the root position. This should never happen.", false); spawnCell = IntVec3.Invalid; result = false; } return(result); }
internal bool <> m__0(IntVec3 c) { bool result; if (c.Standable(this.map) && !c.Roofed(this.map) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(c, this.map) && c.GetFirstItem(this.map) == null) { result = !GenSpawn.WouldWipeAnythingWith(c, Rot4.North, ThingDefOf.Campfire, this.map, (Thing x) => x.def.category == ThingCategory.Building); } else { result = false; } return(result); }
private bool TryFindSpawnCell(CellRect rect, out IntVec3 result) { Map map = BaseGen.globalSettings.map; return(CellFinder.TryFindRandomCellInsideWith(rect, delegate(IntVec3 c) { bool arg_6C_0; if (c.Standable(map) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(c, map) && c.GetFirstItem(map) == null) { arg_6C_0 = !GenSpawn.WouldWipeAnythingWith(c, Rot4.North, ThingDefOf.FirefoamPopper, map, (Thing x) => x.def.category == ThingCategory.Building); } else { arg_6C_0 = false; } return arg_6C_0; }, out result)); }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; bool @bool = Rand.Bool; ThingDef thingDef = rp.singleThingDef ?? Rand.Element <ThingDef>(ThingDefOf.Bed, ThingDefOf.Bedroll, ThingDefOf.SleepingSpot); ThingDef arg_6B_0; if ((arg_6B_0 = rp.singleThingStuff) == null) { arg_6B_0 = GenStuff.RandomStuffByCommonalityFor(thingDef, (rp.faction == null) ? TechLevel.Undefined : rp.faction.def.techLevel); } ThingDef singleThingStuff = arg_6B_0; foreach (IntVec3 current in rp.rect) { if (@bool) { if (current.x % 3 != 0 || current.z % 2 != 0) { continue; } } else if (current.x % 2 != 0 || current.z % 3 != 0) { continue; } Rot4 rot = (!@bool) ? Rot4.North : Rot4.West; if (!GenSpawn.WouldWipeAnythingWith(current, rot, thingDef, map, (Thing x) => x.def.category == ThingCategory.Building)) { if (!BaseGenUtility.AnyDoorAdjacentCardinalTo(GenAdj.OccupiedRect(current, rot, thingDef.Size), map)) { ResolveParams resolveParams = rp; resolveParams.rect = GenAdj.OccupiedRect(current, rot, thingDef.size); resolveParams.singleThingDef = thingDef; resolveParams.singleThingStuff = singleThingStuff; resolveParams.thingRot = new Rot4?(rot); BaseGen.symbolStack.Push("bed", resolveParams); } } } }
public static ThinkResult LayDownInPlace(Pawn pawn, JobGiver_PatientGoToBed giver) { if (Settings.Get().FieldTendingActive(pawn)) { Building_Bed tempTendSpot = pawn.Position.GetThingList(pawn.Map).FirstOrDefault(t => t.def == TempSleepSpot) as Building_Bed; if (tempTendSpot == null && !GenSpawn.WouldWipeAnythingWith(pawn.Position, Rot4.North, TempSleepSpot, pawn.Map, t => true)) { tempTendSpot = ThingMaker.MakeThing(TempSleepSpot) as Building_Bed; GenSpawn.Spawn(tempTendSpot, pawn.Position, pawn.Map, WipeMode.FullRefund); tempTendSpot.Medical = true; Log.Message($"Creating bed {tempTendSpot} for {pawn} at {pawn.Position}"); } return(new ThinkResult(new Job(JobDefOf.LayDown, tempTendSpot), giver)); } else { return(ThinkResult.NoJob); } }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; int num = 0; int num2 = 0; int num3 = -1; int edgeCellsCount = rp.rect.EdgeCellsCount; IntRange lineLengthRange = LineLengthRange; int max = lineLengthRange.max; IntRange gapLengthRange = GapLengthRange; if (edgeCellsCount < (max + gapLengthRange.max) * 2) { num = rp.rect.EdgeCellsCount; } else if (Rand.Bool) { num = LineLengthRange.RandomInRange; } else { num2 = GapLengthRange.RandomInRange; } foreach (IntVec3 edgeCell in rp.rect.EdgeCells) { num3++; if (num2 > 0) { num2--; if (num2 == 0) { if (num3 == rp.rect.EdgeCellsCount - 2) { num2 = 1; } else { num = LineLengthRange.RandomInRange; } } } else if (edgeCell.Standable(map) && !edgeCell.Roofed(map) && edgeCell.SupportsStructureType(map, ThingDefOf.Sandbags.terrainAffordanceNeeded) && !GenSpawn.WouldWipeAnythingWith(edgeCell, Rot4.North, ThingDefOf.Sandbags, map, (Thing x) => x.def.category == ThingCategory.Building || x.def.category == ThingCategory.Item)) { if (num > 0) { num--; if (num == 0) { num2 = GapLengthRange.RandomInRange; } } Thing thing = ThingMaker.MakeThing(ThingDefOf.Sandbags); thing.SetFaction(rp.faction); GenSpawn.Spawn(thing, edgeCell, map); } } }
public override void PassingParameters(ResolveParams rp) { string defChair = "DiningChair"; string defLamp = "Jecrell_GasLamp"; ThingDef lampDef = Cthulhu.Utility.IsIndustrialAgeLoaded() ? ThingDef.Named(defLamp) : ThingDefOf.TorchLamp; ThingDef lampStuffDef = Cthulhu.Utility.IsIndustrialAgeLoaded() ? ThingDefOf.Steel : null; Map map = BaseGen.globalSettings.map; bool @bool = Rand.Bool; bool hasLamp = false; ThingDef thingDef = ThingDefOf.SleepingSpot; ThingDef chairDef = ThingDef.Named(defChair); foreach (IntVec3 current in rp.rect) { if (@bool) { if (current.x % 3 != 0 || current.z % 3 != 0) { continue; } } else if (current.x % 3 != 0 || current.z % 3 != 0) { continue; } Rot4 rot = (!@bool) ? Rot4.South : Rot4.West; if (!GenSpawn.WouldWipeAnythingWith(current, rot, thingDef, map, (Thing x) => x.def.category == ThingCategory.Building)) { bool flag = false; foreach (IntVec3 current2 in GenAdj.CellsOccupiedBy(current, rot, thingDef.Size)) { if (BaseGenUtility.AnyDoorAdjacentCardinalTo(current2, map)) { flag = true; break; } } if (!flag) { ///Bed ThingDef stuff = null; if (thingDef.MadeFromStuff) { stuff = ThingDefOf.WoodLog; } Thing thing = ThingMaker.MakeThing(thingDef, stuff); thing.SetFaction(rp.faction, null); GenSpawn.Spawn(thing, current, map, rot); if (thing != null) { if (thing.Spawned && thing.Position.InBounds(map)) { CellRect thingRect = thing.OccupiedRect(); if (thingRect != null) { thingRect = thingRect.ExpandedBy(1); List <IntVec3> possibleCells = new List <IntVec3>(); possibleCells.AddRange(thingRect.GetEdgeCells(Rot4.North)); possibleCells.AddRange(thingRect.GetEdgeCells(Rot4.South)); possibleCells.AddRange(thingRect.GetEdgeCells(Rot4.East)); possibleCells.AddRange(thingRect.GetEdgeCells(Rot4.West)); possibleCells.Remove(Cthulhu.Utility.GetCornerPos(thingRect, 0)); possibleCells.Remove(Cthulhu.Utility.GetCornerPos(thingRect, 1)); possibleCells.Remove(Cthulhu.Utility.GetCornerPos(thingRect, 2)); possibleCells.Remove(Cthulhu.Utility.GetCornerPos(thingRect, 3)); IntVec3 spawnPos = IntVec3.Invalid; spawnPos = possibleCells.InRandomOrder <IntVec3>().FirstOrDefault((IntVec3 x) => x.InBounds(map) && x.Walkable(map)); if (spawnPos != null) { possibleCells.Remove(spawnPos); Thing thing2 = ThingMaker.MakeThing(chairDef, ThingDefOf.WoodLog); thing2.SetFaction(rp.faction, null); GenSpawn.Spawn(thing2, spawnPos, map, rot.Opposite); } if (!hasLamp) { hasLamp = true; spawnPos = possibleCells.FirstOrDefault((IntVec3 x) => x.InBounds(map) && x.Walkable(map)); if (spawnPos != null) { possibleCells.Remove(spawnPos); Thing thing3 = ThingMaker.MakeThing(lampDef, lampStuffDef); thing3.SetFaction(rp.faction, null); GenSpawn.Spawn(thing3, spawnPos, map, rot.Opposite); } } } } } } } } //if (!Cthulhu.Utility.IsCosmicHorrorsLoaded()) //{ PawnGroupKindDef groupKind = rp.pawnGroupKindDef ?? PawnGroupKindDefOf.Combat; PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms() { faction = (from x in Find.FactionManager.AllFactions where x.HostileTo(rp.faction) && x.def.pawnGroupMakers != null && x.def.pawnGroupMakers.Count > 0 && x.def.humanlikeFaction && IsCosmicHorrorFaction(x) == false && (x.def.pawnGroupMakers.FirstOrDefault((PawnGroupMaker y) => y.kindDef == PawnGroupKindDefOf.Combat) != null) select x).RandomElement <Faction>(), tile = map.Tile, points = 5000, generateFightersOnly = false, }; int num = 0; foreach (Pawn current in PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms, true)) { num++; ResolveParams resolveParams = rp; resolveParams.singlePawnToSpawn = current; BaseGen.symbolStack.Push("pawn", resolveParams); if (num == 3) { break; } } //} //else //{ // Faction tempFaction = Find.FactionManager.AllFactions.InRandomOrder<Faction>().FirstOrDefault((Faction z) => IsCosmicHorrorFaction(z)); // PawnGroupKindDef groupKind = rp.pawnGroupKindDef ?? PawnGroupKindDefOf.Combat; // PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms() // { // faction = tempFaction, // map = map, // points = 5000, // generateFightersOnly = false, // generateMeleeOnly = false // }; // int num = 0; // foreach (Pawn current in PawnGroupMakerUtility.GeneratePawns(groupKind, pawnGroupMakerParms, true)) // { // num++; // ResolveParams resolveParams = rp; // resolveParams.singlePawnToSpawn = current; // resolveParams.singlePawnLord = null; // BaseGen.symbolStack.Push("pawn", resolveParams); // if (num == 3) break; // } //} //List<int> corners = new List<int>() { 0, 1, 2, 3 }; //foreach (int corner in corners.InRandomOrder<int>()) //{ // IntVec3 loc = Cthulhu.Utility.GetCornerPos(rp.rect.ContractedBy(1), corner); // if (!GenSpawn.WouldWipeAnythingWith(loc, Rot4.South, lampDef, map, (Thing x) => x.def.category == ThingCategory.Building)) // { // ThingDef singleThingDef3 = (Cthulhu.Utility.IsIndustrialAgeLoaded()) ? lampDef : ThingDefOf.TorchLamp; // Thing thing3 = ThingMaker.MakeThing(singleThingDef3, ThingDefOf.Steel); // GenSpawn.Spawn(thing3, loc, map); // break; // } //} }
private bool TryFindSpawnCell(CellRect rect, ThingDef thingDef, Rot4 rot, bool mustReachMapEdge, out IntVec3 spawnCell) { Map map = BaseGen.globalSettings.map; IntVec3 center = IntVec3.Zero; IntVec2 size = thingDef.size; GenAdj.AdjustForRotation(ref center, ref size, rot); CellRect rect2 = CellRect.Empty; TraverseParms traverseParms = TraverseParms.For(TraverseMode.PassDoors); Predicate <CellRect> basePredicate = (CellRect x) => x.Cells.All((IntVec3 y) => y.Standable(map)) && !GenSpawn.WouldWipeAnythingWith(x, thingDef, map, (Thing z) => z.def.category == ThingCategory.Building) && (thingDef.category != ThingCategory.Item || x.CenterCell.GetFirstItem(map) == null) && (!mustReachMapEdge || map.reachability.CanReachMapEdge(x.CenterCell, traverseParms)); bool flag = false; if (thingDef.category == ThingCategory.Building) { flag = rect.TryFindRandomInnerRectTouchingEdge(size, out rect2, (CellRect x) => basePredicate(x) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(x, map) && GenConstruct.TerrainCanSupport(x, map, thingDef)); if (!flag) { flag = rect.TryFindRandomInnerRectTouchingEdge(size, out rect2, (CellRect x) => basePredicate(x) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(x, map)); } } if (!flag && !rect.TryFindRandomInnerRectTouchingEdge(size, out rect2, basePredicate)) { spawnCell = IntVec3.Invalid; return(false); } foreach (IntVec3 item in rect2) { if (GenAdj.OccupiedRect(item, rot, thingDef.size) == rect2) { spawnCell = item; return(true); } } Log.Error("We found a valid rect but we couldn't find the root position. This should never happen."); spawnCell = IntVec3.Invalid; return(false); }
public override void PassingParameters(ResolveParams paramsIn) { var defBench = "TableLong"; var defChair = "DiningChair"; var defLamp = "Jecrell_GasLamp"; var lampDef = Utility.IsIndustrialAgeLoaded() ? ThingDef.Named(defLamp) : ThingDefOf.TorchLamp; var furnitureStuff = ThingDefOf.Steel; var lampStuffDef = Utility.IsIndustrialAgeLoaded() ? ThingDefOf.Steel : null; var rp = paramsIn; rp.rect = paramsIn.rect.ContractedBy(3); var map = BaseGen.globalSettings.map; var @bool = Rand.Bool; var thingDef = ThingDef.Named(defBench); var chairDef = ThingDef.Named(defChair); foreach (var current in rp.rect) { if (@bool) { if (current.x % 4 != 0 || current.z % 4 != 0) { continue; } } else if (current.x % 4 != 0 || current.z % 4 != 0) { continue; } var rot = Rot4.Random; if (GenSpawn.WouldWipeAnythingWith(current, rot, thingDef, map, x => x.def.category == ThingCategory.Building)) { continue; } var nearDoor = false; foreach (var current2 in GenAdj.CellsOccupiedBy(current, rot, thingDef.Size)) { if (!BaseGenUtility.AnyDoorAdjacentCardinalTo(current2, map)) { continue; } nearDoor = true; break; } if (nearDoor) { continue; } //TABLE ThingDef stuff = null; if (thingDef.MadeFromStuff) { stuff = furnitureStuff; } var thing = ThingMaker.MakeThing(thingDef, stuff); thing.SetFaction(rp.faction); GenSpawn.Spawn(thing, current, map, rot); if (!thing.Spawned || !thing.Position.InBounds(map)) { continue; } var rectToEdit = thing.OccupiedRect().ExpandedBy(1); var poss = new List <IntVec3>(); poss.AddRange(rectToEdit.GetEdgeCells(Rot4.North)); poss.AddRange(rectToEdit.GetEdgeCells(Rot4.South)); poss.AddRange(rectToEdit.GetEdgeCells(Rot4.East)); poss.AddRange(rectToEdit.GetEdgeCells(Rot4.West)); poss.Remove(Utility.GetCornerPos(rectToEdit, 0)); poss.Remove(Utility.GetCornerPos(rectToEdit, 1)); poss.Remove(Utility.GetCornerPos(rectToEdit, 2)); poss.Remove(Utility.GetCornerPos(rectToEdit, 3)); for (var i = 0; i < 4; i++) { //CHAIR var currentPos = poss.InRandomOrder().RandomElement(); poss.Remove(currentPos); Rot4 newRot; if (currentPos.x > thing.Position.x) { newRot = Rot4.West; } else if (currentPos.x < thing.Position.x) { newRot = Rot4.East; } else if (currentPos.z > thing.Position.z) { newRot = Rot4.South; } else { newRot = Rot4.North; } var unused = thing as Building; //We need an interaction cell var thing2 = ThingMaker.MakeThing(chairDef, stuff); thing2.SetFaction(rp.faction); GenSpawn.Spawn(thing2, currentPos, map, newRot); } } var corners = new List <int> { 0, 1, 2, 3 }; var count = 0; foreach (var corner in corners.InRandomOrder()) { if (count == 1) { break; } var loc = Utility.GetCornerPos(paramsIn.rect.ContractedBy(1), corner); if (!GenSpawn.WouldWipeAnythingWith(loc, Rot4.South, lampDef, map, x => x.def.category == ThingCategory.Building)) { var singleThingDef3 = Utility.IsIndustrialAgeLoaded() ? lampDef : ThingDefOf.TorchLamp; var thing3 = ThingMaker.MakeThing(singleThingDef3, lampStuffDef); GenSpawn.Spawn(thing3, loc, map); } count++; } }
public override void PassingParameters(ResolveParams paramsIn) { string defBench = "SimpleResearchBench"; string defChair = "DiningChair"; string defLamp = "Jecrell_GasLamp"; ThingDef lampDef = Cthulhu.Utility.IsIndustrialAgeLoaded() ? ThingDef.Named(defLamp) : ThingDefOf.TorchLamp; ThingDef lampStuffDef = Cthulhu.Utility.IsIndustrialAgeLoaded() ? ThingDefOf.Steel : null; ThingDef furnitureStuff = ThingDefOf.Steel; ResolveParams rp = paramsIn; rp.rect = paramsIn.rect.ContractedBy(3); Map map = BaseGen.globalSettings.map; bool @bool = Rand.Bool; ThingDef thingDef = ThingDef.Named(defBench); ThingDef chairDef = ThingDef.Named(defChair); foreach (IntVec3 current in rp.rect) { if (@bool) { if (current.x % 4 != 0 || current.z % 4 != 0) { continue; } } else if (current.x % 4 != 0 || current.z % 4 != 0) { continue; } Rot4 rot = Rot4.Random; if (!GenSpawn.WouldWipeAnythingWith(current, rot, thingDef, map, (Thing x) => x.def.category == ThingCategory.Building)) { bool flag = false; foreach (IntVec3 current2 in GenAdj.CellsOccupiedBy(current, rot, thingDef.Size)) { if (BaseGenUtility.AnyDoorAdjacentCardinalTo(current2, map)) { flag = true; break; } } if (!flag) { ///RESEARCH BENCH ThingDef stuff = null; if (thingDef.MadeFromStuff) { stuff = furnitureStuff; } Thing thing = ThingMaker.MakeThing(thingDef, stuff); thing.SetFaction(rp.faction, null); GenSpawn.Spawn(thing, current, map, rot); if (thing != null) { if (thing.Spawned && thing.Position.InBounds(map)) { ///CHAIR Building bld = thing as Building; //We need an interaction cell Thing thing2 = ThingMaker.MakeThing(chairDef, stuff); thing2.SetFaction(rp.faction, null); GenSpawn.Spawn(thing2, bld.InteractionCell, map, rot); } } } } } List <int> corners = new List <int>() { 0, 1, 2, 3 }; foreach (int corner in corners.InRandomOrder <int>()) { IntVec3 loc = Cthulhu.Utility.GetCornerPos(paramsIn.rect.ContractedBy(1), corner); if (!GenSpawn.WouldWipeAnythingWith(loc, Rot4.South, lampDef, map, (Thing x) => x.def.category == ThingCategory.Building)) { ThingDef singleThingDef3 = (Cthulhu.Utility.IsIndustrialAgeLoaded()) ? lampDef : ThingDefOf.TorchLamp; Thing thing3 = ThingMaker.MakeThing(singleThingDef3, lampStuffDef); GenSpawn.Spawn(thing3, loc, map); } } }
private bool TryFindSpawnCell(CellRect rect, out IntVec3 result) { Map map = BaseGen.globalSettings.map; return(CellFinder.TryFindRandomCellInsideWith(rect, (Predicate <IntVec3>)((IntVec3 c) => c.Standable(map) && !c.Roofed(map) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(c, map) && c.GetFirstItem(map) == null && !GenSpawn.WouldWipeAnythingWith(c, Rot4.North, ThingDefOf.Campfire, map, (Thing x) => x.def.category == ThingCategory.Building)), out result)); }
public override void PassingParameters(ResolveParams paramsIn) { var defBench = "SimpleResearchBench"; var defChair = "DiningChair"; var defLamp = "Jecrell_GasLamp"; var lampDef = Utility.IsIndustrialAgeLoaded() ? ThingDef.Named(defLamp) : ThingDefOf.TorchLamp; var lampStuffDef = Utility.IsIndustrialAgeLoaded() ? ThingDefOf.Steel : null; var furnitureStuff = ThingDefOf.Steel; var rp = paramsIn; rp.rect = paramsIn.rect.ContractedBy(3); var map = BaseGen.globalSettings.map; var @bool = Rand.Bool; var thingDef = ThingDef.Named(defBench); var chairDef = ThingDef.Named(defChair); foreach (var current in rp.rect) { if (@bool) { if (current.x % 4 != 0 || current.z % 4 != 0) { continue; } } else if (current.x % 4 != 0 || current.z % 4 != 0) { continue; } var rot = Rot4.Random; if (GenSpawn.WouldWipeAnythingWith(current, rot, thingDef, map, x => x.def.category == ThingCategory.Building)) { continue; } var nearDoor = false; foreach (var current2 in GenAdj.CellsOccupiedBy(current, rot, thingDef.Size)) { if (!BaseGenUtility.AnyDoorAdjacentCardinalTo(current2, map)) { continue; } nearDoor = true; break; } if (nearDoor) { continue; } //RESEARCH BENCH ThingDef stuff = null; if (thingDef.MadeFromStuff) { stuff = furnitureStuff; } var thing = ThingMaker.MakeThing(thingDef, stuff); thing.SetFaction(rp.faction); GenSpawn.Spawn(thing, current, map, rot); if (!thing.Spawned || !thing.Position.InBounds(map)) { continue; } //CHAIR var bld = thing as Building; //We need an interaction cell var thing2 = ThingMaker.MakeThing(chairDef, stuff); thing2.SetFaction(rp.faction); if (bld != null) { GenSpawn.Spawn(thing2, bld.InteractionCell, map, rot); } } var corners = new List <int> { 0, 1, 2, 3 }; foreach (var corner in corners.InRandomOrder()) { var loc = Utility.GetCornerPos(paramsIn.rect.ContractedBy(1), corner); if (GenSpawn.WouldWipeAnythingWith(loc, Rot4.South, lampDef, map, x => x.def.category == ThingCategory.Building)) { continue; } var singleThingDef3 = Utility.IsIndustrialAgeLoaded() ? lampDef : ThingDefOf.TorchLamp; var thing3 = ThingMaker.MakeThing(singleThingDef3, lampStuffDef); GenSpawn.Spawn(thing3, loc, map); } }
public static void FillWithGraves(ResolveParams rp) { Map map = BaseGen.globalSettings.map; ResolveParams cemetaryFences = rp; cemetaryFences.wallStuff = rp.wallStuff ?? BaseGenUtility.RandomCheapWallStuff(TechLevel.Medieval); cemetaryFences.chanceToSkipWallBlock = 0.125f; cemetaryFences.rect = rp.rect.ExpandedBy(1); BaseGen.symbolStack.Push("edgeWalls", cemetaryFences); bool @bool = Rand.Bool; ThingDef thingDef = ThingDefOf.Grave; ThingDef thingDef2; if ((thingDef2 = rp.singleThingStuff) == null) { thingDef2 = GenStuff.RandomStuffByCommonalityFor(thingDef, (rp.faction == null) ? TechLevel.Undefined : rp.faction.def.techLevel); } ThingDef singleThingStuff = thingDef2; foreach (IntVec3 intVec in rp.rect) { if (@bool) { if (intVec.x % 3 != 0 || intVec.z % 2 != 0) { continue; } } else if (intVec.x % 2 != 0 || intVec.z % 3 != 0) { continue; } Rot4 rot = (!@bool) ? Rot4.North : Rot4.West; if (!GenSpawn.WouldWipeAnythingWith(intVec, rot, thingDef, map, (Thing x) => x.def.category == ThingCategory.Building)) { if (!BaseGenUtility.AnyDoorAdjacentCardinalTo(GenAdj.OccupiedRect(intVec, rot, thingDef.Size), map)) { if (Rand.Value < 0.3f) { ResolveParams resolveParams = rp; resolveParams.rect = GenAdj.OccupiedRect(intVec, rot, thingDef.size); resolveParams.singleThingDef = thingDef; resolveParams.singleThingStuff = singleThingStuff; resolveParams.thingRot = new Rot4?(rot); ThingDef singleThingDef = rp.singleThingDef ?? ThingDefOf.Grave; ResolveParams graveParams = rp; graveParams.singleThingDef = singleThingDef; bool?skipSingleThingIfHasToWipeBuildingOrDoesntFit = rp.skipSingleThingIfHasToWipeBuildingOrDoesntFit; graveParams.skipSingleThingIfHasToWipeBuildingOrDoesntFit = new bool?( skipSingleThingIfHasToWipeBuildingOrDoesntFit == null || skipSingleThingIfHasToWipeBuildingOrDoesntFit.Value); graveParams.postThingSpawn = delegate(Thing x) { if (x is Building_Grave g) { var pawnKindDef = DefDatabase <PawnKindDef> .AllDefs.Where(y => y?.defaultFactionType?.isPlayer == false && y?.race?.defName == "Human") .RandomElement(); var factionDef = DefDatabase <FactionDef> .AllDefs .Where(z => z.humanlikeFaction && !z.isPlayer).RandomElement(); var faction = Find.FactionManager.FirstFactionOfDef(factionDef); if (Rand.Value < 0.8f) { Pawn pawnToFillWith = PawnGenerator.GeneratePawn(pawnKindDef, faction); if (pawnToFillWith.IsVampire()) { pawnToFillWith.Destroy(); return; } pawnToFillWith.Kill(null); if (pawnToFillWith.Corpse is Corpse c) { c.SetForbidden(true); g.TryGetInnerInteractableThingOwner().TryAdd(c); } } } }; BaseGen.symbolStack.Push("thing", graveParams); } } } } ResolveParams resolveParams2 = rp; resolveParams2.floorDef = TerrainDef.Named("SoilRich"); BaseGen.symbolStack.Push("floor", resolveParams2); }
public override void PassingParameters(ResolveParams paramsIn) { string defBench = "TableLong"; string defChair = "DiningChair"; string defLamp = "Jecrell_GasLamp"; ThingDef lampDef = Cthulhu.Utility.IsIndustrialAgeLoaded() ? ThingDef.Named(defLamp) : ThingDefOf.TorchLamp; ThingDef furnitureStuff = ThingDefOf.Steel; ThingDef lampStuffDef = Cthulhu.Utility.IsIndustrialAgeLoaded() ? ThingDefOf.Steel : null; ResolveParams rp = paramsIn; rp.rect = paramsIn.rect.ContractedBy(3); Map map = BaseGen.globalSettings.map; bool @bool = Rand.Bool; ThingDef thingDef = ThingDef.Named(defBench); ThingDef chairDef = ThingDef.Named(defChair); foreach (IntVec3 current in rp.rect) { if (@bool) { if (current.x % 4 != 0 || current.z % 4 != 0) { continue; } } else if (current.x % 4 != 0 || current.z % 4 != 0) { continue; } Rot4 rot = Rot4.Random; if (!GenSpawn.WouldWipeAnythingWith(current, rot, thingDef, map, (Thing x) => x.def.category == ThingCategory.Building)) { bool flag = false; foreach (IntVec3 current2 in GenAdj.CellsOccupiedBy(current, rot, thingDef.Size)) { if (BaseGenUtility.AnyDoorAdjacentCardinalTo(current2, map)) { flag = true; break; } } if (!flag) { ///TABLE ThingDef stuff = null; if (thingDef.MadeFromStuff) { stuff = furnitureStuff; } Thing thing = ThingMaker.MakeThing(thingDef, stuff); thing.SetFaction(rp.faction, null); GenSpawn.Spawn(thing, current, map, rot); if (thing != null) { if (thing.Spawned && thing.Position.InBounds(map)) { CellRect rectToEdit = thing.OccupiedRect().ExpandedBy(1); List <IntVec3> poss = new List <IntVec3>(); poss.AddRange(rectToEdit.GetEdgeCells(Rot4.North)); poss.AddRange(rectToEdit.GetEdgeCells(Rot4.South)); poss.AddRange(rectToEdit.GetEdgeCells(Rot4.East)); poss.AddRange(rectToEdit.GetEdgeCells(Rot4.West)); poss.Remove(Cthulhu.Utility.GetCornerPos(rectToEdit, 0)); poss.Remove(Cthulhu.Utility.GetCornerPos(rectToEdit, 1)); poss.Remove(Cthulhu.Utility.GetCornerPos(rectToEdit, 2)); poss.Remove(Cthulhu.Utility.GetCornerPos(rectToEdit, 3)); for (int i = 0; i < 4; i++) { ///CHAIR IntVec3 currentPos = poss.InRandomOrder <IntVec3>().RandomElement <IntVec3>(); poss.Remove(currentPos); Rot4 newRot = Rot4.North; if (currentPos.x > thing.Position.x) { newRot = Rot4.West; } else if (currentPos.x < thing.Position.x) { newRot = Rot4.East; } else if (currentPos.z > thing.Position.z) { newRot = Rot4.South; } else { newRot = Rot4.North; } Building bld = thing as Building; //We need an interaction cell Thing thing2 = ThingMaker.MakeThing(chairDef, stuff); thing2.SetFaction(rp.faction, null); GenSpawn.Spawn(thing2, currentPos, map, newRot); } } } } } } List <int> corners = new List <int>() { 0, 1, 2, 3 }; int count = 0; foreach (int corner in corners.InRandomOrder <int>()) { if (count == 1) { break; } IntVec3 loc = Cthulhu.Utility.GetCornerPos(paramsIn.rect.ContractedBy(1), corner); if (!GenSpawn.WouldWipeAnythingWith(loc, Rot4.South, lampDef, map, (Thing x) => x.def.category == ThingCategory.Building)) { ThingDef singleThingDef3 = (Cthulhu.Utility.IsIndustrialAgeLoaded()) ? lampDef : ThingDefOf.TorchLamp; Thing thing3 = ThingMaker.MakeThing(singleThingDef3, lampStuffDef); GenSpawn.Spawn(thing3, loc, map); } count++; } }
public override void PassingParameters(ResolveParams rp) { var map = BaseGen.globalSettings.map; var @bool = Rand.Bool; var defTypewriter = "Estate_TableTypewriter"; var defBench = "SimpleResearchBench"; var defChair = "DiningChair"; var defLamp = "Jecrell_GasLamp"; var wallDef = ThingDefOf.Steel; var floorDef = TerrainDefOf.MetalTile; var lampDef = Utility.IsIndustrialAgeLoaded() ? ThingDef.Named(defLamp) : ThingDefOf.TorchLamp; var lampStuffDef = Utility.IsIndustrialAgeLoaded() ? ThingDefOf.Steel : null; var thingDef = rp.singleThingDef ?? (Utility.IsIndustrialAgeLoaded() ? ThingDef.Named(defTypewriter) : ThingDef.Named(defBench)); var chairDef = ThingDef.Named(defChair); var rot = !@bool ? Rot4.South : Rot4.West; var loc = rp.rect.CenterCell; if (!GenSpawn.WouldWipeAnythingWith(loc, rot, thingDef, map, x => x.def.category == ThingCategory.Building)) { var doorNear = false; foreach (var current2 in GenAdj.CellsOccupiedBy(loc, rot, thingDef.Size)) { if (!BaseGenUtility.AnyDoorAdjacentCardinalTo(current2, map)) { continue; } doorNear = true; break; } if (!doorNear) { //RESEARCH BENCH ThingDef stuff = null; if (thingDef.MadeFromStuff) { stuff = ThingDefOf.WoodLog; } var thing = ThingMaker.MakeThing(thingDef, stuff); thing.SetFaction(rp.faction); GenSpawn.Spawn(thing, loc, map, rot); if (thing.Spawned && thing.Position != IntVec3.Invalid) { //CHAIR var bld = thing as Building; //We need an interaction cell var thing2 = ThingMaker.MakeThing(chairDef, stuff); thing2.SetFaction(rp.faction); if (bld != null) { GenSpawn.Spawn(thing2, bld.InteractionCell, map, rot.Opposite); } } //Adjacent lamps var singleThingDef3 = Utility.IsIndustrialAgeLoaded() ? lampDef : ThingDefOf.TorchLamp; var thing3 = ThingMaker.MakeThing(singleThingDef3, lampStuffDef); var thingLoc = Utility.GetCornerPos(thing.OccupiedRect(), 0) + GenAdj.AdjacentCells[Rot4.West.AsInt]; GenSpawn.Spawn(thing3, thingLoc, map); } } UnfogRoomCenter(rp.rect.CenterCell); FactionUtility.RectReport(rp.rect); }
public override void PassingParameters(ResolveParams rp) { var defChair = "DiningChair"; var defLamp = "Jecrell_GasLamp"; var lampDef = Utility.IsIndustrialAgeLoaded() ? ThingDef.Named(defLamp) : ThingDefOf.TorchLamp; var lampStuffDef = Utility.IsIndustrialAgeLoaded() ? ThingDefOf.Steel : null; var map = BaseGen.globalSettings.map; var @bool = Rand.Bool; var hasLamp = false; var thingDef = ThingDefOf.Bed; var chairDef = ThingDef.Named(defChair); foreach (var current in rp.rect) { if (@bool) { if (current.x % 3 != 0 || current.z % 3 != 0) { continue; } } else if (current.x % 3 != 0 || current.z % 3 != 0) { continue; } var rot = !@bool ? Rot4.South : Rot4.West; if (GenSpawn.WouldWipeAnythingWith(current, rot, thingDef, map, x => x.def.category == ThingCategory.Building)) { continue; } var doorNear = false; foreach (var current2 in GenAdj.CellsOccupiedBy(current, rot, thingDef.Size)) { if (!BaseGenUtility.AnyDoorAdjacentCardinalTo(current2, map)) { continue; } doorNear = true; break; } if (doorNear) { continue; } //Bed ThingDef stuff = null; if (thingDef.MadeFromStuff) { stuff = ThingDefOf.WoodLog; } var thing = ThingMaker.MakeThing(thingDef, stuff); thing.SetFaction(rp.faction); GenSpawn.Spawn(thing, current, map, rot); if (!thing.Spawned || !thing.Position.InBounds(map)) { continue; } var thingRect = thing.OccupiedRect(); thingRect = thingRect.ExpandedBy(1); var possibleCells = new List <IntVec3>(); possibleCells.AddRange(thingRect.GetEdgeCells(Rot4.North)); possibleCells.AddRange(thingRect.GetEdgeCells(Rot4.South)); possibleCells.AddRange(thingRect.GetEdgeCells(Rot4.East)); possibleCells.AddRange(thingRect.GetEdgeCells(Rot4.West)); possibleCells.Remove(Utility.GetCornerPos(thingRect, 0)); possibleCells.Remove(Utility.GetCornerPos(thingRect, 1)); possibleCells.Remove(Utility.GetCornerPos(thingRect, 2)); possibleCells.Remove(Utility.GetCornerPos(thingRect, 3)); var spawnPos = possibleCells.FirstOrDefault(x => x.InBounds(map) && x.Walkable(map)); possibleCells.Remove(spawnPos); var thing2 = ThingMaker.MakeThing(chairDef, stuff); thing2.SetFaction(rp.faction); GenSpawn.Spawn(thing2, spawnPos, map, rot.Opposite); if (hasLamp) { continue; } hasLamp = true; spawnPos = possibleCells.FirstOrDefault(x => x.InBounds(map) && x.Walkable(map)); possibleCells.Remove(spawnPos); var thing3 = ThingMaker.MakeThing(lampDef, lampStuffDef); thing3.SetFaction(rp.faction); GenSpawn.Spawn(thing3, spawnPos, map, rot.Opposite); } //List<int> corners = new List<int>() { 0, 1, 2, 3 }; //foreach (int corner in corners.InRandomOrder<int>()) //{ // IntVec3 loc = Cthulhu.Utility.GetCornerPos(rp.rect.ContractedBy(1), corner); // if (!GenSpawn.WouldWipeAnythingWith(loc, Rot4.South, lampDef, map, (Thing x) => x.def.category == ThingCategory.Building)) // { // ThingDef singleThingDef3 = (Cthulhu.Utility.IsIndustrialAgeLoaded()) ? lampDef : ThingDefOf.TorchLamp; // Thing thing3 = ThingMaker.MakeThing(singleThingDef3, ThingDefOf.Steel); // GenSpawn.Spawn(thing3, loc, map); // break; // } //} }
public override void Resolve(ResolveParams rp) { var stoveElectric = DefDatabase <ThingDef> .GetNamedSilentFail("ElectricStove"); var stoveFueled = DefDatabase <ThingDef> .GetNamedSilentFail("FueledStove"); var tableButcher = DefDatabase <ThingDef> .GetNamedSilentFail("TableButcher"); var spotButcher = DefDatabase <ThingDef> .GetNamedSilentFail("ButcherSpot"); var map = BaseGen.globalSettings.map; ThingDef thingDef; if (rp.singleThingDef != null) { thingDef = rp.singleThingDef; } else if (rp.faction != null && rp.faction.def.techLevel >= TechLevel.Medieval) { thingDef = stoveElectric; } else { thingDef = Rand.Element(stoveFueled, ThingDefOf.Campfire, spotButcher); } var flipACoin = Rand.Bool; foreach (var potentialSpot in rp.rect) { if (flipACoin) { if (potentialSpot.x % 3 != 0 || potentialSpot.z % 2 != 0) { continue; } } else if (potentialSpot.x % 2 != 0 || potentialSpot.z % 3 != 0) { continue; } var rot = !flipACoin ? Rot4.North : Rot4.West; if (GenSpawn.WouldWipeAnythingWith(potentialSpot, rot, thingDef, map, x => x.def.category == ThingCategory.Building)) { continue; } var dontTouchMe = new IntVec2(thingDef.Size.x + 1, thingDef.Size.z + 1); if (BaseGenUtility.AnyDoorAdjacentCardinalTo( GenAdj.OccupiedRect(potentialSpot, rot, dontTouchMe), map)) { continue; } var resolveParams = rp; resolveParams.rect = GenAdj.OccupiedRect(potentialSpot, rot, thingDef.Size); resolveParams.singleThingDef = Rand.Element(thingDef, tableButcher); resolveParams.thingRot = rot; var skipSingleThingIfHasToWipeBuildingOrDoesntFit = rp.skipSingleThingIfHasToWipeBuildingOrDoesntFit; resolveParams.skipSingleThingIfHasToWipeBuildingOrDoesntFit = !skipSingleThingIfHasToWipeBuildingOrDoesntFit.HasValue || skipSingleThingIfHasToWipeBuildingOrDoesntFit.Value; BaseGen.symbolStack.Push("thing", resolveParams); } }
public override void PassingParameters(ResolveParams rp) { Map map = BaseGen.globalSettings.map; bool @bool = Rand.Bool; string defTypewriter = "Estate_TableTypewriter"; string defBench = "SimpleResearchBench"; string defChair = "DiningChair"; string defLamp = "Jecrell_GasLamp"; ThingDef wallDef = ThingDefOf.Steel; TerrainDef floorDef = TerrainDefOf.MetalTile; ThingDef lampDef = Cthulhu.Utility.IsIndustrialAgeLoaded() ? ThingDef.Named(defLamp) : ThingDefOf.TorchLamp; ThingDef lampStuffDef = Cthulhu.Utility.IsIndustrialAgeLoaded() ? ThingDefOf.Steel : null; ThingDef thingDef = rp.singleThingDef ?? ((Cthulhu.Utility.IsIndustrialAgeLoaded()) ? ThingDef.Named(defTypewriter) : ThingDef.Named(defBench)); ThingDef chairDef = ThingDef.Named(defChair); Rot4 rot = (!@bool) ? Rot4.South : Rot4.West; IntVec3 loc = rp.rect.CenterCell; if (!GenSpawn.WouldWipeAnythingWith(loc, rot, thingDef, map, (Thing x) => x.def.category == ThingCategory.Building)) { bool flag = false; foreach (IntVec3 current2 in GenAdj.CellsOccupiedBy(loc, rot, thingDef.Size)) { if (BaseGenUtility.AnyDoorAdjacentCardinalTo(current2, map)) { flag = true; break; } } if (!flag) { ///RESEARCH BENCH ThingDef stuff = null; if (thingDef.MadeFromStuff) { stuff = ThingDefOf.WoodLog; } Thing thing = ThingMaker.MakeThing(thingDef, stuff); thing.SetFaction(rp.faction, null); GenSpawn.Spawn(thing, loc, map, rot); if (thing != null) { if (thing.Spawned && thing.Position != IntVec3.Invalid) { ///CHAIR Building bld = thing as Building; //We need an interaction cell Thing thing2 = ThingMaker.MakeThing(chairDef, stuff); thing2.SetFaction(rp.faction, null); GenSpawn.Spawn(thing2, bld.InteractionCell, map, rot.Opposite); } ///Adjacent lamps ThingDef singleThingDef3 = (Cthulhu.Utility.IsIndustrialAgeLoaded()) ? lampDef : ThingDefOf.TorchLamp; Thing thing3 = ThingMaker.MakeThing(singleThingDef3, lampStuffDef); IntVec3 thingLoc = Cthulhu.Utility.GetCornerPos(thing.OccupiedRect(), 0) + GenAdj.AdjacentCells[Rot4.West.AsInt]; GenSpawn.Spawn(thing3, thingLoc, map); } } } UnfogRoomCenter(rp.rect.CenterCell); Utility.RectReport(rp.rect); }
public override void PassingParameters(ResolveParams rp) { var defChair = "DiningChair"; var defLamp = "Jecrell_GasLamp"; var lampDef = Utility.IsIndustrialAgeLoaded() ? ThingDef.Named(defLamp) : ThingDefOf.TorchLamp; var lampStuffDef = Utility.IsIndustrialAgeLoaded() ? ThingDefOf.Steel : null; var map = BaseGen.globalSettings.map; var @bool = Rand.Bool; var hasLamp = false; var thingDef = ThingDefOf.SleepingSpot; var chairDef = ThingDef.Named(defChair); foreach (var current in rp.rect) { if (@bool) { if (current.x % 3 != 0 || current.z % 3 != 0) { continue; } } else if (current.x % 3 != 0 || current.z % 3 != 0) { continue; } var rot = !@bool ? Rot4.South : Rot4.West; if (GenSpawn.WouldWipeAnythingWith(current, rot, thingDef, map, x => x.def.category == ThingCategory.Building)) { continue; } { var doorNear = false; foreach (var current2 in GenAdj.CellsOccupiedBy(current, rot, thingDef.Size)) { if (!BaseGenUtility.AnyDoorAdjacentCardinalTo(current2, map)) { continue; } doorNear = true; break; } if (doorNear) { continue; } //Bed ThingDef stuff = null; if (thingDef.MadeFromStuff) { stuff = ThingDefOf.WoodLog; } var thing = ThingMaker.MakeThing(thingDef, stuff); thing.SetFaction(rp.faction); GenSpawn.Spawn(thing, current, map, rot); if (!thing.Spawned || !thing.Position.InBounds(map)) { continue; } var thingRect = thing.OccupiedRect(); thingRect = thingRect.ExpandedBy(1); var possibleCells = new List <IntVec3>(); possibleCells.AddRange(thingRect.GetEdgeCells(Rot4.North)); possibleCells.AddRange(thingRect.GetEdgeCells(Rot4.South)); possibleCells.AddRange(thingRect.GetEdgeCells(Rot4.East)); possibleCells.AddRange(thingRect.GetEdgeCells(Rot4.West)); possibleCells.Remove(Utility.GetCornerPos(thingRect, 0)); possibleCells.Remove(Utility.GetCornerPos(thingRect, 1)); possibleCells.Remove(Utility.GetCornerPos(thingRect, 2)); possibleCells.Remove(Utility.GetCornerPos(thingRect, 3)); var spawnPos = possibleCells.InRandomOrder() .FirstOrDefault(x => x.InBounds(map) && x.Walkable(map)); possibleCells.Remove(spawnPos); var thing2 = ThingMaker.MakeThing(chairDef, ThingDefOf.WoodLog); thing2.SetFaction(rp.faction); GenSpawn.Spawn(thing2, spawnPos, map, rot.Opposite); if (hasLamp) { continue; } hasLamp = true; spawnPos = possibleCells.FirstOrDefault(x => x.InBounds(map) && x.Walkable(map)); possibleCells.Remove(spawnPos); var thing3 = ThingMaker.MakeThing(lampDef, lampStuffDef); thing3.SetFaction(rp.faction); GenSpawn.Spawn(thing3, spawnPos, map, rot.Opposite); } } //if (!Cthulhu.Utility.IsCosmicHorrorsLoaded()) //{ var unused = rp.pawnGroupKindDef ?? PawnGroupKindDefOf.Combat; var pawnGroupMakerParms = new PawnGroupMakerParms { faction = (from x in Find.FactionManager.AllFactions where x.HostileTo(rp.faction) && x.def.pawnGroupMakers is { Count : > 0 } && x.def.humanlikeFaction &&
private bool IsRotationValid(IntVec3 loc, Rot4 rot, Map map) { return(GenAdj.OccupiedRect(loc, rot, this.thingDef.size).InBounds(map) && !GenSpawn.WouldWipeAnythingWith(loc, rot, this.thingDef, map, (Thing x) => x.def == this.thingDef || (x.def.category != ThingCategory.Plant && x.def.category != ThingCategory.Filth))); }