public override void PostLoadSpecial(ThingDef parent) { if (parent.thingClass == typeof(Building_Bed)) { maxAssignedPawnsCount = BedUtility.GetSleepingSlotsCount(parent.size); } }
public static IntVec3 GetSleepingSlotPos(int index, IntVec3 bedCenter, Rot4 bedRot, IntVec2 bedSize) { int sleepingSlotsCount = BedUtility.GetSleepingSlotsCount(bedSize); if (index < 0 || index >= sleepingSlotsCount) { Log.Error(string.Concat(new object[] { "Tried to get sleeping slot pos with index ", index, ", but there are only ", sleepingSlotsCount, " sleeping slots available." }), false); return(bedCenter); } CellRect cellRect = GenAdj.OccupiedRect(bedCenter, bedRot, bedSize); if (bedRot == Rot4.North) { return(new IntVec3(cellRect.minX + index, bedCenter.y, cellRect.minZ)); } if (bedRot == Rot4.East) { return(new IntVec3(cellRect.minX, bedCenter.y, cellRect.maxZ - index)); } if (bedRot == Rot4.South) { return(new IntVec3(cellRect.minX + index, bedCenter.y, cellRect.maxZ)); } return(new IntVec3(cellRect.maxX, bedCenter.y, cellRect.maxZ - index)); }
public static bool CanPotentiallyLinkTo_Static(ThingDef facilityDef, IntVec3 facilityPos, Rot4 facilityRot, ThingDef myDef, IntVec3 myPos, Rot4 myRot) { CompProperties_Facility compProperties = facilityDef.GetCompProperties <CompProperties_Facility>(); if (compProperties.mustBePlacedAdjacent) { CellRect rect = GenAdj.OccupiedRect(myPos, myRot, myDef.size); CellRect rect2 = GenAdj.OccupiedRect(facilityPos, facilityRot, facilityDef.size); if (!GenAdj.AdjacentTo8WayOrInside(rect, rect2)) { return(false); } } if (compProperties.mustBePlacedAdjacentCardinalToBedHead) { if (!myDef.IsBed) { return(false); } CellRect other = GenAdj.OccupiedRect(facilityPos, facilityRot, facilityDef.size); bool flag = false; int sleepingSlotsCount = BedUtility.GetSleepingSlotsCount(myDef.size); for (int i = 0; i < sleepingSlotsCount; i++) { IntVec3 sleepingSlotPos = BedUtility.GetSleepingSlotPos(i, myPos, myRot, myDef.size); if (sleepingSlotPos.IsAdjacentToCardinalOrInside(other)) { flag = true; } } if (!flag) { return(false); } } if (!compProperties.mustBePlacedAdjacent && !compProperties.mustBePlacedAdjacentCardinalToBedHead) { Vector3 a = Gen.TrueCenter(myPos, myRot, myDef.size, myDef.Altitude); Vector3 b = Gen.TrueCenter(facilityPos, facilityRot, facilityDef.size, facilityDef.Altitude); if (Vector3.Distance(a, b) > compProperties.maxDistance) { return(false); } } return(true); }
public static IntVec3 GetSleepingSlotPos(int index, IntVec3 bedCenter, Rot4 bedRot, IntVec2 bedSize) { int sleepingSlotsCount = BedUtility.GetSleepingSlotsCount(bedSize); if (index >= 0 && index < sleepingSlotsCount) { CellRect cellRect = GenAdj.OccupiedRect(bedCenter, bedRot, bedSize); if (bedRot == Rot4.North) { return new IntVec3(cellRect.minX + index, bedCenter.y, cellRect.minZ); } if (bedRot == Rot4.East) { return new IntVec3(cellRect.minX, bedCenter.y, cellRect.maxZ - index); } if (bedRot == Rot4.South) { return new IntVec3(cellRect.minX + index, bedCenter.y, cellRect.maxZ); } return new IntVec3(cellRect.maxX, bedCenter.y, cellRect.maxZ - index); } Log.Error("Tried to get sleeping slot pos with index " + index + ", but there are only " + sleepingSlotsCount + " sleeping slots available."); return bedCenter; }
public IntVec3 GetSleepingSlotPos(int index) { return(BedUtility.GetSleepingSlotPos(index, base.Position, base.Rotation, this.def.size)); }