public static Thing TryAnyMoteSpawn(this Vector3 loc, Map map, float rot, float scale, ThingDef moteDef, bool debug = false) { if (loc.ForbiddenMote(map)) { return(null); } //if(Pawn.story.bodyType == BodyTypeDefOf. if (moteDef == null) { if (debug) { Log.Warning("null mote"); } return(null); } Type moteType = moteDef.thingClass; if (moteType == typeof(CustomTransformation_Mote)) { CustomTransformation_Mote castedMote = (CustomTransformation_Mote)ThingMaker.MakeThing(moteDef); return(castedMote.FinalizeMoteSpawn(loc, map, rot, scale)); } else if (moteType == typeof(MoteThrown)) { MoteThrown castedMote = (MoteThrown)ThingMaker.MakeThing(moteDef); return(castedMote.FinalizeMoteSpawn(loc, map, rot, scale)); } return(null); }