Exemple #1
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft)
        {
            var gizmoRect = new Rect(topLeft.x, topLeft.y, Width, MinGizmoSize);

            if (Mouse.IsOver(gizmoRect))
            {
                LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SimpleSidearmsBasic, OpportunityType.Important);
            }

            var contentRect = gizmoRect.ContractedBy(ContentPadding);

            Widgets.DrawWindowBackground(gizmoRect);

            var globalInteracted = false;

            interactedWeapon       = null;
            interactedWeaponMemory = null;
            interactedRanged       = false;
            interactedUnarmed      = false;

            GoldfishModule pawnMemory = GoldfishModule.GetGoldfishForPawn(parent);
            //if (pawnMemory == null)
            //    return new GizmoResult(GizmoState.Clear);

            int i = 0;

            for (i = 0; i < rangedWeapons.Count; i++)
            {
                var  iconOffset = new Vector2((IconSize * i) + IconGap * (i - 1) + LockPanelWidth, 0);
                bool interacted = DrawIconForWeapon(pawnMemory, rangedWeapons[i], contentRect, iconOffset);
                if (interacted)
                {
                    interactedWeapon = rangedWeapons[i];
                }
                if (interacted)
                {
                    interactedRanged = true;
                }
                globalInteracted |= interacted;
            }

            int j = 0;

            if (pawnMemory != null)
            {
                foreach (ThingDef def in rangedWeaponMemories)
                {
                    if (!parent.hasWeaponSomewhere(def))
                    {
                        var  iconOffset = new Vector2((IconSize * (i + j)) + IconGap * ((i + j) - 1) + LockPanelWidth, 0);
                        bool interacted = DrawIconForWeaponMemory(pawnMemory, def, contentRect, iconOffset);
                        if (interacted)
                        {
                            interactedWeaponMemory = def;
                        }
                        if (interacted)
                        {
                            interactedRanged = true;
                        }
                        globalInteracted |= interacted;
                        j++;
                    }
                }
            }

            for (i = 0; i < meleeWeapons.Count; i++)
            {
                var  iconOffset = new Vector2((IconSize * i) + IconGap * (i - 1) + LockPanelWidth, IconSize + IconGap);
                bool interacted = DrawIconForWeapon(pawnMemory, meleeWeapons[i], contentRect, iconOffset);
                if (interacted)
                {
                    interactedWeapon = meleeWeapons[i];
                }
                if (interacted)
                {
                    interactedRanged = false;
                }
                globalInteracted |= interacted;
            }

            j = 0;
            if (pawnMemory != null)
            {
                foreach (ThingDef def in meleeWeaponMemories)
                {
                    if (!parent.hasWeaponSomewhere(def))
                    {
                        var  iconOffset = new Vector2((IconSize * (i + j)) + IconGap * ((i + j) - 1) + LockPanelWidth, IconSize + IconGap);
                        bool interacted = DrawIconForWeaponMemory(pawnMemory, def, contentRect, iconOffset);
                        if (interacted)
                        {
                            interactedWeaponMemory = def;
                        }
                        if (interacted)
                        {
                            interactedRanged = false;
                        }
                        globalInteracted |= interacted;
                        j++;
                    }
                }
            }

            var unarmedIconOffset = new Vector2((IconSize * (i + j)) + IconGap * ((i + j) - 1) + LockPanelWidth, IconSize + IconGap);

            interactedUnarmed = DrawIconForUnarmed(parent, contentRect, unarmedIconOffset);
            globalInteracted |= interactedUnarmed;

            Rect locksPanel = new Rect(gizmoRect.x + ContentPadding, gizmoRect.y, LockPanelWidth - ContentPadding, MinGizmoSize);
            //locksPanel = locksPanel.ContractedBy(LockPanelPadding);

            SwapControlsHandler handler = SwapControlsHandler.GetHandlerForPawn(parent);

            Rect lockPanel     = new Rect(locksPanel.x, locksPanel.y + (locksPanel.height / 2f) - locksPanel.width - LockIconsOffset, locksPanel.width, locksPanel.width);
            Rect locklockPanel = new Rect(locksPanel.x, locksPanel.y + (locksPanel.height / 2f) + LockIconsOffset, locksPanel.width, locksPanel.width);

            DrawLock(handler, lockPanel);
            UIHighlighter.HighlightOpportunity(lockPanel, "SidearmListButton");
            DrawLocklock(handler, locklockPanel);
            UIHighlighter.HighlightOpportunity(locklockPanel, "SidearmListButton");

            UIHighlighter.HighlightOpportunity(gizmoRect, "SidearmList");

            DrawGizmoLabel(defaultLabel, gizmoRect);
            return(globalInteracted ? new GizmoResult(GizmoState.Interacted, Event.current) : new GizmoResult(GizmoState.Clear));
        }
Exemple #2
0
        private void iconClickAction(int buttonID)
        {
            if (interactedWeapon != null)
            {
                Thing toSwapTo;
                if (interactedRanged)
                {
                    if (buttonID == 0)
                    {
                        toSwapTo = interactedWeapon;

                        if (GoldfishModule.GetGoldfishForPawn(parent) != null && toSwapTo.def.defName.Equals(GoldfishModule.GetGoldfishForPawn(parent).primary))
                        {
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsPrimary, KnowledgeAmount.Total);
                        }

                        WeaponAssingment.weaponSwapSpecific(parent, toSwapTo, true, MiscUtils.shouldDrop(DroppingModeEnum.UserForced), false);
                        SwapControlsHandler handler = SwapControlsHandler.GetHandlerForPawn(parent);
                        if (handler.autoLockOnManualSwap)
                        {
                            handler.currentWeaponLocked = true;
                        }

                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsInInventory, KnowledgeAmount.SpecificInteraction);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                    }
                    else if (buttonID == 1)
                    {
                        WeaponAssingment.dropSidearm(parent, interactedWeapon);

                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsInInventory, KnowledgeAmount.SpecificInteraction);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                    }
                }
                else
                {
                    if (buttonID == 0)
                    {
                        toSwapTo = interactedWeapon;

                        if (GoldfishModule.GetGoldfishForPawn(parent) != null && toSwapTo.def.defName.Equals(GoldfishModule.GetGoldfishForPawn(parent).primary))
                        {
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsPrimary, KnowledgeAmount.Total);
                        }

                        WeaponAssingment.weaponSwapSpecific(parent, toSwapTo, true, MiscUtils.shouldDrop(DroppingModeEnum.UserForced), false);

                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsInInventory, KnowledgeAmount.SpecificInteraction);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                    }
                    else if (buttonID == 1)
                    {
                        WeaponAssingment.dropSidearm(parent, interactedWeapon);

                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsInInventory, KnowledgeAmount.SpecificInteraction);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                    }
                }
            }
            else if (interactedWeaponMemory != null)
            {
                if (interactedRanged)
                {
                    if (buttonID == 0)
                    {
                    }
                    else if (buttonID == 1)
                    {
                        WeaponAssingment.forgetSidearmMemory(parent, interactedWeaponMemory);

                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsMissing, KnowledgeAmount.SpecificInteraction);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                    }
                }
                else
                {
                    if (buttonID == 0)
                    {
                    }
                    else if (buttonID == 1)
                    {
                        WeaponAssingment.forgetSidearmMemory(parent, interactedWeaponMemory);

                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsMissing, KnowledgeAmount.SpecificInteraction);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                    }
                }
            }
            else if (interactedUnarmed == true)
            {
                if (buttonID == 0)
                {
                    WeaponAssingment.weaponSwapSpecific(parent, null, true, MiscUtils.shouldDrop(DroppingModeEnum.UserForced), false);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                }
            }
        }
Exemple #3
0
 private void iconClickAction(int buttonID)
 {
     if (interactedWeapon != null)
     {
         Thing toSwapTo;
         if (interactedRanged)
         {
             if (buttonID == 0)
             {
                 toSwapTo = interactedWeapon;
                 WeaponAssingment.weaponSwapSpecific(parent, toSwapTo, true, MiscUtils.shouldDrop(DroppingModeEnum.UserForced), false);
                 SwapControlsHandler handler = SwapControlsHandler.GetHandlerForPawn(parent);
                 if (handler.autoLockOnManualSwap)
                 {
                     handler.currentWeaponLocked = true;
                 }
             }
             else if (buttonID == 1)
             {
                 WeaponAssingment.dropSidearm(parent, interactedWeapon);
             }
         }
         else
         {
             if (buttonID == 0)
             {
                 toSwapTo = interactedWeapon;
                 WeaponAssingment.weaponSwapSpecific(parent, toSwapTo, true, MiscUtils.shouldDrop(DroppingModeEnum.UserForced), false);
             }
             else if (buttonID == 1)
             {
                 WeaponAssingment.dropSidearm(parent, interactedWeapon);
             }
         }
     }
     else if (interactedWeaponMemory != null)
     {
         if (interactedRanged)
         {
             if (buttonID == 0)
             {
             }
             else if (buttonID == 1)
             {
                 WeaponAssingment.forgetSidearmMemory(parent, interactedWeaponMemory);
             }
         }
         else
         {
             if (buttonID == 0)
             {
             }
             else if (buttonID == 1)
             {
                 WeaponAssingment.forgetSidearmMemory(parent, interactedWeaponMemory);
             }
         }
     }
     else if (interactedUnarmed == true)
     {
         if (buttonID == 0)
         {
             WeaponAssingment.weaponSwapSpecific(parent, null, true, MiscUtils.shouldDrop(DroppingModeEnum.UserForced), false);
         }
     }
 }