public static bool SpawnedOrAnyParentSpawned(IThingHolder holder) { return(ThingOwnerUtility.SpawnedParentOrMe(holder) != null); }
public static bool AnyParentIs <T>(Thing thing) where T : class, IThingHolder { return(ThingOwnerUtility.GetAnyParent <T>(thing) != null); }
public void GetChildHolders(List <IThingHolder> outChildren) { ThingOwnerUtility.AppendThingHoldersFromThings(outChildren, GetDirectlyHeldThings()); }
public void FaceTarget(LocalTargetInfo target) { if (!target.IsValid) { return; } if (target.HasThing) { Thing thing = (target.Thing.Spawned ? target.Thing : ThingOwnerUtility.GetFirstSpawnedParentThing(target.Thing)); if (thing == null || !thing.Spawned) { return; } bool flag = false; IntVec3 c = default(IntVec3); CellRect cellRect = thing.OccupiedRect(); for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { if (pawn.Position == new IntVec3(j, 0, i)) { Face(thing.DrawPos); return; } } } for (int k = cellRect.minZ; k <= cellRect.maxZ; k++) { for (int l = cellRect.minX; l <= cellRect.maxX; l++) { IntVec3 intVec = new IntVec3(l, 0, k); if (intVec.AdjacentToCardinal(pawn.Position)) { FaceAdjacentCell(intVec); return; } if (intVec.AdjacentTo8Way(pawn.Position)) { flag = true; c = intVec; } } } if (flag) { if (DebugViewSettings.drawPawnRotatorTarget) { pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.6f, "jbthing"); GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), c.ToVector3Shifted()); } FaceAdjacentCell(c); } else { Face(thing.DrawPos); } } else if (pawn.Position.AdjacentTo8Way(target.Cell)) { if (DebugViewSettings.drawPawnRotatorTarget) { pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.2f, "jbloc"); GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), target.Cell.ToVector3Shifted()); } FaceAdjacentCell(target.Cell); } else if (target.Cell.IsValid && target.Cell != pawn.Position) { Face(target.Cell.ToVector3()); } }