public static bool IsNewThingReplacement(this ThingDef newDef, IntVec3 pos, Rot4 rotation, Map map, out Thing oldThing) { foreach (IntVec3 checkPos in GenAdj.OccupiedRect(pos, rotation, newDef.Size)) { foreach (Thing oThing in checkPos.GetThingList(map)) { if (newDef.CanReplace(oThing.def)) { oldThing = oThing; return(true); } } } oldThing = null; return(false); }
public static bool CanReplaceOldThing(this Thing newThing, Thing oldThing) { ThingDef newDef = GenConstruct.BuiltDefOf(newThing.def) as ThingDef; return(newDef?.CanReplace(oldThing.def) ?? false); }