public void PreUpdatePlayer(Player player) { if (ModPlayer.stackSplit > 0) ModPlayer.stackSplit--; tPlayer = player; controlInv = false; //invSelectItem = false; invSelectItemRelease = false; //craftScroll = 0; if (!Main.gameMenu && (Main.netMode != 2)) { if(invCool>0) invCool--; if (padState.IsConnected) { int ScrollValue = HandleScroll(Microsoft.Xna.Framework.Input.Buttons.LeftTrigger, Microsoft.Xna.Framework.Input.Buttons.RightTrigger); //Open Inventory if (padState.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.Y)) { controlInv = true; } if (padState.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.RightStick)) { rightStick=true; } else if(rightStick) { rightStick=false; aimMode++; if(aimMode>1) aimMode=0; } if (!Main.playerInventory) { //Use Tile if (padState.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.B)) { useTile=true; } else if(useTile) { useTile=false; player.controlUseTile=true; } HandleMovement(player); //Aiming if(aimMode==0) { Point stickPoint = new Point(1, 0); Vector2 stick = padState.ThumbSticks.Right; if (stick.X != 0 || stick.Y != 0) { stickPoint = updateStick(stick, (float)Player.tileRangeX); } else { stickPoint = new Point(1, 0); stick = padState.ThumbSticks.Left; if (stick.Y == 0) { stick.X = ((float)1 * (float)tPlayer.direction); } stickPoint = updateStick(stick, 2F); } if (Math.Abs(stickPoint.X) + Math.Abs(stickPoint.Y) > 0) { if (stickPoint.X != lastStickPoint.X || stickPoint.Y != lastStickPoint.Y) { Microsoft.Xna.Framework.Input.Mouse.SetPosition(stickPoint.X, stickPoint.Y); lastStickPoint.X = (int) stickPoint.X; lastStickPoint.Y = (int) stickPoint.Y; } } } else if(aimMode==1) { Vector2 stick = padState.ThumbSticks.Right; Point stickPoint = new Point(0, 0); //Add to velocity of mouse velocity = padState.ThumbSticks.Right; mousePos.X += (velocity.X/2); mousePos.Y += (velocity.Y/2); if(mousePos.X > (float)Player.tileRangeX) mousePos.X = (float)Player.tileRangeX; if(mousePos.X < (float)Player.tileRangeX*-1) mousePos.X = (float)Player.tileRangeX*-1; if(mousePos.Y > (float)Player.tileRangeY) mousePos.Y = (float)Player.tileRangeY; if(mousePos.Y < (float)Player.tileRangeY*-1) mousePos.Y = (float)Player.tileRangeY*-1; //Main.NewText(velocity.X+","+velocity.Y); int X = (int)((float)(Main.screenWidth / 2) + mousePos.X * 16f); //* (float)Player.tileRangeX int Y = (int)((float)(Main.screenHeight / 2) - mousePos.Y * 16f); //* 2F Microsoft.Xna.Framework.Input.Mouse.SetPosition(X, Y); } //Throw an Item! if (padState.Buttons.X == Microsoft.Xna.Framework.Input.ButtonState.Pressed) //padState.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.X)) // { player.controlThrow = true; //player.releaseThrow = true; } //Use an item! if (padState.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.RightShoulder)) { player.controlUseItem = true; } if(ScrollValue!=0) { player.selectedItem+=ScrollValue; if (ScrollValue != 0) { Main.PlaySound(12, -1, -1, 1); scrollCooldown = scrollCooldownAmt; } if (player.changeItem >= 0) { if (player.selectedItem != tPlayer.changeItem) Main.PlaySound(12, -1, -1, 1); player.selectedItem = player.changeItem; player.changeItem = -1; } while (player.selectedItem > 9) player.selectedItem -= 10; while (player.selectedItem < 0) player.selectedItem += 10; } } else { if (padState.Buttons.Back == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { Main.menuMode = 10; WorldGen.SaveAndQuit(); } if (padState.Buttons.Start == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { enableCraft=true; } else if(enableCraft) { showCraft=!showCraft; enableCraft=false; } if (padState.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.LeftShoulder)) { craftBtn=true; } else { craftBtn=false; //ModPlayer.stackSplit=0; } if(ScrollValue!=0) { invMenu+=ScrollValue; scrollCooldown = scrollCooldownAmt; if(invMenu==CHEST && Main.player[Main.myPlayer].chest==-1) invMenu+=ScrollValue; if(invMenu>invMenuMax) invMenu=0; if(invMenu<0) invMenu=invMenuMax; UpdateInvMouse(); } int craftScroll=0; //Handle craft selection if(craftCooldown<=0) { if(padState.ThumbSticks.Right.Y < 0) craftScroll++; else if (padState.ThumbSticks.Right.Y > 0) craftScroll--; craftCooldown=craftCooldownAmt; } else craftCooldown--; Main.focusRecipe+=craftScroll; if(Main.focusRecipe<0) Main.focusRecipe=0; if(Main.focusRecipe>Main.numAvailableRecipes) Main.focusRecipe=Main.numAvailableRecipes; //if(!padState.IsButtonDown(right) // && !padState.IsButtonDown(left)) scrollCooldown=0; if (padState.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.A)) { invSelectItem = true; } else if(invSelectItem) { invSelectItem=false; invSelectItemRelease = true; } if (padState.IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.RightShoulder)) { invSelectMore = true; } else { invSelectMore=false; //ModPlayer.stackSplit=0; } if(invCool<=0) { Point stickPoint = new Point(0, 0); Vector2 stick = padState.ThumbSticks.Left; if (stick.X != 0 || stick.Y != 0) { stickPoint.X = (int) stick.X; stickPoint.Y = (int) stick.Y; } if(Math.Abs(stickPoint.X) + Math.Abs(stickPoint.Y) > 0) { if(invMenu==INVENTORY) { //Main inventory of items //Inventory selection int oldSelectionX = invSelectionX; int oldSelectionY = invSelectionY; if(stickPoint.X > 0) { invSelectionX++; } else if(stickPoint.X < 0) { invSelectionX--; } else if (stickPoint.Y > 0) { invSelectionY--; } else if (stickPoint.Y < 0) { invSelectionY++; } if(invSelectionX>11) invSelectionX = 11; if(invSelectionX<0) invSelectionX = 0; if(invSelectionY>3) { if(Main.player[Main.myPlayer].chest!=-1) { invMenu=CHEST; chestSelY=0; chestSelX=invSelectionX-1; if(chestSelX>4) chestSelX=4; invCool = invCoolAmt; UpdateInvMouse(); } else invSelectionY = 3; } if(invSelectionY<0) invSelectionY = 0; if(oldSelectionX != invSelectionX || oldSelectionY != invSelectionY) { invCool = invCoolAmt; UpdateInvMouse(); } } else if(invMenu==CHEST) { if(Main.player[Main.myPlayer].chest==-1) { invMenu=0; UpdateInvMouse(); } else { int oldSelectionX = chestSelX; int oldSelectionY = chestSelY; if(stickPoint.X > 0) { chestSelX++; } else if(stickPoint.X < 0) { chestSelX--; } else if (stickPoint.Y > 0) { chestSelY--; } else if (stickPoint.Y < 0) { chestSelY++; } if(chestSelX>5) chestSelX = 5; if(chestSelX<0) chestSelX = 0; if(chestSelY>3) chestSelY = 3; if(chestSelY<0) { invMenu=ModPlayer.INVENTORY; chestSelY = 0; invSelectionY = 3; invSelectionX = chestSelX+1; invCool = invCoolAmt; } if(oldSelectionX != chestSelX || oldSelectionY != chestSelY) { invCool = invCoolAmt; UpdateInvMouse(); } } } /*else if(invMenu==COINS) { int prev = coinSel; if (stickPoint.Y > 0) { coinSel--; } else if (stickPoint.Y < 0) { coinSel++; } if(coinSel!=prev) { invCool = invCoolAmt; } }*/ else if(invMenu==ARMOR) { //Inventory selection int oldSelectionX = armorSel; //int oldSelectionY = invSelectionY; if(stickPoint.Y > 0) { armorSel--; } else if(stickPoint.Y < 0) { armorSel++; } else if (stickPoint.X > 0 && armorSel>=8) { armorSel-=8; } else if (stickPoint.X < 0 && armorSel<8) { armorSel+=8; } if(armorSel>10) armorSel = 10; if(armorSel<0) armorSel = 0; //if(invSelectionY>3) invSelectionY = 3; //if(invSelectionY<0) invSelectionY = 0; if(oldSelectionX != armorSel) { // || oldSelectionY != invSelectionY) { invCool = invCoolAmt; UpdateInvMouse(); } } } } } if (controlInv) { if (releaseInventory) { player.toggleInv(); if(Main.playerInventory) UpdateInvMouse(); } releaseInventory = false; } else releaseInventory = true; if (player.delayUseItem) { if (!player.controlUseItem) player.delayUseItem = false; player.controlUseItem = false; } if (player.itemAnimation == 0 && player.itemTime == 0) { player.dropItemCheck(); } } } //UpdateButtons(); }