public static List <Thing> ThingsUnderMouse(Vector3 clickPos, float pawnWideClickRadius, TargetingParameters clickParams) { IntVec3 c = IntVec3.FromVector3(clickPos); List <Thing> list = new List <Thing>(); GenUI.clickedPawns.Clear(); List <Pawn> allPawnsSpawned = Find.VisibleMap.mapPawns.AllPawnsSpawned; for (int i = 0; i < allPawnsSpawned.Count; i++) { Pawn pawn = allPawnsSpawned[i]; if ((pawn.DrawPos - clickPos).MagnitudeHorizontal() < 0.4f && clickParams.CanTarget(pawn)) { GenUI.clickedPawns.Add(pawn); } } GenUI.clickedPawns.Sort(new Comparison <Pawn>(GenUI.CompareThingsByDistanceToMousePointer)); for (int j = 0; j < GenUI.clickedPawns.Count; j++) { list.Add(GenUI.clickedPawns[j]); } List <Thing> list2 = new List <Thing>(); foreach (Thing current in Find.VisibleMap.thingGrid.ThingsAt(c)) { if (!list.Contains(current) && clickParams.CanTarget(current)) { list2.Add(current); } } list2.Sort(new Comparison <Thing>(GenUI.CompareThingsByDrawAltitude)); list.AddRange(list2); GenUI.clickedPawns.Clear(); List <Pawn> allPawnsSpawned2 = Find.VisibleMap.mapPawns.AllPawnsSpawned; for (int k = 0; k < allPawnsSpawned2.Count; k++) { Pawn pawn2 = allPawnsSpawned2[k]; if ((pawn2.DrawPos - clickPos).MagnitudeHorizontal() < pawnWideClickRadius && clickParams.CanTarget(pawn2)) { GenUI.clickedPawns.Add(pawn2); } } GenUI.clickedPawns.Sort(new Comparison <Pawn>(GenUI.CompareThingsByDistanceToMousePointer)); for (int l = 0; l < GenUI.clickedPawns.Count; l++) { if (!list.Contains(GenUI.clickedPawns[l])) { list.Add(GenUI.clickedPawns[l]); } } list.RemoveAll((Thing t) => !t.Spawned); GenUI.clickedPawns.Clear(); return(list); }
public static IEnumerable <LocalTargetInfo> TargetsAt(Vector3 clickPos, TargetingParameters clickParams, bool thingsOnly = false) { List <Thing> clickableList = GenUI.ThingsUnderMouse(clickPos, 0.8f, clickParams); int i = 0; if (i < clickableList.Count) { yield return((LocalTargetInfo)clickableList[i]); /*Error: Unable to find new state assignment for yield return*/; } if (thingsOnly) { yield break; } IntVec3 cellTarg = UI.MouseCell(); if (!cellTarg.InBounds(Find.VisibleMap)) { yield break; } if (!clickParams.CanTarget(new TargetInfo(cellTarg, Find.VisibleMap, false))) { yield break; } yield return((LocalTargetInfo)cellTarg); /*Error: Unable to find new state assignment for yield return*/; }
public static IEnumerable <LocalTargetInfo> TargetsAt(Vector3 clickPos, TargetingParameters clickParams, bool thingsOnly = false) { List <Thing> clickableList = GenUI.ThingsUnderMouse(clickPos, 0.8f, clickParams); for (int i = 0; i < clickableList.Count; i++) { yield return(clickableList[i]); } if (!thingsOnly) { IntVec3 cellTarg = UI.MouseCell(); if (cellTarg.InBounds(Find.VisibleMap) && clickParams.CanTarget(new TargetInfo(cellTarg, Find.VisibleMap, false))) { yield return(cellTarg); } } }
public static IEnumerable <LocalTargetInfo> TargetsAt_NewTemp(Vector3 clickPos, TargetingParameters clickParams, bool thingsOnly = false, ITargetingSource source = null) { List <Thing> clickableList = ThingsUnderMouse(clickPos, 0.8f, clickParams); Thing caster = source?.Caster; for (int i = 0; i < clickableList.Count; i++) { Pawn pawn = clickableList[i] as Pawn; if (pawn == null || !pawn.IsInvisible() || caster == null || caster.Faction == pawn.Faction) { yield return(clickableList[i]); } } if (!thingsOnly) { IntVec3 intVec = UI.MouseCell(); if (intVec.InBounds(Find.CurrentMap) && clickParams.CanTarget(new TargetInfo(intVec, Find.CurrentMap))) { yield return(intVec); } } }
public static List <Thing> ThingsUnderMouse(Vector3 clickPos, float pawnWideClickRadius, TargetingParameters clickParams) { IntVec3 c = IntVec3.FromVector3(clickPos); List <Thing> list = new List <Thing>(); clickedPawns.Clear(); List <Pawn> allPawnsSpawned = Find.CurrentMap.mapPawns.AllPawnsSpawned; for (int i = 0; i < allPawnsSpawned.Count; i++) { Pawn pawn = allPawnsSpawned[i]; if ((pawn.DrawPos - clickPos).MagnitudeHorizontal() < 0.4f && clickParams.CanTarget(pawn)) { clickedPawns.Add(pawn); } } clickedPawns.Sort(CompareThingsByDistanceToMousePointer); for (int j = 0; j < clickedPawns.Count; j++) { list.Add(clickedPawns[j]); } List <Thing> list2 = new List <Thing>(); foreach (Thing item in Find.CurrentMap.thingGrid.ThingsAt(c)) { if (!list.Contains(item) && clickParams.CanTarget(item)) { list2.Add(item); } } List <Thing> list3 = Find.CurrentMap.listerThings.ThingsInGroup(ThingRequestGroup.WithCustomRectForSelector); for (int k = 0; k < list3.Count; k++) { Thing thing = list3[k]; if (thing.CustomRectForSelector.HasValue && thing.CustomRectForSelector.Value.Contains(c) && !list.Contains(thing) && clickParams.CanTarget(thing)) { list2.Add(thing); } } list2.Sort(CompareThingsByDrawAltitude); list.AddRange(list2); clickedPawns.Clear(); List <Pawn> allPawnsSpawned2 = Find.CurrentMap.mapPawns.AllPawnsSpawned; for (int l = 0; l < allPawnsSpawned2.Count; l++) { Pawn pawn2 = allPawnsSpawned2[l]; if ((pawn2.DrawPos - clickPos).MagnitudeHorizontal() < pawnWideClickRadius && clickParams.CanTarget(pawn2)) { clickedPawns.Add(pawn2); } } clickedPawns.Sort(CompareThingsByDistanceToMousePointer); for (int m = 0; m < clickedPawns.Count; m++) { if (!list.Contains(clickedPawns[m])) { list.Add(clickedPawns[m]); } } list.RemoveAll((Thing t) => !t.Spawned); clickedPawns.Clear(); return(list); }