Example #1
0
        internal static HoldType getCustomHoldType(Item item)
        {
            int style;

            if (ModConfWeaponOutCustom.TryGetCustomHoldStyle(item.type, out style))
            {
                return(setHoldTypeSafeWrapping(style));
            }
            return(HoldType.None);
        }
Example #2
0
        private static void PickItemDrawType(bool drawOnBack, Player drawPlayer, Item heldItem, bool isYoyo, int gWidth, int gHeight, ref DrawData data, float itemWidth, float itemHeight, float larger, float lesser)
        {
            HoldType holdType = HoldType.None;
            int      style;

            if (ModConfWeaponOutCustom.TryGetCustomHoldStyle(heldItem.type, out style))
            {
                holdType = getCustomHoldType(heldItem);
            }
            else
            {
                #region AutoPicker
                if (heldItem.useStyle == 1 || //swing
                    heldItem.useStyle == 2 || //eat
                    heldItem.useStyle == 3)   //stab
                {
                    //|       ######
                    //|       ##  ##
                    //|     ##########
                    //|       ##  ##
                    //|       ##  ##
                    //|       ##  ##
                    //|       ##  ##
                    //|         ##
                    //Items, daggers and other throwables lie below 28 and are easily held in the hand
                    if ((larger < 28 && !heldItem.magic) ||      //nonmagic weapons
                        (larger <= 32 && heldItem.shoot != 0) || //larger for throwing weapons
                        (larger <= 24 && heldItem.magic))        //only smallest magic weapons
                    {
                        if (DEBUG_WEAPONHOLD && drawPlayer.controlHook)
                        {
                            Main.NewText(heldItem.useStyle + "(hand): " + itemWidth + " x " + itemHeight);
                        }
                        holdType = HoldType.Hand;
                    }
                    //|             ####
                    //|           ##  ##
                    //|         ##  ##
                    //|       ##  ##
                    //|   ####  ##
                    //|   ##  ##
                    //| ##  ####
                    //| ####
                    //Broadsword weapons are swing type weapons between 28 - 48
                    //They are worn on the waist, and react to falling! Except when disabled
                    //This also amusingly applies to ducks, axes and rockfish
                    //But shouldn't apply to pickaxes, except when they are also not pickaxes
                    else if (larger <= 48 &&
                             (heldItem.pick <= 0 ||
                              (heldItem.pick > 0 && heldItem.axe > 0)))
                    {
                        if (DEBUG_WEAPONHOLD && drawPlayer.controlHook)
                        {
                            Main.NewText(heldItem.useStyle + "(waist): " + itemWidth + " x " + itemHeight);
                        }
                        holdType = HoldType.Waist;
                    }
                    //|           ########
                    //|           ##    ##
                    //|         ##    ####
                    //|   ##  ##    ##
                    //|   ####    ##
                    //|   ##  ####
                    //| ##  ########
                    //| ######
                    //Great weapons are swing type weapons past 36 in size and slung on the back
                    else
                    {
                        if (DEBUG_WEAPONHOLD && drawPlayer.controlHook)
                        {
                            Main.NewText(heldItem.useStyle + "(back): " + itemWidth + " x " + itemHeight);
                        }
                        holdType = HoldType.Back;
                    }
                }

                if (heldItem.useStyle == 4 || //hold up
                    heldItem.useStyle == 5)   //hold out
                {
                    bool isAStaff = Item.staff[heldItem.type];
                    //staves, guns and bows
                    if (gHeight >= gWidth * 1.2f && !isAStaff)
                    {
                        //|    ######
                        //|    ##  ######
                        //|    ##    ##  ##
                        //|    ##    ##  ##
                        //|    ##    ##  ##
                        //|    ##    ##  ##
                        //|    ##  ######
                        //|    ######
                        //bows
                        if (DEBUG_WEAPONHOLD && drawPlayer.controlHook)
                        {
                            Main.NewText(heldItem.useStyle + "(bow): " + itemWidth + " x " + itemHeight);
                        }
                        holdType = HoldType.Bow;
                    }
                    else if (gWidth >= gHeight * 1.2f && !isAStaff)
                    {
                        if (heldItem.noUseGraphic && heldItem.melee)
                        {
                            //|
                            //|    ####
                            //|  ##  ##########
                            //|  ####    ##    ####
                            //|  ##  ##  ##        ####
                            //|  ##      ##  ######
                            //|    ############
                            //|
                            //drills, chainsaws
                            if (DEBUG_WEAPONHOLD && drawPlayer.controlHook)
                            {
                                Main.NewText(heldItem.useStyle + "(drill): " + itemWidth + " x " + itemHeight);
                            }
                            holdType = HoldType.PowerTool;
                        }
                        else
                        {
                            if (larger < 45)
                            {
                                //| ####        ####
                                //| ##  ########  ##
                                //|   ####        ##
                                //|   ##    ########
                                //|   ##  ##  ##
                                //|   ##  ####
                                //|   ######
                                //|
                                if (drawPlayer.grapCount > 0)
                                {
                                    return;                           // can't see while grappling
                                }
                                if (DEBUG_WEAPONHOLD && drawPlayer.controlHook)
                                {
                                    Main.NewText(heldItem.useStyle + "(pistol): " + itemWidth + " x " + itemHeight);
                                }
                                //small aimed weapons (like handgun/aquasceptre) held halfway down, 1/3 back
                                holdType = HoldType.SmallGun;
                            }
                            else
                            {
                                //|
                                //|               ##
                                //| ######################
                                //| ##  ##      ##  ##
                                //| ##  ############
                                //| ####  ##    ##
                                //|     ####    ##
                                //|
                                if (DEBUG_WEAPONHOLD && drawPlayer.controlHook)
                                {
                                    Main.NewText(heldItem.useStyle + "(rifle): " + itemWidth + " x " + itemHeight);
                                }
                                //large guns (rifles, launchers, etc.) held with both hands
                                holdType = HoldType.LargeGun;
                            }
                        }
                    }
                    else
                    {
                        if (heldItem.noUseGraphic && !isAStaff)
                        {
                            if (!heldItem.autoReuse)
                            {
                                if (DEBUG_WEAPONHOLD && drawPlayer.controlHook)
                                {
                                    Main.NewText(heldItem.useStyle + "(polearm): " + itemWidth + " x " + itemHeight);
                                }
                                if (isYoyo)
                                {
                                    //sam (?why did i write sam? maybe same?)
                                    data = WeaponDrawInfo.modDraw_HandWeapon(data, drawPlayer, larger, lesser, isYoyo);
                                }
                                else
                                {
                                    //|             ####
                                    //|         ####  ##
                                    //|       ##    ##
                                    //|         ##  ##
                                    //|       ##  ##
                                    //|     ##
                                    //|   ##
                                    //| ##
                                    //spears are held facing to the floor, maces generally held
                                    holdType = HoldType.Spear;
                                }
                            }
                            else
                            {
                                //nebula blaze, flairon, solar eruption (too inconsistent)
                                if (larger <= 48)
                                {
                                    if (DEBUG_WEAPONHOLD && drawPlayer.controlHook)
                                    {
                                        Main.NewText(heldItem.useStyle + "(waist safe): " + itemWidth + " x " + itemHeight);
                                    }
                                    holdType = HoldType.Waist;
                                }
                                else
                                {
                                    if (DEBUG_WEAPONHOLD && drawPlayer.controlHook)
                                    {
                                        Main.NewText(heldItem.useStyle + "(back safe): " + itemWidth + " x " + itemHeight);
                                    }
                                    holdType = HoldType.Back;
                                }
                            }
                        }
                        else
                        {
                            if (larger + lesser <= 72) //only smallest magic weapons
                            {
                                //|         ######
                                //|       ##  ##  ##
                                //|     ##      ##  ##
                                //|   ##        ######
                                //| ##        ##  ##
                                //| ##      ##  ##
                                //|   ##  ##  ##
                                //|     ######
                                if (DEBUG_WEAPONHOLD && drawPlayer.controlHook)
                                {
                                    Main.NewText(heldItem.useStyle + "(hand magic): " + itemWidth + " x " + itemHeight);
                                }
                                holdType = HoldType.Hand;
                            }
                            else if (lesser <= 42) //medium sized magic weapons, treated like polearms
                            {
                                if (DEBUG_WEAPONHOLD && drawPlayer.controlHook)
                                {
                                    Main.NewText(heldItem.useStyle + "(polearm magic): " + itemWidth + " x " + itemHeight);
                                }
                                holdType = HoldType.Spear;
                            }
                            else
                            { //largestaves are held straight up
                              //|
                              //|             ####
                              //|   ############  ##
                              //| ##        ##      ##
                              //|   ############  ##
                              //|             ####
                              //|
                              //|
                                if (DEBUG_WEAPONHOLD && drawPlayer.controlHook)
                                {
                                    Main.NewText(heldItem.useStyle + "(staff): " + itemWidth + " x " + itemHeight);
                                }
                                //staves
                                holdType = HoldType.Staff;
                            }
                        }
                    }
                }
                #endregion

                // Get any custom hold if no override was set
                foreach (var drawMethod in WeaponOut.mod.weaponOutCustomHoldMethods)
                {
                    holdType = setHoldTypeSafeWrapping(drawMethod(drawPlayer, heldItem, (int)holdType));
                }
            }


            // can't see non-backed while grappling
            if (holdTypeHideOnBack[(int)holdType] && drawPlayer.grapCount > 0)
            {
                return;
            }
            // Only draw back items when it is a back item hold type
            if (holdTypeHideOnBack[(int)holdType] == drawOnBack)
            {
                return;
            }

            switch (holdType)
            {
            case HoldType.Hand: data = WeaponDrawInfo.modDraw_HandWeapon(data, drawPlayer, larger, lesser); break;

            case HoldType.Waist: data = WeaponDrawInfo.modDraw_WaistWeapon(data, drawPlayer, larger); break;

            case HoldType.Spear: data = WeaponDrawInfo.modDraw_PoleWeapon(data, drawPlayer, larger); break;

            case HoldType.PowerTool: data = WeaponDrawInfo.modDraw_DrillWeapon(data, drawPlayer, larger); break;

            case HoldType.Back: data = WeaponDrawInfo.modDraw_BackWeapon(data, drawPlayer, larger); break;

            case HoldType.Bow: data = WeaponDrawInfo.modDraw_ForwardHoldWeapon(data, drawPlayer, lesser); break;

            case HoldType.SmallGun: data = WeaponDrawInfo.modDraw_AimedWeapon(data, drawPlayer, larger); break;

            case HoldType.LargeGun: data = WeaponDrawInfo.modDraw_HeavyWeapon(data, drawPlayer, lesser); break;

            case HoldType.Staff: data = WeaponDrawInfo.modDraw_MagicWeapon(data, drawPlayer, larger); break;

            default: return;
            }


            // Run custom draws

            bool allowDraw = true;
            foreach (var drawMethod in WeaponOut.mod.weaponOutCustomPreDrawMethods)
            {
                if (!drawMethod(drawPlayer, heldItem, data))
                {
                    allowDraw = false;
                }
            }

            // Attempt standard draw if allowed
            if (allowDraw)
            {
                //Add the weapon to the draw layers
                Main.playerDrawData.Add(data);
                WeaponDrawInfo.drawGlowLayer(data, drawPlayer, heldItem);
            }
        }
Example #3
0
        private void DrawInterfaceWeaponOutToggleEye(SpriteBatch spriteBatch)
        {
            //if (Disabled) return;

            // Janky quick inventory visibilty
            if (!Main.playerInventory || !ModConf.showWeaponOut || ModConf.forceShowWeaponOut)
            {
                return;
            }
            //Get vars
            PlayerWOFX pfx       = Main.LocalPlayer.GetModPlayer <PlayerWOFX>(this);
            Texture2D  eye       = Main.inventoryTickOnTexture;
            string     hoverText = GetTranslationTextValue("WOVisualShow"); // Visible
            Vector2    position  = new Vector2(20, 10);

            // Display custom styling
            int style;

            if (ModConfWeaponOutCustom.TryGetCustomHoldStyle(Main.LocalPlayer.HeldItem.type, out style))
            {
                switch (style)
                {
                case 1: hoverText += ": " + GetTranslationTextValue("WOVisualTypeHand"); break;

                case 2: hoverText += ": " + GetTranslationTextValue("WOVisualTypeWaist"); break;

                case 3: hoverText += ": " + GetTranslationTextValue("WOVisualTypeBack"); break;

                case 4: hoverText += ": " + GetTranslationTextValue("WOVisualTypeSpear"); break;

                case 5: hoverText += ": " + GetTranslationTextValue("WOVisualTypePowerTool"); break;

                case 6: hoverText += ": " + GetTranslationTextValue("WOVisualTypeBow"); break;

                case 7: hoverText += ": " + GetTranslationTextValue("WOVisualTypeSmallGun"); break;

                case 8: hoverText += ": " + GetTranslationTextValue("WOVisualTypeLargeGun"); break;

                case 9: hoverText += ": " + GetTranslationTextValue("WOVisualTypeStaff"); break;
                }
            }

            // Show hidden instead
            if (!pfx.weaponVisual)
            {
                eye       = Main.inventoryTickOffTexture;
                hoverText = GetTranslationTextValue("WOVisualHide"); // Hidden
            }

            // Get rectangle for eye
            Rectangle eyeRect = new Rectangle(
                (int)position.X, (int)position.Y - (eye.Height / 2),
                eye.Width, eye.Height);

            if (eyeRect.Contains(Main.mouseX, Main.mouseY))
            {
                // Prevent item use and show text
                Main.hoverItemName = hoverText;
                Main.blockMouse    = true;

                // On plain click
                if (!Main.mouseRight && Main.mouseLeft && Main.mouseLeftRelease)
                {
                    ToggleWeaponVisual(pfx, !pfx.weaponVisual);
                }
                if (pfx.weaponVisual)
                {
                    // On alt click
                    if (Main.mouseRight && Main.mouseRightRelease)
                    {
                        ModConfWeaponOutCustom.UpdateCustomHoldIncrement(Main.LocalPlayer.HeldItem, 1);
                    }

                    // On click during alt
                    if (Main.mouseRight && Main.mouseLeft && Main.mouseLeftRelease)
                    {
                        ModConfWeaponOutCustom.UpdateCustomHoldIncrement(Main.LocalPlayer.HeldItem, -1);
                    }
                }
            }

            // Draw this!
            spriteBatch.Draw(
                eye,
                new Vector2(20, 4),
                null,
                Color.White
                );
        }