Example #1
0
 public override void ProcessInput(Event ev)
 {
     if (!base.CheckCanInteract())
     {
         return;
     }
     if (Designator_AreaAllowed.selectedArea != null)
     {
         base.ProcessInput(ev);
     }
     AreaUtility.MakeAllowedAreaListFloatMenu(delegate(Area a)
     {
         Designator_AreaAllowed.selectedArea = a;
         base.ProcessInput(ev);
     }, AllowedAreaMode.Any, false, true, base.Map);
 }
Example #2
0
        private static void DoAreaSelector(Rect rect, Pawn p, Area area)
        {
            rect = rect.ContractedBy(1f);
            GUI.DrawTexture(rect, (area == null) ? BaseContent.GreyTex : area.ColorTexture);
            Text.Anchor = TextAnchor.MiddleLeft;
            string text  = AreaUtility.AreaAllowedLabel_Area(area);
            Rect   rect2 = rect;

            rect2.xMin += 3f;
            rect2.yMin += 2f;
            Widgets.Label(rect2, text);
            if (p.playerSettings.AreaRestriction == area)
            {
                Widgets.DrawBox(rect, 2);
            }
            if (Event.current.rawType == EventType.MouseUp && Event.current.button == 0)
            {
                AreaAllowedGUI.dragging = false;
            }
            if (!Input.GetMouseButton(0) && Event.current.type != EventType.MouseDown)
            {
                AreaAllowedGUI.dragging = false;
            }
            if (Mouse.IsOver(rect))
            {
                if (area != null)
                {
                    area.MarkForDraw();
                }
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
                {
                    AreaAllowedGUI.dragging = true;
                }
                if (AreaAllowedGUI.dragging && p.playerSettings.AreaRestriction != area)
                {
                    p.playerSettings.AreaRestriction = area;
                    SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null);
                }
            }
            Text.Anchor = TextAnchor.UpperLeft;
            TooltipHandler.TipRegion(rect, text);
        }
        void DoAreaRow(ref float y, float width, Area area)
        {
            // if they have this, unrestricted
            Rect rl = new Rect(5, y + 1, (width / 2) - 10, 28);
            // if they don't, unrestricted
            Rect rr = new Rect((width / 2) + 5, y + 1, (width / 2) - 10, 28);

            GUI.DrawTexture(rr, (area != null) ? area.ColorTexture : BaseContent.GreyTex);
            GUI.DrawTexture(rl, (area != null) ? area.ColorTexture : BaseContent.GreyTex);
            //Text.Anchor = TextAnchor.MiddleLeft; // no idea what unity assembly this is, so leave it out.

            // note that AreaAllowedLabel_Area (and all this) takes `null` for "unrestricted"
            string text  = AreaUtility.AreaAllowedLabel_Area(area);
            bool   left  = this.crs.IsAllowedInArea(area);
            bool   right = this.crs.IsAllowedNotInArea(area);

            Widgets.CheckboxLabeled(rl, text, ref left);
            Widgets.CheckboxLabeled(rr, text, ref right);
            if (left != this.crs.IsAllowedInArea(area))
            {
                if (left)
                {
                    crs.AddAllowedArea(area);
                }
                else
                {
                    this.crs.RemoveAllowedArea(area);
                }
            }
            if (right != this.crs.IsAllowedNotInArea(area))
            {
                if (right)
                {
                    this.crs.AddAllowedNotInArea(area);
                }
                else
                {
                    this.crs.RemoveAllowedNotInArea(area);
                }
            }
            y += 30;
        }
        private static void DoAreaSelector(Rect rect, ref Area areaRestriction, Area area, IEnumerable <Pawn> pawns)
        {
            rect = rect.ContractedBy(1f);
            GUI.DrawTexture(rect, (area != null) ? area.ColorTexture : BaseContent.GreyTex);
            Text.Anchor = TextAnchor.MiddleLeft;
            string text  = AreaUtility.AreaAllowedLabel_Area(area);
            Rect   rect2 = rect;

            rect2.xMin += 3f;
            rect2.yMin += 2f;
            Widgets.Label(rect2, text);
            if (areaRestriction == area)
            {
                Widgets.DrawBox(rect, 2);
            }
            if (Mouse.IsOver(rect))
            {
                if (area != null)
                {
                    area.MarkForDraw();
                }
                if (Input.GetMouseButton(0))
                {
                    areaRestriction = area;
                    bool flag = false;
                    foreach (Pawn current in pawns)
                    {
                        if (current.playerSettings.AreaRestriction != area)
                        {
                            flag = true;
                        }
                        current.playerSettings.AreaRestriction = area;
                    }
                    if (flag)
                    {
                        SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera();
                    }
                }
            }
            TooltipHandler.TipRegion(rect, text);
            Text.Anchor = TextAnchor.UpperLeft;
        }
Example #5
0
        public override void ProcessInput(Event ev)
        {
            if (CheckCanInteract())
            {
                if (selectedArea != null)
                {
                    //base.ProcessInput(ev);
                }
                AreaUtility.MakeAllowedAreaListFloatMenu(delegate(Area a)
                {
                    selectedArea = a;
                    // base.ProcessInput(ev);

                    /*
                     * selectedArea == null --> Unrestricted
                     * selectedArea != null --> User Area
                     */
                    selectAction(selectedArea);
                }, addNullAreaOption: true, addManageOption: false, base.Map);
            }
        }
        private static IEnumerable <Widgets.DropdownMenuElement <Area> > Button_GenerateMenu(Pawn pawn)
        {
            yield return(new Widgets.DropdownMenuElement <Area>
            {
                option = new FloatMenuOption(AreaUtility.AreaAllowedLabel_Area(null), () => pawn.playerSettings.AreaRestriction = null),
                payload = null
            });

            foreach (Area area in Find.CurrentMap.areaManager.AllAreas)
            {
                Area a = area;
                if (area != pawn.playerSettings.AreaRestriction && area.AssignableAsAllowed())
                {
                    yield return(new Widgets.DropdownMenuElement <Area>
                    {
                        option = new FloatMenuOption(a.Label, () => pawn.playerSettings.AreaRestriction = a, mouseoverGuiAction: (rect) => a.MarkForDraw()),
                        payload = a
                    });
                }
            }
        }
        private bool DoAreaSelector(Rect rect, Area area)
        {
            rect = rect.ContractedBy(1f);
            GUI.DrawTexture(rect, area == null ? BaseContent.GreyTex : area.ColorTexture);
            Text.Anchor = TextAnchor.MiddleLeft;
            var labelRect = rect.ContractedBy(3f);
            var label     = AreaUtility.AreaAllowedLabel_Area(area);

            Widgets.Label(labelRect, label);
            TooltipHandler.TipRegion(rect, label);
            if (Mouse.IsOver(rect))
            {
                area?.MarkForDraw();
                if (Input.GetMouseButton(0))
                {
                    SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera();
                    return(true);
                }
            }
            return(false);
        }
Example #8
0
        // Added use of get/set methods
        private static void DoAreaSelector(Rect rect, Pawn p, Area area, Func <Pawn, Area> getArea, Action <Pawn, Area> setArea)
        {
            rect = rect.ContractedBy(1f);
            GUI.DrawTexture(rect, area == null ? BaseContent.GreyTex : area.ColorTexture);
            Text.Anchor = TextAnchor.MiddleLeft;
            string label = AreaUtility.AreaAllowedLabel_Area(area);
            Rect   rect1 = rect;

            rect1.xMin += 3f;
            rect1.yMin += 2f;
            Widgets.Label(rect1, label);
            if (getArea(p) == area)
            {
                Widgets.DrawBox(rect, 2);
            }
            if (Event.current.rawType == EventType.MouseUp && Event.current.button == 0)
            {
                dragging = false;
            }
            if (!Input.GetMouseButton(0) && Event.current.type != EventType.MouseDown)
            {
                dragging = false;
            }
            if (Mouse.IsOver(rect))
            {
                area?.MarkForDraw();
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
                {
                    dragging = true;
                }
                if (dragging && getArea(p) != area)
                {
                    setArea(p, area);
                    SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null);
                }
            }

            Text.Anchor = TextAnchor.UpperLeft;
            TooltipHandler.TipRegion(rect, (TipSignal)label);
        }
Example #9
0
        private static void DrawAreaAllowed(WidgetRow row, Pawn pawn)
        {
            if (pawn.playerSettings == null || !pawn.playerSettings.RespectsAllowedArea)
            {
                return;
            }
            row.Gap(6f);
            bool      flag = pawn.playerSettings != null && pawn.playerSettings.AreaRestriction != null;
            Texture2D fillTex;

            if (flag)
            {
                fillTex = pawn.playerSettings.AreaRestriction.ColorTexture;
            }
            else
            {
                fillTex = BaseContent.GreyTex;
            }
            Rect rect = row.FillableBar(93f, 16f, 1f, AreaUtility.AreaAllowedLabel(pawn), fillTex, null);

            if (Mouse.IsOver(rect))
            {
                if (flag)
                {
                    pawn.playerSettings.AreaRestriction.MarkForDraw();
                }
                Rect rect2 = rect.ContractedBy(-1f);
                Widgets.DrawBox(rect2, 1);
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                AllowedAreaMode mode = (!pawn.RaceProps.Humanlike) ? AllowedAreaMode.Animal : AllowedAreaMode.Humanlike;
                AreaUtility.MakeAllowedAreaListFloatMenu(delegate(Area a)
                {
                    pawn.playerSettings.AreaRestriction = a;
                }, mode, true, true, pawn.Map);
            }
        }
        public void DisplayFineOptions(Rect outerRect)
        {
            Color origColor = GUI.color;

            if (allowAll || allowNone)
            {
                GUI.color = Color.gray;
            }
            Color tmpColor;
            float y        = 0f;
            float w        = outerRect.width - 6f;                  //width, with room for scrollbar  //todo: 16f??
            Rect  viewRect = new Rect(0f, 0f, w, scrollViewHeight); //todo: 16f??

            //GUI.BeginGroup(outerRect); do scroll view instead
            Widgets.BeginScrollView(outerRect, ref scrollPosition, viewRect);
            //todo: maybe a bar showing what's actually selected?....??
            //Much todo:
            // todo: make this label a button that shows who CAN take from here?
            Widgets.Label(new Rect(0, 0, w, 22f), "Who may take from here?"); // todo: or "These options have no effect right now"
            y += 22f;
            if (CheckboxChangedToTrue(ref y, w, "All Humans" /*-like*/, ref allowHumans, "Humans, humanlike, etc"))
            {
                noAllNone();
            }
            tmpColor = GUI.color;
            if (tmpColor != Color.gray && allowHumans) // gray options if animals are selected
            {
                GUI.color = Color.gray;
            }
            if ( // human options
                // cannibals
                // non-cannials
                // depressives
                // non-depressives (chirpy people)?
                CheckboxChangedToTrue(ref y, w, "Colonists", ref allowColonists, "LWM.ColonistsDesc", 1) ||
                // if the player selects the first one, the rest won't be drawn, but who cares? they get drawn an instant later
                CheckboxChangedToTrue(ref y, w, "Guests", ref allowGuests, "LWM.ColonistsDesc", 1) ||
                CheckboxChangedToTrue(ref y, w, "Prisoners", ref allowPrisoners, "LWM.ColonistsDesc", 1)
                )
            {
                noAllNone();
                if (allowHumans)
                {
                    allowHumans = false;
                }
            }
            GUI.color = tmpColor;
            Widgets.DrawLineHorizontal(0, y + 1, w);
            y += 2;
            if (CheckboxChangedToTrue(ref y, w, "All animals", ref allowAnimals, "LWM.AllAnimalsDesc"))
            {
                noAllNone();
            }
            tmpColor = GUI.color;
            if (tmpColor != Color.gray && allowAnimals) // gray options if animals are selected
            {
                GUI.color = Color.gray;
            }
            if ( // animal options
                CheckboxChangedToTrue(ref y, w, "that can graze (plant eaters)", ref allowGrazers, "LWM.AnimalsThatGrazeDesc", 1) ||
                // if the player selects the first one, the rest won't be drawn, but who cares? they get drawn an instant later
                CheckboxChangedToTrue(ref y, w, "that cannot graze", ref allowNonGrazers, "LWM.AnimalsThatDoNotGrazeDesc", 1) ||
                CheckboxChangedToTrue(ref y, w, "that can eat meat", ref allowMeatEaters, "LWM.AnimalsThatEatMeatDesc", 1) ||
                CheckboxChangedToTrue(ref y, w, "that cannot eat meat", ref allowNonMeatEaters, "LWM.AnimalsThatDoNotEatMeatDesc", 1)
                //CheckboxChangedToTrue(ref y, w, ,1) ||
                )
            {
                noAllNone();
                if (allowAnimals)
                {
                    allowAnimals = false;
                }
            }
            GUI.color = tmpColor;

            if (Widgets.ButtonText(new Rect(0, y, w, 22), "Area control"))
            {
                Find.WindowStack.Add(new Dialog_SpecifyAreas(this.parent.Map, this));
            }
            y += 22f;
//todo: add buttons / info here
            bool needToRemove = false;
            Area toRemove     = null; // "null" is a valid Area

            if (allowedIfInAreas != null)
            {
                foreach (Area a in allowedIfInAreas)
                {
                    bool tmp = true; // can do this MUCH better - with color!
                    Widgets.CheckboxLabeled(new Rect(20f, y, w - 20f, 22), "Anyone with area " + AreaUtility.AreaAllowedLabel_Area(a), ref tmp);
                    y += 22f;
                    if (!tmp)
                    {
                        toRemove     = a; // can't remove things mid-foreach
                        needToRemove = true;
                    }
                }
                if (needToRemove)
                {
                    allowedIfInAreas.Remove(toRemove);
                }
            }
            if (allowedIfNotInAreas != null) //oh hey, it's stupid to have more than one...whatever.
            {
                needToRemove = false;
                foreach (Area a in allowedIfNotInAreas)
                {
                    bool tmp = true; // can do this MUCH better - with color!
                    Widgets.CheckboxLabeled(new Rect(20f, y, w - 20f, 22), "Any area BESIDES " + AreaUtility.AreaAllowedLabel_Area(a), ref tmp);
                    y += 22f;
                    if (!tmp)
                    {
                        toRemove = a;
                    }
                }
                if (needToRemove)
                {
                    allowedIfNotInAreas.Remove(toRemove);
                }
            }
            if (Widgets.ButtonText(new Rect(0, y, w, 22), "Pawn control"))
            {
                Find.WindowStack.Add(new Dialog_SpecifyPawns(this));
            }
            y += 22f;
            Pawn pawnToRemove = null;

            if (allowedPawns != null)
            {
                foreach (Pawn p in allowedPawns)
                {
                    bool tmp = true;
                    Widgets.CheckboxLabeled(new Rect(20f, y, w - 20f, 22), "Allowed: " + p.Name, ref tmp);
                    y += 22;
                    if (!tmp)
                    {
                        pawnToRemove = p; // can't remove things mid-foreach
                    }
                }
                if (pawnToRemove != null)
                {
                    allowedPawns.Remove(pawnToRemove);
                }
            }
            if (disallowedPawns != null)
            {
                pawnToRemove = null;
                foreach (Pawn p in disallowedPawns)
                {
                    bool tmp = true;
                    Widgets.CheckboxLabeled(new Rect(20f, y, w - 20f, 22), "NOT allowed: " + p.Name, ref tmp);
                    y += 22;
                    if (!tmp)
                    {
                        pawnToRemove = p; // can't remove things mid-foreach
                    }
                }
                if (pawnToRemove != null)
                {
                    disallowedPawns.Remove(pawnToRemove);
                }
            }
            GUI.color        = origColor;
            scrollViewHeight = y;
            Widgets.EndScrollView();
        }
Example #11
0
        private static void DrawAreaAllowed(WidgetRow row, Pawn pawn)
        {
            if (pawn.playerSettings == null || !pawn.playerSettings.RespectsAllowedArea)
            {
                return;
            }
            row.Gap(6f);
            bool flag = pawn.playerSettings != null && pawn.playerSettings.EffectiveAreaRestriction != null;
            Rect rect = row.FillableBar(fillTex: (!flag) ? BaseContent.GreyTex : pawn.playerSettings.EffectiveAreaRestriction.ColorTexture, width: 93f, height: 16f, fillPct: 1f, label: AreaUtility.AreaAllowedLabel(pawn));

            if (Mouse.IsOver(rect))
            {
                if (flag)
                {
                    pawn.playerSettings.EffectiveAreaRestriction.MarkForDraw();
                }
                Widgets.DrawBox(rect.ContractedBy(-1f));
            }
            if (Widgets.ButtonInvisible(rect))
            {
                AreaUtility.MakeAllowedAreaListFloatMenu(delegate(Area a)
                {
                    pawn.playerSettings.AreaRestriction = a;
                }, addNullAreaOption: true, addManageOption: true, pawn.Map);
            }
        }
        public static bool DoAreaSelectorPrefix(Rect rect, Pawn p, Area area)
        {
            MouseoverSounds.DoRegion(rect);
            rect = rect.ContractedBy(1f);
            GUI.DrawTexture(rect, (area == null) ? BaseContent.GreyTex : area.ColorTexture);
            Text.Anchor = TextAnchor.MiddleLeft;
            string text  = AreaUtility.AreaAllowedLabel_Area(area);
            Rect   rect2 = rect;

            rect2.xMin += 3f;
            rect2.yMin += 2f;
            Widgets.Label(rect2, text);

            bool            dragging         = (bool)FieldInfos.dragging.GetValue(null);
            Area            currentArea      = p.playerSettings.AreaRestriction;
            AreaExt         currentAreaExt   = p.playerSettings.AreaRestriction as AreaExt;
            AreaExtOperator currentAreaExtOp = currentAreaExt?.GetAreaOperator(area?.ID ?? -1) ?? AreaExtOperator.None;

            // null area인 경우, 현재 구역의 첫 구역이 exclusion이면 inclusion으로 선택된것처럼 출력해준다. (실제로는 아님)
            if (area == null)
            {
                if (currentArea == null || (currentAreaExt != null && currentAreaExt.IsWholeExclusive))
                {
                    GUI.color = Color.white;
                    Widgets.DrawBox(rect, 2);
                    GUI.color = Color.white;
                }
            }
            else
            {
                if (currentAreaExt != null)
                {
                    if (currentAreaExtOp == AreaExtOperator.Inclusion)
                    {
                        GUI.color = Color.white;
                        Widgets.DrawBox(rect, 2);
                        GUI.color = Color.white;
                    }
                    else if (currentAreaExtOp == AreaExtOperator.Exclusion)
                    {
                        GUI.color = Color.red;
                        Widgets.DrawBox(rect, 2);
                        GUI.color = Color.white;
                    }
                }
                else
                {
                    if (currentArea == area)
                    {
                        Widgets.DrawBox(rect, 2);
                    }
                }
            }

            bool mouseOver   = Mouse.IsOver(rect);
            bool leftButton  = Event.current.button == 0;
            bool rightButton = Event.current.button == 1;

            if (mouseOver && area != null)
            {
                area.MarkForDraw();
            }

            if (editMode == AreaAllowedEditMode.None)
            {
                if (mouseOver && dragging)
                {
                    if (leftButton)
                    {
                        // 구역이 null이 아니면서, 현재 선택되어있다면 Remove, 아니면 Inclusion
                        if (area != null && (currentArea == area || currentAreaExtOp == AreaExtOperator.Inclusion))
                        {
                            editMode = AreaAllowedEditMode.Remove;
                        }
                        else
                        {
                            editMode = AreaAllowedEditMode.AddInclusion;
                        }
                    }
                    else if (rightButton)
                    {
                        // 이미 Exclusion으로 선택된것만 Remove, 아니면 Exclusion으로 덮어쓰거나 수정하지 않음
                        if (currentAreaExtOp == AreaExtOperator.Exclusion)
                        {
                            editMode = AreaAllowedEditMode.Remove;
                        }
                        else if (area != null)
                        {
                            editMode = AreaAllowedEditMode.AddExclusion;
                        }
                    }
                }
            }

            if (editMode == AreaAllowedEditMode.AddInclusion)
            {
                if (mouseOver && dragging)
                {
                    if (currentArea != area)
                    {
                        if (area == null)
                        {
                            p.playerSettings.AreaRestriction = null;
                        }
                        else
                        {
                            if (currentArea == null)
                            {
                                p.playerSettings.AreaRestriction = area;
                            }
                            else
                            {
                                if (currentAreaExt != null)
                                {
                                    if (!currentAreaExt.Contains(area, AreaExtOperator.Inclusion))
                                    {
                                        p.playerSettings.AreaRestriction = currentAreaExt.CloneWithOperationArea(AreaExtOperator.Inclusion, area);
                                    }
                                }
                                else
                                {
                                    p.playerSettings.AreaRestriction = new AreaExt(currentArea.Map, AreaExtOperator.Inclusion, currentArea).CloneWithOperationArea(AreaExtOperator.Inclusion, area);
                                }
                            }
                        }
                    }
                }
                else if (!dragging)
                {
                    editMode = AreaAllowedEditMode.None;
                }
            }
            else if (editMode == AreaAllowedEditMode.AddExclusion)
            {
                if (mouseOver && dragging)
                {
                    if (currentArea != area)
                    {
                        if (area == null)
                        {
                            p.playerSettings.AreaRestriction = null;
                        }
                        else
                        {
                            if (currentArea == null)
                            {
                                p.playerSettings.AreaRestriction = new AreaExt(area.Map, AreaExtOperator.Exclusion, area);
                            }
                            else
                            {
                                if (currentAreaExt != null)
                                {
                                    if (!currentAreaExt.Contains(area, AreaExtOperator.Exclusion))
                                    {
                                        p.playerSettings.AreaRestriction = currentAreaExt.CloneWithOperationArea(AreaExtOperator.Exclusion, area);
                                    }
                                }
                                else
                                {
                                    p.playerSettings.AreaRestriction = new AreaExt(currentArea.Map, AreaExtOperator.Inclusion, currentArea).CloneWithOperationArea(AreaExtOperator.Exclusion, area);
                                }
                            }
                        }
                    }
                }
                else if (!dragging)
                {
                    editMode = AreaAllowedEditMode.None;
                }
            }
            else if (editMode == AreaAllowedEditMode.Remove)
            {
                if (mouseOver && dragging)
                {
                    if (currentArea != null && area != null)
                    {
                        if (currentArea == area)
                        {
                            p.playerSettings.AreaRestriction = null;
                        }
                        else if (currentAreaExt != null && currentAreaExt.Contains(area))
                        {
                            p.playerSettings.AreaRestriction = currentAreaExt.CloneWithOperationArea(AreaExtOperator.None, area);
                        }
                    }
                }
                else if (!dragging)
                {
                    editMode = AreaAllowedEditMode.None;
                }
            }

            Text.Anchor = TextAnchor.UpperLeft;
            TooltipHandler.TipRegion(rect, text);

            return(false);
        }
Example #13
0
        public static bool DoAreaSelectorPrefix(Rect rect, Pawn p, Area area)
        {
            MouseoverSounds.DoRegion(rect);
            rect = rect.ContractedBy(1f);
            GUI.DrawTexture(rect, (area == null) ? BaseContent.GreyTex : area.ColorTexture);
            Text.Anchor = TextAnchor.MiddleLeft;
            string text  = AreaUtility.AreaAllowedLabel_Area(area);
            Rect   rect2 = rect;

            rect2.xMin += 3f;
            rect2.yMin += 2f;
            Widgets.Label(rect2, text);

            bool    dragging       = (bool)FieldInfos.dragging.GetValue(null);
            Area    currentArea    = p.playerSettings.AreaRestriction;
            AreaExt currentAreaExt = p.playerSettings.AreaRestriction as AreaExt;

            if (area != null && currentAreaExt != null)
            {
                AreaExtOperator areaOp = currentAreaExt.GetAreaOperator(area.ID);
                if (areaOp == AreaExtOperator.Inclusion)
                {
                    GUI.color = Color.white;
                    Widgets.DrawBox(rect, 2);
                    GUI.color = Color.white;
                }
                else if (areaOp == AreaExtOperator.Exclusion)
                {
                    GUI.color = Color.red;
                    Widgets.DrawBox(rect, 2);
                    GUI.color = Color.white;
                }
            }
            else
            {
                if (currentArea == area)
                {
                    Widgets.DrawBox(rect, 2);
                }
            }

            if (Mouse.IsOver(rect))
            {
                if (area != null)
                {
                    area.MarkForDraw();
                }
            }

            if (dragging && Mouse.IsOver(rect))
            {
                if (editMode == AreaAllowedEditMode.None)
                {
                    if (area != null && currentAreaExt != null)
                    {
                        var t = currentAreaExt.GetAreaOperator(area.ID);
                        if (t != AreaExtOperator.None)
                        {
                            if ((Event.current.button == 0 && t == AreaExtOperator.Inclusion) ||
                                (Event.current.button == 1 && t == AreaExtOperator.Exclusion))
                            {
                                editMode = AreaAllowedEditMode.Remove;
                            }
                            else
                            {
                                editMode = Event.current.button == 0 ? AreaAllowedEditMode.AddInclusion : AreaAllowedEditMode.AddExclusion;
                            }
                        }
                        else
                        {
                            editMode = Event.current.button == 0 ? AreaAllowedEditMode.AddInclusion : AreaAllowedEditMode.AddExclusion;
                        }
                    }
                    else
                    {
                        if (currentArea == area)
                        {
                            editMode = AreaAllowedEditMode.Remove;
                        }
                        else
                        {
                            if (Event.current.button == 0)
                            {
                                editMode = AreaAllowedEditMode.AddInclusion;
                            }
                            else if (Event.current.button == 1)
                            {
                                editMode = AreaAllowedEditMode.AddExclusion;
                            }
                        }
                    }
                }

                if (editMode == AreaAllowedEditMode.AddInclusion)
                {
                    if (area == null)
                    {
                        p.playerSettings.AreaRestriction = null;
                        SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null);
                    }
                    else if (currentAreaExt != null)
                    {
                        if (currentAreaExt.GetAreaOperator(area.ID) != AreaExtOperator.Inclusion)
                        {
                            p.playerSettings.AreaRestriction = currentAreaExt.CloneWithOperationArea(AreaExtOperator.Inclusion, area);
                            SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null);
                        }
                    }
                    else
                    {
                        p.playerSettings.AreaRestriction = new AreaExt(area.Map, AreaExtOperator.Inclusion, area);
                        SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null);
                    }
                }

                if (editMode == AreaAllowedEditMode.AddExclusion)
                {
                    if (area == null)
                    {
                        p.playerSettings.AreaRestriction = null;
                        SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null);
                    }
                    else if (currentAreaExt != null)
                    {
                        if (currentAreaExt.GetAreaOperator(area.ID) != AreaExtOperator.Exclusion)
                        {
                            p.playerSettings.AreaRestriction = currentAreaExt.CloneWithOperationArea(AreaExtOperator.Exclusion, area);
                            SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null);
                        }
                    }
                    else
                    {
                        p.playerSettings.AreaRestriction = new AreaExt(area.Map, AreaExtOperator.Exclusion, area);
                        SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null);
                    }
                }

                if (editMode == AreaAllowedEditMode.Remove)
                {
                    if (currentAreaExt != null)
                    {
                        if (area != null)
                        {
                            if (currentAreaExt.GetAreaOperator(area.ID) != AreaExtOperator.None)
                            {
                                p.playerSettings.AreaRestriction = currentAreaExt.CloneWithOperationArea(AreaExtOperator.None, area);
                                SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null);
                            }
                        }
                    }
                    else
                    {
                        if (currentArea != null)
                        {
                            p.playerSettings.AreaRestriction = null;
                            SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null);
                        }
                    }
                }
            }

            Text.Anchor = TextAnchor.UpperLeft;
            TooltipHandler.TipRegion(rect, text);

            return(false);
        }