public static ReplaceFrame PlaceReplaceFrame(Thing oldThing, ThingDef stuff) { ThingDef replaceFrameDef = ThingDefGenerator_ReplaceFrame.ReplaceFrameDefFor(oldThing.def); if (replaceFrameDef == null) { return(null); } if (oldThing.Position.GetFirstThing(oldThing.Map, replaceFrameDef) != null) { return(null); } ReplaceFrame replaceFrame = (ReplaceFrame)ThingMaker.MakeThing(replaceFrameDef, stuff); //QualityBuilder if (QBTypes.qbDesDef != null && replaceFrame.def.HasComp(QBTypes.compQBType)) { oldThing.Map.designationManager.AddDesignation(new Designation(replaceFrame, QBTypes.qbDesDef)); } replaceFrame.SetFactionDirect(Faction.OfPlayer); replaceFrame.oldThing = oldThing; replaceFrame.oldStuff = oldThing.Stuff; GenSpawn.Spawn(replaceFrame, oldThing.Position, oldThing.Map, oldThing.Rotation); return(replaceFrame); }
public static ReplaceFrame PlaceReplaceFrame(Thing oldThing, ThingDef stuff) { ThingDef replaceFrameDef = ThingDefGenerator_ReplaceFrame.ReplaceFrameDefFor(oldThing.def); if (replaceFrameDef == null) { return(null); } if (oldThing.Position.GetFirstThing(oldThing.Map, replaceFrameDef) != null) { return(null); } ReplaceFrame replaceFrame = (ReplaceFrame)ThingMaker.MakeThing(replaceFrameDef, stuff); //QualityBuilder if (DefDatabase <DesignationDef> .GetNamed("SkilledBuilder", false) is DesignationDef d && AccessTools.TypeByName("CompQualityBuilder") is Type qbType && replaceFrame.def.HasComp(qbType)) { oldThing.Map.designationManager.AddDesignation(new Designation(replaceFrame, d)); } replaceFrame.SetFactionDirect(Faction.OfPlayer); replaceFrame.oldThing = oldThing; replaceFrame.oldStuff = oldThing.Stuff; GenSpawn.Spawn(replaceFrame, oldThing.Position, oldThing.Map, oldThing.Rotation); return(replaceFrame); }