public void ChangeDestToMissWild()
 {
     if ((double)(this.dest - this.source).LengthHorizontal < 2.5)
     {
         IntVec3 b = IntVec3.FromVector3((this.dest - this.source).ToVector3().normalized * 2f);
         this.dest += b;
     }
     this.dest = this.dest.RandomAdjacentCell8Way();
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }