Example #1
0
        private void SelectAllMatchingObjectUnderMouseOnScreen()
        {
            List <object> list = this.SelectableObjectsUnderMouse().ToList <object>();

            if (list.Count == 0)
            {
                return;
            }
            Thing clickedThing = list.FirstOrDefault((object o) => o is Pawn && ((Pawn)o).Faction == Faction.OfPlayer && !((Pawn)o).IsPrisoner) as Thing;

            clickedThing = (list.FirstOrDefault((object o) => o is Pawn) as Thing);
            if (clickedThing == null)
            {
                clickedThing = ((from o in list
                                 where o is Thing && !((Thing)o).def.neverMultiSelect
                                 select o).FirstOrDefault <object>() as Thing);
            }
            Rect rect = new Rect(0f, 0f, (float)UI.screenWidth, (float)UI.screenHeight);

            if (clickedThing != null)
            {
                IEnumerable       enumerable = ThingSelectionUtility.MultiSelectableThingsInScreenRectDistinct(rect);
                Predicate <Thing> predicate  = delegate(Thing t)
                {
                    if (t.def != clickedThing.def || t.Faction != clickedThing.Faction || this.IsSelected(t))
                    {
                        return(false);
                    }
                    Pawn pawn = clickedThing as Pawn;
                    if (pawn != null)
                    {
                        Pawn pawn2 = t as Pawn;
                        if (pawn2.RaceProps != pawn.RaceProps)
                        {
                            return(false);
                        }
                        if (pawn2.HostFaction != pawn.HostFaction)
                        {
                            return(false);
                        }
                    }
                    return(true);
                };
                foreach (Thing obj in enumerable)
                {
                    if (predicate(obj))
                    {
                        this.Select(obj, true, true);
                    }
                }
                return;
            }
            if (list.FirstOrDefault((object o) => o is Zone && ((Zone)o).IsMultiselectable) == null)
            {
                return;
            }
            IEnumerable <Zone> enumerable2 = ThingSelectionUtility.MultiSelectableZonesInScreenRectDistinct(rect);

            foreach (Zone current in enumerable2)
            {
                if (!this.IsSelected(current))
                {
                    this.Select(current, true, true);
                }
            }
        }
Example #2
0
        private void SelectAllMatchingObjectUnderMouseOnScreen()
        {
            List <object> list = SelectableObjectsUnderMouse().ToList();

            if (list.Count == 0)
            {
                return;
            }
            Thing clickedThing = list.FirstOrDefault((object o) => o is Pawn && ((Pawn)o).Faction == Faction.OfPlayer && !((Pawn)o).IsPrisoner) as Thing;

            clickedThing = (list.FirstOrDefault((object o) => o is Pawn) as Thing);
            if (clickedThing == null)
            {
                clickedThing = (list.Where((object o) => o is Thing && !((Thing)o).def.neverMultiSelect).FirstOrDefault() as Thing);
            }
            Rect rect = new Rect(0f, 0f, UI.screenWidth, UI.screenHeight);

            if (clickedThing == null)
            {
                if (list.FirstOrDefault((object o) => o is Zone && ((Zone)o).IsMultiselectable) != null)
                {
                    foreach (Zone item in ThingSelectionUtility.MultiSelectableZonesInScreenRectDistinct(rect))
                    {
                        if (!IsSelected(item))
                        {
                            Select(item);
                        }
                    }
                }
            }
            else
            {
                IEnumerable <Thing> enumerable = ThingSelectionUtility.MultiSelectableThingsInScreenRectDistinct(rect);
                Predicate <Thing>   predicate  = delegate(Thing t)
                {
                    if (t.def != clickedThing.GetInnerIfMinified().def || t.Faction != clickedThing.Faction || IsSelected(t))
                    {
                        return(false);
                    }
                    Pawn pawn = clickedThing as Pawn;
                    if (pawn != null)
                    {
                        Pawn pawn2 = t as Pawn;
                        if (pawn2.RaceProps != pawn.RaceProps)
                        {
                            return(false);
                        }
                        if (pawn2.HostFaction != pawn.HostFaction)
                        {
                            return(false);
                        }
                    }
                    return(true);
                };
                foreach (Thing item2 in (IEnumerable)enumerable)
                {
                    if (predicate(item2.GetInnerIfMinified()))
                    {
                        Select(item2);
                    }
                }
            }
        }
Example #3
0
        private void SelectInsideDragBox()
        {
            if (!this.ShiftIsHeld)
            {
                this.ClearSelection();
            }
            bool         selectedSomething = false;
            List <Thing> list = Find.ColonistBar.MapColonistsOrCorpsesInScreenRect(this.dragBox.ScreenRect);

            for (int i = 0; i < list.Count; i++)
            {
                selectedSomething = true;
                this.Select(list[i], true, true);
            }
            if (selectedSomething)
            {
                return;
            }
            List <Caravan> list2 = Find.ColonistBar.CaravanMembersCaravansInScreenRect(this.dragBox.ScreenRect);

            for (int j = 0; j < list2.Count; j++)
            {
                if (!selectedSomething)
                {
                    CameraJumper.TryJumpAndSelect(list2[j]);
                    selectedSomething = true;
                }
                else
                {
                    Find.WorldSelector.Select(list2[j], true);
                }
            }
            if (selectedSomething)
            {
                return;
            }
            List <Thing> boxThings = ThingSelectionUtility.MultiSelectableThingsInScreenRectDistinct(this.dragBox.ScreenRect).ToList <Thing>();
            Func <Predicate <Thing>, bool> func = delegate(Predicate <Thing> predicate)
            {
                foreach (Thing current2 in from t in boxThings
                         where predicate(t)
                         select t)
                {
                    this.Select(current2, true, true);
                    selectedSomething = true;
                }
                return(selectedSomething);
            };
            Predicate <Thing> arg = (Thing t) => t.def.category == ThingCategory.Pawn && ((Pawn)t).RaceProps.Humanlike && t.Faction == Faction.OfPlayer;

            if (func(arg))
            {
                return;
            }
            Predicate <Thing> arg2 = (Thing t) => t.def.category == ThingCategory.Pawn && ((Pawn)t).RaceProps.Humanlike;

            if (func(arg2))
            {
                return;
            }
            Predicate <Thing> arg3 = (Thing t) => t.def.CountAsResource;

            if (func(arg3))
            {
                return;
            }
            Predicate <Thing> arg4 = (Thing t) => t.def.category == ThingCategory.Pawn;

            if (func(arg4))
            {
                return;
            }
            if (func((Thing t) => t.def.selectable))
            {
                return;
            }
            List <Zone> list3 = ThingSelectionUtility.MultiSelectableZonesInScreenRectDistinct(this.dragBox.ScreenRect).ToList <Zone>();

            foreach (Zone current in list3)
            {
                selectedSomething = true;
                this.Select(current, true, true);
            }
            if (selectedSomething)
            {
                return;
            }
            this.SelectUnderMouse();
        }
Example #4
0
        private void SelectAllMatchingObjectUnderMouseOnScreen()
        {
            List <object> list = SelectableObjectsUnderMouse().ToList();

            if (list.Count != 0)
            {
                Thing clickedThing = list.FirstOrDefault((object o) => o is Pawn && ((Pawn)o).Faction == Faction.OfPlayer && !((Pawn)o).IsPrisoner) as Thing;
                clickedThing = (list.FirstOrDefault((object o) => o is Pawn) as Thing);
                if (clickedThing == null)
                {
                    clickedThing = ((from o in list
                                     where o is Thing && !((Thing)o).def.neverMultiSelect
                                     select o).FirstOrDefault() as Thing);
                }
                Rect rect = new Rect(0f, 0f, (float)UI.screenWidth, (float)UI.screenHeight);
                if (clickedThing == null)
                {
                    object obj = list.FirstOrDefault((object o) => o is Zone && ((Zone)o).IsMultiselectable);
                    if (obj != null)
                    {
                        IEnumerable <Zone> enumerable = ThingSelectionUtility.MultiSelectableZonesInScreenRectDistinct(rect);
                        foreach (Zone item in enumerable)
                        {
                            if (!IsSelected(item))
                            {
                                Select(item);
                            }
                        }
                    }
                }
                else
                {
                    IEnumerable       enumerable2 = ThingSelectionUtility.MultiSelectableThingsInScreenRectDistinct(rect);
                    Predicate <Thing> predicate   = delegate(Thing t)
                    {
                        if (t.def != clickedThing.def || t.Faction != clickedThing.Faction || IsSelected(t))
                        {
                            return(false);
                        }
                        Pawn pawn = clickedThing as Pawn;
                        if (pawn != null)
                        {
                            Pawn pawn2 = t as Pawn;
                            if (pawn2.RaceProps != pawn.RaceProps)
                            {
                                return(false);
                            }
                            if (pawn2.HostFaction != pawn.HostFaction)
                            {
                                return(false);
                            }
                        }
                        return(true);
                    };
                    IEnumerator enumerator2 = enumerable2.GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            Thing obj2 = (Thing)enumerator2.Current;
                            if (predicate(obj2))
                            {
                                Select(obj2);
                            }
                        }
                    }
                    finally
                    {
                        IDisposable disposable;
                        if ((disposable = (enumerator2 as IDisposable)) != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }
            }
        }