public static void PlaceWaitingBuildings() { GenConstruct_CanPlaceBlueprintAt_Patch.Mode = BlueprintMode.Place; foreach (RemoveRoofModel model in _removeRoofModels) { foreach (Thing thing in model.WaitingThings.ToList()) { if (thing.DestroyedOrNull() || thing.MapHeld != model.Map) { model.WaitingThings.Remove(thing); continue; } IntVec3 deltaCell = GetDeltaCell(thing, model.MousePos, model.GhostPosition); Thing inner = thing.GetInnerIfMinified(); if (GenConstruct.CanPlaceBlueprintAt(inner.def, deltaCell, inner.Rotate(model.Rotation), inner.MapHeld, thing: inner).Accepted) { if (thing is MinifiedThing minifiedThing) { GenConstruct.PlaceBlueprintForInstall(minifiedThing, deltaCell, minifiedThing.MapHeld, inner.Rotate(model.Rotation), Faction.OfPlayer); } else { GenConstruct.PlaceBlueprintForReinstall(thing as Building, deltaCell, thing.MapHeld, thing.Rotate(model.Rotation), Faction.OfPlayer); } model.WaitingThings.Remove(thing); } } } }
public static Blueprint_Install BlueprintInstall(this Thing wanted, Pawn pawn, IntVec3 vec3, Room room, Rot4 rot) { Blueprint_Install bp; if (wanted is MinifiedThing minifiedThing) { bp = GenConstruct.PlaceBlueprintForInstall(minifiedThing, vec3, room.Map, rot, pawn.Faction); } else { bp = GenConstruct.PlaceBlueprintForReinstall((Building) wanted, vec3, room.Map, rot, pawn.Faction); } return bp; }
public override void DesignateSingleCell(IntVec3 c) { if (_mode == Mode.Select) { List <Thing> things = this.ReinstallableInCell(c); if (things.Any()) { if (_originFound == false) { _originFound = true; _origin = c; } DesignatedThings.AddRange(things); things.ForEach(thing => DesignateThing(thing)); } } else if (_mode == Mode.Place) { GenConstruct_CanPlaceBlueprintAt_Patch.Mode = BlueprintMode.Place; HashSet <Thing> placedThings = new HashSet <Thing>(); Dictionary <Thing, Thing> twinThings = new Dictionary <Thing, Thing>(); Dictionary <Thing, Blueprint_Install> blueprintWork = new Dictionary <Thing, Blueprint_Install>(); Dictionary <Thing, IntVec3> siblingWork = new Dictionary <Thing, IntVec3>(); IntVec3 mousePos = UI.MouseCell(); foreach (Thing designatedThing in DesignatedThings) { IntVec3 drawCell = GetDeltaCell(designatedThing, mousePos, _ghostPos); List <Thing> things = drawCell.GetThingList(designatedThing.MapHeld); bool foundTwin = false; bool foundSibling = false; foreach (Thing thingOnCell in things) { if (DesignatedThings.Contains(thingOnCell)) { if (designatedThing.IdenticalWith(_rotation, thingOnCell)) { if (blueprintWork.TryGetValue(thingOnCell, out Blueprint_Install install)) { Thing twin = this.GetTailInTwinThings(twinThings, designatedThing); _setBuildingToReinstall.Invoke(install, new[] { twin }); blueprintWork[twin] = install; blueprintWork.Remove(thingOnCell); placedThings.Add(twin); } else if (siblingWork.TryGetValue(thingOnCell, out IntVec3 position)) { Thing twin = this.GetTailInTwinThings(twinThings, designatedThing); _ghostPos[twin] = position; siblingWork.Remove(thingOnCell); siblingWork[twin] = position; placedThings.Add(thingOnCell); } else { twinThings[thingOnCell] = designatedThing; _ghostPos[designatedThing] = _ghostPos[thingOnCell]; placedThings.Add(thingOnCell); } this.Map.designationManager.TryRemoveDesignationOn(thingOnCell, MoveBaseDefOf.MoveBase); foundTwin = true; break; } else if (!GenConstruct.BlocksConstruction(designatedThing, thingOnCell)) { continue; } else { foundSibling = true; Thing twin = this.GetTailInTwinThings(twinThings, designatedThing); siblingWork[twin] = _ghostPos[twin] = _ghostPos[designatedThing]; break; } } } if (foundTwin || foundSibling) { continue; } Thing twin1 = this.GetTailInTwinThings(twinThings, designatedThing); AcceptanceReport report = GenConstruct.CanPlaceBlueprintAt( twin1.def , drawCell , GetRotation(twin1) , twin1.MapHeld , false , null , twin1); if (report.Accepted) { Building building = twin1 as Building; blueprintWork[building] = GenConstruct.PlaceBlueprintForReinstall(building, drawCell, building.MapHeld, GetRotation(building), Faction.OfPlayer); placedThings.Add(building); } } RemoveRoofModel model = InitModel( DesignatedThings , DesignatedThings.Except(placedThings).ToList() , DesignatedThings.First().MapHeld , mousePos , _rotation , _ghostPos); ResolveDeadLock(model); this.KeepDesignation = true; _mode = Mode.Select; Find.DesignatorManager.Deselect(); } }