// Decompiled with JetBrains decompiler // Type: Terraria.Player // Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null // MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83 // Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; using ReLogic.Utilities; using System; using System.Collections.Generic; using System.IO; using System.Security.Cryptography; using System.Text; using Terraria.Audio; using Terraria.Chat; using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent; using Terraria.GameContent.Achievements; using Terraria.GameContent.Creative; using Terraria.GameContent.Drawing; using Terraria.GameContent.Events; using Terraria.GameContent.Golf; using Terraria.GameContent.ObjectInteractions; using Terraria.GameContent.Tile_Entities; using Terraria.GameContent.UI; using Terraria.GameInput; using Terraria.Graphics; using Terraria.Graphics.Capture; using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.IO; using Terraria.Localization; using Terraria.ObjectData; using Terraria.Social; using Terraria.UI; using Terraria.UI.Chat; using Terraria.UI.Gamepad; using Terraria.Utilities; using Terraria.WorldBuilding; namespace Terraria { public class Player : Entity { public int emoteTime; public CreativeUnlocksTracker creativeTracker; private static byte[] ENCRYPTION_KEY = new UnicodeEncoding().GetBytes("h3y_gUyZ"); public Player.OverheadMessage chatOverhead; public Player.SelectionRadial DpadRadial = new Player.SelectionRadial(); public Player.SelectionRadial CircularRadial = new Player.SelectionRadial(Player.SelectionRadial.SelectionMode.RadialCircular); public Player.SelectionRadial QuicksRadial = new Player.SelectionRadial(Player.SelectionRadial.SelectionMode.RadialQuicks); public bool alchemyTable; public int HotbarOffset; public bool GoingDownWithGrapple; public byte spelunkerTimer; public bool[] hideInfo = new bool[13]; public int[] builderAccStatus = new int[12] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; public int lostCoins; public string lostCoinString = ""; public int soulDrain; public float drainBoost; public bool dd2Accessory; private static bool disabledBlizzardGraphic = false; private static bool disabledBlizzardSound = false; private static float _blizzardSoundVolume; private static SlotId _strongBlizzardSound = (SlotId) SlotId.Invalid; private static SlotId _insideBlizzardSound = (SlotId) SlotId.Invalid; public string name = ""; public int taxMoney; public int taxTimer; public static int taxRate = 3600; public static int crystalLeafDamage = 100; public static int crystalLeafKB = 10; public float basiliskCharge; public Vector2 lastDeathPostion; public DateTime lastDeathTime; public bool showLastDeath; public int extraAccessorySlots = 2; public bool extraAccessory; private bool dontConsumeWand; public int tankPet = -1; public bool tankPetReset; public int stringColor; public int counterWeight; public bool yoyoString; public bool yoyoGlove; public int beetleOrbs; public float beetleCounter; public int beetleCountdown; public bool beetleDefense; public bool beetleOffense; public bool beetleBuff; public int solarShields; public int solarCounter; public const int maxSolarShields = 3; public Vector2[] solarShieldPos = new Vector2[3]; public Vector2[] solarShieldVel = new Vector2[3]; public bool solarDashing; public bool solarDashConsumedFlare; public const int nebulaMaxLevel = 3; public int nebulaLevelLife; public int nebulaLevelMana; public int nebulaManaCounter; public int nebulaLevelDamage; public bool manaMagnet; public bool lifeMagnet; public bool treasureMagnet; public bool lifeForce; public bool calmed; public bool inferno; public float flameRingRot; public float flameRingScale = 1f; public byte flameRingFrame; public byte flameRingAlpha; public int netManaTime; public int netLifeTime; public bool netMana; public bool netLife; public Vector2[] beetlePos = new Vector2[3]; public Vector2[] beetleVel = new Vector2[3]; public int beetleFrame; public int beetleFrameCounter; public static int manaSickTime = 300; public static int manaSickTimeMax = 600; public static float manaSickLessDmg = 0.25f; public float manaSickReduction; public bool manaSick; public int afkCounter; public bool stairFall; public int loadStatus; public Vector2[] itemFlamePos = new Vector2[7]; public int itemFlameCount; public bool outOfRange; public float lifeSteal = 99999f; public float ghostDmg; public bool teleporting; public float teleportTime; public int teleportStyle; public bool sloping; public bool chilled; public bool dazed; public bool frozen; public bool stoned; public bool lastStoned; public bool ichor; public bool webbed; public bool tipsy; public bool noBuilding; public int ropeCount; public int manaRegenBonus; public int manaRegenDelayBonus; public int dashType; public int dash; public int dashTime; public int dashDelay; public int eocDash; public int eocHit; public float accRunSpeed; public bool cordage; public int gem = -1; public int gemCount; public BitsByte ownedLargeGems; public byte meleeEnchant; public byte pulleyDir; public bool pulley; public int pulleyFrame; public float pulleyFrameCounter; public bool blackBelt; public bool sliding; public int slideDir; public int launcherWait; public bool iceSkate; public bool carpet; public int spikedBoots; public int carpetFrame = -1; public float carpetFrameCounter; public bool canCarpet; public int carpetTime; public int miscCounter; public int infernoCounter; public int starCloakCooldown; public bool sandStorm; public bool crimsonRegen; public bool ghostHeal; public bool ghostHurt; public bool sticky; public bool slippy; public bool slippy2; public bool powerrun; public bool runningOnSand; public bool flapSound; public bool iceBarrier; public bool dangerSense; public byte luckPotion; public byte oldLuckPotion; public float endurance; public bool loveStruck; public bool stinky; public bool resistCold; public bool electrified; public bool dryadWard; public bool panic; public bool brainOfConfusion; public int brainOfConfusionDodgeAnimationCounter; public byte iceBarrierFrame; public byte iceBarrierFrameCounter; public bool shadowDodge; public float shadowDodgeCount; public bool palladiumRegen; public bool onHitDodge; public bool onHitRegen; public bool onHitPetal; public bool onHitTitaniumStorm; public bool hasTitaniumStormBuff; public int petalTimer; public int shadowDodgeTimer; public int phantomPhoneixCounter; public int fishingSkill; public bool cratePotion; public bool sonarPotion; public bool accFishingLine; public bool accTackleBox; public bool accLavaFishing; public int maxMinions = 1; public int numMinions; public float slotsMinions; public bool pygmy; public bool raven; public bool slime; public bool hornetMinion; public bool impMinion; public bool twinsMinion; public bool spiderMinion; public bool pirateMinion; public bool sharknadoMinion; public bool UFOMinion; public bool DeadlySphereMinion; public bool stardustMinion; public bool stardustGuardian; public bool stardustDragon; public bool batsOfLight; public bool babyBird; public bool vampireFrog; public bool stormTiger; public int highestStormTigerGemOriginalDamage; public bool smolstar; public bool empressBlade; public float wingTime; public int wings; public int wingsLogic; public int wingTimeMax; public int wingFrame; public int wingFrameCounter; public int skinVariant; public bool ghost; public int ghostFrame; public int ghostFrameCounter; public int miscTimer; public bool pvpDeath; public BitsByte zone1 = (BitsByte) (byte) 0; public BitsByte zone2 = (BitsByte) (byte) 0; public BitsByte zone3 = (BitsByte) (byte) 0; public BitsByte zone4 = (BitsByte) (byte) 0; public bool boneArmor; public bool frostArmor; public bool honey; public bool crystalLeaf; public PortableStoolUsage portableStoolInfo; public bool preventAllItemPickups; public bool dontHurtCritters; public int[] doubleTapCardinalTimer = new int[4]; public int[] holdDownCardinalTimer = new int[4]; public bool defendedByPaladin; public bool hasPaladinShield; public float[] speedSlice = new float[60]; public float townNPCs; public double headFrameCounter; public double bodyFrameCounter; public double legFrameCounter; public int netSkip; public int oldSelectItem; public bool immune; public bool immuneNoBlink; public int immuneTime; public int immuneAlphaDirection; public int immuneAlpha; public int team; private int _timeSinceLastImmuneGet; private int _immuneStrikes; public bool hbLocked; public static int nameLen = 20; public float maxRegenDelay; public int sign = -1; public bool editedChestName; public int reuseDelay; public int aggro; public float nearbyActiveNPCs; public bool creativeInterface; public bool mouseInterface; public bool lastMouseInterface; public int noThrow; public int changeItem = -1; public int selectedItem; public const int SupportedSlotsArmor = 3; public const int SupportedSlotsAccs = 7; public const int SupportedSlotSets = 10; public const int InitialAccSlotCount = 5; public const int miscSlotPet = 0; public const int miscSlotLight = 1; public const int miscSlotCart = 2; public const int miscSlotMount = 3; public const int miscSlotHook = 4; public Item[] armor = new Item[20]; public Item[] dye = new Item[10]; public Item[] miscEquips = new Item[5]; public Item[] miscDyes = new Item[5]; public Item trashItem = new Item(); public float itemRotation; public int itemWidth; public int itemHeight; public Vector2 itemLocation; public bool poundRelease; public float ghostFade; public float ghostDir = 1f; public const int maxBuffs = 22; public int[] buffType = new int[22]; public int[] buffTime = new int[22]; public bool[] buffImmune = new bool[323]; public int heldProj = -1; public int breathCD; public int breathMax = 200; public int breath = 200; public int lavaCD; public int lavaMax; public int lavaTime; public bool ignoreWater; public bool armorEffectDrawShadow; public bool armorEffectDrawShadowSubtle; public bool armorEffectDrawOutlines; public bool armorEffectDrawShadowLokis; public bool armorEffectDrawShadowBasilisk; public bool armorEffectDrawOutlinesForbidden; public bool armorEffectDrawShadowEOCShield; public bool socialShadowRocketBoots; public bool socialGhost; public bool shroomiteStealth; public bool socialIgnoreLight; public int stealthTimer; public float stealth = 1f; public bool isDisplayDollOrInanimate; public bool isHatRackDoll; public bool isFirstFractalAfterImage; public float firstFractalAfterImageOpacity; public string setBonus = ""; public Item[] inventory = new Item[59]; public bool[] inventoryChestStack = new bool[59]; public Item lastVisualizedSelectedItem; public Chest bank = new Chest(true); public Chest bank2 = new Chest(true); public Chest bank3 = new Chest(true); public Chest bank4 = new Chest(true); public BitsByte voidVaultInfo; public float headRotation; public float bodyRotation; public float legRotation; public Vector2 headPosition; public Vector2 bodyPosition; public Vector2 legPosition; public Vector2 headVelocity; public Vector2 bodyVelocity; public Vector2 legVelocity; public float fullRotation; public Vector2 fullRotationOrigin = Vector2.Zero; public int nonTorch = -1; public float gfxOffY; public float stepSpeed = 1f; public static bool deadForGood = false; public bool dead; public int respawnTimer; public const int respawnTimerMax = 1800; public long lastTimePlayerWasSaved; public int attackCD; public int potionDelay; public byte difficulty; public byte wetSlime; public HitTile hitTile; public HitTile hitReplace; public int jump; public int head = -1; public int body = -1; public int legs = -1; public sbyte handon = -1; public sbyte handoff = -1; public sbyte back = -1; public sbyte front = -1; public sbyte shoe = -1; public sbyte waist = -1; public sbyte shield = -1; public sbyte neck = -1; public sbyte face = -1; public sbyte balloon = -1; public bool[] hideVisibleAccessory = new bool[10]; public BitsByte hideMisc = (BitsByte) (byte) 0; public Microsoft.Xna.Framework.Rectangle headFrame; public Microsoft.Xna.Framework.Rectangle bodyFrame; public Microsoft.Xna.Framework.Rectangle legFrame; public Microsoft.Xna.Framework.Rectangle hairFrame; public bool controlLeft; public bool controlRight; public bool controlUp; public bool controlDown; public bool controlJump; public bool controlUseItem; public bool controlUseTile; public bool controlThrow; public bool controlInv; public bool controlHook; public bool controlTorch; public bool controlMap; public bool controlSmart; public bool controlMount; public bool releaseJump; public bool releaseUp; public bool releaseUseItem; public bool releaseUseTile; public bool releaseInventory; public bool releaseHook; public bool releaseThrow; public bool releaseQuickMana; public bool releaseQuickHeal; public bool releaseLeft; public bool releaseRight; public bool releaseSmart; public bool releaseMount; public bool releaseDown; public bool controlQuickMana; public bool controlQuickHeal; public bool controlCreativeMenu; public bool releaseCreativeMenu; public bool tileInteractionHappened; public bool tileInteractAttempted; public bool tryKeepingHoveringDown; public bool tryKeepingHoveringUp; public int altFunctionUse; public bool mapZoomIn; public bool mapZoomOut; public bool mapAlphaUp; public bool mapAlphaDown; public bool mapFullScreen; public bool mapStyle; public bool releaseMapFullscreen; public bool releaseMapStyle; public int leftTimer; public int rightTimer; public bool delayUseItem; public const int defaultWidth = 20; public const int defaultHeight = 42; public bool cursorItemIconEnabled; public bool cursorItemIconReversed; public int cursorItemIconID; public string cursorItemIconText = ""; public int runSoundDelay; public float shadow; public const int shadowMax = 3; public Vector2[] shadowPos = new Vector2[3]; public float[] shadowRotation = new float[3]; public Vector2[] shadowOrigin = new Vector2[3]; public int[] shadowDirection = new int[3]; public int shadowCount; public float manaCost = 1f; public bool fireWalk; public bool channel; public int step = -1; public bool skipAnimatingValuesInPlayerFrame; public Player.RabbitOrderFrameHelper rabbitOrderFrame; public bool creativeGodMode; private const int MaxAdvancedShadows = 60; public int availableAdvancedShadowsCount; private EntityShadowInfo[] _advancedShadows = new EntityShadowInfo[60]; private int _lastAddedAvancedShadow; public Player.CompositeArmData compositeFrontArm; public Player.CompositeArmData compositeBackArm; public int anglerQuestsFinished; public int golferScoreAccumulated; public int bartenderQuestLog; public bool downedDD2EventAnyDifficulty; public int armorPenetration; public int statDefense; public int statLifeMax = 100; public int statLifeMax2 = 100; public int statLife = 100; public int statMana; public int statManaMax; public int statManaMax2; public int lifeRegen; public int lifeRegenCount; public int lifeRegenTime; public int manaRegen; public int manaRegenCount; public int manaRegenDelay; public bool manaRegenBuff; public bool noKnockback; public bool spaceGun; public float gravDir = 1f; public bool chloroAmmoCost80; public bool ammoCost80; public bool ammoCost75; public int stickyBreak; public bool magicQuiver; public bool magmaStone; public bool lavaRose; public bool hasMoltenQuiver; public int phantasmTime; public bool ammoBox; public bool ammoPotion; public bool chaosState; public bool strongBees; public bool sporeSac; public bool shinyStone; public bool empressBrooch; public bool volatileGelatin; public int volatileGelatinCounter; public int yoraiz0rEye; public bool yoraiz0rDarkness; public bool hasUnicornHorn; public bool leinforsHair; public bool unlockedBiomeTorches; public bool suspiciouslookingTentacle; public bool crimsonHeart; public bool lightOrb; public bool blueFairy; public bool redFairy; public bool greenFairy; public bool bunny; public bool turtle; public bool eater; public bool penguin; public bool HasGardenGnomeNearby; public bool magicLantern; public bool rabid; public bool sunflower; public bool wellFed; public bool puppy; public bool grinch; public bool miniMinotaur; public bool flowerBoots; public bool fairyBoots; public bool moonLordLegs; public bool arcticDivingGear; public bool coolWhipBuff; public bool wearsRobe; public bool minecartLeft; public bool onWrongGround; public bool onTrack; public int cartRampTime; public bool cartFlip; public float trackBoost; public Vector2 lastBoost = Vector2.Zero; public Mount mount; public bool blackCat; public bool spider; public bool squashling; public bool petFlagDD2Gato; public bool petFlagDD2Ghost; public bool petFlagDD2Dragon; public bool petFlagUpbeatStar; public bool petFlagSugarGlider; public bool petFlagBabyShark; public bool petFlagLilHarpy; public bool petFlagFennecFox; public bool petFlagGlitteryButterfly; public bool petFlagBabyImp; public bool petFlagBabyRedPanda; public bool petFlagPlantero; public bool petFlagDynamiteKitten; public bool petFlagBabyWerewolf; public bool petFlagShadowMimic; public bool petFlagVoltBunny; public bool petFlagKingSlimePet; public bool petFlagEyeOfCthulhuPet; public bool petFlagEaterOfWorldsPet; public bool petFlagBrainOfCthulhuPet; public bool petFlagSkeletronPet; public bool petFlagQueenBeePet; public bool petFlagDestroyerPet; public bool petFlagTwinsPet; public bool petFlagSkeletronPrimePet; public bool petFlagPlanteraPet; public bool petFlagGolemPet; public bool petFlagDukeFishronPet; public bool petFlagLunaticCultistPet; public bool petFlagMoonLordPet; public bool petFlagFairyQueenPet; public bool petFlagPumpkingPet; public bool petFlagEverscreamPet; public bool petFlagIceQueenPet; public bool petFlagMartianPet; public bool petFlagDD2OgrePet; public bool petFlagDD2BetsyPet; public bool petFlagQueenSlimePet; public bool companionCube; public bool babyFaceMonster; public bool magicCuffs; public bool coldDash; public bool sailDash; public bool desertDash; public bool eyeSpring; public bool snowman; public bool scope; public bool dino; public bool skeletron; public bool hornet; public bool zephyrfish; public bool tiki; public bool parrot; public bool truffle; public bool sapling; public bool cSapling; public bool wisp; public bool lizard; public bool archery; public bool poisoned; public bool venom; public bool blind; public bool blackout; public bool headcovered; public bool frostBurn; public bool onFrostBurn; public bool burned; public bool suffocating; public byte suffocateDelay; public bool dripping; public bool drippingSlime; public bool drippingSparkleSlime; public bool onFire; public bool onFire2; public bool noItems; public bool cursed; public bool windPushed; public bool wereWolf; public bool wolfAcc; public bool hideMerman; public bool hideWolf; public bool forceMerman; public bool forceWerewolf; public bool rulerGrid; public bool rulerLine; public bool bleed; public bool confused; public bool accMerman; public bool merman; public bool trident; public bool brokenArmor; public bool silence; public bool slow; public bool gross; public bool tongued; public bool kbGlove; public bool kbBuff; public bool starCloak; public bool starCloakIsManaCloak; public bool starCloakIsStarVeil; public bool starCloakIsBeeCloak; public bool longInvince; public bool pStone; public bool manaFlower; public bool moonLeech; public bool vortexDebuff; public bool trapDebuffSource; public bool witheredArmor; public bool witheredWeapon; public bool slowOgreSpit; public bool parryDamageBuff; public bool ballistaPanic; public bool JustDroppedAnItem; public int meleeCrit = 4; public int magicCrit = 4; public int rangedCrit = 4; public float meleeDamage = 1f; public float magicDamage = 1f; public float rangedDamage = 1f; public float bulletDamage = 1f; public float arrowDamage = 1f; public float rocketDamage = 1f; public float minionDamage = 1f; public float minionKB; public float meleeSpeed = 1f; public float moveSpeed = 1f; public float pickSpeed = 1f; public float wallSpeed = 1f; public float tileSpeed = 1f; public bool autoPaint; public bool autoActuator; public int SpawnX = -1; public int SpawnY = -1; public Vector2? PotionOfReturnOriginalUsePosition; public Vector2? PotionOfReturnHomePosition; public int[] spX = new int[200]; public int[] spY = new int[200]; public string[] spN = new string[200]; public int[] spI = new int[200]; public static int tileRangeX = 5; public static int tileRangeY = 4; public int lastTileRangeX; public int lastTileRangeY; public static int tileTargetX; public static int tileTargetY; public static float defaultGravity = 0.4f; public static int jumpHeight = 15; public static float jumpSpeed = 5.01f; public float gravity = Player.defaultGravity; public float maxFallSpeed = 10f; public float maxRunSpeed = 3f; public float runAcceleration = 0.08f; public float runSlowdown = 0.2f; public bool adjWater; public bool adjHoney; public bool adjLava; public bool oldAdjWater; public bool oldAdjHoney; public bool oldAdjLava; public bool[] adjTile = new bool[623]; public bool[] oldAdjTile = new bool[623]; public static int defaultItemGrabRange = 42; private static float itemGrabSpeed = 0.45f; private static float itemGrabSpeedMax = 4f; public byte hairDye; public Color hairDyeColor = Color.Transparent; public float hairDyeVar; public int skinDyePacked; public Color hairColor = new Color(215, 90, 55); public Color skinColor = new Color((int) byte.MaxValue, 125, 90); public Color eyeColor = new Color(105, 90, 75); public Color shirtColor = new Color(175, 165, 140); public Color underShirtColor = new Color(160, 180, 215); public Color pantsColor = new Color((int) byte.MaxValue, 230, 175); public Color shoeColor = new Color(160, 105, 60); public int hair; public bool hostile; public SoundPlaySet hermesStepSound = new SoundPlaySet(); public Vector2 instantMovementAccumulatedThisFrame; public int accCompass; public int accWatch; public int accDepthMeter; public bool accFishFinder; public bool accWeatherRadio; public bool accJarOfSouls; public bool accCalendar; public int lastCreatureHit = -1; public bool accThirdEye; public byte accThirdEyeCounter; public byte accThirdEyeNumber; public bool accStopwatch; public bool accOreFinder; public bool accCritterGuide; public byte accCritterGuideCounter; public byte accCritterGuideNumber; public bool accDreamCatcher; public bool hasFootball; public bool drawingFootball; public bool ActuationRodLock; public bool ActuationRodLockSetting; public bool InfoAccMechShowWires; public DateTime dpsStart; public DateTime dpsEnd; public DateTime dpsLastHit; public int dpsDamage; public bool dpsStarted; public string displayedFishingInfo = ""; public bool discount; public bool coins; public bool goldRing; public bool accDivingHelm; public bool accFlipper; public bool hasJumpOption_Cloud; public bool canJumpAgain_Cloud; public bool isPerformingJump_Cloud; public bool hasJumpOption_Sandstorm; public bool canJumpAgain_Sandstorm; public bool isPerformingJump_Sandstorm; public bool hasJumpOption_Blizzard; public bool canJumpAgain_Blizzard; public bool isPerformingJump_Blizzard; public bool hasJumpOption_Fart; public bool canJumpAgain_Fart; public bool isPerformingJump_Fart; public bool hasJumpOption_Sail; public bool canJumpAgain_Sail; public bool isPerformingJump_Sail; public bool hasJumpOption_Unicorn; public bool canJumpAgain_Unicorn; public bool isPerformingJump_Unicorn; public bool hasJumpOption_Santank; public bool canJumpAgain_Santank; public bool isPerformingJump_Santank; public bool hasJumpOption_WallOfFleshGoat; public bool canJumpAgain_WallOfFleshGoat; public bool isPerformingJump_WallOfFleshGoat; public bool hasJumpOption_Basilisk; public bool canJumpAgain_Basilisk; public bool isPerformingJump_Basilisk; public bool isPerformingPogostickTricks; public bool autoJump; public bool justJumped; public float jumpSpeedBoost; public int extraFall; public bool canFloatInWater; public bool hasFloatingTube; public bool frogLegJumpBoost; public bool skyStoneEffects; public bool spawnMax; public int blockRange; public int[] grappling = new int[20]; public int grapCount; public int rocketTime; public int rocketTimeMax = 7; public int rocketDelay; public int rocketDelay2; public bool rocketRelease; public bool rocketFrame; public int rocketBoots; public bool canRocket; public bool jumpBoost; public bool noFallDmg; public int swimTime; public bool killGuide; public bool killClothier; public bool lavaImmune; public bool gills; public bool slowFall; public bool findTreasure; public bool invis; public bool detectCreature; public bool nightVision; public bool enemySpawns; public float thorns; public bool turtleArmor; public bool turtleThorns; public bool spiderArmor; public bool CanSeeInvisibleBlocks; public bool setSolar; public bool setVortex; public bool setNebula; public int nebulaCD; public bool setStardust; public bool setForbidden; public bool setForbiddenCooldownLocked; public bool setSquireT3; public bool setHuntressT3; public bool setApprenticeT3; public bool setMonkT3; public bool setSquireT2; public bool setHuntressT2; public bool setApprenticeT2; public bool setMonkT2; public int maxTurrets = 1; public int maxTurretsOld = 1; public bool vortexStealthActive; public bool waterWalk; public bool waterWalk2; public bool gravControl; public bool gravControl2; public bool releaseBeesWhenHurt; public int wireOperationsCooldown; public int lastChest; public int flyingPigChest = -1; public int voidLensChest = -1; public int chest = -1; public int chestX; public int chestY; public int fallStart; public int fallStart2; public int potionDelayTime = Item.potionDelay; public int restorationDelayTime = Item.restorationDelay; public bool isPettingAnimal; public bool isTheAnimalBeingPetSmall; public PlayerSittingHelper sitting; public PlayerSleepingHelper sleeping; public PlayerEyeHelper eyeHelper; public PlayerInteractionAnchor tileEntityAnchor; public DoorOpeningHelper doorHelper; public ShoppingSettings currentShoppingSettings = ShoppingSettings.NotInShop; public int cHead; public int cBody; public int cLegs; public int cHandOn; public int cHandOff; public int cBack; public int cFront; public int cShoe; public int cWaist; public int cShield; public int cNeck; public int cFace; public int cBalloon; public int cWings; public int cCarpet; public int cFloatingTube; public int cGrapple; public int cMount; public int cMinecart; public int cPet; public int cLight; public int cYorai; public int cPortalbeStool; public int cUnicornHorn; public int cMinion; public int cLeinShampoo; public int[] ownedProjectileCounts = new int[950]; public bool[] npcTypeNoAggro = new bool[663]; public int lastPortalColorIndex; public int _portalPhysicsTime; public bool portalPhysicsFlag; public int lastTeleportPylonStyleUsed; public float MountFishronSpecialCounter; public Vector2 MinionRestTargetPoint = Vector2.Zero; public int MinionAttackTargetNPC = -1; public List TouchedTiles = new List(); public int itemAnimation; public int itemAnimationMax; public int itemTime; public int itemTimeMax; public int toolTime; public static int BlockInteractionWithProjectiles = 3; private HashSet _blackListedTileCoordsForGrappling = new HashSet(); private bool makeStrongBee; public bool equippedAnyTileRangeAcc; public bool equippedAnyTileSpeedAcc; public bool equippedAnyWallSpeedAcc; public bool behindBackWall; public int _funkytownAchievementCheckCooldown; private float _stormShaderObstruction = 1f; private float _shaderObstructionInternalValue = 1f; private int graveImmediateTime; public const int ChairSittingMaxDistance = 40; private static SmartInteractSystem _smartInteractSys = new SmartInteractSystem(); private int _lastSmartCursorToolStrategy = -1; private bool[] nearbyTorch = new bool[22]; private bool dryCoralTorch; private int luckyTorchCounter; private int nearbyTorches; public float torchLuck; public bool happyFunTorchTime; private int torchFunTimer; private int torchGodCooldown; private int numberOfTorchAttacks; private static int maxTorchAttacks = 200; private int[] unlitTorchX = new int[Player.maxTorchAttacks]; private int[] unlitTorchY = new int[Player.maxTorchAttacks]; private static int[] _torchAttackPosX = new int[400]; private static int[] _torchAttackPosY = new int[400]; public int ladyBugLuckTimeLeft; public float luck; public float luckMinimumCap = -0.7f; public float luckMaximumCap = 1f; public bool luckNeedsSync; private int _quickGrappleCooldown; public PlayerMovementAccsCache movementAbilitiesCache; public float wingAccRunSpeed = -1f; public float wingRunAccelerationMult = 1f; public const int SHIELD_PARRY_DURATION = 20; public const int SHIELD_PARRY_DURATION_DRAWING_TWEAKER = 20; public const int SHIELD_PARRY_DAMAGE_BUFF_MULTIPLIER = 5; public bool hasRaisableShield; public bool shieldRaised; public int shieldParryTimeLeft; public int shield_parry_cooldown; private bool _forceForwardCursor; private Point _inputMouseCoordsForward; private Point _mainMouseCoordsForward; private bool _forceSmartSelectCursor; private Point _inputMouseCoordsSmartSelect; private Point _mainMouseCoordsSmartSelect; private Point _tileTargetSmartSelect; private bool botherWithUnaimedMinecartTracks = true; private List _projectilesToInteractWith = new List(); private int _lockTileInteractionsTimer; public int[] hurtCooldowns = new int[4]; public static bool lastPound = true; public static int musicNotes = 6; private static List _oldestProjCheckList = new List(); public Player.SavedPlayerDataWithAnnoyingRules savedPerPlayerFieldsThatArentInThePlayerClass; private const int SaveSlotIndex_MouseItem = 0; private const int SaveSlotIndex_CreativeSacrifice = 1; private const int SaveSlotIndexCount = 2; private Item[] _temporaryItemSlots = new Item[2]; public Vector2 BlehOldPositionFixer => -Vector2.UnitY; public float HeightOffsetVisual { get { if (this.mount.Active) return (float) this.mount.PlayerOffset; return this.portableStoolInfo.IsInUse ? (float) this.portableStoolInfo.VisualYOffset : 0.0f; } } public float HeightOffsetHitboxCenter { get { if (this.mount.Active) return (float) this.mount.PlayerOffsetHitbox; return this.portableStoolInfo.IsInUse ? (float) (this.portableStoolInfo.HeightBoost - this.portableStoolInfo.VisualYOffset) : 0.0f; } } public int HeightOffsetBoost { get { if (this.mount.Active) return this.mount.HeightBoost; return this.portableStoolInfo.IsInUse ? this.portableStoolInfo.HeightBoost : 0; } } public int HeightMapOffset { get { if (this.mount.Active) return this.mount.PlayerHeadOffset; return this.portableStoolInfo.IsInUse ? this.portableStoolInfo.HeightBoost : 0; } } public Vector2 MountedCenter { get => new Vector2(this.position.X + (float) (this.width / 2), this.position.Y + 21f + this.HeightOffsetHitboxCenter); set => this.position = new Vector2(value.X - (float) (this.width / 2), value.Y - 21f - this.HeightOffsetHitboxCenter); } public void RotateRelativePoint(ref float x, ref float y) { Vector2 vector2 = this.RotatedRelativePoint(new Vector2(x, y)); x = vector2.X; y = vector2.Y; } public Vector2 RotatedRelativePointOld(Vector2 pos, bool rotateForward = true) { Vector2 vector2 = this.position + this.fullRotationOrigin; Matrix rotationZ = Matrix.CreateRotationZ(this.fullRotation * (float) rotateForward.ToInt()); pos -= this.position + this.fullRotationOrigin; pos = Vector2.Transform(pos, rotationZ); return pos + vector2; } public Vector2 RotatedRelativePoint(Vector2 pos, bool reverseRotation = false, bool addGfxOffY = true) { float num1 = reverseRotation ? -this.fullRotation : this.fullRotation; if (this.sleeping.isSleeping) num1 = 0.0f; Vector2 vector2_1 = this.Bottom + new Vector2(0.0f, this.gfxOffY); int num2 = this.mount.PlayerOffset / 2 + 4; Vector2 vector2_2 = new Vector2(0.0f, (float) -num2) + new Vector2(0.0f, (float) num2).RotatedBy((double) num1); if (addGfxOffY) pos.Y += this.gfxOffY; pos = vector2_1 + (pos - vector2_1).RotatedBy((double) num1) + vector2_2; if (this.sleeping.isSleeping) { Vector2 posOffset; this.sleeping.GetSleepingOffsetInfo(this, out posOffset); pos += posOffset; } if (this.sitting.isSitting) { Vector2 posOffset; float seatAdjustment; this.sitting.GetSittingOffsetInfo(this, out posOffset, out seatAdjustment); pos += posOffset + new Vector2(0.0f, seatAdjustment); } return pos; } public bool TileReplacementEnabled => this.builderAccStatus[10] == 0; public override Vector2 VisualPosition => this.position + new Vector2(0.0f, this.gfxOffY); public bool CCed => this.frozen || this.webbed || this.stoned; public bool CanDemonHeartAccessoryBeShown() => this.IsAValidEquipmentSlotForIteration(8) || this.armor[8].type > 0 || this.armor[18].type > 0 || this.dye[8].type > 0; public bool CanMasterModeAccessoryBeShown() => this.IsAValidEquipmentSlotForIteration(9) || this.armor[9].type > 0 || this.armor[19].type > 0 || this.dye[9].type > 0; public int GetAmountOfExtraAccessorySlotsToShow() { int num = 0; if (this.CanDemonHeartAccessoryBeShown()) ++num; if (this.CanMasterModeAccessoryBeShown()) ++num; return num; } public float miscCounterNormalized => (float) this.miscCounter / 300f; public bool Male { get => PlayerVariantID.Sets.Male[this.skinVariant]; set { if (value) { if (this.Male) return; this.skinVariant = PlayerVariantID.Sets.AltGenderReference[this.skinVariant]; } else { if (!this.Male) return; this.skinVariant = PlayerVariantID.Sets.AltGenderReference[this.skinVariant]; } } } public bool ZoneDungeon { get => this.zone1[0]; set => this.zone1[0] = value; } public bool ZoneCorrupt { get => this.zone1[1]; set => this.zone1[1] = value; } public bool ZoneHallow { get => this.zone1[2]; set => this.zone1[2] = value; } public bool ZoneMeteor { get => this.zone1[3]; set => this.zone1[3] = value; } public bool ZoneJungle { get => this.zone1[4]; set => this.zone1[4] = value; } public bool ZoneSnow { get => this.zone1[5]; set => this.zone1[5] = value; } public bool ZoneCrimson { get => this.zone1[6]; set => this.zone1[6] = value; } public bool ZoneWaterCandle { get => this.zone1[7]; set => this.zone1[7] = value; } public bool ZonePeaceCandle { get => this.zone2[0]; set => this.zone2[0] = value; } public bool ZoneTowerSolar { get => this.zone2[1]; set => this.zone2[1] = value; } public bool ZoneTowerVortex { get => this.zone2[2]; set => this.zone2[2] = value; } public bool ZoneTowerNebula { get => this.zone2[3]; set => this.zone2[3] = value; } public bool ZoneTowerStardust { get => this.zone2[4]; set => this.zone2[4] = value; } public bool ZoneDesert { get => this.zone2[5]; set => this.zone2[5] = value; } public bool ZoneGlowshroom { get => this.zone2[6]; set => this.zone2[6] = value; } public bool ZoneUndergroundDesert { get => this.zone2[7]; set => this.zone2[7] = value; } public bool ZoneSkyHeight { get => this.zone3[0]; set => this.zone3[0] = value; } public bool ZoneOverworldHeight { get => this.zone3[1]; set => this.zone3[1] = value; } public bool ZoneDirtLayerHeight { get => this.zone3[2]; set => this.zone3[2] = value; } public bool ZoneRockLayerHeight { get => this.zone3[3]; set => this.zone3[3] = value; } public bool ZoneUnderworldHeight { get => this.zone3[4]; set => this.zone3[4] = value; } public bool ZoneBeach { get => this.zone3[5]; set => this.zone3[5] = value; } public bool ZoneRain { get => this.zone3[6]; set => this.zone3[6] = value; } public bool ZoneSandstorm { get => this.zone3[7]; set => this.zone3[7] = value; } public bool ZoneOldOneArmy { get => this.zone4[0]; set => this.zone4[0] = value; } public bool ZoneGranite { get => this.zone4[1]; set => this.zone4[1] = value; } public bool ZoneMarble { get => this.zone4[2]; set => this.zone4[2] = value; } public bool ZoneHive { get => this.zone4[3]; set => this.zone4[3] = value; } public bool ZoneGemCave { get => this.zone4[4]; set => this.zone4[4] = value; } public bool ZoneLihzhardTemple { get => this.zone4[5]; set => this.zone4[5] = value; } public bool ZoneGraveyard { get => this.zone4[6]; set => this.zone4[6] = value; } public Vector2 Directions => new Vector2((float) this.direction, this.gravDir); public Item HeldItem => this.inventory[this.selectedItem]; public int breathCDMax { get { int num = 7; if (this.inventory[this.selectedItem].type == 186 && this.itemAnimation == 0) num *= 2; if (this.accDivingHelm) num *= 4; return num; } } public bool ShouldFloatInWater { get { if (!this.canFloatInWater || this.controlDown) return false; return !this.mount.Active || this.mount.Type == 37; } } public bool CanBeTalkedTo => this.active && !this.dead && !this.ShouldNotDraw && (double) this.stealth == 1.0; public bool IsVoidVaultEnabled { get => this.voidVaultInfo[0]; set => this.voidVaultInfo[0] = value; } public bool DeadOrGhost => this.dead || this.ghost; public bool TryingToHoverUp => this.controlUp || this.tryKeepingHoveringUp; public bool TryingToHoverDown => this.controlDown || this.tryKeepingHoveringDown; public Vector2 DefaultSize => new Vector2(20f, 42f); public EntityShadowInfo GetAdvancedShadow(int shadowIndex) { if (shadowIndex > this.availableAdvancedShadowsCount) shadowIndex = this.availableAdvancedShadowsCount; return this._advancedShadows[(this._lastAddedAvancedShadow - shadowIndex).ModulusPositive(60)]; } public void UpdateAdvancedShadows() { ++this.availableAdvancedShadowsCount; if (this.availableAdvancedShadowsCount > 60) this.availableAdvancedShadowsCount = 60; if (++this._lastAddedAvancedShadow >= 60) this._lastAddedAvancedShadow = 0; this._advancedShadows[this._lastAddedAvancedShadow].CopyPlayer(this); } public void ResetAdvancedShadows() => this.availableAdvancedShadowsCount = 0; public void SetCompositeArmFront( bool enabled, Player.CompositeArmStretchAmount stretch, float rotation) { if ((double) this.gravDir == -1.0) rotation = -rotation; this.compositeFrontArm = new Player.CompositeArmData(enabled, stretch, rotation); } public void SetCompositeArmBack( bool enabled, Player.CompositeArmStretchAmount stretch, float rotation) { if ((double) this.gravDir == -1.0) rotation = -rotation; this.compositeBackArm = new Player.CompositeArmData(enabled, stretch, rotation); } public bool UsingBiomeTorches { get => this.unlockedBiomeTorches && this.builderAccStatus[11] == 0; set => this.builderAccStatus[11] = value ? 0 : 1; } public bool ShouldNotDraw => this.invis && this.itemAnimation == 0 && !this.isDisplayDollOrInanimate && !this.isHatRackDoll; public int talkNPC { get; private set; } public bool isLockedToATile => this.sitting.isSitting || this.sleeping.isSleeping; public void SetTalkNPC(int npcIndex, bool fromNet = false) { this.talkNPC = npcIndex; if (Main.netMode != 1 && npcIndex >= 0 && npcIndex < 200) Main.BestiaryTracker.Chats.RegisterChatStartWith(Main.npc[npcIndex]); if (this.talkNPC == -1) this.currentShoppingSettings = ShoppingSettings.NotInShop; else this.currentShoppingSettings = Main.ShopHelper.GetShoppingSettings(this, Main.npc[this.talkNPC]); } public bool PortalPhysicsEnabled => this._portalPhysicsTime > 0 && !this.mount.Active; public bool MountFishronSpecial { get { if (this.statLife < this.statLifeMax2 / 2 || this.wet && !this.lavaWet && !this.honeyWet || this.dripping || (double) this.MountFishronSpecialCounter > 0.0) return true; return Main.raining && WorldGen.InAPlaceWithWind(this.position, this.width, this.height); } } public bool HasMinionRestTarget => this.MinionRestTargetPoint != Vector2.Zero; public bool HasMinionAttackTargetNPC => this.MinionAttackTargetNPC != -1; public bool ItemTimeIsZero => this.itemTime == 0; public void SetItemTime(int frames) { this.itemTime = frames; this.itemTimeMax = frames; } public void ApplyItemTime(Item sItem) => this.SetItemTime(sItem.useTime); public void ApplyItemTime(Item sItem, float multiplier) => this.SetItemTime((int) ((double) sItem.useTime * (double) multiplier)); public void SetDummyItemTime(int frames) { this.itemAnimation = frames; this.itemTime = frames; this.itemTimeMax = frames + 1; } private void SetItemAnimation(int frames) { this.itemAnimation = frames; this.itemAnimationMax = frames; } private void ApplyItemAnimation(Item sItem, float multiplier, int itemReuseDelay = 0) { this.SetItemAnimation((int) ((double) sItem.useAnimation * (double) multiplier)); this.reuseDelay = itemReuseDelay; } private void ApplyItemAnimation(Item sItem) { if (sItem.melee) this.SetItemAnimation((int) ((double) sItem.useAnimation * (double) this.meleeSpeed)); else if (sItem.summon && ItemID.Sets.SummonerWeaponThatScalesWithAttackSpeed[sItem.type]) this.SetItemAnimation((int) ((double) sItem.useAnimation * (double) this.meleeSpeed)); else if (sItem.createTile >= 0) this.SetItemAnimation((int) ((double) sItem.useAnimation * (double) this.tileSpeed)); else if (sItem.createWall >= 0) { this.SetItemAnimation((int) ((double) sItem.useAnimation * (double) this.wallSpeed)); } else { this.SetItemAnimation(sItem.useAnimation); this.reuseDelay = sItem.reuseDelay; } } public bool InOpposingTeam(Player otherPlayer) { if (!this.hostile || !otherPlayer.hostile) return false; return otherPlayer.team == 0 || otherPlayer.team != this.team; } public bool TeamChangeAllowed() => true; public void HealEffect(int healAmount, bool broadcast = true) { CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int) this.position.X, (int) this.position.Y, this.width, this.height), CombatText.HealLife, healAmount); if (!broadcast || Main.netMode != 1 || this.whoAmI != Main.myPlayer) return; NetMessage.SendData(35, number: this.whoAmI, number2: ((float) healAmount)); } public void ManaEffect(int manaAmount) { CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int) this.position.X, (int) this.position.Y, this.width, this.height), CombatText.HealMana, manaAmount); if (Main.netMode != 1 || this.whoAmI != Main.myPlayer) return; NetMessage.SendData(43, number: this.whoAmI, number2: ((float) manaAmount)); } public void InterruptItemUsageIfOverTile(int tileTypeToBeOver) { Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; if (tile == null || !tile.active() || (int) tile.type != tileTypeToBeOver) return; Main.blockMouse = true; } public Vector2 GetHelmetDrawOffset() { Vector2 vector2 = Vector2.Zero; if ((this.hair == 15 || this.hair == 76 || this.hair == 108) && this.head == 222) vector2 = new Vector2(0.0f, 4f) * this.Directions; return vector2; } public void AccumulateGolfingScore(int score) { int num = score; if (this.golferScoreAccumulated + num > 1000000000) num = 1000000000 - this.golferScoreAccumulated; this.golferScoreAccumulated += num; } public static byte FindClosest(Vector2 Position, int Width, int Height) { byte num1 = 0; for (int index = 0; index < (int) byte.MaxValue; ++index) { if (Main.player[index].active) { num1 = (byte) index; break; } } float num2 = -1f; for (int index = 0; index < (int) byte.MaxValue; ++index) { if (Main.player[index].active && !Main.player[index].dead) { float num3 = Math.Abs((float) ((double) Main.player[index].position.X + (double) (Main.player[index].width / 2) - ((double) Position.X + (double) (Width / 2)))) + Math.Abs((float) ((double) Main.player[index].position.Y + (double) (Main.player[index].height / 2) - ((double) Position.Y + (double) (Height / 2)))); if ((double) num2 == -1.0 || (double) num3 < (double) num2) { num2 = num3; num1 = (byte) index; } } } return num1; } public void ToggleInv() { bool interactAreShared = PlayerInput.GrappleAndInteractAreShared; if (Main.mapFullscreen) { Main.mapFullscreen = false; this.releaseInventory = false; SoundEngine.PlaySound(11); } else if (PlayerInput.InBuildingMode) PlayerInput.ExitBuildingMode(); else if (Main.ingameOptionsWindow) { if (PlayerInput.UsingGamepadUI && UILinkPointNavigator.CurrentPage == 1002) UILinkPointNavigator.ChangePage(1001); else IngameOptions.Close(); } else if (Main.inFancyUI) IngameFancyUI.Close(); else if (CaptureManager.Instance.Active) CaptureManager.Instance.Active = false; else if (this.talkNPC >= 0) { this.SetTalkNPC(-1); Main.npcChatCornerItem = 0; Main.npcChatText = ""; SoundEngine.PlaySound(11); if (PlayerInput.UsingGamepad) Main.npcChatRelease = false; } else if (this.sign >= 0) { this.sign = -1; Main.editSign = false; Main.npcChatText = ""; SoundEngine.PlaySound(11); } else if (Main.clothesWindow) Main.CancelClothesWindow(); else if (!Main.playerInventory) { Player.OpenInventory(); } else { Main.playerInventory = false; if (this.channel && Main.mouseItem != null && !Main.mouseItem.IsAir) this.channel = false; this.tileEntityAnchor.Clear(); if (!PlayerInput.UsingGamepad) { Main.EquipPageSelected = 0; } else { PlayerInput.NavigatorUnCachePosition(); Main.GamepadCursorAlpha = 0.0f; Player.BlockInteractionWithProjectiles = 3; if (PlayerInput.GrappleAndInteractAreShared) this.LockGamepadTileInteractions(); } SoundEngine.PlaySound(11); if (ItemSlot.Options.HighlightNewItems) { foreach (Item obj in this.inventory) obj.newAndShiny = false; } if (PlayerInput.UsingGamepad) { Main.npcChatRelease = false; this.tileInteractionHappened = true; this.releaseInventory = false; Main.mouseRight = true; } } if (!interactAreShared) return; this.GamepadEnableGrappleCooldown(); } private static void OpenInventory() { Recipe.FindRecipes(); Main.playerInventory = true; Main.EquipPageSelected = 0; SoundEngine.PlaySound(10); } public void ToggleCreativeMenu() { if (this.dead || this.difficulty != (byte) 3) return; bool flag = false; if (Main.mapFullscreen) { Main.mapFullscreen = false; flag = true; } if (PlayerInput.InBuildingMode) PlayerInput.ExitBuildingMode(); if (Main.ingameOptionsWindow) IngameOptions.Close(); if (Main.inFancyUI) IngameFancyUI.Close(); if (CaptureManager.Instance.Active) CaptureManager.Instance.Active = false; if (this.talkNPC >= 0) { this.SetTalkNPC(-1); Main.npcChatCornerItem = 0; Main.npcChatText = ""; flag = true; if (PlayerInput.UsingGamepad) Main.npcChatRelease = false; } if (this.sign >= 0) { this.sign = -1; Main.editSign = false; Main.npcChatText = ""; flag = true; } else if (Main.clothesWindow) Main.CancelClothesWindow(); if (this.tileEntityAnchor.InUse) { Recipe.FindRecipes(); this.tileEntityAnchor.Clear(); flag = true; } if (flag) SoundEngine.PlaySound(11); if (!Main.playerInventory) Player.OpenInventory(); Main.CreativeMenu.ToggleMenu(); } public void dropItemCheck() { if (!Main.playerInventory) this.noThrow = 0; if (this.noThrow > 0) --this.noThrow; GetItemSettings itemInDropItemCheck = GetItemSettings.GetItemInDropItemCheck; if (!Main.InGuideCraftMenu && Main.guideItem.type > 0) { Main.guideItem.position = this.Center; Item obj = this.GetItem(this.whoAmI, Main.guideItem, itemInDropItemCheck); if (obj.stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, obj.type, obj.stack, pfix: ((int) Main.guideItem.prefix), noGrabDelay: true); Main.item[number].newAndShiny = false; if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); } Main.guideItem = new Item(); } if (!Main.InReforgeMenu && Main.reforgeItem.type > 0) { Main.reforgeItem.position = this.Center; Item obj = this.GetItem(this.whoAmI, Main.reforgeItem, itemInDropItemCheck); if (obj.stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, obj.type, obj.stack, pfix: ((int) Main.reforgeItem.prefix), noGrabDelay: true); Main.item[number].newAndShiny = false; if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); } Main.reforgeItem = new Item(); } if (Main.myPlayer == this.whoAmI) this.inventory[58] = Main.mouseItem.Clone(); bool flag = true; if (Main.mouseItem.type > 0 && Main.mouseItem.stack > 0) { if (!Main.gamePaused) { Player.tileTargetX = (int) (((double) Main.mouseX + (double) Main.screenPosition.X) / 16.0); Player.tileTargetY = (int) (((double) Main.mouseY + (double) Main.screenPosition.Y) / 16.0); if ((double) this.gravDir == -1.0) Player.tileTargetY = (int) (((double) Main.screenPosition.Y + (double) Main.screenHeight - (double) Main.mouseY) / 16.0); } if (this.selectedItem != 58) this.oldSelectItem = this.selectedItem; this.selectedItem = 58; flag = false; } if (flag && this.selectedItem == 58 && this.ItemTimeIsZero && this.itemAnimation == 0) this.selectedItem = this.oldSelectItem; if (Main.mouseItem.type > 0 && !Main.playerInventory) { Main.mouseItem.position = this.Center; Item obj = this.GetItem(this.whoAmI, Main.mouseItem, itemInDropItemCheck); if (obj.stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, obj.type, obj.stack, pfix: ((int) Main.mouseItem.prefix), noGrabDelay: true); Main.item[number].newAndShiny = false; if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); } Main.mouseItem = new Item(); this.inventory[58] = new Item(); Recipe.FindRecipes(); } if ((this.controlThrow && this.releaseThrow && !this.inventory[this.selectedItem].favorited && this.inventory[this.selectedItem].type > 0 && !Main.drawingPlayerChat || (Main.mouseRight && !this.mouseInterface && Main.mouseRightRelease || !Main.playerInventory) && Main.mouseItem.type > 0 && Main.mouseItem.stack > 0) && this.noThrow <= 0) this.DropSelectedItem(); if (!Main.gamePaused || this.selectedItem != 58) return; this.selectedItem = this.oldSelectItem; } public void DropSelectedItem() { bool flag = false; if (this.inventory[this.selectedItem].favorited) { this.inventory[this.selectedItem] = this.GetItem(this.whoAmI, this.inventory[this.selectedItem], GetItemSettings.GetItemInDropItemCheck); if (this.selectedItem == 58) Main.mouseItem = this.inventory[this.selectedItem]; Recipe.FindRecipes(); if (this.inventory[this.selectedItem].type == 0) flag = true; } if (flag) return; Item obj = new Item(); if ((Main.mouseRight && !this.mouseInterface && Main.mouseRightRelease || !Main.playerInventory) && Main.mouseItem.type > 0 && Main.mouseItem.stack > 0) { obj = this.inventory[this.selectedItem]; this.inventory[this.selectedItem] = Main.mouseItem; this.delayUseItem = true; this.controlUseItem = false; } int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, this.inventory[this.selectedItem].type); this.inventory[this.selectedItem].position = Main.item[number].position; Main.item[number] = this.inventory[this.selectedItem]; this.inventory[this.selectedItem] = new Item(); if (this.selectedItem == 58) Main.mouseItem = new Item(); if (Main.netMode == 0) Main.item[number].noGrabDelay = 100; Main.item[number].velocity.Y = -2f; Main.item[number].velocity.X = (float) (4 * this.direction) + this.velocity.X; Main.item[number].favorited = false; Main.item[number].newAndShiny = false; if ((Main.mouseRight && !this.mouseInterface || !Main.playerInventory) && Main.mouseItem.type > 0) { this.inventory[this.selectedItem] = obj; Main.mouseItem = new Item(); } else { this.SetItemAnimation(10); this.JustDroppedAnItem = true; this.DropSelectedItem_InterruptActionsThatUseAnimations(); } Recipe.FindRecipes(); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number); } private void DropSelectedItem_InterruptActionsThatUseAnimations() { if (this.heldProj >= 0) { Projectile projectile = Main.projectile[this.heldProj]; if (projectile.active && projectile.owner == this.whoAmI) projectile.Kill(); } for (int index = 0; index < 1000; ++index) { Projectile projectile = Main.projectile[index]; if (projectile.active && projectile.owner == this.whoAmI && (projectile.aiStyle == 61 || projectile.aiStyle == 160)) projectile.Kill(); } } public int FindBuffIndex(int type) { if (this.buffImmune[type]) return -1; for (int index = 0; index < 22; ++index) { if (this.buffTime[index] >= 1 && this.buffType[index] == type) return index; } return -1; } public void AddBuff(int type, int timeToAdd, bool quiet = true, bool foodHack = false) { if (this.buffImmune[type]) return; if (BuffID.Sets.IsWellFed[type]) { for (int b = 0; b < 22; ++b) { if (BuffID.Sets.IsWellFed[this.buffType[b]]) this.DelBuff(b); } } int buffTimeToAdd = this.AddBuff_DetermineBuffTimeToAdd(type, timeToAdd); if (this.AddBuff_TryUpdatingExistingBuffTime(type, buffTimeToAdd)) return; if (!quiet && Main.netMode == 1) NetMessage.SendData(55, number: this.whoAmI, number2: ((float) type), number3: ((float) buffTimeToAdd)); this.AddBuff_RemoveOldPetBuffsOfMatchingType(type); this.AddBuff_RemoveOldMeleeBuffsOfMatchingType(type); this.AddBuff_ActuallyTryToAddTheBuff(type, buffTimeToAdd); } private bool AddBuff_ActuallyTryToAddTheBuff(int type, int time) { int index1 = -1; while (index1 == -1) { int b = -1; for (int index2 = 0; index2 < 22; ++index2) { if (!Main.debuff[this.buffType[index2]]) { b = index2; break; } } if (b == -1) return false; for (int index3 = b; index3 < 22; ++index3) { if (this.buffType[index3] == 0) { index1 = index3; break; } } if (index1 == -1) this.DelBuff(b); } this.buffType[index1] = type; this.buffTime[index1] = time; return true; } private void AddBuff_RemoveOldMeleeBuffsOfMatchingType(int type) { if (!Main.meleeBuff[type]) return; for (int b = 0; b < 22; ++b) { if (this.buffType[b] != type && Main.meleeBuff[this.buffType[b]]) { this.DelBuff(b); --b; } } } private void AddBuff_RemoveOldPetBuffsOfMatchingType(int type) { if (Main.lightPet[type]) { for (int b = 0; b < 22; ++b) { if (Main.lightPet[this.buffType[b]]) this.DelBuff(b); } } if (!Main.vanityPet[type]) return; for (int b = 0; b < 22; ++b) { if (Main.vanityPet[this.buffType[b]]) this.DelBuff(b); } } private bool AddBuff_TryUpdatingExistingBuffTime(int type, int time) { bool flag = false; for (int index = 0; index < 22; ++index) { if (this.buffType[index] == type) { if (type == 94) { this.buffTime[index] += time; if (this.buffTime[index] > Player.manaSickTimeMax) this.buffTime[index] = Player.manaSickTimeMax; } else if (this.buffTime[index] < time) this.buffTime[index] = time; flag = true; break; } } return flag; } private int AddBuff_DetermineBuffTimeToAdd(int type, int time1) { int num = time1; if (Main.expertMode && this.whoAmI == Main.myPlayer && (type == 20 || type == 22 || type == 23 || type == 24 || type == 30 || type == 31 || type == 32 || type == 33 || type == 35 || type == 36 || type == 39 || type == 44 || type == 46 || type == 47 || type == 69 || type == 70 || type == 80)) num = (int) ((double) Main.GameModeInfo.DebuffTimeMultiplier * (double) num); return num; } public void DelBuff(int b) { this.buffTime[b] = 0; this.buffType[b] = 0; for (int index1 = 0; index1 < 21; ++index1) { if (this.buffTime[index1] == 0 || this.buffType[index1] == 0) { for (int index2 = index1 + 1; index2 < 22; ++index2) { if (this.buffTime[index2] > 0 && this.buffType[index2] > 0) { this.buffTime[index1] = this.buffTime[index2]; this.buffType[index1] = this.buffType[index2]; this.buffTime[index2] = 0; this.buffType[index2] = 0; break; } } } } } public void ClearBuff(int type) { for (int b = 0; b < 22; ++b) { if (this.buffType[b] == type) this.DelBuff(b); } } public int CountBuffs() { int index1 = 0; for (int index2 = 0; index2 < 22; ++index2) { if (this.buffType[index1] > 0) ++index1; } return index1; } public void QuickHeal() { if (this.cursed || this.CCed || this.dead || this.statLife == this.statLifeMax2 || this.potionDelay > 0) return; Item itemToUse = this.QuickHeal_GetItemToUse(); if (itemToUse == null) return; SoundEngine.PlaySound(itemToUse.UseSound, this.position); if (itemToUse.potion) { if (itemToUse.type == 227) { this.potionDelay = this.restorationDelayTime; this.AddBuff(21, this.potionDelay); } else { this.potionDelay = this.potionDelayTime; this.AddBuff(21, this.potionDelay); } } this.statLife += itemToUse.healLife; this.statMana += itemToUse.healMana; if (this.statLife > this.statLifeMax2) this.statLife = this.statLifeMax2; if (this.statMana > this.statManaMax2) this.statMana = this.statManaMax2; if (itemToUse.healLife > 0 && Main.myPlayer == this.whoAmI) this.HealEffect(itemToUse.healLife); if (itemToUse.healMana > 0) { this.AddBuff(94, Player.manaSickTime); if (Main.myPlayer == this.whoAmI) this.ManaEffect(itemToUse.healMana); } --itemToUse.stack; if (itemToUse.stack <= 0) itemToUse.TurnToAir(); Recipe.FindRecipes(); } public Item QuickHeal_GetItemToUse() { int num1 = this.statLifeMax2 - this.statLife; Item obj1 = (Item) null; int num2 = -this.statLifeMax2; for (int index = 0; index < 58; ++index) { Item obj2 = this.inventory[index]; if (obj2.stack > 0 && obj2.type > 0 && obj2.potion && obj2.healLife > 0) { int num3 = obj2.healLife - num1; if (obj2.type == 227 && num3 < 0) { num3 += 30; if (num3 > 0) num3 = 0; } if (num2 < 0) { if (num3 > num2) { obj1 = obj2; num2 = num3; } } else if (num3 < num2 && num3 >= 0) { obj1 = obj2; num2 = num3; } } } return obj1; } public void QuickMana() { if (this.cursed || this.CCed || this.dead || this.statMana == this.statManaMax2) return; for (int index = 0; index < 58; ++index) { if (this.inventory[index].stack > 0 && this.inventory[index].type > 0 && this.inventory[index].healMana > 0 && (this.potionDelay == 0 || !this.inventory[index].potion)) { SoundEngine.PlaySound(this.inventory[index].UseSound, this.position); if (this.inventory[index].potion) { if (this.inventory[index].type == 227) { this.potionDelay = this.restorationDelayTime; this.AddBuff(21, this.potionDelay); } else { this.potionDelay = this.potionDelayTime; this.AddBuff(21, this.potionDelay); } } this.statLife += this.inventory[index].healLife; this.statMana += this.inventory[index].healMana; if (this.statLife > this.statLifeMax2) this.statLife = this.statLifeMax2; if (this.statMana > this.statManaMax2) this.statMana = this.statManaMax2; if (this.inventory[index].healLife > 0 && Main.myPlayer == this.whoAmI) this.HealEffect(this.inventory[index].healLife); if (this.inventory[index].healMana > 0) { this.AddBuff(94, Player.manaSickTime); if (Main.myPlayer == this.whoAmI) this.ManaEffect(this.inventory[index].healMana); } --this.inventory[index].stack; if (this.inventory[index].stack <= 0) this.inventory[index].TurnToAir(); Recipe.FindRecipes(); break; } } } public Item QuickMana_GetItemToUse() { for (int index = 0; index < 58; ++index) { if (this.inventory[index].stack > 0 && this.inventory[index].type > 0 && this.inventory[index].healMana > 0 && (this.potionDelay == 0 || !this.inventory[index].potion)) return this.inventory[index]; } return (Item) null; } public void QuickBuff() { if (this.cursed || this.CCed || this.dead) return; LegacySoundStyle type = (LegacySoundStyle) null; if (this.CountBuffs() == 22) return; Item obj1 = this.QuickBuff_PickBestFoodItem(); if (obj1 != null) { type = obj1.UseSound; int timeToAdd = obj1.buffTime; if (timeToAdd == 0) timeToAdd = 3600; this.AddBuff(obj1.buffType, timeToAdd); if (obj1.consumable) { --obj1.stack; if (obj1.stack <= 0) obj1.TurnToAir(); } } if (this.CountBuffs() != 22) { for (int index = 0; index < 58; ++index) { Item obj2 = this.inventory[index]; if (obj2.stack > 0 && obj2.type > 0 && obj2.buffType > 0 && !obj2.summon) { int num = obj2.buffType; bool flag = this.QuickBuff_ShouldBotherUsingThisBuff(num); if (obj2.mana > 0 & flag) { if (this.statMana >= (int) ((double) obj2.mana * (double) this.manaCost)) { this.manaRegenDelay = (int) this.maxRegenDelay; this.statMana -= (int) ((double) obj2.mana * (double) this.manaCost); } else flag = false; } if (this.whoAmI == Main.myPlayer && obj2.type == 603 && !Main.runningCollectorsEdition) flag = false; if (num == 27) { num = Main.rand.Next(3); if (num == 0) num = 27; if (num == 1) num = 101; if (num == 2) num = 102; } if (flag) { type = obj2.UseSound; int timeToAdd = obj2.buffTime; if (timeToAdd == 0) timeToAdd = 3600; this.AddBuff(num, timeToAdd); if (obj2.consumable) { --obj2.stack; if (obj2.stack <= 0) obj2.TurnToAir(); } if (this.CountBuffs() == 22) break; } } } } if (type == null) return; SoundEngine.PlaySound(type, this.position); Recipe.FindRecipes(); } private Item QuickBuff_PickBestFoodItem() { int num = 0; Item obj1 = (Item) null; for (int index = 0; index < 22; ++index) { if (this.buffTime[index] >= 1) { int foodPriority = this.QuickBuff_FindFoodPriority(this.buffType[index]); if (num <= foodPriority) num = foodPriority + 1; } } for (int index = 0; index < 58; ++index) { Item obj2 = this.inventory[index]; if (!obj2.IsAir) { int foodPriority = this.QuickBuff_FindFoodPriority(obj2.buffType); if (foodPriority >= num && (obj1 == null || obj1.buffTime < obj2.buffTime || foodPriority > num)) { obj1 = obj2; num = foodPriority; } } } return obj1; } private int QuickBuff_FindFoodPriority(int buffType) { switch (buffType) { case 26: return 1; case 206: return 2; case 207: return 3; default: return 0; } } private bool QuickBuff_ShouldBotherUsingThisBuff(int attemptedType) { bool flag = true; for (int index = 0; index < 22; ++index) { if (attemptedType == 27 && (this.buffType[index] == 27 || this.buffType[index] == 101 || this.buffType[index] == 102)) { flag = false; break; } if (BuffID.Sets.IsWellFed[attemptedType] && BuffID.Sets.IsWellFed[this.buffType[index]]) { flag = false; break; } if (this.buffType[index] == attemptedType) { flag = false; break; } if (Main.meleeBuff[attemptedType] && Main.meleeBuff[this.buffType[index]]) { flag = false; break; } } if (Main.lightPet[attemptedType] || Main.vanityPet[attemptedType]) { for (int index = 0; index < 22; ++index) { if (Main.lightPet[this.buffType[index]] && Main.lightPet[attemptedType]) flag = false; if (Main.vanityPet[this.buffType[index]] && Main.vanityPet[attemptedType]) flag = false; } } return flag; } public void QuickMount() { if (this.mount.Active) { this.mount.Dismount(this); } else { if (this.frozen || this.tongued || this.webbed || this.stoned || (double) this.gravDir == -1.0 || this.dead || this.noItems) return; Item itemToUse = this.QuickMount_GetItemToUse(); if (itemToUse != null && itemToUse.mountType != -1 && this.mount.CanMount(itemToUse.mountType, this)) { if (this.QuickMinecartSnap()) return; this.mount.SetMount(itemToUse.mountType, this); if (itemToUse.UseSound == null) return; SoundEngine.PlaySound(itemToUse.UseSound, this.Center); } else this.QuickMinecart(); } } public bool CanFitSpace(int heightBoost) { int Height = 42 + heightBoost; return Collision.IsClearSpotTest(this.position + new Vector2(0.0f, (float) (this.height - Height)) + this.velocity, 16f, this.width, Height, true, true); } private void QuickMinecart() { int num1 = 0; int num2 = (int) ((double) this.position.X / 16.0) - Player.tileRangeX - num1 + 1; int num3 = (int) (((double) this.position.X + (double) this.width) / 16.0) + Player.tileRangeX + num1 - 1; int num4 = (int) ((double) this.position.Y / 16.0) - Player.tileRangeY - num1 + 1; int num5 = (int) (((double) this.position.Y + (double) this.height) / 16.0) + Player.tileRangeY + num1 - 2; int max = Main.maxTilesX - 10; int num6 = Utils.Clamp(num2, 10, max); int num7 = Utils.Clamp(num3, 10, Main.maxTilesX - 10); int num8 = Utils.Clamp(num4, 10, Main.maxTilesY - 10); int num9 = Utils.Clamp(num5, 10, Main.maxTilesY - 10); List tilesIn = Collision.GetTilesIn(new Vector2((float) num6, (float) num8) * 16f, new Vector2((float) (num7 + 1), (float) (num9 + 1)) * 16f); if (tilesIn.Count <= 0) return; Point? nullable = new Point?(); Microsoft.Xna.Framework.Rectangle hitbox = this.Hitbox; for (int index = 0; index < tilesIn.Count; ++index) { Point point = tilesIn[index]; Tile tileSafely = Framing.GetTileSafely(point.X, point.Y); if (tileSafely.active() && tileSafely.type == (ushort) 314) { Vector2 vector2 = tilesIn[index].ToVector2() * 16f + new Vector2(8f); if (!nullable.HasValue || (double) this.Distance(vector2) < (double) this.Distance(nullable.Value.ToVector2() * 16f + new Vector2(8f)) && Collision.CanHitLine(this.Center, 0, 0, vector2, 0, 0)) nullable = new Point?(tilesIn[index]); } } if (!nullable.HasValue) return; this.LaunchMinecartHook(nullable.Value.X, nullable.Value.Y); } private bool QuickMinecartSnap() { bool flag = false; List tilesIn = Collision.GetTilesIn(this.TopLeft - new Vector2(24f), this.BottomRight + new Vector2(24f)); if (tilesIn.Count > 0) { Point? nullable = new Point?(); Microsoft.Xna.Framework.Rectangle hitbox = this.Hitbox; for (int index = 0; index < tilesIn.Count; ++index) { Point point = tilesIn[index]; Tile tileSafely = Framing.GetTileSafely(point.X, point.Y); if (tileSafely.active() && tileSafely.type == (ushort) 314) { Vector2 vector2 = tilesIn[index].ToVector2() * 16f + new Vector2(8f); if (!nullable.HasValue || (double) this.Distance(vector2) < (double) this.Distance(nullable.Value.ToVector2() * 16f + new Vector2(8f)) && Collision.CanHitLine(this.Center, 0, 0, vector2, 0, 0)) nullable = new Point?(tilesIn[index]); } } if (nullable.HasValue) { this.LaunchMinecartHook(nullable.Value.X, nullable.Value.Y); flag = true; } } return flag; } public Item QuickMount_GetItemToUse() { Item obj = (Item) null; if (obj == null && this.miscEquips[3].mountType != -1 && !MountID.Sets.Cart[this.miscEquips[3].mountType]) obj = this.miscEquips[3]; if (obj == null) { for (int index = 0; index < 58; ++index) { if (this.inventory[index].mountType != -1 && !MountID.Sets.Cart[this.inventory[index].mountType]) { obj = this.inventory[index]; break; } } } return obj; } public void ClearGrapplingBlacklist() => this._blackListedTileCoordsForGrappling.Clear(); public bool IsBlacklistedForGrappling(Point p) => this._blackListedTileCoordsForGrappling.Contains(p); public void UpdateBlacklistedTilesForGrappling() { this.ClearGrapplingBlacklist(); for (int index1 = 0; index1 < 1000; ++index1) { if (Main.projectile[index1].active && Main.projectile[index1].owner == this.whoAmI && Main.projectile[index1].aiStyle == 7 && (double) Main.projectile[index1].ai[0] == 2.0) { Point tileCoordinates = Main.projectile[index1].Center.ToTileCoordinates(); for (int index2 = -1; index2 <= 1; ++index2) { for (int index3 = -1; index3 <= 1; ++index3) { if (!WorldGen.SolidTile(tileCoordinates.X + index2, tileCoordinates.Y + index3)) this._blackListedTileCoordsForGrappling.Add(new Point(tileCoordinates.X + index2, tileCoordinates.Y + index3)); } } } } } public void QuickGrapple() { if (this.frozen || this.tongued || this.webbed || this.stoned || this.dead) return; if (PlayerInput.GrappleAndInteractAreShared) { if (Main.HoveringOverAnNPC || Main.SmartInteractShowingGenuine || Main.SmartInteractShowingFake || this._quickGrappleCooldown > 0 && !Main.mapFullscreen || WiresUI.Settings.DrawToolModeUI) return; int num = this.controlUseTile ? 1 : 0; bool releaseUseTile = this.releaseUseTile; if (num == 0 && !releaseUseTile) return; Tile tileSafely = Framing.GetTileSafely(Player.tileTargetX, Player.tileTargetY); if (tileSafely.active() && (tileSafely.type == (ushort) 4 || tileSafely.type == (ushort) 33 || tileSafely.type == (ushort) 372 || tileSafely.type == (ushort) 174 || tileSafely.type == (ushort) 49) || this.inventory[this.selectedItem].type == 3384) return; } if (this.noItems) return; if (this.mount.Active) this.mount.Dismount(this); Item obj = this.QuickGrapple_GetItemToUse(); if (obj == null) return; if (obj.shoot == 73) { int num = 0; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && (Main.projectile[index].type == 73 || Main.projectile[index].type == 74)) ++num; } if (num > 1) obj = (Item) null; } else if (obj.shoot == 165) { int num = 0; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && Main.projectile[index].type == 165) ++num; } if (num > 8) obj = (Item) null; } else if (obj.shoot == 372) { int num = 0; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && Main.projectile[index].type == 372) ++num; } if (num > 2) obj = (Item) null; } else if (obj.shoot == 652) { int num = 0; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && Main.projectile[index].type == 652) ++num; } if (num > 1) obj = (Item) null; } else if (obj.type == 3572) { int num = 0; bool flag = false; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && Main.projectile[index].type >= 646 && Main.projectile[index].type <= 649) { ++num; if ((double) Main.projectile[index].ai[0] == 2.0) flag = true; } } if (num > 4 || !flag && num > 3) obj = (Item) null; } else { for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && Main.projectile[index].type == obj.shoot && (double) Main.projectile[index].ai[0] != 2.0) { obj = (Item) null; break; } } } if (obj == null) return; this.UpdateBlacklistedTilesForGrappling(); SoundEngine.PlaySound(obj.UseSound, this.position); if (Main.netMode == 1 && this.whoAmI == Main.myPlayer) NetMessage.SendData(51, number: this.whoAmI, number2: 2f); int Type = obj.shoot; float shootSpeed = obj.shootSpeed; int damage = obj.damage; float knockBack = obj.knockBack; if (Type == 13 || Type == 32 || Type == 315 || Type >= 230 && Type <= 235 || Type == 331 || Type == 753 || Type == 865 || Type == 935) { this.grappling[0] = -1; this.grapCount = 0; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI) { switch (Main.projectile[index].type) { case 13: case 230: case 231: case 232: case 233: case 234: case 235: case 315: case 331: case 753: case 865: case 935: Main.projectile[index].Kill(); continue; default: continue; } } } } if (Type == 256) { int num1 = 0; int index1 = -1; int num2 = 100000; for (int index2 = 0; index2 < 1000; ++index2) { if (Main.projectile[index2].active && Main.projectile[index2].owner == this.whoAmI && Main.projectile[index2].type == 256) { ++num1; if (Main.projectile[index2].timeLeft < num2) { index1 = index2; num2 = Main.projectile[index2].timeLeft; } } } if (num1 > 1) Main.projectile[index1].Kill(); } if (Type == 652) { int num3 = 0; int index3 = -1; int num4 = 100000; for (int index4 = 0; index4 < 1000; ++index4) { if (Main.projectile[index4].active && Main.projectile[index4].owner == this.whoAmI && Main.projectile[index4].type == 652) { ++num3; if (Main.projectile[index4].timeLeft < num4) { index3 = index4; num4 = Main.projectile[index4].timeLeft; } } } if (num3 > 1) Main.projectile[index3].Kill(); } if (Type == 73) { for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI && Main.projectile[index].type == 73) Type = 74; } } if (obj.type == 3572) { int num5 = -1; int num6 = -1; for (int index = 0; index < 1000; ++index) { Projectile projectile = Main.projectile[index]; if (projectile.active && projectile.owner == this.whoAmI && projectile.type >= 646 && projectile.type <= 649 && (num6 == -1 || num6 < projectile.timeLeft)) { num5 = projectile.type; num6 = projectile.timeLeft; } } switch (num5) { case -1: case 649: Type = 646; break; case 646: Type = 647; break; case 647: Type = 648; break; case 648: Type = 649; break; } } Vector2 vector2 = new Vector2(this.position.X + (float) this.width * 0.5f, this.position.Y + (float) this.height * 0.5f); float f1 = (float) Main.mouseX + Main.screenPosition.X - vector2.X; float f2 = (float) Main.mouseY + Main.screenPosition.Y - vector2.Y; if ((double) this.gravDir == -1.0) f2 = Main.screenPosition.Y + (float) Main.screenHeight - (float) Main.mouseY - vector2.Y; float num7 = (float) Math.Sqrt((double) f1 * (double) f1 + (double) f2 * (double) f2); float num8; if (float.IsNaN(f1) && float.IsNaN(f2) || (double) f1 == 0.0 && (double) f2 == 0.0) { f1 = (float) this.direction; f2 = 0.0f; num8 = shootSpeed; } else num8 = shootSpeed / num7; float SpeedX = f1 * num8; float SpeedY = f2 * num8; Projectile.NewProjectile(vector2.X, vector2.Y, SpeedX, SpeedY, Type, damage, knockBack, this.whoAmI); } public Item QuickGrapple_GetItemToUse() { Item obj = (Item) null; if (Main.projHook[this.miscEquips[4].shoot]) obj = this.miscEquips[4]; if (obj == null) { for (int index = 0; index < 58; ++index) { if (Main.projHook[this.inventory[index].shoot]) { obj = this.inventory[index]; break; } } } return obj; } public void StatusToNPC(int type, int i) { if (this.meleeEnchant > (byte) 0) { if (this.meleeEnchant == (byte) 1) Main.npc[i].AddBuff(70, 60 * Main.rand.Next(5, 10)); if (this.meleeEnchant == (byte) 2) Main.npc[i].AddBuff(39, 60 * Main.rand.Next(3, 7)); if (this.meleeEnchant == (byte) 3) Main.npc[i].AddBuff(24, 60 * Main.rand.Next(3, 7)); if (this.meleeEnchant == (byte) 5) Main.npc[i].AddBuff(69, 60 * Main.rand.Next(10, 20)); if (this.meleeEnchant == (byte) 6) Main.npc[i].AddBuff(31, 60 * Main.rand.Next(1, 4)); if (this.meleeEnchant == (byte) 8) Main.npc[i].AddBuff(20, 60 * Main.rand.Next(5, 10)); if (this.meleeEnchant == (byte) 4) Main.npc[i].AddBuff(72, 120); } if (this.frostBurn) Main.npc[i].AddBuff(44, 60 * Main.rand.Next(5, 15)); if (this.magmaStone) { if (Main.rand.Next(4) == 0) Main.npc[i].AddBuff(24, 360); else if (Main.rand.Next(2) == 0) Main.npc[i].AddBuff(24, 240); else Main.npc[i].AddBuff(24, 120); } if (type == 3211) Main.npc[i].AddBuff(69, 60 * Main.rand.Next(5, 10)); if (type == 121) { if (Main.rand.Next(2) != 0) return; Main.npc[i].AddBuff(24, 180); } else if (type == 3823) { if (Main.rand.Next(4) != 0) return; Main.npc[i].AddBuff(24, 300); } else if (type == 122) { if (Main.rand.Next(10) != 0) return; Main.npc[i].AddBuff(24, 180); } else if (type == 190) { if (Main.rand.Next(4) != 0) return; Main.npc[i].AddBuff(20, 420); } else if (type == 217) { if (Main.rand.Next(5) != 0) return; Main.npc[i].AddBuff(24, 180); } else { if (type != 1123 || Main.rand.Next(10) == 0) return; Main.npc[i].AddBuff(31, 120); } } public void StatusToPlayerPvP(int type, int i) { if (this.meleeEnchant > (byte) 0) { if (this.meleeEnchant == (byte) 1) Main.player[i].AddBuff(70, 60 * Main.rand.Next(5, 10)); if (this.meleeEnchant == (byte) 2) Main.player[i].AddBuff(39, 60 * Main.rand.Next(3, 7)); if (this.meleeEnchant == (byte) 3) Main.player[i].AddBuff(24, 60 * Main.rand.Next(3, 7)); if (this.meleeEnchant == (byte) 5) Main.player[i].AddBuff(69, 60 * Main.rand.Next(10, 20)); if (this.meleeEnchant == (byte) 6) Main.player[i].AddBuff(31, 60 * Main.rand.Next(1, 4)); if (this.meleeEnchant == (byte) 8) Main.player[i].AddBuff(20, 60 * Main.rand.Next(5, 10)); } if (this.frostBurn) Main.player[i].AddBuff(44, 60 * Main.rand.Next(1, 8)); if (this.magmaStone) { if (Main.rand.Next(7) == 0) Main.player[i].AddBuff(24, 360); else if (Main.rand.Next(3) == 0) Main.player[i].AddBuff(24, 120); else Main.player[i].AddBuff(24, 60); } switch (type) { case 121: if (Main.rand.Next(2) != 0) break; Main.player[i].AddBuff(24, 180, false); break; case 122: if (Main.rand.Next(10) != 0) break; Main.player[i].AddBuff(24, 180, false); break; case 190: if (Main.rand.Next(4) != 0) break; Main.player[i].AddBuff(20, 420, false); break; case 217: if (Main.rand.Next(5) != 0) break; Main.player[i].AddBuff(24, 180, false); break; case 1123: if (Main.rand.Next(9) == 0) break; Main.player[i].AddBuff(31, 120, false); break; case 3823: if (Main.rand.Next(4) != 0) break; Main.player[i].AddBuff(24, 300); break; } } public void Ghost() { this.immune = false; this.immuneAlpha = 0; if (Main.hasFocus && this.whoAmI == Main.myPlayer) { this.controlUp = false; this.controlLeft = false; this.controlDown = false; this.controlRight = false; this.controlJump = false; if (!Main.drawingPlayerChat && !Main.editSign && !Main.editChest && !Main.blockInput) { PlayerInput.Triggers.Current.CopyInto(this); if (Main.netMode == 1) { bool flag = false; if (this.controlUp != Main.clientPlayer.controlUp) flag = true; if (this.controlDown != Main.clientPlayer.controlDown) flag = true; if (this.controlLeft != Main.clientPlayer.controlLeft) flag = true; if (this.controlRight != Main.clientPlayer.controlRight) flag = true; if (this.controlJump != Main.clientPlayer.controlJump) flag = true; if (this.controlUseItem != Main.clientPlayer.controlUseItem) flag = true; if (this.selectedItem != Main.clientPlayer.selectedItem) flag = true; if (flag) NetMessage.SendData(13, number: Main.myPlayer); } } } if (this.controlUp || this.controlJump) { if ((double) this.velocity.Y > 0.0) this.velocity.Y *= 0.9f; this.velocity.Y -= 0.1f; if ((double) this.velocity.Y < -3.0) this.velocity.Y = -3f; } else if (this.controlDown) { if ((double) this.velocity.Y < 0.0) this.velocity.Y *= 0.9f; this.velocity.Y += 0.1f; if ((double) this.velocity.Y > 3.0) this.velocity.Y = 3f; } else if ((double) this.velocity.Y < -0.1 || (double) this.velocity.Y > 0.1) this.velocity.Y *= 0.9f; else this.velocity.Y = 0.0f; if (this.controlLeft && !this.controlRight) { if ((double) this.velocity.X > 0.0) this.velocity.X *= 0.9f; this.velocity.X -= 0.1f; if ((double) this.velocity.X < -3.0) this.velocity.X = -3f; } else if (this.controlRight && !this.controlLeft) { if ((double) this.velocity.X < 0.0) this.velocity.X *= 0.9f; this.velocity.X += 0.1f; if ((double) this.velocity.X > 3.0) this.velocity.X = 3f; } else if ((double) this.velocity.X < -0.1 || (double) this.velocity.X > 0.1) this.velocity.X *= 0.9f; else this.velocity.X = 0.0f; this.position = this.position + this.velocity; ++this.ghostFrameCounter; if ((double) this.velocity.X < 0.0) this.direction = -1; else if ((double) this.velocity.X > 0.0) this.direction = 1; if (this.ghostFrameCounter >= 8) { this.ghostFrameCounter = 0; ++this.ghostFrame; if (this.ghostFrame >= 4) this.ghostFrame = 0; } if ((double) this.position.X < (double) Main.leftWorld + (double) (Lighting.OffScreenTiles * 16) + 16.0) { this.position.X = (float) ((double) Main.leftWorld + (double) (Lighting.OffScreenTiles * 16) + 16.0); this.velocity.X = 0.0f; } if ((double) this.position.X + (double) this.width > (double) Main.rightWorld - (double) (Lighting.OffScreenTiles * 16) - 32.0) { this.position.X = (float) ((double) Main.rightWorld - (double) (Lighting.OffScreenTiles * 16) - 32.0) - (float) this.width; this.velocity.X = 0.0f; } if ((double) this.position.Y < (double) Main.topWorld + (double) (Lighting.OffScreenTiles * 16) + 16.0) { this.position.Y = (float) ((double) Main.topWorld + (double) (Lighting.OffScreenTiles * 16) + 16.0); if ((double) this.velocity.Y < -0.1) this.velocity.Y = -0.1f; } if ((double) this.position.Y <= (double) Main.bottomWorld - (double) (Lighting.OffScreenTiles * 16) - 32.0 - (double) this.height) return; this.position.Y = (float) ((double) Main.bottomWorld - (double) (Lighting.OffScreenTiles * 16) - 32.0) - (float) this.height; this.velocity.Y = 0.0f; } public void OnHit(float x, float y, Entity victim) { if (Main.myPlayer != this.whoAmI) return; bool flag = victim is NPC && ((NPC) victim).type == 488; if (victim is NPC) Main.BigBossProgressBar.TryTracking(victim.whoAmI); if (this.onHitTitaniumStorm && !flag) { this.AddBuff(306, 600); if (this.ownedProjectileCounts[908] < 7) { ++this.ownedProjectileCounts[908]; Projectile.NewProjectile(this.Center, Vector2.Zero, 908, 50, 15f, this.whoAmI); } } if (this.onHitDodge && this.shadowDodgeTimer == 0 && Main.rand.Next(4) == 0) { if (!this.shadowDodge) this.shadowDodgeTimer = 1800; this.AddBuff(59, 1800); } if (this.onHitRegen) this.AddBuff(58, 300); if (this.stardustMinion && victim is NPC) { for (int index = 0; index < 1000; ++index) { Projectile projectile = Main.projectile[index]; if (projectile.active && projectile.owner == this.whoAmI && projectile.type == 613 && (double) projectile.localAI[1] <= 0.0 && Main.rand.Next(2) == 0) { Vector2 vector2 = new Vector2(x, y) - projectile.Center; if ((double) vector2.Length() > 0.0) vector2.Normalize(); vector2 *= 20f; Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, vector2.X, vector2.Y, 614, projectile.damage / 3, 0.0f, projectile.owner, ai1: ((float) victim.whoAmI)); projectile.localAI[1] = (float) (30 + Main.rand.Next(4) * 10); } } } if (this.onHitPetal && this.petalTimer == 0) { this.petalTimer = 20; double num1 = (double) this.position.X + (double) (this.width / 2); int direction = this.direction; float x1 = Main.screenPosition.X; if (direction < 0) x1 += (float) Main.screenWidth; float num2 = Main.screenPosition.Y + (float) Main.rand.Next(Main.screenHeight); Vector2 vector2 = new Vector2(x1, num2); float num3 = x - vector2.X; float num4 = y - vector2.Y; float num5 = num3 + (float) Main.rand.Next(-50, 51) * 0.1f; float num6 = num4 + (float) Main.rand.Next(-50, 51) * 0.1f; float num7 = 24f / (float) Math.Sqrt((double) num5 * (double) num5 + (double) num6 * (double) num6); float SpeedX = num5 * num7; float SpeedY = num6 * num7; Projectile.NewProjectile(x1, num2, SpeedX, SpeedY, 221, 36, 0.0f, this.whoAmI); } if (!this.crystalLeaf || this.petalTimer != 0) return; int type = this.inventory[this.selectedItem].type; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].owner == this.whoAmI && Main.projectile[index].type == 226) { this.petalTimer = 50; Vector2 vector2 = new Vector2(Main.projectile[index].position.X + (float) this.width * 0.5f, Main.projectile[index].position.Y + (float) this.height * 0.5f); float num8 = x - vector2.X; float num9 = y - vector2.Y; float num10 = (float) (12.0 / Math.Sqrt((double) num8 * (double) num8 + (double) num9 * (double) num9)); float SpeedX = num8 * num10; float SpeedY = num9 * num10; Projectile.NewProjectile(Main.projectile[index].Center.X - 4f, Main.projectile[index].Center.Y, SpeedX, SpeedY, 227, Player.crystalLeafDamage, (float) Player.crystalLeafKB, this.whoAmI); break; } } } public void openPresent() { if (Main.rand.Next(15) == 0 && Main.hardMode) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 602); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(30) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1922); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(400) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1927); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(150) == 0) { int number1 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1870); if (Main.netMode == 1) NetMessage.SendData(21, number: number1, number2: 1f); int number2 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 97, Main.rand.Next(30, 61)); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number2, number2: 1f); } else if (Main.rand.Next(150) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1909); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(150) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1917); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(150) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1915); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(150) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1918); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(150) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1921); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(300) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1923); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(40) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1907); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(10) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1908); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(15) == 0) { switch (Main.rand.Next(5)) { case 0: int number3 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1932); if (Main.netMode == 1) NetMessage.SendData(21, number: number3, number2: 1f); int number4 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1933); if (Main.netMode == 1) NetMessage.SendData(21, number: number4, number2: 1f); int number5 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1934); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number5, number2: 1f); break; case 1: int number6 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1935); if (Main.netMode == 1) NetMessage.SendData(21, number: number6, number2: 1f); int number7 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1936); if (Main.netMode == 1) NetMessage.SendData(21, number: number7, number2: 1f); int number8 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1937); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number8, number2: 1f); break; case 2: int number9 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1940); if (Main.netMode == 1) NetMessage.SendData(21, number: number9, number2: 1f); int number10 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1941); if (Main.netMode == 1) NetMessage.SendData(21, number: number10, number2: 1f); int number11 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1942); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number11, number2: 1f); break; case 3: int number12 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1938); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number12, number2: 1f); break; case 4: int number13 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1939); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number13, number2: 1f); break; } } else if (Main.rand.Next(7) == 0) { int Type = Main.rand.Next(3); if (Type == 0) Type = 1911; if (Type == 1) Type = 1919; if (Type == 2) Type = 1920; int number14 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number14, number2: 1f); } else if (Main.rand.Next(8) == 0) { int number15 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1912, Main.rand.Next(1, 4)); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number15, number2: 1f); } else if (Main.rand.Next(9) == 0) { int number16 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1913, Main.rand.Next(20, 41)); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number16, number2: 1f); } else { switch (Main.rand.Next(3)) { case 0: int number17 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1872, Main.rand.Next(20, 50)); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number17, number2: 1f); break; case 1: int number18 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 586, Main.rand.Next(20, 50)); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number18, number2: 1f); break; default: int number19 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 591, Main.rand.Next(20, 50)); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number19, number2: 1f); break; } } } public void QuickSpawnItem(int item, int stack = 1) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, item, stack, pfix: -1); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } public void OpenBossBag(int type) { switch (type) { case 3318: if (Main.rand.Next(2) == 0) this.QuickSpawnItem(2430); if (Main.rand.Next(7) == 0) this.QuickSpawnItem(2493); int num1 = Main.rand.Next(256, 259); int num2 = Main.rand.Next(256, 259); while (num2 == num1) num2 = Main.rand.Next(256, 259); this.QuickSpawnItem(num1); this.QuickSpawnItem(num2); if (Main.rand.Next(2) == 0) this.QuickSpawnItem(2610); else this.QuickSpawnItem(2585); this.QuickSpawnItem(998); this.QuickSpawnItem(3090); break; case 3319: if (Main.rand.Next(7) == 0) this.QuickSpawnItem(2112); if (Main.rand.Next(30) == 0) this.QuickSpawnItem(1299); if (WorldGen.crimson) { this.QuickSpawnItem(880, Main.rand.Next(20) + 10 + (Main.rand.Next(20) + 10) + (Main.rand.Next(20) + 10)); this.QuickSpawnItem(2171, Main.rand.Next(3) + 1); } else { this.QuickSpawnItem(56, Main.rand.Next(20) + 10 + (Main.rand.Next(20) + 10) + (Main.rand.Next(20) + 10)); this.QuickSpawnItem(59, Main.rand.Next(3) + 1); this.QuickSpawnItem(47, Main.rand.Next(30) + 20); } this.QuickSpawnItem(3097); break; case 3320: this.QuickSpawnItem(56, Main.rand.Next(15, 30) + Main.rand.Next(15, 31)); this.QuickSpawnItem(86, Main.rand.Next(10, 20)); if (Main.rand.Next(20) == 0) this.QuickSpawnItem(994); if (Main.rand.Next(7) == 0) this.QuickSpawnItem(2111); this.QuickSpawnItem(3224); break; case 3321: this.QuickSpawnItem(880, Main.rand.Next(20, 46) + Main.rand.Next(20, 46)); this.QuickSpawnItem(1329, Main.rand.Next(10, 20)); if (Main.rand.Next(7) == 0) this.QuickSpawnItem(2104); if (Main.rand.Next(20) == 0) this.QuickSpawnItem(3060); this.QuickSpawnItem(3223); break; case 3322: if (Main.rand.Next(7) == 0) this.QuickSpawnItem(2108); int num3 = Main.rand.Next(3); switch (num3) { case 0: num3 = 1121; break; case 1: num3 = 1123; break; case 2: num3 = 2888; break; } this.QuickSpawnItem(num3); this.QuickSpawnItem(3333); if (Main.rand.Next(3) == 0) this.QuickSpawnItem(1132); if (Main.rand.Next(9) == 0) this.QuickSpawnItem(1170); if (Main.rand.Next(9) == 0) this.QuickSpawnItem(2502); this.QuickSpawnItem(1129); this.QuickSpawnItem(Main.rand.Next(842, 845)); this.QuickSpawnItem(1130, Main.rand.Next(10, 30)); this.QuickSpawnItem(2431, Main.rand.Next(17, 30)); break; case 3323: this.QuickSpawnItem(3245); switch (Main.rand.Next(3)) { case 0: this.QuickSpawnItem(1281); break; case 1: this.QuickSpawnItem(1273); break; default: this.QuickSpawnItem(1313); break; } break; case 3324: if (Main.rand.Next(7) == 0) this.QuickSpawnItem(2105); this.QuickSpawnItem(367); if (!this.extraAccessory) this.QuickSpawnItem(3335); int num4 = Main.rand.Next(4); this.QuickSpawnItem(num4 != 3 ? 489 + num4 : 2998); switch (Main.rand.Next(4)) { case 0: this.QuickSpawnItem(514); break; case 1: this.QuickSpawnItem(426); break; case 2: this.QuickSpawnItem(434); break; case 3: this.QuickSpawnItem(4912); break; } break; case 3325: this.TryGettingDevArmor(); if (Main.rand.Next(7) == 0) this.QuickSpawnItem(2113); this.QuickSpawnItem(548, Main.rand.Next(25, 41)); this.QuickSpawnItem(1225, Main.rand.Next(20, 36)); this.QuickSpawnItem(3355); break; case 3326: this.TryGettingDevArmor(); if (Main.rand.Next(7) == 0) this.QuickSpawnItem(2106); this.QuickSpawnItem(549, Main.rand.Next(25, 41)); this.QuickSpawnItem(1225, Main.rand.Next(20, 36)); this.QuickSpawnItem(3354); break; case 3327: this.TryGettingDevArmor(); if (Main.rand.Next(7) == 0) this.QuickSpawnItem(2107); this.QuickSpawnItem(547, Main.rand.Next(25, 41)); this.QuickSpawnItem(1225, Main.rand.Next(20, 36)); this.QuickSpawnItem(3356); break; case 3328: this.TryGettingDevArmor(); if (Main.rand.Next(7) == 0) this.QuickSpawnItem(2109); this.QuickSpawnItem(1141); this.QuickSpawnItem(3336); if (Main.rand.Next(15) == 0) this.QuickSpawnItem(1182); if (Main.rand.Next(20) == 0) this.QuickSpawnItem(1305); if (Main.rand.Next(2) == 0) this.QuickSpawnItem(1157); if (Main.rand.Next(10) == 0) this.QuickSpawnItem(3021); switch (Main.rand.Next(7)) { case 0: this.QuickSpawnItem(758); this.QuickSpawnItem(771, Main.rand.Next(50, 150)); break; case 1: this.QuickSpawnItem(1255); break; case 2: this.QuickSpawnItem(788); break; case 3: this.QuickSpawnItem(1178); break; case 4: this.QuickSpawnItem(1259); break; case 5: this.QuickSpawnItem(1155); break; case 6: this.QuickSpawnItem(3018); break; } break; case 3329: this.TryGettingDevArmor(); this.QuickSpawnItem(3337); if (Main.rand.Next(7) == 0) this.QuickSpawnItem(2110); if (Main.rand.Next(3) == 0) this.QuickSpawnItem(1294); switch (Main.rand.Next(7)) { case 0: this.QuickSpawnItem(1258); this.QuickSpawnItem(1261, Main.rand.Next(60, 100)); break; case 1: this.QuickSpawnItem(1122); break; case 2: this.QuickSpawnItem(899); break; case 3: this.QuickSpawnItem(1248); break; case 4: this.QuickSpawnItem(1295); break; case 5: this.QuickSpawnItem(1296); break; default: this.QuickSpawnItem(1297); break; } this.QuickSpawnItem(2218, Main.rand.Next(18, 24)); break; case 3330: this.TryGettingDevArmor(); this.QuickSpawnItem(3367); if (Main.rand.Next(7) == 0) this.QuickSpawnItem(2588); if (Main.rand.Next(10) == 0) this.QuickSpawnItem(2609); switch (Main.rand.Next(5)) { case 0: this.QuickSpawnItem(2611); break; case 1: this.QuickSpawnItem(2624); break; case 2: this.QuickSpawnItem(2622); break; case 3: this.QuickSpawnItem(2621); break; case 4: this.QuickSpawnItem(2623); break; } break; case 3331: this.TryGettingDevArmor(); if (Main.rand.Next(7) == 0) { this.QuickSpawnItem(3372); break; } break; case 3332: this.TryGettingDevArmor(); if (Main.rand.Next(7) == 0) this.QuickSpawnItem(3373); if (Main.rand.Next(10) == 0) this.QuickSpawnItem(4469); if (!this.HasItem(3384)) this.QuickSpawnItem(3384); this.QuickSpawnItem(3460, Main.rand.Next(90, 111)); this.QuickSpawnItem(1131); this.QuickSpawnItem(3577); this.QuickSpawnItem(4954); this.QuickSpawnItem(Utils.SelectRandom(Main.rand, 3063, 3389, 3065, 1553, 3930, 3541, 3570, 3571, 3569)); break; case 3860: this.TryGettingDevArmor(); if (Main.rand.Next(7) == 0) this.QuickSpawnItem(3863); switch (Main.rand.Next(4)) { case 0: this.QuickSpawnItem(3859); break; case 1: this.QuickSpawnItem(3827); break; case 2: this.QuickSpawnItem(3870); break; default: this.QuickSpawnItem(3858); break; } if (Main.rand.Next(4) == 0) this.QuickSpawnItem(3883); this.QuickSpawnItem(3817, Main.rand.Next(30, 50)); break; case 4782: this.TryGettingDevArmor(); this.QuickSpawnItem(4989); if (Main.rand.Next(7) == 0) this.QuickSpawnItem(4784); if (Main.rand.Next(10) == 0) this.QuickSpawnItem(4823); if (Main.rand.Next(20) == 0) this.QuickSpawnItem(4715); if (Main.rand.Next(4) == 0) this.QuickSpawnItem(4778); switch (Main.rand.Next(4)) { case 0: this.QuickSpawnItem(4923); break; case 1: this.QuickSpawnItem(4952); break; case 2: this.QuickSpawnItem(4953); break; case 3: this.QuickSpawnItem(4914); break; } break; case 4957: this.QuickSpawnItem(4987); this.QuickSpawnItem(4986, Main.rand.Next(25, 75)); if (Main.rand.Next(7) == 0) this.QuickSpawnItem(4959); if (Main.rand.Next(2) == 0) this.QuickSpawnItem(4981); if (Main.rand.Next(2) == 0) this.QuickSpawnItem(4980); int num5 = Main.rand.Next(4982, 4985); int num6 = Main.rand.Next(4982, 4985); while (num6 == num5) num5 = Main.rand.Next(4982, 4985); this.QuickSpawnItem(num5); this.QuickSpawnItem(num6); break; } int Type = -1; if (type == 3318) Type = 50; if (type == 3319) Type = 4; if (type == 3320) Type = 13; if (type == 3321) Type = 266; if (type == 3322) Type = 222; if (type == 3323) Type = 35; if (type == 3324) Type = 113; if (type == 3325) Type = 134; if (type == 3326) Type = 125; if (type == 3327) Type = (int) sbyte.MaxValue; if (type == 3328) Type = 262; if (type == 3329) Type = 245; if (type == 3330) Type = 370; if (type == 3331) Type = 439; if (type == 3332) Type = 398; if (type == 3860) Type = 551; if (type == 3861) Type = 576; if (type == 3862) Type = 564; if (type == 4782) Type = 636; if (type == 4957) Type = 657; if (Type <= 0) return; NPC npc = new NPC(); npc.SetDefaults(Type); float num7 = npc.value * (float) (1.0 + (double) Main.rand.Next(-20, 21) * 0.00999999977648258); if (Main.rand.Next(5) == 0) num7 *= (float) (1.0 + (double) Main.rand.Next(5, 11) * 0.00999999977648258); if (Main.rand.Next(10) == 0) num7 *= (float) (1.0 + (double) Main.rand.Next(10, 21) * 0.00999999977648258); if (Main.rand.Next(15) == 0) num7 *= (float) (1.0 + (double) Main.rand.Next(15, 31) * 0.00999999977648258); if (Main.rand.Next(20) == 0) num7 *= (float) (1.0 + (double) Main.rand.Next(20, 41) * 0.00999999977648258); while ((int) num7 > 0) { if ((double) num7 > 1000000.0) { int stack = (int) ((double) num7 / 1000000.0); num7 -= (float) (1000000 * stack); this.QuickSpawnItem(74, stack); } else if ((double) num7 > 10000.0) { int stack = (int) ((double) num7 / 10000.0); num7 -= (float) (10000 * stack); this.QuickSpawnItem(73, stack); } else if ((double) num7 > 100.0) { int stack = (int) ((double) num7 / 100.0); num7 -= (float) (100 * stack); this.QuickSpawnItem(72, stack); } else { int stack = (int) num7; if (stack < 1) stack = 1; num7 -= (float) stack; this.QuickSpawnItem(71, stack); } } } private void TryGettingDevArmor() { if (Main.rand.Next(20) != 0) return; switch (Main.rand.Next(18)) { case 0: this.QuickSpawnItem(666); this.QuickSpawnItem(667); this.QuickSpawnItem(668); this.QuickSpawnItem(665); this.QuickSpawnItem(3287); break; case 1: this.QuickSpawnItem(1554); this.QuickSpawnItem(1555); this.QuickSpawnItem(1556); this.QuickSpawnItem(1586); break; case 2: this.QuickSpawnItem(1554); this.QuickSpawnItem(1587); this.QuickSpawnItem(1588); this.QuickSpawnItem(1586); break; case 3: this.QuickSpawnItem(1557); this.QuickSpawnItem(1558); this.QuickSpawnItem(1559); this.QuickSpawnItem(1585); break; case 4: this.QuickSpawnItem(1560); this.QuickSpawnItem(1561); this.QuickSpawnItem(1562); this.QuickSpawnItem(1584); break; case 5: this.QuickSpawnItem(1563); this.QuickSpawnItem(1564); this.QuickSpawnItem(1565); this.QuickSpawnItem(3582); break; case 6: this.QuickSpawnItem(1566); this.QuickSpawnItem(1567); this.QuickSpawnItem(1568); break; case 7: this.QuickSpawnItem(1580); this.QuickSpawnItem(1581); this.QuickSpawnItem(1582); this.QuickSpawnItem(1583); break; case 8: this.QuickSpawnItem(3226); this.QuickSpawnItem(3227); this.QuickSpawnItem(3228); this.QuickSpawnItem(3288); break; case 9: this.QuickSpawnItem(3583); this.QuickSpawnItem(3581); this.QuickSpawnItem(3578); this.QuickSpawnItem(3579); this.QuickSpawnItem(3580); break; case 10: this.QuickSpawnItem(3585); this.QuickSpawnItem(3586); this.QuickSpawnItem(3587); this.QuickSpawnItem(3588); this.QuickSpawnItem(3024, 4); break; case 11: this.QuickSpawnItem(3589); this.QuickSpawnItem(3590); this.QuickSpawnItem(3591); this.QuickSpawnItem(3592); this.QuickSpawnItem(3599, 4); break; case 12: this.QuickSpawnItem(3368); this.QuickSpawnItem(3921); this.QuickSpawnItem(3922); this.QuickSpawnItem(3923); this.QuickSpawnItem(3924); break; case 13: this.QuickSpawnItem(3925); this.QuickSpawnItem(3926); this.QuickSpawnItem(3927); this.QuickSpawnItem(3928); this.QuickSpawnItem(3929); break; case 14: this.QuickSpawnItem(4732); this.QuickSpawnItem(4733); this.QuickSpawnItem(4734); this.QuickSpawnItem(4730); break; case 15: this.QuickSpawnItem(4747); this.QuickSpawnItem(4748); this.QuickSpawnItem(4749); this.QuickSpawnItem(4746); break; case 16: this.QuickSpawnItem(4751); this.QuickSpawnItem(4752); this.QuickSpawnItem(4753); this.QuickSpawnItem(4750); break; case 17: this.QuickSpawnItem(4755); this.QuickSpawnItem(4756); this.QuickSpawnItem(4757); this.QuickSpawnItem(4754); break; } } public void OpenFishingCrate(int crateItemID) { bool flag1 = ItemID.Sets.IsFishingCrateHardmode[crateItemID]; switch (crateItemID) { case 2334: case 3979: bool flag2 = true; while (flag2) { if (flag1 & flag2 && Main.rand.Next(200) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 3064); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); flag2 = false; } if (flag2 && Main.rand.Next(40) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 3200, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); flag2 = false; } if (flag2 && Main.rand.Next(40) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 3201, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); flag2 = false; } if (flag1 & flag2 && Main.rand.Next(25) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 2424, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); flag2 = false; } if (Main.rand.Next(45) == 0) { int Type = Main.rand.Next(5); switch (Type) { case 0: Type = 285; break; case 1: Type = 953; break; case 2: Type = 946; break; case 3: Type = 3068; break; case 4: Type = 3084; break; } int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); flag2 = false; } if (!flag1 & flag2 && Main.rand.Next(50) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 997); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); flag2 = false; } if (Main.rand.Next(7) == 0) { int Type; int Stack; if (Main.rand.Next(3) == 0) { Type = 73; Stack = Main.rand.Next(1, 6); } else { Type = 72; Stack = Main.rand.Next(20, 91); } int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); flag2 = false; } if (Main.rand.Next(7) == 0) { int Type = Main.rand.Next(4); switch (Type) { case 0: Type = 12; break; case 1: Type = 699; break; case 2: Type = 11; break; case 3: Type = 700; break; } if (Main.rand.Next(2) == 0 & flag1) { Type = Main.rand.Next(2); switch (Type) { case 0: Type = 364; break; case 1: Type = 1104; break; } } int Stack = Main.rand.Next(6, 24); int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); flag2 = false; } else if (Main.rand.Next(8) == 0) { int Type = Main.rand.Next(4); switch (Type) { case 0: Type = 20; break; case 1: Type = 703; break; case 2: Type = 22; break; case 3: Type = 704; break; case 4: Type = 21; break; case 5: Type = 705; break; case 6: Type = 19; break; case 7: Type = 706; break; } int Stack = Main.rand.Next(2, 8); if (Main.rand.Next(2) == 0 & flag1) { Type = Main.rand.Next(2); switch (Type) { case 0: Type = 381; break; case 1: Type = 1184; break; case 2: Type = 382; break; case 3: Type = 1191; break; case 4: Type = 391; break; case 5: Type = 1198; break; } Stack = Main.rand.Next(2, 6); } int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); flag2 = false; } if (Main.rand.Next(7) == 0) { int Type = Main.rand.Next(10); switch (Type) { case 0: Type = 288; break; case 1: Type = 290; break; case 2: Type = 292; break; case 3: Type = 299; break; case 4: Type = 298; break; case 5: Type = 304; break; case 6: Type = 291; break; case 7: Type = 2322; break; case 8: Type = 2323; break; case 9: Type = 2329; break; } int Stack = Main.rand.Next(1, 4); int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); flag2 = false; } } if (Main.rand.Next(3) == 0) { int Type = Main.rand.Next(2); switch (Type) { case 0: Type = 28; break; case 1: Type = 110; break; } int Stack = Main.rand.Next(5, 16); int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); } if (Main.rand.Next(3) != 0) break; int number1 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Main.rand.Next(3) != 0 ? 2674 : 2675, Main.rand.Next(1, 5)); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number1, number2: 1f); break; case 2335: case 3980: bool flag3 = true; while (flag3) { if (flag1 & flag3 && Main.rand.Next(60) == 0) { int number2 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 3064); if (Main.netMode == 1) NetMessage.SendData(21, number: number2, number2: 1f); flag3 = false; } if (flag3 && Main.rand.Next(25) == 0) { int number3 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 2501); if (Main.netMode == 1) NetMessage.SendData(21, number: number3, number2: 1f); flag3 = false; } if (flag3 && Main.rand.Next(20) == 0) { int number4 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 2587); if (Main.netMode == 1) NetMessage.SendData(21, number: number4, number2: 1f); flag3 = false; } if (flag3 && Main.rand.Next(15) == 0) { int number5 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 2608, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number5, number2: 1f); flag3 = false; } if (flag3 && Main.rand.Next(20) == 0) { int number6 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 3200, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number6, number2: 1f); flag3 = false; } if (flag3 && Main.rand.Next(20) == 0) { int number7 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 3201, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number7, number2: 1f); flag3 = false; } if (Main.rand.Next(4) == 0) { int number8 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 73, Main.rand.Next(5, 11)); if (Main.netMode == 1) NetMessage.SendData(21, number: number8, number2: 1f); flag3 = false; } if (Main.rand.Next(6) == 0) { int Type = Main.rand.Next(6); switch (Type) { case 0: Type = 12; break; case 1: Type = 699; break; case 2: Type = 11; break; case 3: Type = 700; break; case 4: Type = 14; break; case 5: Type = 701; break; } if (Main.rand.Next(2) == 0 & flag1) { Type = Main.rand.Next(4); switch (Type) { case 0: Type = 364; break; case 1: Type = 1104; break; case 2: Type = 365; break; case 3: Type = 1105; break; } } int Stack = Main.rand.Next(18, 30); int number9 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number9, number2: 1f); flag3 = false; } else if (Main.rand.Next(4) == 0) { int Type = Main.rand.Next(6); switch (Type) { case 0: Type = 20; break; case 1: Type = 703; break; case 2: Type = 22; break; case 3: Type = 704; break; case 4: Type = 21; break; case 5: Type = 705; break; } int Stack = Main.rand.Next(6, 10); if ((uint) Main.rand.Next(3) > 0U & flag1) { Type = Main.rand.Next(4); switch (Type) { case 0: Type = 381; break; case 1: Type = 1184; break; case 2: Type = 382; break; case 3: Type = 1191; break; } Stack -= Main.rand.Next(2); } int number10 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number10, number2: 1f); flag3 = false; } if (Main.rand.Next(4) == 0) { int Type = Main.rand.Next(8); switch (Type) { case 0: Type = 288; break; case 1: Type = 296; break; case 2: Type = 304; break; case 3: Type = 305; break; case 4: Type = 2322; break; case 5: Type = 2323; break; case 6: Type = 2324; break; case 7: Type = 2327; break; } int Stack = Main.rand.Next(2, 5); int number11 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number11, number2: 1f); flag3 = false; } } if (Main.rand.Next(2) == 0) { int number12 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Main.rand.Next(188, 190), Main.rand.Next(5, 16)); if (Main.netMode == 1) NetMessage.SendData(21, number: number12, number2: 1f); } if (Main.rand.Next(2) != 0) break; int number13 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Main.rand.Next(3) != 0 ? 2675 : 2676, Main.rand.Next(2, 5)); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number13, number2: 1f); break; case 2336: case 3981: bool flag4 = true; while (flag4) { if (flag1 & flag4 && Main.rand.Next(20) == 0) { int number14 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 3064); if (Main.netMode == 1) NetMessage.SendData(21, number: number14, number2: 1f); flag4 = false; } if (flag4 && Main.rand.Next(15) == 0) { int number15 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 29); if (Main.netMode == 1) NetMessage.SendData(21, number: number15, number2: 1f); flag4 = false; } if (flag4 && Main.rand.Next(10) == 0) { int number16 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 2491); if (Main.netMode == 1) NetMessage.SendData(21, number: number16, number2: 1f); flag4 = false; } if (Main.rand.Next(3) == 0) { int number17 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 73, Main.rand.Next(8, 21)); if (Main.netMode == 1) NetMessage.SendData(21, number: number17, number2: 1f); flag4 = false; } if (Main.rand.Next(5) == 0) { int Type = Main.rand.Next(4); switch (Type) { case 0: Type = 14; break; case 1: Type = 701; break; case 2: Type = 13; break; case 3: Type = 702; break; } if (Main.rand.Next(2) == 0 & flag1) { Type = Main.rand.Next(4); switch (Type) { case 0: Type = 365; break; case 1: Type = 1105; break; case 2: Type = 366; break; case 3: Type = 1106; break; } } int Stack = Main.rand.Next(30, 45); int number18 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number18, number2: 1f); flag4 = false; } else if (Main.rand.Next(3) == 0) { int Type = Main.rand.Next(4); switch (Type) { case 0: Type = 21; break; case 1: Type = 19; break; case 2: Type = 705; break; case 3: Type = 706; break; } if ((uint) Main.rand.Next(3) > 0U & flag1) { Type = Main.rand.Next(4); switch (Type) { case 0: Type = 382; break; case 1: Type = 391; break; case 2: Type = 1191; break; case 3: Type = 1198; break; } } int Stack = Main.rand.Next(10, 15); int number19 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number19, number2: 1f); flag4 = false; } } if (Main.rand.Next(3) == 0) { int Type = Main.rand.Next(5); switch (Type) { case 0: Type = 288; break; case 1: Type = 296; break; case 2: Type = 305; break; case 3: Type = 2322; break; case 4: Type = 2323; break; } int Stack = Main.rand.Next(2, 6); int number20 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number20, number2: 1f); } if (Main.rand.Next(2) == 0) { int number21 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Main.rand.Next(188, 190), Main.rand.Next(5, 21)); if (Main.netMode == 1) NetMessage.SendData(21, number: number21, number2: 1f); } if (Main.rand.Next(3) != 0) { int number22 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 2676, Main.rand.Next(3, 8)); if (Main.netMode == 1) NetMessage.SendData(21, number: number22, number2: 1f); } if (Main.rand.Next(50) != 0) break; int number23 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 989); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number23, number2: 1f); break; default: int maxValue = 1; bool flag5 = true; bool flag6; while (flag5) { if ((crateItemID == 5002 || crateItemID == 5003) && flag5 && Main.rand.Next(maxValue) == 0) { int num = Main.rand.Next(4); int Type; if (Main.rand.Next(10) == 0) Type = 4425; else if (Main.rand.Next(10) == 0) { Type = 863; } else { switch (num) { case 0: Type = 186; break; case 1: Type = 4404; break; case 2: Type = 277; break; default: Type = 187; break; } } int number24 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number24, number2: 1f); flag5 = false; } if ((crateItemID == 3203 || crateItemID == 3982) && flag5 && Main.rand.Next(maxValue) == 0) { int Type; switch (Main.rand.Next(5)) { case 0: Type = 162; break; case 1: Type = 111; break; case 2: Type = 96; break; case 3: Type = 115; break; default: Type = 64; break; } int number25 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number25, number2: 1f); flag5 = false; } if ((crateItemID == 3204 || crateItemID == 3983) && flag5 && Main.rand.Next(maxValue) == 0) { int Type; switch (Main.rand.Next(5)) { case 0: Type = 800; break; case 1: Type = 802; break; case 2: Type = 1256; break; case 3: Type = 1290; break; default: Type = 3062; break; } int number26 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number26, number2: 1f); flag5 = false; } if ((crateItemID == 3205 || crateItemID == 3984) && flag5 && Main.rand.Next(maxValue) == 0) { int number27 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 3085, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number27, number2: 1f); flag5 = false; if (Main.rand.Next(2) == 0) { int number28 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 149, Main.rand.Next(5, 16), pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number28, number2: 1f); } } if ((crateItemID == 3206 || crateItemID == 3985) && flag5 && Main.rand.Next(maxValue) == 0) { int Type; switch (Main.rand.Next(3)) { case 0: Type = 158; break; case 1: Type = 65; break; default: Type = 159; break; } int number29 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number29, number2: 1f); flag5 = false; } if ((crateItemID == 3208 || crateItemID == 3987) && flag5 && Main.rand.Next(maxValue) == 0) { if (Main.rand.Next(20) == 0) { Main.rand.Next(5); int number30 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 3017, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number30, number2: 1f); flag5 = false; } else { int Type; switch (Main.rand.Next(5)) { case 0: Type = 212; break; case 1: Type = 964; break; case 2: Type = 211; break; case 3: Type = 213; break; default: Type = 2292; break; } int number31 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number31, number2: 1f); flag5 = false; } } if ((crateItemID == 4405 || crateItemID == 4406) && flag5 && Main.rand.Next(maxValue) == 0) { int Type; switch (Main.rand.Next(6)) { case 0: Type = 670; break; case 1: Type = 724; break; case 2: Type = 950; break; case 3: Type = 1319; break; case 4: Type = 987; break; default: Type = 1579; break; } int number32 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number32, number2: 1f); flag5 = false; } if (crateItemID == 4407 || crateItemID == 4408) { if (flag5 && Main.rand.Next(maxValue) == 0) { int Type; switch (Main.rand.Next(8)) { case 0: Type = 4056; break; case 1: Type = 4442; break; case 2: Type = 4055; break; case 3: Type = 4061; break; case 4: Type = 4062; break; case 5: Type = 4276; break; case 6: Type = 4262; break; default: Type = 4263; break; } int number33 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number33, number2: 1f); flag5 = false; } if (Main.rand.Next(4) == 0) { int number34 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 4423, Main.rand.Next(4, 7)); if (Main.netMode == 1) NetMessage.SendData(21, number: number34, number2: 1f); flag5 = false; } } if (crateItemID == 4877 || crateItemID == 4878) { if (flag5 && Main.rand.Next(maxValue) == 0) { if (Main.rand.Next(40) == 0) { Main.rand.Next(5); int number35 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 906, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number35, number2: 1f); flag6 = false; } else { int Type; switch (Main.rand.Next(5)) { case 0: Type = 4822; break; case 1: Type = 4828; break; case 2: Type = 4880; break; case 3: Type = 4881; break; default: Type = 4868; break; } int number36 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number36, number2: 1f); flag6 = false; } if (Main.rand.Next(4) == 0) { int number37 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 4858, 2); if (Main.netMode == 1) NetMessage.SendData(21, number: number37, number2: 1f); flag6 = false; } } int number38 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 4879, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number38, number2: 1f); flag5 = false; if (Main.rand.Next(3) == 0) { int number39 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 4824, Main.rand.Next(7, 11)); if (Main.netMode == 1) NetMessage.SendData(21, number: number39, number2: 1f); flag5 = false; } if (Main.rand.Next(2) == 0) { int Type = Main.rand.Next(5); switch (Type) { case 0: Type = 4902; break; case 1: Type = 4903; break; case 2: Type = 4904; break; case 3: Type = 4905; break; case 4: Type = 4906; break; } int number40 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number40, number2: 1f); flag5 = false; } } if (Main.rand.Next(4) == 0) { int number41 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 73, Main.rand.Next(5, 13)); if (Main.netMode == 1) NetMessage.SendData(21, number: number41, number2: 1f); flag5 = false; } if (Main.rand.Next(7) == 0) { int Type = Main.rand.Next(8); switch (Type) { case 0: Type = 12; break; case 1: Type = 699; break; case 2: Type = 11; break; case 3: Type = 700; break; case 4: Type = 14; break; case 5: Type = 701; break; case 6: Type = 13; break; case 7: Type = 702; break; } if (Main.rand.Next(2) == 0 & flag1) { Type = Main.rand.Next(6); switch (Type) { case 0: Type = 364; break; case 1: Type = 1104; break; case 2: Type = 365; break; case 3: Type = 1105; break; case 4: Type = 366; break; case 5: Type = 1106; break; } } int Stack = Main.rand.Next(30, 50); int number42 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number42, number2: 1f); flag5 = false; } if (Main.rand.Next(4) == 0) { int Type = Main.rand.Next(6); switch (Type) { case 0: Type = 22; break; case 1: Type = 21; break; case 2: Type = 19; break; case 3: Type = 704; break; case 4: Type = 705; break; case 5: Type = 706; break; } int Stack = Main.rand.Next(10, 21); if ((uint) Main.rand.Next(3) > 0U & flag1) { Type = Main.rand.Next(6); switch (Type) { case 0: Type = 381; break; case 1: Type = 382; break; case 2: Type = 391; break; case 3: Type = 1184; break; case 4: Type = 1191; break; case 5: Type = 1198; break; } Stack -= Main.rand.Next(3); } int number43 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number43, number2: 1f); flag5 = false; } } if (Main.rand.Next(4) == 0) { int Type = Main.rand.Next(6); switch (Type) { case 0: Type = 288; break; case 1: Type = 296; break; case 2: Type = 304; break; case 3: Type = 305; break; case 4: Type = 2322; break; case 5: Type = 2323; break; } int Stack = Main.rand.Next(2, 5); int number44 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number44, number2: 1f); flag6 = false; } if (Main.rand.Next(2) == 0) { int number45 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Main.rand.Next(188, 190), Main.rand.Next(5, 18)); if (Main.netMode == 1) NetMessage.SendData(21, number: number45, number2: 1f); } if (Main.rand.Next(2) == 0) { int number46 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Main.rand.Next(2) != 0 ? 2675 : 2676, Main.rand.Next(2, 7)); if (Main.netMode == 1) NetMessage.SendData(21, number: number46, number2: 1f); } if (crateItemID == 5002 || crateItemID == 5003) { if (Main.rand.Next(3) == 0) { int number47 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 4090, Main.rand.Next(20, 51)); if (Main.netMode == 1) NetMessage.SendData(21, number: number47, number2: 1f); } if (Main.rand.Next(10) == 0) { int number48 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 4460); if (Main.netMode == 1) NetMessage.SendData(21, number: number48, number2: 1f); } } if (crateItemID == 3208 || crateItemID == 3987) { if (Main.rand.Next(3) == 0) { int number49 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 4564, Main.rand.Next(20, 51)); if (Main.netMode == 1) NetMessage.SendData(21, number: number49, number2: 1f); } if (Main.rand.Next(20) == 0) { int number50 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 753); if (Main.netMode == 1) NetMessage.SendData(21, number: number50, number2: 1f); } } if ((crateItemID == 4405 || crateItemID == 4406) && Main.rand.Next(20) == 0) { int number51 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 669); if (Main.netMode == 1) NetMessage.SendData(21, number: number51, number2: 1f); } if (crateItemID == 4877 || crateItemID == 4878) { if (Main.rand.Next(20) == 0) { int number52 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 4737); if (Main.netMode == 1) NetMessage.SendData(21, number: number52, number2: 1f); } if (Main.rand.Next(20) == 0) { int number53 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 4551); if (Main.netMode == 1) NetMessage.SendData(21, number: number53, number2: 1f); } } if (!flag1 || crateItemID != 3982 && crateItemID != 3986 && crateItemID != 3983) break; if (Main.rand.Next(2) == 0) { int Type = 521; if (crateItemID == 3986) Type = 520; int Stack = Main.rand.Next(2, 6); int number54 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number54, number2: 1f); } if (Main.rand.Next(2) != 0) break; int Type1 = 522; int Stack1 = Main.rand.Next(2, 6); switch (crateItemID) { case 3983: Type1 = 1332; break; case 3986: Type1 = 502; Stack1 = Main.rand.Next(4, 11); break; } int number55 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type1, Stack1); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number55, number2: 1f); break; } } public int CountItem(int type, int stopCountingAt = 0) { int num = 0; for (int index = 0; index != 58; ++index) { if (this.inventory[index].stack > 0 && this.inventory[index].type == type) { num += this.inventory[index].stack; if (num >= stopCountingAt) return num; } } return num; } public bool ConsumeItem(int type, bool reverseOrder = false) { int num1 = 0; int num2 = 58; int num3 = 1; if (reverseOrder) { num1 = 57; num2 = -1; num3 = -1; } for (int index = num1; index != num2; index += num3) { if (this.inventory[index].stack > 0 && this.inventory[index].type == type) { --this.inventory[index].stack; if (this.inventory[index].stack <= 0) this.inventory[index].SetDefaults(); return true; } } return false; } public void OpenShadowLockbox() { bool flag = true; while (flag) { flag = false; int Type; switch (Main.rand.Next(6)) { case 1: Type = 274; break; case 2: Type = 220; break; case 3: Type = 112; break; case 4: Type = 218; break; case 5: Type = 3019; break; default: Type = 5010; break; } int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); } } public void OpenLockBox() { bool flag = true; while (flag) { flag = false; int num = Main.rand.Next(7); if (num == 1) num = 2; int number1 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, num != 2 ? (num != 3 ? (num != 4 ? (num != 5 ? (num != 6 ? 164 : 113) : 163) : 157) : 156) : 155, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number1, number2: 1f); if (Main.rand.Next(3) == 0) { int number2 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 329, pfix: -1); if (Main.netMode == 1) NetMessage.SendData(21, number: number2, number2: 1f); } } } public void OpenHerbBag() { int num = Main.rand.Next(2, 5); if (Main.rand.Next(3) == 0) ++num; for (int index = 0; index < num; ++index) { int Type = Main.rand.Next(14); if (Type == 0) Type = 313; if (Type == 1) Type = 314; if (Type == 2) Type = 315; if (Type == 3) Type = 317; if (Type == 4) Type = 316; if (Type == 5) Type = 318; if (Type == 6) Type = 2358; if (Type == 7) Type = 307; if (Type == 8) Type = 308; if (Type == 9) Type = 309; if (Type == 10) Type = 311; if (Type == 11) Type = 310; if (Type == 12) Type = 312; if (Type == 13) Type = 2357; int Stack = Main.rand.Next(2, 5); if (Main.rand.Next(3) == 0) Stack += Main.rand.Next(1, 5); int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Type, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); } } public void OpenCanofWorms() { this.QuickSpawnItem(2002, Main.rand.Next(5, 9)); if (Main.rand.Next(10) < 3) this.QuickSpawnItem(3191, Main.rand.Next(1, 3)); if (Main.rand.Next(20) != 0) return; this.QuickSpawnItem(2895); } public void OpenOyster() { if (Main.rand.Next(5) == 0) { if (Main.rand.Next(25) == 0) this.QuickSpawnItem(4414); else if (Main.rand.Next(5) == 0) this.QuickSpawnItem(4413); else this.QuickSpawnItem(4412); } this.QuickSpawnItem(4411); } public void OpenGoodieBag() { if (Main.rand.Next(150) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1810); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(150) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1800); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(4) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1809, Main.rand.Next(10, 41)); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else if (Main.rand.Next(10) == 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, Main.rand.Next(1846, 1851)); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else { switch (Main.rand.Next(19)) { case 0: int number1 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1749); if (Main.netMode == 1) NetMessage.SendData(21, number: number1, number2: 1f); int number2 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1750); if (Main.netMode == 1) NetMessage.SendData(21, number: number2, number2: 1f); int number3 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1751); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number3, number2: 1f); break; case 1: int number4 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1746); if (Main.netMode == 1) NetMessage.SendData(21, number: number4, number2: 1f); int number5 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1747); if (Main.netMode == 1) NetMessage.SendData(21, number: number5, number2: 1f); int number6 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1748); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number6, number2: 1f); break; case 2: int number7 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1752); if (Main.netMode == 1) NetMessage.SendData(21, number: number7, number2: 1f); int number8 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1753); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number8, number2: 1f); break; case 3: int number9 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1767); if (Main.netMode == 1) NetMessage.SendData(21, number: number9, number2: 1f); int number10 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1768); if (Main.netMode == 1) NetMessage.SendData(21, number: number10, number2: 1f); int number11 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1769); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number11, number2: 1f); break; case 4: int number12 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1770); if (Main.netMode == 1) NetMessage.SendData(21, number: number12, number2: 1f); int number13 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1771); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number13, number2: 1f); break; case 5: int number14 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1772); if (Main.netMode == 1) NetMessage.SendData(21, number: number14, number2: 1f); int number15 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1773); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number15, number2: 1f); break; case 6: int number16 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1754); if (Main.netMode == 1) NetMessage.SendData(21, number: number16, number2: 1f); int number17 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1755); if (Main.netMode == 1) NetMessage.SendData(21, number: number17, number2: 1f); int number18 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1756); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number18, number2: 1f); break; case 7: int number19 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1757); if (Main.netMode == 1) NetMessage.SendData(21, number: number19, number2: 1f); int number20 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1758); if (Main.netMode == 1) NetMessage.SendData(21, number: number20, number2: 1f); int number21 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1759); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number21, number2: 1f); break; case 8: int number22 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1760); if (Main.netMode == 1) NetMessage.SendData(21, number: number22, number2: 1f); int number23 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1761); if (Main.netMode == 1) NetMessage.SendData(21, number: number23, number2: 1f); int number24 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1762); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number24, number2: 1f); break; case 9: int number25 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1763); if (Main.netMode == 1) NetMessage.SendData(21, number: number25, number2: 1f); int number26 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1764); if (Main.netMode == 1) NetMessage.SendData(21, number: number26, number2: 1f); int number27 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1765); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number27, number2: 1f); break; case 10: int number28 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1766); if (Main.netMode == 1) NetMessage.SendData(21, number: number28, number2: 1f); int number29 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1775); if (Main.netMode == 1) NetMessage.SendData(21, number: number29, number2: 1f); int number30 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1776); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number30, number2: 1f); break; case 11: int number31 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1777); if (Main.netMode == 1) NetMessage.SendData(21, number: number31, number2: 1f); int number32 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1778); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number32, number2: 1f); break; case 12: int number33 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1779); if (Main.netMode == 1) NetMessage.SendData(21, number: number33, number2: 1f); int number34 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1780); if (Main.netMode == 1) NetMessage.SendData(21, number: number34, number2: 1f); int number35 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1781); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number35, number2: 1f); break; case 13: int number36 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1819); if (Main.netMode == 1) NetMessage.SendData(21, number: number36, number2: 1f); int number37 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1820); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number37, number2: 1f); break; case 14: int number38 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1821); if (Main.netMode == 1) NetMessage.SendData(21, number: number38, number2: 1f); int number39 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1822); if (Main.netMode == 1) NetMessage.SendData(21, number: number39, number2: 1f); int number40 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1823); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number40, number2: 1f); break; case 15: int number41 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1824); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number41, number2: 1f); break; case 16: int number42 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1838); if (Main.netMode == 1) NetMessage.SendData(21, number: number42, number2: 1f); int number43 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1839); if (Main.netMode == 1) NetMessage.SendData(21, number: number43, number2: 1f); int number44 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1840); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number44, number2: 1f); break; case 17: int number45 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1841); if (Main.netMode == 1) NetMessage.SendData(21, number: number45, number2: 1f); int number46 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1842); if (Main.netMode == 1) NetMessage.SendData(21, number: number46, number2: 1f); int number47 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1843); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number47, number2: 1f); break; case 18: int number48 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1851); if (Main.netMode == 1) NetMessage.SendData(21, number: number48, number2: 1f); int number49 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 1852); if (Main.netMode != 1) break; NetMessage.SendData(21, number: number49, number2: 1f); break; } } } public void UpdateDyes() { this.cHead = 0; this.cBody = 0; this.cLegs = 0; this.cHandOn = 0; this.cHandOff = 0; this.cBack = 0; this.cFront = 0; this.cShoe = 0; this.cWaist = 0; this.cShield = 0; this.cNeck = 0; this.cFace = 0; this.cBalloon = 0; this.cWings = 0; this.cCarpet = 0; this.cFloatingTube = 0; this.cGrapple = this.cMount = this.cMinecart = this.cPet = this.cLight = this.cYorai = this.cPortalbeStool = this.cUnicornHorn = this.cMinion = this.cLeinShampoo = 0; this.skinDyePacked = 0; this.cHead = (int) this.dye[0].dye; this.cBody = (int) this.dye[1].dye; this.cLegs = (int) this.dye[2].dye; if (this.wearsRobe) this.cLegs = this.cBody; this.cPet = (int) this.miscDyes[0].dye; this.cLight = (int) this.miscDyes[1].dye; this.cMinecart = (int) this.miscDyes[2].dye; this.cMount = (int) this.miscDyes[3].dye; this.cGrapple = (int) this.miscDyes[4].dye; for (int slot = 0; slot < 20; ++slot) { if (this.IsAValidEquipmentSlotForIteration(slot)) { int index = slot % 10; this.UpdateItemDye(slot < 10, this.hideVisibleAccessory[index], this.armor[slot], this.dye[index]); } } this.cYorai = this.cPet; } private void UpdateItemDye( bool effectiveEquipmentSlot, bool armorHidden, Item armorItem, Item dyeItem) { if (armorItem.IsAir || effectiveEquipmentSlot & armorHidden && armorItem.wingSlot <= (sbyte) 0 && armorItem.type != 934 && armorItem.type != 4341 && armorItem.type != 4563) return; if (armorItem.handOnSlot > (sbyte) 0 && armorItem.handOnSlot < (sbyte) 22) this.cHandOn = (int) dyeItem.dye; if (armorItem.handOffSlot > (sbyte) 0 && armorItem.handOffSlot < (sbyte) 14) this.cHandOff = (int) dyeItem.dye; if (armorItem.backSlot > (sbyte) 0 && armorItem.backSlot < (sbyte) 30) this.cBack = (int) dyeItem.dye; if (armorItem.frontSlot > (sbyte) 0 && armorItem.frontSlot < (sbyte) 9) this.cFront = (int) dyeItem.dye; if (armorItem.shoeSlot > (sbyte) 0 && armorItem.shoeSlot < (sbyte) 25) this.cShoe = (int) dyeItem.dye; if (armorItem.waistSlot > (sbyte) 0 && armorItem.waistSlot < (sbyte) 17) this.cWaist = (int) dyeItem.dye; if (armorItem.shieldSlot > (sbyte) 0 && armorItem.shieldSlot < (sbyte) 10) this.cShield = (int) dyeItem.dye; if (armorItem.neckSlot > (sbyte) 0 && armorItem.neckSlot < (sbyte) 11) this.cNeck = (int) dyeItem.dye; if (armorItem.faceSlot > (sbyte) 0 && armorItem.faceSlot < (sbyte) 16) this.cFace = (int) dyeItem.dye; if (armorItem.balloonSlot > (sbyte) 0 && armorItem.balloonSlot < (sbyte) 18) this.cBalloon = (int) dyeItem.dye; if (armorItem.wingSlot > (sbyte) 0 && armorItem.wingSlot < (sbyte) 47) this.cWings = (int) dyeItem.dye; if (armorItem.type == 934) this.cCarpet = (int) dyeItem.dye; if (armorItem.type == 4404) this.cFloatingTube = (int) dyeItem.dye; if (armorItem.type == 4341) this.cPortalbeStool = (int) dyeItem.dye; if (armorItem.type == 4563) this.cUnicornHorn = (int) dyeItem.dye; if (armorItem.type == 4762) this.cMinion = (int) dyeItem.dye; if (armorItem.type != 3929) return; this.cLeinShampoo = (int) dyeItem.dye; } public int ArmorSetDye() { switch (Main.rand.Next(3)) { case 0: return this.cHead; case 1: return this.cBody; case 2: return this.cLegs; default: return this.cBody; } } public void UpdateBuffs(int i) { if (this.soulDrain > 0 && this.whoAmI == Main.myPlayer) this.AddBuff(151, 2); for (int index1 = 0; index1 < 22; ++index1) { if (this.buffType[index1] > 0 && this.buffTime[index1] > 0) { if (this.whoAmI == Main.myPlayer && !BuffID.Sets.TimeLeftDoesNotDecrease[this.buffType[index1]]) --this.buffTime[index1]; if (this.buffType[index1] == 1) { this.lavaImmune = true; this.fireWalk = true; this.buffImmune[24] = true; } else if (BuffID.Sets.BasicMountData[this.buffType[index1]] != null) { BuffID.Sets.BuffMountData buffMountData = BuffID.Sets.BasicMountData[this.buffType[index1]]; this.mount.SetMount(buffMountData.mountID, this, buffMountData.faceLeft); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 158) this.manaRegenBonus += 2; else if (this.buffType[index1] == 159 && this.inventory[this.selectedItem].melee) this.armorPenetration = 12; else if (this.buffType[index1] == 192) { this.pickSpeed -= 0.2f; this.moveSpeed += 0.2f; } else if (this.buffType[index1] == 321) { int num = 20; this.meleeCrit += num; this.rangedCrit += num; this.magicCrit += num; this.minionDamage += (float) num / 100f; } else if (this.buffType[index1] == 2) this.lifeRegen += 4; else if (this.buffType[index1] == 3) this.moveSpeed += 0.25f; else if (this.buffType[index1] == 4) this.gills = true; else if (this.buffType[index1] == 5) this.statDefense += 8; else if (this.buffType[index1] == 6) this.manaRegenBuff = true; else if (this.buffType[index1] == 7) this.magicDamage += 0.2f; else if (this.buffType[index1] == 8) this.slowFall = true; else if (this.buffType[index1] == 9) this.findTreasure = true; else if (this.buffType[index1] == 10) this.invis = true; else if (this.buffType[index1] == 11) Lighting.AddLight((int) ((double) this.position.X + (double) (this.width / 2)) / 16, (int) ((double) this.position.Y + (double) (this.height / 2)) / 16, 0.8f, 0.95f, 1f); else if (this.buffType[index1] == 12) this.nightVision = true; else if (this.buffType[index1] == 13) this.enemySpawns = true; else if (this.buffType[index1] == 14) { if ((double) this.thorns < 1.0) this.thorns = 0.3333333f; } else if (this.buffType[index1] == 15) this.waterWalk = true; else if (this.buffType[index1] == 16) this.archery = true; else if (this.buffType[index1] == 17) this.detectCreature = true; else if (this.buffType[index1] == 18) this.gravControl = true; else if (this.buffType[index1] == 30) this.bleed = true; else if (this.buffType[index1] == 31) this.confused = true; else if (this.buffType[index1] == 32) this.slow = true; else if (this.buffType[index1] == 35) this.silence = true; else if (this.buffType[index1] == 160) this.dazed = true; else if (this.buffType[index1] == 46) this.chilled = true; else if (this.buffType[index1] == 47) this.frozen = true; else if (this.buffType[index1] == 156) this.stoned = true; else if (this.buffType[index1] == 69) { this.ichor = true; this.statDefense -= 20; } else if (this.buffType[index1] == 36) this.brokenArmor = true; else if (this.buffType[index1] == 48) this.honey = true; else if (this.buffType[index1] == 59) this.shadowDodge = true; else if (this.buffType[index1] == 93) this.ammoBox = true; else if (this.buffType[index1] == 58) this.palladiumRegen = true; else if (this.buffType[index1] == 306) this.hasTitaniumStormBuff = true; else if (this.buffType[index1] == 88) this.chaosState = true; else if (this.buffType[index1] == 215) this.statDefense += 5; else if (this.buffType[index1] == 311) this.meleeSpeed += 0.5f; else if (this.buffType[index1] == 308) this.meleeSpeed += 0.35f; else if (this.buffType[index1] == 314) this.meleeSpeed += 0.2f; else if (this.buffType[index1] == 312) this.coolWhipBuff = true; else if (this.buffType[index1] == 63) ++this.moveSpeed; else if (this.buffType[index1] == 104) this.pickSpeed -= 0.25f; else if (this.buffType[index1] == 105) this.lifeMagnet = true; else if (this.buffType[index1] == 106) this.calmed = true; else if (this.buffType[index1] == 121) this.fishingSkill += 15; else if (this.buffType[index1] == 122) this.sonarPotion = true; else if (this.buffType[index1] == 123) this.cratePotion = true; else if (this.buffType[index1] == 107) { this.tileSpeed += 0.25f; this.wallSpeed += 0.25f; ++this.blockRange; } else if (this.buffType[index1] == 108) this.kbBuff = true; else if (this.buffType[index1] == 109) { this.ignoreWater = true; this.accFlipper = true; } else if (this.buffType[index1] == 110) ++this.maxMinions; else if (this.buffType[index1] == 150) ++this.maxMinions; else if (this.buffType[index1] == 111) this.dangerSense = true; else if (this.buffType[index1] == 112) this.ammoPotion = true; else if (this.buffType[index1] == 113) { this.lifeForce = true; this.statLifeMax2 += this.statLifeMax / 5 / 20 * 20; } else if (this.buffType[index1] == 114) this.endurance += 0.1f; else if (this.buffType[index1] == 115) { this.meleeCrit += 10; this.rangedCrit += 10; this.magicCrit += 10; } else if (this.buffType[index1] == 116) { this.inferno = true; Lighting.AddLight((int) ((double) this.Center.X / 16.0), (int) ((double) this.Center.Y / 16.0), 0.65f, 0.4f, 0.1f); int type = 24; float num1 = 200f; bool flag = this.infernoCounter % 60 == 0; int num2 = 10; if (this.whoAmI == Main.myPlayer) { for (int index2 = 0; index2 < 200; ++index2) { NPC npc = Main.npc[index2]; if (npc.active && !npc.friendly && npc.damage > 0 && !npc.dontTakeDamage && !npc.buffImmune[type] && this.CanNPCBeHitByPlayerOrPlayerProjectile(npc) && (double) Vector2.Distance(this.Center, npc.Center) <= (double) num1) { if (npc.FindBuffIndex(type) == -1) npc.AddBuff(type, 120); if (flag) this.ApplyDamageToNPC(npc, num2, 0.0f, 0, false); } } if (this.hostile) { for (int playerTargetIndex = 0; playerTargetIndex < (int) byte.MaxValue; ++playerTargetIndex) { Player player = Main.player[playerTargetIndex]; if (player != this && player.active && !player.dead && player.hostile && !player.buffImmune[type] && (player.team != this.team || player.team == 0) && (double) Vector2.Distance(this.Center, player.Center) <= (double) num1) { if (player.FindBuffIndex(type) == -1) player.AddBuff(type, 120); if (flag) { player.Hurt(PlayerDeathReason.LegacyEmpty(), num2, 0, true); if (Main.netMode != 0) { PlayerDeathReason reason = PlayerDeathReason.ByOther(16); NetMessage.SendPlayerHurt(playerTargetIndex, reason, num2, 0, false, true, -1); } } } } } } } else if (this.buffType[index1] == 117) { this.meleeDamage += 0.1f; this.rangedDamage += 0.1f; this.magicDamage += 0.1f; this.minionDamage += 0.1f; } else if (this.buffType[index1] == 119) this.loveStruck = true; else if (this.buffType[index1] == 120) this.stinky = true; else if (this.buffType[index1] == 124) this.resistCold = true; else if (this.buffType[index1] == 257) { if (Main.myPlayer == this.whoAmI) this.luckPotion = this.buffTime[index1] <= 18000 ? (this.buffTime[index1] <= 10800 ? (byte) 1 : (byte) 2) : (byte) 3; } else if (this.buffType[index1] == 165) { this.lifeRegen += 6; this.statDefense += 8; this.dryadWard = true; if ((double) this.thorns < 1.0) this.thorns += 0.2f; } else if (this.buffType[index1] == 144) { this.electrified = true; Lighting.AddLight((int) this.Center.X / 16, (int) this.Center.Y / 16, 0.3f, 0.8f, 1.1f); } else if (this.buffType[index1] == 94) { this.manaSick = true; this.manaSickReduction = Player.manaSickLessDmg * ((float) this.buffTime[index1] / (float) Player.manaSickTime); } else if (this.buffType[index1] >= 95 && this.buffType[index1] <= 97) { this.buffTime[index1] = 5; int num = (int) (byte) (1 + this.buffType[index1] - 95); if (this.beetleOrbs > 0 && this.beetleOrbs != num) { if (this.beetleOrbs > num) { this.DelBuff(index1); --index1; } else { for (int b = 0; b < 22; ++b) { if (this.buffType[b] >= 95 && this.buffType[b] <= 95 + num - 1) { this.DelBuff(b); --b; } } } } this.beetleOrbs = num; if (!this.beetleDefense) { this.beetleOrbs = 0; this.DelBuff(index1); --index1; } else this.beetleBuff = true; } else if (this.buffType[index1] >= 170 && this.buffType[index1] <= 172) { this.buffTime[index1] = 5; int num = (int) (byte) (1 + this.buffType[index1] - 170); if (this.solarShields > 0 && this.solarShields != num) { if (this.solarShields > num) { this.DelBuff(index1); --index1; } else { for (int b = 0; b < 22; ++b) { if (this.buffType[b] >= 170 && this.buffType[b] <= 170 + num - 1) { this.DelBuff(b); --b; } } } } this.solarShields = num; if (!this.setSolar) { this.solarShields = 0; this.DelBuff(index1); --index1; } } else if (this.buffType[index1] >= 98 && this.buffType[index1] <= 100) { int num = (int) (byte) (1 + this.buffType[index1] - 98); if (this.beetleOrbs > 0 && this.beetleOrbs != num) { if (this.beetleOrbs > num) { this.DelBuff(index1); --index1; } else { for (int b = 0; b < 22; ++b) { if (this.buffType[b] >= 98 && this.buffType[b] <= 98 + num - 1) { this.DelBuff(b); --b; } } } } this.beetleOrbs = num; this.meleeDamage += 0.1f * (float) this.beetleOrbs; this.meleeSpeed += 0.1f * (float) this.beetleOrbs; if (!this.beetleOffense) { this.beetleOrbs = 0; this.DelBuff(index1); --index1; } else this.beetleBuff = true; } else if (this.buffType[index1] >= 176 && this.buffType[index1] <= 178) { int nebulaLevelMana = this.nebulaLevelMana; int num = (int) (byte) (1 + this.buffType[index1] - 176); if (nebulaLevelMana > 0 && nebulaLevelMana != num) { if (nebulaLevelMana > num) { this.DelBuff(index1); --index1; } else { for (int b = 0; b < 22; ++b) { if (this.buffType[b] >= 176 && this.buffType[b] <= 178 + num - 1) { this.DelBuff(b); --b; } } } } this.nebulaLevelMana = num; if (this.buffTime[index1] == 2 && this.nebulaLevelMana > 1) { --this.nebulaLevelMana; --this.buffType[index1]; this.buffTime[index1] = 480; } } else if (this.buffType[index1] >= 173 && this.buffType[index1] <= 175) { int nebulaLevelLife = this.nebulaLevelLife; int num = (int) (byte) (1 + this.buffType[index1] - 173); if (nebulaLevelLife > 0 && nebulaLevelLife != num) { if (nebulaLevelLife > num) { this.DelBuff(index1); --index1; } else { for (int b = 0; b < 22; ++b) { if (this.buffType[b] >= 173 && this.buffType[b] <= 175 + num - 1) { this.DelBuff(b); --b; } } } } this.nebulaLevelLife = num; if (this.buffTime[index1] == 2 && this.nebulaLevelLife > 1) { --this.nebulaLevelLife; --this.buffType[index1]; this.buffTime[index1] = 480; } this.lifeRegen += 6 * this.nebulaLevelLife; } else if (this.buffType[index1] >= 179 && this.buffType[index1] <= 181) { int nebulaLevelDamage = this.nebulaLevelDamage; int num3 = (int) (byte) (1 + this.buffType[index1] - 179); if (nebulaLevelDamage > 0 && nebulaLevelDamage != num3) { if (nebulaLevelDamage > num3) { this.DelBuff(index1); --index1; } else { for (int b = 0; b < 22; ++b) { if (this.buffType[b] >= 179 && this.buffType[b] <= 181 + num3 - 1) { this.DelBuff(b); --b; } } } } this.nebulaLevelDamage = num3; if (this.buffTime[index1] == 2 && this.nebulaLevelDamage > 1) { --this.nebulaLevelDamage; --this.buffType[index1]; this.buffTime[index1] = 480; } float num4 = 0.15f * (float) this.nebulaLevelDamage; this.meleeDamage += num4; this.rangedDamage += num4; this.magicDamage += num4; this.minionDamage += num4; } else if (this.buffType[index1] == 62) { if ((double) this.statLife <= (double) this.statLifeMax2 * 0.5) { Lighting.AddLight((int) ((double) this.Center.X / 16.0), (int) ((double) this.Center.Y / 16.0), 0.1f, 0.2f, 0.45f); this.iceBarrier = true; this.endurance += 0.25f; ++this.iceBarrierFrameCounter; if (this.iceBarrierFrameCounter > (byte) 2) { this.iceBarrierFrameCounter = (byte) 0; ++this.iceBarrierFrame; if (this.iceBarrierFrame >= (byte) 12) this.iceBarrierFrame = (byte) 0; } } else { this.DelBuff(index1); --index1; } } else if (this.buffType[index1] == 49) { for (int index3 = 191; index3 <= 194; ++index3) { if (this.ownedProjectileCounts[index3] > 0) this.pygmy = true; } if (!this.pygmy) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 83) { if (this.ownedProjectileCounts[317] > 0) this.raven = true; if (!this.raven) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 64) { if (this.ownedProjectileCounts[266] > 0) this.slime = true; if (!this.slime) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 125) { if (this.ownedProjectileCounts[373] > 0) this.hornetMinion = true; if (!this.hornetMinion) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 126) { if (this.ownedProjectileCounts[375] > 0) this.impMinion = true; if (!this.impMinion) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 133) { if (this.ownedProjectileCounts[390] > 0 || this.ownedProjectileCounts[391] > 0 || this.ownedProjectileCounts[392] > 0) this.spiderMinion = true; if (!this.spiderMinion) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 134) { if (this.ownedProjectileCounts[387] > 0 || this.ownedProjectileCounts[388] > 0) this.twinsMinion = true; if (!this.twinsMinion) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 135) { if (this.ownedProjectileCounts[393] > 0 || this.ownedProjectileCounts[394] > 0 || this.ownedProjectileCounts[395] > 0) this.pirateMinion = true; if (!this.pirateMinion) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 214) { if (this.ownedProjectileCounts[758] > 0) this.vampireFrog = true; if (!this.vampireFrog) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 139) { if (this.ownedProjectileCounts[407] > 0) this.sharknadoMinion = true; if (!this.sharknadoMinion) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 140) { if (this.ownedProjectileCounts[423] > 0) this.UFOMinion = true; if (!this.UFOMinion) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 182) { if (this.ownedProjectileCounts[613] > 0) this.stardustMinion = true; if (!this.stardustMinion) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 213) { if (this.ownedProjectileCounts[755] > 0) this.batsOfLight = true; if (!this.batsOfLight) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 216) { if (this.ownedProjectileCounts[759] > 0) this.babyBird = true; else if (this.whoAmI == Main.myPlayer && this.numMinions < this.maxMinions) { int index4 = this.FindItem(4281); if (index4 != -1) { Item obj = this.inventory[index4]; int index5 = Projectile.NewProjectile(this.Top, Vector2.Zero, obj.shoot, obj.damage, obj.knockBack, this.whoAmI); Main.projectile[index5].originalDamage = obj.damage; this.babyBird = true; } } if (!this.babyBird) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 263) { if (this.ownedProjectileCounts[831] > 0) this.stormTiger = true; if (!this.stormTiger) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; if (this.whoAmI == Main.myPlayer) this.UpdateStormTigerStatus(); } else if (this.buffType[index1] == 271) { if (this.ownedProjectileCounts[864] > 0) this.smolstar = true; if (!this.smolstar) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 322) { if (this.ownedProjectileCounts[946] > 0) this.empressBlade = true; if (!this.empressBlade) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 187) { if (this.ownedProjectileCounts[623] > 0) this.stardustGuardian = true; if (!this.stardustGuardian) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 188) { if (this.ownedProjectileCounts[625] > 0) this.stardustDragon = true; if (!this.stardustDragon) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 161) { if (this.ownedProjectileCounts[533] > 0) this.DeadlySphereMinion = true; if (!this.DeadlySphereMinion) { this.DelBuff(index1); --index1; } else this.buffTime[index1] = 18000; } else if (this.buffType[index1] == 90) { this.mount.SetMount(0, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 128) { this.mount.SetMount(1, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 129) { this.mount.SetMount(2, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 130) { this.mount.SetMount(3, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 131) { this.ignoreWater = true; this.accFlipper = true; this.mount.SetMount(4, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 132) { this.mount.SetMount(5, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 168) { this.ignoreWater = true; this.accFlipper = true; this.mount.SetMount(12, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 141) { this.mount.SetMount(7, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 142) { this.mount.SetMount(8, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 143) { this.mount.SetMount(9, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 162) { this.mount.SetMount(10, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 193) { this.mount.SetMount(14, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 212) { this.mount.SetMount(17, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 230) { this.mount.SetMount(23, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 265) { this.canFloatInWater = true; this.accFlipper = true; this.mount.SetMount(37, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 275) { this.mount.SetMount(40, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 276) { this.mount.SetMount(41, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 277) { this.mount.SetMount(42, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 278) { this.mount.SetMount(43, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 279) { this.ignoreWater = true; this.accFlipper = true; this.mount.SetMount(44, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 280) { this.mount.SetMount(45, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 281) { this.mount.SetMount(46, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 282) { this.mount.SetMount(47, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 283) { this.mount.SetMount(48, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 305) { this.ignoreWater = true; this.accFlipper = true; this.lavaImmune = true; this.mount.SetMount(49, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 318) { this.mount.SetMount(50, this); this.buffTime[index1] = 10; } else if (this.buffType[index1] == 37) { if (Main.wofNPCIndex >= 0 && Main.npc[Main.wofNPCIndex].type == 113) { this.gross = true; this.buffTime[index1] = 10; } else { this.DelBuff(index1); --index1; } } else if (this.buffType[index1] == 38) { this.buffTime[index1] = 10; this.tongued = true; } else if (this.buffType[index1] == 146) { this.moveSpeed += 0.1f; this.moveSpeed *= 1.1f; this.sunflower = true; } else if (this.buffType[index1] == 19) { this.buffTime[index1] = 18000; this.lightOrb = true; bool flag = true; if (this.ownedProjectileCounts[18] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 18, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 155) { this.buffTime[index1] = 18000; this.crimsonHeart = true; bool flag = true; if (this.ownedProjectileCounts[500] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 500, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 191) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.companionCube, 653); else if (this.buffType[index1] == 202) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagDD2Dragon, 701); else if (this.buffType[index1] == 217) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagUpbeatStar, 764); else if (this.buffType[index1] == 219) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagBabyShark, 774); else if (this.buffType[index1] == 258) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagLilHarpy, 815); else if (this.buffType[index1] == 259) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagFennecFox, 816); else if (this.buffType[index1] == 260) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagGlitteryButterfly, 817); else if (this.buffType[index1] == 261) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagBabyImp, 821); else if (this.buffType[index1] == 262) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagBabyRedPanda, 825); else if (this.buffType[index1] == 264) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagPlantero, 854); else if (this.buffType[index1] == 266) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagDynamiteKitten, 858); else if (this.buffType[index1] == 267) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagBabyWerewolf, 859); else if (this.buffType[index1] == 268) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagShadowMimic, 860); else if (this.buffType[index1] == 274) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagVoltBunny, 875); else if (this.buffType[index1] == 284) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagKingSlimePet, 881); else if (this.buffType[index1] == 285) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagEyeOfCthulhuPet, 882); else if (this.buffType[index1] == 286) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagEaterOfWorldsPet, 883); else if (this.buffType[index1] == 287) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagBrainOfCthulhuPet, 884); else if (this.buffType[index1] == 288) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagSkeletronPet, 885); else if (this.buffType[index1] == 289) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagQueenBeePet, 886); else if (this.buffType[index1] == 290) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagDestroyerPet, 887); else if (this.buffType[index1] == 291) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagTwinsPet, 888); else if (this.buffType[index1] == 292) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagSkeletronPrimePet, 889); else if (this.buffType[index1] == 293) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagPlanteraPet, 890); else if (this.buffType[index1] == 294) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagGolemPet, 891); else if (this.buffType[index1] == 295) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagDukeFishronPet, 892); else if (this.buffType[index1] == 296) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagLunaticCultistPet, 893); else if (this.buffType[index1] == 297) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagMoonLordPet, 894); else if (this.buffType[index1] == 298) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagFairyQueenPet, 895); else if (this.buffType[index1] == 299) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagPumpkingPet, 896); else if (this.buffType[index1] == 300) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagEverscreamPet, 897); else if (this.buffType[index1] == 301) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagIceQueenPet, 898); else if (this.buffType[index1] == 302) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagMartianPet, 899); else if (this.buffType[index1] == 303) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagDD2OgrePet, 900); else if (this.buffType[index1] == 304) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagDD2BetsyPet, 901); else if (this.buffType[index1] == 317) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagQueenSlimePet, 934); else if (this.buffType[index1] == 200) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagDD2Gato, 703); else if (this.buffType[index1] == 201) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagDD2Ghost, 702); else if (this.buffType[index1] == 218) this.BuffHandle_SpawnPetIfNeededAndSetTime(index1, ref this.petFlagSugarGlider, 765); else if (this.buffType[index1] == 190) { this.buffTime[index1] = 18000; this.suspiciouslookingTentacle = true; bool flag = true; if (this.ownedProjectileCounts[650] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 650, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 27 || this.buffType[index1] == 101 || this.buffType[index1] == 102) { this.buffTime[index1] = 18000; bool flag = true; int Type = 72; if (this.buffType[index1] == 27) this.blueFairy = true; if (this.buffType[index1] == 101) { Type = 86; this.redFairy = true; } if (this.buffType[index1] == 102) { Type = 87; this.greenFairy = true; } if (this.head == 45 && this.body == 26 && this.legs == 25) Type = 72; if (this.ownedProjectileCounts[Type] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, Type, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 40) { this.buffTime[index1] = 18000; this.bunny = true; bool flag = true; if (this.ownedProjectileCounts[111] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 111, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 148) { this.rabid = true; if (Main.rand.Next(1200) == 0) { int num5 = Main.rand.Next(6); float num6 = (float) Main.rand.Next(60, 100) * 0.01f; switch (num5) { case 0: this.AddBuff(22, (int) (60.0 * (double) num6 * 3.0)); break; case 1: this.AddBuff(23, (int) (60.0 * (double) num6 * 0.75)); break; case 2: this.AddBuff(31, (int) (60.0 * (double) num6 * 1.5)); break; case 3: this.AddBuff(32, (int) (60.0 * (double) num6 * 3.5)); break; case 4: this.AddBuff(33, (int) (60.0 * (double) num6 * 5.0)); break; case 5: this.AddBuff(35, (int) (60.0 * (double) num6 * 1.0)); break; } } this.meleeDamage += 0.2f; this.magicDamage += 0.2f; this.rangedDamage += 0.2f; this.minionDamage += 0.2f; } else if (this.buffType[index1] == 41) { this.buffTime[index1] = 18000; this.penguin = true; bool flag = true; if (this.ownedProjectileCounts[112] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 112, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 152) { this.buffTime[index1] = 18000; this.magicLantern = true; if (this.ownedProjectileCounts[492] == 0 && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 492, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 91) { this.buffTime[index1] = 18000; this.puppy = true; bool flag = true; if (this.ownedProjectileCounts[334] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 334, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 92) { this.buffTime[index1] = 18000; this.grinch = true; bool flag = true; if (this.ownedProjectileCounts[353] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 353, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 84) { this.buffTime[index1] = 18000; this.blackCat = true; bool flag = true; if (this.ownedProjectileCounts[319] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 319, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 61) { this.buffTime[index1] = 18000; this.dino = true; bool flag = true; if (this.ownedProjectileCounts[236] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 236, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 154) { this.buffTime[index1] = 18000; this.babyFaceMonster = true; bool flag = true; if (this.ownedProjectileCounts[499] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 499, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 65) { this.buffTime[index1] = 18000; this.eyeSpring = true; bool flag = true; if (this.ownedProjectileCounts[268] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 268, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 66) { this.buffTime[index1] = 18000; this.snowman = true; bool flag = true; if (this.ownedProjectileCounts[269] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 269, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 42) { this.buffTime[index1] = 18000; this.turtle = true; bool flag = true; if (this.ownedProjectileCounts[(int) sbyte.MaxValue] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, (int) sbyte.MaxValue, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 45) { this.buffTime[index1] = 18000; this.eater = true; bool flag = true; if (this.ownedProjectileCounts[175] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 175, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 50) { this.buffTime[index1] = 18000; this.skeletron = true; bool flag = true; if (this.ownedProjectileCounts[197] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 197, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 51) { this.buffTime[index1] = 18000; this.hornet = true; bool flag = true; if (this.ownedProjectileCounts[198] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 198, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 52) { this.buffTime[index1] = 18000; this.tiki = true; bool flag = true; if (this.ownedProjectileCounts[199] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 199, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 53) { this.buffTime[index1] = 18000; this.lizard = true; bool flag = true; if (this.ownedProjectileCounts[200] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 200, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 54) { this.buffTime[index1] = 18000; this.parrot = true; bool flag = true; if (this.ownedProjectileCounts[208] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 208, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 55) { this.buffTime[index1] = 18000; this.truffle = true; bool flag = true; if (this.ownedProjectileCounts[209] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 209, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 56) { this.buffTime[index1] = 18000; this.sapling = true; bool flag = true; if (this.ownedProjectileCounts[210] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 210, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 85) { this.buffTime[index1] = 18000; this.cSapling = true; bool flag = true; if (this.ownedProjectileCounts[324] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 324, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 81) { this.buffTime[index1] = 18000; this.spider = true; bool flag = true; if (this.ownedProjectileCounts[313] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 313, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 82) { this.buffTime[index1] = 18000; this.squashling = true; bool flag = true; if (this.ownedProjectileCounts[314] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 314, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 57) { this.buffTime[index1] = 18000; this.wisp = true; bool flag = true; if (this.ownedProjectileCounts[211] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 211, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 60) { this.buffTime[index1] = 18000; this.crystalLeaf = true; bool flag = true; for (int index6 = 0; index6 < 1000; ++index6) { if (Main.projectile[index6].active && Main.projectile[index6].owner == this.whoAmI && Main.projectile[index6].type == 226) { if (!flag) Main.projectile[index6].Kill(); flag = false; } } if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 226, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == (int) sbyte.MaxValue) { this.buffTime[index1] = 18000; this.zephyrfish = true; bool flag = true; if (this.ownedProjectileCounts[380] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 380, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 136) { this.buffTime[index1] = 18000; this.miniMinotaur = true; bool flag = true; if (this.ownedProjectileCounts[398] > 0) flag = false; if (flag && this.whoAmI == Main.myPlayer) Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, 398, 0, 0.0f, this.whoAmI); } else if (this.buffType[index1] == 70) this.venom = true; else if (this.buffType[index1] == 20) this.poisoned = true; else if (this.buffType[index1] == 21) this.potionDelay = this.buffTime[index1]; else if (this.buffType[index1] == 22) this.blind = true; else if (this.buffType[index1] == 80) this.blackout = true; else if (this.buffType[index1] == 23) { this.noItems = true; this.cursed = true; } else if (this.buffType[index1] == 24) this.onFire = true; else if (this.buffType[index1] == 103) this.dripping = true; else if (this.buffType[index1] == 137) this.drippingSlime = true; else if (this.buffType[index1] == 320) this.drippingSparkleSlime = true; else if (this.buffType[index1] == 67) this.burned = true; else if (this.buffType[index1] == 68) this.suffocating = true; else if (this.buffType[index1] == 39) this.onFire2 = true; else if (this.buffType[index1] == 44) this.onFrostBurn = true; else if (this.buffType[index1] == 163) { this.headcovered = true; this.bleed = true; } else if (this.buffType[index1] == 164) this.vortexDebuff = true; else if (this.buffType[index1] == 194) this.windPushed = true; else if (this.buffType[index1] == 195) this.witheredArmor = true; else if (this.buffType[index1] == 205) this.ballistaPanic = true; else if (this.buffType[index1] == 196) this.witheredWeapon = true; else if (this.buffType[index1] == 197) this.slowOgreSpit = true; else if (this.buffType[index1] == 198) this.parryDamageBuff = true; else if (this.buffType[index1] == 145) this.moonLeech = true; else if (this.buffType[index1] == 149) { this.webbed = true; if ((double) this.velocity.Y != 0.0) this.velocity = new Vector2(0.0f, 1E-06f); else this.velocity = Vector2.Zero; Player.jumpHeight = 0; this.gravity = 0.0f; this.moveSpeed = 0.0f; this.dash = 0; this.dashType = 0; this.noKnockback = true; this.RemoveAllGrapplingHooks(); } else if (this.buffType[index1] == 43) this.defendedByPaladin = true; else if (this.buffType[index1] == 29) { this.magicCrit += 2; this.magicDamage += 0.05f; this.statManaMax2 += 20; this.manaCost -= 0.02f; } else if (this.buffType[index1] == 28) { if (!Main.dayTime && this.wolfAcc && !this.merman) { ++this.lifeRegen; this.wereWolf = true; this.meleeCrit += 2; this.meleeDamage += 0.051f; this.meleeSpeed += 0.051f; this.statDefense += 3; this.moveSpeed += 0.05f; } else { this.DelBuff(index1); --index1; } } else if (this.buffType[index1] == 33) { this.meleeDamage -= 0.051f; this.meleeSpeed -= 0.051f; this.statDefense -= 4; this.moveSpeed -= 0.1f; } else if (this.buffType[index1] == 25) { this.tipsy = true; this.statDefense -= 4; this.meleeCrit += 2; this.meleeDamage += 0.1f; this.meleeSpeed += 0.1f; } else if (this.buffType[index1] == 26) { this.wellFed = true; this.statDefense += 2; this.meleeCrit += 2; this.meleeDamage += 0.05f; this.meleeSpeed += 0.05f; this.magicCrit += 2; this.magicDamage += 0.05f; this.rangedCrit += 2; this.rangedDamage += 0.05f; this.minionDamage += 0.05f; this.minionKB += 0.5f; this.moveSpeed += 0.2f; this.pickSpeed -= 0.05f; } else if (this.buffType[index1] == 206) { this.wellFed = true; this.statDefense += 3; this.meleeCrit += 3; this.meleeDamage += 0.075f; this.meleeSpeed += 0.075f; this.magicCrit += 3; this.magicDamage += 0.075f; this.rangedCrit += 3; this.rangedDamage += 0.075f; this.minionDamage += 0.075f; this.minionKB += 0.75f; this.moveSpeed += 0.3f; this.pickSpeed -= 0.1f; } else if (this.buffType[index1] == 207) { this.wellFed = true; this.statDefense += 4; this.meleeCrit += 4; this.meleeDamage += 0.1f; this.meleeSpeed += 0.1f; this.magicCrit += 4; this.magicDamage += 0.1f; this.rangedCrit += 4; this.rangedDamage += 0.1f; this.minionDamage += 0.1f; ++this.minionKB; this.moveSpeed += 0.4f; this.pickSpeed -= 0.15f; } else if (this.buffType[index1] == 71) this.meleeEnchant = (byte) 1; else if (this.buffType[index1] == 73) this.meleeEnchant = (byte) 2; else if (this.buffType[index1] == 74) this.meleeEnchant = (byte) 3; else if (this.buffType[index1] == 75) this.meleeEnchant = (byte) 4; else if (this.buffType[index1] == 76) this.meleeEnchant = (byte) 5; else if (this.buffType[index1] == 77) this.meleeEnchant = (byte) 6; else if (this.buffType[index1] == 78) this.meleeEnchant = (byte) 7; else if (this.buffType[index1] == 79) this.meleeEnchant = (byte) 8; } } if (this.whoAmI != Main.myPlayer || (int) this.luckPotion == (int) this.oldLuckPotion) return; this.luckNeedsSync = true; this.oldLuckPotion = this.luckPotion; } private void UpdateProjectileCaches(int i) { for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == i) { ++this.ownedProjectileCounts[Main.projectile[index].type]; if (Main.projectile[index].type == 831) { int originalDamage = Main.projectile[index].originalDamage; if (this.highestStormTigerGemOriginalDamage < originalDamage) this.highestStormTigerGemOriginalDamage = originalDamage; } } } } private void ResetProjectileCaches() { this.highestStormTigerGemOriginalDamage = 0; for (int index = 0; index < this.ownedProjectileCounts.Length; ++index) this.ownedProjectileCounts[index] = 0; } private void BuffHandle_SpawnPetIfNeededAndSetTime( int buffIndex, ref bool petBool, int petProjID, int buffTimeToGive = 18000) { this.buffTime[buffIndex] = buffTimeToGive; this.BuffHandle_SpawnPetIfNeeded(ref petBool, petProjID); } private void BuffHandle_SpawnPetIfNeeded(ref bool petBool, int petProjID) { petBool = true; bool flag = true; if (this.ownedProjectileCounts[petProjID] > 0) flag = false; if (!flag || this.whoAmI != Main.myPlayer) return; Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), 0.0f, 0.0f, petProjID, 0, 0.0f, this.whoAmI); } private void UpdateStormTigerStatus() { int Type; switch (this.GetDesiredStormTigerMinionRank()) { case 1: Type = 833; break; case 2: Type = 834; break; case 3: Type = 835; break; default: Type = -1; break; } bool flag = false; if (Type == -1) flag = true; for (int index = 0; index < ProjectileID.Sets.StormTigerIds.Length; ++index) { int stormTigerId = ProjectileID.Sets.StormTigerIds[index]; if (stormTigerId != Type && this.ownedProjectileCounts[stormTigerId] >= 1) { flag = true; break; } } if (flag) { for (int index = 0; index < 1000; ++index) { Projectile projectile = Main.projectile[index]; if (projectile.active && projectile.owner == this.whoAmI && projectile.type != Type && ProjectileID.Sets.StormTiger[projectile.type]) projectile.Kill(); } } else { if (this.ownedProjectileCounts[Type] >= 1) return; Projectile.NewProjectile(this.Center, Vector2.Zero, Type, 0, 0.0f, this.whoAmI); } } private int GetDesiredStormTigerMinionRank() { int num = 0; int ownedProjectileCount = this.ownedProjectileCounts[831]; if (ownedProjectileCount > 0) num = 1; if (ownedProjectileCount > 3) num = 2; if (ownedProjectileCount > 6) num = 3; return num; } public void Counterweight(Vector2 hitPos, int dmg, float kb) { if (!this.yoyoGlove && this.counterWeight <= 0) return; int index1 = -1; int num1 = 0; int num2 = 0; for (int index2 = 0; index2 < 1000; ++index2) { if (Main.projectile[index2].active && Main.projectile[index2].owner == this.whoAmI) { if (Main.projectile[index2].counterweight) ++num2; else if (Main.projectile[index2].aiStyle == 99) { ++num1; index1 = index2; } } } if (this.yoyoGlove && num1 < 2) { if (index1 < 0) return; Vector2 vector2_1 = hitPos - this.Center; vector2_1.Normalize(); Vector2 vector2_2 = vector2_1 * 16f; Projectile.NewProjectile(this.Center.X, this.Center.Y, vector2_2.X, vector2_2.Y, Main.projectile[index1].type, Main.projectile[index1].damage, Main.projectile[index1].knockBack, this.whoAmI, 1f); } else { if (num2 >= num1) return; Vector2 vector2_3 = hitPos - this.Center; vector2_3.Normalize(); Vector2 vector2_4 = vector2_3 * 16f; float KnockBack = (float) (((double) kb + 6.0) / 2.0); if (num2 > 0) Projectile.NewProjectile(this.Center.X, this.Center.Y, vector2_4.X, vector2_4.Y, this.counterWeight, (int) ((double) dmg * 0.8), KnockBack, this.whoAmI, 1f); else Projectile.NewProjectile(this.Center.X, this.Center.Y, vector2_4.X, vector2_4.Y, this.counterWeight, (int) ((double) dmg * 0.8), KnockBack, this.whoAmI); } } public int beeType() { if (this.strongBees && Main.rand.Next(2) == 0) { this.makeStrongBee = true; return 566; } this.makeStrongBee = false; return 181; } public int beeDamage(int dmg) => this.makeStrongBee ? dmg + Main.rand.Next(1, 4) : dmg + Main.rand.Next(2); public float beeKB(float KB) => this.makeStrongBee ? (float) (0.5 + (double) KB * 1.10000002384186) : KB; public void Yoraiz0rEye() { int index = 0 + this.bodyFrame.Y / 56; if (index >= Main.OffsetsPlayerHeadgear.Length) index = 0; Vector2 vector2_1 = new Vector2((float) (this.width / 2), (float) (this.height / 2)) + Main.OffsetsPlayerHeadgear[index] + (this.MountedCenter - this.Center); Vector2 posOffset; float seatAdjustment; this.sitting.GetSittingOffsetInfo(this, out posOffset, out seatAdjustment); Vector2 vector2_2 = vector2_1 + (posOffset + new Vector2(0.0f, seatAdjustment)); float y = -11.5f * this.gravDir; if ((double) this.gravDir == -1.0) y -= 4f; Vector2 spinningpoint1 = new Vector2((float) (3 * this.direction - (this.direction == 1 ? 1 : 0)), y) + Vector2.UnitY * this.gfxOffY + vector2_2; Vector2 spinningpoint2 = new Vector2((float) (3 * this.shadowDirection[1] - (this.direction == 1 ? 1 : 0)), y) + vector2_2; Vector2 vector2_3 = Vector2.Zero; if (this.mount.Active && this.mount.Cart) { int num = Math.Sign(this.velocity.X); if (num == 0) num = this.direction; vector2_3 = new Vector2(MathHelper.Lerp(0.0f, -8f, this.fullRotation / 0.7853982f), MathHelper.Lerp(0.0f, 2f, Math.Abs(this.fullRotation / 0.7853982f))).RotatedBy((double) this.fullRotation); if (num == Math.Sign(this.fullRotation)) vector2_3 *= MathHelper.Lerp(1f, 0.6f, Math.Abs(this.fullRotation / 0.7853982f)); } if ((double) this.fullRotation != 0.0) { spinningpoint1 = spinningpoint1.RotatedBy((double) this.fullRotation, this.fullRotationOrigin); spinningpoint2 = spinningpoint2.RotatedBy((double) this.fullRotation, this.fullRotationOrigin); } float num1 = 0.0f; Vector2 vector2_4 = this.position + spinningpoint1 + vector2_3; Vector2 vector2_5 = this.oldPosition + spinningpoint2 + vector2_3; vector2_5.Y -= num1 / 2f; vector2_4.Y -= num1 / 2f; float num2 = 1f; switch (this.yoraiz0rEye % 10) { case 1: return; case 2: num2 = 0.5f; break; case 3: num2 = 0.625f; break; case 4: num2 = 0.75f; break; case 5: num2 = 0.875f; break; case 6: num2 = 1f; break; case 7: num2 = 1.1f; break; } if (this.yoraiz0rEye < 7) { DelegateMethods.v3_1 = Main.hslToRgb(Main.rgbToHsl(this.eyeColor).X, 1f, 0.5f).ToVector3() * 0.5f * num2; if (this.velocity != Vector2.Zero) Utils.PlotTileLine(this.Center, this.Center + this.velocity * 2f, 4f, new Utils.TileActionAttempt(DelegateMethods.CastLightOpen)); else Utils.PlotTileLine(this.Left, this.Right, 4f, new Utils.TileActionAttempt(DelegateMethods.CastLightOpen)); } int num3 = (int) Vector2.Distance(vector2_4, vector2_5) / 3 + 1; if ((double) Vector2.Distance(vector2_4, vector2_5) % 3.0 != 0.0) ++num3; for (float num4 = 1f; (double) num4 <= (double) num3; ++num4) { Dust dust = Main.dust[Dust.NewDust(this.Center, 0, 0, 182)]; dust.position = Vector2.Lerp(vector2_5, vector2_4, num4 / (float) num3); dust.noGravity = true; dust.velocity = Vector2.Zero; dust.customData = (object) this; dust.scale = num2; dust.shader = GameShaders.Armor.GetSecondaryShader(this.cYorai, this); } } public bool IsAValidEquipmentSlotForIteration(int slot) { switch (slot) { case 8: case 18: bool flag1 = this.extraAccessory; if ((Main.expertMode ? 1 : (Main.gameMenu ? 1 : 0)) == 0) flag1 = false; return flag1; case 9: case 19: bool flag2 = true; if ((Main.masterMode ? 1 : (Main.gameMenu ? 1 : 0)) == 0) flag2 = false; return flag2; default: return true; } } public void UpdateEquips(int i) { if (this.inventory[this.selectedItem].type == 277 && (!this.mount.Active || !this.mount.Cart)) this.trident = true; for (int index = 0; index < 58; ++index) { int type = this.inventory[index].type; if ((type == 15 || type == 707) && this.accWatch < 1) this.accWatch = 1; if ((type == 16 || type == 708) && this.accWatch < 2) this.accWatch = 2; if ((type == 17 || type == 709) && this.accWatch < 3) this.accWatch = 3; if (type == 393) this.accCompass = 1; if (type == 18) this.accDepthMeter = 1; if (type == 395 || type == 3123 || type == 3124) { this.accWatch = 3; this.accDepthMeter = 1; this.accCompass = 1; } if (type == 3120 || type == 3036 || type == 3123 || type == 3124) this.accFishFinder = true; if (type == 3037 || type == 3036 || type == 3123 || type == 3124) this.accWeatherRadio = true; if (type == 3096 || type == 3036 || type == 3123 || type == 3124) this.accCalendar = true; if (type == 3084 || type == 3122 || type == 3123 || type == 3124) this.accThirdEye = true; if (type == 3095 || type == 3122 || type == 3123 || type == 3124) this.accJarOfSouls = true; if (type == 3118 || type == 3122 || type == 3123 || type == 3124) this.accCritterGuide = true; if (type == 3099 || type == 3121 || type == 3123 || type == 3124) this.accStopwatch = true; if (type == 3102 || type == 3121 || type == 3123 || type == 3124) this.accOreFinder = true; if (type == 3119 || type == 3121 || type == 3123 || type == 3124) this.accDreamCatcher = true; if (type == 3619 || type == 3611) this.InfoAccMechShowWires = true; if (type == 486 || type == 3611) this.rulerLine = true; if (type == 2799) this.rulerGrid = true; if (type == 2216 || type == 3061) this.autoPaint = true; if (type == 3624) this.autoActuator = true; if (type == 4346) this.preventAllItemPickups = true; if (type == 4767) this.dontHurtCritters = true; if (type == 4743) this.hasFootball = true; } if (this.inventory[58].type == 4743) this.hasFootball = true; for (int slot = 0; slot < 10; ++slot) { if (this.IsAValidEquipmentSlotForIteration(slot) && (!this.armor[slot].expertOnly || Main.expertMode)) { int type = this.armor[slot].type; if ((type == 15 || type == 707) && this.accWatch < 1) this.accWatch = 1; if ((type == 16 || type == 708) && this.accWatch < 2) this.accWatch = 2; if ((type == 17 || type == 709) && this.accWatch < 3) this.accWatch = 3; if (type == 393) this.accCompass = 1; if (type == 18) this.accDepthMeter = 1; if (type == 395 || type == 3123 || type == 3124) { this.accWatch = 3; this.accDepthMeter = 1; this.accCompass = 1; } if (type == 3120 || type == 3036 || type == 3123 || type == 3124) this.accFishFinder = true; if (type == 3037 || type == 3036 || type == 3123 || type == 3124) this.accWeatherRadio = true; if (type == 3096 || type == 3036 || type == 3123 || type == 3124) this.accCalendar = true; if (type == 3084 || type == 3122 || type == 3123 || type == 3124) this.accThirdEye = true; if (type == 3095 || type == 3122 || type == 3123 || type == 3124) this.accJarOfSouls = true; if (type == 3118 || type == 3122 || type == 3123 || type == 3124) this.accCritterGuide = true; if (type == 3099 || type == 3121 || type == 3123 || type == 3124) this.accStopwatch = true; if (type == 3102 || type == 3121 || type == 3123 || type == 3124) this.accOreFinder = true; if (type == 3119 || type == 3121 || type == 3123 || type == 3124) this.accDreamCatcher = true; if (type == 3619) this.InfoAccMechShowWires = true; if (this.armor[slot].type == 3017 || this.armor[slot].type == 3993) { this.flowerBoots = true; if (this.armor[slot].type == 3993) this.fairyBoots = true; if (this.whoAmI == Main.myPlayer) this.DoBootsEffect(new Utils.TileActionAttempt(this.DoBootsEffect_PlaceFlowersOnTile)); } if (this.armor[slot].type == 5001) { this.moveSpeed += 0.25f; this.moonLordLegs = true; } this.statDefense += this.armor[slot].defense; this.lifeRegen += this.armor[slot].lifeRegen; if (this.armor[slot].shieldSlot > (sbyte) 0) this.hasRaisableShield = true; switch (this.armor[slot].type) { case 3797: ++this.maxTurrets; this.manaCost -= 0.1f; break; case 3798: this.magicDamage += 0.1f; this.minionDamage += 0.2f; break; case 3799: this.minionDamage += 0.1f; this.magicCrit += 20; break; case 3800: ++this.maxTurrets; this.lifeRegen += 4; break; case 3801: this.meleeDamage += 0.15f; this.minionDamage += 0.15f; break; case 3802: this.minionDamage += 0.15f; this.meleeCrit += 20; this.moveSpeed += 0.2f; break; case 3803: ++this.maxTurrets; this.rangedCrit += 10; break; case 3804: this.rangedDamage += 0.2f; this.minionDamage += 0.2f; break; case 3805: this.minionDamage += 0.1f; this.moveSpeed += 0.2f; break; case 3806: ++this.maxTurrets; this.meleeSpeed += 0.2f; break; case 3807: this.meleeDamage += 0.2f; this.minionDamage += 0.2f; break; case 3808: this.minionDamage += 0.1f; this.meleeCrit += 10; this.moveSpeed += 0.2f; break; case 3871: this.maxTurrets += 2; this.minionDamage += 0.1f; break; case 3872: this.minionDamage += 0.3f; this.lifeRegen += 8; break; case 3873: this.minionDamage += 0.2f; this.meleeCrit += 20; this.moveSpeed += 0.3f; break; case 3874: this.maxTurrets += 2; this.magicDamage += 0.1f; this.minionDamage += 0.1f; break; case 3875: this.minionDamage += 0.3f; this.magicDamage += 0.15f; break; case 3876: this.minionDamage += 0.2f; this.magicCrit += 25; break; case 3877: this.maxTurrets += 2; this.minionDamage += 0.1f; this.rangedCrit += 10; break; case 3878: this.minionDamage += 0.25f; this.rangedDamage += 0.25f; break; case 3879: this.minionDamage += 0.25f; this.moveSpeed += 0.2f; break; case 3880: this.maxTurrets += 2; this.minionDamage += 0.2f; this.meleeDamage += 0.2f; break; case 3881: this.meleeSpeed += 0.2f; this.minionDamage += 0.2f; break; case 3882: this.minionDamage += 0.2f; this.meleeCrit += 20; this.moveSpeed += 0.2f; break; } if (this.armor[slot].type == 268) this.accDivingHelm = true; if (this.armor[slot].type == 238) this.magicDamage += 0.15f; if (this.armor[slot].type == 3770) this.slowFall = true; if (this.armor[slot].type == 4404) this.canFloatInWater = true; if (this.armor[slot].type == 3776) { this.magicDamage += 0.15f; this.minionDamage += 0.15f; } if (this.armor[slot].type == 3777) { this.statManaMax2 += 40; ++this.maxMinions; } if (this.armor[slot].type == 3778) { this.statManaMax2 += 40; ++this.maxMinions; } if (this.armor[slot].type == 3212) this.armorPenetration += 5; if (this.armor[slot].type == 2277) { this.magicDamage += 0.05f; this.meleeDamage += 0.05f; this.rangedDamage += 0.05f; this.minionDamage += 0.05f; this.magicCrit += 5; this.rangedCrit += 5; this.meleeCrit += 5; this.meleeSpeed += 0.1f; this.moveSpeed += 0.1f; } if (this.armor[slot].type == 2279) { this.magicDamage += 0.06f; this.magicCrit += 6; this.manaCost -= 0.1f; } if (this.armor[slot].type == 3109 || this.armor[slot].type == 4008) this.nightVision = true; if (this.armor[slot].type == 256 || this.armor[slot].type == 257 || this.armor[slot].type == 258) { this.rangedCrit += 3; this.meleeCrit += 3; this.magicCrit += 3; } if (this.armor[slot].type == 3374 || this.armor[slot].type == 3375 || this.armor[slot].type == 3376) this.rangedCrit += 3; if (this.armor[slot].type == 151 || this.armor[slot].type == 959 || this.armor[slot].type == 152 || this.armor[slot].type == 153) this.rangedDamage += 0.05f; if (this.armor[slot].type == 2275) { this.magicDamage += 0.07f; this.magicCrit += 7; } if (this.armor[slot].type == 123 || this.armor[slot].type == 124 || this.armor[slot].type == 125) this.magicDamage += 0.07f; if (this.armor[slot].type == 111 || this.armor[slot].type == 228 || this.armor[slot].type == 229 || this.armor[slot].type == 230 || this.armor[slot].type == 960 || this.armor[slot].type == 961 || this.armor[slot].type == 962) this.statManaMax2 += 20; if (this.armor[slot].type == 228 || this.armor[slot].type == 960) this.statManaMax2 += 20; if (this.armor[slot].type == 228 || this.armor[slot].type == 229 || this.armor[slot].type == 230 || this.armor[slot].type == 960 || this.armor[slot].type == 961 || this.armor[slot].type == 962) this.magicCrit += 4; if (this.armor[slot].type == 100 || this.armor[slot].type == 101 || this.armor[slot].type == 102) this.meleeSpeed += 0.07f; if (this.armor[slot].type == 956 || this.armor[slot].type == 957 || this.armor[slot].type == 958) this.meleeSpeed += 0.07f; if (this.armor[slot].type == 792 || this.armor[slot].type == 793 || this.armor[slot].type == 794) { this.meleeDamage += 0.02f; this.rangedDamage += 0.02f; this.magicDamage += 0.02f; this.minionDamage += 0.02f; } if (this.armor[slot].type == 371) { this.magicCrit += 9; this.statManaMax2 += 40; } if (this.armor[slot].type == 372) { this.moveSpeed += 0.07f; this.meleeSpeed += 0.12f; } if (this.armor[slot].type == 373) { this.rangedDamage += 0.1f; this.rangedCrit += 6; } if (this.armor[slot].type == 374) { this.magicCrit += 3; this.meleeCrit += 3; this.rangedCrit += 3; } if (this.armor[slot].type == 375) this.moveSpeed += 0.1f; if (this.armor[slot].type == 376) { this.magicDamage += 0.15f; this.statManaMax2 += 60; } if (this.armor[slot].type == 377) { this.meleeCrit += 5; this.meleeDamage += 0.1f; } if (this.armor[slot].type == 378) { this.rangedDamage += 0.12f; this.rangedCrit += 7; } if (this.armor[slot].type == 379) { this.rangedDamage += 0.05f; this.meleeDamage += 0.05f; this.magicDamage += 0.05f; this.minionDamage += 0.05f; } if (this.armor[slot].type == 380) { this.magicCrit += 3; this.meleeCrit += 3; this.rangedCrit += 3; } if (this.armor[slot].type >= 2367 && this.armor[slot].type <= 2369) this.fishingSkill += 5; if (this.armor[slot].type == 400) { this.magicDamage += 0.11f; this.magicCrit += 11; this.statManaMax2 += 80; } if (this.armor[slot].type == 401) { this.meleeCrit += 7; this.meleeDamage += 0.14f; } if (this.armor[slot].type == 402) { this.rangedDamage += 0.14f; this.rangedCrit += 8; } if (this.armor[slot].type == 403) { this.rangedDamage += 0.06f; this.meleeDamage += 0.06f; this.magicDamage += 0.06f; this.minionDamage += 0.06f; } if (this.armor[slot].type == 404) { this.magicCrit += 4; this.meleeCrit += 4; this.rangedCrit += 4; this.moveSpeed += 0.05f; } if (this.armor[slot].type == 1205) { this.meleeDamage += 0.08f; this.meleeSpeed += 0.12f; } if (this.armor[slot].type == 1206) { this.rangedDamage += 0.09f; this.rangedCrit += 9; } if (this.armor[slot].type == 1207) { this.magicDamage += 0.07f; this.magicCrit += 7; this.statManaMax2 += 60; } if (this.armor[slot].type == 1208) { this.meleeDamage += 0.03f; this.rangedDamage += 0.03f; this.magicDamage += 0.03f; this.minionDamage += 0.03f; this.magicCrit += 2; this.meleeCrit += 2; this.rangedCrit += 2; } if (this.armor[slot].type == 1209) { this.meleeDamage += 0.02f; this.rangedDamage += 0.02f; this.magicDamage += 0.02f; this.minionDamage += 0.02f; ++this.magicCrit; ++this.meleeCrit; ++this.rangedCrit; } if (this.armor[slot].type == 1210) { this.meleeDamage += 0.07f; this.meleeSpeed += 0.07f; this.moveSpeed += 0.07f; } if (this.armor[slot].type == 1211) { this.rangedCrit += 15; this.moveSpeed += 0.08f; } if (this.armor[slot].type == 1212) { this.magicCrit += 18; this.statManaMax2 += 80; } if (this.armor[slot].type == 1213) { this.magicCrit += 6; this.meleeCrit += 6; this.rangedCrit += 6; } if (this.armor[slot].type == 1214) this.moveSpeed += 0.11f; if (this.armor[slot].type == 1215) { this.meleeDamage += 0.08f; this.meleeCrit += 8; this.meleeSpeed += 0.08f; } if (this.armor[slot].type == 1216) { this.rangedDamage += 0.16f; this.rangedCrit += 7; } if (this.armor[slot].type == 1217) { this.magicDamage += 0.16f; this.magicCrit += 7; this.statManaMax2 += 100; } if (this.armor[slot].type == 1218) { this.meleeDamage += 0.04f; this.rangedDamage += 0.04f; this.magicDamage += 0.04f; this.minionDamage += 0.04f; this.magicCrit += 3; this.meleeCrit += 3; this.rangedCrit += 3; } if (this.armor[slot].type == 1219) { this.meleeDamage += 0.03f; this.rangedDamage += 0.03f; this.magicDamage += 0.03f; this.minionDamage += 0.03f; this.magicCrit += 3; this.meleeCrit += 3; this.rangedCrit += 3; this.moveSpeed += 0.06f; } if (this.armor[slot].type == 558 || this.armor[slot].type == 4898) { this.magicDamage += 0.12f; this.magicCrit += 12; this.statManaMax2 += 100; } if (this.armor[slot].type == 559 || this.armor[slot].type == 4896) { this.meleeCrit += 10; this.meleeDamage += 0.1f; this.meleeSpeed += 0.1f; } if (this.armor[slot].type == 553 || this.armor[slot].type == 4897) { this.rangedDamage += 0.15f; this.rangedCrit += 8; } if (this.armor[slot].type == 4873 || this.armor[slot].type == 4899) { this.minionDamage += 0.1f; ++this.maxMinions; } if (this.armor[slot].type == 551 || this.armor[slot].type == 4900) { this.magicCrit += 7; this.meleeCrit += 7; this.rangedCrit += 7; } if (this.armor[slot].type == 552 || this.armor[slot].type == 4901) { this.rangedDamage += 0.07f; this.meleeDamage += 0.07f; this.magicDamage += 0.07f; this.minionDamage += 0.07f; this.moveSpeed += 0.08f; } if (this.armor[slot].type == 4982) { this.rangedCrit += 5; this.meleeCrit += 5; this.magicCrit += 5; } if (this.armor[slot].type == 4983) { this.rangedDamage += 0.05f; this.meleeDamage += 0.05f; this.magicDamage += 0.05f; this.minionDamage += 0.05f; } if (this.armor[slot].type == 4984) this.moveSpeed += 0.1f; if (this.armor[slot].type == 1001) { this.meleeDamage += 0.16f; this.meleeCrit += 6; } if (this.armor[slot].type == 1002) { this.rangedDamage += 0.16f; this.chloroAmmoCost80 = true; } if (this.armor[slot].type == 1003) { this.statManaMax2 += 80; this.manaCost -= 0.17f; this.magicDamage += 0.16f; } if (this.armor[slot].type == 1004) { this.meleeDamage += 0.05f; this.magicDamage += 0.05f; this.rangedDamage += 0.05f; this.minionDamage += 0.05f; this.magicCrit += 7; this.meleeCrit += 7; this.rangedCrit += 7; } if (this.armor[slot].type == 1005) { this.magicCrit += 8; this.meleeCrit += 8; this.rangedCrit += 8; this.moveSpeed += 0.05f; } if (this.armor[slot].type == 2189) { this.statManaMax2 += 60; this.manaCost -= 0.13f; this.magicDamage += 0.05f; this.magicCrit += 5; } if (this.armor[slot].type == 1503) this.magicDamage -= 0.4f; if (this.armor[slot].type == 1504) { this.magicDamage += 0.07f; this.magicCrit += 7; } if (this.armor[slot].type == 1505) { this.magicDamage += 0.08f; this.moveSpeed += 0.08f; } if (this.armor[slot].type == 1546) { this.rangedCrit += 5; this.arrowDamage += 0.15f; } if (this.armor[slot].type == 1547) { this.rangedCrit += 5; this.bulletDamage += 0.15f; } if (this.armor[slot].type == 1548) { this.rangedCrit += 5; this.rocketDamage += 0.15f; } if (this.armor[slot].type == 1549) { this.rangedCrit += 13; this.rangedDamage += 0.13f; this.ammoCost80 = true; } if (this.armor[slot].type == 1550) { this.rangedCrit += 7; this.moveSpeed += 0.12f; } if (this.armor[slot].type == 1282) { this.statManaMax2 += 20; this.manaCost -= 0.05f; } if (this.armor[slot].type == 1283) { this.statManaMax2 += 40; this.manaCost -= 0.07f; } if (this.armor[slot].type == 1284) { this.statManaMax2 += 40; this.manaCost -= 0.09f; } if (this.armor[slot].type == 1285) { this.statManaMax2 += 60; this.manaCost -= 0.11f; } if (this.armor[slot].type == 1286 || this.armor[slot].type == 4256) { this.statManaMax2 += 60; this.manaCost -= 0.13f; } if (this.armor[slot].type == 1287) { this.statManaMax2 += 80; this.manaCost -= 0.15f; } if (this.armor[slot].type == 1316 || this.armor[slot].type == 1317 || this.armor[slot].type == 1318) this.aggro += 250; if (this.armor[slot].type == 1316) this.meleeDamage += 0.06f; if (this.armor[slot].type == 1317) { this.meleeDamage += 0.08f; this.meleeCrit += 8; } if (this.armor[slot].type == 1318) this.meleeCrit += 4; if (this.armor[slot].type == 2199 || this.armor[slot].type == 2202) this.aggro += 250; if (this.armor[slot].type == 2201) this.aggro += 400; if (this.armor[slot].type == 2199) this.meleeDamage += 0.06f; if (this.armor[slot].type == 2200) { this.meleeDamage += 0.08f; this.meleeCrit += 8; this.meleeSpeed += 0.06f; this.moveSpeed += 0.06f; } if (this.armor[slot].type == 2201) { this.meleeDamage += 0.05f; this.meleeCrit += 5; } if (this.armor[slot].type == 2202) { this.meleeSpeed += 0.06f; this.moveSpeed += 0.06f; } if (this.armor[slot].type == 684) { this.rangedDamage += 0.16f; this.meleeDamage += 0.16f; } if (this.armor[slot].type == 685) { this.meleeCrit += 11; this.rangedCrit += 11; } if (this.armor[slot].type == 686) { this.moveSpeed += 0.08f; this.meleeSpeed += 0.07f; } if (this.armor[slot].type == 2361) { ++this.maxMinions; this.minionDamage += 0.04f; } if (this.armor[slot].type == 2362) { ++this.maxMinions; this.minionDamage += 0.04f; } if (this.armor[slot].type == 2363) this.minionDamage += 0.05f; if (this.armor[slot].type >= 1158 && this.armor[slot].type <= 1161) ++this.maxMinions; if (this.armor[slot].type >= 1159 && this.armor[slot].type <= 1161) this.minionDamage += 0.1f; if (this.armor[slot].type >= 2370 && this.armor[slot].type <= 2371) { this.minionDamage += 0.05f; ++this.maxMinions; } if (this.armor[slot].type == 2372) { this.minionDamage += 0.06f; ++this.maxMinions; } if (this.armor[slot].type == 3381 || this.armor[slot].type == 3382 || this.armor[slot].type == 3383) { if (this.armor[slot].type != 3381) ++this.maxMinions; ++this.maxMinions; this.minionDamage += 0.22f; } if (this.armor[slot].type == 2763) { this.aggro += 300; this.meleeCrit += 26; this.lifeRegen += 2; } if (this.armor[slot].type == 2764) { this.aggro += 300; this.meleeDamage += 0.29f; this.lifeRegen += 2; } if (this.armor[slot].type == 2765) { this.aggro += 300; this.meleeSpeed += 0.15f; this.moveSpeed += 0.15f; this.lifeRegen += 2; } if (this.armor[slot].type == 2757) { this.rangedCrit += 7; this.rangedDamage += 0.16f; } if (this.armor[slot].type == 2758) { this.ammoCost75 = true; this.rangedCrit += 12; this.rangedDamage += 0.12f; } if (this.armor[slot].type == 2759) { this.rangedCrit += 8; this.rangedDamage += 0.08f; this.moveSpeed += 0.1f; } if (this.armor[slot].type == 2760) { this.statManaMax2 += 60; this.manaCost -= 0.15f; this.magicCrit += 7; this.magicDamage += 0.07f; } if (this.armor[slot].type == 2761) { this.magicDamage += 0.09f; this.magicCrit += 9; } if (this.armor[slot].type == 2762) { this.moveSpeed += 0.1f; this.magicDamage += 0.1f; } if (this.armor[slot].type == 1832) { ++this.maxMinions; this.minionDamage += 0.11f; } if (this.armor[slot].type == 1833) { this.maxMinions += 2; this.minionDamage += 0.11f; } if (this.armor[slot].type == 1834) { this.moveSpeed += 0.2f; ++this.maxMinions; this.minionDamage += 0.11f; } if (this.armor[slot].prefix == (byte) 62) ++this.statDefense; if (this.armor[slot].prefix == (byte) 63) this.statDefense += 2; if (this.armor[slot].prefix == (byte) 64) this.statDefense += 3; if (this.armor[slot].prefix == (byte) 65) this.statDefense += 4; if (this.armor[slot].prefix == (byte) 66) this.statManaMax2 += 20; if (this.armor[slot].prefix == (byte) 67) { this.meleeCrit += 2; this.rangedCrit += 2; this.magicCrit += 2; } if (this.armor[slot].prefix == (byte) 68) { this.meleeCrit += 4; this.rangedCrit += 4; this.magicCrit += 4; } if (this.armor[slot].prefix == (byte) 69) { this.meleeDamage += 0.01f; this.rangedDamage += 0.01f; this.magicDamage += 0.01f; this.minionDamage += 0.01f; } if (this.armor[slot].prefix == (byte) 70) { this.meleeDamage += 0.02f; this.rangedDamage += 0.02f; this.magicDamage += 0.02f; this.minionDamage += 0.02f; } if (this.armor[slot].prefix == (byte) 71) { this.meleeDamage += 0.03f; this.rangedDamage += 0.03f; this.magicDamage += 0.03f; this.minionDamage += 0.03f; } if (this.armor[slot].prefix == (byte) 72) { this.meleeDamage += 0.04f; this.rangedDamage += 0.04f; this.magicDamage += 0.04f; this.minionDamage += 0.04f; } if (this.armor[slot].prefix == (byte) 73) this.moveSpeed += 0.01f; if (this.armor[slot].prefix == (byte) 74) this.moveSpeed += 0.02f; if (this.armor[slot].prefix == (byte) 75) this.moveSpeed += 0.03f; if (this.armor[slot].prefix == (byte) 76) this.moveSpeed += 0.04f; if (this.armor[slot].prefix == (byte) 77) this.meleeSpeed += 0.01f; if (this.armor[slot].prefix == (byte) 78) this.meleeSpeed += 0.02f; if (this.armor[slot].prefix == (byte) 79) this.meleeSpeed += 0.03f; if (this.armor[slot].prefix == (byte) 80) this.meleeSpeed += 0.04f; } } this.equippedAnyWallSpeedAcc = false; this.equippedAnyTileSpeedAcc = false; this.equippedAnyTileRangeAcc = false; for (int index = 3; index < 10; ++index) { if (this.IsAValidEquipmentSlotForIteration(index)) this.ApplyEquipFunctional(index, this.armor[index]); } if (this.skyStoneEffects) { this.lifeRegen += 2; this.statDefense += 4; this.meleeSpeed += 0.1f; this.meleeDamage += 0.1f; this.meleeCrit += 2; this.rangedDamage += 0.1f; this.rangedCrit += 2; this.magicDamage += 0.1f; this.magicCrit += 2; this.pickSpeed -= 0.15f; this.minionDamage += 0.1f; this.minionKB += 0.5f; } if (this.dd2Accessory) { this.minionDamage += 0.1f; ++this.maxTurrets; } for (int slot = 3; slot < 10; ++slot) { if (this.armor[slot].wingSlot > (sbyte) 0 && this.IsAValidEquipmentSlotForIteration(slot)) { if (!this.hideVisibleAccessory[slot] || (double) this.velocity.Y != 0.0 && !this.mount.Active) this.wings = (int) this.armor[slot].wingSlot; this.wingsLogic = (int) this.armor[slot].wingSlot; } } for (int index = 13; index < 20; ++index) { if (this.IsAValidEquipmentSlotForIteration(index)) this.ApplyEquipVanity(index, this.armor[index]); } if (this.wet && this.ShouldFloatInWater) this.accFlipper = true; if (this.whoAmI == Main.myPlayer && Main.SceneMetrics.HasClock && this.accWatch < 3) ++this.accWatch; if (this.equippedAnyTileSpeedAcc && this.inventory[this.selectedItem].createTile != 4) this.tileSpeed += 0.5f; if (this.equippedAnyWallSpeedAcc) this.wallSpeed += 0.5f; if (this.equippedAnyTileRangeAcc && this.whoAmI == Main.myPlayer) { Player.tileRangeX += 3; Player.tileRangeY += 2; } if (!this.accThirdEye) this.accThirdEyeCounter = (byte) 0; if (Main.netMode == 1 && this.whoAmI == Main.myPlayer) { for (int index = 0; index < (int) byte.MaxValue; ++index) { if (index != this.whoAmI && Main.player[index].active && !Main.player[index].dead && Main.player[index].team == this.team && Main.player[index].team != 0) { int num = 800; if ((double) (Main.player[index].Center - this.Center).Length() < (double) num) { if (Main.player[index].accWatch > this.accWatch) this.accWatch = Main.player[index].accWatch; if (Main.player[index].accCompass > this.accCompass) this.accCompass = Main.player[index].accCompass; if (Main.player[index].accDepthMeter > this.accDepthMeter) this.accDepthMeter = Main.player[index].accDepthMeter; if (Main.player[index].accFishFinder) this.accFishFinder = true; if (Main.player[index].accWeatherRadio) this.accWeatherRadio = true; if (Main.player[index].accThirdEye) this.accThirdEye = true; if (Main.player[index].accJarOfSouls) this.accJarOfSouls = true; if (Main.player[index].accCalendar) this.accCalendar = true; if (Main.player[index].accStopwatch) this.accStopwatch = true; if (Main.player[index].accOreFinder) this.accOreFinder = true; if (Main.player[index].accCritterGuide) this.accCritterGuide = true; if (Main.player[index].accDreamCatcher) this.accDreamCatcher = true; } } } } if (!this.accDreamCatcher && this.dpsStarted) { this.dpsStarted = false; this.dpsEnd = DateTime.Now; } if (this.HeldItem.type != 4760 || this.ownedProjectileCounts[866] >= 1) return; this.hasRaisableShield = true; } private void DoBootsEffect(Utils.TileActionAttempt theEffectMethod) { if (this.miscCounter % 2 != 0 || (double) this.velocity.Y != 0.0 || this.grappling[0] != -1 || (double) this.velocity.X == 0.0) return; int x = (int) this.Center.X / 16; int y = (int) ((double) this.position.Y + (double) this.height - 1.0) / 16; int num = theEffectMethod(x, y) ? 1 : 0; } private bool DoBootsEffect_PlaceFlamesOnTile(int X, int Y) { Tile tile = Main.tile[X, Y + 1]; if (tile == null || !tile.active() || tile.liquid > (byte) 0 || !WorldGen.SolidTileAllowBottomSlope(X, Y + 1)) return false; ParticleOrchestrator.RequestParticleSpawn(true, ParticleOrchestraType.FlameWaders, new ParticleOrchestraSettings() { PositionInWorld = new Vector2((float) (X * 16 + 8), (float) (Y * 16 + 16)) }, new int?(this.whoAmI)); return true; } private bool DoBootsEffect_PlaceFlowersOnTile(int X, int Y) { Tile tile = Main.tile[X, Y]; if (tile == null || tile.active() || tile.liquid != (byte) 0 || Main.tile[X, Y + 1] == null || !WorldGen.SolidTile(X, Y + 1)) return false; tile.frameY = (short) 0; tile.slope((byte) 0); tile.halfBrick(false); if (Main.tile[X, Y + 1].type == (ushort) 2 || Main.tile[X, Y + 1].type == (ushort) 477) { int num = Main.rand.NextFromList(6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 27, 30, 33, 36, 39, 42); switch (num) { case 21: case 24: case 27: case 30: case 33: case 36: case 39: case 42: num += Main.rand.Next(3); break; } tile.active(true); tile.type = (ushort) 3; tile.frameX = (short) (num * 18); tile.color(Main.tile[X, Y + 1].color()); if (Main.netMode == 1) NetMessage.SendTileSquare(-1, X, Y, 1); return true; } if (Main.tile[X, Y + 1].type == (ushort) 109 || Main.tile[X, Y + 1].type == (ushort) 492) { if (Main.rand.Next(2) == 0) { tile.active(true); tile.type = (ushort) 110; tile.frameX = (short) (18 * Main.rand.Next(4, 7)); tile.color(Main.tile[X, Y + 1].color()); while (tile.frameX == (short) 90) tile.frameX = (short) (18 * Main.rand.Next(4, 7)); } else { tile.active(true); tile.type = (ushort) 113; tile.frameX = (short) (18 * Main.rand.Next(2, 8)); tile.color(Main.tile[X, Y + 1].color()); while (tile.frameX == (short) 90) tile.frameX = (short) (18 * Main.rand.Next(2, 8)); } if (Main.netMode == 1) NetMessage.SendTileSquare(-1, X, Y, 1); return true; } if (Main.tile[X, Y + 1].type != (ushort) 60) return false; tile.active(true); tile.type = (ushort) 74; tile.frameX = (short) (18 * Main.rand.Next(9, 17)); tile.color(Main.tile[X, Y + 1].color()); if (Main.netMode == 1) NetMessage.SendTileSquare(-1, X, Y, 1); return true; } private void ApplyEquipVanity(int itemSlot, Item currentItem) { int type = currentItem.type; if (currentItem.wingSlot > (sbyte) 0) this.wings = (int) currentItem.wingSlot; if (type == 861 || type == 3110 || type == 485) { this.hideWolf = false; this.forceWerewolf = true; } if (((!this.wet || this.lavaWet ? 0 : (!this.mount.Active ? 1 : (!this.mount.IsConsideredASlimeMount ? 1 : 0))) != 0 || !this.forceWerewolf) && (type == 861 || type == 3110 || type == 497)) { this.hideMerman = false; this.forceMerman = true; } if ((!this.mount.Active || this.mount.Type != 47) && (type == 4822 || type == 4874)) this.DoBootsEffect(new Utils.TileActionAttempt(this.DoBootsEffect_PlaceFlamesOnTile)); if (Main.myPlayer != this.whoAmI) return; this.ApplyMusicBox(currentItem); } private WingStats GetWingStats(int wingID) => wingID <= 0 || wingID >= ArmorIDs.Wing.Sets.Stats.Length ? new WingStats() : ArmorIDs.Wing.Sets.Stats[wingID]; private void ApplyEquipFunctional(int itemSlot, Item currentItem) { if (currentItem.expertOnly && !Main.expertMode) return; if (currentItem.type == 3810 || currentItem.type == 3809 || currentItem.type == 3812 || currentItem.type == 3811) this.dd2Accessory = true; switch (currentItem.type) { case 3990: this.accRunSpeed = 6f; this.sailDash = true; this.autoJump = true; this.jumpSpeedBoost += 2.4f; this.extraFall += 15; break; case 3991: this.manaFlower = true; this.manaCost -= 0.08f; this.aggro -= 400; break; case 3992: this.kbGlove = true; this.meleeSpeed += 0.12f; this.aggro += 400; break; case 3993: this.accRunSpeed = 6f; this.rocketBoots = 2; break; case 3994: this.autoJump = true; this.frogLegJumpBoost = true; this.accFlipper = true; break; case 3995: this.autoJump = true; this.frogLegJumpBoost = true; this.accFlipper = true; this.spikedBoots += 2; break; case 3996: this.autoJump = true; this.frogLegJumpBoost = true; this.spikedBoots += 2; break; case 3999: this.fireWalk = true; this.magmaStone = true; break; case 4000: this.manaFlower = true; this.manaCost -= 0.08f; this.manaMagnet = true; break; case 4001: this.manaFlower = true; this.manaCost -= 0.08f; this.starCloak = true; this.starCloakIsManaCloak = true; break; case 4002: this.magicQuiver = true; this.arrowDamage += 0.1f; this.hasMoltenQuiver = true; break; case 4003: this.fireWalk = true; this.lavaRose = true; this.magmaStone = true; break; case 4004: this.fireWalk = true; this.lavaRose = true; break; case 4005: this.rangedCrit += 10; this.rangedDamage += 0.1f; this.aggro -= 400; break; case 4006: this.aggro -= 400; this.magicQuiver = true; this.arrowDamage += 0.1f; break; case 4007: this.releaseBeesWhenHurt = true; this.armorPenetration += 5; break; case 4038: this.fireWalk = true; break; case 4055: this.accRunSpeed = 6f; this.desertDash = true; break; case 4056: this.pickSpeed -= 0.25f; break; case 4341: this.portableStoolInfo.SetStats(26, 26, 26); break; case 4409: this.CanSeeInvisibleBlocks = true; break; case 5010: this.treasureMagnet = true; break; } if (currentItem.type == 3015) { this.aggro -= 400; this.meleeCrit += 5; this.magicCrit += 5; this.rangedCrit += 5; this.meleeDamage += 0.05f; this.magicDamage += 0.05f; this.rangedDamage += 0.05f; this.minionDamage += 0.05f; } if (currentItem.type == 3016) this.aggro += 400; if (currentItem.type == 2373) this.accFishingLine = true; if (currentItem.type == 2374) this.fishingSkill += 10; if (currentItem.type == 2375) this.accTackleBox = true; if (currentItem.type == 4881) this.accLavaFishing = true; if (currentItem.type == 3721) { this.accFishingLine = true; this.accTackleBox = true; this.fishingSkill += 10; } if (currentItem.type == 3090) { this.npcTypeNoAggro[1] = true; this.npcTypeNoAggro[16] = true; this.npcTypeNoAggro[59] = true; this.npcTypeNoAggro[71] = true; this.npcTypeNoAggro[81] = true; this.npcTypeNoAggro[138] = true; this.npcTypeNoAggro[121] = true; this.npcTypeNoAggro[122] = true; this.npcTypeNoAggro[141] = true; this.npcTypeNoAggro[147] = true; this.npcTypeNoAggro[183] = true; this.npcTypeNoAggro[184] = true; this.npcTypeNoAggro[204] = true; this.npcTypeNoAggro[225] = true; this.npcTypeNoAggro[244] = true; this.npcTypeNoAggro[302] = true; this.npcTypeNoAggro[333] = true; this.npcTypeNoAggro[335] = true; this.npcTypeNoAggro[334] = true; this.npcTypeNoAggro[336] = true; this.npcTypeNoAggro[537] = true; } if (currentItem.stringColor > 0) this.yoyoString = true; if (currentItem.type == 3366) { this.counterWeight = 556 + Main.rand.Next(6); this.yoyoGlove = true; this.yoyoString = true; } if (currentItem.type >= 3309 && currentItem.type <= 3314) this.counterWeight = 556 + currentItem.type - 3309; if (currentItem.type == 3334) this.yoyoGlove = true; if (currentItem.type == 3337) this.shinyStone = true; if (currentItem.type == 4989) { this.empressBrooch = true; this.moveSpeed += 0.1f; } if (currentItem.type == 3336) { this.SporeSac(); this.sporeSac = true; } if (currentItem.type == 4987) { this.VolatileGelatin(); this.volatileGelatin = true; } if (currentItem.type == 2423) { this.autoJump = true; this.frogLegJumpBoost = true; } if (currentItem.type == 857) this.hasJumpOption_Sandstorm = true; if (currentItem.type == 983) { this.hasJumpOption_Sandstorm = true; this.jumpBoost = true; } if (currentItem.type == 987) this.hasJumpOption_Blizzard = true; if (currentItem.type == 1163) { this.hasJumpOption_Blizzard = true; this.jumpBoost = true; } if (currentItem.type == 1724) this.hasJumpOption_Fart = true; if (currentItem.type == 1863) { this.hasJumpOption_Fart = true; this.jumpBoost = true; } if (currentItem.type == 1164) { this.hasJumpOption_Cloud = true; this.hasJumpOption_Sandstorm = true; this.hasJumpOption_Blizzard = true; this.jumpBoost = true; } if (currentItem.type == 1250) { this.jumpBoost = true; this.hasJumpOption_Cloud = true; this.noFallDmg = true; } if (currentItem.type == 1252) { this.hasJumpOption_Sandstorm = true; this.jumpBoost = true; this.noFallDmg = true; } if (currentItem.type == 1251) { this.hasJumpOption_Blizzard = true; this.jumpBoost = true; this.noFallDmg = true; } if (currentItem.type == 3250) { this.hasJumpOption_Fart = true; this.jumpBoost = true; this.noFallDmg = true; } if (currentItem.type == 3252) { this.hasJumpOption_Sail = true; this.jumpBoost = true; this.noFallDmg = true; } if (currentItem.type == 3251) { this.jumpBoost = true; this.releaseBeesWhenHurt = true; this.noFallDmg = true; } if (currentItem.type == 1249) { this.jumpBoost = true; this.releaseBeesWhenHurt = true; } if (currentItem.type == 3241) { this.jumpBoost = true; this.hasJumpOption_Sail = true; } if ((currentItem.type == 1253 || currentItem.type == 3997) && (double) this.statLife <= (double) this.statLifeMax2 * 0.5) this.AddBuff(62, 5); if (currentItem.type == 1290) this.panic = true; if ((currentItem.type == 1300 || currentItem.type == 1858 || currentItem.type == 4005) && (this.inventory[this.selectedItem].useAmmo == AmmoID.Bullet || this.inventory[this.selectedItem].useAmmo == AmmoID.CandyCorn || this.inventory[this.selectedItem].useAmmo == AmmoID.Stake || this.inventory[this.selectedItem].useAmmo == 23)) this.scope = true; if (currentItem.type == 1858) { this.rangedCrit += 10; this.rangedDamage += 0.1f; } if (currentItem.type == 1303 && this.wet) Lighting.AddLight((int) this.Center.X / 16, (int) this.Center.Y / 16, 0.9f, 0.2f, 0.6f); if (currentItem.type == 1301) { this.meleeCrit += 8; this.rangedCrit += 8; this.magicCrit += 8; this.meleeDamage += 0.1f; this.rangedDamage += 0.1f; this.magicDamage += 0.1f; this.minionDamage += 0.1f; } if (currentItem.type == 982) { this.statManaMax2 += 20; ++this.manaRegenDelayBonus; this.manaRegenBonus += 25; } if (currentItem.type == 1595) { this.statManaMax2 += 20; this.magicCuffs = true; } if (currentItem.type == 2219) this.manaMagnet = true; if (currentItem.type == 2220) { this.manaMagnet = true; this.magicDamage += 0.15f; } if (currentItem.type == 2221) { this.manaMagnet = true; this.magicCuffs = true; } if (this.whoAmI == Main.myPlayer && currentItem.type == 1923) { ++Player.tileRangeX; ++Player.tileRangeY; } if (currentItem.type == 1247) { this.starCloak = true; this.releaseBeesWhenHurt = true; this.starCloakIsBeeCloak = true; } if (currentItem.type == 1248) { this.meleeCrit += 10; this.rangedCrit += 10; this.magicCrit += 10; } if (currentItem.type == 854) this.discount = true; if (currentItem.type == 855) this.coins = true; if (currentItem.type == 3033) this.goldRing = true; if (currentItem.type == 3034) { this.goldRing = true; this.coins = true; } if (currentItem.type == 3035) { this.goldRing = true; this.coins = true; this.discount = true; } if (currentItem.type == 53) this.hasJumpOption_Cloud = true; if (currentItem.type == 3201) this.hasJumpOption_Sail = true; if (currentItem.type == 54) this.accRunSpeed = 6f; if (currentItem.type == 3068) this.cordage = true; if (currentItem.type == 1579) { this.accRunSpeed = 6f; this.coldDash = true; } if (currentItem.type == 3200) { this.accRunSpeed = 6f; this.sailDash = true; } if (currentItem.type == 128) this.rocketBoots = 1; if (currentItem.type == 156) this.noKnockback = true; if (currentItem.type == 158) this.noFallDmg = true; if (currentItem.type == 934) this.carpet = true; if (currentItem.type == 953) ++this.spikedBoots; if (currentItem.type == 975) ++this.spikedBoots; if (currentItem.type == 976) this.spikedBoots += 2; if (currentItem.type == 977) this.dashType = 1; if (currentItem.type == 3097) this.dashType = 2; if (currentItem.type == 963) this.blackBelt = true; if (currentItem.type == 984) { this.blackBelt = true; this.dashType = 1; this.spikedBoots = 2; } if (currentItem.type == 1131) this.gravControl2 = true; if (currentItem.type == 1132) this.releaseBeesWhenHurt = true; if (currentItem.type == 1578) { this.releaseBeesWhenHurt = true; this.panic = true; } if (currentItem.type == 3224) this.endurance += 0.17f; if (currentItem.type == 3223) this.brainOfConfusion = true; if (currentItem.type == 950) this.iceSkate = true; if (currentItem.type == 159) this.jumpBoost = true; if (currentItem.type == 3225) this.jumpBoost = true; if (currentItem.type == 187) this.accFlipper = true; if (currentItem.type == 211) this.meleeSpeed += 0.12f; if (currentItem.type == 223) this.manaCost -= 0.06f; if (currentItem.type == 285) this.moveSpeed += 0.05f; if (currentItem.type == 212) this.moveSpeed += 0.1f; if (currentItem.type == 267) this.killGuide = true; if (currentItem.type == 1307) this.killClothier = true; if (currentItem.type == 193) this.fireWalk = true; if (currentItem.type == 861) { this.accMerman = true; this.wolfAcc = true; if (this.hideVisibleAccessory[itemSlot]) { this.hideMerman = true; this.hideWolf = true; } } if (currentItem.type == 862) { this.starCloak = true; this.longInvince = true; this.starCloakIsStarVeil = true; } if (currentItem.type == 860) this.pStone = true; if (currentItem.type == 863) this.waterWalk2 = true; if (currentItem.type == 907) { this.waterWalk2 = true; this.fireWalk = true; } if (currentItem.type == 908 || currentItem.type == 4874 || currentItem.type == 5000) { this.waterWalk = true; this.fireWalk = true; this.lavaMax += 420; } if ((!this.mount.Active || this.mount.Type != 47) && !this.hideVisibleAccessory[itemSlot] && (currentItem.type == 4822 || currentItem.type == 4874)) this.DoBootsEffect(new Utils.TileActionAttempt(this.DoBootsEffect_PlaceFlamesOnTile)); if (currentItem.type == 906 || currentItem.type == 4038) this.lavaMax += 420; if (currentItem.type == 485) { this.wolfAcc = true; if (this.hideVisibleAccessory[itemSlot]) this.hideWolf = true; } if (currentItem.type == 486) this.rulerLine = true; if (currentItem.type == 2799) this.rulerGrid = true; if (currentItem.type == 394) { this.accFlipper = true; this.accDivingHelm = true; } if (currentItem.type == 396) { this.noFallDmg = true; this.fireWalk = true; } if (currentItem.type == 397) { this.noKnockback = true; this.fireWalk = true; } if (currentItem.type == 399) { this.jumpBoost = true; this.hasJumpOption_Cloud = true; } if (currentItem.type == 405) { this.accRunSpeed = 6f; this.rocketBoots = 2; } if (currentItem.type == 1860) { this.accFlipper = true; this.accDivingHelm = true; if (this.wet) Lighting.AddLight((int) this.Center.X / 16, (int) this.Center.Y / 16, 0.9f, 0.2f, 0.6f); } if (currentItem.type == 1861) { this.arcticDivingGear = true; this.accFlipper = true; this.accDivingHelm = true; this.iceSkate = true; if (this.wet) Lighting.AddLight((int) this.Center.X / 16, (int) this.Center.Y / 16, 0.2f, 0.8f, 0.9f); } if (currentItem.type == 2214) this.equippedAnyTileSpeedAcc = true; if (currentItem.type == 2215) this.equippedAnyTileRangeAcc = true; if (currentItem.type == 2216) this.autoPaint = true; if (currentItem.type == 2217) this.equippedAnyWallSpeedAcc = true; if (currentItem.type == 3061) { this.equippedAnyWallSpeedAcc = true; this.equippedAnyTileSpeedAcc = true; this.autoPaint = true; this.equippedAnyTileRangeAcc = true; } if (currentItem.type == 3624) this.autoActuator = true; if (currentItem.type == 897) { this.kbGlove = true; this.meleeSpeed += 0.12f; } if (currentItem.type == 1343) { this.kbGlove = true; this.meleeSpeed += 0.1f; this.meleeDamage += 0.1f; this.magmaStone = true; } if (currentItem.type == 1167) { this.minionKB += 2f; this.minionDamage += 0.15f; } if (currentItem.type == 1864) { this.minionKB += 2f; this.minionDamage += 0.15f; ++this.maxMinions; } if (currentItem.type == 1845) { this.minionDamage += 0.1f; ++this.maxMinions; } if (currentItem.type == 1321) { this.magicQuiver = true; this.arrowDamage += 0.1f; } if (currentItem.type == 1322) this.magmaStone = true; if (currentItem.type == 1323) this.lavaRose = true; if (currentItem.type == 3333) this.strongBees = true; if (currentItem.type == 938 || currentItem.type == 3997 || currentItem.type == 3998) { this.noKnockback = true; if ((double) this.statLife > (double) this.statLifeMax2 * 0.25) { this.hasPaladinShield = true; if (this.whoAmI != Main.myPlayer && this.miscCounter % 10 == 0) { int player = Main.myPlayer; if (Main.player[player].team == this.team && this.team != 0) { double num1 = (double) this.position.X - (double) Main.player[player].position.X; float num2 = this.position.Y - Main.player[player].position.Y; if (Math.Sqrt(num1 * num1 + (double) num2 * (double) num2) < 800.0) Main.player[player].AddBuff(43, 20); } } } } if (currentItem.type == 936) { this.kbGlove = true; this.meleeSpeed += 0.12f; this.meleeDamage += 0.12f; } if (currentItem.type == 898) { this.accRunSpeed = 6.75f; this.rocketBoots = 2; this.moveSpeed += 0.08f; } if (currentItem.type == 1862) { this.accRunSpeed = 6.75f; this.rocketBoots = 3; this.moveSpeed += 0.08f; this.iceSkate = true; } if (currentItem.type == 5000) { this.accRunSpeed = 6.75f; this.rocketBoots = 4; this.moveSpeed += 0.08f; this.iceSkate = true; } if (currentItem.type == 3110) { this.accMerman = true; this.wolfAcc = true; if (this.hideVisibleAccessory[itemSlot]) { this.hideMerman = true; this.hideWolf = true; } } if (currentItem.type == 1865 || currentItem.type == 3110) this.skyStoneEffects = true; if (currentItem.type == 899 && Main.dayTime) this.skyStoneEffects = true; if (currentItem.type == 900 && (!Main.dayTime || Main.eclipse)) this.skyStoneEffects = true; if (currentItem.type == 407) ++this.blockRange; if (currentItem.type == 489) this.magicDamage += 0.15f; if (currentItem.type == 490) this.meleeDamage += 0.15f; if (currentItem.type == 491) this.rangedDamage += 0.15f; if (currentItem.type == 2998) this.minionDamage += 0.15f; if (currentItem.type == 935) { this.magicDamage += 0.12f; this.meleeDamage += 0.12f; this.rangedDamage += 0.12f; this.minionDamage += 0.12f; } if (currentItem.wingSlot != (sbyte) -1) this.wingTimeMax = this.GetWingStats((int) currentItem.wingSlot).FlyTime; if (currentItem.wingSlot == (sbyte) 26) this.ignoreWater = true; if (currentItem.type == 885) this.buffImmune[30] = true; if (currentItem.type == 886) this.buffImmune[36] = true; if (currentItem.type == 887) this.buffImmune[20] = true; if (currentItem.type == 888) this.buffImmune[22] = true; if (currentItem.type == 889) this.buffImmune[32] = true; if (currentItem.type == 890) this.buffImmune[35] = true; if (currentItem.type == 891) this.buffImmune[23] = true; if (currentItem.type == 892) this.buffImmune[33] = true; if (currentItem.type == 893) this.buffImmune[31] = true; if (currentItem.type == 3781) this.buffImmune[156] = true; if (currentItem.type == 901) { this.buffImmune[33] = true; this.buffImmune[36] = true; } if (currentItem.type == 902) { this.buffImmune[30] = true; this.buffImmune[20] = true; } if (currentItem.type == 903) { this.buffImmune[32] = true; this.buffImmune[31] = true; } if (currentItem.type == 904) { this.buffImmune[35] = true; this.buffImmune[23] = true; } if (currentItem.type == 1921) { this.buffImmune[46] = true; this.buffImmune[47] = true; } if (currentItem.type == 1612) { this.buffImmune[33] = true; this.buffImmune[36] = true; this.buffImmune[30] = true; this.buffImmune[20] = true; this.buffImmune[32] = true; this.buffImmune[31] = true; this.buffImmune[35] = true; this.buffImmune[23] = true; this.buffImmune[22] = true; } if (currentItem.type == 1613) { this.buffImmune[46] = true; this.noKnockback = true; this.fireWalk = true; this.buffImmune[33] = true; this.buffImmune[36] = true; this.buffImmune[30] = true; this.buffImmune[20] = true; this.buffImmune[32] = true; this.buffImmune[31] = true; this.buffImmune[35] = true; this.buffImmune[23] = true; this.buffImmune[22] = true; } if (currentItem.type == 497) { this.accMerman = true; if (this.hideVisibleAccessory[itemSlot]) this.hideMerman = true; } if (currentItem.type == 535) this.pStone = true; if (currentItem.type == 536) this.kbGlove = true; if (currentItem.type == 532) this.starCloak = true; if (currentItem.type == 554) this.longInvince = true; if (currentItem.type == 555) { this.manaFlower = true; this.manaCost -= 0.08f; } if (Main.myPlayer != this.whoAmI) return; if (currentItem.type == 576 && Main.rand.Next(540) == 0 && Main.curMusic > 0 && Main.curMusic <= 89) { SoundEngine.PlaySound(SoundID.Item166, this.Center); int num = -1; if (Main.curMusic == 1) num = 0; if (Main.curMusic == 2) num = 1; if (Main.curMusic == 3) num = 2; if (Main.curMusic == 4) num = 4; if (Main.curMusic == 5) num = 5; if (Main.curMusic == 6) num = 3; if (Main.curMusic == 7) num = 6; if (Main.curMusic == 8) num = 7; if (Main.curMusic == 9) num = 9; if (Main.curMusic == 10) num = 8; if (Main.curMusic == 11) num = 11; if (Main.curMusic == 12) num = 10; if (Main.curMusic == 13) num = 12; if (Main.curMusic == 28) currentItem.SetDefaults(1963); else if (Main.curMusic == 29) currentItem.SetDefaults(1610); else if (Main.curMusic == 30) currentItem.SetDefaults(1963); else if (Main.curMusic == 31) currentItem.SetDefaults(1964); else if (Main.curMusic == 32) currentItem.SetDefaults(1965); else if (Main.curMusic == 33) currentItem.SetDefaults(2742); else if (Main.curMusic == 34) currentItem.SetDefaults(3370); else if (Main.curMusic == 35) currentItem.SetDefaults(3236); else if (Main.curMusic == 36) currentItem.SetDefaults(3237); else if (Main.curMusic == 37) currentItem.SetDefaults(3235); else if (Main.curMusic == 38) currentItem.SetDefaults(3044); else if (Main.curMusic == 39) currentItem.SetDefaults(3371); else if (Main.curMusic == 40) currentItem.SetDefaults(3796); else if (Main.curMusic == 41) currentItem.SetDefaults(3869); else if (Main.curMusic == 42) currentItem.SetDefaults(4079); else if (Main.curMusic == 43) currentItem.SetDefaults(4077); else if (Main.curMusic == 44) currentItem.SetDefaults(4082); else if (Main.curMusic == 46) currentItem.SetDefaults(4080); else if (Main.curMusic == 47) currentItem.SetDefaults(4081); else if (Main.curMusic == 48) currentItem.SetDefaults(4078); else if (Main.curMusic == 49) currentItem.SetDefaults(4237); else if (Main.curMusic == 51) currentItem.SetDefaults(4356); else if (Main.curMusic == 52) currentItem.SetDefaults(4357); else if (Main.curMusic == 53) currentItem.SetDefaults(4358); else if (Main.curMusic == 54) currentItem.SetDefaults(4421); else if (Main.curMusic == 55) currentItem.SetDefaults(4606); else if (Main.curMusic == 56) currentItem.SetDefaults(4979); else if (Main.curMusic == 57) currentItem.SetDefaults(4985); else if (Main.curMusic == 58) currentItem.SetDefaults(4990); else if (Main.curMusic == 59) currentItem.SetDefaults(4991); else if (Main.curMusic == 60) currentItem.SetDefaults(4992); else if (Main.curMusic == 61) currentItem.SetDefaults(5006); else if (Main.curMusic == 62) currentItem.SetDefaults(5014); else if (Main.curMusic == 63) currentItem.SetDefaults(5015); else if (Main.curMusic == 64) currentItem.SetDefaults(5016); else if (Main.curMusic == 65) currentItem.SetDefaults(5017); else if (Main.curMusic == 66) currentItem.SetDefaults(5018); else if (Main.curMusic == 67) currentItem.SetDefaults(5019); else if (Main.curMusic == 68) currentItem.SetDefaults(5020); else if (Main.curMusic == 69) currentItem.SetDefaults(5021); else if (Main.curMusic == 70) currentItem.SetDefaults(5022); else if (Main.curMusic == 71) currentItem.SetDefaults(5023); else if (Main.curMusic == 72) currentItem.SetDefaults(5024); else if (Main.curMusic == 73) currentItem.SetDefaults(5025); else if (Main.curMusic == 74) currentItem.SetDefaults(5026); else if (Main.curMusic == 75) currentItem.SetDefaults(5027); else if (Main.curMusic == 76) currentItem.SetDefaults(5028); else if (Main.curMusic == 77) currentItem.SetDefaults(5029); else if (Main.curMusic == 78) currentItem.SetDefaults(5030); else if (Main.curMusic == 79) currentItem.SetDefaults(5031); else if (Main.curMusic == 80) currentItem.SetDefaults(5032); else if (Main.curMusic == 81) currentItem.SetDefaults(5033); else if (Main.curMusic == 82) currentItem.SetDefaults(5034); else if (Main.curMusic == 83) currentItem.SetDefaults(5035); else if (Main.curMusic == 84) currentItem.SetDefaults(5036); else if (Main.curMusic == 85) currentItem.SetDefaults(5037); else if (Main.curMusic == 86) currentItem.SetDefaults(5038); else if (Main.curMusic == 87) currentItem.SetDefaults(5039); else if (Main.curMusic == 88) currentItem.SetDefaults(5040); else if (Main.curMusic == 89) currentItem.SetDefaults(5044); else if (Main.curMusic > 13) currentItem.SetDefaults(1596 + Main.curMusic - 14); else if (num != -1) currentItem.SetDefaults(num + 562); } this.ApplyMusicBox(currentItem); } private void ApplyMusicBox(Item currentItem) { if (currentItem.type >= 562 && currentItem.type <= 574) Main.musicBox2 = currentItem.type - 562; if (currentItem.type >= 1596 && currentItem.type <= 1609) Main.musicBox2 = currentItem.type - 1596 + 13; if (currentItem.type == 1610) Main.musicBox2 = 27; if (currentItem.type == 1963) Main.musicBox2 = 28; if (currentItem.type == 1964) Main.musicBox2 = 29; if (currentItem.type == 1965) Main.musicBox2 = 30; if (currentItem.type == 2742) Main.musicBox2 = 31; if (currentItem.type == 3044) Main.musicBox2 = 32; if (currentItem.type == 3235) Main.musicBox2 = 33; if (currentItem.type == 3236) Main.musicBox2 = 34; if (currentItem.type == 3237) Main.musicBox2 = 35; if (currentItem.type == 3370) Main.musicBox2 = 36; if (currentItem.type == 3371) Main.musicBox2 = 37; if (currentItem.type == 3796) Main.musicBox2 = 38; if (currentItem.type == 3869) Main.musicBox2 = 39; if (currentItem.type == 4082) Main.musicBox2 = 40; if (currentItem.type == 4078) Main.musicBox2 = 41; if (currentItem.type == 4079) Main.musicBox2 = 42; if (currentItem.type == 4077) Main.musicBox2 = 43; if (currentItem.type == 4080) Main.musicBox2 = 44; if (currentItem.type == 4081) Main.musicBox2 = 45; if (currentItem.type == 4237) Main.musicBox2 = 46; if (currentItem.type == 4356) Main.musicBox2 = 47; if (currentItem.type == 4357) Main.musicBox2 = 48; if (currentItem.type == 4358) Main.musicBox2 = 49; if (currentItem.type == 4421) Main.musicBox2 = 50; if (currentItem.type == 4606) Main.musicBox2 = 51; if (currentItem.type == 4979) Main.musicBox2 = 52; if (currentItem.type == 4985) Main.musicBox2 = 53; if (currentItem.type == 4990) Main.musicBox2 = 54; if (currentItem.type == 4991) Main.musicBox2 = 55; if (currentItem.type == 4992) Main.musicBox2 = 56; if (currentItem.type == 5006) Main.musicBox2 = 57; if (currentItem.type == 5014) Main.musicBox2 = 58; if (currentItem.type == 5015) Main.musicBox2 = 59; if (currentItem.type == 5016) Main.musicBox2 = 60; if (currentItem.type == 5017) Main.musicBox2 = 61; if (currentItem.type == 5018) Main.musicBox2 = 62; if (currentItem.type == 5019) Main.musicBox2 = 63; if (currentItem.type == 5020) Main.musicBox2 = 64; if (currentItem.type == 5021) Main.musicBox2 = 65; if (currentItem.type == 5022) Main.musicBox2 = 66; if (currentItem.type == 5023) Main.musicBox2 = 67; if (currentItem.type == 5024) Main.musicBox2 = 68; if (currentItem.type == 5025) Main.musicBox2 = 69; if (currentItem.type == 5026) Main.musicBox2 = 70; if (currentItem.type == 5027) Main.musicBox2 = 71; if (currentItem.type == 5028) Main.musicBox2 = 72; if (currentItem.type == 5029) Main.musicBox2 = 73; if (currentItem.type == 5030) Main.musicBox2 = 74; if (currentItem.type == 5031) Main.musicBox2 = 75; if (currentItem.type == 5032) Main.musicBox2 = 76; if (currentItem.type == 5033) Main.musicBox2 = 77; if (currentItem.type == 5034) Main.musicBox2 = 78; if (currentItem.type == 5035) Main.musicBox2 = 79; if (currentItem.type == 5036) Main.musicBox2 = 80; if (currentItem.type == 5037) Main.musicBox2 = 81; if (currentItem.type == 5038) Main.musicBox2 = 82; if (currentItem.type == 5039) Main.musicBox2 = 83; if (currentItem.type == 5040) Main.musicBox2 = 84; if (currentItem.type != 5044) return; Main.musicBox2 = 85; } public void UpdateArmorSets(int i) { this.setBonus = ""; if (this.body == 67 && this.legs == 56 && this.head >= 103 && this.head <= 105) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Shroomite"); this.shroomiteStealth = true; } if (this.head == 52 && this.body == 32 && this.legs == 31 || this.head == 53 && this.body == 33 && this.legs == 32 || this.head == 54 && this.body == 34 && this.legs == 33 || this.head == 55 && this.body == 35 && this.legs == 34 || this.head == 70 && this.body == 46 && this.legs == 42 || this.head == 71 && this.body == 47 && this.legs == 43 || this.head == 166 && this.body == 173 && this.legs == 108 || this.head == 167 && this.body == 174 && this.legs == 109) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Wood"); ++this.statDefense; } if (this.head == 1 && this.body == 1 && this.legs == 1 || (this.head == 72 || this.head == 2) && this.body == 2 && this.legs == 2 || this.head == 47 && this.body == 28 && this.legs == 27) { this.setBonus = Language.GetTextValue("ArmorSetBonus.MetalTier1"); this.statDefense += 2; } if (this.head == 3 && this.body == 3 && this.legs == 3 || (this.head == 73 || this.head == 4) && this.body == 4 && this.legs == 4 || this.head == 48 && this.body == 29 && this.legs == 28 || this.head == 49 && this.body == 30 && this.legs == 29) { this.setBonus = Language.GetTextValue("ArmorSetBonus.MetalTier2"); this.statDefense += 3; } if (this.head == 50 && this.body == 31 && this.legs == 30) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Platinum"); this.statDefense += 4; } if (this.head == 112 && this.body == 75 && this.legs == 64) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Pumpkin"); this.meleeDamage += 0.1f; this.magicDamage += 0.1f; this.rangedDamage += 0.1f; this.minionDamage += 0.1f; } if (this.head == 22 && this.body == 14 && this.legs == 14) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Ninja"); this.moveSpeed += 0.2f; } if (this.head == 188 && this.body == 189 && this.legs == 129) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Fossil"); this.ammoCost80 = true; } if ((this.head == 75 || this.head == 7) && this.body == 7 && this.legs == 7) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Bone"); this.rangedCrit += 15; } if (this.head == 157 && this.body == 105 && this.legs == 98) { int num1 = 0; this.setBonus = Language.GetTextValue("ArmorSetBonus.BeetleDamage"); this.beetleOffense = true; this.beetleCounter -= 3f; this.beetleCounter -= (float) (this.beetleCountdown / 10); ++this.beetleCountdown; if ((double) this.beetleCounter < 0.0) this.beetleCounter = 0.0f; int num2 = 400; int num3 = 1200; int num4 = 4600; if ((double) this.beetleCounter > (double) (num2 + num3 + num4 + num3)) this.beetleCounter = (float) (num2 + num3 + num4 + num3); if ((double) this.beetleCounter > (double) (num2 + num3 + num4)) { this.AddBuff(100, 5, false); num1 = 3; } else if ((double) this.beetleCounter > (double) (num2 + num3)) { this.AddBuff(99, 5, false); num1 = 2; } else if ((double) this.beetleCounter > (double) num2) { this.AddBuff(98, 5, false); num1 = 1; } if (num1 < this.beetleOrbs) this.beetleCountdown = 0; else if (num1 > this.beetleOrbs) this.beetleCounter += 200f; if (num1 != this.beetleOrbs && this.beetleOrbs > 0) { for (int b = 0; b < 22; ++b) { if (this.buffType[b] >= 98 && this.buffType[b] <= 100 && this.buffType[b] != 97 + num1) this.DelBuff(b); } } } else if (this.head == 157 && this.body == 106 && this.legs == 98) { this.setBonus = Language.GetTextValue("ArmorSetBonus.BeetleDefense"); this.beetleDefense = true; ++this.beetleCounter; int num = 180; if ((double) this.beetleCounter >= (double) num) { if (this.beetleOrbs > 0 && this.beetleOrbs < 3) { for (int b = 0; b < 22; ++b) { if (this.buffType[b] >= 95 && this.buffType[b] <= 96) this.DelBuff(b); } } if (this.beetleOrbs < 3) { this.AddBuff(95 + this.beetleOrbs, 5, false); this.beetleCounter = 0.0f; } else this.beetleCounter = (float) num; } } if (!this.beetleDefense && !this.beetleOffense) { this.beetleCounter = 0.0f; } else { ++this.beetleFrameCounter; if (this.beetleFrameCounter >= 1) { this.beetleFrameCounter = 0; ++this.beetleFrame; if (this.beetleFrame > 2) this.beetleFrame = 0; } for (int beetleOrbs = this.beetleOrbs; beetleOrbs < 3; ++beetleOrbs) { this.beetlePos[beetleOrbs].X = 0.0f; this.beetlePos[beetleOrbs].Y = 0.0f; } for (int index = 0; index < this.beetleOrbs; ++index) { this.beetlePos[index] += this.beetleVel[index]; this.beetleVel[index].X += (float) Main.rand.Next(-100, 101) * 0.005f; this.beetleVel[index].Y += (float) Main.rand.Next(-100, 101) * 0.005f; float x1 = this.beetlePos[index].X; float y1 = this.beetlePos[index].Y; float num5 = (float) Math.Sqrt((double) x1 * (double) x1 + (double) y1 * (double) y1); if ((double) num5 > 100.0) { float num6 = 20f / num5; float num7 = x1 * -num6; float num8 = y1 * -num6; int num9 = 10; this.beetleVel[index].X = (this.beetleVel[index].X * (float) (num9 - 1) + num7) / (float) num9; this.beetleVel[index].Y = (this.beetleVel[index].Y * (float) (num9 - 1) + num8) / (float) num9; } else if ((double) num5 > 30.0) { float num10 = 10f / num5; float num11 = x1 * -num10; float num12 = y1 * -num10; int num13 = 20; this.beetleVel[index].X = (this.beetleVel[index].X * (float) (num13 - 1) + num11) / (float) num13; this.beetleVel[index].Y = (this.beetleVel[index].Y * (float) (num13 - 1) + num12) / (float) num13; } float x2 = this.beetleVel[index].X; float y2 = this.beetleVel[index].Y; if (Math.Sqrt((double) x2 * (double) x2 + (double) y2 * (double) y2) > 2.0) this.beetleVel[index] *= 0.9f; this.beetlePos[index] -= this.velocity * 0.25f; } } if (this.head == 14 && (this.body >= 58 && this.body <= 63 || this.body == 167 || this.body == 213)) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Wizard"); this.magicCrit += 10; } if (this.head == 159 && (this.body >= 58 && this.body <= 63 || this.body == 167 || this.body == 213)) { this.setBonus = Language.GetTextValue("ArmorSetBonus.MagicHat"); this.statManaMax2 += 60; } if ((this.head == 5 || this.head == 74) && (this.body == 5 || this.body == 48) && (this.legs == 5 || this.legs == 44)) { this.setBonus = Language.GetTextValue("ArmorSetBonus.ShadowScale"); this.moveSpeed += 0.15f; } if (this.head == 57 && this.body == 37 && this.legs == 35) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Crimson"); this.crimsonRegen = true; } if (this.head == 101 && this.body == 66 && this.legs == 55) { this.setBonus = Language.GetTextValue("ArmorSetBonus.SpectreHealing"); this.ghostHeal = true; } if (this.head == 156 && this.body == 66 && this.legs == 55) { this.setBonus = Language.GetTextValue("ArmorSetBonus.SpectreDamage"); this.ghostHurt = true; } if (this.head == 6 && this.body == 6 && this.legs == 6) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Meteor"); this.spaceGun = true; } if (this.head == 46 && this.body == 27 && this.legs == 26) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Frost"); this.frostBurn = true; } if ((this.head == 76 || this.head == 8) && (this.body == 49 || this.body == 8) && (this.legs == 45 || this.legs == 8)) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Jungle"); this.manaCost -= 0.16f; } if (this.head == 9 && this.body == 9 && this.legs == 9) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Molten"); this.meleeDamage += 0.17f; } if (this.head == 11 && this.body == 20 && this.legs == 19) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Mining"); this.pickSpeed -= 0.3f; } if (this.head == 216 && this.body == 20 && this.legs == 19) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Mining"); this.pickSpeed -= 0.3f; } if (this.head == 78 && this.body == 51 && this.legs == 47) { this.setBonus = Language.GetTextValue("ArmorSetBonus.ChlorophyteMelee"); this.AddBuff(60, 18000); this.endurance += 0.05f; } else if ((this.head == 80 || this.head == 79) && this.body == 51 && this.legs == 47) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Chlorophyte"); this.AddBuff(60, 18000); } else if (this.crystalLeaf) { for (int b = 0; b < 22; ++b) { if (this.buffType[b] == 60) this.DelBuff(b); } } if (this.head == 99 && this.body == 65 && this.legs == 54) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Turtle"); this.endurance += 0.15f; this.thorns = 1f; this.turtleThorns = true; } if (this.body == 17 && this.legs == 16) { if (this.head == 29) { this.setBonus = Language.GetTextValue("ArmorSetBonus.CobaltCaster"); this.manaCost -= 0.14f; } else if (this.head == 30) { this.setBonus = Language.GetTextValue("ArmorSetBonus.CobaltMelee"); this.meleeSpeed += 0.15f; } else if (this.head == 31) { this.setBonus = Language.GetTextValue("ArmorSetBonus.CobaltRanged"); this.ammoCost80 = true; } } if (this.body == 18 && this.legs == 17) { if (this.head == 32) { this.setBonus = Language.GetTextValue("ArmorSetBonus.MythrilCaster"); this.manaCost -= 0.17f; } else if (this.head == 33) { this.setBonus = Language.GetTextValue("ArmorSetBonus.MythrilMelee"); this.meleeCrit += 5; } else if (this.head == 34) { this.setBonus = Language.GetTextValue("ArmorSetBonus.MythrilRanged"); this.ammoCost80 = true; } } if (this.body == 19 && this.legs == 18) { if (this.head == 35) { this.setBonus = Language.GetTextValue("ArmorSetBonus.AdamantiteCaster"); this.manaCost -= 0.19f; } else if (this.head == 36) { this.setBonus = Language.GetTextValue("ArmorSetBonus.AdamantiteMelee"); this.meleeSpeed += 0.18f; this.moveSpeed += 0.18f; } else if (this.head == 37) { this.setBonus = Language.GetTextValue("ArmorSetBonus.AdamantiteRanged"); this.ammoCost75 = true; } } if (this.body == 54 && this.legs == 49 && (this.head == 83 || this.head == 84 || this.head == 85)) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Palladium"); this.onHitRegen = true; } if (this.body == 55 && this.legs == 50 && (this.head == 86 || this.head == 87 || this.head == 88)) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Orichalcum"); this.onHitPetal = true; } if (this.body == 56 && this.legs == 51) { bool flag = false; if (this.head == 91) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Titanium"); this.manaCost -= 0.19f; flag = true; } else if (this.head == 89) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Titanium"); this.meleeSpeed += 0.18f; this.moveSpeed += 0.18f; flag = true; } else if (this.head == 90) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Titanium"); this.ammoCost75 = true; flag = true; } if (flag) this.onHitTitaniumStorm = true; } if ((this.body == 24 || this.body == 229) && (this.legs == 23 || this.legs == 212) && (this.head == 42 || this.head == 41 || this.head == 43 || this.head == 254 || this.head == 257 || this.head == 256 || this.head == (int) byte.MaxValue || this.head == 258)) { if (this.head == 254 || this.head == 258) { this.setBonus = Language.GetTextValue("ArmorSetBonus.HallowedSummoner"); this.maxMinions += 2; } else this.setBonus = Language.GetTextValue("ArmorSetBonus.Hallowed"); this.onHitDodge = true; } if (this.head == 261 && this.body == 230 && this.legs == 213) { this.setBonus = Language.GetTextValue("ArmorSetBonus.CrystalNinja"); this.moveSpeed += 0.15f; this.rangedDamage += 0.1f; this.meleeDamage += 0.1f; this.magicDamage += 0.1f; this.minionDamage += 0.1f; this.rangedCrit += 10; this.meleeCrit += 10; this.magicCrit += 10; } if (this.head == 82 && this.body == 53 && this.legs == 48) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Tiki"); ++this.maxMinions; } if (this.head == 134 && this.body == 95 && this.legs == 79) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Spooky"); this.minionDamage += 0.25f; } if (this.head == 160 && this.body == 168 && this.legs == 103) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Bee"); this.minionDamage += 0.1f; if (this.itemAnimation > 0 && this.inventory[this.selectedItem].type == 1121) AchievementsHelper.HandleSpecialEvent(this, 3); } if (this.head == 162 && this.body == 170 && this.legs == 105) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Spider"); this.minionDamage += 0.12f; } if (this.head == 171 && this.body == 177 && this.legs == 112) { this.endurance += 0.12f; this.setSolar = true; this.setBonus = Language.GetTextValue("ArmorSetBonus.Solar"); ++this.solarCounter; int num = 180; if (this.solarCounter >= num) { if (this.solarShields > 0 && this.solarShields < 3) { for (int b = 0; b < 22; ++b) { if (this.buffType[b] >= 170 && this.buffType[b] <= 171) this.DelBuff(b); } } if (this.solarShields < 3) { this.AddBuff(170 + this.solarShields, 5, false); for (int index = 0; index < 16; ++index) { Dust dust = Main.dust[Dust.NewDust(this.position, this.width, this.height, 6, Alpha: 100)]; dust.noGravity = true; dust.scale = 1.7f; dust.fadeIn = 0.5f; dust.velocity *= 5f; dust.shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } this.solarCounter = 0; } else this.solarCounter = num; } for (int solarShields = this.solarShields; solarShields < 3; ++solarShields) this.solarShieldPos[solarShields] = Vector2.Zero; for (int index = 0; index < this.solarShields; ++index) { this.solarShieldPos[index] += this.solarShieldVel[index]; Vector2 vector2 = ((float) ((double) this.miscCounter / 100.0 * 6.28318548202515 + (double) index * (6.28318548202515 / (double) this.solarShields))).ToRotationVector2() * 6f; vector2.X = (float) (this.direction * 20); this.solarShieldVel[index] = (vector2 - this.solarShieldPos[index]) * 0.2f; } if (this.dashDelay >= 0) { this.solarDashing = false; this.solarDashConsumedFlare = false; } if (this.solarShields > 0 | (this.solarDashing && this.dashDelay < 0)) this.dashType = 3; } else this.solarCounter = 0; if (this.head == 169 && this.body == 175 && this.legs == 110) { this.setVortex = true; this.setBonus = Language.GetTextValue("ArmorSetBonus.Vortex", (object) Language.GetTextValue(Main.ReversedUpDownArmorSetBonuses ? "Key.UP" : "Key.DOWN")); } else this.vortexStealthActive = false; if (this.head == 170 && this.body == 176 && this.legs == 111) { if (this.nebulaCD > 0) --this.nebulaCD; this.setNebula = true; this.setBonus = Language.GetTextValue("ArmorSetBonus.Nebula"); } if (this.head == 189 && this.body == 190 && this.legs == 130) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Stardust", (object) Language.GetTextValue(Main.ReversedUpDownArmorSetBonuses ? "Key.UP" : "Key.DOWN")); this.setStardust = true; if (this.whoAmI == Main.myPlayer) { if (this.FindBuffIndex(187) == -1) this.AddBuff(187, 3600); if (this.ownedProjectileCounts[623] < 1) { int num = 10; int Damage = 30; int index = Projectile.NewProjectile(this.Center.X, this.Center.Y, 0.0f, -1f, 623, Damage, (float) num, Main.myPlayer); Main.projectile[index].originalDamage = Damage; } } } else if (this.FindBuffIndex(187) != -1) this.DelBuff(this.FindBuffIndex(187)); if (this.head == 200 && this.body == 198 && this.legs == 142) { this.setBonus = Language.GetTextValue("ArmorSetBonus.Forbidden", (object) Language.GetTextValue(Main.ReversedUpDownArmorSetBonuses ? "Key.UP" : "Key.DOWN")); this.setForbidden = true; this.UpdateForbiddenSetLock(); Lighting.AddLight(this.Center, 0.8f, 0.7f, 0.2f); } if (this.head == 204 && this.body == 201 && this.legs == 145) { this.setBonus = Language.GetTextValue("ArmorSetBonus.SquireTier2"); this.setSquireT2 = true; ++this.maxTurrets; } if (this.head == 203 && this.body == 200 && this.legs == 144) { this.setBonus = Language.GetTextValue("ArmorSetBonus.ApprenticeTier2"); this.setApprenticeT2 = true; ++this.maxTurrets; } if (this.head == 205 && this.body == 202 && (this.legs == 147 || this.legs == 146)) { this.setBonus = Language.GetTextValue("ArmorSetBonus.HuntressTier2"); this.setHuntressT2 = true; ++this.maxTurrets; } if (this.head == 206 && this.body == 203 && this.legs == 148) { this.setBonus = Language.GetTextValue("ArmorSetBonus.MonkTier2"); this.setMonkT2 = true; ++this.maxTurrets; } if (this.head == 210 && this.body == 204 && this.legs == 152) { this.setBonus = Language.GetTextValue("ArmorSetBonus.SquireTier3"); this.setSquireT3 = true; this.setSquireT2 = true; ++this.maxTurrets; } if (this.head == 211 && this.body == 205 && this.legs == 153) { this.setBonus = Language.GetTextValue("ArmorSetBonus.ApprenticeTier3"); this.setApprenticeT3 = true; this.setApprenticeT2 = true; ++this.maxTurrets; } if (this.head == 212 && this.body == 206 && (this.legs == 154 || this.legs == 155)) { this.setBonus = Language.GetTextValue("ArmorSetBonus.HuntressTier3"); this.setHuntressT3 = true; this.setHuntressT2 = true; ++this.maxTurrets; } if (this.head == 213 && this.body == 207 && this.legs == 156) { this.setBonus = Language.GetTextValue("ArmorSetBonus.MonkTier3"); this.setMonkT3 = true; this.setMonkT2 = true; ++this.maxTurrets; } this.ApplyArmorSoundAndDustChanges(); } public void UpdateSocialShadow() { for (int index = 2; index > 0; --index) this.shadowDirection[index] = this.shadowDirection[index - 1]; this.shadowDirection[0] = this.direction; ++this.shadowCount; if (this.shadowCount == 1) { this.shadowPos[2] = this.shadowPos[1]; this.shadowRotation[2] = this.shadowRotation[1]; this.shadowOrigin[2] = this.shadowOrigin[1]; } else if (this.shadowCount == 2) { this.shadowPos[1] = this.shadowPos[0]; this.shadowRotation[1] = this.shadowRotation[0]; this.shadowOrigin[1] = this.shadowOrigin[0]; } else { if (this.shadowCount < 3) return; this.shadowCount = 0; this.shadowPos[0] = this.position; this.shadowPos[0].Y += this.gfxOffY; this.shadowRotation[0] = this.fullRotation; this.shadowOrigin[0] = this.fullRotationOrigin; } } public void UpdateTeleportVisuals() { if ((double) this.teleportTime <= 0.0) return; if (this.teleportStyle == 0) { if ((double) Main.rand.Next(100) <= 100.0 * (double) this.teleportTime * 2.0) { int index = Dust.NewDust(new Vector2((float) this.getRect().X, (float) this.getRect().Y), this.getRect().Width, this.getRect().Height, 159); Main.dust[index].scale = this.teleportTime * 1.5f; Main.dust[index].noGravity = true; Main.dust[index].velocity *= 1.1f; } } else if (this.teleportStyle == 1) { if ((double) Main.rand.Next(100) <= 100.0 * (double) this.teleportTime) { int index = Dust.NewDust(new Vector2((float) this.getRect().X, (float) this.getRect().Y), this.getRect().Width, this.getRect().Height, 164); Main.dust[index].scale = this.teleportTime * 1.5f; Main.dust[index].noGravity = true; Main.dust[index].velocity *= 1.1f; } } else if (this.teleportStyle == 2) this.teleportTime = 0.005f; else if (this.teleportStyle == 3) this.teleportTime = 0.005f; else if (this.teleportStyle == 4) { this.teleportTime -= 0.02f; if ((double) Main.rand.Next(100) <= 100.0 * (double) this.teleportTime) { Dust dust = Main.dust[Dust.NewDust(this.position, this.width, this.height, 263)]; dust.color = PortalHelper.GetPortalColor(this.lastPortalColorIndex); dust.noLight = true; dust.noGravity = true; dust.scale = 1.2f; dust.fadeIn = 0.4f; } } else if (this.teleportStyle == 9) { Microsoft.Xna.Framework.Rectangle hitbox = this.Hitbox; hitbox.Inflate(5, 5); if ((double) Main.rand.Next(100) <= 100.0 * (double) this.teleportTime) TeleportPylonsSystem.SpawnInWorldDust(this.lastTeleportPylonStyleUsed, hitbox); } this.teleportTime -= 0.005f; } private void UpdateGraveyard(bool now = false) { float lerpValue = Utils.GetLerpValue((float) SceneMetrics.GraveyardTileMin, (float) SceneMetrics.GraveyardTileMax, (float) Main.SceneMetrics.GraveyardTileCount, true); if (now) this.graveImmediateTime = 30; if (this.graveImmediateTime > 0) { --this.graveImmediateTime; Main.GraveyardVisualIntensity = lerpValue; } else if ((double) Main.GraveyardVisualIntensity < (double) lerpValue) { Main.GraveyardVisualIntensity += 0.02f; if ((double) Main.GraveyardVisualIntensity <= (double) lerpValue) return; Main.GraveyardVisualIntensity = lerpValue; } else { if ((double) Main.GraveyardVisualIntensity <= (double) lerpValue) return; Main.GraveyardVisualIntensity -= 0.01f; if ((double) Main.GraveyardVisualIntensity >= (double) lerpValue) return; Main.GraveyardVisualIntensity = lerpValue; } } public int GetPrimaryBiome() { if (this.ZoneDungeon) return 8; if (this.ZoneCorrupt) return 9; if (this.ZoneCrimson) return 10; if (this.ZoneGlowshroom) return 7; if (this.ZoneHallow) return 6; if (this.ZoneJungle) return 4; if (this.ZoneSnow) return 2; if (this.ZoneBeach) return 5; if (this.ZoneDesert) return 3; return (double) this.position.Y > Main.worldSurface * 16.0 ? 1 : 0; } public void UpdateBiomes() { Point tileCoordinates1 = this.Center.ToTileCoordinates(); this.ZoneDungeon = false; if (Main.SceneMetrics.DungeonTileCount >= 250 && (double) this.Center.Y > Main.worldSurface * 16.0) { int index1 = (int) this.Center.X / 16; int index2 = (int) this.Center.Y / 16; if (Main.tile[index1, index2] != null && Main.wallDungeon[(int) Main.tile[index1, index2].wall]) this.ZoneDungeon = true; } Tile tileSafely = Framing.GetTileSafely(this.Center); if (tileSafely != null) this.behindBackWall = tileSafely.wall > (ushort) 0; if (this.behindBackWall && this.ZoneDesert && (double) this.Center.Y > Main.worldSurface) { if (WallID.Sets.Conversion.Sandstone[(int) tileSafely.wall] || WallID.Sets.Conversion.HardenedSand[(int) tileSafely.wall]) this.ZoneUndergroundDesert = true; } else this.ZoneUndergroundDesert = false; this.ZoneGranite = this.behindBackWall && (tileSafely.wall == (ushort) 184 || tileSafely.wall == (ushort) 180); this.ZoneMarble = this.behindBackWall && (tileSafely.wall == (ushort) 183 || tileSafely.wall == (ushort) 178); this.ZoneHive = this.behindBackWall && (tileSafely.wall == (ushort) 108 || tileSafely.wall == (ushort) 86); this.ZoneGemCave = this.behindBackWall && tileSafely.wall >= (ushort) 48 && tileSafely.wall <= (ushort) 53; this.ZoneCorrupt = Main.SceneMetrics.EnoughTilesForCorruption; this.ZoneCrimson = Main.SceneMetrics.EnoughTilesForCrimson; this.ZoneHallow = Main.SceneMetrics.EnoughTilesForHallow; this.ZoneJungle = Main.SceneMetrics.EnoughTilesForJungle && (double) this.position.Y / 16.0 < (double) Main.UnderworldLayer; this.ZoneSnow = Main.SceneMetrics.EnoughTilesForSnow; this.ZoneDesert = Main.SceneMetrics.EnoughTilesForDesert; this.ZoneGlowshroom = Main.SceneMetrics.EnoughTilesForGlowingMushroom; this.ZoneMeteor = Main.SceneMetrics.EnoughTilesForMeteor; this.ZoneWaterCandle = Main.SceneMetrics.WaterCandleCount > 0; this.ZonePeaceCandle = Main.SceneMetrics.PeaceCandleCount > 0; this.ZoneGraveyard = Main.SceneMetrics.EnoughTilesForGraveyard; this.UpdateGraveyard(); if (this.HasGardenGnomeNearby != Main.SceneMetrics.HasGardenGnome) { this.luckNeedsSync = true; this.HasGardenGnomeNearby = Main.SceneMetrics.HasGardenGnome; } this.ZoneUnderworldHeight = tileCoordinates1.Y > Main.UnderworldLayer; this.ZoneRockLayerHeight = tileCoordinates1.Y <= Main.UnderworldLayer && (double) tileCoordinates1.Y > Main.rockLayer; this.ZoneDirtLayerHeight = (double) tileCoordinates1.Y <= Main.rockLayer && (double) tileCoordinates1.Y > Main.worldSurface; this.ZoneOverworldHeight = (double) tileCoordinates1.Y <= Main.worldSurface && (double) tileCoordinates1.Y > Main.worldSurface * 0.349999994039536; this.ZoneSkyHeight = (double) tileCoordinates1.Y <= Main.worldSurface * 0.349999994039536; this.ZoneBeach = WorldGen.oceanDepths(tileCoordinates1.X, tileCoordinates1.Y); this.ZoneRain = Main.raining && (double) tileCoordinates1.Y <= Main.worldSurface; this.ZoneSandstorm = (double) tileCoordinates1.Y <= Main.worldSurface && this.ZoneDesert && !this.ZoneBeach && Sandstorm.Happening; this.ZoneTowerSolar = this.ZoneTowerVortex = this.ZoneTowerNebula = this.ZoneTowerStardust = false; this.ZoneOldOneArmy = false; Vector2 vector2_1 = Vector2.Zero; Vector2 vector2_2 = Vector2.Zero; Vector2 vector2_3 = Vector2.Zero; Vector2 vector2_4 = Vector2.Zero; Vector2 zero = Vector2.Zero; for (int index = 0; index < 200; ++index) { if (Main.npc[index].active) { if (Main.npc[index].type == 493) { if ((double) this.Distance(Main.npc[index].Center) <= 4000.0) { this.ZoneTowerStardust = true; vector2_4 = Main.npc[index].Center; } } else if (Main.npc[index].type == 507) { if ((double) this.Distance(Main.npc[index].Center) <= 4000.0) { this.ZoneTowerNebula = true; vector2_3 = Main.npc[index].Center; } } else if (Main.npc[index].type == 422) { if ((double) this.Distance(Main.npc[index].Center) <= 4000.0) { this.ZoneTowerVortex = true; vector2_2 = Main.npc[index].Center; } } else if (Main.npc[index].type == 517) { if ((double) this.Distance(Main.npc[index].Center) <= 4000.0) { this.ZoneTowerSolar = true; vector2_1 = Main.npc[index].Center; } } else if (Main.npc[index].type == 549 && (double) this.Distance(Main.npc[index].Center) <= 4000.0) { this.ZoneOldOneArmy = true; vector2_1 = Main.npc[index].Center; } } } bool flag1 = this.ZoneRain && this.ZoneSnow; bool flag2 = tileCoordinates1.Y > Main.maxTilesY - 320; bool flag3 = this.ZoneOverworldHeight && (tileCoordinates1.X < 380 || tileCoordinates1.X > Main.maxTilesX - 380); this.ManageSpecialBiomeVisuals("Stardust", this.ZoneTowerStardust, vector2_4 - new Vector2(0.0f, 10f)); this.ManageSpecialBiomeVisuals("Nebula", this.ZoneTowerNebula, vector2_3 - new Vector2(0.0f, 10f)); this.ManageSpecialBiomeVisuals("Vortex", this.ZoneTowerVortex, vector2_2 - new Vector2(0.0f, 10f)); this.ManageSpecialBiomeVisuals("Solar", this.ZoneTowerSolar, vector2_1 - new Vector2(0.0f, 10f)); this.ManageSpecialBiomeVisuals("MoonLord", NPC.AnyNPCs(398)); this.ManageSpecialBiomeVisuals("BloodMoon", Main.bloodMoon || Main.SceneMetrics.BloodMoonMonolith); this.ManageSpecialBiomeVisuals("Blizzard", Main.UseStormEffects & flag1); this.ManageSpecialBiomeVisuals("HeatDistortion", Main.UseHeatDistortion && (flag2 || (double) tileCoordinates1.Y < Main.worldSurface && this.ZoneDesert && !flag3 && !Main.raining && !Filters.Scene["Sandstorm"].IsActive())); if ((double) Main.GraveyardVisualIntensity > 0.0) { if (!Filters.Scene["Graveyard"].IsActive()) { Filters.Scene.Activate("Graveyard", new Vector2()); } else { Filters.Scene["Graveyard"].GetShader().UseTargetPosition(this.Center); float progress = MathHelper.Lerp(0.0f, 0.75f, Main.GraveyardVisualIntensity); Filters.Scene["Graveyard"].GetShader().UseProgress(progress); Filters.Scene["Graveyard"].GetShader().UseIntensity(1.2f); } } else if (Filters.Scene["Graveyard"].IsActive()) Filters.Scene.Deactivate("Graveyard"); if (!Filters.Scene["WaterDistortion"].IsActive() && Main.WaveQuality > 0) Filters.Scene.Activate("WaterDistortion", new Vector2()); else if (Filters.Scene["WaterDistortion"].IsActive() && Main.WaveQuality == 0) Filters.Scene.Deactivate("WaterDistortion"); if (Filters.Scene["WaterDistortion"].IsActive()) { double num1 = (double) Main.maxTilesX * 0.5 - (double) Math.Abs((float) tileCoordinates1.X - (float) Main.maxTilesX * 0.5f); float num2 = 1f + Math.Abs(Main.windSpeedCurrent) * 1.25f + MathHelper.Clamp(Main.maxRaining, 0.0f, 1f) * 1.25f + (float) -((double) MathHelper.Clamp((float) ((num1 - 380.0) / 100.0), 0.0f, 1f) * 0.5 - 0.25); float num3 = 1f - MathHelper.Clamp((float) (3.0 * ((double) ((float) tileCoordinates1.Y - (float) Main.worldSurface) / (Main.rockLayer - Main.worldSurface))), 0.0f, 1f); float intensity = MathHelper.Clamp(num2 * num3 + (float) (0.899999976158142 - (double) MathHelper.Clamp((float) (Main.maxTilesY - tileCoordinates1.Y - 200) / 300f, 0.0f, 1f) * 0.899999976158142) + (float) ((1.0 - (double) num3) * 0.75), 0.0f, 2.5f); Filters.Scene["WaterDistortion"].GetShader().UseIntensity(intensity); } if (flag2) { float intensity = Math.Min(1f, (float) (tileCoordinates1.Y - (Main.maxTilesY - 320)) / 120f) * 2f; Filters.Scene["HeatDistortion"].GetShader().UseIntensity(intensity); } this._shaderObstructionInternalValue = Utils.Clamp(this._shaderObstructionInternalValue + (float) this.behindBackWall.ToDirectionInt() * -0.005f, -0.1f, 1.1f); this._stormShaderObstruction = Utils.Clamp(this._shaderObstructionInternalValue, 0.0f, 1f); if (Filters.Scene["Sandstorm"].IsActive()) { Filters.Scene["Sandstorm"].GetShader().UseIntensity(this._stormShaderObstruction * 0.4f * Math.Min(1f, Sandstorm.Severity)); Filters.Scene["Sandstorm"].GetShader().UseOpacity(Math.Min(1f, Sandstorm.Severity * 1.5f) * this._stormShaderObstruction); ((SimpleOverlay) Overlays.Scene["Sandstorm"]).GetShader().UseOpacity(Math.Min(1f, Sandstorm.Severity * 1.5f) * (1f - this._stormShaderObstruction)); } else if (this.ZoneDesert && !flag3 && !Main.raining && !flag2) { Vector3 vector3 = Main.tileColor.ToVector3(); float num = (float) (((double) vector3.X + (double) vector3.Y + (double) vector3.Z) / 3.0); float intensity = this._stormShaderObstruction * 4f * Math.Max(0.0f, 0.5f - Main.cloudAlpha) * num; Filters.Scene["HeatDistortion"].GetShader().UseIntensity(intensity); if ((double) intensity <= 0.0) Filters.Scene["HeatDistortion"].IsHidden = true; else Filters.Scene["HeatDistortion"].IsHidden = false; } if (!Player.disabledBlizzardGraphic) { try { if (flag1) { float opacity = Math.Min(1f, Main.cloudAlpha * 2f) * this._stormShaderObstruction; Filters.Scene["Blizzard"].GetShader().UseIntensity((float) ((double) this._stormShaderObstruction * 0.400000005960464 * (double) Math.Min(1f, Main.cloudAlpha * 2f) * 0.899999976158142 + 0.100000001490116)); Filters.Scene["Blizzard"].GetShader().UseOpacity(opacity); ((SimpleOverlay) Overlays.Scene["Blizzard"]).GetShader().UseOpacity(1f - opacity); } } catch { Player.disabledBlizzardGraphic = true; } } if (!Player.disabledBlizzardSound) { try { if (flag1) { ActiveSound activeSound1 = SoundEngine.GetActiveSound(Player._strongBlizzardSound); ActiveSound activeSound2 = SoundEngine.GetActiveSound(Player._insideBlizzardSound); if (activeSound1 == null) Player._strongBlizzardSound = SoundEngine.PlayTrackedSound((SoundStyle) SoundID.BlizzardStrongLoop); if (activeSound2 == null) Player._insideBlizzardSound = SoundEngine.PlayTrackedSound((SoundStyle) SoundID.BlizzardInsideBuildingLoop); SoundEngine.GetActiveSound(Player._strongBlizzardSound); SoundEngine.GetActiveSound(Player._insideBlizzardSound); } Player._blizzardSoundVolume = !flag1 ? Math.Max(Player._blizzardSoundVolume - 0.01f, 0.0f) : Math.Min(Player._blizzardSoundVolume + 0.01f, 1f); float num = Math.Min(1f, Main.cloudAlpha * 2f) * this._stormShaderObstruction; ActiveSound activeSound3 = SoundEngine.GetActiveSound(Player._strongBlizzardSound); ActiveSound activeSound4 = SoundEngine.GetActiveSound(Player._insideBlizzardSound); if ((double) Player._blizzardSoundVolume > 0.0) { if (activeSound3 == null) { Player._strongBlizzardSound = SoundEngine.PlayTrackedSound((SoundStyle) SoundID.BlizzardStrongLoop); activeSound3 = SoundEngine.GetActiveSound(Player._strongBlizzardSound); } activeSound3.Volume = num * Player._blizzardSoundVolume; if (activeSound4 == null) { Player._insideBlizzardSound = SoundEngine.PlayTrackedSound((SoundStyle) SoundID.BlizzardInsideBuildingLoop); activeSound4 = SoundEngine.GetActiveSound(Player._insideBlizzardSound); } activeSound4.Volume = (1f - num) * Player._blizzardSoundVolume; } else { if (activeSound3 != null) activeSound3.Volume = 0.0f; else Player._strongBlizzardSound = (SlotId) SlotId.Invalid; if (activeSound4 != null) activeSound4.Volume = 0.0f; else Player._insideBlizzardSound = (SlotId) SlotId.Invalid; } } catch { Player.disabledBlizzardSound = true; } } if (!this.dead) { Point tileCoordinates2 = this.Center.ToTileCoordinates(); if (WorldGen.InWorld(tileCoordinates2.X, tileCoordinates2.Y, 1)) { int num = 0; if (Main.tile[tileCoordinates2.X, tileCoordinates2.Y] != null) num = (int) Main.tile[tileCoordinates2.X, tileCoordinates2.Y].wall; switch (num) { case 62: AchievementsHelper.HandleSpecialEvent(this, 13); break; case 86: AchievementsHelper.HandleSpecialEvent(this, 12); break; } } if (this._funkytownAchievementCheckCooldown > 0) --this._funkytownAchievementCheckCooldown; if ((double) this.position.Y / 16.0 > (double) Main.UnderworldLayer) { AchievementsHelper.HandleSpecialEvent(this, 14); } else { if (this._funkytownAchievementCheckCooldown != 0 || (double) this.position.Y / 16.0 >= Main.worldSurface || !this.ZoneGlowshroom) return; AchievementsHelper.HandleSpecialEvent(this, 15); } } else this._funkytownAchievementCheckCooldown = 100; } public void ManageSpecialBiomeVisuals(string biomeName, bool inZone, Vector2 activationSource = default (Vector2)) { if (SkyManager.Instance[biomeName] != null && inZone != SkyManager.Instance[biomeName].IsActive()) { if (inZone) SkyManager.Instance.Activate(biomeName, activationSource); else SkyManager.Instance.Deactivate(biomeName); } if (inZone != Filters.Scene[biomeName].IsActive()) { if (inZone) Filters.Scene.Activate(biomeName, activationSource); else Filters.Scene[biomeName].Deactivate(); } else if (inZone) Filters.Scene[biomeName].GetShader().UseTargetPosition(activationSource); if (Overlays.Scene[biomeName] == null || inZone == (Overlays.Scene[biomeName].Mode != OverlayMode.Inactive)) return; if (inZone) Overlays.Scene.Activate(biomeName, activationSource); else Overlays.Scene[biomeName].Deactivate(); } public void GetHairSettings( out bool fullHair, out bool hatHair, out bool hideHair, out bool backHairDraw, out bool drawsBackHairWithoutHeadgear) { fullHair = hatHair = hideHair = drawsBackHairWithoutHeadgear = false; switch (this.head) { case 0: case 23: case 259: drawsBackHairWithoutHeadgear = true; break; case 10: case 12: case 28: case 42: case 62: case 97: case 106: case 113: case 116: case 119: case 133: case 138: case 139: case 163: case 178: case 181: case 191: case 198: case 217: case 218: case 220: case 222: case 224: case 225: case 228: case 229: case 230: case 232: case 235: case 238: case 242: case 243: case 244: case 245: fullHair = true; break; case 13: case 14: case 15: case 16: case 18: case 21: case 24: case 25: case 26: case 29: case 40: case 44: case 51: case 56: case 59: case 60: case 63: case 64: case 65: case 67: case 68: case 69: case 81: case 92: case 94: case 95: case 100: case 114: case 121: case 126: case 130: case 136: case 140: case 143: case 145: case 158: case 159: case 161: case 182: case 184: case 190: case 195: case 215: case 219: case 223: case 226: case 227: case 231: case 233: case 234: case 262: case 263: case 264: case 265: hatHair = true; break; } if (this.face > (sbyte) -1 && ArmorIDs.Face.Sets.PreventHairDraw[(int) this.face]) hideHair = true; int hair = this.hair; backHairDraw = hair > 50 && (hair < 56 || hair > 63) && (hair < 74 || hair > 77) && (hair < 88 || hair > 89) && hair != 94 && hair != 100 && hair != 104 && hair != 112 && hair < 116; if (hair != 133) return; backHairDraw = true; } public void UpdateDead() { this._portalPhysicsTime = 0; this.MountFishronSpecialCounter = 0.0f; this.gem = -1; this.ownedLargeGems = (BitsByte) (byte) 0; this.brainOfConfusionDodgeAnimationCounter = 0; this.ResetFloorFlags(); this.wings = 0; this.wingsLogic = 0; this.face = this.neck = this.back = this.front = this.handoff = this.handon = this.shoe = this.waist = this.balloon = this.shield = (sbyte) 0; this.poisoned = false; this.venom = false; this.onFire = false; this.dripping = false; this.drippingSlime = false; this.drippingSparkleSlime = false; this.burned = false; this.suffocating = false; this.onFire2 = false; this.onFrostBurn = false; this.blind = false; this.blackout = false; this.loveStruck = false; this.dryadWard = false; this.stinky = false; this.resistCold = false; this.electrified = false; this.moonLeech = false; this.headcovered = false; this.vortexDebuff = false; this.windPushed = false; this.setForbidden = false; this.setMonkT3 = false; this.setHuntressT3 = false; this.setApprenticeT3 = false; this.setSquireT3 = false; this.setForbiddenCooldownLocked = false; this.setSolar = this.setVortex = this.setNebula = this.setStardust = false; this.nebulaLevelDamage = this.nebulaLevelLife = this.nebulaLevelMana = 0; this.trapDebuffSource = false; this.yoraiz0rEye = 0; this.yoraiz0rDarkness = false; this.hasFloatingTube = false; this.hasUnicornHorn = false; this.leinforsHair = false; this.gravDir = 1f; for (int index = 0; index < 22; ++index) { if (this.buffType[index] <= 0 || !Main.persistentBuff[this.buffType[index]]) { this.buffTime[index] = 0; this.buffType[index] = 0; } } if (this.whoAmI == Main.myPlayer) { Main.npcChatText = ""; Main.editSign = false; Main.npcChatCornerItem = 0; } this.numMinions = 0; this.grappling[0] = -1; this.grappling[1] = -1; this.grappling[2] = -1; this.sign = -1; this.SetTalkNPC(-1); this.statLife = 0; this.channel = false; this.potionDelay = 0; this.chest = -1; this.tileEntityAnchor.Clear(); this.changeItem = -1; this.itemAnimation = 0; this.immuneAlpha += 2; if (this.immuneAlpha > (int) byte.MaxValue) this.immuneAlpha = (int) byte.MaxValue; this.headPosition += this.headVelocity; this.bodyPosition += this.bodyVelocity; this.legPosition += this.legVelocity; this.headRotation += this.headVelocity.X * 0.1f; this.bodyRotation += this.bodyVelocity.X * 0.1f; this.legRotation += this.legVelocity.X * 0.1f; this.headVelocity.Y += 0.1f; this.bodyVelocity.Y += 0.1f; this.legVelocity.Y += 0.1f; this.headVelocity.X *= 0.99f; this.bodyVelocity.X *= 0.99f; this.legVelocity.X *= 0.99f; for (int index = 0; index < this.npcTypeNoAggro.Length; ++index) this.npcTypeNoAggro[index] = false; if (this.difficulty == (byte) 2) { if (this.respawnTimer > 0) this.respawnTimer = Utils.Clamp(this.respawnTimer - 1, 0, 1800); else if (this.whoAmI == Main.myPlayer || Main.netMode == 2) this.ghost = true; } else { this.respawnTimer = Utils.Clamp(this.respawnTimer - 1, 0, 1800); if (this.respawnTimer <= 0 && Main.myPlayer == this.whoAmI) { if (Main.mouseItem.type > 0) Main.playerInventory = true; this.Spawn(PlayerSpawnContext.ReviveFromDeath); } } if (this.whoAmI != Main.myPlayer || Main.drawingPlayerChat || Main.editSign || Main.editChest || Main.blockInput) return; PlayerInput.Triggers.Current.CopyInto(this); if (this.controlInv) { if (!this.releaseInventory) return; this.releaseInventory = false; if (Main.ingameOptionsWindow) IngameOptions.Close(); else IngameOptions.Open(); } else this.releaseInventory = true; } public void UpdatePet(int i) { if (i != Main.myPlayer || this.miscEquips[0].buffType < 1 || this.miscEquips[0].stack < 1) return; int buffType = this.miscEquips[0].buffType; if (!Main.vanityPet[buffType] && !Main.lightPet[buffType] || this.hideMisc[0] || this.miscEquips[0].type == 603 && !Main.runningCollectorsEdition || this.FindBuffIndex(buffType) != -1) return; this.AddBuff(buffType, 3600); SoundEngine.PlaySound(this.miscEquips[0].UseSound, this.position); } public void UpdatePetLight(int i) { if (i != Main.myPlayer || this.miscEquips[1].buffType < 1 || this.miscEquips[1].stack < 1) return; int type = this.miscEquips[1].buffType; if (!Main.vanityPet[type] && !Main.lightPet[type] || this.hideMisc[1] || this.miscEquips[1].type == 603 && !Main.runningCollectorsEdition) return; int buffIndex = this.FindBuffIndex(type); if (type == 27 && buffIndex == -1) buffIndex = this.FindBuffIndex(102); if (type == 27 && buffIndex == -1) buffIndex = this.FindBuffIndex(101); if (buffIndex != -1) return; if (type == 27) type = Utils.SelectRandom(Main.rand, 27, 102, 101); this.AddBuff(type, 3600); SoundEngine.PlaySound(this.miscEquips[1].UseSound, this.position); } public void TogglePet() { this.hideMisc[0] = !this.hideMisc[0]; if (!this.hideMisc[0]) return; this.ClearBuff(this.miscEquips[0].buffType); } public void ToggleLight() { this.hideMisc[1] = !this.hideMisc[1]; if (!this.hideMisc[1]) return; this.ClearBuff(this.miscEquips[1].buffType); if (this.miscEquips[1].buffType != 27) return; this.ClearBuff(102); this.ClearBuff(101); } public bool IsWithinSnappngRangeToTile(int x, int y, int distanceInPixels) => (double) (new Vector2((float) (x * 16 + 8), (float) (y * 16 + 8)) - new Vector2(this.Center.X, this.Bottom.Y - 16f)).Length() <= (double) distanceInPixels; public void SmartInteractLookup() { Main.ClearSmartInteract(); if (UILinkPointNavigator.InUse || PlayerInput.UsingGamepad && Main.HoveringOverAnNPC) Main.SmartInteractTileCoordsSelected.Clear(); bool flag = PlayerInput.UsingGamepad || Main.SmartCursorEnabled; if (!flag && !PlayerInput.UsingGamepad) return; Vector2 mousevec; int LX; int HX; int LY; int HY; this.SmartInteractLookup_PrepareCommonlyUsedInfo(out mousevec, out LX, out HX, out LY, out HY); Player._smartInteractSys.RunQuery(new SmartInteractScanSettings() { DemandOnlyZeroDistanceTargets = PlayerInput.UsingGamepad && !Main.SmartCursorEnabled, FullInteraction = flag, HX = HX, HY = HY, LX = LX, LY = LY, mousevec = mousevec, player = this }); } private void SmartInteractLookup_PrepareCommonlyUsedInfo( out Vector2 mousevec, out int LX, out int HX, out int LY, out int HY) { mousevec = Main.ReverseGravitySupport(Main.MouseScreen) + Main.screenPosition; int num = 0; LX = (int) ((double) this.position.X / 16.0) - Player.tileRangeX - num + 1; HX = (int) (((double) this.position.X + (double) this.width) / 16.0) + Player.tileRangeX + num - 1; LY = (int) ((double) this.position.Y / 16.0) - Player.tileRangeY - num + 1; HY = (int) (((double) this.position.Y + (double) this.height) / 16.0) + Player.tileRangeY + num - 2; LX = Utils.Clamp(LX, 10, Main.maxTilesX - 10); HX = Utils.Clamp(HX, 10, Main.maxTilesX - 10); LY = Utils.Clamp(LY, 10, Main.maxTilesY - 10); HY = Utils.Clamp(HY, 10, Main.maxTilesY - 10); } public void SmartSelectLookup() { if (this.mouseInterface) this.controlTorch = false; if (this.controlTorch && this.itemAnimation == 0) { int tX; int tY; PlayerInput.smartSelectPointer.SmartSelectLookup_GetTargetTile(this, out tX, out tY); int toolStrategy; bool wetTile; this.SmartSelect_GetToolStrategy(tX, tY, out toolStrategy, out wetTile); if (PlayerInput.UsingGamepad && this._lastSmartCursorToolStrategy != -1) toolStrategy = this._lastSmartCursorToolStrategy; if (toolStrategy == 0 || toolStrategy == 4) { double num1 = (double) Math.Abs((float) ((double) Main.mouseX + (double) Main.screenPosition.X - ((double) this.position.X + (double) (this.width / 2)))); float num2 = Math.Abs((float) ((double) Main.mouseY + (double) Main.screenPosition.Y - ((double) this.position.Y + (double) (this.height / 2)))) * 1.3f; if (Math.Sqrt(num1 * num1 + (double) num2 * (double) num2) > 200.0) toolStrategy = 5; } this.SmartSelect_PickToolForStrategy(tX, tY, toolStrategy, wetTile); this._lastSmartCursorToolStrategy = toolStrategy; } else if (this.itemAnimation == 0 && this.DpadRadial.SelectedItem != -1 && this.inventory[this.DpadRadial.SelectedItem].stack > 0) { if (this.nonTorch == -1) this.nonTorch = this.selectedItem; this.selectedItem = this.DpadRadial.SelectedItem; this._lastSmartCursorToolStrategy = -1; } else if (this.itemAnimation == 0 && this.CircularRadial.SelectedItem != -1 && this.inventory[this.CircularRadial.SelectedItem].stack > 0) { if (this.nonTorch == -1) this.nonTorch = this.selectedItem; this.selectedItem = this.CircularRadial.SelectedItem; this._lastSmartCursorToolStrategy = -1; } else { if (this.nonTorch <= -1 || this.itemAnimation != 0) return; this.selectedItem = this.nonTorch; this.nonTorch = -1; this._lastSmartCursorToolStrategy = -1; } } private void SmartSelectLookup_GetTargetTile(out int tX, out int tY) { tX = (int) (((double) Main.mouseX + (double) Main.screenPosition.X) / 16.0); tY = (int) (((double) Main.mouseY + (double) Main.screenPosition.Y) / 16.0); if ((double) this.gravDir != -1.0) return; tY = (int) (((double) Main.screenPosition.Y + (double) Main.screenHeight - (double) Main.mouseY) / 16.0); } private void SmartSelect_PickToolForStrategy(int tX, int tY, int toolStrategy, bool wetTile) { for (int t = 0; t < 50; ++t) { int type = this.inventory[t].type; switch (toolStrategy) { case 0: if (ItemID.Sets.Torches[type]) { this.SmartSelect_SelectItem(t); return; } if (type == 282 || type == 286 || type == 3002 || type == 3112 || type == 4776) { this.SmartSelect_SelectItem(t); break; } break; case 1: if (this.inventory[t].hammer > 0) { this.SmartSelect_SelectItem(t); return; } break; case 2: if (this.inventory[t].axe > 0) { this.SmartSelect_SelectItem(t); return; } break; case 3: if (this.inventory[t].pick > 0) { this.SmartSelect_SelectItem(t); return; } break; case 4: if (this.inventory[t].type != 282 && this.inventory[t].type != 286 && this.inventory[t].type != 3002 && this.inventory[t].type != 3112 && this.inventory[t].type != 4776 && this.inventory[t].type != 930 && ItemID.Sets.Torches[type] && !ItemID.Sets.WaterTorches[type]) { if (this.nonTorch == -1) this.nonTorch = this.selectedItem; if (this.inventory[this.selectedItem].createTile != 4) { this.selectedItem = t; break; } break; } if (((type == 282 || type == 286 || type == 3002 || type == 3112 ? 1 : (type == 4776 ? 1 : 0)) & (wetTile ? 1 : 0)) != 0) { this.SmartSelect_SelectItem(t); return; } if (type == 930 & wetTile) { bool flag = false; for (int index = 57; index >= 0; --index) { if (this.inventory[index].ammo == this.inventory[t].useAmmo && this.inventory[index].stack > 0) { flag = true; break; } } if (flag) { this.SmartSelect_SelectItem(t); return; } break; } if (ItemID.Sets.WaterTorches[type]) { this.SmartSelect_SelectItem(t); return; } break; case 5: if (ItemID.Sets.Torches[type]) { if (this.nonTorch == -1) this.nonTorch = this.selectedItem; if (this.inventory[this.selectedItem].createTile != 4) { this.selectedItem = t; break; } break; } switch (type) { case 282: case 286: case 3002: case 3112: case 4776: this.SmartSelect_SelectItem(t); return; case 930: bool flag1 = false; for (int index = 57; index >= 0; --index) { if (this.inventory[index].ammo == this.inventory[t].useAmmo && this.inventory[index].stack > 0) { flag1 = true; break; } } if (flag1) { this.SmartSelect_SelectItem(t); return; } continue; default: continue; } case 6: int num = 929; if (Main.tile[tX, tY].frameX >= (short) 144) num = 1345; else if (Main.tile[tX, tY].frameX >= (short) 72) num = 1338; if (type == num) { this.SmartSelect_SelectItem(t); return; } break; case 7: if (ItemID.Sets.ExtractinatorMode[type] >= 0) { this.SmartSelect_SelectItem(t); return; } break; case 8: if (ItemID.Sets.IsPaintScraper[type]) { this.SmartSelect_SelectItem(t); return; } break; } } } private void SmartSelect_SelectItem(int t) { if (this.nonTorch == -1) this.nonTorch = this.selectedItem; this.selectedItem = t; } private void SmartSelect_GetToolStrategy( int tX, int tY, out int toolStrategy, out bool wetTile) { toolStrategy = 0; bool flag = false; wetTile = false; try { int num1 = 0; int num2 = 0; if ((double) this.position.X / 16.0 >= (double) tX) num1 = (int) ((double) this.position.X / 16.0) - tX; if (((double) this.position.X + (double) this.width) / 16.0 <= (double) tX) num1 = tX - (int) (((double) this.position.X + (double) this.width) / 16.0); if ((double) this.position.Y / 16.0 >= (double) tY) num2 = (int) ((double) this.position.Y / 16.0) - tY; if (((double) this.position.Y + (double) this.height) / 16.0 <= (double) tY) num2 = tY - (int) (((double) this.position.Y + (double) this.height) / 16.0); int pickRange; int axeRange; int hammerRange; int cannonRange; int extractItemRange; int paintScraperRange; this.SmartSelect_GetAvailableToolRanges(out pickRange, out axeRange, out hammerRange, out cannonRange, out extractItemRange, out paintScraperRange); wetTile = Main.tile[tX, tY].liquid > (byte) 0; if (Main.tile[tX, tY].active()) { int type = (int) Main.tile[tX, tY].type; if (type == 219 && num1 <= extractItemRange + Player.tileRangeX && num2 <= extractItemRange + Player.tileRangeY) { toolStrategy = 7; flag = true; } else if (type == 209 && num1 <= cannonRange + Player.tileRangeX && num2 <= cannonRange + Player.tileRangeY) { toolStrategy = 6; flag = true; } else if (Main.tileHammer[type] && num1 <= hammerRange + Player.tileRangeX && num2 <= hammerRange + Player.tileRangeY) { toolStrategy = 1; flag = true; } else if (Main.tileAxe[type] && num1 <= axeRange + Player.tileRangeX && num2 <= axeRange + Player.tileRangeY) { toolStrategy = 2; flag = true; } else if (type == 184 && num1 <= paintScraperRange + Player.tileRangeX && num2 <= paintScraperRange + Player.tileRangeY) { toolStrategy = 8; flag = true; } else if (num1 <= pickRange + Player.tileRangeX) { if (num2 <= pickRange + Player.tileRangeY) { toolStrategy = 3; flag = true; } } } else if (wetTile) { if (this.wet) { toolStrategy = 4; flag = true; } } } catch { } if (flag || !this.wet) return; toolStrategy = 4; } private void SmartSelect_GetAvailableToolRanges( out int pickRange, out int axeRange, out int hammerRange, out int cannonRange, out int extractItemRange, out int paintScraperRange) { pickRange = -10; axeRange = -10; hammerRange = -10; cannonRange = -10; extractItemRange = -10; paintScraperRange = -10; for (int index = 0; index < 50; ++index) { if (this.inventory[index].pick > 0 && pickRange == -10) pickRange = this.inventory[index].tileBoost; if (this.inventory[index].axe > 0 && axeRange == -10) axeRange = this.inventory[index].tileBoost; if (this.inventory[index].hammer > 0 && hammerRange == -10) hammerRange = this.inventory[index].tileBoost; if ((this.inventory[index].type == 929 || this.inventory[index].type == 1338 || this.inventory[index].type == 1345) && cannonRange == -10) cannonRange = this.inventory[index].tileBoost; if (ItemID.Sets.IsPaintScraper[this.inventory[index].type] && paintScraperRange == -10) paintScraperRange = this.inventory[index].tileBoost; if (ItemID.Sets.ExtractinatorMode[this.inventory[index].type] != -1 && extractItemRange == -10) extractItemRange = this.inventory[index].tileBoost; } } private void TryRecalculatingTorchLuck() { if (this.happyFunTorchTime) { this.luckyTorchCounter = 0; this.TorchAttack(); } else { if (this.torchGodCooldown > 0) --this.torchGodCooldown; if ((double) this.Center.Y < Main.worldSurface * 16.0) { this.UpdateTorchLuck_ConsumeCountersAndCalculate(); } else { int num1 = 1; int num2 = 40; int num3 = (int) this.Center.Y / 16 - num2; int num4 = (int) this.Center.X / 16 - num2; int num5 = (int) this.Center.X / 16 + num2; int num6 = Utils.Clamp(num4, 10, Main.maxTilesX - 10); int num7 = Utils.Clamp(num5, 10, Main.maxTilesX - 10); for (int index1 = 0; index1 < num1; ++index1) { int index2 = num3 + index1 + this.luckyTorchCounter * num1; if (index2 >= 10 && index2 <= Main.maxTilesY - 10) { for (int index3 = num6; index3 <= num7; ++index3) { Tile tile = Main.tile[index3, index2]; if (tile == null) return; if (tile.active() && tile.type == (ushort) 4) { if (tile.frameX < (short) 66) ++this.nearbyTorches; int index4 = (int) tile.frameY / 22; if (index4 < 22) { this.nearbyTorch[index4] = true; if (index4 == 17 && (tile.liquid == (byte) 0 || tile.liquidType() != (byte) 0)) this.dryCoralTorch = true; } } } if (index2 >= (int) this.Center.Y / 16 + num2) { this.UpdateTorchLuck_ConsumeCountersAndCalculate(); return; } } } ++this.luckyTorchCounter; } } } private void RelightTorches() { this.torchGodCooldown = 3600; for (int index = 0; index < this.numberOfTorchAttacks; ++index) { int tileX = this.unlitTorchX[index]; int tileY = this.unlitTorchY[index]; if (Main.tile[tileX, tileY].type == (ushort) 4 && Main.tile[tileX, tileY].frameX >= (short) 66) { Main.tile[tileX, tileY].frameX -= (short) 66; NetMessage.SendTileSquare(-1, tileX, tileY, 1); } } } private void TorchAttack() { if (this.whoAmI != Main.myPlayer) return; if ((double) this.position.Y < Main.worldSurface * 16.0) { this.RelightTorches(); this.happyFunTorchTime = false; if (Main.netMode != 1) return; NetMessage.SendData(4, number: this.whoAmI); } else { this.AddBuff(80, 2); ++this.torchFunTimer; if (this.torchFunTimer <= 20) return; this.torchFunTimer = 0; int maxValue = 0; int num1 = 100; int num2 = (int) this.Center.X / 16 - num1; int num3 = (int) this.Center.X / 16 + num1; int num4 = (int) this.Center.Y / 16 - num1; int num5 = (int) this.Center.Y / 16 + num1; int max = Main.maxTilesX - 10; int num6 = Utils.Clamp(num2, 10, max); int num7 = Utils.Clamp(num3, 10, Main.maxTilesX - 10); int num8 = Utils.Clamp(num4, 10, Main.maxTilesY - 10); int num9 = Utils.Clamp(num5, 10, Main.maxTilesY - 10); for (int index1 = num6; index1 <= num7; ++index1) { for (int index2 = num8; index2 <= num9; ++index2) { Tile tile = Main.tile[index1, index2]; if (tile != null && tile.active() & tile.type == (ushort) 4 && tile.frameX < (short) 66) { Player._torchAttackPosX[maxValue] = index1; Player._torchAttackPosY[maxValue] = index2; ++maxValue; if (maxValue >= Player._torchAttackPosX.Length) break; } } if (maxValue >= Player._torchAttackPosX.Length) break; } if (this.dead) { this.RelightTorches(); this.happyFunTorchTime = false; if (Main.netMode != 1) return; NetMessage.SendData(4, number: this.whoAmI); } else if (maxValue == 0 || this.numberOfTorchAttacks >= Player.maxTorchAttacks) { this.RelightTorches(); this.happyFunTorchTime = false; if (Main.netMode == 1) NetMessage.SendData(4, number: this.whoAmI); if (this.numberOfTorchAttacks < 95) return; int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 5043); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else { if (maxValue <= 0) return; int index3 = Main.rand.Next(maxValue); int tileX = Player._torchAttackPosX[index3]; int tileY = Player._torchAttackPosY[index3]; if (Main.tile[tileX, tileY].type != (ushort) 4 || Main.tile[tileX, tileY].frameX >= (short) 66) return; float num10 = 8f; int Damage = 20; if (Damage < 10) Damage = 10; int num11 = (int) Main.tile[tileX, tileY].frameY / 22; int num12; switch (num11) { case 0: num12 = 6; break; case 8: num12 = 75; break; case 9: num12 = 135; break; case 10: num12 = 158; break; case 11: num12 = 169; break; case 12: num12 = 156; break; case 13: num12 = 234; break; case 14: num12 = 66; break; case 15: num12 = 242; break; case 16: num12 = 293; break; case 17: num12 = 294; break; default: num12 = 58 + num11; break; } Main.tile[tileX, tileY].frameX += (short) 66; this.unlitTorchX[this.numberOfTorchAttacks] = tileX; this.unlitTorchY[this.numberOfTorchAttacks] = tileY; ++this.numberOfTorchAttacks; NetMessage.SendTileSquare(-1, tileX, tileY, 1); Vector2 position = new Vector2((float) (tileX * 16 + 8), (float) (tileY * 16)); Vector2 velocity = this.Center - position; float ai1 = velocity.Length(); velocity.Normalize(); velocity *= num10; int index4 = Projectile.NewProjectile(position, velocity, 949, Damage, 1f, this.whoAmI, (float) num12, ai1); Main.projectile[index4].ai[0] = (float) num12; Main.projectile[index4].ai[1] = ai1; Main.projectile[index4].netUpdate = true; if ((maxValue != 1 || this.numberOfTorchAttacks < 95) && this.numberOfTorchAttacks < Player.maxTorchAttacks) return; this.torchFunTimer = -180; } } } private void UpdateTorchLuck_ConsumeCountersAndCalculate() { this.luckyTorchCounter = 0; this.torchLuck = 0.0f; if (this.inventory[this.selectedItem].createTile == 4 && this.inventory[this.selectedItem].placeStyle < 22) this.nearbyTorch[this.inventory[this.selectedItem].placeStyle] = true; float num1 = 0.0f; float num2 = 0.0f; if (!this.ZoneDungeon && !this.ZoneLihzhardTemple) { if (this.nearbyTorch[9]) { if (this.ZoneSnow) ++num2; else ++num1; } if (this.nearbyTorch[16]) { if (this.ZoneDesert) ++num2; else ++num1; } if (this.nearbyTorch[17]) { if (WorldGen.oceanDepths((int) this.Center.X / 16, (int) this.Center.Y / 16)) ++num2; else if (this.dryCoralTorch) ++num1; } if (this.nearbyTorch[21]) { if (this.ZoneJungle) ++num2; else ++num1; } if (this.nearbyTorch[18]) { if (this.ZoneCorrupt) ++num2; else ++num1; } if (this.nearbyTorch[8] && this.ZoneCorrupt) ++num2; if (this.nearbyTorch[19]) { if (this.ZoneCrimson) ++num2; else ++num1; } if (this.nearbyTorch[11] && this.ZoneCrimson) ++num2; if (this.nearbyTorch[20]) { if (this.ZoneHallow) ++num2; else ++num1; } if (this.nearbyTorch[13] && !this.ZoneSnow && !this.ZoneDesert && !this.ZoneCorrupt && !this.ZoneCrimson && !this.ZoneHallow && !this.ZoneJungle) num2 += 0.5f; if (this.nearbyTorch[0]) { if (this.ZoneSnow) num1 += 2f; else if (this.ZoneDesert || this.ZoneCorrupt || this.ZoneCrimson || this.ZoneHallow) num1 += 0.5f; } } if ((double) num2 >= 1.0) ++this.torchLuck; else if ((double) num2 > 0.0) this.torchLuck += 0.5f; if ((double) num1 >= 2.0) this.torchLuck += -1.5f; else if ((double) num1 >= 1.0) this.torchLuck += -1f; else if ((double) num1 > 0.0) this.torchLuck += -0.5f; this.dryCoralTorch = false; for (int index = 0; index < 22; ++index) this.nearbyTorch[index] = false; if ((double) this.torchLuck < 0.0) this.torchLuck = 0.0f; if (this.torchGodCooldown <= 0 && !this.unlockedBiomeTorches && this.nearbyTorches > 100 && !this.happyFunTorchTime && (double) this.position.Y > Main.worldSurface * 16.0) { bool flag = false; for (int index = 0; index < this.inventory.Length; ++index) { if (this.inventory[index].type == 5043) { flag = true; break; } } if (!flag) { this.happyFunTorchTime = true; this.numberOfTorchAttacks = 0; } } this.nearbyTorches = 0; } public float NormalizedLuck { get { float num = 0.0f; if ((double) this.luck > 0.0) num = this.luck / this.luckMaximumCap; else if ((double) this.luck < 0.0) num = (float) -((double) this.luck / (double) this.luckMinimumCap); return MathHelper.Clamp(num, -1f, 1f); } } private float GetLadyBugLuck() { if (this.ladyBugLuckTimeLeft > 0) return (float) this.ladyBugLuckTimeLeft / (float) NPC.ladyBugGoodLuckTime; return this.ladyBugLuckTimeLeft < 0 ? (float) -(double) this.ladyBugLuckTimeLeft / (float) NPC.ladyBugBadLuckTime : 0.0f; } public static float GetClosestPlayersLuck(Point Position) => Main.player[(int) Player.FindClosest(new Vector2((float) (Position.X * 16), (float) (Position.Y * 16)), 1, 1)].luck; public static float GetClosestPlayersLuck(Vector2 Position) => Main.player[(int) Player.FindClosest(Position, 1, 1)].luck; public int RollLuck(int range) { if ((double) this.luck > 0.0 && (double) Main.rand.NextFloat() < (double) this.luck) return Main.rand.Next(Main.rand.Next(range / 2, range)); return (double) this.luck < 0.0 && (double) Main.rand.NextFloat() < -(double) this.luck ? Main.rand.Next(Main.rand.Next(range, range * 2)) : Main.rand.Next(range); } public static float GetClosestRollLuck(Vector2 position, int range) => (float) Main.player[(int) Player.FindClosest(position, 1, 1)].RollLuck(range); public static float GetClosestRollLuck(int x, int y, int range) => (float) Main.player[(int) Player.FindClosest(new Vector2((float) (x * 16), (float) (y * 16)), 1, 1)].RollLuck(range); public void ResetEffects() { this.extraAccessorySlots = !this.extraAccessory || !Main.expertMode && !Main.gameMenu ? 0 : 1; this.fairyBoots = false; this.moonLordLegs = false; this.flowerBoots = false; this.arcticDivingGear = false; this.noBuilding = false; this.strongBees = false; this.armorPenetration = 0; this.shroomiteStealth = false; this.statDefense = 0; this.accWatch = 0; this.accCompass = 0; this.accDepthMeter = 0; this.accDivingHelm = false; this.canFloatInWater = false; this.lifeRegen = 0; this.manaCost = 1f; this.meleeSpeed = 1f; this.meleeDamage = 1f; this.rangedDamage = 1f; this.magicDamage = 1f; this.minionDamage = 1f; this.meleeCrit = 4; this.rangedCrit = 4; this.magicCrit = 4; this.hasFootball = false; this.drawingFootball = false; this.minionKB = 0.0f; this.moveSpeed = 1f; this.boneArmor = false; this.honey = false; this.frostArmor = false; this.rocketBoots = 0; this.fireWalk = false; this.noKnockback = false; this.jumpBoost = false; this.frogLegJumpBoost = false; this.skyStoneEffects = false; this.noFallDmg = false; this.accFlipper = false; this.spawnMax = false; this.spaceGun = false; this.killGuide = false; this.killClothier = false; this.lavaImmune = false; this.gills = false; this.slowFall = false; this.findTreasure = false; this.invis = false; this.nightVision = false; this.enemySpawns = false; this.hasTitaniumStormBuff = false; this.thorns = 0.0f; this.aggro = 0; this.waterWalk = false; this.waterWalk2 = false; this.detectCreature = false; this.gravControl = false; this.releaseBeesWhenHurt = false; this.gravControl2 = false; this.statLifeMax2 = this.statLifeMax; this.statManaMax2 = this.statManaMax; this.chloroAmmoCost80 = false; this.ammoCost80 = false; this.ammoCost75 = false; this.manaRegenBuff = false; this.arrowDamage = 1f; this.bulletDamage = 1f; this.rocketDamage = 1f; this.coolWhipBuff = false; this.yoraiz0rEye = 0; this.yoraiz0rDarkness = false; this.hasFloatingTube = false; this.hasUnicornHorn = false; this.leinforsHair = false; this.suspiciouslookingTentacle = false; this.crimsonHeart = false; this.lightOrb = false; this.blueFairy = false; this.redFairy = false; this.greenFairy = false; this.wisp = false; this.bunny = false; this.turtle = false; this.eater = false; this.trident = false; this.skeletron = false; this.hornet = false; this.zephyrfish = false; this.tiki = false; this.lizard = false; this.parrot = false; this.sapling = false; this.cSapling = false; this.truffle = false; this.yoyoGlove = false; this.counterWeight = 0; this.stringColor = 0; this.yoyoString = false; this.shadowDodge = false; this.palladiumRegen = false; this.chaosState = false; this.onHitDodge = false; this.onHitRegen = false; this.onHitPetal = false; this.iceBarrier = false; this.onHitTitaniumStorm = false; this.maxMinions = 1; this.maxTurrets = 1; this.ammoBox = false; this.ammoPotion = false; this.penguin = false; this.sporeSac = false; this.shinyStone = false; this.empressBrooch = false; this.volatileGelatin = false; this.dd2Accessory = false; this.magicLantern = false; this.rabid = false; this.sunflower = false; this.wellFed = false; this.inferno = false; this.manaMagnet = false; this.lifeMagnet = false; this.treasureMagnet = false; this.lifeForce = false; this.dangerSense = false; if (Main.myPlayer == this.whoAmI) this.luckPotion = (byte) 0; this.endurance = 0.0f; this.calmed = false; this.beetleOrbs = 0; this.beetleBuff = false; this.miniMinotaur = false; this.goldRing = false; this.solarShields = 0; this.GoingDownWithGrapple = false; this.fishingSkill = 0; this.cratePotion = false; this.sonarPotion = false; this.accTackleBox = false; this.accFishingLine = false; this.accLavaFishing = false; this.accFishFinder = false; this.accWeatherRadio = false; this.accThirdEye = false; this.InfoAccMechShowWires = false; this.accJarOfSouls = false; this.accCalendar = false; this.accStopwatch = false; this.accOreFinder = false; this.accCritterGuide = false; this.accDreamCatcher = false; this.wallSpeed = 1f; this.tileSpeed = 1f; this.autoPaint = false; this.autoActuator = false; this.petFlagKingSlimePet = false; this.petFlagEyeOfCthulhuPet = false; this.petFlagEaterOfWorldsPet = false; this.petFlagBrainOfCthulhuPet = false; this.petFlagSkeletronPet = false; this.petFlagQueenBeePet = false; this.petFlagDestroyerPet = false; this.petFlagTwinsPet = false; this.petFlagSkeletronPrimePet = false; this.petFlagPlanteraPet = false; this.petFlagGolemPet = false; this.petFlagDukeFishronPet = false; this.petFlagLunaticCultistPet = false; this.petFlagMoonLordPet = false; this.petFlagFairyQueenPet = false; this.petFlagPumpkingPet = false; this.petFlagEverscreamPet = false; this.petFlagIceQueenPet = false; this.petFlagMartianPet = false; this.petFlagDD2OgrePet = false; this.petFlagDD2BetsyPet = false; this.petFlagQueenSlimePet = false; this.petFlagVoltBunny = false; this.petFlagShadowMimic = false; this.petFlagBabyWerewolf = false; this.petFlagDynamiteKitten = false; this.petFlagPlantero = false; this.petFlagBabyRedPanda = false; this.petFlagLilHarpy = false; this.petFlagFennecFox = false; this.petFlagGlitteryButterfly = false; this.petFlagBabyImp = false; this.petFlagBabyShark = false; this.petFlagUpbeatStar = false; this.petFlagDD2Gato = false; this.petFlagDD2Dragon = false; this.petFlagDD2Ghost = false; this.companionCube = false; this.petFlagSugarGlider = false; this.babyFaceMonster = false; this.manaSick = false; this.puppy = false; this.grinch = false; this.blackCat = false; this.spider = false; this.squashling = false; this.magicCuffs = false; this.coldDash = false; this.desertDash = false; this.sailDash = false; this.cordage = false; this.magicQuiver = false; this.hasMoltenQuiver = false; this.magmaStone = false; this.hasRaisableShield = false; this.lavaRose = false; this.eyeSpring = false; this.snowman = false; this.scope = false; this.panic = false; this.brainOfConfusion = false; this.dino = false; this.crystalLeaf = false; this.pygmy = false; this.raven = false; this.slime = false; this.hornetMinion = false; this.impMinion = false; this.twinsMinion = false; this.spiderMinion = false; this.pirateMinion = false; this.sharknadoMinion = false; this.stardustMinion = false; this.batsOfLight = false; this.babyBird = false; this.stormTiger = false; this.smolstar = false; this.empressBlade = false; this.stardustGuardian = false; this.stardustDragon = false; this.UFOMinion = false; this.DeadlySphereMinion = false; this.chilled = false; this.tipsy = false; this.dazed = false; this.frozen = false; this.stoned = false; this.webbed = false; this.ichor = false; this.manaRegenBonus = 0; this.manaRegenDelayBonus = 0; this.carpet = false; this.iceSkate = false; this.dashType = 0; this.spikedBoots = 0; this.blackBelt = false; this.lavaMax = 0; this.archery = false; this.poisoned = false; this.venom = false; this.blind = false; this.blackout = false; this.onFire = false; this.dripping = false; this.drippingSlime = false; this.drippingSparkleSlime = false; this.burned = false; this.suffocating = false; this.onFire2 = false; this.onFrostBurn = false; this.frostBurn = false; this.noItems = false; this.cursed = false; this.blockRange = 0; this.pickSpeed = 1f; this.wereWolf = false; this.rulerGrid = false; this.rulerLine = true; this.bleed = false; this.confused = false; this.witheredArmor = false; this.witheredWeapon = false; this.parryDamageBuff = false; this.slowOgreSpit = false; this.wings = 0; this.wingsLogic = 0; this.wingTimeMax = 0; this.brokenArmor = false; this.silence = false; this.slow = false; this.gross = false; this.tongued = false; this.kbGlove = false; this.kbBuff = false; this.starCloak = false; this.starCloakIsManaCloak = false; this.starCloakIsStarVeil = false; this.starCloakIsBeeCloak = false; this.longInvince = false; this.pStone = false; this.manaFlower = false; this.crimsonRegen = false; this.ghostHeal = false; this.ghostHurt = false; this.turtleArmor = false; this.turtleThorns = false; this.spiderArmor = false; this.loveStruck = false; this.stinky = false; this.dryadWard = false; this.resistCold = false; this.electrified = false; this.moonLeech = false; this.headcovered = false; this.vortexDebuff = false; this.windPushed = false; this.ballistaPanic = false; this.vampireFrog = false; this.CanSeeInvisibleBlocks = false; this.setVortex = this.setNebula = this.setStardust = false; this.setForbidden = false; this.setHuntressT3 = false; this.setSquireT3 = false; this.setMonkT3 = false; this.setApprenticeT3 = false; this.setHuntressT2 = false; this.setSquireT2 = false; this.setMonkT2 = false; this.setApprenticeT2 = false; this.setForbiddenCooldownLocked = false; this.nebulaLevelDamage = this.nebulaLevelLife = this.nebulaLevelMana = 0; this.ignoreWater = false; this.meleeEnchant = (byte) 0; this.discount = false; this.coins = false; this.hasJumpOption_Cloud = false; this.hasJumpOption_Sail = false; this.hasJumpOption_Sandstorm = false; this.hasJumpOption_Blizzard = false; this.hasJumpOption_Fart = false; this.hasJumpOption_Unicorn = false; this.hasJumpOption_Santank = false; this.hasJumpOption_WallOfFleshGoat = false; this.hasJumpOption_Basilisk = false; this.defendedByPaladin = false; this.hasPaladinShield = false; this.preventAllItemPickups = false; this.dontHurtCritters = false; this.portableStoolInfo.Reset(); this.ResizeHitbox(); this.autoJump = false; this.justJumped = false; this.jumpSpeedBoost = 0.0f; this.extraFall = 0; this.creativeGodMode = false; if (this.phantasmTime > 0) --this.phantasmTime; if (this.brainOfConfusionDodgeAnimationCounter > 0) --this.brainOfConfusionDodgeAnimationCounter; if (this.wireOperationsCooldown > 0) --this.wireOperationsCooldown; if (this.releaseUseItem) this.ActuationRodLock = false; for (int index = 0; index < this.npcTypeNoAggro.Length; ++index) this.npcTypeNoAggro[index] = false; this.ResetProjectileCaches(); if (this.whoAmI == Main.myPlayer) { Player.tileRangeX = 5; Player.tileRangeY = 4; if (Main.GameModeInfo.IsJourneyMode) { CreativePowers.FarPlacementRangePower power = CreativePowerManager.Instance.GetPower(); if (power.GetIsUnlocked() && power.IsEnabledForPlayer(this.whoAmI)) { Player.tileRangeX *= 2; Player.tileRangeY *= 2; Player.tileRangeX += 8; Player.tileRangeY += 8; } } } this.mount.CheckMountBuff(this); } private void UpdateLadyBugLuckTime() { if (this.ladyBugLuckTimeLeft > 0) { this.ladyBugLuckTimeLeft -= Main.dayRate; if (this.ladyBugLuckTimeLeft >= 0) return; this.ladyBugLuckTimeLeft = 0; } else { if (this.ladyBugLuckTimeLeft >= 0) return; this.ladyBugLuckTimeLeft += Main.dayRate; if (this.ladyBugLuckTimeLeft <= 0) return; this.ladyBugLuckTimeLeft = 0; } } public void UpdateImmunity() { if (this.immune) { --this.immuneTime; if (this.immuneTime <= 0) { this.immune = false; this.immuneNoBlink = false; } if (this.immuneNoBlink) { this.immuneAlpha = 0; } else { this.immuneAlpha += this.immuneAlphaDirection * 50; if (this.immuneAlpha <= 50) this.immuneAlphaDirection = 1; else if (this.immuneAlpha >= 205) this.immuneAlphaDirection = -1; } } else this.immuneAlpha = 0; for (int index = 0; index < this.hurtCooldowns.Length; ++index) { if (this.hurtCooldowns[index] > 0) --this.hurtCooldowns[index]; } } public void UpdateLifeRegen() { bool flag = false; if (this.shinyStone && (double) Math.Abs(this.velocity.X) < 0.05 && (double) Math.Abs(this.velocity.Y) < 0.05 && this.itemAnimation == 0) flag = true; if (this.poisoned) { if (this.lifeRegen > 0) this.lifeRegen = 0; this.lifeRegenTime = 0; this.lifeRegen -= 4; } if (this.venom) { if (this.lifeRegen > 0) this.lifeRegen = 0; this.lifeRegenTime = 0; this.lifeRegen -= 30; } if (this.onFire) { if (this.lifeRegen > 0) this.lifeRegen = 0; this.lifeRegenTime = 0; this.lifeRegen -= 8; } if (this.onFrostBurn) { if (this.lifeRegen > 0) this.lifeRegen = 0; this.lifeRegenTime = 0; this.lifeRegen -= 12; } if (this.onFire2) { if (this.lifeRegen > 0) this.lifeRegen = 0; this.lifeRegenTime = 0; this.lifeRegen -= 24; } if (this.burned) { if (this.lifeRegen > 0) this.lifeRegen = 0; this.lifeRegenTime = 0; this.lifeRegen -= 60; this.moveSpeed *= 0.5f; } if (this.suffocating) { if (this.lifeRegen > 0) this.lifeRegen = 0; this.lifeRegenTime = 0; this.lifeRegen -= 40; } if (this.electrified) { if (this.lifeRegen > 0) this.lifeRegen = 0; this.lifeRegenTime = 0; this.lifeRegen -= 8; if (this.controlLeft || this.controlRight) this.lifeRegen -= 32; } if (this.tongued && Main.expertMode) { if (this.lifeRegen > 0) this.lifeRegen = 0; this.lifeRegenTime = 0; this.lifeRegen -= 100; } if (this.honey && this.lifeRegen < 0) { this.lifeRegen += 4; if (this.lifeRegen > 0) this.lifeRegen = 0; } if (this.lifeRegen < 0 && this.nebulaLevelLife > 0) this.lifeRegen = 0; if (flag && this.lifeRegen < 0) this.lifeRegen /= 2; ++this.lifeRegenTime; if (this.crimsonRegen) ++this.lifeRegenTime; if (this.soulDrain > 0) this.lifeRegenTime += 2; if (flag) { if (this.lifeRegenTime > 90 && this.lifeRegenTime < 1800) this.lifeRegenTime = 1800; this.lifeRegenTime += 4; this.lifeRegen += 4; } if (this.honey) { this.lifeRegenTime += 2; this.lifeRegen += 2; } if (this.soulDrain > 0) { int num = (5 + this.soulDrain) / 2; this.lifeRegenTime += num; this.lifeRegen += num; } if (this.whoAmI == Main.myPlayer && Main.SceneMetrics.HasCampfire) ++this.lifeRegen; if (this.whoAmI == Main.myPlayer && Main.SceneMetrics.HasHeartLantern) this.lifeRegen += 2; if (this.bleed) this.lifeRegenTime = 0; float num1 = 0.0f; if (this.lifeRegenTime >= 300) ++num1; if (this.lifeRegenTime >= 600) ++num1; if (this.lifeRegenTime >= 900) ++num1; if (this.lifeRegenTime >= 1200) ++num1; if (this.lifeRegenTime >= 1500) ++num1; if (this.lifeRegenTime >= 1800) ++num1; if (this.lifeRegenTime >= 2400) ++num1; if (this.lifeRegenTime >= 3000) ++num1; if (flag) { float num2 = (float) (this.lifeRegenTime - 3000) / 300f; if ((double) num2 > 0.0) { if ((double) num2 > 30.0) num2 = 30f; num1 += num2; } } else if (this.lifeRegenTime >= 3600) { ++num1; this.lifeRegenTime = 3600; } if (this.sitting.isSitting || this.sleeping.isSleeping) { this.lifeRegenTime += 10; num1 *= 1.5f; } float num3 = (double) this.velocity.X == 0.0 || this.grappling[0] > 0 ? num1 * 1.25f : num1 * 0.5f; if (this.crimsonRegen) num3 *= 1.5f; if (this.shinyStone) num3 *= 1.1f; if (this.whoAmI == Main.myPlayer && Main.SceneMetrics.HasCampfire) num3 *= 1.1f; if (Main.expertMode && !this.wellFed) { if (this.shinyStone) num3 *= 0.75f; else num3 /= 2f; } if (this.rabid) { if (this.shinyStone) num3 *= 0.75f; else num3 /= 2f; } float num4 = (float) ((double) this.statLifeMax2 / 400.0 * 0.850000023841858 + 0.150000005960464); this.lifeRegen += (int) Math.Round((double) (num3 * num4)); this.lifeRegenCount += this.lifeRegen; if (this.palladiumRegen) this.lifeRegenCount += 6; if (flag && this.lifeRegen > 0 && this.statLife < this.statLifeMax2) { ++this.lifeRegenCount; if (flag && (Main.rand.Next(30000) < this.lifeRegenTime || Main.rand.Next(30) == 0)) { int index = Dust.NewDust(this.position, this.width, this.height, 55, Alpha: 200, Scale: 0.5f); Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.75f; Main.dust[index].fadeIn = 1.3f; Vector2 vector2_1 = new Vector2((float) Main.rand.Next(-100, 101), (float) Main.rand.Next(-100, 101)); vector2_1.Normalize(); Vector2 vector2_2 = vector2_1 * ((float) Main.rand.Next(50, 100) * 0.04f); Main.dust[index].velocity = vector2_2; vector2_2.Normalize(); Vector2 vector2_3 = vector2_2 * 34f; Main.dust[index].position = this.Center - vector2_3; } } while (this.lifeRegenCount >= 120) { this.lifeRegenCount -= 120; if (this.statLife < this.statLifeMax2) { ++this.statLife; if (this.crimsonRegen) { for (int index1 = 0; index1 < 10; ++index1) { int index2 = Dust.NewDust(this.position, this.width, this.height, 5, Alpha: 175, Scale: 1.75f); Main.dust[index2].noGravity = true; Main.dust[index2].velocity *= 0.75f; int num5 = Main.rand.Next(-40, 41); int num6 = Main.rand.Next(-40, 41); Main.dust[index2].position.X += (float) num5; Main.dust[index2].position.Y += (float) num6; Main.dust[index2].velocity.X = (float) -num5 * 0.075f; Main.dust[index2].velocity.Y = (float) -num6 * 0.075f; } } } if (this.statLife > this.statLifeMax2) this.statLife = this.statLifeMax2; } if (this.burned || this.suffocating || this.tongued && Main.expertMode) { while (this.lifeRegenCount <= -600) { this.lifeRegenCount += 600; this.statLife -= 5; CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int) this.position.X, (int) this.position.Y, this.width, this.height), CombatText.LifeRegen, 5, dot: true); if (this.statLife <= 0 && this.whoAmI == Main.myPlayer) { if (this.suffocating) this.KillMe(PlayerDeathReason.ByOther(7), 10.0, 0); else this.KillMe(PlayerDeathReason.ByOther(8), 10.0, 0); } } } else { while (this.lifeRegenCount <= -120) { if (this.lifeRegenCount <= -480) { this.lifeRegenCount += 480; this.statLife -= 4; CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int) this.position.X, (int) this.position.Y, this.width, this.height), CombatText.LifeRegen, 4, dot: true); } else if (this.lifeRegenCount <= -360) { this.lifeRegenCount += 360; this.statLife -= 3; CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int) this.position.X, (int) this.position.Y, this.width, this.height), CombatText.LifeRegen, 3, dot: true); } else if (this.lifeRegenCount <= -240) { this.lifeRegenCount += 240; this.statLife -= 2; CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int) this.position.X, (int) this.position.Y, this.width, this.height), CombatText.LifeRegen, 2, dot: true); } else { this.lifeRegenCount += 120; --this.statLife; CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int) this.position.X, (int) this.position.Y, this.width, this.height), CombatText.LifeRegen, 1, dot: true); } if (this.statLife <= 0 && this.whoAmI == Main.myPlayer) { if (this.poisoned || this.venom) this.KillMe(PlayerDeathReason.ByOther(9), 10.0, 0); else if (this.electrified) this.KillMe(PlayerDeathReason.ByOther(10), 10.0, 0); else this.KillMe(PlayerDeathReason.ByOther(8), 10.0, 0); } } } } public void UpdateManaRegen() { if (this.nebulaLevelMana > 0) { int num = 6; this.nebulaManaCounter += this.nebulaLevelMana; if (this.nebulaManaCounter >= num) { this.nebulaManaCounter -= num; ++this.statMana; if (this.statMana >= this.statManaMax2) this.statMana = this.statManaMax2; } } else this.nebulaManaCounter = 0; if (this.manaRegenDelay > 0) { --this.manaRegenDelay; this.manaRegenDelay -= this.manaRegenDelayBonus; if ((double) this.velocity.X == 0.0 && (double) this.velocity.Y == 0.0 || this.grappling[0] >= 0 || this.manaRegenBuff) --this.manaRegenDelay; } if (this.manaRegenBuff && this.manaRegenDelay > 20) this.manaRegenDelay = 20; if (this.manaRegenDelay <= 0) { this.manaRegenDelay = 0; this.manaRegen = this.statManaMax2 / 7 + 1 + this.manaRegenBonus; if ((double) this.velocity.X == 0.0 && (double) this.velocity.Y == 0.0 || this.grappling[0] >= 0 || this.manaRegenBuff) this.manaRegen += this.statManaMax2 / 2; float num = (float) ((double) this.statMana / (double) this.statManaMax2 * 0.800000011920929 + 0.200000002980232); if (this.manaRegenBuff) num = 1f; this.manaRegen = (int) ((double) this.manaRegen * (double) num * 1.15); } else this.manaRegen = 0; this.manaRegenCount += this.manaRegen; while (this.manaRegenCount >= 120) { bool flag = false; this.manaRegenCount -= 120; if (this.statMana < this.statManaMax2) { ++this.statMana; flag = true; } if (this.statMana >= this.statManaMax2) { if (this.whoAmI == Main.myPlayer & flag) { SoundEngine.PlaySound(25); for (int index1 = 0; index1 < 5; ++index1) { int index2 = Dust.NewDust(this.position, this.width, this.height, 45, Alpha: ((int) byte.MaxValue), Scale: ((float) Main.rand.Next(20, 26) * 0.1f)); Main.dust[index2].noLight = true; Main.dust[index2].noGravity = true; Main.dust[index2].velocity *= 0.5f; } } this.statMana = this.statManaMax2; } } } public void UpdateJumpHeight() { if (this.mount.Active) { Player.jumpHeight = this.mount.JumpHeight(this.velocity.X); Player.jumpSpeed = this.mount.JumpSpeed(this.velocity.X); } else { if (this.jumpBoost) { Player.jumpHeight = 20; Player.jumpSpeed = 6.51f; } if (this.empressBrooch) this.jumpSpeedBoost += 2.4f; if (this.frogLegJumpBoost) { this.jumpSpeedBoost += 2.4f; this.extraFall += 15; } if (this.moonLordLegs) { this.jumpSpeedBoost += 1.8f; this.extraFall += 10; ++Player.jumpHeight; } if (this.wereWolf) { Player.jumpHeight += 2; Player.jumpSpeed += 0.2f; } if (this.portableStoolInfo.IsInUse) Player.jumpHeight += 5; Player.jumpSpeed += this.jumpSpeedBoost; } if (this.sticky) { Player.jumpHeight /= 10; Player.jumpSpeed /= 5f; } if (!this.dazed) return; Player.jumpHeight /= 5; Player.jumpSpeed /= 2f; } public void FindPulley() { if (this.portableStoolInfo.IsInUse || !this.controlUp && !this.controlDown) return; int index1 = (int) ((double) this.position.X + (double) (this.width / 2)) / 16; int index2 = (int) ((double) this.position.Y - 8.0) / 16; if (Main.tile[index1, index2] == null || !Main.tile[index1, index2].active() || !Main.tileRope[(int) Main.tile[index1, index2].type]) return; float num1 = this.position.Y; if (Main.tile[index1, index2 - 1] == null) Main.tile[index1, index2 - 1] = new Tile(); if (Main.tile[index1, index2 + 1] == null) Main.tile[index1, index2 + 1] = new Tile(); if ((!Main.tile[index1, index2 - 1].active() || !Main.tileRope[(int) Main.tile[index1, index2 - 1].type]) && (!Main.tile[index1, index2 + 1].active() || !Main.tileRope[(int) Main.tile[index1, index2 + 1].type])) num1 = (float) (index2 * 16 + 22); float x1 = (float) (index1 * 16 + 8 - this.width / 2 + 6 * this.direction); int num2 = index1 * 16 + 8 - this.width / 2 + 6; int num3 = index1 * 16 + 8 - this.width / 2; int num4 = index1 * 16 + 8 - this.width / 2 - 6; int num5 = 1; float num6 = Math.Abs(this.position.X - (float) num2); if ((double) Math.Abs(this.position.X - (float) num3) < (double) num6) { num5 = 2; num6 = Math.Abs(this.position.X - (float) num3); } if ((double) Math.Abs(this.position.X - (float) num4) < (double) num6) { num5 = 3; Math.Abs(this.position.X - (float) num4); } if (num5 == 1) { x1 = (float) num2; this.pulleyDir = (byte) 2; this.direction = 1; } if (num5 == 2) { x1 = (float) num3; this.pulleyDir = (byte) 1; } if (num5 == 3) { x1 = (float) num4; this.pulleyDir = (byte) 2; this.direction = -1; } if (!Collision.SolidCollision(new Vector2(x1, this.position.Y), this.width, this.height)) { if (this.whoAmI == Main.myPlayer) Main.cameraX = Main.cameraX + this.position.X - x1; this.pulley = true; this.position.X = x1; this.gfxOffY = this.position.Y - num1; this.stepSpeed = 2.5f; this.position.Y = num1; this.velocity.X = 0.0f; } else { float x2 = (float) num2; this.pulleyDir = (byte) 2; this.direction = 1; if (!Collision.SolidCollision(new Vector2(x2, this.position.Y), this.width, this.height)) { if (this.whoAmI == Main.myPlayer) Main.cameraX = Main.cameraX + this.position.X - x2; this.pulley = true; this.position.X = x2; this.gfxOffY = this.position.Y - num1; this.stepSpeed = 2.5f; this.position.Y = num1; this.velocity.X = 0.0f; } else { float x3 = (float) num4; this.pulleyDir = (byte) 2; this.direction = -1; if (Collision.SolidCollision(new Vector2(x3, this.position.Y), this.width, this.height)) return; if (this.whoAmI == Main.myPlayer) Main.cameraX = Main.cameraX + this.position.X - x3; this.pulley = true; this.position.X = x3; this.gfxOffY = this.position.Y - num1; this.stepSpeed = 2.5f; this.position.Y = num1; this.velocity.X = 0.0f; } } } public void HorizontalMovement() { if (this.chilled) this.accRunSpeed = this.maxRunSpeed; bool flag1 = (this.itemAnimation == 0 || this.inventory[this.selectedItem].useTurn) && this.mount.AllowDirectionChange; bool flag2 = this.controlLeft || this.controlRight; float num1 = (float) (((double) this.accRunSpeed + (double) this.maxRunSpeed) / 2.0); float num2 = 0.0f; bool flag3 = false; if (flag2 && this.mount.Active && this.mount.Type == 43 && (double) this.velocity.Y == 0.0 && !this.controlJump) { SoundEngine.PlaySound(SoundID.Item168, this.Center); float num3 = (float) ((double) Player.jumpSpeed * (double) this.gravDir * 0.5); if ((double) num3 < 2.0) num3 = 2f; this.velocity.Y = -(num3 + 0.01f); this.jump = Player.jumpHeight; this.fullRotation = 0.0f; } else { if (this.windPushed && !this.isLockedToATile && ((!this.mount.Active ? 0 : ((double) this.velocity.Y == 0.0 ? 1 : 0)) & (flag2 ? 1 : 0)) == 0) { num2 = (float) Math.Sign(Main.windSpeedCurrent) * 0.06f; if ((double) Math.Abs(Main.windSpeedCurrent) > 0.5) num2 *= 1.37f; if ((double) this.velocity.Y != 0.0) num2 *= 1.5f; if (flag2) { float num4 = num2 * 0.8f; float max = 0.072f; num2 = MathHelper.Clamp(num4, -max, max); } flag3 = true; if (Math.Sign(this.direction) != Math.Sign(num2)) num1 -= Math.Abs(num2) * 40f; } if ((double) this.trackBoost != 0.0) { this.velocity.X += this.trackBoost; this.trackBoost = 0.0f; if ((double) this.velocity.X < 0.0) { if ((double) this.velocity.X < -(double) this.maxRunSpeed) this.velocity.X = -this.maxRunSpeed; } else if ((double) this.velocity.X > (double) this.maxRunSpeed) this.velocity.X = this.maxRunSpeed; } if (this.controlLeft && (double) this.velocity.X > -(double) this.maxRunSpeed) { if (!this.mount.Active || !this.mount.Cart || (double) this.velocity.Y == 0.0) { if ((double) this.velocity.X > (double) this.runSlowdown) this.velocity.X -= this.runSlowdown; this.velocity.X -= this.runAcceleration; } if (this.onWrongGround) { if ((double) this.velocity.X < -(double) this.runSlowdown) this.velocity.X += this.runSlowdown; else this.velocity.X = 0.0f; } if (this.mount.Active && this.mount.Cart && !this.onWrongGround) { if ((double) this.velocity.X < 0.0 & flag1) this.direction = -1; else if (this.itemAnimation <= 0 && (double) this.velocity.Y == 0.0) { SoundEngine.PlaySound(SoundID.Item55, (int) this.position.X + this.width / 2, (int) this.position.Y + this.height / 2); DelegateMethods.Minecart.rotation = this.fullRotation; DelegateMethods.Minecart.rotationOrigin = this.fullRotationOrigin; if ((double) Math.Abs(this.velocity.X) > (double) this.maxRunSpeed * 0.66) { if (Main.rand.Next(2) == 0) Minecart.WheelSparks(this.mount.Delegations.MinecartDust, this.position + this.velocity * 0.66f, this.width, this.height, 1); if (Main.rand.Next(2) == 0) Minecart.WheelSparks(this.mount.Delegations.MinecartDust, this.position + this.velocity * 0.33f, this.width, this.height, 1); if (Main.rand.Next(2) == 0) Minecart.WheelSparks(this.mount.Delegations.MinecartDust, this.position, this.width, this.height, 1); } else if ((double) Math.Abs(this.velocity.X) > (double) this.maxRunSpeed * 0.33) { if (Main.rand.Next(3) != 0) Minecart.WheelSparks(this.mount.Delegations.MinecartDust, this.position + this.velocity * 0.5f, this.width, this.height, 1); if (Main.rand.Next(3) != 0) Minecart.WheelSparks(this.mount.Delegations.MinecartDust, this.position, this.width, this.height, 1); } else Minecart.WheelSparks(this.mount.Delegations.MinecartDust, this.position, this.width, this.height, 1); } } else if (!this.sandStorm && (this.itemAnimation == 0 || this.inventory[this.selectedItem].useTurn) && this.mount.AllowDirectionChange) this.direction = -1; } else if (this.controlRight && (double) this.velocity.X < (double) this.maxRunSpeed) { if (!this.mount.Active || !this.mount.Cart || (double) this.velocity.Y == 0.0) { if ((double) this.velocity.X < -(double) this.runSlowdown) this.velocity.X += this.runSlowdown; this.velocity.X += this.runAcceleration; } if (this.onWrongGround) { if ((double) this.velocity.X > (double) this.runSlowdown) this.velocity.X -= this.runSlowdown; else this.velocity.X = 0.0f; } if (this.mount.Active && this.mount.Cart && !this.onWrongGround) { if ((double) this.velocity.X > 0.0 & flag1) this.direction = 1; else if (this.itemAnimation <= 0 && (double) this.velocity.Y == 0.0) { SoundEngine.PlaySound(SoundID.Item55, (int) this.position.X + this.width / 2, (int) this.position.Y + this.height / 2); DelegateMethods.Minecart.rotation = this.fullRotation; DelegateMethods.Minecart.rotationOrigin = this.fullRotationOrigin; if ((double) Math.Abs(this.velocity.X) > (double) this.maxRunSpeed * 0.66) { if (Main.rand.Next(2) == 0) Minecart.WheelSparks(this.mount.Delegations.MinecartDust, this.position + this.velocity * 0.66f, this.width, this.height, 1); if (Main.rand.Next(2) == 0) Minecart.WheelSparks(this.mount.Delegations.MinecartDust, this.position + this.velocity * 0.33f, this.width, this.height, 1); if (Main.rand.Next(2) == 0) Minecart.WheelSparks(this.mount.Delegations.MinecartDust, this.position, this.width, this.height, 1); } else if ((double) Math.Abs(this.velocity.X) > (double) this.maxRunSpeed * 0.33) { if (Main.rand.Next(3) != 0) Minecart.WheelSparks(this.mount.Delegations.MinecartDust, this.position + this.velocity * 0.5f, this.width, this.height, 1); if (Main.rand.Next(3) != 0) Minecart.WheelSparks(this.mount.Delegations.MinecartDust, this.position, this.width, this.height, 1); } else Minecart.WheelSparks(this.mount.Delegations.MinecartDust, this.position, this.width, this.height, 1); } } else if (!this.sandStorm && (this.itemAnimation == 0 || this.inventory[this.selectedItem].useTurn) && this.mount.AllowDirectionChange) this.direction = 1; } else if (this.controlLeft && (double) this.velocity.X > -(double) this.accRunSpeed && this.dashDelay >= 0) { if (this.mount.Active && this.mount.Cart) { if ((double) this.velocity.X < 0.0) this.direction = -1; } else if ((this.itemAnimation == 0 || this.inventory[this.selectedItem].useTurn) && this.mount.AllowDirectionChange) this.direction = -1; if ((double) this.velocity.Y == 0.0 || this.wingsLogic > 0 || this.mount.CanFly()) { if ((double) this.velocity.X > (double) this.runSlowdown) this.velocity.X -= this.runSlowdown; this.velocity.X -= this.runAcceleration * 0.2f; if (this.wingsLogic > 0) this.velocity.X -= this.runAcceleration * 0.2f; } if (this.onWrongGround) { if ((double) this.velocity.X < (double) this.runSlowdown) this.velocity.X += this.runSlowdown; else this.velocity.X = 0.0f; } if ((double) this.velocity.X < -(double) num1 && (double) this.velocity.Y == 0.0 && !this.mount.Active) this.SpawnFastRunParticles(); } else if (this.controlRight && (double) this.velocity.X < (double) this.accRunSpeed && this.dashDelay >= 0) { if (this.mount.Active && this.mount.Cart) { if ((double) this.velocity.X > 0.0) this.direction = -1; } else if ((this.itemAnimation == 0 || this.inventory[this.selectedItem].useTurn) && this.mount.AllowDirectionChange) this.direction = 1; if ((double) this.velocity.Y == 0.0 || this.wingsLogic > 0 || this.mount.CanFly()) { if ((double) this.velocity.X < -(double) this.runSlowdown) this.velocity.X += this.runSlowdown; this.velocity.X += this.runAcceleration * 0.2f; if (this.wingsLogic > 0) this.velocity.X += this.runAcceleration * 0.2f; } if (this.onWrongGround) { if ((double) this.velocity.X > (double) this.runSlowdown) this.velocity.X -= this.runSlowdown; else this.velocity.X = 0.0f; } if ((double) this.velocity.X > (double) num1 && (double) this.velocity.Y == 0.0 && !this.mount.Active) this.SpawnFastRunParticles(); } else if (this.mount.Active && this.mount.Cart && (double) Math.Abs(this.velocity.X) >= 1.0) { if (this.onWrongGround) { if ((double) this.velocity.X > 0.0) { if ((double) this.velocity.X > (double) this.runSlowdown) this.velocity.X -= this.runSlowdown; else this.velocity.X = 0.0f; } else if ((double) this.velocity.X < 0.0) { if ((double) this.velocity.X < -(double) this.runSlowdown) this.velocity.X += this.runSlowdown; else this.velocity.X = 0.0f; } } if ((double) this.velocity.X > (double) this.maxRunSpeed) this.velocity.X = this.maxRunSpeed; if ((double) this.velocity.X < -(double) this.maxRunSpeed) this.velocity.X = -this.maxRunSpeed; } else if ((double) this.velocity.Y == 0.0) { if ((double) this.velocity.X > (double) this.runSlowdown) this.velocity.X -= this.runSlowdown; else if ((double) this.velocity.X < -(double) this.runSlowdown) this.velocity.X += this.runSlowdown; else this.velocity.X = 0.0f; } else if (!this.PortalPhysicsEnabled) { if ((double) this.velocity.X > (double) this.runSlowdown * 0.5) this.velocity.X -= this.runSlowdown * 0.5f; else if ((double) this.velocity.X < -(double) this.runSlowdown * 0.5) this.velocity.X += this.runSlowdown * 0.5f; else this.velocity.X = 0.0f; } if (flag3) { if ((double) num2 < 0.0 && (double) this.velocity.X > (double) num2) { this.velocity.X += num2; if ((double) this.velocity.X < (double) num2) this.velocity.X = num2; } if ((double) num2 > 0.0 && (double) this.velocity.X < (double) num2) { this.velocity.X += num2; if ((double) this.velocity.X > (double) num2) this.velocity.X = num2; } } bool flag4 = this.mount.Type == 40 || this.mount.Type == 41 || this.mount.Type == 42; if (this.mount.Active && ((this.mount.Type == 10 ? 1 : (this.mount.Type == 47 ? 1 : 0)) | (flag4 ? 1 : 0)) != 0 && (double) Math.Abs(this.velocity.X) > (double) this.mount.DashSpeed - (double) this.mount.RunSpeed / 2.0) { Microsoft.Xna.Framework.Rectangle rect = this.getRect(); if (this.direction == 1) rect.Offset(this.width - 1, 0); rect.Width = 2; rect.Inflate(6, 12); int num5 = 60; if (flag4) num5 = 30; float Damage = (float) num5 * this.meleeDamage; float Knockback = 10f; if (flag4) Knockback = 7f; int NPCImmuneTime = 30; int PlayerImmuneTime = 6; this.CollideWithNPCs(rect, Damage, Knockback, NPCImmuneTime, PlayerImmuneTime); } if (this.mount.Active && this.mount.Type == 44 && (double) Math.Abs(this.velocity.X) > (double) this.mount.DashSpeed - (double) this.mount.RunSpeed / 4.0) { Microsoft.Xna.Framework.Rectangle rect = this.getRect(); if (this.direction == 1) rect.Offset(this.width - 1, 0); rect.Width = 2; rect.Inflate(6, 12); float Damage = 100f * this.minionDamage; float Knockback = 12f; int NPCImmuneTime = 30; int PlayerImmuneTime = 6; this.CollideWithNPCs(rect, Damage, Knockback, NPCImmuneTime, PlayerImmuneTime); } if (this.mount.Active && this.mount.Type == 45 && (double) Math.Abs(this.velocity.X) > (double) this.mount.DashSpeed * 0.899999976158142) { Microsoft.Xna.Framework.Rectangle rect = this.getRect(); if (this.direction == 1) rect.Offset(this.width - 1, 0); rect.Width = 2; rect.Inflate(6, 12); float Damage = 120f * this.minionDamage; float Knockback = 12f; int NPCImmuneTime = 30; int PlayerImmuneTime = 6; this.CollideWithNPCs(rect, Damage, Knockback, NPCImmuneTime, PlayerImmuneTime); } if (this.mount.Active && this.mount.Type == 14 && (double) Math.Abs(this.velocity.X) > (double) this.mount.RunSpeed / 2.0) { Microsoft.Xna.Framework.Rectangle rect = this.getRect(); if (this.direction == 1) rect.Offset(this.width - 1, 0); rect.Width = 2; rect.Inflate(6, 12); float Damage = 90f * this.minionDamage; float Knockback = 10f; int NPCImmuneTime = 30; int PlayerImmuneTime = 6; this.CollideWithNPCs(rect, Damage, Knockback, NPCImmuneTime, PlayerImmuneTime); } if (this.mount.Active && this.mount.Type == 17 && (double) Math.Abs(this.velocity.X) > (double) this.mount.RunSpeed / 2.0) { Microsoft.Xna.Framework.Rectangle rect = this.getRect(); if (this.direction == 1) rect.Offset(this.width - 1, 0); rect.Width = 2; rect.Inflate(6, 12); float Damage = 40f; float Knockback = 10f; int NPCImmuneTime = 30; int PlayerImmuneTime = 12; this.CollideWithNPCs(rect, Damage, Knockback, NPCImmuneTime, PlayerImmuneTime); } this.TryUsingDiggerCart(); if (this.HeldItem.type != 4049 || this.whoAmI != Main.myPlayer) return; this.MowTheLawn(); } } private void TryUsingDiggerCart() { if (this.whoAmI != Main.myPlayer || !this.mount.Active || this.mount.Type != 39 || (double) this.velocity.Y != 0.0) return; int num1 = 12; int num2 = 20; Vector2 vector2_1 = new Vector2(0.0f, this.gravDir * 10f); Vector2 vector2_2 = this.RotatedRelativePoint(this.Center + new Vector2((float) (num1 * this.direction), this.gravDir * (float) num2)) + vector2_1; Tile tileSafely = Framing.GetTileSafely(vector2_2); if (!tileSafely.active() || tileSafely.type != (ushort) 314) vector2_2 = this.RotatedRelativePoint(this.Center + new Vector2((float) (num1 * this.direction) * 0.5f, this.gravDir * (float) num2)) + vector2_1; int digDirectionY = this.controlDown.ToInt() - this.controlUp.ToInt(); if (this.controlUp.ToInt() + this.controlDown.ToInt() + this.controlLeft.ToInt() + this.controlRight.ToInt() <= 0) return; MinecartDiggerHelper.Instance.TryDigging(this, vector2_2, this.direction, digDirectionY); } private void SpawnFastRunParticles() { int num = 0; if ((double) this.gravDir == -1.0) num -= this.height; if (this.runSoundDelay == 0 && (double) this.velocity.Y == 0.0) { SoundEngine.PlaySound(this.hermesStepSound.SoundType, (int) this.position.X, (int) this.position.Y, this.hermesStepSound.SoundStyle); this.runSoundDelay = this.hermesStepSound.IntendedCooldown; } if (this.wings == 3) { int index1 = Dust.NewDust(new Vector2(this.position.X - 4f, this.position.Y + (float) this.height + (float) num), this.width + 8, 4, 186, (float) (-(double) this.velocity.X * 0.5), this.velocity.Y * 0.5f, 50, Scale: 1.5f); Main.dust[index1].velocity *= 0.025f; Main.dust[index1].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); int index2 = Dust.NewDust(new Vector2(this.position.X - 4f, this.position.Y + (float) this.height + (float) num), this.width + 8, 4, 186, (float) (-(double) this.velocity.X * 0.5), this.velocity.Y * 0.5f, 50, Scale: 1.5f); Main.dust[index2].velocity *= 0.2f; Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } else if (this.sailDash) { for (int index3 = 0; index3 < 4; ++index3) { int index4 = Dust.NewDust(new Vector2(this.position.X - 4f, this.position.Y), this.width + 8, this.height, 253, (float) (-(double) this.velocity.X * 0.5), this.velocity.Y * 0.5f, 100, Scale: 1.5f); Main.dust[index4].noGravity = true; Main.dust[index4].velocity.X *= 0.2f; Main.dust[index4].velocity.Y *= 0.2f; Main.dust[index4].shader = GameShaders.Armor.GetSecondaryShader(this.cShoe, this); Main.dust[index4].scale += (float) Main.rand.Next(-5, 3) * 0.1f; Vector2 vector2 = new Vector2((float) Main.rand.Next(-100, 101), (float) Main.rand.Next(-100, 101)); vector2.Normalize(); vector2 *= (float) Main.rand.Next(81) * 0.1f; } } else if (this.desertDash) { Dust dust = Dust.NewDustDirect(new Vector2(this.position.X - 4f, this.position.Y + (float) this.height + (float) num), this.width + 8, 4, 32, (float) (-(double) this.velocity.X * 0.5), this.velocity.Y * 0.5f); dust.velocity *= 0.2f; dust.velocity.Y -= this.gravDir * 2f; dust.shader = GameShaders.Armor.GetSecondaryShader(this.cShoe, this); } else if (this.coldDash) { for (int index5 = 0; index5 < 2; ++index5) { int index6 = index5 != 0 ? Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2), this.position.Y + (float) this.height + this.gfxOffY), this.width / 2, 6, 76, Scale: 1.35f) : Dust.NewDust(new Vector2(this.position.X, this.position.Y + (float) this.height + this.gfxOffY), this.width / 2, 6, 76, Scale: 1.35f); Main.dust[index6].scale *= (float) (1.0 + (double) Main.rand.Next(20, 40) * 0.00999999977648258); Main.dust[index6].noGravity = true; Main.dust[index6].noLight = true; Main.dust[index6].velocity *= 1f / 1000f; Main.dust[index6].velocity.Y -= 3f / 1000f; Main.dust[index6].shader = GameShaders.Armor.GetSecondaryShader(this.cShoe, this); } } else if (this.fairyBoots) { int Type = (int) Main.rand.NextFromList((short) 61, (short) 61, (short) 61, (short) 242, (short) 64, (short) 63); int Alpha = 0; for (int index7 = 1; index7 < 3; ++index7) { float Scale = 1.5f; if (index7 == 2) Scale = 1f; int index8 = Dust.NewDust(new Vector2(this.position.X - 4f, this.position.Y + (float) this.height + (float) num), this.width + 8, 4, Type, (float) (-(double) this.velocity.X * 0.5), this.velocity.Y * 0.5f, Alpha, Scale: Scale); Main.dust[index8].velocity *= 1.5f; if (index7 == 2) Main.dust[index8].position += Main.dust[index8].velocity; Main.dust[index8].noGravity = true; Main.dust[index8].noLightEmittence = true; Main.dust[index8].shader = GameShaders.Armor.GetSecondaryShader(this.cShoe, this); } } else { int index = Dust.NewDust(new Vector2(this.position.X - 4f, this.position.Y + (float) this.height + (float) num), this.width + 8, 4, 16, (float) (-(double) this.velocity.X * 0.5), this.velocity.Y * 0.5f, 50, Scale: 1.5f); Main.dust[index].velocity.X *= 0.2f; Main.dust[index].velocity.Y *= 0.2f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cShoe, this); } } private void MowTheLawn() { if (this.miscCounter % 2 != 0 || (double) this.velocity.Y != 0.0 || this.grappling[0] != -1 || this.itemAnimation < 1) return; Vector2 vector2 = this.Center + new Vector2((float) (this.direction * 38), (float) (this.height / 2 + 4) * this.gravDir); float num = (float) (1.0 - (double) this.itemAnimation / (double) this.itemAnimationMax) * 2f; float amount = (double) num >= 1.0 ? num - 1f : 1f - num; Dust dust = Dust.NewDustDirect(Vector2.Lerp(vector2 + new Vector2((float) (this.direction * -16), this.gravDir * -4f), vector2 + new Vector2((float) (this.direction * -6), this.gravDir * -4f), amount), 0, 0, 31, SpeedY: ((float) (-(double) this.gravDir * 0.25)), Alpha: ((int) sbyte.MaxValue)); dust.scale = 0.9f; dust.position -= new Vector2(4f); if ((double) dust.velocity.Y > 0.0) dust.velocity.Y *= -1f; dust.velocity *= 0.25f; Microsoft.Xna.Framework.Rectangle itemRectangle = Utils.CenteredRectangle(vector2, new Vector2(8f, 20f)); if ((double) this.velocity.X * (double) this.direction > 0.0 || (double) this.velocity.Y * (double) this.gravDir > 0.0) { Microsoft.Xna.Framework.Rectangle myRect = itemRectangle; myRect.Height -= 4; myRect.Y += 2; float Damage = 8f; float Knockback = 2f; int NPCImmuneTime = 12; int PlayerImmuneTime = 6; this.CollideWithNPCs(myRect, Damage, Knockback, NPCImmuneTime, PlayerImmuneTime); } itemRectangle.X -= this.direction * 10; List tileCutIgnoreList = Player.ItemCheck_GetTileCutIgnoreList(this.HeldItem); Player.ItemCheck_CutTiles(this.HeldItem, itemRectangle, tileCutIgnoreList); this.MowGrassTile(vector2); if (WorldGen.SolidTile(Framing.GetTileSafely(vector2.ToTileCoordinates()))) return; this.MowGrassTile(vector2 + new Vector2(0.0f, 16f * this.gravDir)); } private void MowGrassTile(Vector2 thePos) { Point tileCoordinates = thePos.ToTileCoordinates(); Tile tileCache = Main.tile[tileCoordinates.X, tileCoordinates.Y]; if (tileCache == null || !WorldGen.CanKillTile(tileCoordinates.X, tileCoordinates.Y, WorldGen.SpecialKillTileContext.MowingTheGrass)) return; ushort num = 0; switch (tileCache.type) { case 2: num = (ushort) 477; break; case 109: num = (ushort) 492; break; } if (num == (ushort) 0) return; int tileDustAmount = WorldGen.KillTile_GetTileDustAmount(true, tileCache); for (int index = 0; index < tileDustAmount; ++index) WorldGen.KillTile_MakeTileDust(tileCoordinates.X, tileCoordinates.Y, tileCache); tileCache.type = num; if (Main.netMode != 1) return; NetMessage.SendTileSquare(-1, tileCoordinates.X, tileCoordinates.Y, 1); } private int CollideWithNPCs( Microsoft.Xna.Framework.Rectangle myRect, float Damage, float Knockback, int NPCImmuneTime, int PlayerImmuneTime) { int num = 0; for (int index = 0; index < 200; ++index) { NPC npc = Main.npc[index]; if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.immune[this.whoAmI] == 0 && this.CanNPCBeHitByPlayerOrPlayerProjectile(npc)) { Microsoft.Xna.Framework.Rectangle rect = npc.getRect(); if (myRect.Intersects(rect) && (npc.noTileCollide || Collision.CanHit(this.position, this.width, this.height, npc.position, npc.width, npc.height))) { int direction = this.direction; if ((double) this.velocity.X < 0.0) direction = -1; if ((double) this.velocity.X > 0.0) direction = 1; if (this.whoAmI == Main.myPlayer) this.ApplyDamageToNPC(npc, (int) Damage, Knockback, direction, false); npc.immune[this.whoAmI] = NPCImmuneTime; this.GiveImmuneTimeForCollisionAttack(PlayerImmuneTime); ++num; break; } } } return num; } public void ApplyDamageToNPC(NPC npc, int damage, float knockback, int direction, bool crit) { int num1 = Item.NPCtoBanner(npc.BannerID()); if (num1 > 0 && this.HasNPCBannerBuff(num1)) damage = !Main.expertMode ? (int) ((double) damage * (double) ItemID.Sets.BannerStrength[Item.BannerToItem(num1)].NormalDamageDealt) : (int) ((double) damage * (double) ItemID.Sets.BannerStrength[Item.BannerToItem(num1)].ExpertDamageDealt); this.OnHit(npc.Center.X, npc.Center.Y, (Entity) npc); if (this.armorPenetration > 0) damage += npc.checkArmorPenetration(this.armorPenetration); int dmg = (int) npc.StrikeNPC(damage, knockback, direction, crit); if (this.accDreamCatcher) this.addDPS(dmg); if (Main.netMode != 0) NetMessage.SendData(28, number: npc.whoAmI, number2: ((float) damage), number3: knockback, number4: ((float) direction), number5: crit.ToInt()); int num2 = Item.NPCtoBanner(npc.BannerID()); if (num2 < 0) return; this.lastCreatureHit = num2; } public bool SlimeDontHyperJump => this.mount.Active && this.mount.IsConsideredASlimeMount && this.wetSlime > (byte) 0 && !this.controlJump; public void GiveImmuneTimeForCollisionAttack(int time) { if (this._timeSinceLastImmuneGet <= 20) ++this._immuneStrikes; else this._immuneStrikes = 1; this._timeSinceLastImmuneGet = 0; if (this._immuneStrikes >= 3 || this.immune && this.immuneTime > time) return; this.immune = true; this.immuneNoBlink = true; this.immuneTime = time; } public bool CanNPCBeHitByPlayerOrPlayerProjectile(NPC npc) => !this.dontHurtCritters || !NPCID.Sets.CountsAsCritter[npc.type]; public void JumpMovement() { if (this.mount.Active && this.mount.IsConsideredASlimeMount && this.wetSlime == (byte) 0 && (double) this.velocity.Y > 0.0) { Microsoft.Xna.Framework.Rectangle rect1 = this.getRect(); rect1.Offset(0, this.height - 1); rect1.Height = 2; rect1.Inflate(12, 6); for (int index = 0; index < 200; ++index) { NPC npc = Main.npc[index]; if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.immune[this.whoAmI] == 0 && this.CanNPCBeHitByPlayerOrPlayerProjectile(npc)) { Microsoft.Xna.Framework.Rectangle rect2 = npc.getRect(); if (rect1.Intersects(rect2) && (npc.noTileCollide || Collision.CanHit(this.position, this.width, this.height, npc.position, npc.width, npc.height))) { float num = 40f * this.minionDamage; float knockback = 5f; int direction = this.direction; if ((double) this.velocity.X < 0.0) direction = -1; if ((double) this.velocity.X > 0.0) direction = 1; if (this.whoAmI == Main.myPlayer) this.ApplyDamageToNPC(npc, (int) num, knockback, direction, false); npc.immune[this.whoAmI] = 10; this.velocity.Y = -10f; this.GiveImmuneTimeForCollisionAttack(6); break; } } } } if (this.mount.Active && this.mount.Type == 17 && (double) this.velocity.Y > 0.0) { Microsoft.Xna.Framework.Rectangle rect3 = this.getRect(); rect3.Offset(0, this.height - 1); rect3.Height = 2; rect3.Inflate(12, 6); for (int index = 0; index < 200; ++index) { NPC npc = Main.npc[index]; if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.immune[this.whoAmI] == 0 && this.CanNPCBeHitByPlayerOrPlayerProjectile(npc)) { Microsoft.Xna.Framework.Rectangle rect4 = npc.getRect(); if (rect3.Intersects(rect4) && (npc.noTileCollide || Collision.CanHit(this.position, this.width, this.height, npc.position, npc.width, npc.height))) { float num = 40f; float knockback = 5f; int direction = this.direction; if ((double) this.velocity.X < 0.0) direction = -1; if ((double) this.velocity.X > 0.0) direction = 1; if (this.whoAmI == Main.myPlayer) this.ApplyDamageToNPC(npc, (int) num, knockback, direction, false); npc.immune[this.whoAmI] = 12; this.GiveImmuneTimeForCollisionAttack(12); break; } } } } if (this.controlJump) { if (this.sliding) this.autoJump = false; bool flag1 = false; bool flag2 = this.wet && this.accFlipper; bool flag3 = !this.mount.Active || !this.mount.Cart; if (this.mount.Active && this.mount.IsConsideredASlimeMount && this.wetSlime > (byte) 0) { this.wetSlime = (byte) 0; flag1 = true; } if (this.mount.Active && this.mount.Type == 43 && this.releaseJump && (double) this.velocity.Y != 0.0) this.isPerformingPogostickTricks = true; if (this.jump > 0) { if ((double) this.velocity.Y == 0.0) { this.jump = 0; } else { this.velocity.Y = -Player.jumpSpeed * this.gravDir; if (this.merman && (!this.mount.Active || !this.mount.Cart)) { if (this.swimTime <= 10) this.swimTime = 30; } else --this.jump; } } else if ((((this.sliding ? 1 : ((double) this.velocity.Y == 0.0 ? 1 : 0)) | (flag1 ? 1 : 0)) != 0 || this.canJumpAgain_Cloud || this.canJumpAgain_Sandstorm || this.canJumpAgain_Blizzard || this.canJumpAgain_Fart || this.canJumpAgain_Sail || this.canJumpAgain_Unicorn || this.canJumpAgain_Santank || this.canJumpAgain_WallOfFleshGoat || this.canJumpAgain_Basilisk || flag2 & flag3) && (this.releaseJump || this.autoJump && ((double) this.velocity.Y == 0.0 || this.sliding))) { if (this.mount.Active && MountID.Sets.Cart[this.mount.Type]) this.position.Y -= 1f / 1000f; if (this.sliding || (double) this.velocity.Y == 0.0) this.justJumped = true; bool flag4 = false; if (this.wet && this.accFlipper) { if (this.swimTime == 0) this.swimTime = 30; flag4 = true; } bool flag5 = false; bool flag6 = false; bool flag7 = false; bool flag8 = false; bool flag9 = false; bool flag10 = false; bool flag11 = false; bool flag12 = false; if (!flag2 && !flag1) { if (this.canJumpAgain_Basilisk) { flag12 = true; this.canJumpAgain_Basilisk = false; } if (this.canJumpAgain_WallOfFleshGoat) { flag11 = true; this.canJumpAgain_WallOfFleshGoat = false; } else if (this.canJumpAgain_Santank) { flag10 = true; this.canJumpAgain_Santank = false; } else if (this.canJumpAgain_Unicorn) { flag9 = true; this.canJumpAgain_Unicorn = false; } else if (this.canJumpAgain_Sandstorm) { flag5 = true; this.canJumpAgain_Sandstorm = false; } else if (this.canJumpAgain_Blizzard) { flag6 = true; this.canJumpAgain_Blizzard = false; } else if (this.canJumpAgain_Fart) { this.canJumpAgain_Fart = false; flag7 = true; } else if (this.canJumpAgain_Sail) { this.canJumpAgain_Sail = false; flag8 = true; } else this.canJumpAgain_Cloud = false; } this.canRocket = false; this.rocketRelease = false; if (((double) this.velocity.Y == 0.0 || this.sliding ? 1 : (!this.autoJump ? 0 : (this.justJumped ? 1 : 0))) != 0) this.RefreshDoubleJumps(); if ((((double) this.velocity.Y == 0.0 | flag4 ? 1 : (this.sliding ? 1 : 0)) | (flag1 ? 1 : 0)) != 0) { if (this.mount.Active && this.mount.Type == 43) SoundEngine.PlaySound(SoundID.Item168, this.Center); this.velocity.Y = -Player.jumpSpeed * this.gravDir; this.jump = Player.jumpHeight; if (this.portableStoolInfo.IsInUse) { this.position.Y -= (float) this.portableStoolInfo.HeightBoost; this.gfxOffY += (float) this.portableStoolInfo.HeightBoost; } if (this.sliding) this.velocity.X = (float) (3 * -this.slideDir); } else if (flag5) { this.isPerformingJump_Sandstorm = true; int height = this.height; double gravDir = (double) this.gravDir; SoundEngine.PlaySound(16, (int) this.position.X, (int) this.position.Y); this.velocity.Y = -Player.jumpSpeed * this.gravDir; this.jump = Player.jumpHeight * 3; } else if (flag6) { this.isPerformingJump_Blizzard = true; int height = this.height; double gravDir = (double) this.gravDir; SoundEngine.PlaySound(16, (int) this.position.X, (int) this.position.Y); this.velocity.Y = -Player.jumpSpeed * this.gravDir; this.jump = (int) ((double) Player.jumpHeight * 1.5); } else if (flag8) { this.isPerformingJump_Sail = true; int num = this.height; if ((double) this.gravDir == -1.0) num = 0; SoundEngine.PlaySound(16, (int) this.position.X, (int) this.position.Y); this.velocity.Y = -Player.jumpSpeed * this.gravDir; this.jump = (int) ((double) Player.jumpHeight * 1.25); for (int index1 = 0; index1 < 30; ++index1) { int index2 = Dust.NewDust(new Vector2(this.position.X, this.position.Y + (float) num), this.width, 12, 253, this.velocity.X * 0.3f, this.velocity.Y * 0.3f, 100, Scale: 1.5f); if (index1 % 2 == 0) Main.dust[index2].velocity.X += (float) Main.rand.Next(30, 71) * 0.1f; else Main.dust[index2].velocity.X -= (float) Main.rand.Next(30, 71) * 0.1f; Main.dust[index2].velocity.Y += (float) Main.rand.Next(-10, 31) * 0.1f; Main.dust[index2].noGravity = true; Main.dust[index2].scale += (float) Main.rand.Next(-10, 41) * 0.01f; Main.dust[index2].velocity *= Main.dust[index2].scale * 0.7f; Vector2 vector2 = new Vector2((float) Main.rand.Next(-100, 101), (float) Main.rand.Next(-100, 101)); vector2.Normalize(); vector2 *= (float) Main.rand.Next(81) * 0.1f; } } else if (flag7) { this.isPerformingJump_Fart = true; int num = this.height; if ((double) this.gravDir == -1.0) num = 0; SoundEngine.PlaySound(SoundID.Item16, this.position); this.velocity.Y = -Player.jumpSpeed * this.gravDir; this.jump = Player.jumpHeight * 2; for (int index3 = 0; index3 < 10; ++index3) { int index4 = Dust.NewDust(new Vector2(this.position.X - 34f, (float) ((double) this.position.Y + (double) num - 16.0)), 102, 32, 188, (float) (-(double) this.velocity.X * 0.5), this.velocity.Y * 0.5f, 100, Scale: 1.5f); Main.dust[index4].velocity.X = (float) ((double) Main.dust[index4].velocity.X * 0.5 - (double) this.velocity.X * 0.100000001490116); Main.dust[index4].velocity.Y = (float) ((double) Main.dust[index4].velocity.Y * 0.5 - (double) this.velocity.Y * 0.300000011920929); } int index5 = Gore.NewGore(new Vector2((float) ((double) this.position.X + (double) (this.width / 2) - 16.0), (float) ((double) this.position.Y + (double) num - 16.0)), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(435, 438)); Main.gore[index5].velocity.X = (float) ((double) Main.gore[index5].velocity.X * 0.100000001490116 - (double) this.velocity.X * 0.100000001490116); Main.gore[index5].velocity.Y = (float) ((double) Main.gore[index5].velocity.Y * 0.100000001490116 - (double) this.velocity.Y * 0.0500000007450581); int index6 = Gore.NewGore(new Vector2(this.position.X - 36f, (float) ((double) this.position.Y + (double) num - 16.0)), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(435, 438)); Main.gore[index6].velocity.X = (float) ((double) Main.gore[index6].velocity.X * 0.100000001490116 - (double) this.velocity.X * 0.100000001490116); Main.gore[index6].velocity.Y = (float) ((double) Main.gore[index6].velocity.Y * 0.100000001490116 - (double) this.velocity.Y * 0.0500000007450581); int index7 = Gore.NewGore(new Vector2((float) ((double) this.position.X + (double) this.width + 4.0), (float) ((double) this.position.Y + (double) num - 16.0)), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(435, 438)); Main.gore[index7].velocity.X = (float) ((double) Main.gore[index7].velocity.X * 0.100000001490116 - (double) this.velocity.X * 0.100000001490116); Main.gore[index7].velocity.Y = (float) ((double) Main.gore[index7].velocity.Y * 0.100000001490116 - (double) this.velocity.Y * 0.0500000007450581); } else if (flag9) { this.isPerformingJump_Unicorn = true; int height = this.height; double gravDir = (double) this.gravDir; SoundEngine.PlaySound(16, (int) this.position.X, (int) this.position.Y); this.velocity.Y = -Player.jumpSpeed * this.gravDir; this.jump = Player.jumpHeight * 2; Vector2 center = this.Center; Vector2 vector2_1 = new Vector2(50f, 20f); float num1 = 6.283185f * Main.rand.NextFloat(); for (int index = 0; index < 5; ++index) { for (float num2 = 0.0f; (double) num2 < 14.0; ++num2) { Dust dust = Main.dust[Dust.NewDust(center, 0, 0, Utils.SelectRandom(Main.rand, 176, 177, 179))]; Vector2 vector2_2 = Vector2.UnitY.RotatedBy((double) num2 * 6.28318548202515 / 14.0 + (double) num1) * (0.2f * (float) index); dust.position = center + vector2_2 * vector2_1; dust.velocity = vector2_2 + new Vector2(0.0f, this.gravDir * 4f); dust.noGravity = true; dust.scale = (float) (1.0 + (double) Main.rand.NextFloat() * 0.800000011920929); dust.fadeIn = Main.rand.NextFloat() * 2f; dust.shader = GameShaders.Armor.GetSecondaryShader(this.cMount, this); } } } else if (flag11) { this.isPerformingJump_WallOfFleshGoat = true; int height = this.height; double gravDir = (double) this.gravDir; SoundEngine.PlaySound(16, (int) this.position.X, (int) this.position.Y); this.velocity.Y = -Player.jumpSpeed * this.gravDir; this.jump = Player.jumpHeight * 2; Vector2 center = this.Center; Vector2 vector2_3 = new Vector2(50f, 20f); float num3 = 6.283185f * Main.rand.NextFloat(); for (int index = 0; index < 5; ++index) { for (float num4 = 0.0f; (double) num4 < 14.0; ++num4) { Dust dust = Main.dust[Dust.NewDust(center, 0, 0, 6)]; Vector2 vector2_4 = Vector2.UnitY.RotatedBy((double) num4 * 6.28318548202515 / 14.0 + (double) num3) * (0.2f * (float) index); dust.position = center + vector2_4 * vector2_3; dust.velocity = vector2_4 + new Vector2(0.0f, this.gravDir * 4f); dust.noGravity = true; dust.scale = (float) (1.0 + (double) Main.rand.NextFloat() * 0.800000011920929); dust.fadeIn = Main.rand.NextFloat() * 2f; dust.shader = GameShaders.Armor.GetSecondaryShader(this.cMount, this); } } } else if (flag12) { this.isPerformingJump_Basilisk = true; int height = this.height; double gravDir = (double) this.gravDir; SoundEngine.PlaySound(16, (int) this.position.X, (int) this.position.Y); this.velocity.Y = -Player.jumpSpeed * this.gravDir; this.jump = (int) ((double) Player.jumpHeight * 0.75); Vector2 center = this.Center; Vector2 vector2_5 = new Vector2(50f, 20f); float num5 = 6.283185f * Main.rand.NextFloat(); for (int index = 0; index < 5; ++index) { for (float num6 = 0.0f; (double) num6 < 14.0; ++num6) { Dust dust = Main.dust[Dust.NewDust(center, 0, 0, 31)]; Vector2 vector2_6 = Vector2.UnitY.RotatedBy((double) num6 * 6.28318548202515 / 14.0 + (double) num5) * (0.2f * (float) index); dust.position = center + vector2_6 * vector2_5; dust.velocity = vector2_6 + new Vector2(0.0f, this.gravDir * 4f); dust.noGravity = true; dust.scale = (float) (1.0 + (double) Main.rand.NextFloat() * 0.800000011920929); dust.fadeIn = Main.rand.NextFloat() * 2f; dust.shader = GameShaders.Armor.GetSecondaryShader(this.cMount, this); } } } else if (flag10) { this.isPerformingJump_Santank = true; int num = this.height; if ((double) this.gravDir == -1.0) num = 0; SoundEngine.PlaySound(16, (int) this.position.X, (int) this.position.Y); this.velocity.Y = -Player.jumpSpeed * this.gravDir; this.jump = Player.jumpHeight * 2; for (int index8 = 0; index8 < 15; ++index8) { int index9 = Dust.NewDust(new Vector2(this.position.X - 34f, (float) ((double) this.position.Y + (double) num - 16.0)), 102, 32, 4, (float) (-(double) this.velocity.X * 0.5), this.velocity.Y * 0.5f, 100, new Color(250, 230, 230, 150), 1.5f); Main.dust[index9].velocity.X = (float) ((double) Main.dust[index9].velocity.X * 0.5 - (double) this.velocity.X * 0.100000001490116); Main.dust[index9].velocity.Y = (float) ((double) Main.dust[index9].velocity.Y * 0.5 - (double) this.velocity.Y * 0.300000011920929); Main.dust[index9].noGravity = true; int index10 = Dust.NewDust(new Vector2(this.position.X - 34f, (float) ((double) this.position.Y + (double) num - 16.0)), 102, 32, 6, (float) (-(double) this.velocity.X * 0.5), this.velocity.Y * 0.5f, 20, Scale: 1.5f); --Main.dust[index10].velocity.Y; if (index8 % 2 == 0) Main.dust[index10].fadeIn = Main.rand.NextFloat() * 2f; } float y = this.Bottom.Y - 22f; for (int index11 = 0; index11 < 3; ++index11) { Vector2 Position = this.Center; switch (index11) { case 0: Position = new Vector2(this.Center.X - 16f, y); break; case 1: Position = new Vector2(this.position.X - 36f, y); break; case 2: Position = new Vector2(this.Right.X + 4f, y); break; } int index12 = Gore.NewGore(Position, new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(61, 63)); Main.gore[index12].velocity *= 0.1f; Main.gore[index12].velocity.X -= this.velocity.X * 0.1f; Main.gore[index12].velocity.Y -= this.velocity.Y * 0.05f; Main.gore[index12].velocity += Main.rand.NextVector2Circular(1f, 1f) * 0.5f; } } else { this.isPerformingJump_Cloud = true; int num = this.height; if ((double) this.gravDir == -1.0) num = 0; SoundEngine.PlaySound(16, (int) this.position.X, (int) this.position.Y); this.velocity.Y = -Player.jumpSpeed * this.gravDir; this.jump = (int) ((double) Player.jumpHeight * 0.75); for (int index13 = 0; index13 < 10; ++index13) { int index14 = Dust.NewDust(new Vector2(this.position.X - 34f, (float) ((double) this.position.Y + (double) num - 16.0)), 102, 32, 16, (float) (-(double) this.velocity.X * 0.5), this.velocity.Y * 0.5f, 100, Scale: 1.5f); Main.dust[index14].velocity.X = (float) ((double) Main.dust[index14].velocity.X * 0.5 - (double) this.velocity.X * 0.100000001490116); Main.dust[index14].velocity.Y = (float) ((double) Main.dust[index14].velocity.Y * 0.5 - (double) this.velocity.Y * 0.300000011920929); } int index15 = Gore.NewGore(new Vector2((float) ((double) this.position.X + (double) (this.width / 2) - 16.0), (float) ((double) this.position.Y + (double) num - 16.0)), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(11, 14)); Main.gore[index15].velocity.X = (float) ((double) Main.gore[index15].velocity.X * 0.100000001490116 - (double) this.velocity.X * 0.100000001490116); Main.gore[index15].velocity.Y = (float) ((double) Main.gore[index15].velocity.Y * 0.100000001490116 - (double) this.velocity.Y * 0.0500000007450581); int index16 = Gore.NewGore(new Vector2(this.position.X - 36f, (float) ((double) this.position.Y + (double) num - 16.0)), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(11, 14)); Main.gore[index16].velocity.X = (float) ((double) Main.gore[index16].velocity.X * 0.100000001490116 - (double) this.velocity.X * 0.100000001490116); Main.gore[index16].velocity.Y = (float) ((double) Main.gore[index16].velocity.Y * 0.100000001490116 - (double) this.velocity.Y * 0.0500000007450581); int index17 = Gore.NewGore(new Vector2((float) ((double) this.position.X + (double) this.width + 4.0), (float) ((double) this.position.Y + (double) num - 16.0)), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(11, 14)); Main.gore[index17].velocity.X = (float) ((double) Main.gore[index17].velocity.X * 0.100000001490116 - (double) this.velocity.X * 0.100000001490116); Main.gore[index17].velocity.Y = (float) ((double) Main.gore[index17].velocity.Y * 0.100000001490116 - (double) this.velocity.Y * 0.0500000007450581); } } this.releaseJump = false; } else { this.jump = 0; this.releaseJump = true; this.rocketRelease = true; } } public void DashMovement() { if (this.dashDelay == 0) this.dash = this.dashType; if (this.dash == 0) { this.dashTime = 0; this.dashDelay = 0; } if (this.dash == 2 && this.eocDash > 0) { if (this.eocHit < 0) { Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle((int) ((double) this.position.X + (double) this.velocity.X * 0.5 - 4.0), (int) ((double) this.position.Y + (double) this.velocity.Y * 0.5 - 4.0), this.width + 8, this.height + 8); for (int index = 0; index < 200; ++index) { NPC npc = Main.npc[index]; if (npc.active && !npc.dontTakeDamage && !npc.friendly && (npc.aiStyle != 112 || (double) npc.ai[2] <= 1.0) && this.CanNPCBeHitByPlayerOrPlayerProjectile(npc)) { Microsoft.Xna.Framework.Rectangle rect = npc.getRect(); if (rectangle.Intersects(rect) && (npc.noTileCollide || this.CanHit((Entity) npc))) { float num = 30f * this.meleeDamage; float knockback = 9f; bool crit = false; if (this.kbGlove) knockback *= 2f; if (this.kbBuff) knockback *= 1.5f; if (Main.rand.Next(100) < this.meleeCrit) crit = true; int direction = this.direction; if ((double) this.velocity.X < 0.0) direction = -1; if ((double) this.velocity.X > 0.0) direction = 1; if (this.whoAmI == Main.myPlayer) this.ApplyDamageToNPC(npc, (int) num, knockback, direction, crit); this.eocDash = 10; this.dashDelay = 30; this.velocity.X = (float) (-direction * 9); this.velocity.Y = -4f; this.GiveImmuneTimeForCollisionAttack(4); this.eocHit = index; } } } } else if ((!this.controlLeft || (double) this.velocity.X >= 0.0) && (!this.controlRight || (double) this.velocity.X <= 0.0)) this.velocity.X *= 0.95f; } if (this.dash == 3 && this.dashDelay < 0 && this.whoAmI == Main.myPlayer) { Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle((int) ((double) this.position.X + (double) this.velocity.X * 0.5 - 4.0), (int) ((double) this.position.Y + (double) this.velocity.Y * 0.5 - 4.0), this.width + 8, this.height + 8); for (int index1 = 0; index1 < 200; ++index1) { NPC npc = Main.npc[index1]; if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.immune[this.whoAmI] <= 0 && (npc.aiStyle != 112 || (double) npc.ai[2] <= 1.0) && this.CanNPCBeHitByPlayerOrPlayerProjectile(npc)) { Microsoft.Xna.Framework.Rectangle rect = npc.getRect(); if (rectangle.Intersects(rect) && (npc.noTileCollide || this.CanHit((Entity) npc))) { if (!this.solarDashConsumedFlare) { this.solarDashConsumedFlare = true; this.ConsumeSolarFlare(); } float num = 150f * this.meleeDamage; float knockback = 9f; bool crit = false; if (this.kbGlove) knockback *= 2f; if (this.kbBuff) knockback *= 1.5f; if (Main.rand.Next(100) < this.meleeCrit) crit = true; int direction = this.direction; if ((double) this.velocity.X < 0.0) direction = -1; if ((double) this.velocity.X > 0.0) direction = 1; if (this.whoAmI == Main.myPlayer) { this.ApplyDamageToNPC(npc, (int) num, knockback, direction, crit); int index2 = Projectile.NewProjectile(this.Center.X, this.Center.Y, 0.0f, 0.0f, 608, 150, 15f, Main.myPlayer); Main.projectile[index2].Kill(); } npc.immune[this.whoAmI] = 6; this.GiveImmuneTimeForCollisionAttack(4); } } } } if (this.dashDelay > 0) { if (this.eocDash > 0) --this.eocDash; if (this.eocDash == 0) this.eocHit = -1; --this.dashDelay; } else if (this.dashDelay < 0) { this.StopVanityActions(); float num1 = 12f; float num2 = 0.992f; float num3 = Math.Max(this.accRunSpeed, this.maxRunSpeed); float num4 = 0.96f; int num5 = 20; if (this.dash == 1) { for (int index3 = 0; index3 < 2; ++index3) { int index4 = (double) this.velocity.Y != 0.0 ? Dust.NewDust(new Vector2(this.position.X, (float) ((double) this.position.Y + (double) (this.height / 2) - 8.0)), this.width, 16, 31, Alpha: 100, Scale: 1.4f) : Dust.NewDust(new Vector2(this.position.X, (float) ((double) this.position.Y + (double) this.height - 4.0)), this.width, 8, 31, Alpha: 100, Scale: 1.4f); Main.dust[index4].velocity *= 0.1f; Main.dust[index4].scale *= (float) (1.0 + (double) Main.rand.Next(20) * 0.00999999977648258); } } else if (this.dash == 2) { for (int index5 = 0; index5 < 0; ++index5) { int index6 = (double) this.velocity.Y != 0.0 ? Dust.NewDust(new Vector2(this.position.X, (float) ((double) this.position.Y + (double) (this.height / 2) - 8.0)), this.width, 16, 31, Alpha: 100, Scale: 1.4f) : Dust.NewDust(new Vector2(this.position.X, (float) ((double) this.position.Y + (double) this.height - 4.0)), this.width, 8, 31, Alpha: 100, Scale: 1.4f); Main.dust[index6].velocity *= 0.1f; Main.dust[index6].scale *= (float) (1.0 + (double) Main.rand.Next(20) * 0.00999999977648258); } num2 = 0.985f; num4 = 0.94f; num5 = 30; } else if (this.dash == 3) { for (int index7 = 0; index7 < 4; ++index7) { int index8 = Dust.NewDust(new Vector2(this.position.X, this.position.Y + 4f), this.width, this.height - 8, 6, Alpha: 100, Scale: 1.7f); Main.dust[index8].velocity *= 0.1f; Main.dust[index8].scale *= (float) (1.0 + (double) Main.rand.Next(20) * 0.00999999977648258); Main.dust[index8].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); Main.dust[index8].noGravity = true; if (Main.rand.Next(2) == 0) Main.dust[index8].fadeIn = 0.5f; } num1 = 14f; num2 = 0.985f; num4 = 0.94f; num5 = 20; } else if (this.dash == 4) { for (int index9 = 0; index9 < 2; ++index9) { int index10 = Dust.NewDust(new Vector2(this.position.X, this.position.Y + 4f), this.width, this.height - 8, 229, Alpha: 100, Scale: 1.2f); Main.dust[index10].velocity *= 0.1f; Main.dust[index10].scale *= (float) (1.0 + (double) Main.rand.Next(20) * 0.00999999977648258); Main.dust[index10].noGravity = true; if (Main.rand.Next(2) == 0) Main.dust[index10].fadeIn = 0.3f; } num2 = 0.985f; num4 = 0.94f; num5 = 20; } if (this.dash <= 0) return; this.doorHelper.AllowOpeningDoorsByVelocityAloneForATime(num5 * 3); this.vortexStealthActive = false; if ((double) this.velocity.X > (double) num1 || (double) this.velocity.X < -(double) num1) this.velocity.X *= num2; else if ((double) this.velocity.X > (double) num3 || (double) this.velocity.X < -(double) num3) { this.velocity.X *= num4; } else { this.dashDelay = num5; if ((double) this.velocity.X < 0.0) { this.velocity.X = -num3; } else { if ((double) this.velocity.X <= 0.0) return; this.velocity.X = num3; } } } else { if (this.dash <= 0 || this.mount.Active) return; if (this.dash == 1) { int num = 0; bool flag = false; if (this.dashTime > 0) --this.dashTime; if (this.dashTime < 0) ++this.dashTime; if (this.controlRight && this.releaseRight) { if (this.dashTime > 0) { num = 1; flag = true; this.dashTime = 0; } else this.dashTime = 15; } else if (this.controlLeft && this.releaseLeft) { if (this.dashTime < 0) { num = -1; flag = true; this.dashTime = 0; } else this.dashTime = -15; } if (!flag) return; this.velocity.X = 16.9f * (float) num; Point tileCoordinates1 = (this.Center + new Vector2((float) (num * this.width / 2 + 2), (float) ((double) this.gravDir * (double) -this.height / 2.0 + (double) this.gravDir * 2.0))).ToTileCoordinates(); Point tileCoordinates2 = (this.Center + new Vector2((float) (num * this.width / 2 + 2), 0.0f)).ToTileCoordinates(); if (WorldGen.SolidOrSlopedTile(tileCoordinates1.X, tileCoordinates1.Y) || WorldGen.SolidOrSlopedTile(tileCoordinates2.X, tileCoordinates2.Y)) this.velocity.X /= 2f; this.dashDelay = -1; for (int index11 = 0; index11 < 20; ++index11) { int index12 = Dust.NewDust(new Vector2(this.position.X, this.position.Y), this.width, this.height, 31, Alpha: 100, Scale: 2f); Main.dust[index12].position.X += (float) Main.rand.Next(-5, 6); Main.dust[index12].position.Y += (float) Main.rand.Next(-5, 6); Main.dust[index12].velocity *= 0.2f; Main.dust[index12].scale *= (float) (1.0 + (double) Main.rand.Next(20) * 0.00999999977648258); } int index13 = Gore.NewGore(new Vector2((float) ((double) this.position.X + (double) (this.width / 2) - 24.0), (float) ((double) this.position.Y + (double) (this.height / 2) - 34.0)), new Vector2(), Main.rand.Next(61, 64)); Main.gore[index13].velocity.X = (float) Main.rand.Next(-50, 51) * 0.01f; Main.gore[index13].velocity.Y = (float) Main.rand.Next(-50, 51) * 0.01f; Main.gore[index13].velocity *= 0.4f; int index14 = Gore.NewGore(new Vector2((float) ((double) this.position.X + (double) (this.width / 2) - 24.0), (float) ((double) this.position.Y + (double) (this.height / 2) - 14.0)), new Vector2(), Main.rand.Next(61, 64)); Main.gore[index14].velocity.X = (float) Main.rand.Next(-50, 51) * 0.01f; Main.gore[index14].velocity.Y = (float) Main.rand.Next(-50, 51) * 0.01f; Main.gore[index14].velocity *= 0.4f; } else if (this.dash == 2) { int num = 0; bool flag = false; if (this.dashTime > 0) --this.dashTime; if (this.dashTime < 0) ++this.dashTime; if (this.controlRight && this.releaseRight) { if (this.dashTime > 0) { num = 1; flag = true; this.dashTime = 0; } else this.dashTime = 15; } else if (this.controlLeft && this.releaseLeft) { if (this.dashTime < 0) { num = -1; flag = true; this.dashTime = 0; } else this.dashTime = -15; } if (!flag) return; this.velocity.X = 14.5f * (float) num; Point tileCoordinates3 = (this.Center + new Vector2((float) (num * this.width / 2 + 2), (float) ((double) this.gravDir * (double) -this.height / 2.0 + (double) this.gravDir * 2.0))).ToTileCoordinates(); Point tileCoordinates4 = (this.Center + new Vector2((float) (num * this.width / 2 + 2), 0.0f)).ToTileCoordinates(); if (WorldGen.SolidOrSlopedTile(tileCoordinates3.X, tileCoordinates3.Y) || WorldGen.SolidOrSlopedTile(tileCoordinates4.X, tileCoordinates4.Y)) this.velocity.X /= 2f; this.dashDelay = -1; this.eocDash = 15; for (int index15 = 0; index15 < 0; ++index15) { int index16 = Dust.NewDust(new Vector2(this.position.X, this.position.Y), this.width, this.height, 31, Alpha: 100, Scale: 2f); Main.dust[index16].position.X += (float) Main.rand.Next(-5, 6); Main.dust[index16].position.Y += (float) Main.rand.Next(-5, 6); Main.dust[index16].velocity *= 0.2f; Main.dust[index16].scale *= (float) (1.0 + (double) Main.rand.Next(20) * 0.00999999977648258); } } else { if (this.dash != 3) return; int num = 0; bool flag = false; if (this.dashTime > 0) --this.dashTime; if (this.dashTime < 0) ++this.dashTime; if (this.controlRight && this.releaseRight) { if (this.dashTime > 0) { num = 1; flag = true; this.dashTime = 0; this.solarDashing = true; this.solarDashConsumedFlare = false; } else this.dashTime = 15; } else if (this.controlLeft && this.releaseLeft) { if (this.dashTime < 0) { num = -1; flag = true; this.dashTime = 0; this.solarDashing = true; this.solarDashConsumedFlare = false; } else this.dashTime = -15; } if (!flag) return; this.velocity.X = 21.9f * (float) num; Point tileCoordinates5 = (this.Center + new Vector2((float) (num * this.width / 2 + 2), (float) ((double) this.gravDir * (double) -this.height / 2.0 + (double) this.gravDir * 2.0))).ToTileCoordinates(); Point tileCoordinates6 = (this.Center + new Vector2((float) (num * this.width / 2 + 2), 0.0f)).ToTileCoordinates(); if (WorldGen.SolidOrSlopedTile(tileCoordinates5.X, tileCoordinates5.Y) || WorldGen.SolidOrSlopedTile(tileCoordinates6.X, tileCoordinates6.Y)) this.velocity.X /= 2f; this.dashDelay = -1; for (int index17 = 0; index17 < 20; ++index17) { int index18 = Dust.NewDust(new Vector2(this.position.X, this.position.Y), this.width, this.height, 6, Alpha: 100, Scale: 2f); Main.dust[index18].position.X += (float) Main.rand.Next(-5, 6); Main.dust[index18].position.Y += (float) Main.rand.Next(-5, 6); Main.dust[index18].velocity *= 0.2f; Main.dust[index18].scale *= (float) (1.0 + (double) Main.rand.Next(20) * 0.00999999977648258); Main.dust[index18].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); Main.dust[index18].noGravity = true; Main.dust[index18].fadeIn = 0.5f; } } } } public void WallslideMovement() { this.sliding = false; if (this.slideDir == 0 || this.spikedBoots <= 0 || this.mount.Active || (!this.controlLeft || this.slideDir != -1) && (!this.controlRight || this.slideDir != 1)) return; bool flag = false; float x = this.position.X; if (this.slideDir == 1) x += (float) this.width; float num1 = x + (float) this.slideDir; float num2 = (float) ((double) this.position.Y + (double) this.height + 1.0); if ((double) this.gravDir < 0.0) num2 = this.position.Y - 1f; float num3 = num1 / 16f; float num4 = num2 / 16f; if (WorldGen.SolidTile((int) num3, (int) num4) && WorldGen.SolidTile((int) num3, (int) num4 - 1)) flag = true; if (this.spikedBoots >= 2) { if (!flag || ((double) this.velocity.Y <= 0.0 || (double) this.gravDir != 1.0) && ((double) this.velocity.Y >= (double) this.gravity || (double) this.gravDir != -1.0)) return; float num5 = this.gravity; if (this.slowFall) num5 = !this.TryingToHoverUp ? this.gravity / 3f * this.gravDir : this.gravity / 10f * this.gravDir; this.fallStart = (int) ((double) this.position.Y / 16.0); if (this.controlDown && (double) this.gravDir == 1.0 || this.controlUp && (double) this.gravDir == -1.0) { this.velocity.Y = 4f * this.gravDir; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) ((this.width / 2 - 4) * this.slideDir), (float) ((double) this.position.Y + (double) (this.height / 2) + (double) (this.height / 2 - 4) * (double) this.gravDir)), 8, 8, 31); if (this.slideDir < 0) Main.dust[index].position.X -= 10f; if ((double) this.gravDir < 0.0) Main.dust[index].position.Y -= 12f; Main.dust[index].velocity *= 0.1f; Main.dust[index].scale *= 1.2f; Main.dust[index].noGravity = true; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cShoe, this); } else if ((double) this.gravDir == -1.0) this.velocity.Y = (float) (-(double) num5 + 9.99999974737875E-06) * this.gravDir; else this.velocity.Y = (float) (-(double) num5 + 9.99999974737875E-06) * this.gravDir; this.sliding = true; } else { if ((!flag || (double) this.velocity.Y <= 0.5 || (double) this.gravDir != 1.0) && ((double) this.velocity.Y >= -0.5 || (double) this.gravDir != -1.0)) return; this.fallStart = (int) ((double) this.position.Y / 16.0); if (this.controlDown) this.velocity.Y = 4f * this.gravDir; else this.velocity.Y = 0.5f * this.gravDir; this.sliding = true; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) ((this.width / 2 - 4) * this.slideDir), (float) ((double) this.position.Y + (double) (this.height / 2) + (double) (this.height / 2 - 4) * (double) this.gravDir)), 8, 8, 31); if (this.slideDir < 0) Main.dust[index].position.X -= 10f; if ((double) this.gravDir < 0.0) Main.dust[index].position.Y -= 12f; Main.dust[index].velocity *= 0.1f; Main.dust[index].scale *= 1.2f; Main.dust[index].noGravity = true; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cShoe, this); } } public void CarpetMovement() { bool flag = false; if (this.grappling[0] == -1 && this.carpet && !this.canJumpAgain_Cloud && !this.canJumpAgain_Sandstorm && !this.canJumpAgain_Blizzard && !this.canJumpAgain_Fart && !this.canJumpAgain_Sail && !this.canJumpAgain_Unicorn && !this.canJumpAgain_Santank && !this.canJumpAgain_WallOfFleshGoat && !this.canJumpAgain_Basilisk && this.jump == 0 && (double) this.velocity.Y != 0.0 && this.rocketTime == 0 && (double) this.wingTime == 0.0 && !this.mount.Active) { if (this.controlJump && this.canCarpet) { this.canCarpet = false; this.carpetTime = 300; } if (this.carpetTime > 0 && this.controlJump) { this.fallStart = (int) ((double) this.position.Y / 16.0); flag = true; --this.carpetTime; float gravity = this.gravity; if ((double) this.gravDir == 1.0 && (double) this.velocity.Y > -(double) gravity) this.velocity.Y = (float) -((double) gravity + 9.99999997475243E-07); else if ((double) this.gravDir == -1.0 && (double) this.velocity.Y < (double) gravity) this.velocity.Y = gravity + 1E-06f; this.carpetFrameCounter += 1f + Math.Abs(this.velocity.X * 0.5f); if ((double) this.carpetFrameCounter > 8.0) { this.carpetFrameCounter = 0.0f; ++this.carpetFrame; } if (this.carpetFrame < 0) this.carpetFrame = 0; if (this.carpetFrame > 5) this.carpetFrame = 0; } } if (!flag) this.carpetFrame = -1; else this.slowFall = false; } public void DoubleJumpVisuals() { if (this.isPerformingJump_Cloud && this.hasJumpOption_Cloud && !this.canJumpAgain_Cloud && (this.canJumpAgain_Sandstorm || !this.hasJumpOption_Sandstorm) && ((double) this.gravDir == 1.0 && (double) this.velocity.Y < 0.0 || (double) this.gravDir == -1.0 && (double) this.velocity.Y > 0.0)) { int num = this.height; if ((double) this.gravDir == -1.0) num = -6; int index = Dust.NewDust(new Vector2(this.position.X - 4f, this.position.Y + (float) num), this.width + 8, 4, 16, (float) (-(double) this.velocity.X * 0.5), this.velocity.Y * 0.5f, 100, Scale: 1.5f); Main.dust[index].velocity.X = (float) ((double) Main.dust[index].velocity.X * 0.5 - (double) this.velocity.X * 0.100000001490116); Main.dust[index].velocity.Y = (float) ((double) Main.dust[index].velocity.Y * 0.5 - (double) this.velocity.Y * 0.300000011920929); } if (this.isPerformingJump_Sandstorm && this.hasJumpOption_Sandstorm && !this.canJumpAgain_Sandstorm && ((double) this.gravDir == 1.0 && (double) this.velocity.Y < 0.0 || (double) this.gravDir == -1.0 && (double) this.velocity.Y > 0.0)) { int num = this.height; if ((double) this.gravDir == -1.0) num = -6; float Scale = (float) (((double) this.jump / 75.0 + 1.0) / 2.0); for (int index1 = 0; index1 < 3; ++index1) { int index2 = Dust.NewDust(new Vector2(this.position.X, this.position.Y + (float) (num / 2)), this.width, 32, 124, this.velocity.X * 0.3f, this.velocity.Y * 0.3f, 150, Scale: (1f * Scale)); Main.dust[index2].velocity *= 0.5f * Scale; Main.dust[index2].fadeIn = 1.5f * Scale; } this.sandStorm = true; if (this.miscCounter % 3 == 0) { int index = Gore.NewGore(new Vector2((float) ((double) this.position.X + (double) (this.width / 2) - 18.0), this.position.Y + (float) (num / 2)), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(220, 223), Scale); Main.gore[index].velocity = this.velocity * 0.3f * Scale; Main.gore[index].alpha = 100; } } if (this.isPerformingJump_Fart && this.hasJumpOption_Fart && !this.canJumpAgain_Fart && ((double) this.gravDir == 1.0 && (double) this.velocity.Y < 0.0 || (double) this.gravDir == -1.0 && (double) this.velocity.Y > 0.0)) { int num = this.height; if ((double) this.gravDir == -1.0) num = -6; int index = Dust.NewDust(new Vector2(this.position.X - 4f, this.position.Y + (float) num), this.width + 8, 4, 188, (float) (-(double) this.velocity.X * 0.5), this.velocity.Y * 0.5f, 100, Scale: 1.5f); Main.dust[index].velocity.X = (float) ((double) Main.dust[index].velocity.X * 0.5 - (double) this.velocity.X * 0.100000001490116); Main.dust[index].velocity.Y = (float) ((double) Main.dust[index].velocity.Y * 0.5 - (double) this.velocity.Y * 0.300000011920929); Main.dust[index].velocity *= 0.5f; } if (this.isPerformingJump_Unicorn && this.hasJumpOption_Unicorn && !this.canJumpAgain_Unicorn && ((double) this.gravDir == 1.0 && (double) this.velocity.Y < 0.0 || (double) this.gravDir == -1.0 && (double) this.velocity.Y > 0.0)) { Dust dust = Main.dust[Dust.NewDust(this.position, this.width, this.height, Utils.SelectRandom(Main.rand, 176, 177, 179))]; dust.velocity = Vector2.Zero; dust.noGravity = true; dust.scale = (float) (0.5 + (double) Main.rand.NextFloat() * 0.800000011920929); dust.fadeIn = (float) (1.0 + (double) Main.rand.NextFloat() * 2.0); dust.shader = GameShaders.Armor.GetSecondaryShader(this.cMount, this); } if (this.isPerformingJump_Sail && this.hasJumpOption_Sail && !this.canJumpAgain_Sail && ((double) this.gravDir == 1.0 && (double) this.velocity.Y < 1.0 || (double) this.gravDir == -1.0 && (double) this.velocity.Y > 1.0)) { int num1 = 1; if (this.jump > 0) num1 = 2; int num2 = this.height - 6; if ((double) this.gravDir == -1.0) num2 = 6; for (int index3 = 0; index3 < num1; ++index3) { int index4 = Dust.NewDust(new Vector2(this.position.X, this.position.Y + (float) num2), this.width, 12, 253, this.velocity.X * 0.3f, this.velocity.Y * 0.3f, 100, Scale: 1.5f); Main.dust[index4].scale += (float) Main.rand.Next(-5, 3) * 0.1f; if (this.jump <= 0) Main.dust[index4].scale *= 0.8f; else Main.dust[index4].velocity -= this.velocity / 5f; Main.dust[index4].noGravity = true; Vector2 vector2 = new Vector2((float) Main.rand.Next(-100, 101), (float) Main.rand.Next(-100, 101)); vector2.Normalize(); vector2 *= (float) Main.rand.Next(81) * 0.1f; } } if (!this.isPerformingJump_Blizzard || !this.hasJumpOption_Blizzard || this.canJumpAgain_Blizzard || ((double) this.gravDir != 1.0 || (double) this.velocity.Y >= 0.0) && ((double) this.gravDir != -1.0 || (double) this.velocity.Y <= 0.0)) return; int num3 = this.height - 6; if ((double) this.gravDir == -1.0) num3 = 6; for (int index5 = 0; index5 < 2; ++index5) { int index6 = Dust.NewDust(new Vector2(this.position.X, this.position.Y + (float) num3), this.width, 12, 76, this.velocity.X * 0.3f, this.velocity.Y * 0.3f); Main.dust[index6].velocity *= 0.1f; if (index5 == 0) Main.dust[index6].velocity += this.velocity * 0.03f; else Main.dust[index6].velocity -= this.velocity * 0.03f; Main.dust[index6].velocity -= this.velocity * 0.1f; Main.dust[index6].noGravity = true; Main.dust[index6].noLight = true; } for (int index7 = 0; index7 < 3; ++index7) { int index8 = Dust.NewDust(new Vector2(this.position.X, this.position.Y + (float) num3), this.width, 12, 76, this.velocity.X * 0.3f, this.velocity.Y * 0.3f); Main.dust[index8].fadeIn = 1.5f; Main.dust[index8].velocity *= 0.6f; Main.dust[index8].velocity += this.velocity * 0.8f; Main.dust[index8].noGravity = true; Main.dust[index8].noLight = true; } for (int index9 = 0; index9 < 3; ++index9) { int index10 = Dust.NewDust(new Vector2(this.position.X, this.position.Y + (float) num3), this.width, 12, 76, this.velocity.X * 0.3f, this.velocity.Y * 0.3f); Main.dust[index10].fadeIn = 1.5f; Main.dust[index10].velocity *= 0.6f; Main.dust[index10].velocity -= this.velocity * 0.8f; Main.dust[index10].noGravity = true; Main.dust[index10].noLight = true; } } public void WingMovement() { if (this.wingsLogic == 4 && this.TryingToHoverUp) { this.velocity.Y -= 0.2f * this.gravDir; if ((double) this.gravDir == 1.0) { if ((double) this.velocity.Y > 0.0) --this.velocity.Y; else if ((double) this.velocity.Y > -(double) Player.jumpSpeed) this.velocity.Y -= 0.2f; if ((double) this.velocity.Y < -(double) Player.jumpSpeed * 3.0) this.velocity.Y = (float) (-(double) Player.jumpSpeed * 3.0); } else { if ((double) this.velocity.Y < 0.0) ++this.velocity.Y; else if ((double) this.velocity.Y < (double) Player.jumpSpeed) this.velocity.Y += 0.2f; if ((double) this.velocity.Y > (double) Player.jumpSpeed * 3.0) this.velocity.Y = Player.jumpSpeed * 3f; } this.wingTime -= 2f; } else { float num1 = 0.1f; float num2 = 0.5f; float num3 = 1.5f; float num4 = 0.5f; float num5 = 0.1f; if (this.wingsLogic == 26) { num2 = 0.75f; num5 = 0.15f; num4 = 1f; num3 = 2.5f; num1 = 0.125f; } if (this.wingsLogic == 8 || this.wingsLogic == 11 || this.wingsLogic == 24 || this.wingsLogic == 27 || this.wingsLogic == 22) num3 = 1.66f; if (this.wingsLogic == 21 || this.wingsLogic == 12 || this.wingsLogic == 20 || this.wingsLogic == 23) num3 = 1.805f; if (this.wingsLogic == 37) { num2 = 0.75f; num5 = 0.15f; num4 = 1f; num3 = 2.5f; num1 = 0.125f; } if (this.wingsLogic == 44) { num2 = 0.85f; num5 = 0.15f; num4 = 1f; num3 = 2.75f; num1 = 0.125f; if (this.TryingToHoverUp) { this.velocity.Y -= 0.4f * this.gravDir; if ((double) this.gravDir == 1.0) { if ((double) this.velocity.Y > 0.0) --this.velocity.Y; else if ((double) this.velocity.Y > -(double) Player.jumpSpeed) this.velocity.Y -= 0.2f; if ((double) this.velocity.Y < -(double) Player.jumpSpeed * 3.0) this.velocity.Y = (float) (-(double) Player.jumpSpeed * 3.0); } else { if ((double) this.velocity.Y < 0.0) ++this.velocity.Y; else if ((double) this.velocity.Y < (double) Player.jumpSpeed) this.velocity.Y += 0.2f; if ((double) this.velocity.Y > (double) Player.jumpSpeed * 3.0) this.velocity.Y = Player.jumpSpeed * 3f; } } if (this.TryingToHoverDown && !this.controlJump && (double) this.velocity.Y != 0.0) this.velocity.Y += 0.4f; } if (this.wingsLogic == 45) { num2 = 0.95f; num5 = 0.15f; num4 = 1f; num3 = 4.5f; if (this.TryingToHoverUp) { this.velocity.Y -= 0.4f * this.gravDir; if ((double) this.gravDir == 1.0) { if ((double) this.velocity.Y > 0.0) --this.velocity.Y; else if ((double) this.velocity.Y > -(double) Player.jumpSpeed) this.velocity.Y -= 0.2f; if ((double) this.velocity.Y < -(double) Player.jumpSpeed * 3.0) this.velocity.Y = (float) (-(double) Player.jumpSpeed * 3.0); } else { if ((double) this.velocity.Y < 0.0) ++this.velocity.Y; else if ((double) this.velocity.Y < (double) Player.jumpSpeed) this.velocity.Y += 0.2f; if ((double) this.velocity.Y > (double) Player.jumpSpeed * 3.0) this.velocity.Y = Player.jumpSpeed * 3f; } } if (this.TryingToHoverDown && !this.controlJump && (double) this.velocity.Y != 0.0) this.velocity.Y += 0.4f; } if (this.wingsLogic == 29 || this.wingsLogic == 32) { num2 = 0.85f; num5 = 0.15f; num4 = 1f; num3 = 3f; num1 = 0.135f; } if (this.wingsLogic == 30 || this.wingsLogic == 31) { num4 = 1f; num3 = 2.45f; if (!this.TryingToHoverDown) num1 = 0.15f; } this.velocity.Y -= num1 * this.gravDir; if ((double) this.gravDir == 1.0) { if ((double) this.velocity.Y > 0.0) this.velocity.Y -= num2; else if ((double) this.velocity.Y > -(double) Player.jumpSpeed * (double) num4) this.velocity.Y -= num5; if ((double) this.velocity.Y < -(double) Player.jumpSpeed * (double) num3) this.velocity.Y = -Player.jumpSpeed * num3; } else { if ((double) this.velocity.Y < 0.0) this.velocity.Y += num2; else if ((double) this.velocity.Y < (double) Player.jumpSpeed * (double) num4) this.velocity.Y += num5; if ((double) this.velocity.Y > (double) Player.jumpSpeed * (double) num3) this.velocity.Y = Player.jumpSpeed * num3; } if ((this.wingsLogic == 22 || this.wingsLogic == 28 || this.wingsLogic == 30 || this.wingsLogic == 31 || this.wingsLogic == 37 || this.wingsLogic == 45) && this.TryingToHoverDown && !this.controlLeft && !this.controlRight) this.wingTime -= 0.5f; else --this.wingTime; } if (!this.empressBrooch || (double) this.wingTime == 0.0) return; this.wingTime = (float) this.wingTimeMax; } public void MoonLeechRope() { int index1 = -1; for (int index2 = 0; index2 < 1000; ++index2) { if (Main.projectile[index2].active && Main.projectile[index2].type == 456 && (double) Main.projectile[index2].ai[1] == (double) this.whoAmI) { index1 = index2; break; } } if (index1 == -1 || (double) Main.projectile[index1].ai[0] < 0.0) return; Projectile projectile = Main.projectile[index1]; Vector2 vector2_1 = new Vector2(0.0f, 216f); Vector2 vector2_2 = Main.npc[(int) Math.Abs(projectile.ai[0]) - 1].Center - this.Center + vector2_1; if ((double) vector2_2.Length() <= 200.0) return; this.position = this.position + Vector2.Normalize(vector2_2) * (vector2_2.Length() - 200f); } public void WOFTongue() { if (Main.wofNPCIndex < 0 || !Main.npc[Main.wofNPCIndex].active) return; float num1 = Main.npc[Main.wofNPCIndex].position.X + 40f; if (Main.npc[Main.wofNPCIndex].direction > 0) num1 -= 96f; if ((double) this.position.X + (double) this.width > (double) num1 && (double) this.position.X < (double) num1 + 140.0 && this.gross) { this.noKnockback = false; int scaledByStrength = Main.npc[Main.wofNPCIndex].GetAttackDamage_ScaledByStrength(50f); this.Hurt(PlayerDeathReason.LegacyDefault(), scaledByStrength, Main.npc[Main.wofNPCIndex].direction); } if (!this.gross && (double) this.position.Y > (double) ((Main.maxTilesY - 250) * 16) && (double) this.position.X > (double) num1 - 1920.0 && (double) this.position.X < (double) num1 + 1920.0) { this.AddBuff(37, 10); SoundEngine.PlaySound(4, (int) Main.npc[Main.wofNPCIndex].position.X, (int) Main.npc[Main.wofNPCIndex].position.Y, 10); } if (this.gross) { if ((double) this.position.Y < (double) (Main.UnderworldLayer * 16)) this.AddBuff(38, 10); if (Main.npc[Main.wofNPCIndex].direction < 0) { if ((double) this.position.X + (double) (this.width / 2) > (double) Main.npc[Main.wofNPCIndex].position.X + (double) (Main.npc[Main.wofNPCIndex].width / 2) + 40.0) this.AddBuff(38, 10); } else if ((double) this.position.X + (double) (this.width / 2) < (double) Main.npc[Main.wofNPCIndex].position.X + (double) (Main.npc[Main.wofNPCIndex].width / 2) - 40.0) this.AddBuff(38, 10); } if (!this.tongued) return; this.controlHook = false; this.controlUseItem = false; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && Main.projectile[index].aiStyle == 7) Main.projectile[index].Kill(); } Vector2 center = this.Center; double num2 = (double) Main.npc[Main.wofNPCIndex].position.X + (double) (Main.npc[Main.wofNPCIndex].width / 2) - (double) center.X; float num3 = Main.npc[Main.wofNPCIndex].position.Y + (float) (Main.npc[Main.wofNPCIndex].height / 2) - center.Y; if (Math.Sqrt(num2 * num2 + (double) num3 * (double) num3) > 3000.0) { this.KillMe(PlayerDeathReason.ByOther(11), 1000.0, 0); } else { if ((double) Main.npc[Main.wofNPCIndex].position.X >= 608.0 && (double) Main.npc[Main.wofNPCIndex].position.X <= (double) ((Main.maxTilesX - 38) * 16)) return; this.KillMe(PlayerDeathReason.ByOther(12), 1000.0, 0); } } public void StatusFromNPC(NPC npc) { if (Main.expertMode && (npc.type == 266 && Main.rand.Next(3) == 0 || npc.type == 267)) { int num1 = Main.rand.Next(9); switch (num1) { case 2: case 4: num1 = Main.rand.Next(9); break; } float num2 = (float) Main.rand.Next(75, 150) * 0.01f; if (num1 == 0) this.AddBuff(20, (int) (60.0 * (double) num2 * 3.5)); else if (num1 == 1) this.AddBuff(22, (int) (60.0 * (double) num2 * 2.0)); else if (num1 == 2) this.AddBuff(23, (int) (60.0 * (double) num2 * 0.5)); else if (num1 == 3) this.AddBuff(30, (int) (60.0 * (double) num2 * 5.0)); else if (num1 == 4) this.AddBuff(31, (int) (60.0 * (double) num2 * 1.0)); else if (num1 == 5) this.AddBuff(32, (int) (60.0 * (double) num2 * 3.5)); else if (num1 == 6) this.AddBuff(33, (int) (60.0 * (double) num2 * 7.5)); else if (num1 == 7) this.AddBuff(35, (int) (60.0 * (double) num2 * 1.0)); else if (num1 == 8) this.AddBuff(36, (int) (60.0 * (double) num2 * 6.5)); } if (npc.type == 530 || npc.type == 531) this.AddBuff(70, Main.rand.Next(240, 241)); if (npc.type == 159 || npc.type == 158) this.AddBuff(30, Main.rand.Next(300, 600)); if (npc.type == 525) this.AddBuff(39, 240); if (npc.type == 526) this.AddBuff(69, 420); if (npc.type == 527) this.AddBuff(31, 840); if (Main.expertMode && (npc.type == 49 || npc.type == 93 || npc.type == 51 || npc.type == 152 || npc.type == 634) && Main.rand.Next(10) == 0) this.AddBuff(148, Main.rand.Next(1800, 5400)); if (Main.expertMode && npc.type == 222) this.AddBuff(20, Main.rand.Next(60, 240)); if (Main.expertMode && (npc.type == 210 || npc.type == 211)) this.AddBuff(20, Main.rand.Next(60, 180)); if (Main.expertMode && npc.type == 35) this.AddBuff(30, Main.rand.Next(180, 300)); if (Main.expertMode && npc.type == 36 && Main.rand.Next(2) == 0) this.AddBuff(32, Main.rand.Next(30, 60)); if (npc.type >= 269 && npc.type <= 272) { if (Main.rand.Next(3) == 0) this.AddBuff(30, 600); else if (Main.rand.Next(3) == 0) this.AddBuff(32, 300); } if (npc.type >= 273 && npc.type <= 276 && Main.rand.Next(2) == 0) this.AddBuff(36, 600); if (npc.type >= 277 && npc.type <= 280) this.AddBuff(24, 600); if (npc.type == 371) this.AddBuff(103, 60 * Main.rand.Next(3, 8)); if (npc.type == 370 && Main.expertMode) { int type = Utils.SelectRandom(Main.rand, 0, 148, 30); if (type != 0) this.AddBuff(type, 60 * Main.rand.Next(3, 11)); } if ((npc.type == 1 && npc.netID == -6 || npc.type == 81 || npc.type == 79 || npc.type == 183 || npc.type == 630) && Main.rand.Next(4) == 0) this.AddBuff(22, 900); if ((npc.type == 23 || npc.type == 25) && Main.rand.Next(3) == 0) this.AddBuff(24, 420); if ((npc.type == 34 || npc.type == 83 || npc.type == 84 || npc.type == 179 || npc.type == 289) && Main.rand.Next(3) == 0) this.AddBuff(23, 240); if ((npc.type == 104 || npc.type == 102) && Main.rand.Next(8) == 0) this.AddBuff(30, 2700); if (npc.type == 75 && Main.rand.Next(10) == 0) this.AddBuff(35, 420); if ((npc.type == 163 || npc.type == 238) && Main.rand.Next(10) == 0) this.AddBuff(70, 240); if ((npc.type == 79 || npc.type == 103 || npc.type == 630) && Main.rand.Next(5) == 0) this.AddBuff(35, 420); if ((npc.type == 75 || npc.type == 78 || npc.type == 82) && Main.rand.Next(8) == 0) this.AddBuff(32, 900); if ((npc.type == 93 || npc.type == 109 || npc.type == 80) && Main.rand.Next(14) == 0) this.AddBuff(31, 300); if (npc.type >= 305 && npc.type <= 314 && Main.rand.Next(10) == 0) this.AddBuff(33, 3600); if (npc.type == 77 && Main.rand.Next(6) == 0) this.AddBuff(36, 7200); if (npc.type == 112 && Main.rand.Next(20) == 0) this.AddBuff(33, 18000); if (npc.type == 182 && Main.rand.Next(25) == 0) this.AddBuff(33, 7200); if (npc.type == 141 && Main.rand.Next(2) == 0) this.AddBuff(20, 600); if (npc.type == 147 && !this.frozen && Main.rand.Next(12) == 0) this.AddBuff(46, 600); if (npc.type == 150) { if (Main.rand.Next(2) == 0) this.AddBuff(46, 900); if (!this.frozen && Main.rand.Next(35) == 0) this.AddBuff(47, 60); else if (!this.frozen && Main.expertMode && Main.rand.Next(35) == 0) this.AddBuff(47, 60); } if (npc.type != 184) return; this.AddBuff(46, 1200); if (!this.frozen && Main.rand.Next(15) == 0) { this.AddBuff(47, 60); } else { if (this.frozen || !Main.expertMode || Main.rand.Next(25) != 0) return; this.AddBuff(47, 60); } } public void GrappleMovement() { if (this.grappling[0] < 0) return; this.StopVanityActions(); if (Main.myPlayer == this.whoAmI && this.mount.Active) this.mount.Dismount(this); this.canCarpet = true; this.carpetFrame = -1; this.wingFrame = 1; if ((double) this.velocity.Y == 0.0 || this.wet && (double) this.velocity.Y > -0.02 && (double) this.velocity.Y < 0.02) this.wingFrame = 0; if (this.wings == 4) this.wingFrame = 3; if (this.wings == 30) this.wingFrame = 0; this.RefreshMovementAbilities(); this.rocketFrame = false; this.canRocket = false; this.rocketRelease = false; this.fallStart = (int) ((double) this.position.Y / 16.0); int index1 = -1; for (int index2 = 0; index2 < this.grapCount; ++index2) { if (Main.projectile[this.grappling[index2]].type == 403) index1 = index2; } int? preferredPlayerDirectionToSet; float preferedPlayerVelocityX; float preferedPlayerVelocityY; this.GetGrapplingForces(this.Center, out preferredPlayerDirectionToSet, out preferedPlayerVelocityX, out preferedPlayerVelocityY); if ((double) preferedPlayerVelocityY > 0.0) this.GoingDownWithGrapple = true; this.velocity.X = preferedPlayerVelocityX; this.velocity.Y = preferedPlayerVelocityY; if (index1 != -1) { Projectile projectile = Main.projectile[this.grappling[index1]]; if ((double) projectile.position.X < (double) this.position.X + (double) this.width && (double) projectile.position.X + (double) projectile.width >= (double) this.position.X && (double) projectile.position.Y < (double) this.position.Y + (double) this.height && (double) projectile.position.Y + (double) projectile.height >= (double) this.position.Y) { int tileX = (int) ((double) projectile.position.X + (double) (projectile.width / 2)) / 16; int tileY = (int) ((double) projectile.position.Y + (double) (projectile.height / 2)) / 16; this.velocity = Vector2.Zero; if (Main.tile[tileX, tileY].type == (ushort) 314) { Vector2 Position; Position.X = projectile.position.X + (float) (projectile.width / 2) - (float) (this.width / 2); Position.Y = projectile.position.Y + (float) (projectile.height / 2) - (float) (this.height / 2); this.RemoveAllGrapplingHooks(); int num = 13; if (this.miscEquips[2].stack > 0 && this.miscEquips[2].mountType >= 0 && MountID.Sets.Cart[this.miscEquips[2].mountType] && (!this.miscEquips[2].expertOnly || Main.expertMode)) num = this.miscEquips[2].mountType; int Height = this.height + Mount.GetHeightBoost(num); if (Minecart.GetOnTrack(tileX, tileY, ref Position, this.width, Height) && !Collision.SolidCollision(Position, this.width, Height - 20)) { this.position = Position; DelegateMethods.Minecart.rotation = this.fullRotation; DelegateMethods.Minecart.rotationOrigin = this.fullRotationOrigin; this.mount.SetMount(num, this, this.minecartLeft); Minecart.WheelSparks(this.mount.Delegations.MinecartDust, this.position, this.width, this.height, 25); } } } } if (this.itemAnimation == 0) { if ((double) this.velocity.X == 0.0 && preferredPlayerDirectionToSet.HasValue) this.ChangeDir(preferredPlayerDirectionToSet.Value); if ((double) this.velocity.X > 0.0) this.ChangeDir(1); if ((double) this.velocity.X < 0.0) this.ChangeDir(-1); } if (this.controlJump) { if (!this.releaseJump) return; if (((double) this.velocity.Y == 0.0 || this.wet && (double) this.velocity.Y > -0.02 && (double) this.velocity.Y < 0.02) && !this.controlDown) { this.velocity.Y = -Player.jumpSpeed; this.jump = Player.jumpHeight / 2; this.releaseJump = false; } else { this.velocity.Y += 0.01f; this.releaseJump = false; } this.RefreshDoubleJumps(); this.RemoveAllGrapplingHooks(); } else this.releaseJump = true; } public void DoQueenSlimeHookTeleport(Vector2 targetPosition) { int num1 = 150; Vector2 position = this.position; Vector2 velocity = this.velocity; for (int index = 0; index < num1; ++index) { Vector2 Velocity = (position + this.Size / 2f).DirectionTo(targetPosition).SafeNormalize(Vector2.Zero) * 12f; Vector2 vector2 = Collision.TileCollision(position, Velocity, this.width, this.height, true, true, (int) this.gravDir); position += vector2; } int num2 = 10; Vector2 vector2_1 = position - this.position; this.Teleport(position, num2); NetMessage.SendData(65, number2: ((float) this.whoAmI), number3: position.X, number4: position.Y, number5: num2); } private void GetGrapplingForces( Vector2 fromPosition, out int? preferredPlayerDirectionToSet, out float preferedPlayerVelocityX, out float preferedPlayerVelocityY) { float num1 = 0.0f; float num2 = 0.0f; preferredPlayerDirectionToSet = new int?(); int num3 = 0; for (int index = 0; index < this.grapCount; ++index) { Projectile projectile = Main.projectile[this.grappling[index]]; if ((double) projectile.ai[0] == 2.0 && !projectile.position.HasNaNs()) { num1 += projectile.position.X + (float) (projectile.width / 2); num2 += projectile.position.Y + (float) (projectile.height / 2); ++num3; if (projectile.type == 446) { Vector2 vector2 = new Vector2((float) (this.controlRight.ToInt() - this.controlLeft.ToInt()), (float) (this.controlDown.ToInt() - this.controlUp.ToInt()) * this.gravDir); if (vector2 != Vector2.Zero) vector2.Normalize(); vector2 *= 100f; Vector2 vec = Vector2.Normalize(this.Center - projectile.Center + vector2); if (vec.HasNaNs()) vec = -Vector2.UnitY; float num4 = 200f; num1 += vec.X * num4; num2 += vec.Y * num4; } else if (projectile.type == 652) { Vector2 vector2_1 = new Vector2((float) (this.controlRight.ToInt() - this.controlLeft.ToInt()), (float) (this.controlDown.ToInt() - this.controlUp.ToInt()) * this.gravDir).SafeNormalize(Vector2.Zero); Vector2 v = projectile.Center - this.Center; Vector2 vector2_2 = v.SafeNormalize(Vector2.Zero); Vector2 vector2_3 = Vector2.Zero; if (vector2_1 != Vector2.Zero) vector2_3 = vector2_2 * Vector2.Dot(vector2_2, vector2_1); float num5 = 6f; if ((double) Vector2.Dot(vector2_3, v) < 0.0 && (double) v.Length() >= 600.0) num5 = 0.0f; num1 += (float) (-(double) v.X + (double) vector2_3.X * (double) num5); num2 += (float) (-(double) v.Y + (double) vector2_3.Y * (double) num5); } else if (projectile.type == 865) { Vector2 vector2_4 = (projectile.rotation - 1.570796f).ToRotationVector2().SafeNormalize(Vector2.UnitY); Vector2 vector2_5 = -vector2_4 * 28f; num1 += vector2_5.X; num2 += vector2_5.Y; if ((double) vector2_4.X != 0.0) preferredPlayerDirectionToSet = new int?(Math.Sign(vector2_4.X)); } } } if (num3 == 0) { preferedPlayerVelocityX = this.velocity.X; preferedPlayerVelocityY = this.velocity.Y; } else { float num6 = num1 / (float) num3; float num7 = num2 / (float) num3; Vector2 vector2 = fromPosition; preferedPlayerVelocityX = num6 - vector2.X; preferedPlayerVelocityY = num7 - vector2.Y; float num8 = (float) Math.Sqrt((double) preferedPlayerVelocityX * (double) preferedPlayerVelocityX + (double) preferedPlayerVelocityY * (double) preferedPlayerVelocityY); float num9 = 11f; if (Main.projectile[this.grappling[0]].type == 315) num9 = 14f; if (Main.projectile[this.grappling[0]].type == 487) num9 = 12f; if (Main.projectile[this.grappling[0]].type >= 646 && Main.projectile[this.grappling[0]].type <= 649) num9 = 16f; float num10 = (double) num8 <= (double) num9 ? 1f : num9 / num8; preferedPlayerVelocityX *= num10; preferedPlayerVelocityY *= num10; } } private void RefreshMovementAbilities(bool doubleJumps = true) { this.wingTime = (float) this.wingTimeMax; this.rocketTime = this.rocketTimeMax; this.rocketDelay = 0; if (!doubleJumps) return; this.RefreshDoubleJumps(); } private void RefreshDoubleJumps() { if (this.hasJumpOption_Cloud) this.canJumpAgain_Cloud = true; if (this.hasJumpOption_Sandstorm) this.canJumpAgain_Sandstorm = true; if (this.hasJumpOption_Blizzard) this.canJumpAgain_Blizzard = true; if (this.hasJumpOption_Fart) this.canJumpAgain_Fart = true; if (this.hasJumpOption_Sail) this.canJumpAgain_Sail = true; if (this.hasJumpOption_Unicorn) this.canJumpAgain_Unicorn = true; if (this.hasJumpOption_Santank) this.canJumpAgain_Santank = true; if (this.hasJumpOption_WallOfFleshGoat) this.canJumpAgain_WallOfFleshGoat = true; if (!this.hasJumpOption_Basilisk) return; this.canJumpAgain_Basilisk = true; } public void StickyMovement() { bool flag = false; if (this.mount.Type > 0 && MountID.Sets.Cart[this.mount.Type] && (double) Math.Abs(this.velocity.X) > 5.0) flag = true; Vector2 vector2_1 = new Vector2(this.position.X + (float) (this.width / 2) - (float) (this.width / 2 / 2), this.position.Y + (float) (this.height / 2) - (float) (this.height / 2 / 2)); Vector2 vector2_2 = Collision.StickyTiles(this.position, this.velocity, this.width, this.height); if ((double) vector2_2.Y != -1.0 && (double) vector2_2.X != -1.0) { int x = (int) vector2_2.X; int y = (int) vector2_2.Y; int type = (int) Main.tile[x, y].type; if (this.whoAmI == Main.myPlayer && type == 51 && ((double) this.velocity.X != 0.0 || (double) this.velocity.Y != 0.0)) { ++this.stickyBreak; if (this.stickyBreak > Main.rand.Next(20, 100) | flag) { this.stickyBreak = 0; WorldGen.KillTile(x, y); if (Main.netMode == 1 && !Main.tile[x, y].active() && Main.netMode == 1) NetMessage.SendData(17, number2: ((float) x), number3: ((float) y)); } } if (flag) return; this.fallStart = (int) ((double) this.position.Y / 16.0); if (type != 229) this.jump = 0; if ((double) this.velocity.X > 1.0) this.velocity.X = 1f; if ((double) this.velocity.X < -1.0) this.velocity.X = -1f; if ((double) this.velocity.X > 0.75 || (double) this.velocity.X < -0.75) this.velocity.X *= 0.85f; else this.velocity.X *= 0.6f; if ((double) this.gravDir == -1.0) { if ((double) this.velocity.Y < -1.0) this.velocity.Y = -1f; if ((double) this.velocity.Y > 5.0) this.velocity.Y = 5f; if ((double) this.velocity.Y > 0.0) this.velocity.Y *= 0.96f; else this.velocity.Y *= 0.3f; } else { if ((double) this.velocity.Y > 1.0) this.velocity.Y = 1f; if ((double) this.velocity.Y < -5.0) this.velocity.Y = -5f; if ((double) this.velocity.Y < 0.0) this.velocity.Y *= 0.96f; else this.velocity.Y *= 0.3f; } if (type != 229 || Main.rand.Next(5) != 0 || (double) this.velocity.Y <= 0.15 && (double) this.velocity.Y >= 0.0) return; if ((double) (x * 16) < (double) this.position.X + (double) (this.width / 2)) { int index = Dust.NewDust(new Vector2(this.position.X - 4f, (float) (y * 16)), 4, 16, 153, Alpha: 50); Main.dust[index].scale += (float) Main.rand.Next(0, 6) * 0.1f; Main.dust[index].velocity *= 0.1f; Main.dust[index].noGravity = true; } else { int index = Dust.NewDust(new Vector2((float) ((double) this.position.X + (double) this.width - 2.0), (float) (y * 16)), 4, 16, 153, Alpha: 50); Main.dust[index].scale += (float) Main.rand.Next(0, 6) * 0.1f; Main.dust[index].velocity *= 0.1f; Main.dust[index].noGravity = true; } if (Main.tile[x, y + 1] != null && Main.tile[x, y + 1].type == (ushort) 229 && (double) this.position.Y + (double) this.height > (double) ((y + 1) * 16)) { if ((double) (x * 16) < (double) this.position.X + (double) (this.width / 2)) { int index = Dust.NewDust(new Vector2(this.position.X - 4f, (float) (y * 16 + 16)), 4, 16, 153, Alpha: 50); Main.dust[index].scale += (float) Main.rand.Next(0, 6) * 0.1f; Main.dust[index].velocity *= 0.1f; Main.dust[index].noGravity = true; } else { int index = Dust.NewDust(new Vector2((float) ((double) this.position.X + (double) this.width - 2.0), (float) (y * 16 + 16)), 4, 16, 153, Alpha: 50); Main.dust[index].scale += (float) Main.rand.Next(0, 6) * 0.1f; Main.dust[index].velocity *= 0.1f; Main.dust[index].noGravity = true; } } if (Main.tile[x, y + 2] == null || Main.tile[x, y + 2].type != (ushort) 229 || (double) this.position.Y + (double) this.height <= (double) ((y + 2) * 16)) return; if ((double) (x * 16) < (double) this.position.X + (double) (this.width / 2)) { int index = Dust.NewDust(new Vector2(this.position.X - 4f, (float) (y * 16 + 32)), 4, 16, 153, Alpha: 50); Main.dust[index].scale += (float) Main.rand.Next(0, 6) * 0.1f; Main.dust[index].velocity *= 0.1f; Main.dust[index].noGravity = true; } else { int index = Dust.NewDust(new Vector2((float) ((double) this.position.X + (double) this.width - 2.0), (float) (y * 16 + 32)), 4, 16, 153, Alpha: 50); Main.dust[index].scale += (float) Main.rand.Next(0, 6) * 0.1f; Main.dust[index].velocity *= 0.1f; Main.dust[index].noGravity = true; } } else this.stickyBreak = 0; } public bool HasLockedInventory() => this.IsStackingItems(); public bool IsStackingItems() { for (int index = 0; index < this.inventoryChestStack.Length; ++index) { if (this.inventoryChestStack[index]) { if (this.inventory[index].type != 0 && this.inventory[index].stack != 0) return true; this.inventoryChestStack[index] = false; } } return false; } public List GetNearbyContainerProjectilesList() { List intList = new List(); Vector2 center = this.Center; for (int index = 0; index < 1000; ++index) { Projectile projectile = Main.projectile[index]; if (projectile.active) { int containerIndex = -1; if (projectile.TryGetContainerIndex(out containerIndex)) { Point tileCoordinates = projectile.Hitbox.ClosestPointInRect(center).ToTileCoordinates(); if (this.IsInTileInteractionRange(tileCoordinates.X, tileCoordinates.Y)) intList.Add(index); } } } return intList; } public void UpdateNearbyInteractibleProjectilesList() { List projectilesToInteractWith = this._projectilesToInteractWith; projectilesToInteractWith.Clear(); if (!Main.CurrentFrameFlags.HadAnActiveInteractibleProjectile) return; Vector2 center = this.Center; for (int index = 0; index < 1000; ++index) { if (this.IsProjectileInteractibleAndInInteractionRange(Main.projectile[index], ref center)) projectilesToInteractWith.Add(index); } } public bool IsProjectileInteractibleAndInInteractionRange( Projectile proj, ref Vector2 compareSpot) { if (!proj.active || !proj.IsInteractible()) return false; Point tileCoordinates = proj.Hitbox.ClosestPointInRect(compareSpot).ToTileCoordinates(); return this.IsInTileInteractionRange(tileCoordinates.X, tileCoordinates.Y); } public void QuickStackAllChests() { if (this.HasLockedInventory()) return; List containerProjectilesList = this.GetNearbyContainerProjectilesList(); for (int index = 0; index < containerProjectilesList.Count; ++index) { int containerIndex; if (Main.projectile[containerProjectilesList[index]].TryGetContainerIndex(out containerIndex)) { int chest = this.chest; this.chest = containerIndex; ChestUI.QuickStack(); this.chest = chest; } } int num1 = 17; int num2 = (int) ((double) this.Center.X / 16.0); int num3 = (int) ((double) this.Center.Y / 16.0); for (int index1 = num2 - num1; index1 <= num2 + num1; ++index1) { if (index1 >= 0 && index1 < Main.maxTilesX) { for (int index2 = num3 - num1; index2 <= num3 + num1; ++index2) { if (index2 >= 0 && index2 < Main.maxTilesY) { int num4 = 0; if (Main.tile[index1, index2].type == (ushort) 29) num4 = -2; else if (Main.tile[index1, index2].type == (ushort) 97) num4 = -3; else if (Main.tile[index1, index2].type == (ushort) 463) num4 = -4; else if (Main.tile[index1, index2].type == (ushort) 491) num4 = -5; if (num4 < 0 && (double) (new Vector2((float) (index1 * 16 + 8), (float) (index2 * 16 + 8)) - this.Center).Length() < 250.0) { int chest = this.chest; this.chest = num4; ChestUI.QuickStack(); this.chest = chest; } } } } } if (Main.netMode == 1) { for (int number = 10; number < 50; ++number) { if (this.inventory[number].type > 0 && this.inventory[number].stack > 0 && !this.inventory[number].favorited && !this.inventory[number].IsACoin) { NetMessage.SendData(5, number: this.whoAmI, number2: ((float) number), number3: ((float) this.inventory[number].prefix)); NetMessage.SendData(85, number: number); this.inventoryChestStack[number] = true; } } } else { bool flag = false; for (int index = 10; index < 50; ++index) { if (this.inventory[index].type > 0 && this.inventory[index].stack > 0 && !this.inventory[index].favorited && !this.inventory[index].IsACoin) { int type = this.inventory[index].type; int stack = this.inventory[index].stack; this.inventory[index] = Chest.PutItemInNearbyChest(this.inventory[index], this.Center); if (this.inventory[index].type != type || this.inventory[index].stack != stack) flag = true; } } if (!flag) return; SoundEngine.PlaySound(7); } } public void CheckDrowning() { bool flag = Collision.DrownCollision(this.position, this.width, this.height, this.gravDir); if (this.armor[0].type == 250 || this.armor[0].type == 4275) flag = true; if (this.inventory[this.selectedItem].type == 186) { if (this.itemAnimation == 0) { try { int index1 = (int) (((double) this.position.X + (double) (this.width / 2) + (double) (6 * this.direction)) / 16.0); int num = 0; if ((double) this.gravDir == -1.0) num = this.height; int index2 = (int) (((double) this.position.Y + (double) num - 44.0 * (double) this.gravDir) / 16.0); if (Main.tile[index1, index2] != null) { if (Main.tile[index1, index2].liquid < (byte) 128) { if (Main.tile[index1, index2] == null) Main.tile[index1, index2] = new Tile(); if (Main.tile[index1, index2].active() && Main.tileSolid[(int) Main.tile[index1, index2].type]) { if (!Main.tileSolidTop[(int) Main.tile[index1, index2].type]) goto label_15; } flag = false; } } } catch { } } } label_15: if (this.gills) flag = false; if (Main.myPlayer == this.whoAmI) { if (this.accMerman) { if (flag) this.merman = true; flag = false; } if (flag) { ++this.breathCD; if (this.breathCD >= this.breathCDMax) { this.breathCD = 0; --this.breath; if (this.breath == 0) SoundEngine.PlaySound(23); if (this.breath <= 0) { this.lifeRegenTime = 0; this.breath = 0; this.statLife -= 2; if (this.statLife <= 0) { this.statLife = 0; this.KillMe(PlayerDeathReason.ByOther(1), 10.0, 0); } } } } else { this.breath += 3; if (this.breath > this.breathMax) this.breath = this.breathMax; this.breathCD = 0; } } if (!flag || Main.rand.Next(20) != 0 || this.lavaWet || this.honeyWet) return; int num1 = 0; if ((double) this.gravDir == -1.0) num1 += this.height - 12; if (this.inventory[this.selectedItem].type == 186) Dust.NewDust(new Vector2((float) ((double) this.position.X + (double) (10 * this.direction) + 4.0), (float) ((double) this.position.Y + (double) num1 - 54.0 * (double) this.gravDir)), this.width - 8, 8, 34, Scale: 1.2f); else Dust.NewDust(new Vector2(this.position.X + (float) (12 * this.direction), (float) ((double) this.position.Y + (double) num1 + 4.0 * (double) this.gravDir)), this.width - 8, 8, 34, Scale: 1.2f); } public void CheckCrackedBrickBreak() { bool flag1 = false; if ((double) Main.rand.Next(2, 12) < (double) Math.Abs(this.velocity.X)) flag1 = true; if ((double) Main.rand.Next(2, 12) < (double) this.velocity.Y) flag1 = true; if (flag1 && (double) this.velocity.Y < 1.0) { Point tileCoordinates1 = (this.Bottom + Vector2.UnitY).ToTileCoordinates(); Point tileCoordinates2 = (this.BottomLeft + Vector2.UnitY).ToTileCoordinates(); Point tileCoordinates3 = (this.BottomRight + Vector2.UnitY).ToTileCoordinates(); if (WorldGen.SolidTileAllowBottomSlope(tileCoordinates1.X, tileCoordinates1.Y) && !TileID.Sets.CrackedBricks[(int) Main.tile[tileCoordinates1.X, tileCoordinates1.Y].type] || WorldGen.SolidTileAllowBottomSlope(tileCoordinates2.X, tileCoordinates2.Y) && !TileID.Sets.CrackedBricks[(int) Main.tile[tileCoordinates2.X, tileCoordinates2.Y].type] || WorldGen.SolidTileAllowBottomSlope(tileCoordinates3.X, tileCoordinates3.Y) && !TileID.Sets.CrackedBricks[(int) Main.tile[tileCoordinates3.X, tileCoordinates3.Y].type]) flag1 = false; } if (!flag1) return; Vector2 vector2 = this.position + this.velocity; bool flag2 = false; int num1 = (int) ((double) vector2.X / 16.0); int num2 = (int) (((double) vector2.X + (double) this.width) / 16.0); int num3 = (int) (((double) this.position.Y + (double) this.height + 1.0) / 16.0); Microsoft.Xna.Framework.Rectangle rect = this.getRect(); rect.Inflate(1, 1); for (int i = num1; i <= num2; ++i) { for (int index = num3; index <= num3 + 1 && Main.tile[i, index] != null; ++index) { if (Main.tile[i, index].nactive() && !WorldGen.SolidTile(i, index - 1) && Main.tile[i, index].type >= (ushort) 481 && Main.tile[i, index].type <= (ushort) 483 && new Microsoft.Xna.Framework.Rectangle(i * 16, index * 16, 16, 16).Intersects(rect)) { flag2 = true; if ((double) this.velocity.Y > 1.0) this.velocity.Y = 1f; NetMessage.SendData(13, number: this.whoAmI); } } } if (!flag2) return; int num4 = (int) (((double) vector2.X - 16.0 - 8.0) / 16.0); int num5 = (int) (((double) vector2.X + (double) this.width + 16.0 + 8.0) / 16.0); for (int i = num4; i <= num5; ++i) { for (int j = num3; j <= num3 + 2; ++j) { if (Main.tile[i, j].nactive() && !WorldGen.SolidTile(i, j - 1) && Main.tile[i, j].type >= (ushort) 481 && Main.tile[i, j].type <= (ushort) 483) { WorldGen.KillTile(i, j); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) i), number3: ((float) j)); } } } } public void CheckIceBreak() { if ((double) this.velocity.Y <= 7.0) return; Vector2 vector2 = this.position + this.velocity; int num1 = (int) ((double) vector2.X / 16.0); int num2 = (int) (((double) vector2.X + (double) this.width) / 16.0); int num3 = (int) (((double) this.position.Y + (double) this.height + 1.0) / 16.0); for (int i = num1; i <= num2; ++i) { for (int j = num3; j <= num3 + 1 && Main.tile[i, j] != null; ++j) { if (Main.tile[i, j].nactive() && Main.tile[i, j].type == (ushort) 162 && !WorldGen.SolidTile(i, j - 1)) { WorldGen.KillTile(i, j); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) i), number3: ((float) j)); } } } } public void SlopeDownMovement() { this.sloping = false; float y = this.velocity.Y; Vector4 vector4 = Collision.WalkDownSlope(this.position, this.velocity, this.width, this.height, this.gravity * this.gravDir); this.position.X = vector4.X; this.position.Y = vector4.Y; this.velocity.X = vector4.Z; this.velocity.Y = vector4.W; if ((double) this.velocity.Y == (double) y) return; this.sloping = true; } public void HoneyCollision(bool fallThrough, bool ignorePlats) { int Height = !this.onTrack ? this.height : this.height - 20; Vector2 velocity = this.velocity; this.velocity = Collision.TileCollision(this.position, this.velocity, this.width, Height, fallThrough, ignorePlats, (int) this.gravDir); Vector2 vector2 = this.velocity * 0.25f; if ((double) this.velocity.X != (double) velocity.X) vector2.X = this.velocity.X; if ((double) this.velocity.Y != (double) velocity.Y) vector2.Y = this.velocity.Y; this.position = this.position + vector2; } public void WaterCollision(bool fallThrough, bool ignorePlats) { int Height = !this.onTrack ? this.height : this.height - 20; Vector2 velocity = this.velocity; this.velocity = Collision.TileCollision(this.position, this.velocity, this.width, Height, fallThrough, ignorePlats, (int) this.gravDir); Vector2 vector2 = this.velocity * 0.5f; if ((double) this.velocity.X != (double) velocity.X) vector2.X = this.velocity.X; if ((double) this.velocity.Y != (double) velocity.Y) vector2.Y = this.velocity.Y; this.position = this.position + vector2; this.TryFloatingInWater(); } private void TryFloatingInWater() { if (!this.ShouldFloatInWater) return; float waterLineHeight; if (Collision.GetWaterLine(this.Center.ToTileCoordinates(), out waterLineHeight)) { float y = this.Center.Y; if (this.mount.Active && this.mount.Type == 37) y -= 6f; float num = y + 8f; if ((double) num + (double) this.velocity.Y < (double) waterLineHeight) return; if ((double) y > (double) waterLineHeight) { this.velocity.Y -= 0.4f; if ((double) this.velocity.Y >= -6.0) return; this.velocity.Y = -6f; } else { this.velocity.Y = waterLineHeight - num; if ((double) this.velocity.Y < -3.0) this.velocity.Y = -3f; if ((double) this.velocity.Y != 0.0) return; this.velocity.Y = float.Epsilon; } } else this.velocity.Y -= 0.4f; } public void DryCollision(bool fallThrough, bool ignorePlats) { int Height = !this.onTrack ? this.height : this.height - 10; if ((double) this.velocity.Length() > 16.0) { Vector2 vector2_1 = Collision.TileCollision(this.position, this.velocity, this.width, Height, fallThrough, ignorePlats, (int) this.gravDir); float num1 = this.velocity.Length(); Vector2 vector2_2 = Vector2.Normalize(this.velocity); if ((double) vector2_1.Y == 0.0) vector2_2.Y = 0.0f; Vector2 zero1 = Vector2.Zero; bool flag = this.mount.Type == 7 || this.mount.Type == 8 || this.mount.Type == 12 || this.mount.Type == 44 || this.mount.Type == 48 || this.mount.Type == 49; Vector2 zero2 = Vector2.Zero; while ((double) num1 > 0.0) { float num2 = num1; if ((double) num2 > 16.0) num2 = 16f; num1 -= num2; Vector2 velocity1 = vector2_2 * num2; this.velocity = velocity1; this.SlopeDownMovement(); velocity1 = this.velocity; if ((double) this.velocity.Y == (double) this.gravity && (!this.mount.Active || !this.mount.Cart && !flag)) Collision.StepDown(ref this.position, ref velocity1, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, (int) this.gravDir, this.waterWalk || this.waterWalk2); if ((double) this.gravDir == -1.0) { if ((this.carpetFrame != -1 || (double) this.velocity.Y <= (double) this.gravity) && !this.controlUp) Collision.StepUp(ref this.position, ref velocity1, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, (int) this.gravDir, this.controlUp); } else if (flag || (this.carpetFrame != -1 || (double) this.velocity.Y >= (double) this.gravity) && !this.controlDown && !this.mount.Cart) Collision.StepUp(ref this.position, ref velocity1, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, (int) this.gravDir, this.controlUp); Vector2 Velocity = Collision.TileCollision(this.position, velocity1, this.width, Height, fallThrough, ignorePlats, (int) this.gravDir); if (Collision.up && (double) this.gravDir == 1.0) this.jump = 0; if (this.waterWalk || this.waterWalk2) { Vector2 velocity2 = this.velocity; Velocity = Collision.WaterCollision(this.position, Velocity, this.width, this.height, fallThrough, lavaWalk: this.waterWalk); Vector2 velocity3 = this.velocity; if (velocity2 != velocity3) this.fallStart = (int) ((double) this.position.Y / 16.0); } this.position = this.position + Velocity; bool Falling = false; if ((double) Velocity.Y > (double) this.gravity) Falling = true; if ((double) Velocity.Y < -(double) this.gravity) Falling = true; this.velocity = Velocity; this.UpdateTouchingTiles(); this.TryBouncingBlocks(Falling); this.TryLandingOnDetonator(); this.SlopingCollision(fallThrough, ignorePlats); Collision.StepConveyorBelt((Entity) this, this.gravDir); Vector2 velocity4 = this.velocity; zero1 += velocity4; } this.velocity = zero1; } else { this.velocity = Collision.TileCollision(this.position, this.velocity, this.width, Height, fallThrough, ignorePlats, (int) this.gravDir); if (Collision.up && (double) this.gravDir == 1.0) this.jump = 0; if (this.waterWalk || this.waterWalk2) { Vector2 velocity5 = this.velocity; this.velocity = Collision.WaterCollision(this.position, this.velocity, this.width, this.height, fallThrough, lavaWalk: this.waterWalk); Vector2 velocity6 = this.velocity; if (velocity5 != velocity6) this.fallStart = (int) ((double) this.position.Y / 16.0); } this.position = this.position + this.velocity; } } public void SlopingCollision(bool fallThrough, bool ignorePlats) { if (ignorePlats || this.controlDown || this.grappling[0] >= 0 || (double) this.gravDir == -1.0) this.stairFall = true; Vector4 vector4 = Collision.SlopeCollision(this.position, this.velocity, this.width, this.height, this.gravity, this.stairFall); if (Collision.stairFall) this.stairFall = true; else if (!fallThrough) this.stairFall = false; if (Collision.stair && (double) Math.Abs(vector4.Y - this.position.Y) > 8.0 + (double) Math.Abs(this.velocity.X)) { this.gfxOffY -= vector4.Y - this.position.Y; this.stepSpeed = 4f; } Vector2 velocity = this.velocity; this.position.X = vector4.X; this.position.Y = vector4.Y; this.velocity.X = vector4.Z; this.velocity.Y = vector4.W; if ((double) this.gravDir != -1.0 || (double) this.velocity.Y != 0.0100999996066093) return; this.velocity.Y = 0.0f; } public void FloorVisuals(bool Falling) { int x = (int) (((double) this.position.X + (double) (this.width / 2)) / 16.0); int y = (int) (((double) this.position.Y + (double) this.height) / 16.0); if ((double) this.gravDir == -1.0) y = (int) ((double) this.position.Y - 0.100000001490116) / 16; int type = Player.GetFloorTileType(x, y); if (type <= -1) { this.ResetFloorFlags(); } else { this.sticky = type == 229; this.slippy = type == 161 || type == 162 || type == 163 || type == 164 || type == 200 || type == (int) sbyte.MaxValue; this.slippy2 = type == 197; this.powerrun = type == 198; this.runningOnSand = TileID.Sets.Conversion.Sand[type] || TileID.Sets.Conversion.Sandstone[type] || TileID.Sets.Conversion.HardenedSand[type]; if (Main.tile[x - 1, y].slope() != (byte) 0 || Main.tile[x, y].slope() != (byte) 0 || Main.tile[x + 1, y].slope() != (byte) 0) type = -1; if ((this.wet ? 0 : (!this.mount.Cart ? 1 : 0)) == 0) return; this.MakeFloorDust(Falling, type); } } private void ResetFloorFlags() { this.slippy = false; this.slippy2 = false; this.sticky = false; this.powerrun = false; this.runningOnSand = false; } private static int GetFloorTileType(int x, int y) { int num = -1; if (Main.tile[x - 1, y] == null) Main.tile[x - 1, y] = new Tile(); if (Main.tile[x + 1, y] == null) Main.tile[x + 1, y] = new Tile(); if (Main.tile[x, y] == null) Main.tile[x, y] = new Tile(); if (Main.tile[x, y].nactive() && Main.tileSolid[(int) Main.tile[x, y].type]) num = (int) Main.tile[x, y].type; else if (Main.tile[x - 1, y].nactive() && Main.tileSolid[(int) Main.tile[x - 1, y].type]) num = (int) Main.tile[x - 1, y].type; else if (Main.tile[x + 1, y].nactive() && Main.tileSolid[(int) Main.tile[x + 1, y].type]) num = (int) Main.tile[x + 1, y].type; return num; } private void MakeFloorDust(bool Falling, int type) { if (type != 147 && type != 25 && type != 53 && type != 189 && type != 0 && type != 123 && type != 57 && type != 112 && type != 116 && type != 196 && type != 193 && type != 195 && type != 197 && type != 199 && type != 229 && type != 371 && type != 460) return; int num1 = 1; if (Falling) num1 = 20; for (int index1 = 0; index1 < num1; ++index1) { bool flag = true; int Type = 76; if (type == 53) Type = 32; if (type == 189) Type = 16; if (type == 0) Type = 0; if (type == 123) Type = 53; if (type == 57) Type = 36; if (type == 112) Type = 14; if (type == 116) Type = 51; if (type == 196) Type = 108; if (type == 193) Type = 4; if (type == 195 || type == 199) Type = 5; if (type == 197) Type = 4; if (type == 229) Type = 153; if (type == 371) Type = 243; if (type == 460) Type = 108; if (type == 25) Type = 37; if (Type == 32 && Main.rand.Next(2) == 0) flag = false; if (Type == 14 && Main.rand.Next(2) == 0) flag = false; if (Type == 51 && Main.rand.Next(2) == 0) flag = false; if (Type == 36 && Main.rand.Next(2) == 0) flag = false; if (Type == 0 && Main.rand.Next(3) != 0) flag = false; if (Type == 53 && Main.rand.Next(3) != 0) flag = false; Color newColor = new Color(); if (type == 193) newColor = new Color(30, 100, (int) byte.MaxValue, 100); if (type == 197) newColor = new Color(97, 200, (int) byte.MaxValue, 100); if (!Falling) { float num2 = Math.Abs(this.velocity.X) / 3f; if ((double) Main.rand.Next(100) > (double) num2 * 100.0) flag = false; } if (flag) { float num3 = this.velocity.X; if ((double) num3 > 6.0) num3 = 6f; if ((double) num3 < -6.0) num3 = -6f; if ((double) this.velocity.X != 0.0 | Falling) { int index2 = Dust.NewDust(new Vector2(this.position.X, (float) ((double) this.position.Y + (double) this.height - 2.0)), this.width, 6, Type, Alpha: 50, newColor: newColor); if ((double) this.gravDir == -1.0) Main.dust[index2].position.Y -= (float) (this.height + 4); if (Type == 76) { Main.dust[index2].scale += (float) Main.rand.Next(3) * 0.1f; Main.dust[index2].noLight = true; } if (Type == 16 || Type == 108 || Type == 153) Main.dust[index2].scale += (float) Main.rand.Next(6) * 0.1f; if (Type == 37) { Main.dust[index2].scale += 0.25f; Main.dust[index2].alpha = 50; } if (Type == 5) Main.dust[index2].scale += (float) Main.rand.Next(2, 8) * 0.1f; Main.dust[index2].noGravity = true; if (num1 > 1) { Main.dust[index2].velocity.X *= 1.2f; Main.dust[index2].velocity.Y *= 0.8f; --Main.dust[index2].velocity.Y; Main.dust[index2].velocity *= 0.8f; Main.dust[index2].scale += (float) Main.rand.Next(3) * 0.1f; Main.dust[index2].velocity.X = (float) (((double) Main.dust[index2].position.X - ((double) this.position.X + (double) (this.width / 2))) * 0.200000002980232); if ((double) Main.dust[index2].velocity.Y > 0.0) Main.dust[index2].velocity.Y *= -1f; Main.dust[index2].velocity.X += num3 * 0.3f; } else Main.dust[index2].velocity *= 0.2f; Main.dust[index2].position.X -= num3 * 1f; if ((double) this.gravDir == -1.0) Main.dust[index2].velocity.Y *= -1f; } } } } public void BordersMovement() { if ((double) this.position.X < (double) Main.leftWorld + 640.0 + 16.0) { Main.cameraX = 0.0f; this.position.X = (float) ((double) Main.leftWorld + 640.0 + 16.0); this.velocity.X = 0.0f; } if ((double) this.position.X + (double) this.width > (double) Main.rightWorld - 640.0 - 32.0) { Main.cameraX = 0.0f; this.position.X = (float) ((double) Main.rightWorld - 640.0 - 32.0) - (float) this.width; this.velocity.X = 0.0f; } if ((double) this.position.Y < (double) Main.topWorld + 640.0 + 16.0) { this.position.Y = (float) ((double) Main.topWorld + 640.0 + 16.0); if ((double) this.velocity.Y < 0.11) this.velocity.Y = 0.11f; this.gravDir = 1f; AchievementsHelper.HandleSpecialEvent(this, 11); } if ((double) this.position.Y > (double) Main.bottomWorld - 640.0 - 32.0 - (double) this.height) { this.position.Y = (float) ((double) Main.bottomWorld - 640.0 - 32.0) - (float) this.height; this.velocity.Y = 0.0f; } if ((double) this.position.Y <= (double) Main.bottomWorld - 640.0 - 150.0 - (double) this.height) return; AchievementsHelper.HandleSpecialEvent(this, 10); } public void CollectTaxes() { int num1 = Item.buyPrice(copper: 50); int num2 = Item.buyPrice(gold: 10); if (!NPC.taxCollector || this.taxMoney >= num2) return; int num3 = 0; for (int index = 0; index < 200; ++index) { if (Main.npc[index].active && !Main.npc[index].homeless && !NPCID.Sets.IsTownPet[Main.npc[index].type] && NPC.TypeToDefaultHeadIndex(Main.npc[index].type) > 0) ++num3; } this.taxMoney += num1 * num3; if (this.taxMoney <= num2) return; this.taxMoney = num2; } public void GamepadEnableGrappleCooldown() => this._quickGrappleCooldown = 3; public void TryInterruptingItemUsage() { bool flag1 = false; if (this.heldProj > -1 && Main.projectile[this.heldProj].IsInterruptible(this)) flag1 = true; if (!flag1) return; bool flag2 = false; if (PlayerInput.Triggers.Current.Hotbar1) flag2 = true; if (PlayerInput.Triggers.Current.Hotbar2) flag2 = true; if (PlayerInput.Triggers.Current.Hotbar3) flag2 = true; if (PlayerInput.Triggers.Current.Hotbar4) flag2 = true; if (PlayerInput.Triggers.Current.Hotbar5) flag2 = true; if (PlayerInput.Triggers.Current.Hotbar6) flag2 = true; if (PlayerInput.Triggers.Current.Hotbar7) flag2 = true; if (PlayerInput.Triggers.Current.Hotbar8) flag2 = true; if (PlayerInput.Triggers.Current.Hotbar9) flag2 = true; if (PlayerInput.Triggers.Current.Hotbar10) flag2 = true; bool flag3 = Main.hairWindow; if (flag3) { int y = Main.screenHeight / 2 + 60; flag3 = new Microsoft.Xna.Framework.Rectangle(Main.screenWidth / 2 - TextureAssets.HairStyleBack.Width() / 2, y, TextureAssets.HairStyleBack.Width(), TextureAssets.HairStyleBack.Height()).Contains(Main.MouseScreen.ToPoint()); } if ((Main.mapFullscreen || CaptureManager.Instance.Active || flag3 ? 0 : (!Main.playerInventory ? 1 : 0)) != 0) { int Offset = PlayerInput.Triggers.Current.HotbarPlus.ToInt() - PlayerInput.Triggers.Current.HotbarMinus.ToInt(); if (PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired != -1) Offset = PlayerInput.Triggers.JustReleased.HotbarPlus.ToInt() - PlayerInput.Triggers.JustReleased.HotbarMinus.ToInt(); if (PlayerInput.Triggers.Current.HotbarScrollCD != 0) Offset = 0; if (!Main.inFancyUI && !Main.ingameOptionsWindow) Offset += PlayerInput.ScrollWheelDelta / -120; if (Offset != 0) { int num = this.selectedItem + Player.ClampHotbarOffset(Offset); flag2 = true; } } if (!flag2 || this.heldProj <= -1) return; Main.projectile[this.heldProj].Interrupt(this); } private bool CanMoveForwardOnRope(int dir, int x, int y) { int index = x + dir; if (Main.tile[index, y] == null || !Main.tile[index, y].active() || !Main.tileRope[(int) Main.tile[index, y].type]) return false; int num = index * 16 + 8 - this.width / 2; float y1 = this.position.Y; float y2 = (float) (y * 16 + 22); if ((!Main.tile[index, y - 1].active() || !Main.tileRope[(int) Main.tile[index, y - 1].type]) && (!Main.tile[index, y + 1].active() || !Main.tileRope[(int) Main.tile[index, y + 1].type])) y2 = (float) (y * 16 + 22); return !Collision.SolidCollision(new Vector2((float) num, y2), this.width, this.height); } public void UpdateHairDyeDust() { if (Main.netMode == 2 || Main.gamePaused || this.dead || this.ghost || this.stoned || this.frozen || (int) this.hairDye != ContentSamples.CommonlyUsedContentSamples.TeamDyeShaderIndex) return; if (Main.rand.Next(45) == 0) { int index = Dust.NewDust(this.position, this.width, 8, Main.rand.Next(139, 143), Scale: 1.2f); Main.dust[index].velocity.X *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.dust[index].velocity.Y *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.dust[index].velocity.X += (float) Main.rand.Next(-50, 51) * 0.01f; Main.dust[index].velocity.Y += (float) Main.rand.Next(-50, 51) * 0.01f; --Main.dust[index].velocity.Y; Main.dust[index].scale *= (float) (0.699999988079071 + (double) Main.rand.Next(-30, 31) * 0.00999999977648258); Main.dust[index].velocity += this.velocity * 0.2f; } if (Main.rand.Next(225) != 0) return; int Type = Main.rand.Next(276, 283); int index1 = Gore.NewGore(new Vector2(this.position.X + (float) Main.rand.Next(this.width), this.position.Y + (float) Main.rand.Next(8)), this.velocity, Type); Main.gore[index1].velocity.X *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.gore[index1].velocity.Y *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.gore[index1].scale *= (float) (1.0 + (double) Main.rand.Next(-20, 21) * 0.00999999977648258); Main.gore[index1].velocity.X += (float) Main.rand.Next(-50, 51) * 0.01f; Main.gore[index1].velocity.Y += (float) Main.rand.Next(-50, 51) * 0.01f; --Main.gore[index1].velocity.Y; Main.gore[index1].velocity += this.velocity * 0.2f; } public void Update(int i) { this.UpdateHairDyeDust(); if (i == Main.myPlayer && Main.netMode != 2) LockOnHelper.Update(); if (this.launcherWait > 0) --this.launcherWait; this.maxFallSpeed = 10f; this.gravity = Player.defaultGravity; Player.jumpHeight = 15; Player.jumpSpeed = 5.01f; this.maxRunSpeed = 3f; this.runAcceleration = 0.08f; this.runSlowdown = 0.2f; this.accRunSpeed = this.maxRunSpeed; if (!this.mount.Active || !this.mount.Cart) this.onWrongGround = false; this.heldProj = -1; this.instantMovementAccumulatedThisFrame = Vector2.Zero; if (this.PortalPhysicsEnabled) this.maxFallSpeed = 35f; if (this.wet) { if (this.honeyWet) { this.gravity = 0.1f; this.maxFallSpeed = 3f; } else if (this.merman) { this.gravity = 0.3f; this.maxFallSpeed = 7f; } else if (this.trident && !this.lavaWet) { this.gravity = 0.25f; this.maxFallSpeed = 6f; Player.jumpHeight = 25; Player.jumpSpeed = 5.51f; if (this.controlUp) { this.gravity = 0.1f; this.maxFallSpeed = 2f; } } else { this.gravity = 0.2f; this.maxFallSpeed = 5f; Player.jumpHeight = 30; Player.jumpSpeed = 6.01f; } } if (this.vortexDebuff) this.gravity = 0.0f; this.maxFallSpeed += 0.01f; bool flag1 = false; if (Main.mapFullscreen) this.GamepadEnableGrappleCooldown(); else if (this._quickGrappleCooldown > 0) --this._quickGrappleCooldown; if (Main.myPlayer == i) { TileObject.objectPreview.Reset(); if (DD2Event.DownedInvasionAnyDifficulty) this.downedDD2EventAnyDifficulty = true; } if (this.active) { if (NPC.freeCake && this.talkNPC >= 0 && Main.npc[this.talkNPC].type == 208) { NPC.freeCake = false; if (Main.netMode != 1) Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, 3750); } if (this.emoteTime > 0) --this.emoteTime; if ((double) this.ghostDmg > 0.0) this.ghostDmg -= 4.166667f; if ((double) this.ghostDmg < 0.0) this.ghostDmg = 0.0f; if (Main.expertMode) { if ((double) this.lifeSteal < 70.0) this.lifeSteal += 0.5f; if ((double) this.lifeSteal > 70.0) this.lifeSteal = 70f; } else { if ((double) this.lifeSteal < 80.0) this.lifeSteal += 0.6f; if ((double) this.lifeSteal > 80.0) this.lifeSteal = 80f; } this.ResizeHitbox(); if (this.mount.Active && this.mount.Type == 0) { int i1 = (int) ((double) this.position.X + (double) (this.width / 2)) / 16; int j = (int) ((double) this.position.Y + (double) (this.height / 2) - 14.0) / 16; Lighting.AddLight(i1, j, 0.5f, 0.2f, 0.05f); Lighting.AddLight(i1 + this.direction, j, 0.5f, 0.2f, 0.05f); Lighting.AddLight(i1 + this.direction * 2, j, 0.5f, 0.2f, 0.05f); } this.outOfRange = false; if (this.whoAmI != Main.myPlayer) { int x = (int) ((double) this.position.X + (double) (this.width / 2)) / 16; int y = (int) ((double) this.position.Y + (double) (this.height / 2)) / 16; if (!WorldGen.InWorld(x, y, 4)) flag1 = true; else if (Main.tile[x, y] == null) flag1 = true; else if (Main.tile[x - 3, y] == null) flag1 = true; else if (Main.tile[x + 3, y] == null) flag1 = true; else if (Main.tile[x, y - 3] == null) flag1 = true; else if (Main.tile[x, y + 3] == null) flag1 = true; if (flag1) { this.outOfRange = true; this.numMinions = 0; this.slotsMinions = 0.0f; this.itemAnimation = 0; this.UpdateBuffs(i); this.PlayerFrame(); } } if (this.tankPet >= 0) { if (!this.tankPetReset) this.tankPetReset = true; else this.tankPet = -1; } if (i == Main.myPlayer) this.IsVoidVaultEnabled = this.HasItem(4131); } if (this.chatOverhead.timeLeft > 0) --this.chatOverhead.timeLeft; if (!this.active | flag1) return; this.UpdateMiscCounter(); ++this.infernoCounter; if (this.infernoCounter >= 180) this.infernoCounter = 0; if (this.starCloakCooldown > 0) { --this.starCloakCooldown; if (Main.rand.Next(5) == 0) { for (int index = 0; index < 2; ++index) { Dust dust = Dust.NewDustDirect(this.position, this.width, this.height, 45, Alpha: ((int) byte.MaxValue), Scale: ((float) Main.rand.Next(20, 26) * 0.1f)); dust.noLight = true; dust.noGravity = true; dust.velocity *= 0.5f; dust.velocity.X = 0.0f; dust.velocity.Y -= 0.5f; } } if (this.starCloakCooldown == 0) SoundEngine.PlaySound(25); } ++this._timeSinceLastImmuneGet; if (this._timeSinceLastImmuneGet >= 10000) this._timeSinceLastImmuneGet = 10000; float num1 = (float) (Main.maxTilesX / 4200); float num2 = (float) (((double) this.position.Y / 16.0 - (60.0 + 10.0 * (double) (num1 * num1))) / (Main.worldSurface / 6.0)); if ((double) num2 < 0.25) num2 = 0.25f; if ((double) num2 > 1.0) num2 = 1f; this.gravity *= num2; this.maxRegenDelay = (float) ((1.0 - (double) this.statMana / (double) this.statManaMax2) * 60.0 * 4.0 + 45.0); this.maxRegenDelay *= 0.7f; this.UpdateSocialShadow(); this.UpdateTeleportVisuals(); this.whoAmI = i; if (this.whoAmI == Main.myPlayer) { if (!DD2Event.Ongoing) this.PurgeDD2EnergyCrystals(); this.TryPortalJumping(); if (this.whoAmI == Main.myPlayer) this.doorHelper.Update(this); } if (this.runSoundDelay > 0) --this.runSoundDelay; if (this.attackCD > 0) --this.attackCD; if (this.itemAnimation == 0) this.attackCD = 0; if (this.potionDelay > 0) --this.potionDelay; if (i == Main.myPlayer) { if (this.trashItem.type >= 1522 && this.trashItem.type <= 1527) this.trashItem.SetDefaults(); if (this.trashItem.type == 3643) this.trashItem.SetDefaults(); this.UpdateBiomes(); this.UpdateMinionTarget(); } if (this.ghost) this.Ghost(); else if (this.dead) { this.UpdateDead(); this.ResetProjectileCaches(); this.UpdateProjectileCaches(i); } else { if ((double) this.velocity.Y == 0.0) this.mount.FatigueRecovery(); if (i == Main.myPlayer) { this.controlUp = false; this.controlLeft = false; this.controlDown = false; this.controlRight = false; this.controlJump = false; this.controlUseItem = false; this.controlUseTile = false; this.controlThrow = false; this.controlInv = false; this.controlHook = false; this.controlTorch = false; this.controlSmart = false; this.controlMount = false; this.controlQuickHeal = false; this.controlQuickMana = false; this.controlCreativeMenu = false; this.mapStyle = false; this.mapAlphaDown = false; this.mapAlphaUp = false; this.mapFullScreen = false; this.mapZoomIn = false; this.mapZoomOut = false; if (Main.hasFocus) { if (!Main.drawingPlayerChat && !Main.editSign && !Main.editChest && !Main.blockInput) { PlayerInput.Triggers.Current.CopyInto(this); if (Main.mapFullscreen) { if (this.controlUp) Main.mapFullscreenPos.Y -= (float) (1.0 * (16.0 / (double) Main.mapFullscreenScale)); if (this.controlDown) Main.mapFullscreenPos.Y += (float) (1.0 * (16.0 / (double) Main.mapFullscreenScale)); if (this.controlLeft) Main.mapFullscreenPos.X -= (float) (1.0 * (16.0 / (double) Main.mapFullscreenScale)); if (this.controlRight) Main.mapFullscreenPos.X += (float) (1.0 * (16.0 / (double) Main.mapFullscreenScale)); this.controlUp = false; this.controlLeft = false; this.controlDown = false; this.controlRight = false; this.controlJump = false; this.controlUseItem = false; this.controlUseTile = false; this.controlThrow = false; this.controlHook = false; this.controlTorch = false; this.controlSmart = false; this.controlMount = false; } if (this.controlQuickHeal) { if (this.releaseQuickHeal) this.QuickHeal(); this.releaseQuickHeal = false; } else this.releaseQuickHeal = true; if (this.controlQuickMana) { if (this.releaseQuickMana) this.QuickMana(); this.releaseQuickMana = false; } else this.releaseQuickMana = true; if (this.controlCreativeMenu) { if (this.releaseCreativeMenu) this.ToggleCreativeMenu(); this.releaseCreativeMenu = false; } else this.releaseCreativeMenu = true; if (this.controlLeft && this.controlRight) { this.controlLeft = false; this.controlRight = false; } if (PlayerInput.UsingGamepad || !this.mouseInterface || !ItemSlot.Options.DisableLeftShiftTrashCan) { if (Main.cSmartCursorModeIsToggleAndNotHold) { if (this.controlSmart && this.releaseSmart) { SoundEngine.PlaySound(12); Main.SmartCursorEnabled = !Main.SmartCursorEnabled; } } else { if (this.controlSmart && this.releaseSmart) SoundEngine.PlaySound(12); if (Main.SmartCursorEnabled) { if (!this.controlSmart && !this.controlUseItem) Main.SmartCursorEnabled = false; } else Main.SmartCursorEnabled = this.controlSmart; } } this.releaseSmart = !this.controlSmart; if (this.controlMount) { if (this.releaseMount) this.QuickMount(); this.releaseMount = false; } else this.releaseMount = true; if (Main.mapFullscreen) { if (this.mapZoomIn) Main.mapFullscreenScale *= 1.05f; if (this.mapZoomOut) Main.mapFullscreenScale *= 0.95f; } else { switch (Main.mapStyle) { case 1: if (this.mapZoomIn) Main.mapMinimapScale *= 1.025f; if (this.mapZoomOut) Main.mapMinimapScale *= 0.975f; if (this.mapAlphaUp) Main.mapMinimapAlpha += 0.015f; if (this.mapAlphaDown) { Main.mapMinimapAlpha -= 0.015f; break; } break; case 2: if (this.mapZoomIn) Main.mapOverlayScale *= 1.05f; if (this.mapZoomOut) Main.mapOverlayScale *= 0.95f; if (this.mapAlphaUp) Main.mapOverlayAlpha += 0.015f; if (this.mapAlphaDown) { Main.mapOverlayAlpha -= 0.015f; break; } break; } if (this.mapStyle) { if (this.releaseMapStyle) { SoundEngine.PlaySound(12); ++Main.mapStyle; if (Main.mapStyle > 2) Main.mapStyle = 0; } this.releaseMapStyle = false; } else this.releaseMapStyle = true; } if (this.mapFullScreen) { if (this.releaseMapFullscreen) { if (Main.mapFullscreen) { SoundEngine.PlaySound(11); Main.mapFullscreen = false; } else this.TryOpeningFullscreenMap(); } this.releaseMapFullscreen = false; } else this.releaseMapFullscreen = true; } else if (!PlayerInput.UsingGamepad && !Main.editSign && !Main.editChest && !Main.blockInput) PlayerInput.Triggers.Current.CopyIntoDuringChat(this); if (this.confused) { bool controlLeft = this.controlLeft; bool controlUp = this.controlUp; this.controlLeft = this.controlRight; this.controlRight = controlLeft; this.controlUp = this.controlRight; this.controlDown = controlUp; } else if (this.cartFlip) { if (this.controlRight || this.controlLeft) { bool controlLeft = this.controlLeft; this.controlLeft = this.controlRight; this.controlRight = controlLeft; } else this.cartFlip = false; } for (int index = 0; index < this.doubleTapCardinalTimer.Length; ++index) { --this.doubleTapCardinalTimer[index]; if (this.doubleTapCardinalTimer[index] < 0) this.doubleTapCardinalTimer[index] = 0; } for (int keyDir = 0; keyDir < 4; ++keyDir) { bool flag2 = false; bool flag3 = false; switch (keyDir) { case 0: flag2 = this.controlDown && this.releaseDown; flag3 = this.controlDown; break; case 1: flag2 = this.controlUp && this.releaseUp; flag3 = this.controlUp; break; case 2: flag2 = this.controlRight && this.releaseRight; flag3 = this.controlRight; break; case 3: flag2 = this.controlLeft && this.releaseLeft; flag3 = this.controlLeft; break; } if (flag2) { if (this.doubleTapCardinalTimer[keyDir] > 0) this.KeyDoubleTap(keyDir); else this.doubleTapCardinalTimer[keyDir] = 15; } if (flag3) { ++this.holdDownCardinalTimer[keyDir]; this.KeyHoldDown(keyDir, this.holdDownCardinalTimer[keyDir]); } else this.holdDownCardinalTimer[keyDir] = 0; } if (this.controlInv) { if (this.releaseInventory) this.ToggleInv(); this.releaseInventory = false; } else this.releaseInventory = true; if (this.delayUseItem) { if (!this.controlUseItem) this.delayUseItem = false; this.controlUseItem = false; } if (this.itemAnimation == 0 && this.ItemTimeIsZero && this.reuseDelay == 0) { this.dropItemCheck(); int selectedItem = this.selectedItem; bool flag4 = false; if (!Main.drawingPlayerChat && this.selectedItem != 58 && !Main.editSign && !Main.editChest) { if (PlayerInput.Triggers.Current.Hotbar1) { this.selectedItem = 0; flag4 = true; } if (PlayerInput.Triggers.Current.Hotbar2) { this.selectedItem = 1; flag4 = true; } if (PlayerInput.Triggers.Current.Hotbar3) { this.selectedItem = 2; flag4 = true; } if (PlayerInput.Triggers.Current.Hotbar4) { this.selectedItem = 3; flag4 = true; } if (PlayerInput.Triggers.Current.Hotbar5) { this.selectedItem = 4; flag4 = true; } if (PlayerInput.Triggers.Current.Hotbar6) { this.selectedItem = 5; flag4 = true; } if (PlayerInput.Triggers.Current.Hotbar7) { this.selectedItem = 6; flag4 = true; } if (PlayerInput.Triggers.Current.Hotbar8) { this.selectedItem = 7; flag4 = true; } if (PlayerInput.Triggers.Current.Hotbar9) { this.selectedItem = 8; flag4 = true; } if (PlayerInput.Triggers.Current.Hotbar10) { this.selectedItem = 9; flag4 = true; } int selectedBinding1 = this.DpadRadial.SelectedBinding; int selectedBinding2 = this.CircularRadial.SelectedBinding; int selectedBinding3 = this.QuicksRadial.SelectedBinding; this.DpadRadial.Update(); this.CircularRadial.Update(); this.QuicksRadial.Update(); if (this.CircularRadial.SelectedBinding >= 0 && selectedBinding2 != this.CircularRadial.SelectedBinding) this.DpadRadial.ChangeSelection(-1); if (this.DpadRadial.SelectedBinding >= 0 && selectedBinding1 != this.DpadRadial.SelectedBinding) this.CircularRadial.ChangeSelection(-1); if (this.QuicksRadial.SelectedBinding != -1 && PlayerInput.Triggers.JustReleased.RadialQuickbar && !PlayerInput.MiscSettingsTEMP.HotbarRadialShouldBeUsed) { switch (this.QuicksRadial.SelectedBinding) { case 0: this.QuickMount(); break; case 1: this.QuickHeal(); break; case 2: this.QuickBuff(); break; case 3: this.QuickMana(); break; } } if (this.controlTorch | flag4) { this.DpadRadial.ChangeSelection(-1); this.CircularRadial.ChangeSelection(-1); } if (this.controlTorch & flag4) { if (this.selectedItem != this.nonTorch) SoundEngine.PlaySound(12); this.nonTorch = this.selectedItem; this.selectedItem = selectedItem; flag4 = false; } } bool flag5 = Main.hairWindow; Microsoft.Xna.Framework.Rectangle rectangle; if (flag5) { int y = Main.screenHeight / 2 + 60; rectangle = new Microsoft.Xna.Framework.Rectangle(Main.screenWidth / 2 - TextureAssets.HairStyleBack.Width() / 2, y, TextureAssets.HairStyleBack.Width(), TextureAssets.HairStyleBack.Height()); flag5 = rectangle.Contains(Main.MouseScreen.ToPoint()); } if (flag4 && CaptureManager.Instance.Active) CaptureManager.Instance.Active = false; if (selectedItem != this.selectedItem) SoundEngine.PlaySound(12); if (Main.mapFullscreen) { float num3 = (float) (PlayerInput.ScrollWheelDelta / 120); if (PlayerInput.UsingGamepad) num3 += (float) (PlayerInput.Triggers.Current.HotbarPlus.ToInt() - PlayerInput.Triggers.Current.HotbarMinus.ToInt()) * 0.1f; Main.mapFullscreenScale *= (float) (1.0 + (double) num3 * 0.300000011920929); } else if (CaptureManager.Instance.Active) CaptureManager.Instance.Scrolling(); else if (!flag5) { if (!Main.playerInventory) { this.HandleHotbar(); } else { int mouseScrollDelta = Player.GetMouseScrollDelta(); bool flag6 = true; if (Main.recBigList) { int num4 = 42; int y = 340; int x = 310; PlayerInput.SetZoom_UI(); int num5 = (Main.screenWidth - x - 280) / num4; int num6 = (Main.screenHeight - y - 20) / num4; rectangle = new Microsoft.Xna.Framework.Rectangle(x, y, num5 * num4, num6 * num4); if (rectangle.Contains(Main.MouseScreen.ToPoint())) { mouseScrollDelta *= -1; int num7 = Math.Sign(mouseScrollDelta); for (; mouseScrollDelta != 0; mouseScrollDelta -= num7) { if (mouseScrollDelta < 0) { Main.recStart -= num5; if (Main.recStart < 0) Main.recStart = 0; } else { Main.recStart += num5; if (Main.recStart > Main.numAvailableRecipes - num5) Main.recStart = Main.numAvailableRecipes - num5; } } } PlayerInput.SetZoom_World(); } if (flag6) { Main.focusRecipe += mouseScrollDelta; if (Main.focusRecipe > Main.numAvailableRecipes - 1) Main.focusRecipe = Main.numAvailableRecipes - 1; if (Main.focusRecipe < 0) Main.focusRecipe = 0; } } } } else { bool flag7 = false; if (!Main.drawingPlayerChat && this.selectedItem != 58 && !Main.editSign && !Main.editChest) { int num8 = -1; if (Main.keyState.IsKeyDown(Keys.D1)) { num8 = 0; flag7 = true; } if (Main.keyState.IsKeyDown(Keys.D2)) { num8 = 1; flag7 = true; } if (Main.keyState.IsKeyDown(Keys.D3)) { num8 = 2; flag7 = true; } if (Main.keyState.IsKeyDown(Keys.D4)) { num8 = 3; flag7 = true; } if (Main.keyState.IsKeyDown(Keys.D5)) { num8 = 4; flag7 = true; } if (Main.keyState.IsKeyDown(Keys.D6)) { num8 = 5; flag7 = true; } if (Main.keyState.IsKeyDown(Keys.D7)) { num8 = 6; flag7 = true; } if (Main.keyState.IsKeyDown(Keys.D8)) { num8 = 7; flag7 = true; } if (Main.keyState.IsKeyDown(Keys.D9)) { num8 = 8; flag7 = true; } if (Main.keyState.IsKeyDown(Keys.D0)) { num8 = 9; flag7 = true; } if (flag7) { if (num8 != this.nonTorch) SoundEngine.PlaySound(12); this.nonTorch = num8; } } } } if (this.selectedItem != 58) this.SmartSelectLookup(); if (this.stoned != this.lastStoned) { if (this.whoAmI == Main.myPlayer && this.stoned) { int Damage = (int) (20.0 * (double) Main.GameModeInfo.EnemyDamageMultiplier); this.Hurt(PlayerDeathReason.ByOther(5), Damage, 0); } SoundEngine.PlaySound(0, (int) this.position.X, (int) this.position.Y); for (int index1 = 0; index1 < 20; ++index1) { int index2 = Dust.NewDust(this.position, this.width, this.height, 1); if (Main.rand.Next(2) == 0) Main.dust[index2].noGravity = true; } } this.lastStoned = this.stoned; if (this.frozen || this.webbed || this.stoned) { this.controlJump = false; this.controlDown = false; this.controlLeft = false; this.controlRight = false; this.controlUp = false; this.controlUseItem = false; this.controlUseTile = false; this.controlThrow = false; this.gravDir = 1f; } this.releaseThrow = !this.controlThrow; if (this.controlDown && this.releaseDown) { if (this.tryKeepingHoveringUp) this.tryKeepingHoveringUp = false; else this.tryKeepingHoveringDown = true; } if (this.controlUp && this.releaseUp) { if (this.tryKeepingHoveringDown) this.tryKeepingHoveringDown = false; else this.tryKeepingHoveringUp = true; } if ((double) this.velocity.Y == 0.0) { this.tryKeepingHoveringUp = false; this.tryKeepingHoveringDown = false; } if (Player.Settings.HoverControl == Player.Settings.HoverControlMode.Hold) { this.tryKeepingHoveringUp = false; this.tryKeepingHoveringDown = false; } if (Main.netMode == 1) { bool flag8 = false; if (this.controlUp != Main.clientPlayer.controlUp) flag8 = true; if (this.controlDown != Main.clientPlayer.controlDown) flag8 = true; if (this.controlLeft != Main.clientPlayer.controlLeft) flag8 = true; if (this.controlRight != Main.clientPlayer.controlRight) flag8 = true; if (this.controlJump != Main.clientPlayer.controlJump) flag8 = true; if (this.controlUseItem != Main.clientPlayer.controlUseItem) flag8 = true; if (this.selectedItem != Main.clientPlayer.selectedItem) flag8 = true; if (flag8) NetMessage.SendData(13, number: Main.myPlayer); } if (Main.playerInventory) this.AdjTiles(); this.HandleBeingInChestRange(); this.tileEntityAnchor.GetTileEntity()?.OnPlayerUpdate(this); if ((double) this.velocity.Y <= 0.0) this.fallStart2 = (int) ((double) this.position.Y / 16.0); if ((double) this.velocity.Y == 0.0) { int num9 = 25 + this.extraFall; int num10 = (int) ((double) this.position.Y / 16.0) - this.fallStart; if (this.mount.CanFly()) num10 = 0; if (this.mount.Cart && Minecart.OnTrack(this.position, this.width, this.height)) num10 = 0; if (this.mount.Type == 1) num10 = 0; if (num10 > 0 || (double) this.gravDir == -1.0 && num10 < 0) { int num11 = (int) ((double) this.position.X / 16.0); int num12 = (int) (((double) this.position.X + (double) this.width) / 16.0); int index3 = (int) (((double) this.position.Y + (double) this.height + 1.0) / 16.0); if ((double) this.gravDir == -1.0) index3 = (int) (((double) this.position.Y - 1.0) / 16.0); for (int index4 = num11; index4 <= num12; ++index4) { if (Main.tile[index4, index3] != null && Main.tile[index4, index3].active() && (Main.tile[index4, index3].type == (ushort) 189 || Main.tile[index4, index3].type == (ushort) 196 || Main.tile[index4, index3].type == (ushort) 460)) { num10 = 0; break; } } } bool flag9 = false; for (int index = 3; index < 10; ++index) { if (this.armor[index].stack > 0 && this.armor[index].wingSlot > (sbyte) -1) flag9 = true; } if (this.stoned) { int Damage = (int) (((double) num10 * (double) this.gravDir - 2.0) * 20.0); if (Damage > 0) { this.Hurt(PlayerDeathReason.ByOther(5), Damage, 0); this.immune = false; } } else if (((double) this.gravDir == 1.0 && num10 > num9 || (double) this.gravDir == -1.0 && num10 < -num9) && !this.noFallDmg && !flag9) { this.immune = false; int Damage = (int) ((double) num10 * (double) this.gravDir - (double) num9) * 10; if (this.mount.Active) Damage = (int) ((double) Damage * (double) this.mount.FallDamage); this.Hurt(PlayerDeathReason.ByOther(0), Damage, 0); if (!this.dead && this.statLife <= this.statLifeMax2 / 10) AchievementsHelper.HandleSpecialEvent(this, 8); } this.fallStart = (int) ((double) this.position.Y / 16.0); } if (this.jump > 0 || this.rocketDelay > 0 || this.wet || this.slowFall || (double) num2 < 0.8 || this.tongued) this.fallStart = (int) ((double) this.position.Y / 16.0); } if (Main.netMode != 1) { if (this.chest == -1 && this.lastChest >= 0 && Main.chest[this.lastChest] != null && Main.chest[this.lastChest] != null) NPC.BigMimicSummonCheck(Main.chest[this.lastChest].x, Main.chest[this.lastChest].y); this.lastChest = this.chest; } if (this.mouseInterface) this.delayUseItem = true; Player.tileTargetX = (int) (((double) Main.mouseX + (double) Main.screenPosition.X) / 16.0); Player.tileTargetY = (int) (((double) Main.mouseY + (double) Main.screenPosition.Y) / 16.0); if ((double) this.gravDir == -1.0) Player.tileTargetY = (int) (((double) Main.screenPosition.Y + (double) Main.screenHeight - (double) Main.mouseY) / 16.0); if (Player.tileTargetX >= Main.maxTilesX - 5) Player.tileTargetX = Main.maxTilesX - 5; if (Player.tileTargetY >= Main.maxTilesY - 5) Player.tileTargetY = Main.maxTilesY - 5; if (Player.tileTargetX < 5) Player.tileTargetX = 5; if (Player.tileTargetY < 5) Player.tileTargetY = 5; if (Main.tile[Player.tileTargetX - 1, Player.tileTargetY] == null) Main.tile[Player.tileTargetX - 1, Player.tileTargetY] = new Tile(); if (Main.tile[Player.tileTargetX + 1, Player.tileTargetY] == null) Main.tile[Player.tileTargetX + 1, Player.tileTargetY] = new Tile(); if (Main.tile[Player.tileTargetX, Player.tileTargetY] == null) Main.tile[Player.tileTargetX, Player.tileTargetY] = new Tile(); if (this.inventory[this.selectedItem].axe > 0 && !Main.tile[Player.tileTargetX, Player.tileTargetY].active() && this.inventory[this.selectedItem].createWall <= 0 && (this.inventory[this.selectedItem].hammer <= 0 || this.inventory[this.selectedItem].axe != 0)) { if (Main.tile[Player.tileTargetX - 1, Player.tileTargetY].active() && Main.tile[Player.tileTargetX - 1, Player.tileTargetY].type == (ushort) 323) { if (Main.tile[Player.tileTargetX - 1, Player.tileTargetY].frameY > (short) 4) --Player.tileTargetX; } else if (Main.tile[Player.tileTargetX + 1, Player.tileTargetY].active() && Main.tile[Player.tileTargetX + 1, Player.tileTargetY].type == (ushort) 323 && Main.tile[Player.tileTargetX + 1, Player.tileTargetY].frameY < (short) -4) ++Player.tileTargetX; } if (i == Main.myPlayer) this.UpdateNearbyInteractibleProjectilesList(); try { if (this.whoAmI == Main.myPlayer) { if (Main.instance.IsActive) { SmartCursorHelper.SmartCursorLookup(this); this.SmartInteractLookup(); } } } catch { Main.SmartCursorEnabled = false; } this.UpdateImmunity(); if (this.petalTimer > 0) --this.petalTimer; if (this.shadowDodgeTimer > 0) --this.shadowDodgeTimer; if (this.jump > 0 || (double) this.velocity.Y != 0.0) this.ResetFloorFlags(); this.potionDelayTime = Item.potionDelay; this.restorationDelayTime = Item.restorationDelay; if (this.pStone) { this.potionDelayTime = (int) ((double) this.potionDelayTime * 0.75); this.restorationDelayTime = (int) ((double) this.restorationDelayTime * 0.75); } if (this.yoraiz0rEye > 0) this.Yoraiz0rEye(); this.ResetEffects(); this.UpdateDyes(); if (CreativePowerManager.Instance.GetPower().IsEnabledForPlayer(this.whoAmI)) this.creativeGodMode = true; if (this.velocity == Vector2.Zero && this.itemAnimation == 0) ++this.afkCounter; else this.afkCounter = 0; this.meleeCrit += this.inventory[this.selectedItem].crit; this.magicCrit += this.inventory[this.selectedItem].crit; this.rangedCrit += this.inventory[this.selectedItem].crit; if (this.whoAmI == Main.myPlayer) { Main.musicBox2 = -1; if (Main.SceneMetrics.WaterCandleCount > 0) this.AddBuff(86, 2, false); if (Main.SceneMetrics.PeaceCandleCount > 0) this.AddBuff(157, 2, false); if (Main.SceneMetrics.HasCampfire) this.AddBuff(87, 2, false); if (Main.SceneMetrics.HasCatBast) this.AddBuff(215, 2, false); if (Main.SceneMetrics.HasStarInBottle) this.AddBuff(158, 2, false); if (Main.SceneMetrics.HasHeartLantern) this.AddBuff(89, 2, false); if (Main.SceneMetrics.HasSunflower) this.AddBuff(146, 2, false); if (Main.SceneMetrics.hasBanner) this.AddBuff(147, 2, false); if (!this.behindBackWall && this.ZoneSandstorm) this.AddBuff(194, 2, false); } for (int index = 0; index < 323; ++index) this.buffImmune[index] = false; this.UpdateProjectileCaches(i); this.UpdateBuffs(i); if (this.whoAmI == Main.myPlayer) { if (!this.onFire && !this.poisoned) this.trapDebuffSource = false; this.UpdatePet(i); this.UpdatePetLight(i); } this.UpdateLuckFactors(); this.RecalculateLuck(); if (this.luckNeedsSync && this.whoAmI == Main.myPlayer) { this.luckNeedsSync = false; NetMessage.SendData(134, number: this.whoAmI); } bool flag10 = this.wet && !this.lavaWet && (!this.mount.Active || !this.mount.IsConsideredASlimeMount); if (this.accMerman & flag10) { this.releaseJump = true; this.wings = 0; this.merman = true; this.accFlipper = true; this.AddBuff(34, 2); } else this.merman = false; if (!flag10 && this.forceWerewolf) this.forceMerman = false; if (this.forceMerman & flag10) this.wings = 0; this.accMerman = false; this.hideMerman = false; this.forceMerman = false; if (this.wolfAcc && !this.merman && !Main.dayTime && !this.wereWolf) this.AddBuff(28, 60); this.wolfAcc = false; this.hideWolf = false; this.forceWerewolf = false; if (this.whoAmI == Main.myPlayer) { for (int b = 0; b < 22; ++b) { if (this.buffType[b] > 0 && this.buffTime[b] <= 0) this.DelBuff(b); } } this.beetleDefense = false; this.beetleOffense = false; this.setSolar = false; this.head = this.armor[0].headSlot; this.body = this.armor[1].bodySlot; this.legs = this.armor[2].legSlot; this.ResetVisibleAccessories(); if ((double) this.MountFishronSpecialCounter > 0.0) --this.MountFishronSpecialCounter; if (this._portalPhysicsTime > 0) --this._portalPhysicsTime; this.UpdateEquips(i); this.UpdatePortableStoolUsage(); if ((double) this.velocity.Y == 0.0 || this.controlJump) this.portalPhysicsFlag = false; if (this.inventory[this.selectedItem].type == 3384 || this.portalPhysicsFlag) this._portalPhysicsTime = 30; if (this.mount.Active) this.mount.UpdateEffects(this); ++this.gemCount; if (this.gemCount >= 10) { this.gem = -1; this.ownedLargeGems = (BitsByte) (byte) 0; this.gemCount = 0; for (int index = 0; index <= 58; ++index) { if (this.inventory[index].type == 0 || this.inventory[index].stack == 0) this.inventory[index].TurnToAir(); if (this.inventory[index].type >= 1522 && this.inventory[index].type <= 1527) { this.gem = this.inventory[index].type - 1522; this.ownedLargeGems[this.gem] = true; } if (this.inventory[index].type == 3643) { this.gem = 6; this.ownedLargeGems[this.gem] = true; } } } this.UpdateArmorLights(); this.UpdateArmorSets(i); if (this.maxTurretsOld != this.maxTurrets) { this.UpdateMaxTurrets(); this.maxTurretsOld = this.maxTurrets; } if (this.shieldRaised) this.statDefense += 20; if (((this.merman ? 1 : (this.forceMerman ? 1 : 0)) & (flag10 ? 1 : 0)) != 0) this.wings = 0; if (this.invis) { if (this.itemAnimation == 0 && this.aggro > -750) this.aggro = -750; else if (this.aggro > -250) this.aggro = -250; } if (this.inventory[this.selectedItem].type == 3106) { if (this.itemAnimation > 0) { this.stealthTimer = 15; if ((double) this.stealth > 0.0) this.stealth += 0.1f; } else if ((double) this.velocity.X > -0.1 && (double) this.velocity.X < 0.1 && (double) this.velocity.Y > -0.1 && (double) this.velocity.Y < 0.1 && !this.mount.Active) { if (this.stealthTimer == 0 && (double) this.stealth > 0.0) { this.stealth -= 0.02f; if ((double) this.stealth <= 0.0) { this.stealth = 0.0f; if (Main.netMode == 1) NetMessage.SendData(84, number: this.whoAmI); } } } else { if ((double) this.stealth > 0.0) this.stealth += 0.1f; if (this.mount.Active) this.stealth = 1f; } if ((double) this.stealth > 1.0) this.stealth = 1f; this.meleeDamage += (float) ((1.0 - (double) this.stealth) * 3.0); this.meleeCrit += (int) ((1.0 - (double) this.stealth) * 30.0); if (this.meleeCrit > 100) this.meleeCrit = 100; this.aggro -= (int) ((1.0 - (double) this.stealth) * 750.0); if (this.stealthTimer > 0) --this.stealthTimer; } else if (this.shroomiteStealth) { if (this.itemAnimation > 0) this.stealthTimer = 5; if ((double) this.velocity.X > -0.1 && (double) this.velocity.X < 0.1 && (double) this.velocity.Y > -0.1 && (double) this.velocity.Y < 0.1 && !this.mount.Active) { if (this.stealthTimer == 0 && (double) this.stealth > 0.0) { this.stealth -= 0.015f; if ((double) this.stealth <= 0.0) { this.stealth = 0.0f; if (Main.netMode == 1) NetMessage.SendData(84, number: this.whoAmI); } } } else { this.stealth += (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) * 0.0075f; if ((double) this.stealth > 1.0) this.stealth = 1f; if (this.mount.Active) this.stealth = 1f; } this.rangedDamage += (float) ((1.0 - (double) this.stealth) * 0.600000023841858); this.rangedCrit += (int) ((1.0 - (double) this.stealth) * 10.0); this.aggro -= (int) ((1.0 - (double) this.stealth) * 750.0); if (this.stealthTimer > 0) --this.stealthTimer; } else if (this.setVortex) { bool flag11 = false; if (this.vortexStealthActive) { float stealth = this.stealth; this.stealth -= 0.04f; if ((double) this.stealth < 0.0) this.stealth = 0.0f; else flag11 = true; if ((double) this.stealth == 0.0 && (double) stealth != (double) this.stealth && Main.netMode == 1) NetMessage.SendData(84, number: this.whoAmI); this.rangedDamage += (float) ((1.0 - (double) this.stealth) * 0.800000011920929); this.rangedCrit += (int) ((1.0 - (double) this.stealth) * 20.0); this.aggro -= (int) ((1.0 - (double) this.stealth) * 1200.0); this.accRunSpeed *= 0.3f; this.maxRunSpeed *= 0.3f; if (this.mount.Active) this.vortexStealthActive = false; } else { float stealth = this.stealth; this.stealth += 0.04f; if ((double) this.stealth > 1.0) this.stealth = 1f; else flag11 = true; if ((double) this.stealth == 1.0 && (double) stealth != (double) this.stealth && Main.netMode == 1) NetMessage.SendData(84, number: this.whoAmI); } if (flag11) { if (Main.rand.Next(2) == 0) { Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515); Dust dust = Main.dust[Dust.NewDust(this.Center - spinningpoint * 30f, 0, 0, 229)]; dust.noGravity = true; dust.position = this.Center - spinningpoint * (float) Main.rand.Next(5, 11); dust.velocity = spinningpoint.RotatedBy(1.57079637050629) * 4f; dust.scale = 0.5f + Main.rand.NextFloat(); dust.fadeIn = 0.5f; } if (Main.rand.Next(2) == 0) { Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515); Dust dust = Main.dust[Dust.NewDust(this.Center - spinningpoint * 30f, 0, 0, 240)]; dust.noGravity = true; dust.position = this.Center - spinningpoint * 12f; dust.velocity = spinningpoint.RotatedBy(-1.57079637050629) * 2f; dust.scale = 0.5f + Main.rand.NextFloat(); dust.fadeIn = 0.5f; } } } else this.stealth = 1f; if (this.manaSick) this.magicDamage *= 1f - this.manaSickReduction; this.meleeSpeed = 1f + (this.meleeSpeed - 1f) * ItemID.Sets.BonusMeleeSpeedMultiplier[this.inventory[this.selectedItem].type]; if ((double) this.pickSpeed < 0.3) this.pickSpeed = 0.3f; if ((double) this.meleeSpeed > 3.0) this.meleeSpeed = 3f; if ((double) this.tileSpeed > 3.0) this.tileSpeed = 3f; this.tileSpeed = 1f / this.tileSpeed; if ((double) this.wallSpeed > 3.0) this.wallSpeed = 3f; this.wallSpeed = 1f / this.wallSpeed; if (this.statManaMax2 > 400) this.statManaMax2 = 400; if (this.statDefense < 0) this.statDefense = 0; if (this.slowOgreSpit) { this.moveSpeed /= 3f; if ((double) this.velocity.Y == 0.0 && (double) Math.Abs(this.velocity.X) > 1.0) this.velocity.X /= 2f; } else if (this.dazed) this.moveSpeed /= 3f; else if (this.slow) this.moveSpeed /= 2f; else if (this.chilled) this.moveSpeed *= 0.75f; if (this.shieldRaised) { this.moveSpeed /= 3f; if ((double) this.velocity.Y == 0.0 && (double) Math.Abs(this.velocity.X) > 3.0) this.velocity.X /= 2f; } if (DD2Event.Ongoing) { DD2Event.FindArenaHitbox(); if (DD2Event.ShouldBlockBuilding(this.Center)) { this.noBuilding = true; this.AddBuff(199, 3); } } this.meleeSpeed = 1f / this.meleeSpeed; this.UpdateLifeRegen(); this.soulDrain = 0; this.UpdateManaRegen(); if (this.manaRegenCount < 0) this.manaRegenCount = 0; if (this.statMana > this.statManaMax2) this.statMana = this.statManaMax2; this.runAcceleration *= this.moveSpeed; this.maxRunSpeed *= this.moveSpeed; this.UpdateJumpHeight(); for (int b = 0; b < 22; ++b) { if (this.buffType[b] > 0 && this.buffTime[b] > 0 && this.buffImmune[this.buffType[b]]) this.DelBuff(b); } if (this.brokenArmor) this.statDefense /= 2; if (this.witheredArmor) this.statDefense /= 2; if (this.witheredWeapon) { this.meleeDamage *= 0.5f; this.rangedDamage *= 0.5f; this.magicDamage *= 0.5f; this.minionDamage *= 0.5f; } this.lastTileRangeX = Player.tileRangeX; this.lastTileRangeY = Player.tileRangeY; if (this.mount.Active) this.movementAbilitiesCache.CopyFrom(this); else this.movementAbilitiesCache.PasteInto(this); if (this.mount.Active && this.mount.BlockExtraJumps) { this.canJumpAgain_Cloud = false; this.canJumpAgain_Sandstorm = false; this.canJumpAgain_Blizzard = false; this.canJumpAgain_Fart = false; this.canJumpAgain_Sail = false; this.canJumpAgain_Unicorn = false; this.canJumpAgain_Santank = false; this.canJumpAgain_WallOfFleshGoat = false; this.canJumpAgain_Basilisk = false; } else if (((double) this.velocity.Y == 0.0 ? 1 : (this.sliding ? 1 : 0)) != 0) { this.RefreshDoubleJumps(); } else { if (!this.hasJumpOption_Cloud) this.canJumpAgain_Cloud = false; if (!this.hasJumpOption_Sandstorm) this.canJumpAgain_Sandstorm = false; if (!this.hasJumpOption_Blizzard) this.canJumpAgain_Blizzard = false; if (!this.hasJumpOption_Fart) this.canJumpAgain_Fart = false; if (!this.hasJumpOption_Sail) this.canJumpAgain_Sail = false; if (!this.hasJumpOption_Unicorn) this.canJumpAgain_Unicorn = false; if (!this.hasJumpOption_Santank) this.canJumpAgain_Santank = false; if (!this.hasJumpOption_WallOfFleshGoat) this.canJumpAgain_WallOfFleshGoat = false; if (!this.hasJumpOption_Basilisk) this.canJumpAgain_Basilisk = false; } if (!this.carpet) { this.canCarpet = false; this.carpetFrame = -1; } else if ((double) this.velocity.Y == 0.0 || this.sliding) { this.canCarpet = true; this.carpetTime = 0; this.carpetFrame = -1; this.carpetFrameCounter = 0.0f; } if ((double) this.gravDir == -1.0) this.canCarpet = false; if (this.ropeCount > 0) --this.ropeCount; if (!this.pulley && !this.frozen && !this.webbed && !this.stoned && !this.controlJump && (double) this.gravDir == 1.0 && this.ropeCount == 0 && this.grappling[0] == -1 && !this.tongued && !this.mount.Active) this.FindPulley(); this.UpdatePettingAnimal(); this.sitting.UpdateSitting(this); this.sleeping.UpdateState(this); this.eyeHelper.Update(this); if (this.pulley) { if (this.mount.Active) this.pulley = false; this.sandStorm = false; this.CancelAllJumpVisualEffects(); int x = (int) ((double) this.position.X + (double) (this.width / 2)) / 16; int y1 = (int) ((double) this.position.Y - 8.0) / 16; bool flag12 = false; if (this.pulleyDir == (byte) 0) this.pulleyDir = (byte) 1; if (this.pulleyDir == (byte) 1) { if (this.direction == -1 && this.controlLeft && (this.releaseLeft || this.leftTimer == 0)) { this.pulleyDir = (byte) 2; flag12 = true; } else if (this.direction == 1 && this.controlRight && this.releaseRight || this.rightTimer == 0) { this.pulleyDir = (byte) 2; flag12 = true; } else { if (this.direction == 1 && this.controlLeft) { this.direction = -1; flag12 = true; } if (this.direction == -1 && this.controlRight) { this.direction = 1; flag12 = true; } } } else if (this.pulleyDir == (byte) 2) { if (this.direction == 1 && this.controlLeft) { flag12 = true; if (!Collision.SolidCollision(new Vector2((float) (x * 16 + 8 - this.width / 2), this.position.Y), this.width, this.height)) { this.pulleyDir = (byte) 1; this.direction = -1; flag12 = true; } } if (this.direction == -1 && this.controlRight) { flag12 = true; if (!Collision.SolidCollision(new Vector2((float) (x * 16 + 8 - this.width / 2), this.position.Y), this.width, this.height)) { this.pulleyDir = (byte) 1; this.direction = 1; flag12 = true; } } } int dir = 1; if (this.controlLeft) dir = -1; bool flag13 = this.CanMoveForwardOnRope(dir, x, y1); if (((!this.controlLeft ? 0 : (this.direction == -1 ? 1 : 0)) & (flag13 ? 1 : 0)) != 0) this.instantMovementAccumulatedThisFrame.X += -1f; if (((!this.controlRight ? 0 : (this.direction == 1 ? 1 : 0)) & (flag13 ? 1 : 0)) != 0) ++this.instantMovementAccumulatedThisFrame.X; bool flag14 = false; if (!flag12 && (this.controlLeft && (this.releaseLeft || this.leftTimer == 0) || this.controlRight && (this.releaseRight || this.rightTimer == 0))) { int index = x + dir; if (Main.tile[index, y1] != null && Main.tile[index, y1].active() && Main.tileRope[(int) Main.tile[index, y1].type]) { this.pulleyDir = (byte) 1; this.direction = dir; int num13 = index * 16 + 8 - this.width / 2; float y2 = this.position.Y; float y3 = (float) (y1 * 16 + 22); if (Main.tile[index, y1 - 1] == null) Main.tile[index, y1 - 1] = new Tile(); if (Main.tile[index, y1 + 1] == null) Main.tile[index, y1 + 1] = new Tile(); if ((!Main.tile[index, y1 - 1].active() || !Main.tileRope[(int) Main.tile[index, y1 - 1].type]) && (!Main.tile[index, y1 + 1].active() || !Main.tileRope[(int) Main.tile[index, y1 + 1].type])) y3 = (float) (y1 * 16 + 22); if (Collision.SolidCollision(new Vector2((float) num13, y3), this.width, this.height)) { this.pulleyDir = (byte) 2; this.direction = -dir; num13 = this.direction != 1 ? index * 16 + 8 - this.width / 2 - 6 : index * 16 + 8 - this.width / 2 + 6; } if (i == Main.myPlayer) Main.cameraX = Main.cameraX + this.position.X - (float) num13; this.position.X = (float) num13; this.gfxOffY = this.position.Y - y3; this.position.Y = y3; flag14 = true; } } if (!flag14 && !flag12 && !this.controlUp && (this.controlLeft && this.releaseLeft || this.controlRight && this.releaseRight)) { this.pulley = false; if (this.controlLeft && (double) this.velocity.X == 0.0) this.velocity.X = -1f; if (this.controlRight && (double) this.velocity.X == 0.0) this.velocity.X = 1f; } if ((double) this.velocity.X != 0.0) this.pulley = false; if (Main.tile[x, y1] == null) Main.tile[x, y1] = new Tile(); if (!Main.tile[x, y1].active() || !Main.tileRope[(int) Main.tile[x, y1].type]) this.pulley = false; if ((double) this.gravDir != 1.0) this.pulley = false; if (this.frozen || this.webbed || this.stoned) this.pulley = false; if (!this.pulley) this.velocity.Y -= this.gravity; if (this.controlJump) { this.pulley = false; this.jump = Player.jumpHeight; this.velocity.Y = -Player.jumpSpeed; } } if (this.grapCount > 0) this.pulley = false; if (this.pulley) { this.fallStart = (int) this.position.Y / 16; this.wingFrame = 0; if (this.wings == 4) this.wingFrame = 3; int index5 = (int) ((double) this.position.X + (double) (this.width / 2)) / 16; int index6 = (int) ((double) this.position.Y - 16.0) / 16; int num14 = (int) ((double) this.position.Y - 8.0) / 16; bool flag15 = true; bool flag16 = false; if (Main.tile[index5, num14 - 1].active() && Main.tileRope[(int) Main.tile[index5, num14 - 1].type] || Main.tile[index5, num14 + 1].active() && Main.tileRope[(int) Main.tile[index5, num14 + 1].type]) flag16 = true; if (Main.tile[index5, index6] == null) Main.tile[index5, index6] = new Tile(); if (!Main.tile[index5, index6].active() || !Main.tileRope[(int) Main.tile[index5, index6].type]) { flag15 = false; if ((double) this.velocity.Y < 0.0) this.velocity.Y = 0.0f; } if (flag16) { if (this.controlUp & flag15) { float x1 = this.position.X; float y = (float) ((double) this.position.Y - (double) Math.Abs(this.velocity.Y) - 2.0); if (Collision.SolidCollision(new Vector2(x1, y), this.width, this.height)) { float x2 = (float) (index5 * 16 + 8 - this.width / 2 + 6); if (!Collision.SolidCollision(new Vector2(x2, y), this.width, (int) ((double) this.height + (double) Math.Abs(this.velocity.Y) + 2.0))) { if (i == Main.myPlayer) Main.cameraX = Main.cameraX + this.position.X - x2; this.pulleyDir = (byte) 2; this.direction = 1; this.position.X = x2; this.velocity.X = 0.0f; } else { float x3 = (float) (index5 * 16 + 8 - this.width / 2 - 6); if (!Collision.SolidCollision(new Vector2(x3, y), this.width, (int) ((double) this.height + (double) Math.Abs(this.velocity.Y) + 2.0))) { if (i == Main.myPlayer) Main.cameraX = Main.cameraX + this.position.X - x3; this.pulleyDir = (byte) 2; this.direction = -1; this.position.X = x3; this.velocity.X = 0.0f; } } } if ((double) this.velocity.Y > 0.0) this.velocity.Y *= 0.7f; if ((double) this.velocity.Y > -3.0) this.velocity.Y -= 0.2f; else this.velocity.Y -= 0.02f; if ((double) this.velocity.Y < -8.0) this.velocity.Y = -8f; } else if (this.controlDown) { float x4 = this.position.X; float y = this.position.Y; if (Collision.SolidCollision(new Vector2(x4, y), this.width, (int) ((double) this.height + (double) Math.Abs(this.velocity.Y) + 2.0))) { float x5 = (float) (index5 * 16 + 8 - this.width / 2 + 6); if (!Collision.SolidCollision(new Vector2(x5, y), this.width, (int) ((double) this.height + (double) Math.Abs(this.velocity.Y) + 2.0))) { if (i == Main.myPlayer) Main.cameraX = Main.cameraX + this.position.X - x5; this.pulleyDir = (byte) 2; this.direction = 1; this.position.X = x5; this.velocity.X = 0.0f; } else { float x6 = (float) (index5 * 16 + 8 - this.width / 2 - 6); if (!Collision.SolidCollision(new Vector2(x6, y), this.width, (int) ((double) this.height + (double) Math.Abs(this.velocity.Y) + 2.0))) { if (i == Main.myPlayer) Main.cameraX = Main.cameraX + this.position.X - x6; this.pulleyDir = (byte) 2; this.direction = -1; this.position.X = x6; this.velocity.X = 0.0f; } } } if ((double) this.velocity.Y < 0.0) this.velocity.Y *= 0.7f; if ((double) this.velocity.Y < 3.0) this.velocity.Y += 0.2f; else this.velocity.Y += 0.1f; if ((double) this.velocity.Y > (double) this.maxFallSpeed) this.velocity.Y = this.maxFallSpeed; } else { this.velocity.Y *= 0.7f; if ((double) this.velocity.Y > -0.1 && (double) this.velocity.Y < 0.1) this.velocity.Y = 0.0f; } } else if (this.controlDown) { this.ropeCount = 10; this.pulley = false; this.velocity.Y = 1f; } else { this.velocity.Y = 0.0f; this.position.Y = (float) (index6 * 16 + 22); } float num15 = (float) (index5 * 16 + 8 - this.width / 2); if (this.pulleyDir == (byte) 1) num15 = (float) (index5 * 16 + 8 - this.width / 2); if (this.pulleyDir == (byte) 2) num15 = (float) (index5 * 16 + 8 - this.width / 2 + 6 * this.direction); if (i == Main.myPlayer) { Main.cameraX += this.position.X - num15; Main.cameraX = MathHelper.Clamp(Main.cameraX, -32f, 32f); } this.position.X = num15; this.pulleyFrameCounter += Math.Abs(this.velocity.Y * 0.75f); if ((double) this.velocity.Y != 0.0) this.pulleyFrameCounter += 0.75f; if ((double) this.pulleyFrameCounter > 10.0) { ++this.pulleyFrame; this.pulleyFrameCounter = 0.0f; } if (this.pulleyFrame > 1) this.pulleyFrame = 0; this.canCarpet = true; this.carpetFrame = -1; this.wingTime = (float) this.wingTimeMax; this.rocketTime = this.rocketTimeMax; this.rocketDelay = 0; this.rocketFrame = false; this.canRocket = false; this.rocketRelease = false; this.DashMovement(); this.UpdateControlHolds(); } else if (this.grappling[0] == -1 && !this.tongued) { if (this.wingsLogic > 0 && (double) this.velocity.Y != 0.0 && !this.merman && !this.mount.Active) this.WingAirLogicTweaks(); if (this.empressBrooch) this.runAcceleration *= 2f; if (this.mount.Active && this.mount.Type == 43 && (double) this.velocity.Y != 0.0) this.runSlowdown = 0.0f; if (this.sticky) { this.maxRunSpeed *= 0.25f; this.runAcceleration *= 0.25f; this.runSlowdown *= 2f; if ((double) this.velocity.X > (double) this.maxRunSpeed) this.velocity.X = this.maxRunSpeed; if ((double) this.velocity.X < -(double) this.maxRunSpeed) this.velocity.X = -this.maxRunSpeed; } else if (this.powerrun) { this.maxRunSpeed *= 3.5f; this.runAcceleration *= 1f; this.runSlowdown *= 2f; } else if (this.runningOnSand && this.desertDash) { float num16 = 1.75f; this.maxRunSpeed *= num16; this.accRunSpeed *= num16; this.runAcceleration *= num16; this.runSlowdown *= num16; } else if (this.slippy2) { this.runAcceleration *= 0.6f; this.runSlowdown = 0.0f; if (this.iceSkate) { this.runAcceleration *= 3.5f; this.maxRunSpeed *= 1.25f; } } else if (this.slippy) { this.runAcceleration *= 0.7f; if (this.iceSkate) { this.runAcceleration *= 3.5f; this.maxRunSpeed *= 1.25f; } else this.runSlowdown *= 0.1f; } if (this.sandStorm) { this.runAcceleration *= 1.5f; this.maxRunSpeed *= 2f; } if (this.isPerformingJump_Blizzard && this.hasJumpOption_Blizzard) { this.runAcceleration *= 3f; this.maxRunSpeed *= 1.5f; } if (this.isPerformingJump_Fart && this.hasJumpOption_Fart) { this.runAcceleration *= 3f; this.maxRunSpeed *= 1.75f; } if (this.isPerformingJump_Unicorn && this.hasJumpOption_Unicorn) { this.runAcceleration *= 3f; this.maxRunSpeed *= 1.5f; } if (this.isPerformingJump_Santank && this.hasJumpOption_Santank) { this.runAcceleration *= 3f; this.maxRunSpeed *= 1.5f; } if (this.isPerformingJump_WallOfFleshGoat && this.hasJumpOption_WallOfFleshGoat) { this.runAcceleration *= 3f; this.maxRunSpeed *= 1.5f; } if (this.isPerformingJump_Basilisk && this.hasJumpOption_Basilisk) { this.runAcceleration *= 3f; this.maxRunSpeed *= 1.5f; } if (this.isPerformingJump_Sail && this.hasJumpOption_Sail) { this.runAcceleration *= 1.5f; this.maxRunSpeed *= 1.25f; } if (this.carpetFrame != -1) { this.runAcceleration *= 1.25f; this.maxRunSpeed *= 1.5f; } if (this.inventory[this.selectedItem].type == 3106 && (double) this.stealth < 1.0) { this.maxRunSpeed -= (float) ((double) this.maxRunSpeed / 2.0 * (1.0 - (double) this.stealth)); this.accRunSpeed = this.maxRunSpeed; } if (this.mount.Active) { this.rocketBoots = 0; this.wings = 0; this.wingsLogic = 0; this.maxRunSpeed = this.mount.RunSpeed; this.accRunSpeed = this.mount.DashSpeed; this.runAcceleration = this.mount.Acceleration; if (this.mount.Type == 12 && !this.MountFishronSpecial) { this.runAcceleration /= 2f; this.maxRunSpeed /= 2f; } this.mount.AbilityRecovery(); if (this.mount.Cart && (double) this.velocity.Y == 0.0) { if (!Minecart.OnTrack(this.position, this.width, this.height)) { this.fullRotation = 0.0f; this.onWrongGround = true; this.runSlowdown = 0.2f; if (this.controlLeft && this.releaseLeft || this.controlRight && this.releaseRight) this.mount.Dismount(this); } else { this.runSlowdown = this.runAcceleration; this.onWrongGround = false; } } if (this.mount.Type == 8) this.mount.UpdateDrill(this, this.controlUp, this.controlDown); } this.HorizontalMovement(); if (this.gravControl) { if (this.controlUp && this.releaseUp) { if ((double) this.gravDir == 1.0) { this.gravDir = -1f; this.fallStart = (int) ((double) this.position.Y / 16.0); this.jump = 0; SoundEngine.PlaySound(SoundID.Item8, this.position); } else { this.gravDir = 1f; this.fallStart = (int) ((double) this.position.Y / 16.0); this.jump = 0; SoundEngine.PlaySound(SoundID.Item8, this.position); } } } else if (this.gravControl2) { if (this.controlUp && this.releaseUp) { if ((double) this.gravDir == 1.0) { this.gravDir = -1f; this.fallStart = (int) ((double) this.position.Y / 16.0); this.jump = 0; SoundEngine.PlaySound(SoundID.Item8, this.position); } else { this.gravDir = 1f; this.fallStart = (int) ((double) this.position.Y / 16.0); this.jump = 0; SoundEngine.PlaySound(SoundID.Item8, this.position); } } } else this.gravDir = 1f; if ((double) this.velocity.Y == 0.0 && this.mount.Active && this.mount.CanHover() && this.controlUp && this.releaseUp) this.velocity.Y = (float) -((double) this.mount.Acceleration + (double) this.gravity + 1.0 / 1000.0); this.UpdateControlHolds(); this.sandStorm = false; this.JumpMovement(); if (this.wingsLogic == 0) this.wingTime = 0.0f; if (this.rocketBoots == 0) this.rocketTime = 0; if (this.jump == 0) this.CancelAllJumpVisualEffects(); this.DashMovement(); this.WallslideMovement(); this.CarpetMovement(); this.DoubleJumpVisuals(); if (this.wingsLogic > 0 || this.mount.Active) this.sandStorm = false; if (((double) this.gravDir == 1.0 && (double) this.velocity.Y > -(double) Player.jumpSpeed || (double) this.gravDir == -1.0 && (double) this.velocity.Y < (double) Player.jumpSpeed) && (double) this.velocity.Y != 0.0) this.canRocket = true; bool wingFlap = false; if (((double) this.velocity.Y == 0.0 || this.sliding) && this.releaseJump || this.autoJump && this.justJumped) { this.mount.ResetFlightTime(this.velocity.X); this.wingTime = (float) this.wingTimeMax; } if (this.wingsLogic > 0 && this.controlJump && (double) this.wingTime > 0.0 && this.jump == 0 && (double) this.velocity.Y != 0.0) wingFlap = true; if ((this.wingsLogic == 22 || this.wingsLogic == 28 || this.wingsLogic == 30 || this.wingsLogic == 32 || this.wingsLogic == 29 || this.wingsLogic == 33 || this.wingsLogic == 35 || this.wingsLogic == 37 || this.wingsLogic == 45) && this.controlJump && this.TryingToHoverDown && (double) this.wingTime > 0.0) wingFlap = true; if (this.frozen || this.webbed || this.stoned) { if (this.mount.Active) this.mount.Dismount(this); this.velocity.Y += this.gravity; if ((double) this.velocity.Y > (double) this.maxFallSpeed) this.velocity.Y = this.maxFallSpeed; this.sandStorm = false; this.CancelAllJumpVisualEffects(); } else { if (wingFlap) { this.WingAirVisuals(); this.WingMovement(); } this.WingFrame(wingFlap); if (this.wingsLogic > 0 && this.rocketBoots != 0 && (double) this.velocity.Y != 0.0 && this.rocketTime != 0) { int num17 = this.rocketTime * 6; this.wingTime += (float) num17; if ((double) this.wingTime > (double) (this.wingTimeMax + num17)) this.wingTime = (float) (this.wingTimeMax + num17); this.rocketTime = 0; } if (wingFlap && this.wings != 4 && this.wings != 22 && this.wings != 0 && this.wings != 24 && this.wings != 28 && this.wings != 30 && this.wings != 33 && this.wings != 45) { bool flag17 = this.wingFrame == 3; if (this.wings == 43 || this.wings == 44) flag17 = this.wingFrame == 4; if (flag17) { if (!this.flapSound) SoundEngine.PlaySound(SoundID.Item32, this.position); this.flapSound = true; } else this.flapSound = false; } if ((double) this.velocity.Y == 0.0 || this.sliding || this.autoJump && this.justJumped) this.rocketTime = this.rocketTimeMax; if (this.empressBrooch) this.rocketTime = this.rocketTimeMax; if (((double) this.wingTime == 0.0 || this.wingsLogic == 0) && this.rocketBoots != 0 && this.controlJump && this.rocketDelay == 0 && this.canRocket && this.rocketRelease && !this.canJumpAgain_Cloud) { if (this.rocketTime > 0) { --this.rocketTime; this.rocketDelay = 10; if (this.rocketDelay2 <= 0) { if (this.rocketBoots == 1) { SoundEngine.PlaySound(SoundID.Item13, this.position); this.rocketDelay2 = 30; } else if (this.rocketBoots == 2 || this.rocketBoots == 3 || this.rocketBoots == 4) { SoundEngine.PlaySound(SoundID.Item24, this.position); this.rocketDelay2 = 15; } } } else this.canRocket = false; } if (this.rocketDelay2 > 0) --this.rocketDelay2; if (this.rocketDelay == 0) this.rocketFrame = false; if (this.rocketDelay > 0) { this.rocketFrame = true; this.RocketBootVisuals(); if (this.rocketDelay == 0) this.releaseJump = true; --this.rocketDelay; this.velocity.Y -= 0.1f * this.gravDir; if ((double) this.gravDir == 1.0) { if ((double) this.velocity.Y > 0.0) this.velocity.Y -= 0.5f; else if ((double) this.velocity.Y > -(double) Player.jumpSpeed * 0.5) this.velocity.Y -= 0.1f; if ((double) this.velocity.Y < -(double) Player.jumpSpeed * 1.5) this.velocity.Y = (float) (-(double) Player.jumpSpeed * 1.5); } else { if ((double) this.velocity.Y < 0.0) this.velocity.Y += 0.5f; else if ((double) this.velocity.Y < (double) Player.jumpSpeed * 0.5) this.velocity.Y += 0.1f; if ((double) this.velocity.Y > (double) Player.jumpSpeed * 1.5) this.velocity.Y = Player.jumpSpeed * 1.5f; } } else if (!wingFlap) { if (this.mount.CanHover()) this.mount.Hover(this); else if (this.mount.CanFly() && this.controlJump && this.jump == 0) { if (this.mount.Flight()) { if (this.TryingToHoverDown) { this.velocity.Y *= 0.9f; if ((double) this.velocity.Y > -1.0 && (double) this.velocity.Y < 0.5) this.velocity.Y = 1E-05f; } else { float jumpSpeed = Player.jumpSpeed; if (this.mount.Type == 50) jumpSpeed *= 0.5f; if ((double) this.velocity.Y > 0.0) this.velocity.Y -= 0.5f; else if ((double) this.velocity.Y > -(double) jumpSpeed * 1.5) this.velocity.Y -= 0.1f; if ((double) this.velocity.Y < -(double) jumpSpeed * 1.5) this.velocity.Y = (float) (-(double) jumpSpeed * 1.5); } } else { this.velocity.Y += this.gravity / 3f * this.gravDir; if ((double) this.gravDir == 1.0) { if ((double) this.velocity.Y > (double) this.maxFallSpeed / 3.0 && !this.TryingToHoverDown) this.velocity.Y = this.maxFallSpeed / 3f; } else if ((double) this.velocity.Y < -(double) this.maxFallSpeed / 3.0 && !this.TryingToHoverUp) this.velocity.Y = (float) (-(double) this.maxFallSpeed / 3.0); } } else if (this.slowFall && !this.TryingToHoverDown) { this.gravity = !this.TryingToHoverUp ? this.gravity / 3f * this.gravDir : this.gravity / 10f * this.gravDir; this.velocity.Y += this.gravity; } else if (this.wingsLogic > 0 && this.controlJump && (double) this.velocity.Y > 0.0) { bool flag18 = this.wingsLogic != this.wings; this.fallStart = (int) ((double) this.position.Y / 16.0); if ((double) this.velocity.Y > 0.0) { if (this.wings == 10 && Main.rand.Next(3) == 0) { int num18 = 4; if (this.direction == 1) num18 = -40; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num18, (float) ((double) this.position.Y + (double) (this.height / 2) - 15.0)), 30, 30, 76, Alpha: 50, Scale: 0.6f); Main.dust[index].fadeIn = 1.1f; Main.dust[index].noGravity = true; Main.dust[index].noLight = true; Main.dust[index].velocity *= 0.3f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } if (this.wings == 34 && this.ShouldDrawWingsThatAreAlwaysAnimated() && Main.rand.Next(3) == 0) { int num19 = 4; if (this.direction == 1) num19 = -40; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num19, (float) ((double) this.position.Y + (double) (this.height / 2) - 15.0)), 30, 30, 261, Alpha: 50, Scale: 0.6f); Main.dust[index].fadeIn = 1.1f; Main.dust[index].noGravity = true; Main.dust[index].noLight = true; Main.dust[index].noLightEmittence = flag18; Main.dust[index].velocity *= 0.3f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } if (this.wings == 40) this.ShouldDrawWingsThatAreAlwaysAnimated(); if (this.wings == 44) this.ShouldDrawWingsThatAreAlwaysAnimated(); if (this.wings == 9 && Main.rand.Next(3) == 0) { int num20 = 8; if (this.direction == 1) num20 = -40; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num20, (float) ((double) this.position.Y + (double) (this.height / 2) - 15.0)), 30, 30, 6, Alpha: 200, Scale: 2f); Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.3f; Main.dust[index].noLightEmittence = flag18; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } if (this.wings == 29 && Main.rand.Next(3) == 0) { int num21 = 8; if (this.direction == 1) num21 = -40; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num21, (float) ((double) this.position.Y + (double) (this.height / 2) - 15.0)), 30, 30, 6, Alpha: 100, Scale: 2.4f); Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.3f; Main.dust[index].noLightEmittence = flag18; if (Main.rand.Next(10) == 0) Main.dust[index].fadeIn = 2f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } if (this.wings == 6) { if (Main.rand.Next(10) == 0) { int num22 = 4; if (this.direction == 1) num22 = -40; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num22, (float) ((double) this.position.Y + (double) (this.height / 2) - 12.0)), 30, 20, 55, Alpha: 200); Main.dust[index].noLightEmittence = flag18; Main.dust[index].velocity *= 0.3f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } } else if (this.wings == 5 && Main.rand.Next(6) == 0) { int num23 = 6; if (this.direction == 1) num23 = -30; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num23, this.position.Y), 18, this.height, 58, Alpha: ((int) byte.MaxValue), Scale: 1.2f); Main.dust[index].velocity *= 0.3f; Main.dust[index].noLightEmittence = flag18; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } if (this.wings == 4) { --this.rocketDelay2; if (this.rocketDelay2 <= 0) { SoundEngine.PlaySound(SoundID.Item13, this.position); this.rocketDelay2 = 60; } int Type = 6; float Scale = 1.5f; int Alpha = 100; float x = (float) ((double) this.position.X + (double) (this.width / 2) + 16.0); if (this.direction > 0) x = (float) ((double) this.position.X + (double) (this.width / 2) - 26.0); float y = (float) ((double) this.position.Y + (double) this.height - 18.0); if (Main.rand.Next(2) == 1) { x = (float) ((double) this.position.X + (double) (this.width / 2) + 8.0); if (this.direction > 0) x = (float) ((double) this.position.X + (double) (this.width / 2) - 20.0); y += 6f; } int index = Dust.NewDust(new Vector2(x, y), 8, 8, Type, Alpha: Alpha, Scale: Scale); Main.dust[index].velocity.X *= 0.3f; Main.dust[index].velocity.Y += 10f; Main.dust[index].noGravity = true; Main.dust[index].noLightEmittence = flag18; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); ++this.wingFrameCounter; if (this.wingFrameCounter > 4) { ++this.wingFrame; this.wingFrameCounter = 0; if (this.wingFrame >= 3) this.wingFrame = 0; } } else if (this.wings != 22 && this.wings != 28) { if (this.wings == 30) { ++this.wingFrameCounter; int num24 = 5; if (this.wingFrameCounter >= num24 * 3) this.wingFrameCounter = 0; this.wingFrame = 1 + this.wingFrameCounter / num24; } else if (this.wings == 34) { ++this.wingFrameCounter; int num25 = 7; if (this.wingFrameCounter >= num25 * 6) this.wingFrameCounter = 0; this.wingFrame = this.wingFrameCounter / num25; } else if (this.wings != 45) { if (this.wings == 40) this.wingFrame = 0; else if (this.wings == 44) this.wingFrame = 2; else if (this.wings == 39) { ++this.wingFrameCounter; int num26 = 12; if (this.wingFrameCounter >= num26 * 6) this.wingFrameCounter = 0; this.wingFrame = this.wingFrameCounter / num26; } else if (this.wings == 26) { int num27 = 6; if (this.direction == 1) num27 = -30; int index7 = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num27, this.position.Y), 18, this.height, 217, Alpha: 100, Scale: 1.4f); Main.dust[index7].noGravity = true; Main.dust[index7].noLight = true; Main.dust[index7].velocity /= 4f; Main.dust[index7].velocity -= this.velocity; Main.dust[index7].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); if (Main.rand.Next(2) == 0) { int num28 = -24; if (this.direction == 1) num28 = 12; float y = this.position.Y; if ((double) this.gravDir == -1.0) y += (float) (this.height / 2); int index8 = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num28, y), 12, this.height / 2, 217, Alpha: 100, Scale: 1.4f); Main.dust[index8].noGravity = true; Main.dust[index8].noLight = true; Main.dust[index8].velocity /= 4f; Main.dust[index8].velocity -= this.velocity; Main.dust[index8].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } this.wingFrame = 2; } else if (this.wings == 37) { Color color = Color.Lerp(Color.Black, Color.White, Main.rand.NextFloat()); int num29 = 6; if (this.direction == 1) num29 = -30; int index9 = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num29, this.position.Y), 24, this.height, Utils.SelectRandom(Main.rand, 31, 31, 31), Alpha: 100, Scale: 0.7f); Main.dust[index9].noGravity = true; Main.dust[index9].noLight = true; Main.dust[index9].velocity /= 4f; Main.dust[index9].velocity -= this.velocity; Main.dust[index9].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); if (Main.dust[index9].type == 55) Main.dust[index9].color = color; if (Main.rand.Next(3) == 0) { int num30 = -24; if (this.direction == 1) num30 = 12; float y = this.position.Y; if ((double) this.gravDir == -1.0) y += (float) (this.height / 2); int index10 = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num30, y), 12, this.height / 2, Utils.SelectRandom(Main.rand, 31, 31, 31), Alpha: 140, Scale: 0.7f); Main.dust[index10].noGravity = true; Main.dust[index10].noLight = true; Main.dust[index10].velocity /= 4f; Main.dust[index10].velocity -= this.velocity; Main.dust[index10].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); if (Main.dust[index10].type == 55) Main.dust[index10].color = color; } this.wingFrame = 2; } else if (this.wings != 24) this.wingFrame = this.wings != 43 ? (this.wings != 12 ? 2 : 3) : 1; } } } this.velocity.Y += this.gravity / 3f * this.gravDir; if ((double) this.gravDir == 1.0) { if ((double) this.velocity.Y > (double) this.maxFallSpeed / 3.0 && !this.TryingToHoverDown) this.velocity.Y = this.maxFallSpeed / 3f; } else if ((double) this.velocity.Y < -(double) this.maxFallSpeed / 3.0 && !this.TryingToHoverUp) this.velocity.Y = (float) (-(double) this.maxFallSpeed / 3.0); } else if (this.cartRampTime <= 0) this.velocity.Y += this.gravity * this.gravDir; else --this.cartRampTime; } if (!this.mount.Active || this.mount.Type != 5) { if ((double) this.gravDir == 1.0) { if ((double) this.velocity.Y > (double) this.maxFallSpeed) this.velocity.Y = this.maxFallSpeed; if (this.slowFall && (double) this.velocity.Y > (double) this.maxFallSpeed / 3.0 && !this.TryingToHoverDown) this.velocity.Y = this.maxFallSpeed / 3f; if (this.slowFall && (double) this.velocity.Y > (double) this.maxFallSpeed / 5.0 && this.TryingToHoverUp) this.velocity.Y = this.maxFallSpeed / 10f; } else { if ((double) this.velocity.Y < -(double) this.maxFallSpeed) this.velocity.Y = -this.maxFallSpeed; if (this.slowFall && (double) this.velocity.Y < -(double) this.maxFallSpeed / 3.0 && !this.TryingToHoverDown) this.velocity.Y = (float) (-(double) this.maxFallSpeed / 3.0); if (this.slowFall && (double) this.velocity.Y < -(double) this.maxFallSpeed / 5.0 && this.TryingToHoverUp) this.velocity.Y = (float) (-(double) this.maxFallSpeed / 10.0); } } } } else this.UpdateControlHolds(); if (this.mount.Active) this.wingFrame = 0; if ((this.wingsLogic == 22 || this.wingsLogic == 28 || this.wingsLogic == 30 || this.wingsLogic == 31 || this.wingsLogic == 33 || this.wingsLogic == 35 || this.wingsLogic == 37 || this.wingsLogic == 45) && this.TryingToHoverDown && this.controlJump && (double) this.wingTime > 0.0 && !this.merman) { float num31 = 0.9f; if (this.wingsLogic == 45) num31 = 0.8f; this.velocity.Y *= num31; if ((double) this.velocity.Y > -2.0 && (double) this.velocity.Y < 1.0) this.velocity.Y = 1E-05f; } if (this.wingsLogic == 37 && this.TryingToHoverDown && this.controlJump && (double) this.wingTime > 0.0 && !this.merman) { this.velocity.Y *= 0.92f; if ((double) this.velocity.Y > -2.0 && (double) this.velocity.Y < 1.0) this.velocity.Y = 1E-05f; } this.GrabItems(i); this.LookForTileInteractions(); if (this.tongued) { this.StopVanityActions(); bool flag19 = false; if (Main.wofNPCIndex >= 0) { float num32 = Main.npc[Main.wofNPCIndex].position.X + (float) (Main.npc[Main.wofNPCIndex].width / 2) + (float) (Main.npc[Main.wofNPCIndex].direction * 200); double num33 = (double) Main.npc[Main.wofNPCIndex].position.Y + (double) (Main.npc[Main.wofNPCIndex].height / 2); Vector2 center = this.Center; float num34 = num32 - center.X; double y = (double) center.Y; float num35 = (float) (num33 - y); float num36 = (float) Math.Sqrt((double) num34 * (double) num34 + (double) num35 * (double) num35); float num37 = 11f; float num38; if ((double) num36 > (double) num37) { num38 = num37 / num36; } else { num38 = 1f; flag19 = true; } float num39 = num34 * num38; float num40 = num35 * num38; this.velocity.X = num39; this.velocity.Y = num40; } else flag19 = true; if (flag19 && Main.myPlayer == this.whoAmI) { for (int b = 0; b < 22; ++b) { if (this.buffType[b] == 38) this.DelBuff(b); } } } if (Main.myPlayer == this.whoAmI) { this.WOFTongue(); if (this.controlHook) { if (this.releaseHook) this.QuickGrapple(); this.releaseHook = false; } else this.releaseHook = true; if (this.talkNPC >= 0 && (!new Microsoft.Xna.Framework.Rectangle((int) ((double) this.position.X + (double) (this.width / 2) - (double) (Player.tileRangeX * 16)), (int) ((double) this.position.Y + (double) (this.height / 2) - (double) (Player.tileRangeY * 16)), Player.tileRangeX * 16 * 2, Player.tileRangeY * 16 * 2).Intersects(new Microsoft.Xna.Framework.Rectangle((int) Main.npc[this.talkNPC].position.X, (int) Main.npc[this.talkNPC].position.Y, Main.npc[this.talkNPC].width, Main.npc[this.talkNPC].height)) || this.chest != -1 || !Main.npc[this.talkNPC].active || this.tileEntityAnchor.InUse)) { if (this.chest == -1) SoundEngine.PlaySound(11); this.SetTalkNPC(-1); Main.npcChatCornerItem = 0; Main.npcChatText = ""; } if (this.sign >= 0) { Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle((int) ((double) this.position.X + (double) (this.width / 2) - (double) (Player.tileRangeX * 16)), (int) ((double) this.position.Y + (double) (this.height / 2) - (double) (Player.tileRangeY * 16)), Player.tileRangeX * 16 * 2, Player.tileRangeY * 16 * 2); try { bool flag20 = false; if (Main.sign[this.sign] == null) flag20 = true; if (!flag20 && !new Microsoft.Xna.Framework.Rectangle(Main.sign[this.sign].x * 16, Main.sign[this.sign].y * 16, 32, 32).Intersects(rectangle)) flag20 = true; if (flag20) { SoundEngine.PlaySound(11); this.sign = -1; Main.editSign = false; Main.npcChatText = ""; } } catch { SoundEngine.PlaySound(11); this.sign = -1; Main.editSign = false; Main.npcChatText = ""; } } if (Main.editSign) { if (this.sign == -1) Main.editSign = false; else Main.InputTextSign(); } else if (Main.editChest) { Main.InputTextChest(); if (Main.player[Main.myPlayer].chest == -1) Main.editChest = false; } if (this.mount.Active && this.mount.Cart && (double) Math.Abs(this.velocity.X) > 4.0) { Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle((int) this.position.X, (int) this.position.Y, this.width, this.height); for (int index = 0; index < 200; ++index) { if (Main.npc[index].active && !Main.npc[index].dontTakeDamage && !Main.npc[index].friendly && Main.npc[index].immune[i] == 0 && this.CanNPCBeHitByPlayerOrPlayerProjectile(Main.npc[index]) && rectangle.Intersects(new Microsoft.Xna.Framework.Rectangle((int) Main.npc[index].position.X, (int) Main.npc[index].position.Y, Main.npc[index].width, Main.npc[index].height))) { float num41 = (float) this.meleeCrit; if ((double) num41 < (double) this.rangedCrit) num41 = (float) this.rangedCrit; if ((double) num41 < (double) this.magicCrit) num41 = (float) this.magicCrit; bool crit = false; if ((double) Main.rand.Next(1, 101) <= (double) num41) crit = true; int damage; float knockback; this.GetMinecartDamage(Math.Abs(this.velocity.X) / this.maxRunSpeed, out damage, out knockback); int direction = 1; if ((double) this.velocity.X < 0.0) direction = -1; if (this.whoAmI == Main.myPlayer) this.ApplyDamageToNPC(Main.npc[index], damage, knockback, direction, crit); Main.npc[index].immune[i] = 30; if (!Main.npc[index].active) AchievementsHelper.HandleSpecialEvent(this, 9); } } } this.Update_NPCCollision(); Vector2 vector2 = !this.mount.Active || !this.mount.Cart ? Collision.HurtTiles(this.position, this.velocity, this.width, this.height, this.fireWalk) : Collision.HurtTiles(this.position, this.velocity, this.width, this.height - 16, this.fireWalk); if ((double) vector2.Y == 0.0 && !this.fireWalk) { foreach (Point touchedTile in this.TouchedTiles) { Tile tile = Main.tile[touchedTile.X, touchedTile.Y]; if (tile != null && tile.active() && tile.nactive() && !this.fireWalk && TileID.Sets.TouchDamageHot[(int) tile.type] != 0) { vector2.Y = (float) TileID.Sets.TouchDamageHot[(int) tile.type]; vector2.X = (double) this.Center.X / 16.0 < (double) touchedTile.X + 0.5 ? -1f : 1f; break; } } } if ((double) vector2.Y == 20.0) this.AddBuff(67, 20); else if ((double) vector2.Y == 15.0) { if (this.suffocateDelay < (byte) 5) ++this.suffocateDelay; else this.AddBuff(68, 1); } else if ((double) vector2.Y != 0.0) { int Damage = Main.DamageVar(vector2.Y, -this.luck); this.Hurt(PlayerDeathReason.ByOther(3), Damage, 0, cooldownCounter: 0); if ((double) vector2.Y == 60.0 || (double) vector2.Y == 80.0) this.AddBuff(30, Main.rand.Next(240, 600)); } else this.suffocateDelay = (byte) 0; } if (this.controlRight) { this.releaseRight = false; } else { this.releaseRight = true; this.rightTimer = 7; } if (this.controlLeft) { this.releaseLeft = false; } else { this.releaseLeft = true; this.leftTimer = 7; } this.releaseDown = !this.controlDown; if (this.rightTimer > 0) --this.rightTimer; else if (this.controlRight) this.rightTimer = 7; if (this.leftTimer > 0) --this.leftTimer; else if (this.controlLeft) this.leftTimer = 7; this.GrappleMovement(); this.StickyMovement(); this.CheckDrowning(); if ((double) this.gravDir == -1.0) { this.waterWalk = false; this.waterWalk2 = false; } int height = this.height; if (this.waterWalk) height -= 6; bool flag21 = Collision.LavaCollision(this.position, this.width, height); if (flag21) { if (!this.lavaImmune && Main.myPlayer == i && !this.immune) { if (this.lavaTime > 0) --this.lavaTime; else if (this.lavaRose) { this.Hurt(PlayerDeathReason.ByOther(2), 50, 0); this.AddBuff(24, 210); } else { this.Hurt(PlayerDeathReason.ByOther(2), 80, 0); this.AddBuff(24, 420); } } this.lavaWet = true; } else { this.lavaWet = false; if (this.lavaTime < this.lavaMax) ++this.lavaTime; } if (this.lavaTime > this.lavaMax) this.lavaTime = this.lavaMax; if (this.waterWalk2 && !this.waterWalk) { int num42 = height - 6; } int num43 = Collision.WetCollision(this.position, this.width, this.height) ? 1 : 0; bool honey = Collision.honey; if (honey) { this.AddBuff(48, 1800); this.honeyWet = true; } if (num43 != 0) { if (this.onFire && !this.lavaWet) { for (int b = 0; b < 22; ++b) { if (this.buffType[b] == 24) this.DelBuff(b); } } if (!this.wet) { if (this.wetCount == (byte) 0) { this.wetCount = (byte) 10; if (!flag21) { if (this.honeyWet) { for (int index11 = 0; index11 < 20; ++index11) { int index12 = Dust.NewDust(new Vector2(this.position.X - 6f, (float) ((double) this.position.Y + (double) (this.height / 2) - 8.0)), this.width + 12, 24, 152); --Main.dust[index12].velocity.Y; Main.dust[index12].velocity.X *= 2.5f; Main.dust[index12].scale = 1.3f; Main.dust[index12].alpha = 100; Main.dust[index12].noGravity = true; } SoundEngine.PlaySound(19, (int) this.position.X, (int) this.position.Y); } else { for (int index13 = 0; index13 < 50; ++index13) { int index14 = Dust.NewDust(new Vector2(this.position.X - 6f, (float) ((double) this.position.Y + (double) (this.height / 2) - 8.0)), this.width + 12, 24, Dust.dustWater()); Main.dust[index14].velocity.Y -= 3f; Main.dust[index14].velocity.X *= 2.5f; Main.dust[index14].scale = 0.8f; Main.dust[index14].alpha = 100; Main.dust[index14].noGravity = true; } SoundEngine.PlaySound(19, (int) this.position.X, (int) this.position.Y, 0); } } else { for (int index15 = 0; index15 < 20; ++index15) { int index16 = Dust.NewDust(new Vector2(this.position.X - 6f, (float) ((double) this.position.Y + (double) (this.height / 2) - 8.0)), this.width + 12, 24, 35); Main.dust[index16].velocity.Y -= 1.5f; Main.dust[index16].velocity.X *= 2.5f; Main.dust[index16].scale = 1.3f; Main.dust[index16].alpha = 100; Main.dust[index16].noGravity = true; } SoundEngine.PlaySound(19, (int) this.position.X, (int) this.position.Y); } } this.wet = true; if (this.ShouldFloatInWater) { this.velocity.Y /= 2f; if ((double) this.velocity.Y > 3.0) this.velocity.Y = 3f; } } } else if (this.wet) { this.wet = false; if (this.jump > Player.jumpHeight / 5 && this.wetSlime == (byte) 0) this.jump = Player.jumpHeight / 5; if (this.wetCount == (byte) 0) { this.wetCount = (byte) 10; if (!this.lavaWet) { if (this.honeyWet) { for (int index17 = 0; index17 < 20; ++index17) { int index18 = Dust.NewDust(new Vector2(this.position.X - 6f, (float) ((double) this.position.Y + (double) (this.height / 2) - 8.0)), this.width + 12, 24, 152); --Main.dust[index18].velocity.Y; Main.dust[index18].velocity.X *= 2.5f; Main.dust[index18].scale = 1.3f; Main.dust[index18].alpha = 100; Main.dust[index18].noGravity = true; } SoundEngine.PlaySound(19, (int) this.position.X, (int) this.position.Y); } else { for (int index19 = 0; index19 < 50; ++index19) { int index20 = Dust.NewDust(new Vector2(this.position.X - 6f, this.position.Y + (float) (this.height / 2)), this.width + 12, 24, Dust.dustWater()); Main.dust[index20].velocity.Y -= 4f; Main.dust[index20].velocity.X *= 2.5f; Main.dust[index20].scale = 0.8f; Main.dust[index20].alpha = 100; Main.dust[index20].noGravity = true; } SoundEngine.PlaySound(19, (int) this.position.X, (int) this.position.Y, 0); } } else { for (int index21 = 0; index21 < 20; ++index21) { int index22 = Dust.NewDust(new Vector2(this.position.X - 6f, (float) ((double) this.position.Y + (double) (this.height / 2) - 8.0)), this.width + 12, 24, 35); Main.dust[index22].velocity.Y -= 1.5f; Main.dust[index22].velocity.X *= 2.5f; Main.dust[index22].scale = 1.3f; Main.dust[index22].alpha = 100; Main.dust[index22].noGravity = true; } SoundEngine.PlaySound(19, (int) this.position.X, (int) this.position.Y); } } } if (!honey) this.honeyWet = false; if (!this.wet) { this.lavaWet = false; this.honeyWet = false; } if (this.wetCount > (byte) 0) --this.wetCount; if (this.wetSlime > (byte) 0) --this.wetSlime; if (this.wet && this.mount.Active) { switch (this.mount.Type) { case 3: case 50: this.wetSlime = (byte) 30; if ((double) this.velocity.Y > 2.0) this.velocity.Y *= 0.9f; this.velocity.Y -= 0.5f; if ((double) this.velocity.Y < -4.0) { this.velocity.Y = -4f; break; } break; case 5: case 7: if (this.whoAmI == Main.myPlayer) { this.mount.Dismount(this); break; } break; } } if (Main.expertMode && this.ZoneSnow && this.wet && !this.lavaWet && !this.honeyWet && !this.arcticDivingGear) this.AddBuff(46, 150); float num44 = (float) (1.0 + (double) Math.Abs(this.velocity.X) / 3.0); if ((double) this.gfxOffY > 0.0) { this.gfxOffY -= num44 * this.stepSpeed; if ((double) this.gfxOffY < 0.0) this.gfxOffY = 0.0f; } else if ((double) this.gfxOffY < 0.0) { this.gfxOffY += num44 * this.stepSpeed; if ((double) this.gfxOffY > 0.0) this.gfxOffY = 0.0f; } if ((double) this.gfxOffY > 32.0) this.gfxOffY = 32f; if ((double) this.gfxOffY < -32.0) this.gfxOffY = -32f; if (Main.myPlayer == i) { if (!this.iceSkate) this.CheckIceBreak(); this.CheckCrackedBrickBreak(); } this.SlopeDownMovement(); bool flag22 = this.mount.Type == 7 || this.mount.Type == 8 || this.mount.Type == 12 || this.mount.Type == 44 || this.mount.Type == 48 || this.mount.Type == 49; if ((double) this.velocity.Y == (double) this.gravity && (!this.mount.Active || !this.mount.Cart && !flag22)) Collision.StepDown(ref this.position, ref this.velocity, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, (int) this.gravDir, this.waterWalk || this.waterWalk2); if ((double) this.gravDir == -1.0) { if ((this.carpetFrame != -1 || (double) this.velocity.Y <= (double) this.gravity) && !this.controlUp) Collision.StepUp(ref this.position, ref this.velocity, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, (int) this.gravDir, this.controlUp); } else if ((this.carpetFrame != -1 || (double) this.velocity.Y >= (double) this.gravity) && !this.controlDown && !this.mount.Cart && !flag22 && this.grappling[0] == -1) Collision.StepUp(ref this.position, ref this.velocity, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, (int) this.gravDir, this.controlUp); this.oldPosition = this.position; this.oldDirection = this.direction; bool Falling = false; if ((double) this.velocity.Y > (double) this.gravity) Falling = true; if ((double) this.velocity.Y < -(double) this.gravity) Falling = true; Vector2 velocity1 = this.velocity; this.slideDir = 0; bool ignorePlats = false; bool fallThrough = this.controlDown; if ((((double) this.gravDir == -1.0 ? 1 : 0) | (!this.mount.Active ? 0 : (this.mount.Cart || this.mount.Type == 12 || this.mount.Type == 7 || this.mount.Type == 8 || this.mount.Type == 23 || this.mount.Type == 44 ? 1 : (this.mount.Type == 48 ? 1 : 0))) | (this.GoingDownWithGrapple ? 1 : 0)) != 0) { ignorePlats = true; fallThrough = true; } this.onTrack = false; bool flag23 = false; if (this.mount.Active && this.mount.Cart) { float num45 = this.ignoreWater || this.merman ? 1f : (!this.honeyWet ? (!this.wet ? 1f : 0.5f) : 0.25f); this.velocity = this.velocity * num45; DelegateMethods.Minecart.rotation = this.fullRotation; DelegateMethods.Minecart.rotationOrigin = this.fullRotationOrigin; BitsByte bitsByte = Minecart.TrackCollision(ref this.position, ref this.velocity, ref this.lastBoost, this.width, this.height, this.controlDown, this.controlUp, this.fallStart2, false, this.mount.Delegations); if (bitsByte[0]) { this.onTrack = true; this.gfxOffY = Minecart.TrackRotation(ref this.fullRotation, this.position + this.velocity, this.width, this.height, this.controlDown, this.controlUp, this.mount.Delegations); this.fullRotationOrigin = new Vector2((float) (this.width / 2), (float) this.height); } if (bitsByte[1]) { if (this.controlLeft || this.controlRight) this.cartFlip = !this.cartFlip; if ((double) this.velocity.X > 0.0) this.direction = 1; else if ((double) this.velocity.X < 0.0) this.direction = -1; this.mount.Delegations.MinecartBumperSound(this.position, this.width, this.height); } this.velocity = this.velocity / num45; if (bitsByte[3] && this.whoAmI == Main.myPlayer) flag23 = true; if (bitsByte[2]) this.cartRampTime = (int) ((double) Math.Abs(this.velocity.X) / (double) this.mount.RunSpeed * 20.0); if (bitsByte[4]) this.trackBoost -= 4f; if (bitsByte[5]) this.trackBoost += 4f; } bool flag24 = this.whoAmI == Main.myPlayer && !this.mount.Active; Vector2 position = this.position; if (this.vortexDebuff) this.velocity.Y = (float) ((double) this.velocity.Y * 0.800000011920929 + Math.Cos((double) this.Center.X % 120.0 / 120.0 * 6.28318548202515) * 5.0 * 0.200000002980232); if (this.tongued) { this.position = this.position + this.velocity; flag24 = false; } else if (this.honeyWet && !this.ignoreWater) this.HoneyCollision(fallThrough, ignorePlats); else if (this.wet && !this.merman && !this.ignoreWater && !this.trident) { this.WaterCollision(fallThrough, ignorePlats); } else { this.DryCollision(fallThrough, ignorePlats); if (this.mount.Active && this.mount.IsConsideredASlimeMount && (double) this.velocity.Y != 0.0 && !this.SlimeDontHyperJump) { Vector2 velocity2 = this.velocity; this.velocity.X = 0.0f; this.DryCollision(fallThrough, ignorePlats); this.velocity.X = velocity2.X; } if (this.mount.Active && this.mount.Type == 43 && (double) this.velocity.Y != 0.0) { Vector2 velocity3 = this.velocity; this.velocity.X = 0.0f; this.DryCollision(fallThrough, ignorePlats); this.velocity.X = velocity3.X; } } this.UpdateTouchingTiles(); this.TryBouncingBlocks(Falling); this.TryLandingOnDetonator(); if (!this.tongued) { this.SlopingCollision(fallThrough, ignorePlats); if (!this.isLockedToATile) Collision.StepConveyorBelt((Entity) this, this.gravDir); } if (flag24 && (double) this.velocity.Y == 0.0) AchievementsHelper.HandleRunning(Math.Abs(this.position.X - position.X)); if (flag23) { NetMessage.SendData(13, number: this.whoAmI); Minecart.HitTrackSwitch(new Vector2(this.position.X, this.position.Y), this.width, this.height); } if ((double) velocity1.X != (double) this.velocity.X) { if ((double) velocity1.X < 0.0) this.slideDir = -1; else if ((double) velocity1.X > 0.0) this.slideDir = 1; } if ((double) this.gravDir == 1.0 && Collision.up) { this.velocity.Y = 0.01f; if (!this.merman) this.jump = 0; } else if ((double) this.gravDir == -1.0 && Collision.down) { this.velocity.Y = -0.01f; if (!this.merman) this.jump = 0; } if ((double) this.velocity.Y == 0.0 && this.grappling[0] == -1) this.FloorVisuals(Falling); if (this.whoAmI == Main.myPlayer) Collision.SwitchTiles(this.position, this.width, this.height, this.oldPosition, 1); PressurePlateHelper.UpdatePlayerPosition(this); this.BordersMovement(); this.numMinions = 0; this.slotsMinions = 0.0f; if (this.mount.Type != 8) this.ItemCheck_ManageRightClickFeatures(); this.ItemCheckWrapped(i); this.PlayerFrame(); if (this.mount.Type == 8) this.mount.UseDrill(this); if (this.statLife > this.statLifeMax2) this.statLife = this.statLifeMax2; if (this.statMana > this.statManaMax2) this.statMana = this.statManaMax2; this.grappling[0] = -1; this.grapCount = 0; this.UpdateReleaseUseTile(); this.UpdateAdvancedShadows(); } } private void UpdateControlHolds() { if (this.controlUp) this.releaseUp = false; else this.releaseUp = true; } public void TryOpeningFullscreenMap() { if (!Main.mapEnabled) return; Main.playerInventory = false; this.sign = -1; Main.editSign = false; this.SetTalkNPC(-1); Main.npcChatCornerItem = 0; SoundEngine.PlaySound(10); Main.mapFullscreenScale = 2.5f; Main.mapFullscreen = true; Main.resetMapFull = true; Main.buffString = string.Empty; } public void UpdateLuckFactors() { this.UpdateLadyBugLuckTime(); if (this.whoAmI != Main.myPlayer) return; float torchLuck = this.torchLuck; this.TryRecalculatingTorchLuck(); if ((double) this.torchLuck == (double) torchLuck) return; this.luckNeedsSync = true; } public void RecalculateLuck() { this.luck = (float) ((double) this.GetLadyBugLuck() * 0.200000002980232 + (double) this.torchLuck * 0.200000002980232); this.luck += (float) this.luckPotion * 0.1f; if (LanternNight.LanternsUp) this.luck += 0.3f; if (!this.HasGardenGnomeNearby) return; this.luck += 0.2f; } private static int GetMouseScrollDelta() => PlayerInput.ScrollWheelDelta / 120; private void UpdatePortableStoolUsage() { bool flag = this.portableStoolInfo.HasAStool && this.controlUp && !this.gravControl && !this.mount.Active && (double) this.velocity.X == 0.0 && (double) this.velocity.Y == 0.0 && !this.pulley && this.grappling[0] == -1; if (flag) flag = this.CanFitSpace(this.portableStoolInfo.HeightBoost); if (!flag) return; this.portableStoolInfo.IsInUse = true; this.ResizeHitbox(); } private void ResizeHitbox() { this.position.Y += (float) this.height; this.height = 42 + this.HeightOffsetBoost; this.position.Y -= (float) this.height; } private void UpdateReleaseUseTile() { bool flag = !this.tileInteractAttempted; if (this._lockTileInteractionsTimer > 0 && !this.releaseUseTile) flag = false; this.releaseUseTile = flag; if (this._lockTileInteractionsTimer <= 0) return; --this._lockTileInteractionsTimer; } private void GetMinecartDamage(float currentSpeed, out int damage, out float knockback) { switch (this.mount.Type) { case 11: damage = Main.DamageVar((float) (50.0 + 100.0 * (double) currentSpeed), this.luck); break; case 13: damage = Main.DamageVar((float) (15.0 + 30.0 * (double) currentSpeed), this.luck); break; case 15: case 16: case 18: case 19: case 20: case 21: case 22: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 38: case 39: damage = Main.DamageVar((float) (25.0 + 55.0 * (double) currentSpeed), this.luck); break; default: damage = Main.DamageVar((float) (25.0 + 55.0 * (double) currentSpeed), this.luck); break; } knockback = (float) (5.0 + 25.0 * (double) currentSpeed); } public void UpdateMiscCounter() { ++this.miscCounter; if (this.miscCounter < 300) return; this.miscCounter = 0; } private void WingAirLogicTweaks() { if (this.wingsLogic < 1) return; WingStats wingStats = this.GetWingStats(this.wingsLogic); bool flag = this.TryingToHoverDown && this.controlJump && (double) this.wingTime > 0.0; if (wingStats.HasDownHoverStats & flag) { if ((double) wingStats.DownHoverSpeedOverride != -1.0) this.accRunSpeed = wingStats.DownHoverSpeedOverride; this.runAcceleration *= wingStats.DownHoverAccelerationMult; } else { if ((double) wingStats.AccRunSpeedOverride != -1.0 && (double) wingStats.AccRunSpeedOverride > (double) this.accRunSpeed) this.accRunSpeed = wingStats.AccRunSpeedOverride; this.runAcceleration *= wingStats.AccRunAccelerationMult; } if (this.wingsLogic != 45) return; this.runSlowdown *= 6f; } private void RocketBootVisuals() { int num1 = this.height; if ((double) this.gravDir == -1.0) num1 = 4; for (int index = 0; index < 2; ++index) { int num2 = index == 0 ? 2 : -2; Microsoft.Xna.Framework.Rectangle r = index != 0 ? new Microsoft.Xna.Framework.Rectangle((int) this.position.X + this.width - 4, (int) this.position.Y + num1 - 10, 8, 8) : new Microsoft.Xna.Framework.Rectangle((int) this.position.X - 4, (int) this.position.Y + num1 - 10, 8, 8); if (this.direction == -1) r.X -= 4; int Type = 6; float Scale = 2.5f; int Alpha = 100; float num3 = 1f; Vector2 vector2 = new Vector2((float) -num2 - this.velocity.X * 0.3f, (float) (2.0 * (double) this.gravDir - (double) this.velocity.Y * 0.300000011920929)); switch (this.rocketBoots) { case 1: if (this.socialShadowRocketBoots) { Type = 27; Scale = 1.5f; goto default; } else goto default; case 2: if (this.fairyBoots) { Type = (int) Main.rand.NextFromList((short) 61, (short) 61, (short) 61, (short) 242, (short) 64, (short) 63); Scale = 2f; Alpha = 120; goto default; } else { Type = 16; Scale = 1.5f; Alpha = 20; goto default; } case 3: Type = 76; Scale = 1f; Alpha = 20; goto default; case 4: int num4 = Main.rand.Next(6); r.Y += 2 * (int) this.gravDir; if (num4 == 0 || num4 == 1) { Dust dust = Dust.NewDustDirect(r.TopLeft(), r.Width, r.Height, 278, Alpha: 100, newColor: Color.Lerp(Color.LimeGreen, Color.White, Main.rand.NextFloat() * 0.3f)); dust.shader = GameShaders.Armor.GetSecondaryShader(this.cShoe, this); dust.scale = 0.66f; dust.noGravity = true; dust.velocity *= 0.25f; dust.velocity -= this.velocity * 0.5f; dust.velocity += vector2 * 0.5f; dust.position += dust.velocity * 4f; if (Main.rand.Next(5) == 0) { dust.fadeIn = 0.8f; break; } break; } Type = 107; Alpha = 100; Scale = 0.7f; num3 = 0.5f; goto default; default: Dust dust1 = Dust.NewDustDirect(r.TopLeft(), r.Width, r.Height, Type, Alpha: Alpha, Scale: Scale); dust1.shader = GameShaders.Armor.GetSecondaryShader(this.cShoe, this); dust1.velocity += vector2; dust1.velocity *= num3; switch (this.rocketBoots) { case 1: dust1.noGravity = true; break; case 2: dust1.velocity *= 0.1f; break; case 3: dust1.velocity *= 0.05f; dust1.velocity.Y += 0.15f; dust1.noLight = true; if (Main.rand.Next(2) == 0) { dust1.noGravity = true; dust1.scale = 1.75f; break; } break; } if (this.fairyBoots) { dust1.noGravity = true; dust1.noLightEmittence = true; break; } break; } } } public void WingFrame(bool wingFlap) { bool flag1 = this.wingsLogic != this.wings; if (this.wings == 4) { if (wingFlap || this.jump > 0) { --this.rocketDelay2; if (this.rocketDelay2 <= 0) { SoundEngine.PlaySound(SoundID.Item13, this.position); this.rocketDelay2 = 60; } int num = 2; if (this.TryingToHoverUp) num = 4; for (int index1 = 0; index1 < num; ++index1) { int Type = 6; if (this.head == 41) { int body = this.body; } float Scale = 1.75f; int Alpha = 100; float x = (float) ((double) this.position.X + (double) (this.width / 2) + 16.0); if (this.direction > 0) x = (float) ((double) this.position.X + (double) (this.width / 2) - 26.0); float y = (float) ((double) this.position.Y + (double) this.height - 18.0); if (index1 == 1 || index1 == 3) { x = (float) ((double) this.position.X + (double) (this.width / 2) + 8.0); if (this.direction > 0) x = (float) ((double) this.position.X + (double) (this.width / 2) - 20.0); y += 6f; } if (index1 > 1) y += this.velocity.Y; int index2 = Dust.NewDust(new Vector2(x, y), 8, 8, Type, Alpha: Alpha, Scale: Scale); Main.dust[index2].velocity.X *= 0.1f; Main.dust[index2].velocity.Y = (float) ((double) Main.dust[index2].velocity.Y * 1.0 + 2.0 * (double) this.gravDir - (double) this.velocity.Y * 0.300000011920929); Main.dust[index2].noGravity = true; Main.dust[index2].noLightEmittence = flag1; Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); if (num == 4) Main.dust[index2].velocity.Y += 6f; } ++this.wingFrameCounter; if (this.wingFrameCounter <= 4) return; ++this.wingFrame; this.wingFrameCounter = 0; if (this.wingFrame < 3) return; this.wingFrame = 0; } else { if (this.controlJump && (double) this.velocity.Y != 0.0) return; this.wingFrame = 3; } } else if (this.wings == 28 && this.ShouldDrawWingsThatAreAlwaysAnimated()) { if (flag1 || (double) this.velocity.Y == 0.0) return; Lighting.AddLight(this.Bottom, 0.3f, 0.1f, 0.4f); } else if (this.wings == 22) { if (!this.controlJump) { this.wingFrame = 0; this.wingFrameCounter = 0; } else if ((double) this.wingTime > 0.0) { if (this.TryingToHoverDown) { if ((double) this.velocity.X != 0.0) { ++this.wingFrameCounter; int num = 2; if (this.wingFrameCounter < num) this.wingFrame = 1; else if (this.wingFrameCounter < num * 2) this.wingFrame = 2; else if (this.wingFrameCounter < num * 3) this.wingFrame = 3; else if (this.wingFrameCounter < num * 4 - 1) { this.wingFrame = 2; } else { this.wingFrame = 2; this.wingFrameCounter = 0; } } else { ++this.wingFrameCounter; int num = 6; if (this.wingFrameCounter < num) this.wingFrame = 4; else if (this.wingFrameCounter < num * 2) this.wingFrame = 5; else if (this.wingFrameCounter < num * 3 - 1) { this.wingFrame = 4; } else { this.wingFrame = 4; this.wingFrameCounter = 0; } } } else { ++this.wingFrameCounter; int num = 2; if (this.wingFrameCounter < num) this.wingFrame = 4; else if (this.wingFrameCounter < num * 2) this.wingFrame = 5; else if (this.wingFrameCounter < num * 3) this.wingFrame = 6; else if (this.wingFrameCounter < num * 4 - 1) { this.wingFrame = 5; } else { this.wingFrame = 5; this.wingFrameCounter = 0; } } } else { ++this.wingFrameCounter; int num = 6; if (this.wingFrameCounter < num) this.wingFrame = 4; else if (this.wingFrameCounter < num * 2) this.wingFrame = 5; else if (this.wingFrameCounter < num * 3 - 1) { this.wingFrame = 4; } else { this.wingFrame = 4; this.wingFrameCounter = 0; } } } else if (this.wings == 12) { if (wingFlap || this.jump > 0) { ++this.wingFrameCounter; int num = 5; if (this.wingFrameCounter < num) this.wingFrame = 1; else if (this.wingFrameCounter < num * 2) this.wingFrame = 2; else if (this.wingFrameCounter < num * 3) this.wingFrame = 3; else if (this.wingFrameCounter < num * 4 - 1) { this.wingFrame = 2; } else { this.wingFrame = 2; this.wingFrameCounter = 0; } } else if ((double) this.velocity.Y != 0.0) this.wingFrame = 2; else this.wingFrame = 0; } else if (this.wings == 24) { if (wingFlap || this.jump > 0) { ++this.wingFrameCounter; int num = 1; if (this.wingFrameCounter < num) this.wingFrame = 1; else if (this.wingFrameCounter < num * 2) this.wingFrame = 2; else if (this.wingFrameCounter < num * 3) { this.wingFrame = 3; } else { this.wingFrame = 2; if (this.wingFrameCounter < num * 4 - 1) return; this.wingFrameCounter = 0; } } else if ((double) this.velocity.Y != 0.0) { if (this.controlJump) { ++this.wingFrameCounter; int num = 3; if (this.wingFrameCounter < num) this.wingFrame = 1; else if (this.wingFrameCounter < num * 2) this.wingFrame = 2; else if (this.wingFrameCounter < num * 3) { this.wingFrame = 3; } else { this.wingFrame = 2; if (this.wingFrameCounter < num * 4 - 1) return; this.wingFrameCounter = 0; } } else if ((double) this.wingTime == 0.0) this.wingFrame = 0; else this.wingFrame = 1; } else this.wingFrame = 0; } else if (this.wings == 30) { bool flag2 = false; if (wingFlap || this.jump > 0) { ++this.wingFrameCounter; int num = 2; if (this.wingFrameCounter >= num * 3) this.wingFrameCounter = 0; this.wingFrame = 1 + this.wingFrameCounter / num; flag2 = true; } else if ((double) this.velocity.Y != 0.0) { if (this.controlJump) { ++this.wingFrameCounter; int num = 2; if (this.wingFrameCounter >= num * 3) this.wingFrameCounter = 0; this.wingFrame = 1 + this.wingFrameCounter / num; flag2 = true; } else this.wingFrame = (double) this.wingTime != 0.0 ? 0 : 0; } else this.wingFrame = 0; if (!flag2) return; for (int index = 0; index < 4; ++index) { if (Main.rand.Next(4) == 0) { Vector2 vector2 = ((float) (0.392699092626572 * (double) index - 0.745398163795471 + 0.0299999993294477 * (double) index)).ToRotationVector2() * new Vector2((float) (-this.direction * 20), 20f); Dust dust = Main.dust[Dust.NewDust(this.Center, 0, 0, 229, Alpha: 100, newColor: Color.White, Scale: 0.8f)]; dust.noGravity = true; dust.noLightEmittence = flag1; dust.position = this.Center + vector2; dust.velocity = this.DirectionTo(dust.position) * 2f; if (Main.rand.Next(10) != 0) dust.customData = (object) this; else dust.fadeIn = 0.5f; dust.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } } for (int index = 0; index < 4; ++index) { if (Main.rand.Next(8) == 0) { Vector2 vector2 = ((float) (0.392699092626572 * (double) index - 0.705398201942444 + 0.0299999993294477 * (double) index)).ToRotationVector2() * new Vector2((float) (this.direction * 20), 24f) + new Vector2((float) -this.direction * 16f, 0.0f); Dust dust = Main.dust[Dust.NewDust(this.Center, 0, 0, 229, Alpha: 100, newColor: Color.White, Scale: 0.5f)]; dust.noGravity = true; dust.noLightEmittence = flag1; dust.position = this.Center + vector2; dust.velocity = Vector2.Normalize(dust.position - this.Center - new Vector2((float) -this.direction * 16f, 0.0f)) * 2f; dust.position += dust.velocity * 5f; if (Main.rand.Next(10) != 0) dust.customData = (object) this; else dust.fadeIn = 0.5f; dust.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } } } else if (this.wings == 34 && this.ShouldDrawWingsThatAreAlwaysAnimated()) { if (wingFlap || this.jump > 0) { ++this.wingFrameCounter; int num = 4; if (this.wingFrameCounter >= num * 6) this.wingFrameCounter = 0; this.wingFrame = this.wingFrameCounter / num; } else if ((double) this.velocity.Y != 0.0) { if (this.controlJump) { ++this.wingFrameCounter; int num = 9; if (this.wingFrameCounter >= num * 6) this.wingFrameCounter = 0; this.wingFrame = this.wingFrameCounter / num; } else { ++this.wingFrameCounter; int num = 6; if (this.wingFrameCounter >= num * 6) this.wingFrameCounter = 0; this.wingFrame = this.wingFrameCounter / num; } } else { ++this.wingFrameCounter; int num = 4; if (this.wingFrameCounter >= num * 6) this.wingFrameCounter = 0; this.wingFrame = this.wingFrameCounter / num; } } else if (this.wings == 45 && this.ShouldDrawWingsThatAreAlwaysAnimated()) { if ((double) this.wingTime > 0.0) { --this.rocketDelay2; if (this.rocketDelay2 <= 0) { SoundEngine.PlaySound(SoundID.Item24, this.position); this.rocketDelay2 = 30; } } if ((double) this.velocity.Y == 0.0) { this.wingFrameCounter = 0; this.wingFrame = 0; } else { ++this.wingFrameCounter; int num = 3; if ((double) this.wingTime == 0.0) num = 5; if (this.wingFrameCounter >= num * 6) this.wingFrameCounter = 0; this.wingFrame = this.wingFrameCounter / num; } if (Main.rand.Next(8) != 0) return; Microsoft.Xna.Framework.Rectangle r = Utils.CenteredRectangle(Main.ReverseGravitySupport(this.Bottom), new Vector2(40f, 24f)); Dust dust = Dust.NewDustDirect(r.TopLeft(), r.Width, r.Height, 43, newColor: (Color.White * 0.5f), Scale: 0.2f); dust.fadeIn = 0.4f; dust.velocity += this.velocity; dust.velocity *= 0.35f; dust.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } else if (this.wings == 44 && this.ShouldDrawWingsThatAreAlwaysAnimated()) { int num = 5; if (wingFlap || this.jump > 0) { ++this.wingFrameCounter; if (this.wingFrameCounter >= num * 6) this.wingFrameCounter = 0; this.wingFrame = 1 + this.wingFrameCounter / num; } else if ((double) this.velocity.Y != 0.0) { if (this.controlJump) this.wingFrame = 2; else if (this.ShouldFloatInWater && this.wet) this.wingFrame = 0; else this.wingFrame = 3; } else { ++this.wingFrameCounter; if (this.wingFrameCounter >= num * 6) this.wingFrameCounter = 0; this.wingFrame = 1 + this.wingFrameCounter / num; } } else if (this.wings == 39 && this.ShouldDrawWingsThatAreAlwaysAnimated()) { if (wingFlap || this.jump > 0) { ++this.wingFrameCounter; int num = 4; if (this.wingFrameCounter >= num * 6) this.wingFrameCounter = 0; this.wingFrame = this.wingFrameCounter / num; } else if ((double) this.velocity.Y != 0.0) { if (this.controlJump) { ++this.wingFrameCounter; int num = 9; if (this.wingFrameCounter >= num * 6) this.wingFrameCounter = 0; this.wingFrame = this.wingFrameCounter / num; } else { ++this.wingFrameCounter; int num = 6; if (this.wingFrameCounter >= num * 6) this.wingFrameCounter = 0; this.wingFrame = this.wingFrameCounter / num; } } else { ++this.wingFrameCounter; int num = 4; if (this.wingFrameCounter >= num * 6) this.wingFrameCounter = 0; this.wingFrame = this.wingFrameCounter / num; } int num1 = 1; if (this.wingFrame == 3) num1 = 5; if ((double) this.velocity.Y == 0.0) num1 = 0; Microsoft.Xna.Framework.Rectangle r = Utils.CenteredRectangle((double) this.gravDir == 1.0 ? this.Bottom + new Vector2(0.0f, -10f) : this.Top + new Vector2(0.0f, 10f), new Vector2(50f, 20f)); for (int index = 0; index < num1; ++index) { Dust dust = Dust.NewDustDirect(r.TopLeft(), r.Width, r.Height, 31, newColor: Color.Black); dust.scale = 0.7f; dust.velocity *= 0.4f; dust.velocity.Y += this.gravDir * 0.5f; dust.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } } else if (this.wings == 33) { bool flag3 = false; if (wingFlap || this.jump > 0) flag3 = true; else if ((double) this.velocity.Y != 0.0 && this.controlJump) flag3 = true; if (!flag3) return; Color rgb = Main.hslToRgb(Main.rgbToHsl(this.eyeColor).X, 1f, 0.5f); int num2 = this.direction == 1 ? 0 : -4; int num3 = (double) this.gravDir == 1.0 ? this.height : 0; for (int index = 0; index < 2; ++index) { Dust rf = Main.dust[Dust.NewDust(this.position, this.width, this.height, 182, this.velocity.X, this.velocity.Y, (int) sbyte.MaxValue, rgb)]; rf.noGravity = true; rf.fadeIn = 1f; rf.scale = 1f; rf.noLight = true; rf.noLightEmittence = flag1; rf.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); if (index == 0) { rf.position = new Vector2(this.position.X + (float) num2, this.position.Y + (float) num3); rf.velocity.X = (float) ((double) rf.velocity.X * 1.0 - 2.0 - (double) this.velocity.X * 0.300000011920929); rf.velocity.Y = (float) ((double) rf.velocity.Y * 1.0 + 2.0 * (double) this.gravDir - (double) this.velocity.Y * 0.300000011920929); } else if (index == 1) { rf.position = new Vector2(this.position.X + (float) this.width + (float) num2, this.position.Y + (float) num3); rf.velocity.X = (float) ((double) rf.velocity.X * 1.0 + 2.0 - (double) this.velocity.X * 0.300000011920929); rf.velocity.Y = (float) ((double) rf.velocity.Y * 1.0 + 2.0 * (double) this.gravDir - (double) this.velocity.Y * 0.300000011920929); } if (rf.dustIndex != 6000) { Dust dust = Dust.CloneDust(rf); dust.scale *= 0.65f; dust.fadeIn *= 0.65f; dust.color = new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue); rf.noLight = true; rf.noLightEmittence = flag1; rf.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } } } else if (this.wings == 38) { bool flag4 = false; if (wingFlap || this.jump > 0) { ++this.wingFrameCounter; if (this.wingFrameCounter >= 32) this.wingFrameCounter = 0; this.wingFrame = 1 + this.wingFrameCounter / 8; if (this.wingFrame == 4) this.wingFrame = 2; flag4 = true; } else if ((double) this.velocity.Y != 0.0) { if (this.controlJump) { ++this.wingFrameCounter; if (this.wingFrameCounter >= 32) this.wingFrameCounter = 0; this.wingFrame = 1 + this.wingFrameCounter / 8; if (this.wingFrame == 4) this.wingFrame = 2; flag4 = true; } else this.wingFrame = 0; } else this.wingFrame = 0; if (!flag4) return; Vector2 vector2_1 = new Vector2((float) this.direction, this.gravDir); Vector2 vector2_2 = this.velocity * 0.5f; int Type = 267; int num = this.miscCounter * this.direction; for (int index = 0; index < 3; ++index) { Vector2 vector2_3 = Vector2.Zero; if (index != 1) { if (index == 2) vector2_3 = this.velocity * -0.66f; } else vector2_3 = this.velocity * -0.33f; Dust dust1 = Dust.NewDustPerfect(this.Center + (new Vector2(-39f, 6f) * vector2_1 + new Vector2(2f, 0.0f).RotatedBy((double) num / -15.0 * 6.28318548202515)) + vector2_3, Type, new Vector2?(vector2_2), newColor: this.underShirtColor); dust1.noGravity = true; dust1.noLight = true; dust1.noLightEmittence = flag1; dust1.scale = 0.47f; dust1.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); Dust dust2 = Dust.NewDustPerfect(this.Center + (new Vector2(-23f, 2f) * vector2_1 + new Vector2(2f, 0.0f).RotatedBy((double) num / -15.0 * 6.28318548202515)) + vector2_3, Type, new Vector2?(vector2_2), newColor: this.underShirtColor); dust2.noGravity = true; dust2.noLight = true; dust2.noLightEmittence = flag1; dust2.scale = 0.35f; dust2.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); Dust dust3 = Dust.NewDustPerfect(this.Center + (new Vector2(-31f, -6f) * vector2_1 + new Vector2(2f, 0.0f).RotatedBy((double) num / -20.0 * 6.28318548202515)) + vector2_3, Type, new Vector2?(vector2_2), newColor: this.underShirtColor); dust3.noGravity = true; dust3.noLight = true; dust3.noLightEmittence = flag1; dust3.scale = 0.49f; dust3.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } } else { int num4 = 4; int num5 = 4; int num6 = 0; if (this.wings == 43) { num5 = 7; num6 = 1; num4 = 3; } if (this.wings == 32) num4 = 3; if (wingFlap || this.jump > 0) { ++this.wingFrameCounter; if (this.wingFrameCounter <= num4) return; ++this.wingFrame; this.wingFrameCounter = 0; if (this.wingFrame < num5) return; this.wingFrame = num6; } else if ((double) this.velocity.Y != 0.0) { this.wingFrame = 1; if (this.wings == 32) this.wingFrame = 3; if (this.wings == 43) { this.wingFrame = 2; if (this.ShouldFloatInWater && this.wet) this.wingFrame = 0; } if (this.wings != 29 || Main.rand.Next(5) != 0) return; int num7 = 4; if (this.direction == 1) num7 = -40; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num7, (float) ((double) this.position.Y + (double) (this.height / 2) - 15.0)), 30, 30, 6, Alpha: 100, Scale: 2.4f); Main.dust[index].noGravity = true; Main.dust[index].noLightEmittence = flag1; Main.dust[index].velocity *= 0.3f; if (Main.rand.Next(10) == 0) Main.dust[index].fadeIn = 2f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } else this.wingFrame = 0; } } public bool ShouldDrawWingsThatAreAlwaysAnimated() => ((double) this.velocity.Y != 0.0 || this.grappling[0] != -1) && (!this.wet || !this.ShouldFloatInWater) && !this.mount.Active; private void WingAirVisuals() { bool flag = this.wingsLogic != this.wings; if (this.wings == 10 && Main.rand.Next(2) == 0) { int num = 4; if (this.direction == 1) num = -40; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num, (float) ((double) this.position.Y + (double) (this.height / 2) - 15.0)), 30, 30, 76, Alpha: 50, Scale: 0.6f); Main.dust[index].fadeIn = 1.1f; Main.dust[index].noGravity = true; Main.dust[index].noLight = true; Main.dust[index].velocity *= 0.3f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } if (this.wings == 34 && Main.rand.Next(2) == 0) { int num = 4; if (this.direction == 1) num = -40; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num, (float) ((double) this.position.Y + (double) (this.height / 2) - 15.0)), 30, 30, 261, Alpha: 50, Scale: 0.6f); Main.dust[index].fadeIn = 1.1f; Main.dust[index].noGravity = true; Main.dust[index].noLight = true; Main.dust[index].noLightEmittence = flag; Main.dust[index].velocity *= 0.3f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } int wings1 = this.wings; int wings2 = this.wings; if (this.wings == 9 && Main.rand.Next(2) == 0) { int num = 4; if (this.direction == 1) num = -40; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num, (float) ((double) this.position.Y + (double) (this.height / 2) - 15.0)), 30, 30, 6, Alpha: 200, Scale: 2f); Main.dust[index].noGravity = true; Main.dust[index].noLightEmittence = flag; Main.dust[index].velocity *= 0.3f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } if (this.wings == 6 && Main.rand.Next(4) == 0) { int num = 4; if (this.direction == 1) num = -40; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num, (float) ((double) this.position.Y + (double) (this.height / 2) - 15.0)), 30, 30, 55, Alpha: 200); Main.dust[index].velocity *= 0.3f; Main.dust[index].noLightEmittence = flag; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } if (this.wings == 5 && Main.rand.Next(3) == 0) { int num = 6; if (this.direction == 1) num = -30; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num, this.position.Y), 18, this.height, 58, Alpha: ((int) byte.MaxValue), Scale: 1.2f); Main.dust[index].noLightEmittence = flag; Main.dust[index].velocity *= 0.3f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } if (this.wings == 26) { int num1 = 6; if (this.direction == 1) num1 = -30; int index1 = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num1, this.position.Y), 18, this.height, 217, Alpha: 100, Scale: 1.4f); Main.dust[index1].noGravity = true; Main.dust[index1].noLight = true; Main.dust[index1].velocity /= 4f; Main.dust[index1].velocity -= this.velocity; Main.dust[index1].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); if (Main.rand.Next(2) == 0) { int num2 = -24; if (this.direction == 1) num2 = 12; float y = this.position.Y; if ((double) this.gravDir == -1.0) y += (float) (this.height / 2); int index2 = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num2, y), 12, this.height / 2, 217, Alpha: 100, Scale: 1.4f); Main.dust[index2].noGravity = true; Main.dust[index2].noLight = true; Main.dust[index2].velocity /= 4f; Main.dust[index2].velocity -= this.velocity; Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } } if (this.wings == 37) { int num3 = 6; if (this.direction == 1) num3 = -30; Dust dust1 = Dust.NewDustDirect(new Vector2(this.position.X + (float) (this.width / 2) + (float) num3, this.position.Y), 24, this.height, Utils.SelectRandom(Main.rand, 31, 31, 31), Alpha: 100); dust1.noGravity = true; dust1.noLight = true; dust1.velocity /= 4f; dust1.velocity -= this.velocity / 2f; dust1.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); if (dust1.type == 55) { dust1.noGravity = true; dust1.velocity *= 2f; dust1.color = Color.Red; } if (Main.rand.Next(3) == 0) { int num4 = -24; if (this.direction == 1) num4 = 12; float y = this.position.Y; if ((double) this.gravDir == -1.0) y += (float) (this.height / 2); Dust dust2 = Dust.NewDustDirect(new Vector2(this.position.X + (float) (this.width / 2) + (float) num4, y), 16, this.height / 2, Utils.SelectRandom(Main.rand, 31, 31, 31), Alpha: 100); dust2.noGravity = true; dust2.noLight = true; dust2.velocity /= 4f; dust2.velocity -= this.velocity / 2f; dust2.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); if (dust2.type == 55) { dust2.noGravity = true; dust2.velocity *= 2f; dust2.color = Color.Red; } } } if (this.wings == 29 && Main.rand.Next(3) == 0) { int num = 4; if (this.direction == 1) num = -40; int index = Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num, (float) ((double) this.position.Y + (double) (this.height / 2) - 15.0)), 30, 30, 6, Alpha: 100, Scale: 2.4f); Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.3f; Main.dust[index].noLightEmittence = flag; if (Main.rand.Next(10) == 0) Main.dust[index].fadeIn = 2f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } if (this.wings != 31) return; if (Main.rand.Next(6) == 0) { int num = 4; if (this.direction == 1) num = -40; Dust dust = Main.dust[Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num, (float) ((double) this.position.Y + (double) (this.height / 2) - 15.0)), 30, 30, 86)]; dust.noGravity = true; dust.scale = 1f; dust.fadeIn = 1.2f; dust.velocity *= 0.2f; dust.noLight = true; dust.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } if (Main.rand.Next(3) == 0) { int num = 4; if (this.direction == 1) num = -40; Dust dust = Main.dust[Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num, (float) ((double) this.position.Y + (double) (this.height / 2) - 15.0)), 30, 30, 240)]; dust.noGravity = true; dust.scale = 1.2f; dust.velocity *= 0.2f; dust.alpha = 200; dust.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } if (Main.rand.Next(2) != 0) return; if (Main.rand.Next(6) == 0) { int num = -24; if (this.direction == 1) num = 12; float y = this.position.Y; if ((double) this.gravDir == -1.0) y += (float) (this.height / 2); Dust dust = Main.dust[Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num, y), 12, this.height / 2, 86)]; dust.noGravity = true; dust.scale = 1f; dust.fadeIn = 1.2f; dust.velocity *= 0.2f; dust.noLight = true; dust.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } if (Main.rand.Next(3) != 0) return; int num5 = -24; if (this.direction == 1) num5 = 12; float y1 = this.position.Y; if ((double) this.gravDir == -1.0) y1 += (float) (this.height / 2); Dust dust3 = Main.dust[Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2) + (float) num5, y1), 12, this.height / 2, 240)]; dust3.noGravity = true; dust3.scale = 1.2f; dust3.velocity *= 0.2f; dust3.alpha = 200; dust3.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this); } private void HandleBeingInChestRange() { if (this.chest != -1) { if (this.chest != -2) this.flyingPigChest = -1; if (this.chest != -5) this.voidLensChest = -1; if (this.flyingPigChest >= 0) { if (!Main.projectile[this.flyingPigChest].active || Main.projectile[this.flyingPigChest].type != 525) { SoundEngine.PlaySound(SoundID.Item59); this.chest = -1; Recipe.FindRecipes(); } else { int num1 = (int) (((double) this.position.X + (double) this.width * 0.5) / 16.0); int num2 = (int) (((double) this.position.Y + (double) this.height * 0.5) / 16.0); Vector2 vector2 = Main.projectile[this.flyingPigChest].Hitbox.ClosestPointInRect(this.Center); this.chestX = (int) vector2.X / 16; this.chestY = (int) vector2.Y / 16; if (num1 >= this.chestX - Player.tileRangeX && num1 <= this.chestX + Player.tileRangeX + 1 && num2 >= this.chestY - Player.tileRangeY && num2 <= this.chestY + Player.tileRangeY + 1) return; if (this.chest != -1) SoundEngine.PlaySound(SoundID.Item59); this.chest = -1; Recipe.FindRecipes(); } } else if (this.voidLensChest >= 0) { if (!Main.projectile[this.voidLensChest].active || Main.projectile[this.voidLensChest].type != 734) { SoundEngine.PlaySound(SoundID.Item130); this.chest = -1; Recipe.FindRecipes(); } else { int num3 = (int) (((double) this.position.X + (double) this.width * 0.5) / 16.0); int num4 = (int) (((double) this.position.Y + (double) this.height * 0.5) / 16.0); Vector2 vector2 = Main.projectile[this.voidLensChest].Hitbox.ClosestPointInRect(this.Center); this.chestX = (int) vector2.X / 16; this.chestY = (int) vector2.Y / 16; if (num3 >= this.chestX - Player.tileRangeX && num3 <= this.chestX + Player.tileRangeX + 1 && num4 >= this.chestY - Player.tileRangeY && num4 <= this.chestY + Player.tileRangeY + 1) return; if (this.chest != -1) SoundEngine.PlaySound(SoundID.Item130); this.chest = -1; Recipe.FindRecipes(); } } else if (!this.IsInInteractionRangeToMultiTileHitbox(this.chestX, this.chestY)) { if (this.chest != -1) SoundEngine.PlaySound(11); this.chest = -1; Recipe.FindRecipes(); } else { if (Main.tile[this.chestX, this.chestY].active()) return; SoundEngine.PlaySound(11); this.chest = -1; Recipe.FindRecipes(); } } else { this.flyingPigChest = -1; this.voidLensChest = -1; } } public bool IsInInteractionRangeToMultiTileHitbox(int chestPointX, int chestPointY) { int num1 = (int) (((double) this.position.X + (double) this.width * 0.5) / 16.0); int num2 = (int) (((double) this.position.Y + (double) this.height * 0.5) / 16.0); Microsoft.Xna.Framework.Rectangle r = Microsoft.Xna.Framework.Rectangle.Empty; Tile tile = Main.tile[chestPointX, chestPointY]; if (tile.type == (ushort) 463 || tile.type == (ushort) 491) r = new Microsoft.Xna.Framework.Rectangle(chestPointX * 16 - 16, chestPointY * 16 - 32, 48, 64); if (TileID.Sets.BasicChest[(int) tile.type] || tile.type == (ushort) 97) r = new Microsoft.Xna.Framework.Rectangle(chestPointX * 16, chestPointY * 16, 32, 32); if (tile.type == (ushort) 88) r = new Microsoft.Xna.Framework.Rectangle(chestPointX * 16, chestPointY * 16, 48, 32); if (tile.type == (ushort) 29) r = new Microsoft.Xna.Framework.Rectangle(chestPointX * 16, chestPointY * 16, 32, 16); r.Inflate(-1, -1); Point tileCoordinates = r.ClosestPointInRect(this.Center).ToTileCoordinates(); chestPointX = tileCoordinates.X; chestPointY = tileCoordinates.Y; return (num1 < chestPointX - Player.tileRangeX || num1 > chestPointX + Player.tileRangeX + 1 || num2 < chestPointY - Player.tileRangeY ? 1 : (num2 > chestPointY + Player.tileRangeY + 1 ? 1 : 0)) == 0; } public void ResetVisibleAccessories() { this.handon = (sbyte) -1; this.handoff = (sbyte) -1; this.back = (sbyte) -1; this.front = (sbyte) -1; this.shoe = (sbyte) -1; this.waist = (sbyte) -1; this.shield = (sbyte) -1; this.neck = (sbyte) -1; this.face = (sbyte) -1; this.balloon = (sbyte) -1; } public void UpdateArmorLights() { if (this.vortexStealthActive) return; float num1 = 0.0f; float num2 = 0.0f; float num3 = 0.0f; switch (this.head) { case 11: num1 = 0.92f; num2 = 0.8f; num3 = 0.65f; break; case 169: num1 = 0.0f; num2 = 0.36f; num3 = 0.4f; break; case 170: num1 = 0.4f; num2 = 0.16f; num3 = 0.36f; break; case 171: num1 = 0.5f; num2 = 0.25f; num3 = 0.05f; break; case 178: num1 = 0.1f; num2 = 0.2f; num3 = 0.3f; break; case 189: num1 = 0.9f; num2 = 0.9f; num3 = 0.7f; break; case 211: num1 = 0.2f; num2 = 0.4f; num3 = 0.8f; break; case 216: num1 = 0.7f; num2 = 0.95f; num3 = 0.82f; break; } float num4 = 0.0f; float num5 = 0.0f; float num6 = 0.0f; switch (this.body) { case 175: num4 = 0.0f; num5 = 0.36f; num6 = 0.4f; break; case 176: num4 = 0.4f; num5 = 0.16f; num6 = 0.36f; break; case 177: num4 = 0.5f; num5 = 0.25f; num6 = 0.05f; break; case 190: num1 = 0.9f; num2 = 0.9f; num3 = 0.7f; break; case 205: num4 = 0.2f; num5 = 0.4f; num6 = 0.8f; break; } float num7 = 0.0f; float num8 = 0.0f; float num9 = 0.0f; switch (this.legs) { case 110: num7 = 0.0f; num8 = 0.36f; num9 = 0.4f; break; case 111: num7 = 0.4f; num8 = 0.16f; num9 = 0.36f; break; case 112: num7 = 0.5f; num8 = 0.25f; num9 = 0.05f; break; case 130: num1 = 0.9f; num2 = 0.9f; num3 = 0.7f; break; } if ((double) num1 != 0.0 || (double) num2 != 0.0 || (double) num3 != 0.0) { float num10 = 1f; if ((double) num1 == (double) num4 && (double) num2 == (double) num5 && (double) num3 == (double) num6) num10 += 0.5f; if ((double) num1 == (double) num7 && (double) num2 == (double) num8 && (double) num3 == (double) num9) num10 += 0.5f; Vector2 spinningpoint = new Vector2((float) (this.width / 2 + 8 * this.direction), 2f); if ((double) this.fullRotation != 0.0) spinningpoint = spinningpoint.RotatedBy((double) this.fullRotation, this.fullRotationOrigin); Lighting.AddLight((int) ((double) this.position.X + (double) spinningpoint.X) / 16, (int) ((double) this.position.Y + (double) spinningpoint.Y) / 16, num1 * num10, num2 * num10, num3 * num10); } if ((double) num4 != 0.0 || (double) num5 != 0.0 || (double) num6 != 0.0) { float num11 = 1f; if ((double) num4 == (double) num1 && (double) num5 == (double) num2 && (double) num6 == (double) num3) num11 += 0.5f; if ((double) num4 == (double) num7 && (double) num5 == (double) num8 && (double) num6 == (double) num9) num11 += 0.5f; Vector2 spinningpoint = new Vector2((float) (this.width / 2 + 8), (float) (this.height / 2)); if ((double) this.fullRotation != 0.0) spinningpoint = spinningpoint.RotatedBy((double) this.fullRotation, this.fullRotationOrigin); Lighting.AddLight((int) ((double) this.position.X + (double) spinningpoint.X) / 16, (int) ((double) this.position.Y + (double) spinningpoint.Y) / 16, num4 * num11, num5 * num11, num6 * num11); } if ((double) num7 == 0.0 && (double) num8 == 0.0 && (double) num9 == 0.0) return; float num12 = 1f; if ((double) num7 == (double) num4 && (double) num8 == (double) num5 && (double) num9 == (double) num6) num12 += 0.5f; if ((double) num7 == (double) num1 && (double) num8 == (double) num2 && (double) num9 == (double) num3) num12 += 0.5f; Vector2 spinningpoint1 = new Vector2((float) (this.width / 2 + 8 * this.direction), (float) this.height * 0.75f); if ((double) this.fullRotation != 0.0) spinningpoint1 = spinningpoint1.RotatedBy((double) this.fullRotation, this.fullRotationOrigin); Lighting.AddLight((int) ((double) this.position.X + (double) spinningpoint1.X) / 16, (int) ((double) this.position.Y + (double) spinningpoint1.Y) / 16, num7 * num12, num8 * num12, num9 * num12); } public void Update_NPCCollision() { if (this.creativeGodMode) return; Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle((int) this.position.X, (int) this.position.Y, this.width, this.height); for (int index = 0; index < 200; ++index) { if (Main.npc[index].active && !Main.npc[index].friendly && Main.npc[index].damage > 0) { int specialHitSetter = -1; switch (Main.npc[index].type) { case 396: case 397: case 398: case 400: case 401: specialHitSetter = 1; break; case 636: specialHitSetter = 1; break; } if ((specialHitSetter != -1 || !this.immune) && (this.dash != 2 || index != this.eocHit || this.eocDash <= 0) && !this.npcTypeNoAggro[Main.npc[index].type]) { float damageMultiplier = 1f; NPC npc1 = Main.npc[index]; npc1.position = npc1.position + Main.npc[index].netOffset; Microsoft.Xna.Framework.Rectangle npcRect = new Microsoft.Xna.Framework.Rectangle((int) Main.npc[index].position.X, (int) Main.npc[index].position.Y, Main.npc[index].width, Main.npc[index].height); NPC.GetMeleeCollisionData(rectangle, index, ref specialHitSetter, ref damageMultiplier, ref npcRect); if (rectangle.Intersects(npcRect)) { if (!this.npcTypeNoAggro[Main.npc[index].type]) { bool flag1 = true; bool flag2 = false; int num1 = this.CanParryAgainst(rectangle, npcRect, Main.npc[index].velocity) ? 1 : 0; float num2 = this.thorns; float knockback = 10f; if (this.turtleThorns) num2 = 2f; if (num1 != 0) { num2 = 2f; knockback = 5f; flag1 = false; flag2 = true; } int hitDirection = -1; if ((double) Main.npc[index].position.X + (double) (Main.npc[index].width / 2) < (double) this.position.X + (double) (this.width / 2)) hitDirection = 1; int Damage = Main.DamageVar((float) Main.npc[index].damage * damageMultiplier, -this.luck); int num3 = Item.NPCtoBanner(Main.npc[index].BannerID()); if (num3 > 0 && this.HasNPCBannerBuff(num3)) Damage = !Main.expertMode ? (int) ((double) Damage * (double) ItemID.Sets.BannerStrength[Item.BannerToItem(num3)].NormalDamageReceived) : (int) ((double) Damage * (double) ItemID.Sets.BannerStrength[Item.BannerToItem(num3)].ExpertDamageReceived); if (this.whoAmI == Main.myPlayer && (double) num2 > 0.0 && !this.immune && !Main.npc[index].dontTakeDamage) { int damage = (int) ((double) Damage * (double) num2); if (damage > 1000) damage = 1000; this.ApplyDamageToNPC(Main.npc[index], damage, knockback, -hitDirection, false); } if (this.resistCold && Main.npc[index].coldDamage) Damage = (int) ((double) Damage * 0.699999988079071); if (!this.immune && !flag2) this.StatusFromNPC(Main.npc[index]); if (flag1) this.Hurt(PlayerDeathReason.ByNPC(index), Damage, hitDirection, cooldownCounter: specialHitSetter); if (num1 != 0) { this.GiveImmuneTimeForCollisionAttack(this.longInvince ? 60 : 30); this.AddBuff(198, 300, false); } } else continue; } NPC npc2 = Main.npc[index]; npc2.position = npc2.position - Main.npc[index].netOffset; } } } } public bool CanParryAgainst( Microsoft.Xna.Framework.Rectangle blockingPlayerRect, Microsoft.Xna.Framework.Rectangle enemyRect, Vector2 enemyVelocity) { return this.shieldParryTimeLeft > 0 && Math.Sign(enemyRect.Center.X - blockingPlayerRect.Center.X) == this.direction && enemyVelocity != Vector2.Zero && !this.immune; } private void PurgeDD2EnergyCrystals() { if (this.trashItem.type == 3822) this.trashItem.TurnToAir(); for (int index = 0; index < 58; ++index) { Item obj = this.inventory[index]; if (obj.stack > 0 && obj.type == 3822) obj.TurnToAir(); } if (this.chest == -2) { Chest bank = this.bank; for (int index = 0; index < 40; ++index) { if (bank.item[index].stack > 0 && bank.item[index].type == 3822) bank.item[index].TurnToAir(); } } if (this.chest == -4) { Chest bank3 = this.bank3; for (int index = 0; index < 40; ++index) { if (bank3.item[index].stack > 0 && bank3.item[index].type == 3822) bank3.item[index].TurnToAir(); } } if (this.chest == -5) { Chest bank4 = this.bank4; for (int index = 0; index < 40; ++index) { if (bank4.item[index].stack > 0 && bank4.item[index].type == 3822) bank4.item[index].TurnToAir(); } } if (this.chest == -3) { Chest bank2 = this.bank2; for (int index = 0; index < 40; ++index) { if (bank2.item[index].stack > 0 && bank2.item[index].type == 3822) bank2.item[index].TurnToAir(); } } if (this.chest <= -1) return; Chest chest = Main.chest[this.chest]; for (int index = 0; index < 40; ++index) { if (chest.item[index].stack > 0 && chest.item[index].type == 3822) { chest.item[index].TurnToAir(); if (Main.netMode == 1) NetMessage.SendData(32, number: this.chest, number2: ((float) index)); } } } public void ItemCheck_ManageRightClickFeatures() { bool theGeneralCheck = this.selectedItem != 58 && this.controlUseTile && !this.tileInteractionHappened && this.releaseUseItem && !this.controlUseItem && !this.mouseInterface && !CaptureManager.Instance.Active && !Main.HoveringOverAnNPC && !Main.SmartInteractShowingGenuine; bool flag = theGeneralCheck; if (!ItemID.Sets.ItemsThatAllowRepeatedRightClick[this.inventory[this.selectedItem].type] && !Main.mouseRightRelease) flag = false; if (flag && this.altFunctionUse == 0) { for (int index = 0; index < this._projectilesToInteractWith.Count; ++index) { Projectile projectile = Main.projectile[this._projectilesToInteractWith[index]]; if (projectile.Hitbox.Contains(Main.MouseWorld.ToPoint()) || Main.SmartInteractProj == projectile.whoAmI) { theGeneralCheck = false; flag = false; break; } } } if (flag && this.altFunctionUse == 0 && this.inventory[this.selectedItem].type == 3384) { this.altFunctionUse = 1; this.controlUseItem = true; } if (flag && this.altFunctionUse == 0 && this.inventory[this.selectedItem].type == 3858) { this.altFunctionUse = 1; this.controlUseItem = true; } if (flag && this.altFunctionUse == 0 && this.inventory[this.selectedItem].type == 4673) { this.altFunctionUse = 1; this.controlUseItem = true; } if (flag && this.altFunctionUse == 0 && this.inventory[this.selectedItem].type == 3852 && this.itemAnimation == 0) { this.altFunctionUse = 1; this.controlUseItem = true; } if (flag && this.altFunctionUse == 0 && this.inventory[this.selectedItem].shoot > 0 && ProjectileID.Sets.TurretFeature[this.inventory[this.selectedItem].shoot]) { this.altFunctionUse = 1; this.controlUseItem = true; } if (flag && this.altFunctionUse == 0 && this.inventory[this.selectedItem].shoot > 0 && ProjectileID.Sets.MinionTargettingFeature[this.inventory[this.selectedItem].shoot]) { this.altFunctionUse = 1; this.controlUseItem = true; } if (!this.controlUseItem && this.altFunctionUse == 1) this.altFunctionUse = 0; this.ItemCheck_ManageRightClickFeatures_ShieldRaise(theGeneralCheck); } public void ItemCheck_ManageRightClickFeatures_ShieldRaise(bool theGeneralCheck) { bool flag1 = PlayerInput.Triggers.JustPressed.MouseRight; if (this.whoAmI != Main.myPlayer) { flag1 = this.shieldRaised; theGeneralCheck = this.shieldRaised; } bool shouldGuard = false; bool flag2 = this.inventory[this.selectedItem].type == 3823 || this.inventory[this.selectedItem].type == 4760; if (theGeneralCheck & flag2 && this.hasRaisableShield && !this.mount.Active && this.itemAnimation == 0 | flag1) shouldGuard = true; if (this.shield_parry_cooldown > 0) { --this.shield_parry_cooldown; if (this.shield_parry_cooldown == 0) { SoundEngine.PlaySound(25, this.Center); for (int index1 = 0; index1 < 10; ++index1) { int index2 = Dust.NewDust(this.Center + new Vector2((float) (this.direction * 6 + (this.direction == -1 ? -10 : 0)), -14f), 10, 16, 45, Alpha: ((int) byte.MaxValue), newColor: new Color((int) byte.MaxValue, 100, 0, (int) sbyte.MaxValue), Scale: ((float) Main.rand.Next(10, 16) * 0.1f)); Main.dust[index2].noLight = true; Main.dust[index2].noGravity = true; Main.dust[index2].velocity *= 0.5f; } } } if (this.shieldParryTimeLeft > 0 && ++this.shieldParryTimeLeft > 20) this.shieldParryTimeLeft = 0; this.TryTogglingShield(shouldGuard); } public void TryTogglingShield(bool shouldGuard) { if (shouldGuard == this.shieldRaised) return; this.shieldRaised = shouldGuard; if (this.shieldRaised) { if (this.shield_parry_cooldown == 0) this.shieldParryTimeLeft = 1; this.itemAnimation = 0; this.itemTime = 0; this.reuseDelay = 0; } else { this.shield_parry_cooldown = 15; this.shieldParryTimeLeft = 0; if (this.attackCD >= 20) return; this.attackCD = 20; } } private void HandleHotbar() { int num = PlayerInput.Triggers.Current.HotbarPlus.ToInt() - PlayerInput.Triggers.Current.HotbarMinus.ToInt(); if (PlayerInput.CurrentProfile.HotbarAllowsRadial && num != 0 && PlayerInput.Triggers.Current.HotbarHoldTime > PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired && PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired != -1) { PlayerInput.MiscSettingsTEMP.HotbarRadialShouldBeUsed = true; PlayerInput.Triggers.Current.HotbarScrollCD = 2; } if (PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired != -1) { num = PlayerInput.Triggers.JustReleased.HotbarPlus.ToInt() - PlayerInput.Triggers.JustReleased.HotbarMinus.ToInt(); if (PlayerInput.Triggers.Current.HotbarScrollCD == 1 && num != 0) num = 0; } if (PlayerInput.Triggers.Current.HotbarScrollCD == 0 && num != 0) { this.HotbarOffset += num; PlayerInput.Triggers.Current.HotbarScrollCD = 8; } if (!Main.inFancyUI && !Main.ingameOptionsWindow) this.HotbarOffset += PlayerInput.ScrollWheelDelta / -120; this.ScrollHotbar(this.HotbarOffset); this.HotbarOffset = 0; } private void ItemCheckWrapped(int i) { int num1 = this.controlLeft || this.controlRight || this.controlUp || this.controlDown || !PlayerInput.UsingGamepad || !Main.SmartCursorEnabled ? 0 : ((double) PlayerInput.GamepadThumbstickRight.Length() < 0.0500000007450581 ? 1 : 0); if (num1 != 0) this.ForceForwardCursor(true); int num2 = !PlayerInput.smartSelectPointer.ShouldBeUsed() ? 0 : (!Main.SmartCursorEnabled ? 1 : 0); if (num2 != 0) this.ForceSmartSelectCursor(true); LockOnHelper.SetUP(); int stack1 = this.inventory[this.selectedItem].stack; if (Main.ignoreErrors) this.ItemCheck(i); else this.ItemCheck(i); int stack2 = this.inventory[this.selectedItem].stack; if (stack1 != stack2) Recipe.FindRecipes(); LockOnHelper.SetDOWN(); if (num2 != 0) this.ForceSmartSelectCursor(false); if (num1 != 0) this.ForceForwardCursor(false); if (this.itemAnimation != 0) return; this.lastVisualizedSelectedItem = this.HeldItem.Clone(); } private void ForceForwardCursor(bool state) { if (state == this._forceForwardCursor) return; this._forceForwardCursor = state; if (state) { this._inputMouseCoordsForward = new Point(PlayerInput.MouseX, PlayerInput.MouseY); this._mainMouseCoordsForward = new Point(Main.mouseX, Main.mouseY); Point point = (this.Center - Main.screenPosition + new Vector2((float) (this.direction * 200), 0.0f)).ToPoint(); Main.mouseX = PlayerInput.MouseX = point.X; Main.mouseY = PlayerInput.MouseY = point.Y; } else { PlayerInput.MouseX = this._inputMouseCoordsForward.X; PlayerInput.MouseY = this._inputMouseCoordsForward.Y; Main.mouseX = this._mainMouseCoordsForward.X; Main.mouseY = this._mainMouseCoordsForward.Y; } } private void ForceSmartSelectCursor(bool state) { if (state == this._forceSmartSelectCursor) return; this._forceSmartSelectCursor = state; if (state) { this._inputMouseCoordsSmartSelect = new Point(PlayerInput.MouseX, PlayerInput.MouseY); this._mainMouseCoordsSmartSelect = new Point(Main.mouseX, Main.mouseY); this._tileTargetSmartSelect = new Point(Player.tileTargetX, Player.tileTargetY); Point point = PlayerInput.smartSelectPointer.GetPointerPosition().ToPoint(); Main.mouseX = PlayerInput.MouseX = point.X; Main.mouseY = PlayerInput.MouseY = point.Y; Point tileCoordinates = (point.ToVector2() + Main.screenPosition).ToTileCoordinates(); Player.tileTargetX = tileCoordinates.X; Player.tileTargetY = tileCoordinates.Y; } else { PlayerInput.MouseX = this._inputMouseCoordsSmartSelect.X; PlayerInput.MouseY = this._inputMouseCoordsSmartSelect.Y; Main.mouseX = this._mainMouseCoordsSmartSelect.X; Main.mouseY = this._mainMouseCoordsSmartSelect.Y; Player.tileTargetX = this._tileTargetSmartSelect.X; Player.tileTargetY = this._tileTargetSmartSelect.Y; } } public void ScrollHotbar(int Offset) { Offset = Player.ClampHotbarOffset(Offset); this.selectedItem += Offset; if (Offset != 0) { SoundEngine.PlaySound(12); int num = this.selectedItem - Offset; this.DpadRadial.ChangeSelection(-1); this.CircularRadial.ChangeSelection(-1); this.selectedItem = num + Offset; this.nonTorch = -1; } if (this.changeItem >= 0) { if (this.selectedItem != this.changeItem) SoundEngine.PlaySound(12); this.selectedItem = this.changeItem; this.changeItem = -1; } if (this.itemAnimation != 0 || this.selectedItem == 58) return; while (this.selectedItem > 9) this.selectedItem -= 10; while (this.selectedItem < 0) this.selectedItem += 10; } private static int ClampHotbarOffset(int Offset) { while (Offset > 9) Offset -= 10; while (Offset < 0) Offset += 10; return Offset; } public List GetListOfProjectilesToInteractWithHack() => this._projectilesToInteractWith; public void LockGamepadTileInteractions() { this.releaseUseTile = false; this._lockTileInteractionsTimer = 3; PlayerInput.LockGamepadTileUseButton = true; } public void LookForTileInteractions() { if (Main.mapFullscreen || Main.InGameUI.CurrentState == Main.BestiaryUI) return; int num1 = Player.tileTargetX; int num2 = Player.tileTargetY; if (Main.SmartInteractShowingGenuine && Main.SmartInteractNPC == -1 && Main.SmartInteractProj == -1) { num1 = Main.SmartInteractX; num2 = Main.SmartInteractY; } bool flag = this.controlUseTile; if (PlayerInput.UsingGamepad && Main.HoveringOverAnNPC) flag = false; if (Main.gamePaused) flag = false; if (this.releaseUseTile) this.tileInteractionHappened = false; this.tileInteractAttempted = flag; if (this.tileInteractAttempted && this.releaseUseTile) { if (Main.instance.currentNPCShowingChatBubble > -1 && (this.talkNPC == -1 || !Main.npcChatRelease)) { this.tileInteractAttempted = true; this.releaseUseTile = false; } if (Main.HasInteractibleObjectThatIsNotATile) { this.tileInteractAttempted = true; this.releaseUseTile = false; } } if (this.IsInTileInteractionRange(num1, num2)) { this.TileInteractionsCheckLongDistance(Player.tileTargetX, Player.tileTargetY); this.TileInteractionsCheck(num1, num2); } else this.TileInteractionsCheckLongDistance(num1, num2); this.TryInteractingWithMinecartTrackInNearbyArea(num1, num2); } private void TryInteractingWithMinecartTrackInNearbyArea( int selectedTargetX, int selectedTargetY) { if (this.mount.Active && MountID.Sets.Cart[this.mount.Type] || !this.botherWithUnaimedMinecartTracks || this.tileInteractionHappened || Main.SmartInteractShowingGenuine || Main.SmartInteractNPC != -1 || Main.SmartInteractProj != -1 || !WorldGen.InWorld(selectedTargetX, selectedTargetY, 10) || (double) this.gravDir != 1.0) return; int num = 2; for (int index1 = selectedTargetX - num; index1 <= selectedTargetX + num; ++index1) { for (int index2 = selectedTargetY - num; index2 <= selectedTargetY + num; ++index2) { if (this.IsInTileInteractionRange(index1, index2)) { Tile tile = Main.tile[index1, index2]; if (tile != null) { if (tile.active() && tile.type == (ushort) 314) { if (!this.cursorItemIconEnabled) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 2343; } if (this.tileInteractAttempted) this.TileInteractionsCheck(index1, index2); } if (this.tileInteractionHappened) return; } } } } } public bool InInteractionRange(int interactX, int interactY) { int num1 = (int) (((double) this.position.X + (double) this.width * 0.5) / 16.0); int num2 = (int) (((double) this.position.Y + (double) this.height * 0.5) / 16.0); Tile tile = Main.tile[interactX, interactY]; return tile.type == (ushort) 475 || tile.type == (ushort) 597 ? num1 >= interactX - Player.tileRangeX - 1 && num1 <= interactX + Player.tileRangeX + 2 && num2 >= interactY - Player.tileRangeY - 1 && num2 <= interactY + Player.tileRangeY + 2 : (tile.type == (ushort) 470 ? num1 >= interactX - Player.tileRangeX - 1 && num1 <= interactX + Player.tileRangeX + 1 && num2 >= interactY - Player.tileRangeY - 1 && num2 <= interactY + Player.tileRangeY + 2 : num1 >= interactX - Player.tileRangeX && num1 <= interactX + Player.tileRangeX + 1 && num2 >= interactY - Player.tileRangeY && num2 <= interactY + Player.tileRangeY + 1); } public bool IsInTileInteractionRange(int targetX, int targetY) => (double) this.position.X / 16.0 - (double) Player.tileRangeX <= (double) targetX && ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX - 1.0 >= (double) targetX && (double) this.position.Y / 16.0 - (double) Player.tileRangeY <= (double) targetY && ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY - 2.0 >= (double) targetY; public void TileInteractionsCheck(int myX, int myY) { if (Main.tile[myX, myY] == null) Main.tile[myX, myY] = new Tile(); if (!Main.tile[myX, myY].active()) return; this.TileInteractionsMouseOver(myX, myY); this.TileInteractionsUse(myX, myY); } private void TileInteractionsCheckLongDistance(int myX, int myY) { if (!WorldGen.InWorld(myX, myY, 10) || Main.tile[myX, myY] == null || !Main.tile[myX, myY].active()) return; if (TileID.Sets.BasicChest[(int) Main.tile[myX, myY].type]) { this.TileInteractionsMouseOver_Containers(myX, myY); if (this.cursorItemIconText == "") { this.cursorItemIconEnabled = false; this.cursorItemIconID = 0; } } if (Main.tile[myX, myY].type == (ushort) 88) { Tile tile = Main.tile[myX, myY]; int num1 = myX; int num2 = myY; int num3 = (int) tile.frameX % 54 / 18; int X = num1 - num3; if ((int) tile.frameY % 36 != 0) --num2; int Y = num2; int chest = Chest.FindChest(X, Y); this.cursorItemIconID = -1; if (chest < 0) { this.cursorItemIconText = Lang.dresserType[0].Value; } else { this.cursorItemIconText = !(Main.chest[chest].name != "") ? Lang.dresserType[(int) tile.frameX / 54].Value : Main.chest[chest].name; if (this.cursorItemIconText == Lang.dresserType[(int) tile.frameX / 54].Value) { this.cursorItemIconID = Chest.dresserTypeToIcon[(int) tile.frameX / 54]; this.cursorItemIconText = ""; } } this.noThrow = 2; this.cursorItemIconEnabled = true; if (this.cursorItemIconText == "") { this.cursorItemIconEnabled = false; this.cursorItemIconID = 0; } } if (!Main.tileSign[(int) Main.tile[myX, myY].type]) return; this.noThrow = 2; int num4 = (int) Main.tile[myX, myY].frameX / 18; int num5 = (int) Main.tile[myX, myY].frameY / 18; int num6 = num4 % 2; int i = myX - num6; int j = myY - num5; Main.signBubble = true; Main.signX = i * 16 + 16; Main.signY = j * 16; int num7 = Sign.ReadSign(i, j, false); if (num7 == -1 || Player.tileTargetX < i || Player.tileTargetY < j || Player.tileTargetX > i + 1 || Player.tileTargetY > j + 1) return; Main.signHover = num7; this.cursorItemIconEnabled = false; this.cursorItemIconID = -1; } private void TileInteractionsUse(int myX, int myY) { if (WiresUI.Open || this.ownedProjectileCounts[651] > 0) return; bool releaseUseTile = this.releaseUseTile; if (!this.tileInteractAttempted) return; bool flag1 = false; if (Main.tile[myX, myY].type == (ushort) 212 && this.launcherWait <= 0) { int index1 = myX; int index2 = myY; bool flag2 = false; for (int index3 = 0; index3 < 58; ++index3) { if (this.inventory[index3].type == 949 && this.inventory[index3].stack > 0) { --this.inventory[index3].stack; if (this.inventory[index3].stack <= 0) this.inventory[index3].SetDefaults(); flag2 = true; break; } } if (flag2) { flag1 = true; this.launcherWait = 10; SoundEngine.PlaySound(SoundID.Item11, this.position); int num1 = (int) Main.tile[index1, index2].frameX / 18; int num2 = 0; for (; num1 >= 3; num1 -= 3) ++num2; int num3 = index1 - num1; int num4 = (int) Main.tile[index1, index2].frameY / 18; while (num4 >= 3) num4 -= 3; int num5 = index2 - num4; double num6 = 12.0 + (double) Main.rand.Next(450) * 0.00999999977648258; float num7 = (float) Main.rand.Next(85, 105); double num8 = (double) Main.rand.Next(-35, 11); int Type = 166; int Damage = 35; float KnockBack = 3.5f; Vector2 vector2 = new Vector2((float) ((num3 + 2) * 16 - 8), (float) ((num5 + 2) * 16 - 8)); if (num2 == 0) { num7 *= -1f; vector2.X -= 12f; } else vector2.X += 12f; float num9 = num7; float num10 = (float) num8; double num11 = Math.Sqrt((double) num9 * (double) num9 + (double) num10 * (double) num10); float num12 = (float) (num6 / num11); float SpeedX = num9 * num12; float SpeedY = num10 * num12; int index4 = Projectile.NewProjectile(vector2.X, vector2.Y, SpeedX, SpeedY, Type, Damage, KnockBack, Main.myPlayer); Main.projectile[index4].originatedFromActivableTile = true; } } if (releaseUseTile) { if (Main.tile[myX, myY].type == (ushort) 132 || Main.tile[myX, myY].type == (ushort) 136 || Main.tile[myX, myY].type == (ushort) 144) { flag1 = true; Wiring.HitSwitch(myX, myY); NetMessage.SendData(59, number: myX, number2: ((float) myY)); } else if (Main.tile[myX, myY].type == (ushort) 597) { flag1 = true; this.TryOpeningFullscreenMap(); } else if (Main.tile[myX, myY].type == (ushort) 441 || Main.tile[myX, myY].type == (ushort) 468) { flag1 = true; int num13 = (int) Main.tile[myX, myY].frameX / 18; while (num13 > 1) num13 -= 2; int num14 = myX - num13; int num15 = myY - (int) Main.tile[myX, myY].frameY / 18; Animation.NewTemporaryAnimation(2, Main.tile[myX, myY].type, num14, num15); NetMessage.SendTemporaryAnimation(-1, 2, (int) Main.tile[myX, myY].type, num14, num15); Wiring.HitSwitch(myX, myY); NetMessage.SendData(59, number: myX, number2: ((float) myY)); } else if (Main.tile[myX, myY].type == (ushort) 139) { flag1 = true; SoundEngine.PlaySound(28, myX * 16, myY * 16, 0); WorldGen.SwitchMB(myX, myY); } else if (Main.tile[myX, myY].type == (ushort) 215) { flag1 = true; SoundEngine.PlaySound(28, myX * 16, myY * 16, 0); int num16 = (int) Main.tile[myX, myY].frameX % 54 / 18; int num17 = (int) Main.tile[myX, myY].frameY % 36 / 18; int index5 = myX - num16; int index6 = myY - num17; int num18 = 36; if (Main.tile[index5, index6].frameY >= (short) 36) num18 = -36; for (int index7 = index5; index7 < index5 + 3; ++index7) { for (int index8 = index6; index8 < index6 + 2; ++index8) Main.tile[index7, index8].frameY += (short) num18; } NetMessage.SendTileSquare(-1, index5 + 1, index6 + 1, 3); } else if (Main.tile[myX, myY].type == (ushort) 207) { flag1 = true; SoundEngine.PlaySound(28, myX * 16, myY * 16, 0); WorldGen.SwitchFountain(myX, myY); } else if (Main.tile[myX, myY].type == (ushort) 410 || Main.tile[myX, myY].type == (ushort) 480 || Main.tile[myX, myY].type == (ushort) 509) { flag1 = true; SoundEngine.PlaySound(28, myX * 16, myY * 16, 0); this.GamepadEnableGrappleCooldown(); WorldGen.SwitchMonolith(myX, myY); } else if (Main.tile[myX, myY].type == (ushort) 455) { flag1 = true; SoundEngine.PlaySound(28, myX * 16, myY * 16, 0); this.GamepadEnableGrappleCooldown(); BirthdayParty.ToggleManualParty(); } else if (Main.tile[myX, myY].type == (ushort) 216) { flag1 = true; WorldGen.LaunchRocket(myX, myY); } else if (Main.tile[myX, myY].type == (ushort) 386 || Main.tile[myX, myY].type == (ushort) 387) { flag1 = true; bool flag3 = Main.tile[myX, myY].type == (ushort) 387; int num = WorldGen.ShiftTrapdoor(myX, myY, (double) (myY * 16) > (double) this.Center.Y).ToInt(); if (num == 0) num = -WorldGen.ShiftTrapdoor(myX, myY, (double) (myY * 16) <= (double) this.Center.Y).ToInt(); if (num != 0) NetMessage.SendData(19, number: (2 + flag3.ToInt()), number2: ((float) myX), number3: ((float) myY), number4: ((float) (num * Math.Sign((float) (myY * 16) - this.Center.Y)))); } else if (Main.tile[myX, myY].type == (ushort) 388 || Main.tile[myX, myY].type == (ushort) 389) { flag1 = true; bool closing = Main.tile[myX, myY].type == (ushort) 389; if (WorldGen.ShiftTallGate(myX, myY, closing)) NetMessage.SendData(19, number: (4 + closing.ToInt()), number2: ((float) myX), number3: ((float) myY)); } else if (Main.tile[myX, myY].type == (ushort) 15 || Main.tile[myX, myY].type == (ushort) 497) { if (this.IsWithinSnappngRangeToTile(myX, myY, 40)) { flag1 = true; this.GamepadEnableGrappleCooldown(); this.sitting.SitDown(this, myX, myY); } } else if (Main.tile[myX, myY].type == (ushort) 89 || Main.tile[myX, myY].type == (ushort) 102 || Main.tile[myX, myY].type == (ushort) 487) { if (this.IsWithinSnappngRangeToTile(myX, myY, 40)) { flag1 = true; this.GamepadEnableGrappleCooldown(); this.sitting.SitDown(this, myX, myY); } } else if (Main.tile[myX, myY].type == (ushort) 335) { flag1 = true; WorldGen.LaunchRocketSmall(myX, myY); } else if (Main.tile[myX, myY].type == (ushort) 411 && Main.tile[myX, myY].frameX < (short) 36) { flag1 = true; Wiring.HitSwitch(myX, myY); NetMessage.SendData(59, number: myX, number2: ((float) myY)); } else if (Main.tile[myX, myY].type == (ushort) 494) { flag1 = true; for (int index = 0; index < 1000; ++index) { if (ProjectileID.Sets.IsAGolfBall[Main.projectile[index].type] && Main.projectile[index].owner == this.whoAmI) Main.projectile[index].Kill(); } int projType; this.GetPreferredGolfBallToUse(out projType); Projectile.NewProjectile((float) (myX * 16) + 8.5f, (float) (myY * 16 + 6), 0.0f, 0.0f, projType, 0, 0.0f, this.whoAmI, ai1: -1f); } else if (Main.tile[myX, myY].type == (ushort) 338) { flag1 = true; int index9 = myX; int index10 = myY; if (Main.tile[index9, index10].frameY == (short) 18) --index10; bool flag4 = false; for (int index11 = 0; index11 < 1000; ++index11) { if (Main.projectile[index11].active && Main.projectile[index11].aiStyle == 73 && (double) Main.projectile[index11].ai[0] == (double) index9 && (double) Main.projectile[index11].ai[1] == (double) index10) { flag4 = true; break; } } if (!flag4) { int index12 = Projectile.NewProjectile((float) (index9 * 16 + 8), (float) (index10 * 16 + 2), 0.0f, 0.0f, 419 + Main.rand.Next(4), 0, 0.0f, this.whoAmI, (float) index9, (float) index10); Main.projectile[index12].originatedFromActivableTile = true; } } else if (Main.tile[myX, myY].type == (ushort) 33 || Main.tile[myX, myY].type == (ushort) 49 || Main.tile[myX, myY].type == (ushort) 372 || Main.tile[myX, myY].type == (ushort) 174) { short num = 18; Tile tile = Main.tile[myX, myY]; if (tile.frameX > (short) 0) num = (short) -18; tile.frameX += num; NetMessage.SendTileSquare(-1, myX, myY, 1); flag1 = true; this.GamepadEnableGrappleCooldown(); } else if (Main.tile[myX, myY].type == (ushort) 4 || Main.tile[myX, myY].type == (ushort) 13 || Main.tile[myX, myY].type == (ushort) 50 && Main.tile[myX, myY].frameX == (short) 90) { WorldGen.KillTile(myX, myY); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) myX), number3: ((float) myY)); flag1 = true; this.GamepadEnableGrappleCooldown(); } else if (Main.tile[myX, myY].type == (ushort) 466) { flag1 = true; this.GamepadEnableGrappleCooldown(); int y = myY; Tile tileSafely = Framing.GetTileSafely(myX, myY); if (tileSafely.frameY == (short) 0) y += 3; if (tileSafely.frameY == (short) 18) y += 2; if (tileSafely.frameY == (short) 36) ++y; bool flag5 = !DD2Event.Ongoing && !NPC.AnyNPCs(548) && !Main.pumpkinMoon && !Main.snowMoon; if (flag5) flag5 = this.HasItem(3828); if (flag5) { flag5 = !DD2Event.WouldFailSpawningHere(myX, y); if (!flag5) DD2Event.FailureMessage(-1); } if (flag5) flag5 = this.ConsumeItem(3828, true); if (flag5) DD2Event.SummonCrystal(myX, y); } else if (Main.tile[myX, myY].type == (ushort) 334) { flag1 = true; if (this.ItemFitsWeaponRack(this.inventory[this.selectedItem])) { this.GamepadEnableGrappleCooldown(); this.PlaceWeapon(myX, myY); } else { int num19 = myX; int j = myY; if (Main.tile[myX, myY].frameY == (short) 0) ++j; if (Main.tile[myX, myY].frameY == (short) 36) --j; int frameX = (int) Main.tile[myX, j].frameX; int num20 = (int) Main.tile[myX, j].frameX; int num21 = 0; while (num20 >= 5000) { num20 -= 5000; ++num21; } if (num21 != 0) num20 = (num21 - 1) * 18; int num22 = num20 % 54; if (num22 == 18) { frameX = (int) Main.tile[myX - 1, j].frameX; --num19; } if (num22 == 36) { frameX = (int) Main.tile[myX - 2, j].frameX; int num23 = num19 - 2; } if (frameX >= 5000) { this.GamepadEnableGrappleCooldown(); WorldGen.KillTile(myX, j, true); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) myX), number3: ((float) j), number4: 1f); } } } else if (Main.tile[myX, myY].type == (ushort) 440) { flag1 = true; int index = myX; int j = myY; int num24 = (int) Main.tile[index, j].frameX / 54; int num25 = (int) Main.tile[index, j].frameY / 54; int num26 = (int) Main.tile[index, j].frameX % 54 / 18; int num27 = (int) Main.tile[index, j].frameY % 54 / 18; int type = -1; switch (num24) { case 0: type = 1526; break; case 1: type = 1524; break; case 2: type = 1525; break; case 3: type = 1523; break; case 4: type = 1522; break; case 5: type = 1527; break; case 6: type = 3643; break; } if (type != -1) { if (num25 == 0 && this.HasItem(type) && this.selectedItem != 58) { this.GamepadEnableGrappleCooldown(); if (Main.netMode != 1) { this.ConsumeItem(type); WorldGen.ToggleGemLock(index, j, true); } else { this.ConsumeItem(type); NetMessage.SendData(105, number: index, number2: ((float) j), number3: 1f); } } else if (num25 == 1) { this.GamepadEnableGrappleCooldown(); if (Main.netMode != 1) WorldGen.ToggleGemLock(index, j, false); else NetMessage.SendData(105, number: index, number2: ((float) j)); } } } else if (Main.tile[myX, myY].type == (ushort) 395) { flag1 = true; TEItemFrame.OnPlayerInteraction(this, myX, myY); } else if (Main.tile[myX, myY].type == (ushort) 520) { flag1 = true; TEFoodPlatter.OnPlayerInteraction(this, myX, myY); } else if (Main.tile[myX, myY].type == (ushort) 471) { flag1 = true; TEWeaponsRack.OnPlayerInteraction(this, myX, myY); } else if (Main.tile[myX, myY].type == (ushort) 470) { flag1 = true; TEDisplayDoll.OnPlayerInteraction(this, myX, myY); } else if (Main.tile[myX, myY].type == (ushort) 475) { flag1 = true; TEHatRack.OnPlayerInteraction(this, myX, myY); } else if (Main.tile[myX, myY].type == (ushort) 125) { flag1 = true; this.AddBuff(29, 36000); SoundEngine.PlaySound(SoundID.Item4, this.position); } else if (Main.tile[myX, myY].type == (ushort) 621) { flag1 = true; this.AddBuff(192, 7200); SoundEngine.PlaySound(SoundID.Item2, this.position); } else if (Main.tile[myX, myY].type == (ushort) 377) { flag1 = true; this.AddBuff(159, 36000); SoundEngine.PlaySound(SoundID.Item37, this.position); } else if (Main.tile[myX, myY].type == (ushort) 354) { flag1 = true; this.AddBuff(150, 36000); SoundEngine.PlaySound(SoundID.Item4, this.position); } else if (Main.tile[myX, myY].type == (ushort) 287) { flag1 = true; this.AddBuff(93, 36000); SoundEngine.PlaySound(SoundID.Item149, this.position); } else if (Main.tile[myX, myY].type == (ushort) 356) { flag1 = true; if (!Main.fastForwardTime && (Main.netMode == 1 || Main.sundialCooldown == 0)) { Main.Sundialing(); SoundEngine.PlaySound(SoundID.Item4, this.position); } } else if (Main.tile[myX, myY].type == (ushort) 79) { flag1 = true; int num28 = myX; int num29 = myY; int num30 = num28 + (int) Main.tile[myX, myY].frameX / 18 * -1; int x = Main.tile[myX, myY].frameX < (short) 72 ? num30 + 2 : num30 + 4 + 1; int num31 = (int) Main.tile[myX, myY].frameY / 18; int num32 = 0; while (num31 > 1) { num31 -= 2; ++num32; } int y = num29 - num31 + 2; if (!Player.IsHoveringOverABottomSideOfABed(myX, myY)) { if (this.IsWithinSnappngRangeToTile(myX, myY, 96)) { flag1 = true; this.GamepadEnableGrappleCooldown(); this.sleeping.StartSleeping(this, myX, myY); } } else { this.FindSpawn(); if (this.SpawnX == x && this.SpawnY == y) { this.RemoveSpawn(); Main.NewText(Language.GetTextValue("Game.SpawnPointRemoved"), G: (byte) 240, B: (byte) 20); } else if (Player.CheckSpawn(x, y)) { this.ChangeSpawn(x, y); Main.NewText(Language.GetTextValue("Game.SpawnPointSet"), G: (byte) 240, B: (byte) 20); } } } else if (Main.tileSign[(int) Main.tile[myX, myY].type]) { flag1 = true; bool flag6 = true; if (this.sign >= 0 && Sign.ReadSign(myX, myY, false) == this.sign) { this.sign = -1; Main.npcChatText = ""; Main.editSign = false; SoundEngine.PlaySound(11); flag6 = false; } if (flag6) { if (Main.netMode == 0) { this.SetTalkNPC(-1); Main.npcChatCornerItem = 0; Main.playerInventory = false; Main.editSign = false; int index = Sign.ReadSign(myX, myY); if (index < 0) return; SoundEngine.PlaySound(10); this.sign = index; Main.npcChatText = Main.sign[index].text; } else { int num33 = (int) Main.tile[myX, myY].frameX / 18; int num34 = (int) Main.tile[myX, myY].frameY / 18; while (num33 > 1) num33 -= 2; int number = myX - num33; int index = myY - num34; if (Main.tileSign[(int) Main.tile[number, index].type]) NetMessage.SendData(46, number: number, number2: ((float) index)); } } } else if (Main.tile[myX, myY].type == (ushort) 104) { flag1 = true; string textValue = Language.GetTextValue("GameUI.TimeAtMorning"); double time = Main.time; if (!Main.dayTime) time += 54000.0; double num35 = time / 86400.0 * 24.0 - 7.5 - 12.0; if (num35 < 0.0) num35 += 24.0; if (num35 >= 12.0) textValue = Language.GetTextValue("GameUI.TimePastMorning"); int num36 = (int) num35; double num37 = (double) (int) ((num35 - (double) num36) * 60.0); string str = string.Concat((object) num37); if (num37 < 10.0) str = "0" + str; if (num36 > 12) num36 -= 12; if (num36 == 0) num36 = 12; Main.NewText(Language.GetTextValue("Game.Time", (object) (num36.ToString() + ":" + str + " " + textValue)), G: (byte) 240, B: (byte) 20); } else if (Main.tile[myX, myY].type == (ushort) 237) { flag1 = true; bool flag7 = false; if (!NPC.AnyNPCs(245) && Main.hardMode && NPC.downedPlantBoss) { for (int index = 0; index < 58; ++index) { if (this.inventory[index].type == 1293) { --this.inventory[index].stack; if (this.inventory[index].stack <= 0) this.inventory[index].SetDefaults(); flag7 = true; break; } } } if (flag7) { SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) NPC.SpawnOnPlayer(this.whoAmI, 245); else NetMessage.SendData(61, number: this.whoAmI, number2: 245f); } } else if (Main.tile[myX, myY].type == (ushort) 10) { flag1 = true; int num38 = myX; int num39 = myY; if (WorldGen.IsLockedDoor(num38, num39)) { int num40 = 1141; for (int index = 0; index < 58; ++index) { if (this.inventory[index].type == num40 && this.inventory[index].stack > 0) { --this.inventory[index].stack; if (this.inventory[index].stack <= 0) this.inventory[index] = new Item(); WorldGen.UnlockDoor(num38, num39); if (Main.netMode == 1) NetMessage.SendData(52, number: this.whoAmI, number2: 2f, number3: ((float) num38), number4: ((float) num39)); } } } else { WorldGen.OpenDoor(myX, myY, this.direction); if (Main.tile[myX, myY].type != (ushort) 10) { NetMessage.SendData(19, number2: ((float) myX), number3: ((float) myY), number4: ((float) this.direction)); } else { WorldGen.OpenDoor(myX, myY, -this.direction); if (Main.tile[myX, myY].type != (ushort) 10) NetMessage.SendData(19, number2: ((float) myX), number3: ((float) myY), number4: ((float) -this.direction)); } } } else if (Main.tile[myX, myY].type == (ushort) 11) { flag1 = true; if (WorldGen.CloseDoor(myX, myY)) NetMessage.SendData(19, number: 1, number2: ((float) myX), number3: ((float) myY), number4: ((float) this.direction)); } else if (Main.tile[myX, myY].type == (ushort) 88) { flag1 = true; int num41 = (int) Main.tile[myX, myY].frameX / 18 % 3; int num42 = myX - num41; int num43 = myY - (int) Main.tile[myX, myY].frameY / 18; if (Main.tile[myX, myY].frameY == (short) 0) { Main.CancelClothesWindow(true); Main.mouseRightRelease = false; this.CloseSign(); this.SetTalkNPC(-1); Main.npcChatCornerItem = 0; Main.npcChatText = ""; if (Main.editChest) { SoundEngine.PlaySound(12); Main.editChest = false; Main.npcChatText = string.Empty; } if (this.editedChestName) { NetMessage.SendData(33, text: NetworkText.FromLiteral(Main.chest[this.chest].name), number: this.chest, number2: 1f); this.editedChestName = false; } if (Main.netMode == 1) { if (num42 == this.chestX && num43 == this.chestY && this.chest != -1) { this.chest = -1; Recipe.FindRecipes(); SoundEngine.PlaySound(11); } else { NetMessage.SendData(31, number: num42, number2: ((float) num43)); Main.stackSplit = 600; } } else { this.flyingPigChest = -1; this.voidLensChest = -1; int chest = Chest.FindChest(num42, num43); if (chest != -1) { Main.stackSplit = 600; if (chest == this.chest) { this.chest = -1; Recipe.FindRecipes(); SoundEngine.PlaySound(11); } else if (chest != this.chest && this.chest == -1) { this.OpenChest(num42, num43, chest); SoundEngine.PlaySound(10); } else { this.OpenChest(num42, num43, chest); SoundEngine.PlaySound(12); } Recipe.FindRecipes(); } } } else { Main.playerInventory = false; this.chest = -1; Recipe.FindRecipes(); this.SetTalkNPC(-1); Main.npcChatCornerItem = 0; Main.npcChatText = ""; Main.interactedDresserTopLeftX = num42; Main.interactedDresserTopLeftY = num43; Main.OpenClothesWindow(); } } else if (Main.tile[myX, myY].type == (ushort) 209) { flag1 = true; Tile tile = Main.tile[myX, myY]; int num44 = (int) tile.frameX % 72 / 18; int num45 = (int) tile.frameY % 54 / 18; int x = myX - num44; int y = myY - num45; int angle = (int) tile.frameY / 54; int num46 = (int) tile.frameX / 72; int num47 = -1; if (num44 == 1 || num44 == 2) num47 = num45; int num48 = 0; if (num44 == 3 || num44 == 2 && num46 != 3 && num46 != 4) num48 = -54; if (num44 == 0 || num44 == 1 && num46 != 3 && num46 != 4) num48 = 54; if (angle >= 8 && num48 > 0) num48 = 0; if (angle == 0 && num48 < 0) num48 = 0; bool flag8 = false; if (num48 != 0) { for (int index13 = x; index13 < x + 4; ++index13) { for (int index14 = y; index14 < y + 3; ++index14) Main.tile[index13, index14].frameY += (short) num48; } flag8 = true; } if ((num46 == 3 || num46 == 4) && (num47 == 1 || num47 == 0)) { int num49 = num46 == 3 ? 72 : -72; for (int index15 = x; index15 < x + 4; ++index15) { for (int index16 = y; index16 < y + 3; ++index16) Main.tile[index15, index16].frameX += (short) num49; } flag8 = true; } if (flag8) NetMessage.SendTileSquare(-1, x + 1, y + 1, 4); if (num47 != -1) { bool flag9 = false; if ((num46 == 3 || num46 == 4) && num47 == 2) flag9 = true; if (flag9) WorldGen.ShootFromCannon(x, y, angle, num46 + 1, 0, 0.0f, this.whoAmI); } } else if (Main.tile[myX, myY].type == (ushort) 510 || Main.tile[myX, myY].type == (ushort) 511) { flag1 = true; Tile tile = Main.tile[myX, myY]; int num50 = (int) tile.frameX % 36 / 18; int num51 = (int) tile.frameY % 36 / 18; int tileX = myX - num50; int tileY = myY - num51; int num52 = (int) tile.frameY / 36; int num53 = (int) tile.frameX / 36; int num54 = 0; if (num50 == 0) num54 = -36; if (num50 == 1) num54 = 36; if (num52 >= 7 && num54 > 0) num54 = -252; if (num52 == 0 && num54 < 0) num54 = 252; bool flag10 = false; if (num54 != 0) { for (int index17 = tileX; index17 < tileX + 2; ++index17) { for (int index18 = tileY; index18 < tileY + 2; ++index18) Main.tile[index17, index18].frameY += (short) num54; } flag10 = true; } if (flag10) NetMessage.SendTileSquare(-1, tileX, tileY, 3); } else if (TileID.Sets.BasicChest[(int) Main.tile[myX, myY].type] || Main.tile[myX, myY].type == (ushort) 29 || Main.tile[myX, myY].type == (ushort) 97 || Main.tile[myX, myY].type == (ushort) 463 || Main.tile[myX, myY].type == (ushort) 491) { flag1 = true; Main.mouseRightRelease = false; int num55 = 0; int num56 = (int) Main.tile[myX, myY].frameX / 18; while (num56 > 1) num56 -= 2; int index19 = myX - num56; int index20 = myY - (int) Main.tile[myX, myY].frameY / 18; if (Main.tile[myX, myY].type == (ushort) 29) num55 = 1; else if (Main.tile[myX, myY].type == (ushort) 97) num55 = 2; else if (Main.tile[myX, myY].type == (ushort) 463) { num55 = 3; if (Main.tile[myX, myY].frameX == (short) 36) --index19; else ++index19; index20 += 2; } else if (Main.tile[myX, myY].type == (ushort) 491) { num55 = 4; if (Main.tile[myX, myY].frameX == (short) 36) --index19; else ++index19; index20 += 2; } this.CloseSign(); this.SetTalkNPC(-1); Main.npcChatCornerItem = 0; Main.npcChatText = ""; if (Main.editChest) { SoundEngine.PlaySound(12); Main.editChest = false; Main.npcChatText = string.Empty; } if (this.editedChestName) { NetMessage.SendData(33, text: NetworkText.FromLiteral(Main.chest[this.chest].name), number: this.chest, number2: 1f); this.editedChestName = false; } bool flag11 = Chest.IsLocked(Main.tile[index19, index20]); if (Main.netMode == 1 && num55 == 0 && !flag11) { if (index19 == this.chestX && index20 == this.chestY && this.chest != -1) { this.chest = -1; Recipe.FindRecipes(); SoundEngine.PlaySound(11); } else { NetMessage.SendData(31, number: index19, number2: ((float) index20)); Main.stackSplit = 600; } } else { int newChest = -1; switch (num55) { case 1: newChest = -2; break; case 2: newChest = -3; break; case 3: newChest = -4; break; case 4: newChest = -5; break; default: bool flag12 = false; if (Chest.IsLocked(index19, index20)) { int type = (int) Main.tile[index19, index20].type; int num57 = 327; switch (type) { case 21: if (Main.tile[index19, index20].frameX >= (short) 144 && Main.tile[index19, index20].frameX <= (short) 178) num57 = 329; if (Main.tile[index19, index20].frameX >= (short) 828 && Main.tile[index19, index20].frameX <= (short) 1006) { int num58 = (int) Main.tile[index19, index20].frameX / 18; int num59 = 0; while (num58 >= 2) { num58 -= 2; ++num59; } num57 = 1533 + (num59 - 23); break; } break; case 467: if ((int) Main.tile[index19, index20].frameX / 36 == 13) { num57 = 4714; break; } break; } flag12 = true; for (int index21 = 0; index21 < 58; ++index21) { if (this.inventory[index21].type == num57 && this.inventory[index21].stack > 0 && Chest.Unlock(index19, index20)) { if (num57 != 329) { --this.inventory[index21].stack; if (this.inventory[index21].stack <= 0) this.inventory[index21] = new Item(); } if (Main.netMode == 1) NetMessage.SendData(52, number: this.whoAmI, number2: 1f, number3: ((float) index19), number4: ((float) index20)); } } } if (!flag12) { newChest = Chest.FindChest(index19, index20); break; } break; } if (newChest != -1) { Main.stackSplit = 600; int num60 = WorldGen.IsChestRigged(index19, index20) ? 1 : 0; if (newChest == this.chest) { this.chest = -1; SoundEngine.PlaySound(11); } else if (newChest != this.chest && this.chest == -1) { this.OpenChest(index19, index20, newChest); SoundEngine.PlaySound(10); if (Main.tile[index19, index20].frameX >= (short) 36 && Main.tile[index19, index20].frameX < (short) 72) AchievementsHelper.HandleSpecialEvent(this, 16); } else { this.OpenChest(index19, index20, newChest); SoundEngine.PlaySound(12); } if (num60 != 0) { Wiring.HitSwitch(myX, myY); NetMessage.SendData(59, number: myX, number2: ((float) myY)); } Recipe.FindRecipes(); } } } else if (Main.tile[myX, myY].type == (ushort) 314 && (double) this.gravDir == 1.0) { flag1 = true; bool flag13 = true; if (this.mount.Active) { if (this.mount.Cart) flag13 = false; else this.mount.Dismount(this); } if (flag13) this.LaunchMinecartHook(myX, myY); } } if (!flag1) return; this.tileInteractionHappened = true; } private static bool IsHoveringOverABottomSideOfABed(int myX, int myY) { int frameX = (int) Main.tile[myX, myY].frameX; bool flag1 = frameX / 72 == 1; bool flag2 = frameX % 72 < 36; if (flag1) flag2 = !flag2; return flag2; } public void PetAnimal(int animalNpcIndex) { int targetDirection; Vector2 playerPositionWhenPetting; bool isPetSmall; this.GetPettingInfo(animalNpcIndex, out targetDirection, out playerPositionWhenPetting, out isPetSmall); Vector2 vector2 = playerPositionWhenPetting.Floor(); bool flag = this.CanSnapToPosition(vector2 - this.Bottom); if (flag && !WorldGen.SolidTileAllowBottomSlope((int) vector2.X / 16, (int) vector2.Y / 16)) flag = false; if (!flag) return; if (this.isPettingAnimal && this.Bottom == vector2) { this.StopPettingAnimal(); } else { this.StopVanityActions(); this.RemoveAllGrapplingHooks(); if (this.mount.Active) this.mount.Dismount(this); this.Bottom = vector2; this.ChangeDir(targetDirection); this.isPettingAnimal = true; this.isTheAnimalBeingPetSmall = isPetSmall; this.velocity = Vector2.Zero; this.gravDir = 1f; } } private void GetPettingInfo( int animalNpcIndex, out int targetDirection, out Vector2 playerPositionWhenPetting, out bool isPetSmall) { NPC npc = Main.npc[animalNpcIndex]; targetDirection = (double) npc.Center.X > (double) this.Center.X ? 1 : -1; isPetSmall = npc.type == 637 || npc.type == 656; int num = 36; switch (npc.type) { case 637: num = 28; break; case 656: num = 24; break; } playerPositionWhenPetting = npc.Bottom + new Vector2((float) (-targetDirection * num), 0.0f); } public bool CanSnapToPosition(Vector2 offset) { if (Collision.SolidCollision(this.position + offset, this.width, this.height)) return false; bool canSnapToPosition = Collision.CanHit(this.position, this.width, this.height, this.position + offset, this.width, this.height); if (!canSnapToPosition) { this.TryAllowingSnappingToPosition(ref canSnapToPosition, this.position, this.position + offset); if (!canSnapToPosition) { int num = Math.Sign(offset.X); if (num != 0) { Vector2 Velocity = new Vector2((float) (num * this.width), 0.0f); if (Collision.TileCollision(this.position, Velocity, this.width, this.height, true, true, (int) this.gravDir) == Velocity) this.TryAllowingSnappingToPosition(ref canSnapToPosition, this.position + Velocity, this.position + offset); } } } return canSnapToPosition; } private void TryAllowingSnappingToPosition( ref bool canSnapToPosition, Vector2 pos1, Vector2 pos2) { Vector2 vector2 = new Vector2((float) (this.width - 2), 0.0f); canSnapToPosition = Collision.CanHit(pos1 + vector2, 2, this.height, pos2, 2, this.height); if (!canSnapToPosition) canSnapToPosition = Collision.CanHit(pos1 + vector2, 2, this.height, pos2 + vector2, 2, this.height); if (!canSnapToPosition) canSnapToPosition = Collision.CanHit(pos1, 2, this.height, pos2, 2, this.height); if (canSnapToPosition) return; canSnapToPosition = Collision.CanHit(pos1, 2, this.height, pos2 + vector2, 2, this.height); } public void StopVanityActions(bool multiplayerBroadcast = true) { this.StopPettingAnimal(); this.sitting.SitUp(this, multiplayerBroadcast); this.sleeping.StopSleeping(this, multiplayerBroadcast); } private void StopPettingAnimal() { this.isPettingAnimal = false; this.isTheAnimalBeingPetSmall = false; } private void UpdatePettingAnimal() { if (!this.isPettingAnimal) return; if (this.talkNPC == -1) { this.StopPettingAnimal(); } else { int num = Math.Sign(Main.npc[this.talkNPC].Center.X - this.Center.X); if (this.controlLeft || this.controlRight || this.controlUp || this.controlDown || this.controlJump || this.pulley || this.mount.Active || num != this.direction) { this.StopPettingAnimal(); } else { Vector2 playerPositionWhenPetting; this.GetPettingInfo(this.talkNPC, out int _, out playerPositionWhenPetting, out bool _); if ((double) this.Bottom.Distance(playerPositionWhenPetting) <= 2.0) return; this.StopPettingAnimal(); } } } private void OpenChest(int x, int y, int newChest) { if (this.chest != -1 && Main.myPlayer == this.whoAmI) { for (int index = 0; index < 40; ++index) ItemSlot.SetGlow(index, -1f, true); } this.chest = newChest; Main.playerInventory = true; UILinkPointNavigator.ForceMovementCooldown(120); if (PlayerInput.GrappleAndInteractAreShared) PlayerInput.Triggers.JustPressed.Grapple = false; Main.recBigList = false; this.chestX = x; this.chestY = y; } public void CloseSign() { if (this.sign <= -1) return; SoundEngine.PlaySound(11); this.sign = -1; Main.editSign = false; Main.npcChatText = string.Empty; } private void LaunchMinecartHook(int myX, int myY) { Vector2 vector2 = new Vector2((float) Main.mouseX + Main.screenPosition.X, (float) Main.mouseY + Main.screenPosition.Y); vector2 = new Vector2((float) (myX * 16 + 8), (float) (myY * 16 + 8)); this.minecartLeft = this.direction <= 0; this.RemoveAllGrapplingHooks(); Projectile.NewProjectile(vector2.X, vector2.Y, 0.0f, 0.0f, 403, 0, 0.0f, this.whoAmI); this.releaseHook = false; } public void RemoveAllGrapplingHooks() { this.ClearGrapplingBlacklist(); this.grappling[0] = -1; this.grapCount = 0; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI && Main.projectile[index].aiStyle == 7) Main.projectile[index].Kill(); } } public void RemoveAllFishingBobbers() { for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI && Main.projectile[index].bobber) Main.projectile[index].Kill(); } } private void TileInteractionsMouseOver(int myX, int myY) { if ((myX != Player.tileTargetX ? 0 : (myY == Player.tileTargetY ? 1 : 0)) == 0) return; if (Main.tile[myX, myY].type == (ushort) 79) { if (!Player.IsHoveringOverABottomSideOfABed(myX, myY)) { if (this.IsWithinSnappngRangeToTile(myX, myY, 96)) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 5013; } } else { this.noThrow = 2; this.cursorItemIconEnabled = true; int num = (int) Main.tile[myX, myY].frameY / 36; this.cursorItemIconID = num != 0 ? (num != 1 ? (num != 2 ? (num != 3 ? (num != 4 ? (num != 5 ? (num != 6 ? (num != 7 ? (num != 8 ? (num != 9 ? (num != 10 ? (num != 11 ? (num != 12 ? (num < 13 || num > 18 ? (num < 19 || num > 20 ? (num != 21 ? (num != 22 ? (num != 23 ? (num != 24 ? (num != 25 ? (num != 26 ? (num != 27 ? (num != 28 ? (num != 29 ? (num != 30 ? (num != 31 ? (num != 32 ? (num != 33 ? (num != 34 ? (num != 35 ? (num != 36 ? (num != 37 ? (num != 38 ? (num != 39 ? 646 : 4567) : 4299) : 4209) : 4188) : 4167) : 4146) : 3959) : 3932) : 3897) : 3163) : 3164) : 3162) : 2811) : 2669) : 2568) : 2553) : 2538) : 2520) : 2231) : 2139 + num - 19) : 2066 + num - 13) : 1722) : 1721) : 1720) : 1719) : 1473) : 1472) : 1471) : 1470) : 920) : 646) : 645) : 644) : 224; } } if (Main.tile[myX, myY].type == (ushort) 597) { int pylonStyleFromTile = TETeleportationPylon.GetPylonStyleFromTile(Main.tile[myX, myY]); int typeFromTileStyle = TETeleportationPylon.GetPylonItemTypeFromTileStyle(pylonStyleFromTile); this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = typeFromTileStyle; if (pylonStyleFromTile == 1) this.cursorItemIconID = 4875; if (pylonStyleFromTile == 2) this.cursorItemIconID = 4916; if (pylonStyleFromTile == 3) this.cursorItemIconID = 4917; if (pylonStyleFromTile == 4) this.cursorItemIconID = 4918; if (pylonStyleFromTile == 5) this.cursorItemIconID = 4919; if (pylonStyleFromTile == 6) this.cursorItemIconID = 4920; if (pylonStyleFromTile == 7) this.cursorItemIconID = 4921; if (pylonStyleFromTile == 8) this.cursorItemIconID = 4951; } if (Main.tile[myX, myY].type == (ushort) 621) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 3750; } if (Main.tile[myX, myY].type == (ushort) 33) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 105; int num = (int) Main.tile[myX, myY].frameY / 22; if (num == 1) this.cursorItemIconID = 1405; if (num == 2) this.cursorItemIconID = 1406; if (num == 3) this.cursorItemIconID = 1407; if (num >= 4 && num <= 13) this.cursorItemIconID = 2045 + num - 4; if (num >= 14 && num <= 16) this.cursorItemIconID = 2153 + num - 14; if (num == 17) this.cursorItemIconID = 2236; if (num == 18) this.cursorItemIconID = 2523; if (num == 19) this.cursorItemIconID = 2542; if (num == 20) this.cursorItemIconID = 2556; if (num == 21) this.cursorItemIconID = 2571; if (num == 22) this.cursorItemIconID = 2648; if (num == 23) this.cursorItemIconID = 2649; if (num == 24) this.cursorItemIconID = 2650; if (num == 25) this.cursorItemIconID = 2651; else if (num == 26) this.cursorItemIconID = 2818; else if (num == 27) this.cursorItemIconID = 3171; else if (num == 28) this.cursorItemIconID = 3173; else if (num == 29) this.cursorItemIconID = 3172; else if (num == 30) this.cursorItemIconID = 3890; else if (num == 31) this.cursorItemIconID = 3936; else if (num == 32) this.cursorItemIconID = 3962; else if (num == 33) this.cursorItemIconID = 4150; else if (num == 34) this.cursorItemIconID = 4171; else if (num == 35) this.cursorItemIconID = 4192; else if (num == 36) this.cursorItemIconID = 4213; else if (num == 37) this.cursorItemIconID = 4303; else if (num == 38) this.cursorItemIconID = 4571; } if (Main.tile[myX, myY].type == (ushort) 21) this.TileInteractionsMouseOver_Containers(myX, myY); if (Main.tile[myX, myY].type == (ushort) 467) this.TileInteractionsMouseOver_Containers(myX, myY); if (Main.tile[myX, myY].type == (ushort) 441) { Tile tile = Main.tile[myX, myY]; int num1 = myX; int num2 = myY; if ((int) tile.frameX % 36 != 0) { int num3 = num1 - 1; } if ((int) tile.frameY % 36 != 0) { int num4 = num2 - 1; } this.cursorItemIconID = -1; this.cursorItemIconID = Chest.chestTypeToIcon[(int) tile.frameX / 36]; this.noThrow = 2; this.cursorItemIconEnabled = true; } if (Main.tile[myX, myY].type == (ushort) 468) { Tile tile = Main.tile[myX, myY]; int num5 = myX; int num6 = myY; if ((int) tile.frameX % 36 != 0) { int num7 = num5 - 1; } if ((int) tile.frameY % 36 != 0) { int num8 = num6 - 1; } this.cursorItemIconID = -1; this.cursorItemIconID = Chest.chestTypeToIcon2[(int) tile.frameX / 36]; this.noThrow = 2; this.cursorItemIconEnabled = true; } if (Main.tile[myX, myY].type == (ushort) 88) { Tile tile = Main.tile[myX, myY]; int num9 = myX; int num10 = myY; int num11 = (int) tile.frameX % 54 / 18; int X = num9 - num11; if ((int) tile.frameY % 36 != 0) --num10; int Y = num10; int chest = Chest.FindChest(X, Y); this.cursorItemIconID = -1; if (chest < 0) { this.cursorItemIconText = Lang.dresserType[0].Value; } else { this.cursorItemIconText = !(Main.chest[chest].name != "") ? Lang.dresserType[(int) tile.frameX / 54].Value : Main.chest[chest].name; if (this.cursorItemIconText == Lang.dresserType[(int) tile.frameX / 54].Value) { this.cursorItemIconID = Chest.dresserTypeToIcon[(int) tile.frameX / 54]; this.cursorItemIconText = ""; } } this.noThrow = 2; this.cursorItemIconEnabled = true; if (Main.tile[myX, myY].frameY > (short) 0) { this.cursorItemIconID = 269; this.cursorItemIconText = ""; } } if (Main.tile[myX, myY].type == (ushort) 10 || Main.tile[myX, myY].type == (ushort) 11) { Tile tile = Main.tile[myX, myY]; this.noThrow = 2; this.cursorItemIconEnabled = true; int frameY = (int) tile.frameY; int num = 0; while (frameY >= 54) { frameY -= 54; ++num; } if (tile.type == (ushort) 10) num += 36 * ((int) tile.frameX / 54); if (tile.type == (ushort) 11) num += 36 * ((int) tile.frameX / 72); this.cursorItemIconID = num != 0 ? (num != 9 ? (num != 10 ? (num != 11 ? (num != 12 ? (num != 13 ? (num != 14 ? (num != 15 ? (num != 16 ? (num != 17 ? (num != 18 ? (num != 19 ? (num < 20 || num > 23 ? (num != 24 ? (num != 25 ? (num != 26 ? (num != 27 ? (num != 28 ? (num != 29 ? (num != 30 ? (num != 31 ? (num != 32 ? (num != 33 ? (num != 34 ? (num != 35 ? (num != 36 ? (num != 37 ? (num != 38 ? (num != 39 ? (num != 40 ? (num != 41 ? (num != 42 ? (num != 43 ? (num != 44 ? (num != 45 ? (num < 4 || num > 8 ? 649 + num : 812 + num) : 4576) : 4415) : 4307) : 4218) : 4197) : 4176) : 4155) : 3967) : 3941) : 3888) : 3130) : 3131) : 3129) : 2815) : 2576) : 2561) : 2528) : 2265) : 2044) : 1924) : 1815) : 1793) : 1709 + num - 20) : 1458) : 1413) : 1412) : 1411) : 1140) : 1139) : 1138) : 1137) : 1141) : 912) : 837) : 25; } if (Main.tile[myX, myY].type == (ushort) 104) { this.noThrow = 2; this.cursorItemIconEnabled = true; switch ((int) Main.tile[myX, myY].frameX / 36) { case 0: this.cursorItemIconID = 359; break; case 1: this.cursorItemIconID = 2237; break; case 2: this.cursorItemIconID = 2238; break; case 3: this.cursorItemIconID = 2239; break; case 4: this.cursorItemIconID = 2240; break; case 5: this.cursorItemIconID = 2241; break; case 6: this.cursorItemIconID = 2560; break; case 7: this.cursorItemIconID = 2575; break; case 8: this.cursorItemIconID = 2591; break; case 9: this.cursorItemIconID = 2592; break; case 10: this.cursorItemIconID = 2593; break; case 11: this.cursorItemIconID = 2594; break; case 12: this.cursorItemIconID = 2595; break; case 13: this.cursorItemIconID = 2596; break; case 14: this.cursorItemIconID = 2597; break; case 15: this.cursorItemIconID = 2598; break; case 16: this.cursorItemIconID = 2599; break; case 17: this.cursorItemIconID = 2600; break; case 18: this.cursorItemIconID = 2601; break; case 19: this.cursorItemIconID = 2602; break; case 20: this.cursorItemIconID = 2603; break; case 21: this.cursorItemIconID = 2604; break; case 22: this.cursorItemIconID = 2605; break; case 23: this.cursorItemIconID = 2606; break; case 24: this.cursorItemIconID = 2809; break; case 25: this.cursorItemIconID = 3126; break; case 26: this.cursorItemIconID = 3128; break; case 27: this.cursorItemIconID = 3127; break; case 28: this.cursorItemIconID = 3898; break; case 29: this.cursorItemIconID = 3899; break; case 30: this.cursorItemIconID = 3900; break; case 31: this.cursorItemIconID = 3901; break; case 32: this.cursorItemIconID = 3902; break; case 33: this.cursorItemIconID = 3940; break; case 34: this.cursorItemIconID = 3966; break; case 35: this.cursorItemIconID = 4154; break; case 36: this.cursorItemIconID = 4175; break; case 37: this.cursorItemIconID = 4196; break; case 38: this.cursorItemIconID = 4217; break; case 39: this.cursorItemIconID = 4306; break; case 40: this.cursorItemIconID = 4575; break; } } if (Main.tile[myX, myY].type == (ushort) 356) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 3064; } if (Main.tile[myX, myY].type == (ushort) 377) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 3198; } if (Main.tile[myX, myY].type == (ushort) 209) { this.noThrow = 2; this.cursorItemIconEnabled = true; if (Main.tile[myX, myY].frameX < (short) 72) this.cursorItemIconID = 928; else if (Main.tile[myX, myY].frameX < (short) 144) this.cursorItemIconID = 1337; else if (Main.tile[myX, myY].frameX < (short) 216) this.cursorItemIconID = 3369; else if (Main.tile[myX, myY].frameX < (short) 360) this.cursorItemIconID = 3664; int num = (int) Main.tile[myX, myY].frameX / 18; while (num >= 4) num -= 4; this.cursorItemIconReversed = num < 2; } if (Main.tile[myX, myY].type == (ushort) 216) { this.noThrow = 2; this.cursorItemIconEnabled = true; int frameY = (int) Main.tile[myX, myY].frameY; int num = 0; while (frameY >= 40) { frameY -= 40; ++num; } this.cursorItemIconID = 970 + num; } if (Main.tile[myX, myY].type == (ushort) 387 || Main.tile[myX, myY].type == (ushort) 386) { this.noThrow = 2; this.cursorItemIconEnabled = true; int x = 0; int y = 0; WorldGen.GetTopLeftAndStyles(ref x, ref y, 2, 1 + (Main.tile[myX, myY].type == (ushort) 386).ToInt(), 18, 18); this.cursorItemIconID = 3239; } if (Main.tile[myX, myY].type == (ushort) 389 || Main.tile[myX, myY].type == (ushort) 388) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 3240; } if (Main.tile[myX, myY].type == (ushort) 335) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 2700; } if (Main.tile[myX, myY].type == (ushort) 15 && this.IsWithinSnappngRangeToTile(myX, myY, 40)) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = WorldGen.GetItemDrop_Chair((int) Main.tile[myX, myY].frameY / 40); if ((int) Main.tile[myX, myY].frameX / 18 < 1) this.cursorItemIconReversed = true; } if (Main.tile[myX, myY].type == (ushort) 102 && this.IsWithinSnappngRangeToTile(myX, myY, 40)) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 355; } if (Main.tile[myX, myY].type == (ushort) 89 && this.IsWithinSnappngRangeToTile(myX, myY, 40)) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = WorldGen.GetItemDrop_Benches((int) Main.tile[myX, myY].frameX / 54); } if (Main.tile[myX, myY].type == (ushort) 487 && this.IsWithinSnappngRangeToTile(myX, myY, 40)) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = WorldGen.GetItemDrop_PicnicTables((int) Main.tile[myX, myY].frameX / 72); } if (Main.tile[myX, myY].type == (ushort) 497 && this.IsWithinSnappngRangeToTile(myX, myY, 40)) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = WorldGen.GetItemDrop_Toilet((int) Main.tile[myX, myY].frameY / 40); if ((int) Main.tile[myX, myY].frameX / 18 < 1) this.cursorItemIconReversed = true; } if (Main.tile[myX, myY].type == (ushort) 410) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 3536 + Math.Min((int) Main.tile[myX, myY].frameX / 36, 3); } if (Main.tile[myX, myY].type == (ushort) 480) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 4054; } if (Main.tile[myX, myY].type == (ushort) 509) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 4318; } if (Main.tile[myX, myY].type == (ushort) 463) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 3813; } if (Main.tile[myX, myY].type == (ushort) 491) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 4076; } if (Main.tile[myX, myY].type == (ushort) 494) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 4089; } if (Main.tile[myX, myY].type == (ushort) 411 && Main.tile[myX, myY].frameX < (short) 36) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 3545; } if (Main.tile[myX, myY].type == (ushort) 338) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 2738; } if (Main.tile[myX, myY].type == (ushort) 455) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 3747; } if (Main.tile[myX, myY].type == (ushort) 219 && (this.inventory[this.selectedItem].type == 424 || this.inventory[this.selectedItem].type == 1103)) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = this.inventory[this.selectedItem].type; } if (Main.tile[myX, myY].type == (ushort) 212) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 949; } if (Main.tile[myX, myY].type == (ushort) 314 && (double) this.gravDir == 1.0) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 2343; } if (Main.tile[myX, myY].type == (ushort) 215) { this.noThrow = 2; this.cursorItemIconEnabled = true; int num = (int) Main.tile[myX, myY].frameX / 54; this.cursorItemIconID = num != 0 ? (num < 8 || num > 13 ? (num != 7 ? (num != 6 ? (num != 5 ? 3046 + num - 1 : 3050) : 3723) : 3724) : 4689 + num - 8) : 966; } if (Main.tile[myX, myY].type == (ushort) 4) { this.noThrow = 2; this.cursorItemIconEnabled = true; int num = (int) Main.tile[myX, myY].frameY / 22; switch (num) { case 0: this.cursorItemIconID = 8; break; case 8: this.cursorItemIconID = 523; break; case 9: this.cursorItemIconID = 974; break; case 10: this.cursorItemIconID = 1245; break; case 11: this.cursorItemIconID = 1333; break; case 12: this.cursorItemIconID = 2274; break; case 13: this.cursorItemIconID = 3004; break; case 14: this.cursorItemIconID = 3045; break; case 15: this.cursorItemIconID = 3114; break; case 16: this.cursorItemIconID = 4383; break; case 17: this.cursorItemIconID = 4384; break; case 18: this.cursorItemIconID = 4385; break; case 19: this.cursorItemIconID = 4386; break; case 20: this.cursorItemIconID = 4387; break; case 21: this.cursorItemIconID = 4388; break; default: this.cursorItemIconID = 426 + num; break; } } if (Main.tile[myX, myY].type == (ushort) 13) { this.noThrow = 2; this.cursorItemIconEnabled = true; switch ((int) Main.tile[myX, myY].frameX / 18) { case 1: this.cursorItemIconID = 28; break; case 2: this.cursorItemIconID = 110; break; case 3: this.cursorItemIconID = 350; break; case 4: this.cursorItemIconID = 351; break; case 5: this.cursorItemIconID = 2234; break; case 6: this.cursorItemIconID = 2244; break; case 7: this.cursorItemIconID = 2257; break; case 8: this.cursorItemIconID = 2258; break; default: this.cursorItemIconID = 31; break; } } if (Main.tile[myX, myY].type == (ushort) 29) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 87; } if (Main.tile[myX, myY].type == (ushort) 97) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 346; } if (Main.tile[myX, myY].type == (ushort) 510) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 4319; int num = (int) Main.tile[myX, myY].frameX / 18; while (num >= 2) num -= 2; this.cursorItemIconReversed = num == 0; } if (Main.tile[myX, myY].type == (ushort) 511) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 4320; int num = (int) Main.tile[myX, myY].frameX / 18; while (num >= 2) num -= 2; this.cursorItemIconReversed = num == 0; } if (Main.tile[myX, myY].type == (ushort) 49) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 148; } if (Main.tile[myX, myY].type == (ushort) 174) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 713; } if (Main.tile[myX, myY].type == (ushort) 50) { this.noThrow = 2; if (Main.tile[myX, myY].frameX == (short) 90) { this.cursorItemIconEnabled = true; this.cursorItemIconID = 165; } } if (Main.tile[myX, myY].type == (ushort) 139) { this.noThrow = 2; int index1 = myX; int index2 = myY; int num = 0; for (int index3 = (int) Main.tile[index1, index2].frameY / 18; index3 >= 2; index3 -= 2) ++num; this.cursorItemIconEnabled = true; this.cursorItemIconID = num != 28 ? (num != 29 ? (num != 30 ? (num != 31 ? (num != 32 ? (num != 33 ? (num != 34 ? (num != 35 ? (num != 36 ? (num != 37 ? (num != 38 ? (num != 39 ? (num != 40 ? (num != 41 ? (num != 42 ? (num != 43 ? (num != 44 ? (num != 45 ? (num != 46 ? (num != 47 ? (num != 48 ? (num != 49 ? (num != 50 ? (num != 51 ? (num != 52 ? (num != 53 ? (num != 54 ? (num != 55 ? (num != 56 ? (num != 57 ? (num != 58 ? (num != 59 ? (num != 60 ? (num != 61 ? (num != 62 ? (num != 63 ? (num != 64 ? (num != 65 ? (num != 66 ? (num != 67 ? (num != 68 ? (num != 69 ? (num != 70 ? (num != 71 ? (num != 72 ? (num != 73 ? (num != 74 ? (num != 75 ? (num != 76 ? (num != 77 ? (num != 78 ? (num != 79 ? (num != 80 ? (num != 81 ? (num != 82 ? (num != 83 ? (num != 84 ? (num != 85 ? (num < 13 ? 562 + num : 1596 + num - 13) : 5044) : 5040) : 5039) : 5038) : 5037) : 5036) : 5035) : 5034) : 5033) : 5032) : 5031) : 5030) : 5029) : 5028) : 5027) : 5026) : 5025) : 5024) : 5023) : 5022) : 5021) : 5020) : 5019) : 5018) : 5017) : 5016) : 5015) : 5014) : 5006) : 4992) : 4991) : 4990) : 4985) : 4979) : 4606) : 4421) : 4358) : 4357) : 4356) : 4237) : 4081) : 4080) : 4077) : 4079) : 4078) : 4082) : 3869) : 3796) : 3371) : 3370) : 3237) : 3236) : 3235) : 3044) : 2742) : 1965) : 1964) : 1963; } if (Main.tile[myX, myY].type == (ushort) 207) { this.noThrow = 2; int index4 = myX; int index5 = myY; int num = 0; for (int index6 = (int) Main.tile[index4, index5].frameX / 18; index6 >= 2; index6 -= 2) ++num; this.cursorItemIconEnabled = true; switch (num) { case 0: this.cursorItemIconID = 909; break; case 1: this.cursorItemIconID = 910; break; case 2: this.cursorItemIconID = 940; break; case 3: this.cursorItemIconID = 941; break; case 4: this.cursorItemIconID = 942; break; case 5: this.cursorItemIconID = 943; break; case 6: this.cursorItemIconID = 944; break; case 7: this.cursorItemIconID = 945; break; case 8: this.cursorItemIconID = 4922; break; case 9: this.cursorItemIconID = 4417; break; } } if (Main.tileSign[(int) Main.tile[myX, myY].type]) { this.noThrow = 2; int num12 = (int) Main.tile[myX, myY].frameX / 18; int num13 = (int) Main.tile[myX, myY].frameY / 18; int num14 = num12 % 2; int i = myX - num14; int j = myY - num13; Main.signBubble = true; Main.signX = i * 16 + 16; Main.signY = j * 16; int num15 = Sign.ReadSign(i, j, false); if (num15 != -1) Main.signHover = num15; if (num15 != -1) { Main.signHover = num15; this.cursorItemIconEnabled = false; this.cursorItemIconID = -1; } } if (Main.tile[myX, myY].type == (ushort) 237) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 1293; } if (Main.tile[myX, myY].type == (ushort) 466) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 3828; } if (Main.tile[myX, myY].type == (ushort) 125) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 487; } if (Main.tile[myX, myY].type == (ushort) 354) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 2999; } if (Main.tile[myX, myY].type == (ushort) 287) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 2177; } if (Main.tile[myX, myY].type == (ushort) 132) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 513; } if (Main.tile[myX, myY].type == (ushort) 136) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 538; } if (Main.tile[myX, myY].type == (ushort) 144) { this.noThrow = 2; this.cursorItemIconEnabled = true; int num = (int) Main.tile[myX, myY].frameX / 18; this.cursorItemIconID = num >= 3 ? 4484 + (num - 3) : 583 + num; } if (Main.tile[myX, myY].type == (ushort) 440) { int index = myY; int num16 = (int) Main.tile[myX, index].frameX / 54; int num17 = (int) Main.tile[myX, index].frameY / 54; int type = -1; switch (num16) { case 0: type = 1526; break; case 1: type = 1524; break; case 2: type = 1525; break; case 3: type = 1523; break; case 4: type = 1522; break; case 5: type = 1527; break; case 6: type = 3643; break; } if (type != -1 && (num17 == 1 || this.HasItem(type))) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = type; } } else if (Main.tile[myX, myY].type == (ushort) 470) { this.noThrow = 2; int num = (int) Main.tile[myX, myY].frameX % 136 / 34; if (num < 2) { this.cursorItemIconEnabled = true; this.cursorItemIconID = 498; } else if (num < 4) { this.cursorItemIconEnabled = true; this.cursorItemIconID = 1989; } } else if (Main.tile[myX, myY].type == (ushort) 475) { this.noThrow = 2; this.cursorItemIconEnabled = true; this.cursorItemIconID = 3977; } else if (Main.tile[myX, myY].type == (ushort) 520) { this.noThrow = 2; int key = TEFoodPlatter.Find(myX, myY); if (key != -1) { this.cursorItemIconEnabled = true; this.cursorItemIconID = ((TEFoodPlatter) TileEntity.ByID[key]).item.type; } } else if (Main.tile[myX, myY].type == (ushort) 395) { this.noThrow = 2; int x = myX; int y = myY; int frameX = (int) Main.tile[myX, myY].frameX; int frameY = (int) Main.tile[myX, myY].frameY; while (frameY > 0) { frameY -= 18; --y; } while (frameX >= 36) frameX -= 36; while (frameX > 0) { frameX -= 18; --x; } int key = TEItemFrame.Find(x, y); if (key != -1) { this.cursorItemIconEnabled = true; this.cursorItemIconID = ((TEItemFrame) TileEntity.ByID[key]).item.type; } } else if (Main.tile[myX, myY].type == (ushort) 471) { this.noThrow = 2; int x = myX; int y = myY; int frameX = (int) Main.tile[myX, myY].frameX; int frameY = (int) Main.tile[myX, myY].frameY; while (frameY > 0) { frameY -= 18; --y; } while (frameX >= 54) frameX -= 54; while (frameX > 0) { frameX -= 18; --x; } int key = TEWeaponsRack.Find(x, y); if (key != -1) { this.cursorItemIconEnabled = true; this.cursorItemIconID = ((TEWeaponsRack) TileEntity.ByID[key]).item.type; } } else if (Main.tile[myX, myY].type == (ushort) 334) this.noThrow = 2; if (!PlayerInput.UsingGamepad || this.cursorItemIconText.Length != 0) return; this.cursorItemIconEnabled = false; this.cursorItemIconID = 0; } public Color ChatColor() { switch (this.difficulty) { case 1: return Main.mcColor; case 2: return Main.hcColor; default: return Color.White; } } private void TileInteractionsMouseOver_Containers(int myX, int myY) { LocalizedText[] localizedTextArray = Lang.chestType; int[] numArray = Chest.chestTypeToIcon; Tile tile = Main.tile[myX, myY]; if (tile.type == (ushort) 467) { localizedTextArray = Lang.chestType2; numArray = Chest.chestTypeToIcon2; } int X = myX; int Y = myY; if ((int) tile.frameX % 36 != 0) --X; if ((int) tile.frameY % 36 != 0) --Y; int chest = Chest.FindChest(X, Y); this.cursorItemIconID = -1; if (chest < 0) { this.cursorItemIconText = localizedTextArray[0].Value; } else { this.cursorItemIconText = !(Main.chest[chest].name != "") ? localizedTextArray[(int) tile.frameX / 36].Value : Main.chest[chest].name; if (this.cursorItemIconText == localizedTextArray[(int) tile.frameX / 36].Value) { this.cursorItemIconID = numArray[(int) tile.frameX / 36]; this.cursorItemIconText = ""; } } if (this.cursorItemIconID == 3988) this.cursorItemIconID = 306; this.noThrow = 2; this.cursorItemIconEnabled = true; } private void TryLandingOnDetonator() { if (this.whoAmI != Main.myPlayer || (double) this.velocity.Y < 3.0) return; Point tileCoordinates = (this.Bottom + new Vector2(0.0f, 0.01f)).ToTileCoordinates(); Tile tileSafely = Framing.GetTileSafely(tileCoordinates.X, tileCoordinates.Y); if (!tileSafely.active() || tileSafely.type != (ushort) 411 || tileSafely.frameY != (short) 0 || tileSafely.frameX >= (short) 36) return; Wiring.HitSwitch(tileCoordinates.X, tileCoordinates.Y); NetMessage.SendData(59, number: tileCoordinates.X, number2: ((float) tileCoordinates.Y)); } private void TryBouncingBlocks(bool Falling) { int num1 = (double) this.velocity.Y >= 5.0 || (double) this.velocity.Y <= -5.0 ? (!this.wet ? 1 : 0) : 0; bool flag1 = false; bool flag2 = false; float num2 = 1f; if (num1 == 0) return; bool flag3 = false; int num3 = 0; foreach (Point touchedTile in this.TouchedTiles) { Tile tile = Main.tile[touchedTile.X, touchedTile.Y]; if (tile != null && tile.active() && tile.nactive() && (flag1 || Main.tileBouncy[(int) tile.type])) { flag3 = true; num3 = touchedTile.Y; break; } } if (!flag3) return; this.velocity.Y *= -0.8f; if (this.controlJump) this.velocity.Y = MathHelper.Clamp(this.velocity.Y, -13f, 13f); this.position.Y = (float) (num3 * 16 - ((double) this.velocity.Y < 0.0 ? this.height : -16)); this.FloorVisuals(Falling); if (flag2) { Vector2 rotationVector2 = (this.fullRotation - 1.570796f).ToRotationVector2(); if ((double) rotationVector2.Y > 0.0) rotationVector2.Y *= -1f; rotationVector2.Y = (float) ((double) rotationVector2.Y * 0.5 - 0.5); float num4 = -rotationVector2.Y; if ((double) num4 < 0.0) num4 = 0.0f; float num5 = (float) ((double) num4 * 1.5 + 1.0); float num6 = MathHelper.Clamp(Math.Abs(this.velocity.Y) * num5 * num2, 2f, 16f); this.velocity = rotationVector2 * num6; float num7 = 20f; Vector2 vector2 = this.Center + (this.fullRotation + 1.570796f).ToRotationVector2() * num7; Vector2 bottom = this.Bottom; ParticleOrchestrator.RequestParticleSpawn(true, ParticleOrchestraType.Keybrand, new ParticleOrchestraSettings() { PositionInWorld = bottom }, new int?(this.whoAmI)); } this.velocity.Y = MathHelper.Clamp(this.velocity.Y, -20f, 20f); if ((double) this.velocity.Y * (double) this.gravDir >= 0.0) return; this.fallStart = (int) this.position.Y / 16; } private bool CanAcceptItemIntoInventory(Item item) => !this.preventAllItemPickups || ItemID.Sets.IgnoresEncumberingStone[item.type]; private void GrabItems(int i) { for (int worldItemArrayIndex = 0; worldItemArrayIndex < 400; ++worldItemArrayIndex) { Item obj = Main.item[worldItemArrayIndex]; if (obj.active && obj.noGrabDelay == 0 && obj.playerIndexTheItemIsReservedFor == i && this.CanAcceptItemIntoInventory(obj)) { int itemGrabRange = this.GetItemGrabRange(obj); Microsoft.Xna.Framework.Rectangle hitbox = obj.Hitbox; if (this.Hitbox.Intersects(hitbox)) { if (i == Main.myPlayer && (this.inventory[this.selectedItem].type != 0 ? 0 : (this.itemAnimation > 0 ? 1 : 0)) == 0) this.PickupItem(i, worldItemArrayIndex, obj); } else if (new Microsoft.Xna.Framework.Rectangle((int) this.position.X - itemGrabRange, (int) this.position.Y - itemGrabRange, this.width + itemGrabRange * 2, this.height + itemGrabRange * 2).Intersects(hitbox)) { Player.ItemSpaceStatus status = this.ItemSpace(obj); if (this.CanPullItem(obj, status)) { obj.beingGrabbed = true; if (this.manaMagnet && (obj.type == 184 || obj.type == 1735 || obj.type == 1868)) this.PullItem_Pickup(obj, 12f, 5); else if (this.lifeMagnet && (obj.type == 58 || obj.type == 1734 || obj.type == 1867)) this.PullItem_Pickup(obj, 15f, 5); else if (ItemID.Sets.NebulaPickup[obj.type]) this.PullItem_Pickup(obj, 12f, 5); else if (status.ItemIsGoingToVoidVault) this.PullItem_ToVoidVault(obj); else if (this.goldRing && obj.IsACoin) this.PullItem_Pickup(obj, 12f, 5); else this.PullItem_Common(obj, 0.75f); } } } } } private void PullItem_ToVoidVault(Item itemToPickUp) => this.PullItem_Pickup(itemToPickUp, 12f, 5); private void PullItem_Common(Item itemToPickUp, float xPullSpeed) { if ((double) this.position.X + (double) this.width * 0.5 > (double) itemToPickUp.position.X + (double) itemToPickUp.width * 0.5) { if ((double) itemToPickUp.velocity.X < (double) Player.itemGrabSpeedMax + (double) this.velocity.X) itemToPickUp.velocity.X += Player.itemGrabSpeed; if ((double) itemToPickUp.velocity.X < 0.0) itemToPickUp.velocity.X += Player.itemGrabSpeed * xPullSpeed; } else { if ((double) itemToPickUp.velocity.X > -(double) Player.itemGrabSpeedMax + (double) this.velocity.X) itemToPickUp.velocity.X -= Player.itemGrabSpeed; if ((double) itemToPickUp.velocity.X > 0.0) itemToPickUp.velocity.X -= Player.itemGrabSpeed * xPullSpeed; } if ((double) this.position.Y + (double) this.height * 0.5 > (double) itemToPickUp.position.Y + (double) itemToPickUp.height * 0.5) { if ((double) itemToPickUp.velocity.Y < (double) Player.itemGrabSpeedMax) itemToPickUp.velocity.Y += Player.itemGrabSpeed; if ((double) itemToPickUp.velocity.Y >= 0.0) return; itemToPickUp.velocity.Y += Player.itemGrabSpeed * xPullSpeed; } else { if ((double) itemToPickUp.velocity.Y > -(double) Player.itemGrabSpeedMax) itemToPickUp.velocity.Y -= Player.itemGrabSpeed; if ((double) itemToPickUp.velocity.Y <= 0.0) return; itemToPickUp.velocity.Y -= Player.itemGrabSpeed * xPullSpeed; } } private void PullItem_Pickup(Item itemToPickUp, float speed, int acc) { Vector2 vector2 = new Vector2(itemToPickUp.position.X + (float) (itemToPickUp.width / 2), itemToPickUp.position.Y + (float) (itemToPickUp.height / 2)); float num1 = this.Center.X - vector2.X; float num2 = this.Center.Y - vector2.Y; float num3 = (float) Math.Sqrt((double) num1 * (double) num1 + (double) num2 * (double) num2); float num4 = speed / num3; float num5 = num1 * num4; float num6 = num2 * num4; itemToPickUp.velocity.X = (itemToPickUp.velocity.X * (float) (acc - 1) + num5) / (float) acc; itemToPickUp.velocity.Y = (itemToPickUp.velocity.Y * (float) (acc - 1) + num6) / (float) acc; } private Item PickupItem(int playerIndex, int worldItemArrayIndex, Item itemToPickUp) { if (ItemID.Sets.NebulaPickup[itemToPickUp.type]) { SoundEngine.PlaySound(7, (int) this.position.X, (int) this.position.Y); int buffType = itemToPickUp.buffType; itemToPickUp = new Item(); if (Main.netMode == 1) NetMessage.SendData(102, number: playerIndex, number2: ((float) buffType), number3: this.Center.X, number4: this.Center.Y); else this.NebulaLevelup(buffType); } if (itemToPickUp.type == 58 || itemToPickUp.type == 1734 || itemToPickUp.type == 1867) { SoundEngine.PlaySound(7, (int) this.position.X, (int) this.position.Y); this.statLife += 20; if (Main.myPlayer == this.whoAmI) this.HealEffect(20); if (this.statLife > this.statLifeMax2) this.statLife = this.statLifeMax2; itemToPickUp = new Item(); } else if (itemToPickUp.type == 184 || itemToPickUp.type == 1735 || itemToPickUp.type == 1868) { SoundEngine.PlaySound(7, (int) this.position.X, (int) this.position.Y); this.statMana += 100; if (Main.myPlayer == this.whoAmI) this.ManaEffect(100); if (this.statMana > this.statManaMax2) this.statMana = this.statManaMax2; itemToPickUp = new Item(); } else if (itemToPickUp.type == 4143) { SoundEngine.PlaySound(7, (int) this.position.X, (int) this.position.Y); this.statMana += 50; if (Main.myPlayer == this.whoAmI) this.ManaEffect(50); if (this.statMana > this.statManaMax2) this.statMana = this.statManaMax2; itemToPickUp = new Item(); } else itemToPickUp = this.GetItem(playerIndex, itemToPickUp, GetItemSettings.PickupItemFromWorld); Main.item[worldItemArrayIndex] = itemToPickUp; if (Main.netMode == 1) NetMessage.SendData(21, number: worldItemArrayIndex); return itemToPickUp; } private int GetItemGrabRange(Item item) { int defaultItemGrabRange = Player.defaultItemGrabRange; if (this.goldRing && item.IsACoin) defaultItemGrabRange += Item.coinGrabRange; if (this.manaMagnet && (item.type == 184 || item.type == 1735 || item.type == 1868)) defaultItemGrabRange += Item.manaGrabRange; if (item.type == 4143) defaultItemGrabRange += Item.manaGrabRange; if (this.lifeMagnet && (item.type == 58 || item.type == 1734 || item.type == 1867)) defaultItemGrabRange += Item.lifeGrabRange; if (this.treasureMagnet) defaultItemGrabRange += Item.treasureGrabRange; if (item.type == 3822) defaultItemGrabRange += 50; if (ItemID.Sets.NebulaPickup[item.type]) defaultItemGrabRange += 100; return defaultItemGrabRange; } public bool SellItem(Item item, int stack = -1) { int calcForSelling; int calcForBuying; this.GetItemExpectedPrice(item, out calcForSelling, out calcForBuying); if (calcForSelling <= 0) return false; if (stack == -1) stack = item.stack; Item[] objArray = new Item[58]; for (int index = 0; index < 58; ++index) { objArray[index] = new Item(); objArray[index] = this.inventory[index].Clone(); } int num1 = calcForSelling / 5; if (num1 < 1) num1 = 1; int num2 = num1; int num3 = num1 * stack; int amount = Main.shopSellbackHelper.GetAmount(item); if (amount > 0) num3 += (-num2 + calcForBuying) * Math.Min(amount, item.stack); bool flag = false; while (num3 >= 1000000 && !flag) { int index = -1; for (int i = 53; i >= 0; --i) { if (index == -1 && (this.inventory[i].type == 0 || this.inventory[i].stack == 0)) index = i; while (this.inventory[i].type == 74 && this.inventory[i].stack < this.inventory[i].maxStack && num3 >= 1000000) { ++this.inventory[i].stack; num3 -= 1000000; this.DoCoins(i); if (this.inventory[i].stack == 0 && index == -1) index = i; } } if (num3 >= 1000000) { if (index == -1) { flag = true; } else { this.inventory[index].SetDefaults(74); num3 -= 1000000; } } } while (num3 >= 10000 && !flag) { int index = -1; for (int i = 53; i >= 0; --i) { if (index == -1 && (this.inventory[i].type == 0 || this.inventory[i].stack == 0)) index = i; while (this.inventory[i].type == 73 && this.inventory[i].stack < this.inventory[i].maxStack && num3 >= 10000) { ++this.inventory[i].stack; num3 -= 10000; this.DoCoins(i); if (this.inventory[i].stack == 0 && index == -1) index = i; } } if (num3 >= 10000) { if (index == -1) { flag = true; } else { this.inventory[index].SetDefaults(73); num3 -= 10000; } } } while (num3 >= 100 && !flag) { int index = -1; for (int i = 53; i >= 0; --i) { if (index == -1 && (this.inventory[i].type == 0 || this.inventory[i].stack == 0)) index = i; while (this.inventory[i].type == 72 && this.inventory[i].stack < this.inventory[i].maxStack && num3 >= 100) { ++this.inventory[i].stack; num3 -= 100; this.DoCoins(i); if (this.inventory[i].stack == 0 && index == -1) index = i; } } if (num3 >= 100) { if (index == -1) { flag = true; } else { this.inventory[index].SetDefaults(72); num3 -= 100; } } } while (num3 >= 1 && !flag) { int index = -1; for (int i = 53; i >= 0; --i) { if (index == -1 && (this.inventory[i].type == 0 || this.inventory[i].stack == 0)) index = i; while (this.inventory[i].type == 71 && this.inventory[i].stack < this.inventory[i].maxStack && num3 >= 1) { ++this.inventory[i].stack; --num3; this.DoCoins(i); if (this.inventory[i].stack == 0 && index == -1) index = i; } } if (num3 >= 1) { if (index == -1) { flag = true; } else { this.inventory[index].SetDefaults(71); --num3; } } } if (!flag) return true; for (int index = 0; index < 58; ++index) this.inventory[index] = objArray[index].Clone(); return false; } public void RefreshItems() { this.RefreshItemArray(this.inventory); this.RefreshItemArray(this.armor); this.RefreshItemArray(this.dye); this.RefreshItemArray(this.miscEquips); this.RefreshItemArray(this.miscDyes); this.RefreshItemArray(this.bank.item); this.RefreshItemArray(this.bank2.item); this.RefreshItemArray(this.bank3.item); this.RefreshItemArray(this.bank4.item); } private void RefreshItemArray(Item[] array) { for (int index = 0; index < array.Length; ++index) { if (!array[index].IsAir) array[index].Refresh(); } } public void GetItemExpectedPrice(Item item, out int calcForSelling, out int calcForBuying) { if (item.shopSpecialCurrency != -1) { CustomCurrencyManager.GetPrices(item, out calcForSelling, out calcForBuying); } else { int storeValue = item.GetStoreValue(); calcForSelling = storeValue; calcForBuying = storeValue; if (this.discount) { if (!item.buyOnce) calcForBuying = (int) ((double) calcForBuying * 0.800000011920929); if (item.isAShopItem) calcForSelling = calcForBuying; } if (item.buyOnce) { calcForBuying = (int) Math.Round((double) calcForBuying / this.currentShoppingSettings.PriceAdjustment); calcForSelling = (int) Math.Round((double) calcForSelling / this.currentShoppingSettings.PriceAdjustment); } else { calcForBuying = (int) Math.Round((double) calcForBuying * this.currentShoppingSettings.PriceAdjustment); calcForSelling = (int) Math.Round((double) calcForSelling / this.currentShoppingSettings.PriceAdjustment); } if (!item.buyOnce) return; calcForBuying /= 5; if (storeValue == 0 || calcForBuying >= 1) return; calcForBuying = 1; } } public bool BuyItem(int price, int customCurrency = -1) { if (customCurrency != -1) return CustomCurrencyManager.BuyItem(this, price, customCurrency); bool overFlowing; long num1 = Utils.CoinsCount(out overFlowing, this.inventory, 58, 57, 56, 55, 54); long num2 = Utils.CoinsCount(out overFlowing, this.bank.item); long num3 = Utils.CoinsCount(out overFlowing, this.bank2.item); long num4 = Utils.CoinsCount(out overFlowing, this.bank3.item); long num5 = Utils.CoinsCount(out overFlowing, this.bank4.item); if (Utils.CoinsCombineStacks(out overFlowing, num1, num2, num3, num4, num5) < (long) price) return false; List inv = new List(); Dictionary> dictionary = new Dictionary>(); List slotsEmpty = new List(); List slotCoins = new List(); List slotEmptyBank = new List(); List slotEmptyBank2 = new List(); List slotEmptyBank3 = new List(); List slotEmptyBank4 = new List(); inv.Add(this.inventory); inv.Add(this.bank.item); inv.Add(this.bank2.item); inv.Add(this.bank3.item); inv.Add(this.bank4.item); for (int key = 0; key < inv.Count; ++key) dictionary[key] = new List(); dictionary[0] = new List() { 58, 57, 56, 55, 54 }; for (int index = 0; index < inv.Count; ++index) { for (int y = 0; y < inv[index].Length; ++y) { if (!dictionary[index].Contains(y) && inv[index][y].IsACoin) slotCoins.Add(new Point(index, y)); } } int num6 = 0; for (int y = inv[num6].Length - 1; y >= 0; --y) { if (!dictionary[num6].Contains(y) && (inv[num6][y].type == 0 || inv[num6][y].stack == 0)) slotsEmpty.Add(new Point(num6, y)); } int num7 = 1; for (int y = inv[num7].Length - 1; y >= 0; --y) { if (!dictionary[num7].Contains(y) && (inv[num7][y].type == 0 || inv[num7][y].stack == 0)) slotEmptyBank.Add(new Point(num7, y)); } int num8 = 2; for (int y = inv[num8].Length - 1; y >= 0; --y) { if (!dictionary[num8].Contains(y) && (inv[num8][y].type == 0 || inv[num8][y].stack == 0)) slotEmptyBank2.Add(new Point(num8, y)); } int num9 = 3; for (int y = inv[num9].Length - 1; y >= 0; --y) { if (!dictionary[num9].Contains(y) && (inv[num9][y].type == 0 || inv[num9][y].stack == 0)) slotEmptyBank3.Add(new Point(num9, y)); } int num10 = 4; for (int y = inv[num10].Length - 1; y >= 0; --y) { if (!dictionary[num10].Contains(y) && (inv[num10][y].type == 0 || inv[num10][y].stack == 0)) slotEmptyBank4.Add(new Point(num10, y)); } return !Player.TryPurchasing(price, inv, slotCoins, slotsEmpty, slotEmptyBank, slotEmptyBank2, slotEmptyBank3, slotEmptyBank4); } private static bool TryPurchasing( int price, List inv, List slotCoins, List slotsEmpty, List slotEmptyBank, List slotEmptyBank2, List slotEmptyBank3, List slotEmptyBank4) { long num1 = (long) price; Dictionary dictionary = new Dictionary(); bool flag = false; while (num1 > 0L) { long num2 = 1000000; for (int index = 0; index < 4; ++index) { if (num1 >= num2) { foreach (Point slotCoin in slotCoins) { if (inv[slotCoin.X][slotCoin.Y].type == 74 - index) { long num3 = num1 / num2; dictionary[slotCoin] = inv[slotCoin.X][slotCoin.Y].Clone(); if (num3 < (long) inv[slotCoin.X][slotCoin.Y].stack) { inv[slotCoin.X][slotCoin.Y].stack -= (int) num3; } else { inv[slotCoin.X][slotCoin.Y].SetDefaults(); slotsEmpty.Add(slotCoin); } num1 -= num2 * (long) (dictionary[slotCoin].stack - inv[slotCoin.X][slotCoin.Y].stack); } } } num2 /= 100L; } if (num1 > 0L) { if (slotsEmpty.Count > 0) { slotsEmpty.Sort(new Comparison(DelegateMethods.CompareYReverse)); Point point = new Point(-1, -1); for (int index1 = 0; index1 < inv.Count; ++index1) { long num4 = 10000; for (int index2 = 0; index2 < 3; ++index2) { if (num1 >= num4) { foreach (Point slotCoin in slotCoins) { if (slotCoin.X == index1 && inv[slotCoin.X][slotCoin.Y].type == 74 - index2 && inv[slotCoin.X][slotCoin.Y].stack >= 1) { List pointList = slotsEmpty; if (index1 == 1 && slotEmptyBank.Count > 0) pointList = slotEmptyBank; if (index1 == 2 && slotEmptyBank2.Count > 0) pointList = slotEmptyBank2; if (index1 == 3 && slotEmptyBank3.Count > 0) pointList = slotEmptyBank3; if (index1 == 4 && slotEmptyBank4.Count > 0) pointList = slotEmptyBank4; if (--inv[slotCoin.X][slotCoin.Y].stack <= 0) { inv[slotCoin.X][slotCoin.Y].SetDefaults(); pointList.Add(slotCoin); } dictionary[pointList[0]] = inv[pointList[0].X][pointList[0].Y].Clone(); inv[pointList[0].X][pointList[0].Y].SetDefaults(73 - index2); inv[pointList[0].X][pointList[0].Y].stack = 100; point = pointList[0]; pointList.RemoveAt(0); break; } } } if (point.X == -1 && point.Y == -1) num4 /= 100L; else break; } for (int index3 = 0; index3 < 2; ++index3) { if (point.X == -1 && point.Y == -1) { foreach (Point slotCoin in slotCoins) { if (slotCoin.X == index1 && inv[slotCoin.X][slotCoin.Y].type == 73 + index3 && inv[slotCoin.X][slotCoin.Y].stack >= 1) { List pointList = slotsEmpty; if (index1 == 1 && slotEmptyBank.Count > 0) pointList = slotEmptyBank; if (index1 == 2 && slotEmptyBank2.Count > 0) pointList = slotEmptyBank2; if (index1 == 3 && slotEmptyBank3.Count > 0) pointList = slotEmptyBank3; if (index1 == 4 && slotEmptyBank4.Count > 0) pointList = slotEmptyBank4; if (--inv[slotCoin.X][slotCoin.Y].stack <= 0) { inv[slotCoin.X][slotCoin.Y].SetDefaults(); pointList.Add(slotCoin); } dictionary[pointList[0]] = inv[pointList[0].X][pointList[0].Y].Clone(); inv[pointList[0].X][pointList[0].Y].SetDefaults(72 + index3); inv[pointList[0].X][pointList[0].Y].stack = 100; point = pointList[0]; pointList.RemoveAt(0); break; } } } } if (point.X != -1 && point.Y != -1) { slotCoins.Add(point); break; } } slotsEmpty.Sort(new Comparison(DelegateMethods.CompareYReverse)); slotEmptyBank.Sort(new Comparison(DelegateMethods.CompareYReverse)); slotEmptyBank2.Sort(new Comparison(DelegateMethods.CompareYReverse)); slotEmptyBank3.Sort(new Comparison(DelegateMethods.CompareYReverse)); slotEmptyBank4.Sort(new Comparison(DelegateMethods.CompareYReverse)); } else { foreach (KeyValuePair keyValuePair in dictionary) inv[keyValuePair.Key.X][keyValuePair.Key.Y] = keyValuePair.Value.Clone(); flag = true; break; } } } return flag; } public void AdjTiles() { int num1 = 4; int num2 = 3; for (int index = 0; index < 623; ++index) { this.oldAdjTile[index] = this.adjTile[index]; this.adjTile[index] = false; } this.oldAdjWater = this.adjWater; this.adjWater = false; this.oldAdjHoney = this.adjHoney; this.adjHoney = false; this.oldAdjLava = this.adjLava; this.adjLava = false; this.alchemyTable = false; int num3 = (int) (((double) this.position.X + (double) (this.width / 2)) / 16.0); int num4 = (int) (((double) this.position.Y + (double) this.height) / 16.0); for (int index1 = num3 - num1; index1 <= num3 + num1; ++index1) { for (int index2 = num4 - num2; index2 < num4 + num2; ++index2) { if (Main.tile[index1, index2].active()) { this.adjTile[(int) Main.tile[index1, index2].type] = true; switch (Main.tile[index1, index2].type) { case 77: case 302: this.adjTile[17] = true; break; case 133: this.adjTile[17] = true; this.adjTile[77] = true; break; case 134: this.adjTile[16] = true; break; case 354: case 469: case 487: this.adjTile[14] = true; break; case 355: this.adjTile[13] = true; this.adjTile[14] = true; this.alchemyTable = true; break; } } if (Main.tile[index1, index2].liquid > (byte) 200 && Main.tile[index1, index2].liquidType() == (byte) 0) this.adjWater = true; if (Main.tile[index1, index2].liquid > (byte) 200 && Main.tile[index1, index2].liquidType() == (byte) 2) this.adjHoney = true; if (Main.tile[index1, index2].liquid > (byte) 200 && Main.tile[index1, index2].liquidType() == (byte) 1) this.adjLava = true; } } if (!Main.playerInventory) return; bool flag = false; for (int index = 0; index < 623; ++index) { if (this.oldAdjTile[index] != this.adjTile[index]) { flag = true; break; } } if (this.adjWater != this.oldAdjWater) flag = true; if (this.adjHoney != this.oldAdjHoney) flag = true; if (this.adjLava != this.oldAdjLava) flag = true; if (!flag) return; Recipe.FindRecipes(); } public bool IsTileTypeInInteractionRange(int targetTileType) { int num1 = (int) (((double) this.position.X + (double) (this.width / 2)) / 16.0); int num2 = (int) (((double) this.position.Y + (double) this.height) / 16.0); int num3 = Player.tileRangeX; int num4 = Player.tileRangeY; if (num3 > 20) num3 = 20; if (num4 > 20) num4 = 20; int num5 = Utils.Clamp(num1 - num3, 0, Main.maxTilesX - 1); int num6 = Utils.Clamp(num1 + num3, 0, Main.maxTilesX - 1); int num7 = Utils.Clamp(num2 - num4, 0, Main.maxTilesY - 1); int num8 = Utils.Clamp(num2 + num4, 0, Main.maxTilesY - 1); for (int index1 = num5; index1 <= num6; ++index1) { for (int index2 = num7; index2 < num8; ++index2) { Tile tile = Main.tile[index1, index2]; if (tile != null && tile.active() && (int) tile.type == targetTileType) return true; } } return false; } public void DisplayDollUpdate() { if (Main.gamePaused) return; ++this.miscCounter; if (this.miscCounter < 300) return; this.miscCounter = 0; } public bool IsColorfulDye(int dye) => dye > 0 && ItemID.Sets.ColorfulDyeValues[dye]; public bool ShouldDrawFootball() { bool flag = this.hasFootball && !this.pulley && !this.compositeBackArm.enabled; if (this.HeldItem.type == 4743 && this.itemAnimation > 0) flag = false; return flag; } public void PlayerFrame() { if (this.swimTime > 0) { --this.swimTime; if (!this.wet) this.swimTime = 0; } this.head = this.armor[0].headSlot; this.body = this.armor[1].bodySlot; this.legs = this.armor[2].legSlot; if (this.armor[10].headSlot >= 0) this.head = this.armor[10].headSlot; if (this.armor[11].bodySlot >= 0) this.body = this.armor[11].bodySlot; if (this.armor[12].legSlot >= 0) this.legs = this.armor[12].legSlot; this.UpdateVisibleAccessories(); this.wearsRobe = false; bool somethingSpecial = false; int num1 = Player.SetMatch(1, this.body, this.Male, ref this.wearsRobe); if (num1 != -1) this.legs = num1; int num2 = Player.SetMatch(2, this.legs, this.Male, ref somethingSpecial); if (num2 != -1) this.legs = num2; int num3 = Player.SetMatch(0, this.head, this.Male, ref somethingSpecial); if (num3 != -1) this.head = num3; if (this.body == 93) { this.shield = (sbyte) 0; this.handoff = (sbyte) 0; } if (this.body >= 0) { sbyte num4 = (sbyte) (this.Male ? ArmorIDs.Body.Sets.IncludedCapeBack : ArmorIDs.Body.Sets.IncludedCapeBackFemale)[this.body]; if (num4 != (sbyte) -1 && this.back == (sbyte) -1 && !this.sitting.isSitting) { this.back = num4; this.cBack = this.cBody; } sbyte num5 = (sbyte) ArmorIDs.Body.Sets.IncludedCapeFront[this.body]; if (num5 != (sbyte) -1 && this.front == (sbyte) -1) { this.front = num5; this.cFront = this.cBody; } ArmorIDs.Body.Sets.IncludeCapeFrontAndBackInfo frontAndBackInfo = ArmorIDs.Body.Sets.IncludeCapeFrontAndBack[this.body]; if (!frontAndBackInfo.Invalid && this.back == (sbyte) -1 && this.front == (sbyte) -1 && !this.sitting.isSitting) { this.front = frontAndBackInfo.frontCape; this.back = frontAndBackInfo.backCape; this.cFront = this.cBody; this.cBack = this.cBody; } } if (this.legs == 67) this.shoe = (sbyte) 0; if (this.legs == 140) this.shoe = (sbyte) 0; if ((this.wereWolf || this.forceWerewolf) && !this.hideWolf) { this.legs = 20; this.body = 21; this.head = 38; } bool flag1 = this.wet && !this.lavaWet && (!this.mount.Active || !this.mount.IsConsideredASlimeMount); if (this.merman || this.forceMerman) { if (!this.hideMerman) { this.head = 39; this.legs = 21; this.body = 22; } if (flag1) this.wings = 0; } this.socialShadowRocketBoots = false; this.socialIgnoreLight = false; this.socialGhost = false; this.armorEffectDrawShadow = false; this.armorEffectDrawShadowSubtle = false; this.armorEffectDrawOutlines = false; this.armorEffectDrawShadowLokis = false; this.armorEffectDrawShadowBasilisk = false; this.armorEffectDrawOutlinesForbidden = false; this.armorEffectDrawShadowEOCShield = false; if (!this.isDisplayDollOrInanimate) { if (this.head == 101 && this.body == 66 && this.legs == 55) this.socialGhost = true; if (this.head == 156 && this.body == 66 && this.legs == 55) this.socialGhost = true; this.SetArmorEffectVisuals(this); } this.hermesStepSound.SoundType = 17; this.hermesStepSound.SoundStyle = -1; this.hermesStepSound.IntendedCooldown = 9; if (this.head == 99 && this.body == 65 && this.legs == 54) this.turtleArmor = true; if (this.head == 162 && this.body == 170 && this.legs == 105) this.spiderArmor = true; this.ApplyArmorSoundAndDustChanges(); if (this.legs == 140) { this.hermesStepSound.SoundType = 2; this.hermesStepSound.SoundStyle = 24; this.hermesStepSound.IntendedCooldown = 6; } if (this.wings > 0 && this.wings != 33) { this.back = (sbyte) -1; this.front = (sbyte) -1; } if (this.head > 0 && this.face != (sbyte) 7) this.face = (sbyte) -1; if (this.webbed || this.frozen || this.stoned || Main.gamePaused && !Main.gameMenu) return; if (!this.isDisplayDollOrInanimate) { if ((this.body == 68 && this.legs == 57 && this.head == 106 || this.body == 74 && this.legs == 63 && this.head == 106) && Main.rand.Next(10) == 0) { int index = Dust.NewDust(new Vector2(this.position.X - this.velocity.X * 2f, (float) ((double) this.position.Y - 2.0 - (double) this.velocity.Y * 2.0)), this.width, this.height, 43, Alpha: 100, newColor: new Color((int) byte.MaxValue, 0, (int) byte.MaxValue), Scale: 0.3f); Main.dust[index].fadeIn = 0.8f; Main.dust[index].noGravity = true; Main.dust[index].velocity *= 2f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } if (this.wings == 27 && this.wingsLogic == this.wings) { float r = 0.4f * this.stealth; Lighting.AddLight((int) this.Center.X / 16, (int) this.Center.Y / 16, r, r * 0.9f, r * 0.2f); } if (this.head == 5 && this.body == 5 && this.legs == 5) this.socialShadowRocketBoots = true; if (this.head == 5 && this.body == 5 && this.legs == 5 && Main.rand.Next(10) == 0) { int index = Dust.NewDust(new Vector2(this.position.X, this.position.Y), this.width, this.height, 14, Alpha: 200, Scale: 1.2f); Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } if (this.head == 76 && this.body == 49 && this.legs == 45) this.socialShadowRocketBoots = true; if (this.head == 74 && this.body == 48 && this.legs == 44) this.socialShadowRocketBoots = true; if (this.head == 74 && this.body == 48 && this.legs == 44 && Main.rand.Next(10) == 0) { int index = Dust.NewDust(new Vector2(this.position.X, this.position.Y), this.width, this.height, 14, Alpha: 200, Scale: 1.2f); Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } if (this.head == 57 && this.body == 37 && this.legs == 35) { int maxValue = 10; if ((double) Math.Abs(this.velocity.X) + (double) Math.Abs(this.velocity.Y) > 1.0) maxValue = 2; if (Main.rand.Next(maxValue) == 0) { int index = Dust.NewDust(new Vector2(this.position.X, this.position.Y), this.width, this.height, 115, Alpha: 140, Scale: 0.75f); Main.dust[index].noGravity = true; Main.dust[index].fadeIn = 1.5f; Main.dust[index].velocity *= 0.3f; Main.dust[index].velocity += this.velocity * 0.2f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } } if (this.head == 6 && this.body == 6 && this.legs == 6 && (double) Math.Abs(this.velocity.X) + (double) Math.Abs(this.velocity.Y) > 1.0 && !this.rocketFrame) { for (int index1 = 0; index1 < 2; ++index1) { int index2 = Dust.NewDust(new Vector2(this.position.X - this.velocity.X * 2f, (float) ((double) this.position.Y - 2.0 - (double) this.velocity.Y * 2.0)), this.width, this.height, 6, Alpha: 100, Scale: 2f); Main.dust[index2].noGravity = true; Main.dust[index2].noLight = true; Main.dust[index2].velocity.X -= this.velocity.X * 0.5f; Main.dust[index2].velocity.Y -= this.velocity.Y * 0.5f; Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } } if (this.head == 8 && this.body == 8 && this.legs == 8 && (double) Math.Abs(this.velocity.X) + (double) Math.Abs(this.velocity.Y) > 1.0) { int index = Dust.NewDust(new Vector2(this.position.X - this.velocity.X * 2f, (float) ((double) this.position.Y - 2.0 - (double) this.velocity.Y * 2.0)), this.width, this.height, 40, Alpha: 50, Scale: 1.4f); Main.dust[index].noGravity = true; Main.dust[index].velocity.X = this.velocity.X * 0.25f; Main.dust[index].velocity.Y = this.velocity.Y * 0.25f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } if (this.head == 9 && this.body == 9 && this.legs == 9 && (double) Math.Abs(this.velocity.X) + (double) Math.Abs(this.velocity.Y) > 1.0 && !this.rocketFrame) { for (int index3 = 0; index3 < 2; ++index3) { int index4 = Dust.NewDust(new Vector2(this.position.X - this.velocity.X * 2f, (float) ((double) this.position.Y - 2.0 - (double) this.velocity.Y * 2.0)), this.width, this.height, 6, Alpha: 100, Scale: 2f); Main.dust[index4].noGravity = true; Main.dust[index4].noLight = true; Main.dust[index4].velocity.X -= this.velocity.X * 0.5f; Main.dust[index4].velocity.Y -= this.velocity.Y * 0.5f; Main.dust[index4].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } } if (this.body == 18 && this.legs == 17 && (this.head == 32 || this.head == 33 || this.head == 34) && Main.rand.Next(10) == 0) { int index = Dust.NewDust(new Vector2(this.position.X - this.velocity.X * 2f, (float) ((double) this.position.Y - 2.0 - (double) this.velocity.Y * 2.0)), this.width, this.height, 43, Alpha: 100, Scale: 0.3f); Main.dust[index].fadeIn = 0.8f; Main.dust[index].velocity *= 0.0f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } if ((this.body == 24 || this.body == 229) && (this.legs == 23 || this.legs == 212) && (this.head == 43 || this.head == 41 || this.head == 42 || this.head == 254 || this.head == (int) byte.MaxValue || this.head == 256 || this.head == 257 || this.head == 258) && (double) this.velocity.X != 0.0 && (double) this.velocity.Y != 0.0 && Main.rand.Next(10) == 0) { int index = Dust.NewDust(new Vector2(this.position.X - this.velocity.X * 2f, (float) ((double) this.position.Y - 2.0 - (double) this.velocity.Y * 2.0)), this.width, this.height, 43, Alpha: 100, Scale: 0.3f); Main.dust[index].fadeIn = 0.8f; Main.dust[index].velocity *= 0.0f; Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } if (this.body == 36 && this.head == 56 && (double) this.velocity.X != 0.0 && (double) this.velocity.Y == 0.0) { for (int index5 = 0; index5 < 2; ++index5) { int index6 = Dust.NewDust(new Vector2(this.position.X, this.position.Y + ((double) this.gravDir == 1.0 ? (float) (this.height - 2) : -4f)), this.width, 6, 106, Alpha: 100, Scale: 0.1f); Main.dust[index6].fadeIn = 1f; Main.dust[index6].noGravity = true; Main.dust[index6].velocity *= 0.2f; Main.dust[index6].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } } if (this.body == 27 && this.head == 46 && this.legs == 26 && (double) this.velocity.X != 0.0 && (double) this.velocity.Y == 0.0 && this.miscCounter % 2 == 0) { for (int index7 = 0; index7 < 2; ++index7) { int index8 = index7 != 0 ? Dust.NewDust(new Vector2(this.position.X + (float) (this.width / 2), this.position.Y + (float) this.height + this.gfxOffY), this.width / 2, 6, 76, Scale: 1.35f) : Dust.NewDust(new Vector2(this.position.X, this.position.Y + (float) this.height + this.gfxOffY), this.width / 2, 6, 76, Scale: 1.35f); Main.dust[index8].scale *= (float) (1.0 + (double) Main.rand.Next(20, 40) * 0.00999999977648258); Main.dust[index8].noGravity = true; Main.dust[index8].noLight = true; Main.dust[index8].velocity *= 1f / 1000f; Main.dust[index8].velocity.Y -= 3f / 1000f; Main.dust[index8].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } } } this.drawingFootball = false; if (this.ShouldDrawFootball()) { this.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, (float) (0.314159274101257 * (double) this.direction * -1.0)); this.drawingFootball = true; } Item.GetDrawHitbox(this.HeldItem.type, this); bool flag2 = this.CanVisuallyHoldItem(this.HeldItem); bool flag3 = this.HeldItem.type != 4952; if (this.mount.Active) { this.legFrameCounter = 0.0; this.legFrame.Y = this.legFrame.Height * 6; if (this.mount.Type == 23 || this.mount.Type == 45 || this.mount.Type == 48) { ref Microsoft.Xna.Framework.Rectangle local = ref this.legFrame; Microsoft.Xna.Framework.Rectangle legFrame = this.legFrame; local.Y = 0; } if ((double) this.velocity.Y != 0.0) { if (this.mount.FlyTime > 0 && this.jump == 0 && this.controlJump && !this.mount.CanHover()) { if (this.mount.Type == 0) { if (this.direction > 0) { if (Main.rand.Next(4) == 0) { int index = Dust.NewDust(new Vector2(this.Center.X - 22f, (float) ((double) this.position.Y + (double) this.height - 6.0)), 20, 10, 64, this.velocity.X * 0.25f, this.velocity.Y * 0.25f, (int) byte.MaxValue); Main.dust[index].velocity *= 0.1f; Main.dust[index].noLight = true; } if (Main.rand.Next(4) == 0) { int index = Dust.NewDust(new Vector2(this.Center.X + 12f, (float) ((double) this.position.Y + (double) this.height - 6.0)), 20, 10, 64, this.velocity.X * 0.25f, this.velocity.Y * 0.25f, (int) byte.MaxValue); Main.dust[index].velocity *= 0.1f; Main.dust[index].noLight = true; } } else { if (Main.rand.Next(4) == 0) { int index = Dust.NewDust(new Vector2(this.Center.X - 32f, (float) ((double) this.position.Y + (double) this.height - 6.0)), 20, 10, 64, this.velocity.X * 0.25f, this.velocity.Y * 0.25f, (int) byte.MaxValue); Main.dust[index].velocity *= 0.1f; Main.dust[index].noLight = true; } if (Main.rand.Next(4) == 0) { int index = Dust.NewDust(new Vector2(this.Center.X + 2f, (float) ((double) this.position.Y + (double) this.height - 6.0)), 20, 10, 64, this.velocity.X * 0.25f, this.velocity.Y * 0.25f, (int) byte.MaxValue); Main.dust[index].velocity *= 0.1f; Main.dust[index].noLight = true; } } } this.mount.TryBeginningFlight(this, 3); this.mount.UpdateFrame(this, 3, this.velocity); this.mount.TryLanding(this); } else if (this.wet) { this.mount.UpdateFrame(this, 4, this.velocity); } else { this.mount.TryBeginningFlight(this, 2); this.mount.UpdateFrame(this, 2, this.velocity); this.mount.TryLanding(this); } } else this.mount.UpdateFrame(this, this.mount.GetIntendedGroundedFrame(this), this.velocity); } else if (this.legs != 140) { if (this.swimTime > 0) { this.legFrameCounter += 2.0; while (this.legFrameCounter > 8.0) { this.legFrameCounter -= 8.0; this.legFrame.Y += this.legFrame.Height; } if (this.legFrame.Y < this.legFrame.Height * 7) this.legFrame.Y = this.legFrame.Height * 19; else if (this.legFrame.Y > this.legFrame.Height * 19) this.legFrame.Y = this.legFrame.Height * 7; } else if ((double) this.velocity.Y != 0.0 || this.grappling[0] > -1) { this.legFrameCounter = 0.0; this.legFrame.Y = this.legFrame.Height * 5; if ((this.wings == 22 || this.wings == 28 || this.wings == 45) && this.ShouldDrawWingsThatAreAlwaysAnimated()) this.legFrame.Y = 0; } else if ((double) this.velocity.X != 0.0) { if ((this.slippy || this.slippy2 || this.windPushed) && !this.controlLeft && !this.controlRight) { this.legFrameCounter = 0.0; ref Microsoft.Xna.Framework.Rectangle local = ref this.legFrame; Microsoft.Xna.Framework.Rectangle legFrame = this.legFrame; local.Y = 0; } else { this.legFrameCounter += (double) Math.Abs(this.velocity.X) * 1.3; while (this.legFrameCounter > 8.0) { this.legFrameCounter -= 8.0; this.legFrame.Y += this.legFrame.Height; } if (this.legFrame.Y < this.legFrame.Height * 7) this.legFrame.Y = this.legFrame.Height * 19; else if (this.legFrame.Y > this.legFrame.Height * 19) this.legFrame.Y = this.legFrame.Height * 7; } } else { this.legFrameCounter = 0.0; ref Microsoft.Xna.Framework.Rectangle local = ref this.legFrame; Microsoft.Xna.Framework.Rectangle legFrame = this.legFrame; local.Y = 0; } } if (this.carpetFrame >= 0) { this.legFrameCounter = 0.0; ref Microsoft.Xna.Framework.Rectangle local = ref this.legFrame; Microsoft.Xna.Framework.Rectangle legFrame = this.legFrame; local.Y = 0; } if (this.sandStorm) { if (this.grappling[0] >= 0) this.sandStorm = false; if (this.miscCounter % 4 == 0 && this.itemAnimation == 0) { this.ChangeDir(this.direction * -1); if (this.inventory[this.selectedItem].holdStyle == 2) { if (this.inventory[this.selectedItem].type == 946 || this.inventory[this.selectedItem].type == 4707) this.itemLocation.X = this.position.X + (float) this.width * 0.5f - (float) (16 * this.direction); if (this.inventory[this.selectedItem].type == 186) { this.itemLocation.X = this.position.X + (float) this.width * 0.5f + (float) (6 * this.direction); this.itemRotation = 0.79f * (float) -this.direction; } } } this.legFrameCounter = 0.0; ref Microsoft.Xna.Framework.Rectangle local = ref this.legFrame; Microsoft.Xna.Framework.Rectangle legFrame = this.legFrame; local.Y = 0; } else if (((this.itemAnimation <= 0 ? 0 : (this.inventory[this.selectedItem].useStyle != 10 ? 1 : 0)) & (flag3 ? 1 : 0)) != 0) { if (this.inventory[this.selectedItem].useStyle == 1 || this.inventory[this.selectedItem].type == 0) this.bodyFrame.Y = (double) this.itemAnimation >= (double) this.itemAnimationMax * 0.333 ? ((double) this.itemAnimation >= (double) this.itemAnimationMax * 0.666 ? this.bodyFrame.Height : this.bodyFrame.Height * 2) : this.bodyFrame.Height * 3; else if (this.inventory[this.selectedItem].useStyle == 7) this.bodyFrame.Y = (double) this.itemAnimation <= (double) this.itemAnimationMax * 0.5 ? this.bodyFrame.Height * 2 : this.bodyFrame.Height * 3; else if (this.inventory[this.selectedItem].useStyle == 2) this.bodyFrame.Y = this.bodyFrame.Height * 3; else if (this.inventory[this.selectedItem].useStyle == 11) this.bodyFrame.Y = (double) this.itemAnimation <= (double) this.itemAnimationMax * 0.5 ? ((double) this.itemAnimation <= (double) this.itemAnimationMax * 0.15 ? this.bodyFrame.Height * 2 : this.bodyFrame.Height * 3) : this.bodyFrame.Height * 4; else if (this.inventory[this.selectedItem].useStyle == 9) this.bodyFrame.Y = 0; else if (this.inventory[this.selectedItem].useStyle == 6) { float num6 = (float) (1.0 - (double) this.itemAnimation / (double) this.itemAnimationMax) * 6f; if ((double) num6 > 1.0) num6 = 1f; this.bodyFrame.Y = (double) num6 < 0.5 ? this.bodyFrame.Height * 2 : this.bodyFrame.Height * 3; } else if (this.inventory[this.selectedItem].useStyle == 3) this.bodyFrame.Y = (double) this.itemAnimation <= (double) this.itemAnimationMax * 0.666 ? this.bodyFrame.Height * 3 : this.bodyFrame.Height * 3; else if (this.inventory[this.selectedItem].useStyle == 4) this.bodyFrame.Y = this.bodyFrame.Height * 2; else if (this.inventory[this.selectedItem].useStyle == 8) this.bodyFrame.Y = 0; else if (this.inventory[this.selectedItem].useStyle == 12) this.bodyFrame.Y = this.bodyFrame.Height * 3; else if (this.inventory[this.selectedItem].useStyle == 13) this.bodyFrame.Y = (double) this.itemAnimation >= (double) this.itemAnimationMax * 0.333 ? ((double) this.itemAnimation >= (double) this.itemAnimationMax * 0.666 ? this.bodyFrame.Height : this.bodyFrame.Height * 2) : this.bodyFrame.Height * 3; else if (this.inventory[this.selectedItem].useStyle == 5) { if (this.inventory[this.selectedItem].type == 281 || this.inventory[this.selectedItem].type == 986) { this.bodyFrame.Y = this.bodyFrame.Height * 2; } else { double num7 = (double) this.itemRotation * (double) this.direction; this.bodyFrame.Y = this.bodyFrame.Height * 3; if (num7 < -0.75) { this.bodyFrame.Y = this.bodyFrame.Height * 2; if ((double) this.gravDir == -1.0) this.bodyFrame.Y = this.bodyFrame.Height * 4; } if (num7 > 0.6) { this.bodyFrame.Y = this.bodyFrame.Height * 4; if ((double) this.gravDir == -1.0) this.bodyFrame.Y = this.bodyFrame.Height * 2; } } } } else if (this.pulley) this.bodyFrame.Y = this.pulleyDir != (byte) 2 ? this.bodyFrame.Height * 2 : this.bodyFrame.Height; else if (flag2 && this.inventory[this.selectedItem].holdStyle == 1 && (!this.wet || !this.inventory[this.selectedItem].noWet) && (!this.happyFunTorchTime || this.inventory[this.selectedItem].createTile != 4)) this.bodyFrame.Y = this.bodyFrame.Height * 3; else if (flag2 && this.inventory[this.selectedItem].holdStyle == 2 && (!this.wet || !this.inventory[this.selectedItem].noWet)) this.bodyFrame.Y = this.bodyFrame.Height * 2; else if (flag2 && this.inventory[this.selectedItem].holdStyle == 3) this.bodyFrame.Y = this.bodyFrame.Height * 3; else if (flag2 && this.inventory[this.selectedItem].holdStyle == 5) this.bodyFrame.Y = this.bodyFrame.Height * 3; else if (flag2 && this.inventory[this.selectedItem].holdStyle == 4 && (double) this.velocity.Y == 0.0 && (double) this.gravDir == 1.0) { ref Microsoft.Xna.Framework.Rectangle local = ref this.bodyFrame; Microsoft.Xna.Framework.Rectangle bodyFrame = this.bodyFrame; local.Y = 0; } else if (this.shieldRaised) this.bodyFrame.Y = this.bodyFrame.Height * 10; else if (this.mount.Active) { this.bodyFrameCounter = 0.0; this.bodyFrame.Y = this.bodyFrame.Height * this.mount.BodyFrame; } else if (this.grappling[0] >= 0) { this.sandStorm = false; this.CancelAllJumpVisualEffects(); Vector2 vector2 = new Vector2(this.position.X + (float) this.width * 0.5f, this.position.Y + (float) this.height * 0.5f); float num8 = 0.0f; float num9 = 0.0f; for (int index = 0; index < this.grapCount; ++index) { num8 += Main.projectile[this.grappling[index]].position.X + (float) (Main.projectile[this.grappling[index]].width / 2); num9 += Main.projectile[this.grappling[index]].position.Y + (float) (Main.projectile[this.grappling[index]].height / 2); } float num10 = num8 / (float) this.grapCount; float num11 = num9 / (float) this.grapCount; float num12 = num10 - vector2.X; float num13 = num11 - vector2.Y; if ((double) num13 < 0.0 && (double) Math.Abs(num13) > (double) Math.Abs(num12)) { this.bodyFrame.Y = this.bodyFrame.Height * 2; if ((double) this.gravDir == -1.0) this.bodyFrame.Y = this.bodyFrame.Height * 4; } else if ((double) num13 > 0.0 && (double) Math.Abs(num13) > (double) Math.Abs(num12)) { this.bodyFrame.Y = this.bodyFrame.Height * 4; if ((double) this.gravDir == -1.0) this.bodyFrame.Y = this.bodyFrame.Height * 2; } else this.bodyFrame.Y = this.bodyFrame.Height * 3; } else if (this.wet && this.ShouldFloatInWater) this.bodyFrame.Y = this.bodyFrame.Height * 9; else if (this.swimTime > 0) { if (this.swimTime > 20) { ref Microsoft.Xna.Framework.Rectangle local = ref this.bodyFrame; Microsoft.Xna.Framework.Rectangle bodyFrame = this.bodyFrame; local.Y = 0; } else if (this.swimTime > 10) { this.bodyFrame.Y = this.bodyFrame.Height * 5; } else { ref Microsoft.Xna.Framework.Rectangle local = ref this.bodyFrame; Microsoft.Xna.Framework.Rectangle bodyFrame = this.bodyFrame; local.Y = 0; } } else if ((double) this.velocity.Y != 0.0) { this.bodyFrame.Y = !this.sliding ? (this.sandStorm || this.carpetFrame >= 0 ? this.bodyFrame.Height * 6 : (this.eocDash <= 0 ? (this.wings <= 0 ? this.bodyFrame.Height * 5 : (this.wings == 22 || this.wings == 28 || this.wings == 45 ? 0 : ((double) this.velocity.Y <= 0.0 ? this.bodyFrame.Height * 6 : (!this.controlJump ? this.bodyFrame.Height * 5 : this.bodyFrame.Height * 6)))) : this.bodyFrame.Height * 6)) : this.bodyFrame.Height * 3; this.bodyFrameCounter = 0.0; } else if ((double) this.velocity.X != 0.0) { if (this.legs == 140) { this.bodyFrameCounter += (double) Math.Abs(this.velocity.X) * 0.5; while (this.bodyFrameCounter > 8.0) { this.bodyFrameCounter -= 8.0; this.bodyFrame.Y += this.bodyFrame.Height; } if (this.bodyFrame.Y < this.bodyFrame.Height * 7) this.bodyFrame.Y = this.bodyFrame.Height * 19; else if (this.bodyFrame.Y > this.bodyFrame.Height * 19) this.bodyFrame.Y = this.bodyFrame.Height * 7; } else { this.bodyFrameCounter += (double) Math.Abs(this.velocity.X) * 1.5; this.bodyFrame.Y = this.legFrame.Y; } } else { this.bodyFrameCounter = 0.0; ref Microsoft.Xna.Framework.Rectangle local = ref this.bodyFrame; Microsoft.Xna.Framework.Rectangle bodyFrame = this.bodyFrame; local.Y = 0; } if (this.legs == 140) { this.legFrameCounter = 0.0; this.legFrame.Y = this.legFrame.Height * ((double) this.velocity.Y != 0.0).ToInt(); int index = this.bodyFrame.Y / this.bodyFrame.Height; if ((double) Main.OffsetsPlayerHeadgear[index].Y == 0.0) this.legFrame.Y = this.legFrame.Height * 7; if (this.wings == 22 || this.wings == 28) this.legFrame.Y = 0; } if (this.legs == 217 && (this.sitting.isSitting || this.sleeping.isSleeping)) { this.legFrameCounter = 0.0; this.legFrame.Y = this.legFrame.Height * 5; } if (this.head != 259 || this.skipAnimatingValuesInPlayerFrame) return; this.rabbitOrderFrame.Update(); } private void CancelAllJumpVisualEffects() { this.isPerformingJump_Cloud = false; this.isPerformingJump_Sandstorm = false; this.isPerformingJump_Blizzard = false; this.isPerformingJump_Fart = false; this.isPerformingJump_Sail = false; this.isPerformingJump_Unicorn = false; this.isPerformingJump_Santank = false; } private void UpdateVisibleAccessories() { for (int index = 3; index < 10; ++index) { if (this.IsAValidEquipmentSlotForIteration(index)) { Item obj = this.armor[index]; if (obj.shieldSlot == (sbyte) 5 && this.eocDash > 0 && this.shield == (sbyte) -1) this.shield = obj.shieldSlot; if (this.shieldRaised && this.shield == (sbyte) -1 && obj.shieldSlot != (sbyte) -1) this.shield = obj.shieldSlot; if (!this.ItemIsVisuallyIncompatible(obj)) { if (obj.wingSlot > (sbyte) 0) { if (!this.hideVisibleAccessory[index] || (double) this.velocity.Y != 0.0 && !this.mount.Active) this.wings = (int) obj.wingSlot; else continue; } if (!this.hideVisibleAccessory[index]) this.UpdateVisibleAccessory(index, obj); } } } for (int index = 13; index < 20; ++index) { if (this.IsAValidEquipmentSlotForIteration(index)) { Item obj = this.armor[index]; if (!this.ItemIsVisuallyIncompatible(obj)) this.UpdateVisibleAccessory(index, obj); } } if (this.HeldItem.type != 4760 || this.ownedProjectileCounts[866] >= 1) return; this.shield = (sbyte) 9; this.cShield = 0; } private bool ItemIsVisuallyIncompatible(Item item) => this.shield > (sbyte) 0 && this.IsVisibleCapeBad((int) item.frontSlot) || this.compositeBackArm.enabled && item.shieldSlot > (sbyte) 0 || item.shieldSlot > (sbyte) 0 && ItemID.Sets.IsFood[this.HeldItem.type] || this.IsVisibleCapeBad((int) this.front) && item.shieldSlot > (sbyte) 0 || (this.legs == 106 || this.legs == 143 || this.legs == 217) && item.shoeSlot == (sbyte) 15; private bool IsVisibleCapeBad(int accFrontSlot) { switch (accFrontSlot) { case 1: case 2: case 3: case 4: case 5: case 8: return true; default: return false; } } private void UpdateVisibleAccessory(int itemSlot, Item item) { if (item.stringColor > 0) this.stringColor = item.stringColor; if (item.handOnSlot > (sbyte) 0) this.handon = item.handOnSlot; if (item.handOffSlot > (sbyte) 0) this.handoff = item.handOffSlot; if (item.backSlot > (sbyte) 0 && !this.sitting.isSitting) { this.back = item.backSlot; this.front = (sbyte) -1; } if (item.frontSlot > (sbyte) 0) this.front = item.frontSlot; if (item.shoeSlot > (sbyte) 0) this.shoe = item.shoeSlot; if (item.waistSlot > (sbyte) 0) this.waist = item.waistSlot; if (item.shieldSlot > (sbyte) 0) this.shield = item.shieldSlot; if (item.neckSlot > (sbyte) 0) this.neck = item.neckSlot; if (item.faceSlot > (sbyte) 0) this.face = item.faceSlot; if (item.balloonSlot > (sbyte) 0) this.balloon = item.balloonSlot; if (item.wingSlot > (sbyte) 0) this.wings = (int) item.wingSlot; if (item.type == 3580) this.yoraiz0rEye = itemSlot - 2; if (item.type == 3581) this.yoraiz0rDarkness = true; if (item.type == 3929) this.leinforsHair = true; if (item.type == 4404) this.hasFloatingTube = true; if (item.type != 4563) return; this.hasUnicornHorn = true; } public void SetArmorEffectVisuals(Player drawPlayer) { if (drawPlayer.head == 111 && drawPlayer.body == 73 && drawPlayer.legs == 62) { this.armorEffectDrawShadowSubtle = true; this.armorEffectDrawOutlines = true; } if (drawPlayer.head == 134 && drawPlayer.body == 95 && drawPlayer.legs == 79) { this.armorEffectDrawShadowSubtle = true; this.armorEffectDrawOutlines = true; } if (drawPlayer.head == 107 && drawPlayer.body == 69 && drawPlayer.legs == 58) { this.armorEffectDrawShadowSubtle = true; this.armorEffectDrawShadow = true; } if (drawPlayer.head == 108 && drawPlayer.body == 70 && drawPlayer.legs == 59) { this.armorEffectDrawShadowSubtle = true; this.armorEffectDrawShadow = true; } if (drawPlayer.head == 109 && drawPlayer.body == 71 && drawPlayer.legs == 60) { this.armorEffectDrawShadowSubtle = true; this.armorEffectDrawShadow = true; } if (drawPlayer.head == 110 && drawPlayer.body == 72 && drawPlayer.legs == 61) { this.armorEffectDrawShadowSubtle = true; this.armorEffectDrawShadow = true; } if (drawPlayer.head == 193 && drawPlayer.body == 194 && drawPlayer.legs == 134) { this.armorEffectDrawShadowSubtle = true; this.armorEffectDrawShadowLokis = true; this.armorEffectDrawOutlines = true; } if (drawPlayer.mount.Active && drawPlayer.mount.Type == 3 && (double) drawPlayer.velocity.Y != 0.0 && !drawPlayer.SlimeDontHyperJump) this.armorEffectDrawShadow = true; if (drawPlayer.mount.Active && drawPlayer.mount.Type == 10 && (double) Math.Abs(drawPlayer.velocity.X) > (double) drawPlayer.mount.DashSpeed - (double) drawPlayer.mount.RunSpeed / 2.0) this.armorEffectDrawShadow = true; if (drawPlayer.mount.Active && drawPlayer.mount.Type == 44 && (double) Math.Abs(drawPlayer.velocity.X) > (double) drawPlayer.mount.DashSpeed - (double) drawPlayer.mount.RunSpeed / 4.0) this.armorEffectDrawShadow = true; if (drawPlayer.mount.Active && drawPlayer.mount.Type == 45 && (double) Math.Abs(drawPlayer.velocity.X) > (double) drawPlayer.mount.DashSpeed * 0.899999976158142) this.armorEffectDrawShadow = true; if (drawPlayer.mount.Active && drawPlayer.mount.Type == 14 && (double) Math.Abs(drawPlayer.velocity.X) > (double) drawPlayer.mount.RunSpeed / 2.0) this.armorEffectDrawShadowBasilisk = true; if (drawPlayer.mount.Active && drawPlayer.mount.Type == 48) { this.armorEffectDrawOutlines = true; this.armorEffectDrawShadow = true; } if (drawPlayer.body == 67 && drawPlayer.legs == 56 && drawPlayer.head >= 103 && drawPlayer.head <= 105) this.armorEffectDrawShadow = true; if ((drawPlayer.head == 78 || drawPlayer.head == 79 || drawPlayer.head == 80) && drawPlayer.body == 51 && drawPlayer.legs == 47) this.armorEffectDrawShadowSubtle = true; if (drawPlayer.head == 200 && drawPlayer.body == 198 && drawPlayer.legs == 142) { this.armorEffectDrawShadowLokis = true; this.armorEffectDrawOutlinesForbidden = true; } if (drawPlayer.head == 171 && drawPlayer.body == 177 && drawPlayer.legs == 112) { this.armorEffectDrawShadow = true; this.armorEffectDrawOutlines = true; } if (drawPlayer.head == 169 && drawPlayer.body == 175 && drawPlayer.legs == 110) this.armorEffectDrawShadow = true; if (drawPlayer.head == 170 && drawPlayer.body == 176 && drawPlayer.legs == 111) { this.armorEffectDrawShadowLokis = true; this.armorEffectDrawOutlines = true; } if (drawPlayer.body == 209 && drawPlayer.legs == 159) this.armorEffectDrawShadow = true; if (drawPlayer.eocDash > 0) this.armorEffectDrawShadowEOCShield = true; else if (drawPlayer.dashDelay < 0) this.armorEffectDrawShadow = true; if (drawPlayer.head == 5 && drawPlayer.body == 5 && drawPlayer.legs == 5) this.armorEffectDrawShadow = true; if (drawPlayer.head == 74 && drawPlayer.body == 48 && drawPlayer.legs == 44) this.armorEffectDrawShadow = true; if (drawPlayer.head == 76 && drawPlayer.body == 49 && drawPlayer.legs == 45) this.armorEffectDrawShadow = true; if (drawPlayer.head == 7 && drawPlayer.body == 7 && drawPlayer.legs == 7) this.armorEffectDrawShadow = true; if (drawPlayer.head == 22 && drawPlayer.body == 14 && drawPlayer.legs == 14) this.armorEffectDrawShadow = true; if (drawPlayer.dye[0].dye == (byte) 30 && drawPlayer.dye[1].dye == (byte) 30 && drawPlayer.dye[2].dye == (byte) 30 && drawPlayer.head == 4 && drawPlayer.body == 27 && drawPlayer.legs == 26) { this.armorEffectDrawShadow = true; this.armorEffectDrawOutlines = true; } if (drawPlayer.head == 189 && drawPlayer.body == 190 && drawPlayer.legs == 130) this.armorEffectDrawOutlines = true; if (drawPlayer.body == 17 && drawPlayer.legs == 16 && (drawPlayer.head == 29 || drawPlayer.head == 30 || drawPlayer.head == 31)) this.armorEffectDrawShadow = true; if (drawPlayer.body == 19 && drawPlayer.legs == 18 && (drawPlayer.head == 35 || drawPlayer.head == 36 || drawPlayer.head == 37)) this.armorEffectDrawOutlines = true; if ((drawPlayer.body == 24 || drawPlayer.body == 229) && (drawPlayer.legs == 23 || drawPlayer.legs == 212) && (drawPlayer.head == 43 || drawPlayer.head == 41 || drawPlayer.head == 42 || drawPlayer.head == 254 || drawPlayer.head == (int) byte.MaxValue || drawPlayer.head == 256 || drawPlayer.head == 257 || drawPlayer.head == 258)) { this.armorEffectDrawOutlines = true; this.armorEffectDrawShadow = true; } if (drawPlayer.head == 157 && drawPlayer.legs == 98 && drawPlayer.body != 105) { int body = drawPlayer.body; } if (drawPlayer.body == 36 && drawPlayer.head == 56) this.armorEffectDrawOutlines = true; if (!drawPlayer.stoned && (double) drawPlayer.stealth == 1.0) return; this.armorEffectDrawOutlines = false; this.armorEffectDrawShadow = false; this.armorEffectDrawShadowSubtle = false; } public static int SetMatch(int armorslot, int type, bool male, ref bool somethingSpecial) { int num = -1; if (armorslot == 0 && type == 201) num = male ? 201 : 202; if (armorslot == 1) { switch (type) { case 15: num = 88; break; case 36: num = 89; break; case 41: num = 97; break; case 42: num = 90; break; case 58: num = 91; break; case 59: num = 92; break; case 60: num = 93; break; case 61: num = 94; break; case 62: num = 95; break; case 63: num = 96; break; case 77: num = 121; break; case 81: num = 169; break; case 88: num = 168; break; case 89: num = 186; break; case 90: num = 166; break; case 93: num = 165; break; case 165: num = !male ? 99 : 118; break; case 166: num = !male ? 100 : 119; break; case 167: num = male ? 101 : 102; break; case 180: num = 115; break; case 181: num = 116; break; case 183: num = male ? 136 : 123; break; case 191: num = 131; break; case 213: num = 187; break; case 215: num = 189; break; case 219: num = 196; break; case 221: num = 199; break; case 223: num = 204; break; case 231: num = 214; break; case 232: num = 215; break; case 233: num = 216; break; } if (num != -1) somethingSpecial = true; } if (armorslot == 2) { switch (type) { case 57: if (male) { num = 137; break; } break; case 83: if (male) { num = 117; break; } break; case 84: if (male) { num = 120; break; } break; case 132: if (male) { num = 135; break; } break; case 146: num = male ? 146 : 147; break; case 154: num = male ? 155 : 154; break; case 158: if (male) { num = 157; break; } break; case 180: if (!male) { num = 179; break; } break; case 184: if (!male) { num = 183; break; } break; case 191: if (!male) { num = 192; break; } break; case 193: if (!male) { num = 194; break; } break; case 197: if (!male) { num = 198; break; } break; case 203: if (!male) { num = 202; break; } break; case 208: if (!male) { num = 207; break; } break; } } return num; } public void Teleport(Vector2 newPos, int Style = 0, int extraInfo = 0) { try { this._funkytownAchievementCheckCooldown = 100; if (Style != 10) this.RemoveAllGrapplingHooks(); this.StopVanityActions(); int extraInfo1 = 0; if (Style == 4) extraInfo1 = this.lastPortalColorIndex; if (Style == 9) { this.lastTeleportPylonStyleUsed = extraInfo; extraInfo1 = this.lastTeleportPylonStyleUsed; } float dustCountMult = MathHelper.Clamp((float) (1.0 - (double) this.teleportTime * 0.990000009536743), 0.01f, 1f); Vector2 position = this.position; Main.TeleportEffect(this.getRect(), Style, extraInfo1, dustCountMult, otherPosition: newPos); float num = Vector2.Distance(this.position, newPos); PressurePlateHelper.UpdatePlayerPosition(this); this.position = newPos; if (Style == 8) { SoundEngine.PlaySound(SoundID.Item6, position); SoundEngine.PlaySound(SoundID.Item6, newPos); } this.fallStart = (int) ((double) this.position.Y / 16.0); if (this.whoAmI == Main.myPlayer) { bool flag = false; if ((double) num < (double) new Vector2((float) Main.screenWidth, (float) Main.screenHeight).Length() / 2.0 + 100.0) { int time = 0; if (Style == 1) time = 10; Main.SetCameraLerp(0.1f, time); flag = true; } else { NPC.ResetNetOffsets(); Main.BlackFadeIn = (int) byte.MaxValue; Lighting.Clear(); Main.screenLastPosition = Main.screenPosition; Main.screenPosition.X = this.position.X + (float) (this.width / 2) - (float) (Main.screenWidth / 2); Main.screenPosition.Y = this.position.Y + (float) (this.height / 2) - (float) (Main.screenHeight / 2); Main.instantBGTransitionCounter = 10; } if ((double) dustCountMult > 0.100000001490116 || !flag || Style != 0) { if (Main.mapTime < 5) Main.mapTime = 5; Main.maxQ = true; Main.renderNow = true; } } if (Style == 4) { this.lastPortalColorIndex = extraInfo; extraInfo1 = this.lastPortalColorIndex; this.portalPhysicsFlag = true; this.gravity = 0.0f; } PressurePlateHelper.UpdatePlayerPosition(this); this.ResetAdvancedShadows(); for (int index = 0; index < 3; ++index) this.UpdateSocialShadow(); this.oldPosition = this.position + this.BlehOldPositionFixer; Main.TeleportEffect(this.getRect(), Style, extraInfo1, dustCountMult, TeleportationSide.Exit, position); this.teleportTime = 1f; this.teleportStyle = Style; } catch { } } public void DoPotionOfReturnTeleportationAndSetTheComebackPoint() { this.RemoveAllGrapplingHooks(); this.PotionOfReturnOriginalUsePosition = new Vector2?(this.Bottom); bool immune = this.immune; int immuneTime = this.immuneTime; this.StopVanityActions(false); this.Spawn(PlayerSpawnContext.RecallFromItem); this.PotionOfReturnHomePosition = new Vector2?(this.Bottom); NetMessage.SendData(13, number: this.whoAmI); this.immune = immune; this.immuneTime = immuneTime; } public void DoPotionOfReturnReturnToOriginalUsePosition() { if (!this.PotionOfReturnOriginalUsePosition.HasValue) return; Vector2 newPos = this.PotionOfReturnOriginalUsePosition.Value + this.Size * new Vector2(-0.5f, -1f); int num = 8; this.Teleport(newPos, num); NetMessage.SendData(65, number2: ((float) this.whoAmI), number3: newPos.X, number4: newPos.Y, number5: num); this.PotionOfReturnOriginalUsePosition = new Vector2?(); this.PotionOfReturnHomePosition = new Vector2?(); } public void AutoFinchStaff() { int index = this.FindItem(4281); if (index == -1) return; this.AddBuff(this.inventory[index].buffType, 3600); } public void Spawn(PlayerSpawnContext context) { Main.LocalPlayer.creativeInterface = false; this._funkytownAchievementCheckCooldown = 100; bool flag1 = false; if (context == PlayerSpawnContext.SpawningIntoWorld && this.dead) { Player.AdjustRespawnTimerForWorldJoining(this); if (this.dead) flag1 = true; } this.StopVanityActions(); if (this.whoAmI == Main.myPlayer) Main.NotifyOfEvent(GameNotificationType.SpawnOrDeath); if (this.whoAmI == Main.myPlayer) { if (Main.mapTime < 5) Main.mapTime = 5; Main.instantBGTransitionCounter = 10; this.FindSpawn(); if (!Player.CheckSpawn(this.SpawnX, this.SpawnY)) { this.SpawnX = -1; this.SpawnY = -1; } Main.maxQ = true; NPC.ResetNetOffsets(); } if (Main.netMode == 1 && this.whoAmI == Main.myPlayer) NetMessage.SendData(12, number: Main.myPlayer, number2: ((float) (byte) context)); if (this.whoAmI == Main.myPlayer && context == PlayerSpawnContext.SpawningIntoWorld) { this.SetPlayerDataToOutOfClassFields(); Main.ReleaseHostAndPlayProcess(); } this.headPosition = Vector2.Zero; this.bodyPosition = Vector2.Zero; this.legPosition = Vector2.Zero; this.headRotation = 0.0f; this.bodyRotation = 0.0f; this.legRotation = 0.0f; this.rabbitOrderFrame.Reset(); this.lavaTime = this.lavaMax; if (!flag1) { if (this.statLife <= 0) { int num = this.statLifeMax2 / 2; this.statLife = 100; if (num > this.statLife) this.statLife = num; this.breath = this.breathMax; if (this.spawnMax) { this.statLife = this.statLifeMax2; this.statMana = this.statManaMax2; } } this.immune = true; this.dead = false; this.immuneTime = 0; } this.active = true; Vector2 position = this.position; if (this.SpawnX >= 0 && this.SpawnY >= 0) { int spawnX = this.SpawnX; int spawnY = this.SpawnY; this.Spawn_SetPosition(this.SpawnX, this.SpawnY); } else this.Spawn_SetPositionAtWorldSpawn(); this.wet = false; this.wetCount = (byte) 0; this.lavaWet = false; this.fallStart = (int) ((double) this.position.Y / 16.0); this.fallStart2 = this.fallStart; this.velocity.X = 0.0f; this.velocity.Y = 0.0f; this.ResetAdvancedShadows(); for (int index = 0; index < 3; ++index) this.UpdateSocialShadow(); this.oldPosition = this.position + this.BlehOldPositionFixer; this.SetTalkNPC(-1); if (this.whoAmI == Main.myPlayer) Main.npcChatCornerItem = 0; if (!flag1) { if (this.pvpDeath) { this.pvpDeath = false; this.immuneTime = 300; this.statLife = this.statLifeMax; } else this.immuneTime = 60; if (this.immuneTime > 0 && !this.hostile) this.immuneNoBlink = true; } if (this.whoAmI == Main.myPlayer) { if (context == PlayerSpawnContext.SpawningIntoWorld) Main.LocalGolfState.SetScoreTime(); bool flag2 = (double) Vector2.Distance(position, this.position) < (double) new Vector2((float) Main.screenWidth, (float) Main.screenHeight).Length() / 2.0 + 100.0; if (flag2) { Main.SetCameraLerp(0.1f, 0); flag2 = true; } else { Main.BlackFadeIn = (int) byte.MaxValue; Lighting.Clear(); Main.screenLastPosition = Main.screenPosition; Main.instantBGTransitionCounter = 10; } if (!flag2) Main.renderNow = true; if (Main.netMode == 1) Netplay.AddCurrentServerToRecentList(); if (!flag2) { Main.screenPosition.X = this.position.X + (float) (this.width / 2) - (float) (Main.screenWidth / 2); Main.screenPosition.Y = this.position.Y + (float) (this.height / 2) - (float) (Main.screenHeight / 2); } } if (flag1) this.immuneAlpha = (int) byte.MaxValue; this.UpdateGraveyard(true); if (this.whoAmI != Main.myPlayer || context != PlayerSpawnContext.ReviveFromDeath || this.difficulty != (byte) 3) return; this.AutoFinchStaff(); } private void Spawn_SetPositionAtWorldSpawn() { int spawnTileX = Main.spawnTileX; int spawnTileY = Main.spawnTileY; if (!this.Spawn_IsAreaAValidWorldSpawn(spawnTileX, spawnTileY)) { bool flag = false; if (!flag) { for (int index = 0; index < 30; ++index) { if (this.Spawn_IsAreaAValidWorldSpawn(spawnTileX, spawnTileY - index)) { spawnTileY -= index; flag = true; break; } } } if (!flag) { for (int index = 0; index < 30; ++index) { if (this.Spawn_IsAreaAValidWorldSpawn(spawnTileX, spawnTileY - index)) { spawnTileY -= index; flag = true; break; } } } if (flag) { this.Spawn_SetPosition(spawnTileX, spawnTileY); } else { this.Spawn_SetPosition(Main.spawnTileX, Main.spawnTileY); if (this.Spawn_IsAreaAValidWorldSpawn(Main.spawnTileX, Main.spawnTileY)) return; Player.Spawn_ForceClearArea(Main.spawnTileX, Main.spawnTileY); } } else { int floorY = Player.Spawn_DescendFromDefaultSpace(spawnTileX, spawnTileY); this.Spawn_SetPosition(spawnTileX, floorY); if (this.Spawn_IsAreaAValidWorldSpawn(spawnTileX, floorY)) return; Player.Spawn_ForceClearArea(spawnTileX, floorY); } } private static int Spawn_DescendFromDefaultSpace(int x, int y) { for (int index1 = 0; index1 < 50; ++index1) { bool flag = false; for (int index2 = -1; index2 <= 1; ++index2) { Tile tile = Main.tile[x + index2, y + index1]; if (tile.nactive() && (Main.tileSolid[(int) tile.type] || !Main.tileSolidTop[(int) tile.type])) { flag = true; break; } } if (flag) { y += index1; break; } } return y; } private static void Spawn_ForceClearArea(int floorX, int floorY) { for (int i = floorX - 1; i < floorX + 2; ++i) { for (int j = floorY - 3; j < floorY; ++j) { if (Main.tile[i, j] != null) { if (Main.tile[i, j].nactive() && Main.tileSolid[(int) Main.tile[i, j].type] && !Main.tileSolidTop[(int) Main.tile[i, j].type]) WorldGen.KillTile(i, j); if (Main.tile[i, j].liquid > (byte) 0) { Main.tile[i, j].lava(false); Main.tile[i, j].liquid = (byte) 0; WorldGen.SquareTileFrame(i, j); } } } } } private bool Spawn_IsAreaAValidWorldSpawn(int floorX, int floorY) { for (int index1 = floorX - 1; index1 < floorX + 2; ++index1) { for (int index2 = floorY - 3; index2 < floorY; ++index2) { if (Main.tile[index1, index2] != null && (Main.tile[index1, index2].nactive() && Main.tileSolid[(int) Main.tile[index1, index2].type] && !Main.tileSolidTop[(int) Main.tile[index1, index2].type] || Main.tile[index1, index2].liquid > (byte) 0)) return false; } } return true; } private void Spawn_SetPosition(int floorX, int floorY) { this.position.X = (float) (floorX * 16 + 8 - this.width / 2); this.position.Y = (float) (floorY * 16 - this.height); } public void SetImmuneTimeForAllTypes(int time) { this.immune = true; this.immuneTime = time; for (int index = 0; index < this.hurtCooldowns.Length; ++index) this.hurtCooldowns[index] = time; } public void ShadowDodge() { this.SetImmuneTimeForAllTypes(this.longInvince ? 120 : 80); if (this.whoAmI != Main.myPlayer) return; for (int b = 0; b < 22; ++b) { if (this.buffTime[b] > 0 && this.buffType[b] == 59) this.DelBuff(b); } NetMessage.SendData(62, number: this.whoAmI, number2: 2f); } public void BrainOfConfusionDodge() { this.SetImmuneTimeForAllTypes(this.longInvince ? 120 : 80); this.brainOfConfusionDodgeAnimationCounter = 300; if (this.whoAmI != Main.myPlayer) return; this.AddBuff(321, 300, false); NetMessage.SendData(62, number: this.whoAmI, number2: 4f); } public void NinjaDodge() { this.SetImmuneTimeForAllTypes(this.longInvince ? 120 : 80); for (int index1 = 0; index1 < 100; ++index1) { int index2 = Dust.NewDust(new Vector2(this.position.X, this.position.Y), this.width, this.height, 31, Alpha: 100, Scale: 2f); Main.dust[index2].position.X += (float) Main.rand.Next(-20, 21); Main.dust[index2].position.Y += (float) Main.rand.Next(-20, 21); Main.dust[index2].velocity *= 0.4f; Main.dust[index2].scale *= (float) (1.0 + (double) Main.rand.Next(40) * 0.00999999977648258); Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(this.cWaist, this); if (Main.rand.Next(2) == 0) { Main.dust[index2].scale *= (float) (1.0 + (double) Main.rand.Next(40) * 0.00999999977648258); Main.dust[index2].noGravity = true; } } int index3 = Gore.NewGore(new Vector2((float) ((double) this.position.X + (double) (this.width / 2) - 24.0), (float) ((double) this.position.Y + (double) (this.height / 2) - 24.0)), new Vector2(), Main.rand.Next(61, 64)); Main.gore[index3].scale = 1.5f; Main.gore[index3].velocity.X = (float) Main.rand.Next(-50, 51) * 0.01f; Main.gore[index3].velocity.Y = (float) Main.rand.Next(-50, 51) * 0.01f; Main.gore[index3].velocity *= 0.4f; int index4 = Gore.NewGore(new Vector2((float) ((double) this.position.X + (double) (this.width / 2) - 24.0), (float) ((double) this.position.Y + (double) (this.height / 2) - 24.0)), new Vector2(), Main.rand.Next(61, 64)); Main.gore[index4].scale = 1.5f; Main.gore[index4].velocity.X = (float) (1.5 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.gore[index4].velocity.Y = (float) (1.5 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.gore[index4].velocity *= 0.4f; int index5 = Gore.NewGore(new Vector2((float) ((double) this.position.X + (double) (this.width / 2) - 24.0), (float) ((double) this.position.Y + (double) (this.height / 2) - 24.0)), new Vector2(), Main.rand.Next(61, 64)); Main.gore[index5].scale = 1.5f; Main.gore[index5].velocity.X = (float) (-1.5 - (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.gore[index5].velocity.Y = (float) (1.5 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.gore[index5].velocity *= 0.4f; int index6 = Gore.NewGore(new Vector2((float) ((double) this.position.X + (double) (this.width / 2) - 24.0), (float) ((double) this.position.Y + (double) (this.height / 2) - 24.0)), new Vector2(), Main.rand.Next(61, 64)); Main.gore[index6].scale = 1.5f; Main.gore[index6].velocity.X = (float) (1.5 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.gore[index6].velocity.Y = (float) (-1.5 - (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.gore[index6].velocity *= 0.4f; int index7 = Gore.NewGore(new Vector2((float) ((double) this.position.X + (double) (this.width / 2) - 24.0), (float) ((double) this.position.Y + (double) (this.height / 2) - 24.0)), new Vector2(), Main.rand.Next(61, 64)); Main.gore[index7].scale = 1.5f; Main.gore[index7].velocity.X = (float) (-1.5 - (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.gore[index7].velocity.Y = (float) (-1.5 - (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.gore[index7].velocity *= 0.4f; if (this.whoAmI != Main.myPlayer) return; NetMessage.SendData(62, number: this.whoAmI, number2: 1f); } public void ApplyArmorSoundAndDustChanges() { int num1 = this.armor[0].headSlot; int num2 = this.armor[1].bodySlot; int num3 = this.armor[2].legSlot; if (this.armor[10].headSlot >= 0) num1 = this.armor[10].headSlot; if (this.armor[11].bodySlot >= 0) num2 = this.armor[11].bodySlot; if (this.armor[12].legSlot >= 0) num3 = this.armor[12].legSlot; if ((this.wereWolf || this.forceWerewolf) && !this.hideWolf) { num3 = 20; num2 = 21; num1 = 38; } if ((num1 == 75 || num1 == 7) && num2 == 7 && num3 == 7) this.boneArmor = true; if (num2 != 27 || num1 != 46 || num3 != 26) return; this.frostArmor = true; } public double Hurt( PlayerDeathReason damageSource, int Damage, int hitDirection, bool pvp = false, bool quiet = false, bool Crit = false, int cooldownCounter = -1) { if (this.creativeGodMode) return 0.0; bool flag1 = !this.immune; bool flag2 = false; int hitContext = cooldownCounter; if (cooldownCounter == 0) flag1 = this.hurtCooldowns[cooldownCounter] <= 0; if (cooldownCounter == 1) flag1 = this.hurtCooldowns[cooldownCounter] <= 0; if (cooldownCounter == 2) { flag2 = true; cooldownCounter = -1; } if (cooldownCounter == 3) flag1 = this.hurtCooldowns[cooldownCounter] <= 0; if (!flag1) return 0.0; if (this.whoAmI == Main.myPlayer && this.blackBelt && Main.rand.Next(10) == 0) { this.NinjaDodge(); return 0.0; } if (this.whoAmI == Main.myPlayer && this.brainOfConfusion && Main.rand.Next(6) == 0 && this.FindBuffIndex(321) == -1) { this.BrainOfConfusionDodge(); return 0.0; } if (this.whoAmI == Main.myPlayer && this.shadowDodge) { this.ShadowDodge(); return 0.0; } if (this.whoAmI == Main.myPlayer && this.panic) this.AddBuff(63, 300); if (this.whoAmI == Main.myPlayer && this.setSquireT2) this.AddBuff(205, 300); this.stealth = 1f; if (Main.netMode == 1) NetMessage.SendData(84, number: this.whoAmI); int Damage1 = Damage; double dmg = Main.CalculateDamagePlayersTake(Damage1, this.statDefense); if (Crit) Damage1 *= 2; if (dmg >= 1.0) { if (this.whoAmI == Main.myPlayer) { Main.NotifyOfEvent(GameNotificationType.Damage); if (this.hasFootball) { for (int index = 0; index < 59; ++index) { if ((this.inventory[index].stack <= 0 ? 0 : (this.inventory[index].type == 4743 ? 1 : 0)) != 0) { Projectile.NewProjectile(this.Center, new Vector2((float) (-hitDirection * 4), -6f), 861, 0, 0.0f, this.whoAmI, ai1: 1f); this.inventory[index].SetDefaults(); if (index == 58) Main.mouseItem = new Item(); } } } } if (this.inventory[this.selectedItem].type == 4790 || this.inventory[this.selectedItem].type == 4788 || this.inventory[this.selectedItem].type == 4789) { for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI && (Main.projectile[index].type == 879 || Main.projectile[index].type == 877 || Main.projectile[index].type == 878)) Main.projectile[index].active = false; } } if (this.invis) { for (int b = 0; b < 22; ++b) { if (this.buffType[b] == 10) this.DelBuff(b); } } dmg = (double) (int) ((1.0 - (double) this.endurance) * dmg); if (dmg < 1.0) dmg = 1.0; if (this.ConsumeSolarFlare()) { dmg = (double) (int) ((1.0 - 0.200000002980232) * dmg); if (dmg < 1.0) dmg = 1.0; if (this.whoAmI == Main.myPlayer) { int index = Projectile.NewProjectile(this.Center.X, this.Center.Y, 0.0f, 0.0f, 608, 150, 15f, Main.myPlayer); Main.projectile[index].netUpdate = true; Main.projectile[index].Kill(); } } if (this.beetleDefense && this.beetleOrbs > 0) { dmg = (double) (int) ((1.0 - (double) (0.15f * (float) this.beetleOrbs)) * dmg); --this.beetleOrbs; for (int b = 0; b < 22; ++b) { if (this.buffType[b] >= 95 && this.buffType[b] <= 97) this.DelBuff(b); } if (this.beetleOrbs > 0) this.AddBuff(95 + this.beetleOrbs - 1, 5, false); this.beetleCounter = 0.0f; if (dmg < 1.0) dmg = 1.0; } if (this.magicCuffs) { int manaAmount = Damage1; this.statMana += manaAmount; if (this.statMana > this.statManaMax2) this.statMana = this.statManaMax2; this.ManaEffect(manaAmount); } if (this.defendedByPaladin) { if (this.whoAmI != Main.myPlayer) { if (Main.player[Main.myPlayer].hasPaladinShield) { Player player = Main.player[Main.myPlayer]; if (player.team == this.team && this.team != 0) { float num1 = player.Distance(this.Center); bool flag3 = (double) num1 < 800.0; if (flag3) { for (int index = 0; index < (int) byte.MaxValue; ++index) { if (index != Main.myPlayer && Main.player[index].active && !Main.player[index].dead && !Main.player[index].immune && Main.player[index].hasPaladinShield && Main.player[index].team == this.team && (double) Main.player[index].statLife > (double) Main.player[index].statLifeMax2 * 0.25) { float num2 = Main.player[index].Distance(this.Center); if ((double) num1 > (double) num2 || (double) num1 == (double) num2 && index < Main.myPlayer) { flag3 = false; break; } } } } if (flag3) { int Damage2 = (int) (dmg * 0.25); dmg = (double) (int) (dmg * 0.75); player.Hurt(PlayerDeathReason.LegacyEmpty(), Damage2, 0); } } } } else { bool flag4 = false; for (int index = 0; index < (int) byte.MaxValue; ++index) { if (index != Main.myPlayer && Main.player[index].active && !Main.player[index].dead && !Main.player[index].immune && Main.player[index].hasPaladinShield && Main.player[index].team == this.team && (double) Main.player[index].statLife > (double) Main.player[index].statLifeMax2 * 0.25) { flag4 = true; break; } } if (flag4) dmg = (double) (int) (dmg * 0.75); } } if (this.brainOfConfusion && Main.myPlayer == this.whoAmI) { for (int index = 0; index < 200; ++index) { if (Main.npc[index].active && !Main.npc[index].friendly) { int num3 = 300 + (int) dmg * 2; if (Main.rand.Next(500) < num3) { double num4 = (double) (Main.npc[index].Center - this.Center).Length(); float num5 = (float) Main.rand.Next(200 + (int) dmg / 2, 301 + (int) dmg * 2); if ((double) num5 > 500.0) num5 = (float) (500.0 + ((double) num5 - 500.0) * 0.75); if ((double) num5 > 700.0) num5 = (float) (700.0 + ((double) num5 - 700.0) * 0.5); if ((double) num5 > 900.0) num5 = (float) (900.0 + ((double) num5 - 900.0) * 0.25); double num6 = (double) num5; if (num4 < num6) { float num7 = (float) Main.rand.Next(90 + (int) dmg / 3, 300 + (int) dmg / 2); Main.npc[index].AddBuff(31, (int) num7); } } } } Projectile.NewProjectile(this.Center.X + (float) Main.rand.Next(-40, 40), this.Center.Y - (float) Main.rand.Next(20, 60), this.velocity.X * 0.3f, this.velocity.Y * 0.3f, 565, 0, 0.0f, this.whoAmI); } if (Main.netMode == 1 && this.whoAmI == Main.myPlayer && !quiet) { if (!this.noKnockback && hitDirection != 0 && (!this.mount.Active || !this.mount.Cart)) NetMessage.SendData(13, number: this.whoAmI); NetMessage.SendData(16, number: this.whoAmI); NetMessage.SendPlayerHurt(this.whoAmI, damageSource, Damage, hitDirection, Crit, pvp, hitContext); } CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int) this.position.X, (int) this.position.Y, this.width, this.height), Crit ? CombatText.DamagedFriendlyCrit : CombatText.DamagedFriendly, (int) dmg, Crit); this.statLife -= (int) dmg; switch (cooldownCounter) { case -1: this.immune = true; this.immuneTime = !pvp ? (dmg != 1.0 ? (this.longInvince ? 80 : 40) : (this.longInvince ? 40 : 20)) : 8; break; case 0: this.hurtCooldowns[cooldownCounter] = dmg != 1.0 ? (this.longInvince ? 80 : 40) : (this.longInvince ? 40 : 20); break; case 1: case 3: this.hurtCooldowns[cooldownCounter] = dmg != 1.0 ? (this.longInvince ? 80 : 40) : (this.longInvince ? 40 : 20); break; } this.lifeRegenTime = 0; int? sourceProjectileType = damageSource.SourceProjectileType; if (sourceProjectileType.HasValue && (!ProjectileID.Sets.DismountsPlayersOnHit.IndexInRange(sourceProjectileType.Value) ? 0 : (ProjectileID.Sets.DismountsPlayersOnHit[sourceProjectileType.Value] ? 1 : 0)) != 0) this.mount.Dismount(this); if (this.whoAmI == Main.myPlayer) { if (this.starCloak) { for (int index1 = 0; index1 < 3; ++index1) { float num8 = this.position.X + (float) Main.rand.Next(-400, 400); float num9 = this.position.Y - (float) Main.rand.Next(500, 800); Vector2 vector2 = new Vector2(num8, num9); float num10 = this.position.X + (float) (this.width / 2) - vector2.X; float num11 = this.position.Y + (float) (this.height / 2) - vector2.Y; float num12 = num10 + (float) Main.rand.Next(-100, 101); float num13 = 23f / (float) Math.Sqrt((double) num12 * (double) num12 + (double) num11 * (double) num11); float SpeedX = num12 * num13; float SpeedY = num11 * num13; int Type = 726; if (this.starCloakIsStarVeil) Type = 725; if (this.starCloakIsBeeCloak) Type = 724; if (this.starCloakIsManaCloak) Type = 723; int index2 = Projectile.NewProjectile(num8, num9, SpeedX, SpeedY, Type, 30, 5f, this.whoAmI); Main.projectile[index2].ai[1] = this.position.Y; } } if (this.releaseBeesWhenHurt) { int num = 1; if (Main.rand.Next(3) == 0) ++num; if (Main.rand.Next(3) == 0) ++num; if (this.strongBees && Main.rand.Next(3) == 0) ++num; for (int index = 0; index < num; ++index) Projectile.NewProjectile(this.position.X, this.position.Y, (float) Main.rand.Next(-35, 36) * 0.02f, (float) Main.rand.Next(-35, 36) * 0.02f, this.beeType(), this.beeDamage(7), this.beeKB(0.0f), Main.myPlayer); } } if (flag2 && hitDirection != 0) { if (!this.mount.Active || !this.mount.Cart) { float num14 = 10.5f; float num15 = -7.5f; if (this.noKnockback) { num14 = 2.5f; num15 = -1.5f; } this.StopVanityActions(); this.velocity.X = num14 * (float) hitDirection; this.velocity.Y = num15; this.fallStart = (int) ((double) this.position.Y / 16.0); } } else if (!this.noKnockback && hitDirection != 0 && (!this.mount.Active || !this.mount.Cart)) { this.StopVanityActions(); this.velocity.X = 4.5f * (float) hitDirection; this.velocity.Y = -3.5f; this.fallStart = (int) ((double) this.position.Y / 16.0); } if (this.stoned) SoundEngine.PlaySound(0, (int) this.position.X, (int) this.position.Y); else if ((this.wereWolf || this.forceWerewolf) && !this.hideWolf) SoundEngine.PlaySound(3, (int) this.position.X, (int) this.position.Y, 6); else if (this.frostArmor) SoundEngine.PlaySound(SoundID.Item27, this.position); else if (this.boneArmor) SoundEngine.PlaySound(3, (int) this.position.X, (int) this.position.Y, 2); else if (!this.Male) SoundEngine.PlaySound(20, (int) this.position.X, (int) this.position.Y); else SoundEngine.PlaySound(1, (int) this.position.X, (int) this.position.Y); this.eyeHelper.BlinkBecausePlayerGotHurt(); if (this.statLife > 0) { double num16 = dmg / (double) this.statLifeMax2 * 100.0; float num17 = (float) (2 * hitDirection); float num18 = 0.0f; if (flag2) { num16 *= 12.0; num18 = 6f; } for (int index3 = 0; (double) index3 < num16; ++index3) { if (this.stoned) Dust.NewDust(this.position, this.width, this.height, 1, num17 + (float) hitDirection * num18 * Main.rand.NextFloat(), -2f); else if (this.frostArmor) { int index4 = Dust.NewDust(this.position, this.width, this.height, 135, num17 + (float) hitDirection * num18 * Main.rand.NextFloat(), -2f); Main.dust[index4].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } else if (this.boneArmor) { int index5 = Dust.NewDust(this.position, this.width, this.height, 26, num17 + (float) hitDirection * num18 * Main.rand.NextFloat(), -2f); Main.dust[index5].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } else Dust.NewDust(this.position, this.width, this.height, 5, num17 + (float) hitDirection * num18 * Main.rand.NextFloat(), -2f); } } else { this.statLife = 0; if (this.whoAmI == Main.myPlayer) this.KillMe(damageSource, dmg, hitDirection, pvp); } } if (pvp) dmg = Main.CalculateDamagePlayersTakeInPVP(Damage1, this.statDefense); return dmg; } public void KillMeForGood() { bool isCloudSave = Main.ActivePlayerFileData.IsCloudSave; if (FileUtilities.Exists(Main.playerPathName, isCloudSave)) FileUtilities.Delete(Main.playerPathName, isCloudSave); if (FileUtilities.Exists(Main.playerPathName + ".bak", isCloudSave)) FileUtilities.Delete(Main.playerPathName + ".bak", isCloudSave); Main.ActivePlayerFileData = new PlayerFileData(); } public void KillMe(PlayerDeathReason damageSource, double dmg, int hitDirection, bool pvp = false) { if (this.creativeGodMode || this.dead) return; this.StopVanityActions(); if (pvp) this.pvpDeath = true; if (this.trapDebuffSource) AchievementsHelper.HandleSpecialEvent(this, 4); if (this.whoAmI == Main.myPlayer) Main.NotifyOfEvent(GameNotificationType.SpawnOrDeath); this.lastDeathPostion = this.Center; this.lastDeathTime = DateTime.Now; this.showLastDeath = true; int coinsOwned = (int) Utils.CoinsCount(out bool _, this.inventory); if (Main.myPlayer == this.whoAmI) { this.lostCoins = coinsOwned; this.lostCoinString = Main.ValueToCoins(this.lostCoins); } if (Main.myPlayer == this.whoAmI) Main.mapFullscreen = false; if (Main.myPlayer == this.whoAmI) { this.trashItem.SetDefaults(); if (this.difficulty == (byte) 0 || this.difficulty == (byte) 3) { for (int index = 0; index < 59; ++index) { if ((this.inventory[index].stack <= 0 ? 0 : (this.inventory[index].type < 1522 || this.inventory[index].type > 1527 ? (this.inventory[index].type == 3643 ? 1 : 0) : 1)) != 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, this.inventory[index].type); Main.item[number].netDefaults(this.inventory[index].netID); Main.item[number].Prefix((int) this.inventory[index].prefix); Main.item[number].stack = this.inventory[index].stack; Main.item[number].velocity.Y = (float) Main.rand.Next(-20, 1) * 0.2f; Main.item[number].velocity.X = (float) Main.rand.Next(-20, 21) * 0.2f; Main.item[number].noGrabDelay = 100; Main.item[number].favorited = false; Main.item[number].newAndShiny = false; if (Main.netMode == 1) NetMessage.SendData(21, number: number); this.inventory[index].SetDefaults(); } } } else if (this.difficulty == (byte) 1) this.DropItems(); else if (this.difficulty == (byte) 2) { this.DropItems(); this.KillMeForGood(); } } SoundEngine.PlaySound(5, (int) this.position.X, (int) this.position.Y); this.headVelocity.Y = (float) Main.rand.Next(-40, -10) * 0.1f; this.bodyVelocity.Y = (float) Main.rand.Next(-40, -10) * 0.1f; this.legVelocity.Y = (float) Main.rand.Next(-40, -10) * 0.1f; this.headVelocity.X = (float) Main.rand.Next(-20, 21) * 0.1f + (float) (2 * hitDirection); this.bodyVelocity.X = (float) Main.rand.Next(-20, 21) * 0.1f + (float) (2 * hitDirection); this.legVelocity.X = (float) Main.rand.Next(-20, 21) * 0.1f + (float) (2 * hitDirection); if (this.stoned) { this.headPosition = Vector2.Zero; this.bodyPosition = Vector2.Zero; this.legPosition = Vector2.Zero; } for (int index1 = 0; index1 < 100; ++index1) { if (this.stoned) Dust.NewDust(this.position, this.width, this.height, 1, (float) (2 * hitDirection), -2f); else if (this.frostArmor) { int index2 = Dust.NewDust(this.position, this.width, this.height, 135, (float) (2 * hitDirection), -2f); Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } else if (this.boneArmor) { int index3 = Dust.NewDust(this.position, this.width, this.height, 26, (float) (2 * hitDirection), -2f); Main.dust[index3].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this); } else Dust.NewDust(this.position, this.width, this.height, 5, (float) (2 * hitDirection), -2f); } this.mount.Dismount(this); this.dead = true; this.respawnTimer = 600; bool flag = false; if (Main.netMode != 0 && !pvp) { for (int index = 0; index < 200; ++index) { if (Main.npc[index].active && (Main.npc[index].boss || Main.npc[index].type == 13 || Main.npc[index].type == 14 || Main.npc[index].type == 15) && (double) Math.Abs(this.Center.X - Main.npc[index].Center.X) + (double) Math.Abs(this.Center.Y - Main.npc[index].Center.Y) < 4000.0) { flag = true; break; } } } if (flag) this.respawnTimer += 600; if (Main.expertMode) this.respawnTimer = (int) ((double) this.respawnTimer * 1.5); this.immuneAlpha = 0; if (!ChildSafety.Disabled) this.immuneAlpha = (int) byte.MaxValue; this.palladiumRegen = false; this.iceBarrier = false; this.crystalLeaf = false; NetworkText deathText = damageSource.GetDeathText(this.name); switch (Main.netMode) { case 0: Main.NewText(deathText.ToString(), (byte) 225, (byte) 25, (byte) 25); break; case 2: ChatHelper.BroadcastChatMessage(deathText, new Color(225, 25, 25)); break; } if (Main.netMode == 1 && this.whoAmI == Main.myPlayer) NetMessage.SendPlayerDeath(this.whoAmI, damageSource, (int) dmg, hitDirection, pvp); if (this.whoAmI == Main.myPlayer && (this.difficulty == (byte) 0 || this.difficulty == (byte) 3)) { if (!pvp) { this.DropCoins(); } else { this.lostCoins = 0; this.lostCoinString = Main.ValueToCoins(this.lostCoins); } } this.DropTombstone(coinsOwned, deathText, hitDirection); if (this.whoAmI != Main.myPlayer) return; try { WorldGen.saveToonWhilePlaying(); } catch { } } public void DropTombstone(int coinsOwned, NetworkText deathText, int hitDirection) { if (Main.netMode == 1) return; float num1 = (float) Main.rand.Next(-35, 36) * 0.1f; while ((double) num1 < 2.0 && (double) num1 > -2.0) num1 += (float) Main.rand.Next(-30, 31) * 0.1f; int num2 = Main.rand.Next(6); int Type = coinsOwned <= 100000 ? (num2 != 0 ? 200 + num2 : 43) : Main.rand.Next(5) + 527; int index = Projectile.NewProjectile(this.position.X + (float) (this.width / 2), this.position.Y + (float) (this.height / 2), (float) Main.rand.Next(10, 30) * 0.1f * (float) hitDirection + num1, (float) Main.rand.Next(-40, -20) * 0.1f, Type, 0, 0.0f, Main.myPlayer); DateTime now = DateTime.Now; string str1 = now.ToString("D"); if (GameCulture.FromCultureName(GameCulture.CultureName.English).IsActive) str1 = now.ToString("MMMM d, yyy"); string str2 = deathText.ToString() + "\n" + str1; Main.projectile[index].miscText = str2; } public bool CanPullItem(Item item, Player.ItemSpaceStatus status) => status.CanTakeItem && this.CanAcceptItemIntoInventory(item); public Player.ItemSpaceStatus ItemSpace(Item newItem) { if (ItemID.Sets.IsAPickup[newItem.type]) return new Player.ItemSpaceStatus(true); if (newItem.uniqueStack && this.HasItem(newItem.type)) return new Player.ItemSpaceStatus(false); int num = 50; if (newItem.IsACoin) num = 54; for (int index = 0; index < num; ++index) { if (this.CanItemSlotAccept(this.inventory[index], newItem)) return new Player.ItemSpaceStatus(true); } if (newItem.ammo > 0 && !newItem.notAmmo) { for (int index = 54; index < 58; ++index) { if (this.CanGoIntoAmmoOnPickup(this.inventory[index], newItem)) return new Player.ItemSpaceStatus(true); } } for (int index = 54; index < 58; ++index) { if (this.inventory[index].type > 0 && this.inventory[index].stack < this.inventory[index].maxStack && newItem.IsTheSameAs(this.inventory[index])) return new Player.ItemSpaceStatus(true); } return this.ItemSpaceForCofveve(newItem) ? new Player.ItemSpaceStatus(true, true) : new Player.ItemSpaceStatus(false); } public bool ItemSpaceForCofveve(Item newItem) { if (!this.IsVoidVaultEnabled || !this.CanVoidVaultAccept(newItem)) return false; foreach (Item theSlot in this.bank4.item) { if (this.CanItemSlotAccept(theSlot, newItem)) return true; } return false; } public bool CanItemSlotAccept(Item theSlot, Item theItemToAccept) => theSlot.type == 0 || theSlot.stack < theSlot.maxStack && theItemToAccept.IsTheSameAs(theSlot); public bool CanGoIntoAmmoOnPickup(Item theSlot, Item theItemToAccept) => (theItemToAccept.CanFillEmptyAmmoSlot() || theSlot.type != 0) && this.CanItemSlotAccept(theSlot, theItemToAccept); public void DoCoins(int i) { if (this.inventory[i].stack != 100 || this.inventory[i].type != 71 && this.inventory[i].type != 72 && this.inventory[i].type != 73) return; this.inventory[i].SetDefaults(this.inventory[i].type + 1); for (int i1 = 0; i1 < 54; ++i1) { if (this.inventory[i1].IsTheSameAs(this.inventory[i]) && i1 != i && this.inventory[i1].type == this.inventory[i].type && this.inventory[i1].stack < this.inventory[i1].maxStack) { ++this.inventory[i1].stack; this.inventory[i].SetDefaults(); this.inventory[i].active = false; this.inventory[i].TurnToAir(); this.DoCoins(i1); } } } public Item FillAmmo(int plr, Item newItem, GetItemSettings settings) { Item obj = newItem; for (int i = 54; i < 58; ++i) { if (this.inventory[i].type > 0 && this.inventory[i].stack < this.inventory[i].maxStack && obj.IsTheSameAs(this.inventory[i])) { SoundEngine.PlaySound(7, (int) this.position.X, (int) this.position.Y); if (obj.stack + this.inventory[i].stack <= this.inventory[i].maxStack) { this.inventory[i].stack += obj.stack; if (!settings.NoText) PopupText.NewText(PopupTextContext.RegularItemPickup, newItem, obj.stack); this.DoCoins(i); if (plr == Main.myPlayer) Recipe.FindRecipes(); settings.HandlePostAction(this.inventory[i]); return new Item(); } obj.stack -= this.inventory[i].maxStack - this.inventory[i].stack; if (!settings.NoText) PopupText.NewText(PopupTextContext.RegularItemPickup, newItem, this.inventory[i].maxStack - this.inventory[i].stack); this.inventory[i].stack = this.inventory[i].maxStack; this.DoCoins(i); if (plr == Main.myPlayer) Recipe.FindRecipes(); settings.HandlePostAction(this.inventory[i]); } } if (obj.CanFillEmptyAmmoSlot()) { for (int i = 54; i < 58; ++i) { if (this.inventory[i].type == 0) { this.inventory[i] = obj; if (!settings.NoText) PopupText.NewText(PopupTextContext.RegularItemPickup, newItem, newItem.stack); this.DoCoins(i); SoundEngine.PlaySound(7, (int) this.position.X, (int) this.position.Y); if (plr == Main.myPlayer) Recipe.FindRecipes(); settings.HandlePostAction(this.inventory[i]); return new Item(); } } } return obj; } public Item GetItem(int plr, Item newItem, GetItemSettings settings) { bool isAcoin = newItem.IsACoin; Item obj = newItem; int num1 = 50; if (newItem.noGrabDelay > 0) return obj; int num2 = 0; if (newItem.uniqueStack && this.HasItem(newItem.type)) return obj; if (isAcoin) { num2 = -4; num1 = 54; } if (obj.FitsAmmoSlot()) { obj = this.FillAmmo(plr, obj, settings); if (obj.type == 0 || obj.stack == 0) return new Item(); } for (int index = num2; index < 50; ++index) { int i = index; if (i < 0) i = 54 + index; if (this.GetItem_FillIntoOccupiedSlot(plr, newItem, settings, obj, i)) return new Item(); } if (!isAcoin && newItem.useStyle != 0) { for (int i = 0; i < 10; ++i) { if (this.GetItem_FillEmptyInventorySlot(plr, newItem, settings, obj, i)) return new Item(); } } if (newItem.favorited) { for (int i = 0; i < num1; ++i) { if (this.GetItem_FillEmptyInventorySlot(plr, newItem, settings, obj, i)) return new Item(); } } else { for (int i = num1 - 1; i >= 0; --i) { if (this.GetItem_FillEmptyInventorySlot(plr, newItem, settings, obj, i)) return new Item(); } } return settings.CanGoIntoVoidVault && this.IsVoidVaultEnabled && this.CanVoidVaultAccept(newItem) && this.GetItem_VoidVault(plr, this.bank4.item, newItem, settings, obj) ? new Item() : obj; } private bool GetItem_VoidVault( int plr, Item[] inventory, Item newItem, GetItemSettings settings, Item returnItem) { if (!this.CanVoidVaultAccept(newItem)) return false; for (int i = 0; i < inventory.Length; ++i) { if (this.GetItem_FillIntoOccupiedSlot_VoidBag(plr, inventory, newItem, settings, returnItem, i)) return true; } for (int i = 0; i < inventory.Length; ++i) { if (this.GetItem_FillEmptyInventorySlot_VoidBag(plr, inventory, newItem, settings, returnItem, i)) return true; } return false; } private bool CanVoidVaultAccept(Item item) => !item.questItem && item.type != 3822; private bool GetItem_FillIntoOccupiedSlot_VoidBag( int plr, Item[] inv, Item newItem, GetItemSettings settings, Item returnItem, int i) { if (inv[i].type > 0 && inv[i].stack < inv[i].maxStack && returnItem.IsTheSameAs(inv[i])) { if (newItem.IsACoin) SoundEngine.PlaySound(38, (int) this.position.X, (int) this.position.Y); else SoundEngine.PlaySound(7, (int) this.position.X, (int) this.position.Y); if (returnItem.stack + inv[i].stack <= inv[i].maxStack) { inv[i].stack += returnItem.stack; if (!settings.NoText) PopupText.NewText(PopupTextContext.ItemPickupToVoidContainer, newItem, returnItem.stack, longText: settings.LongText); AchievementsHelper.NotifyItemPickup(this, returnItem); settings.HandlePostAction(inv[i]); return true; } AchievementsHelper.NotifyItemPickup(this, returnItem, inv[i].maxStack - inv[i].stack); returnItem.stack -= inv[i].maxStack - inv[i].stack; if (!settings.NoText) PopupText.NewText(PopupTextContext.ItemPickupToVoidContainer, newItem, inv[i].maxStack - inv[i].stack, longText: settings.LongText); inv[i].stack = inv[i].maxStack; settings.HandlePostAction(inv[i]); } return false; } private bool GetItem_FillIntoOccupiedSlot( int plr, Item newItem, GetItemSettings settings, Item returnItem, int i) { if (this.inventory[i].type > 0 && this.inventory[i].stack < this.inventory[i].maxStack && returnItem.IsTheSameAs(this.inventory[i])) { if (newItem.IsACoin) SoundEngine.PlaySound(38, (int) this.position.X, (int) this.position.Y); else SoundEngine.PlaySound(7, (int) this.position.X, (int) this.position.Y); if (returnItem.stack + this.inventory[i].stack <= this.inventory[i].maxStack) { this.inventory[i].stack += returnItem.stack; if (!settings.NoText) PopupText.NewText(PopupTextContext.RegularItemPickup, newItem, returnItem.stack, longText: settings.LongText); this.DoCoins(i); if (plr == Main.myPlayer) Recipe.FindRecipes(); AchievementsHelper.NotifyItemPickup(this, returnItem); settings.HandlePostAction(this.inventory[i]); return true; } AchievementsHelper.NotifyItemPickup(this, returnItem, this.inventory[i].maxStack - this.inventory[i].stack); returnItem.stack -= this.inventory[i].maxStack - this.inventory[i].stack; if (!settings.NoText) PopupText.NewText(PopupTextContext.RegularItemPickup, newItem, this.inventory[i].maxStack - this.inventory[i].stack, longText: settings.LongText); this.inventory[i].stack = this.inventory[i].maxStack; this.DoCoins(i); if (plr == Main.myPlayer) Recipe.FindRecipes(); settings.HandlePostAction(this.inventory[i]); } return false; } private bool GetItem_FillEmptyInventorySlot_VoidBag( int plr, Item[] inv, Item newItem, GetItemSettings settings, Item returnItem, int i) { if (inv[i].type != 0) return false; if (newItem.IsACoin) SoundEngine.PlaySound(38, (int) this.position.X, (int) this.position.Y); else SoundEngine.PlaySound(7, (int) this.position.X, (int) this.position.Y); inv[i] = returnItem; if (!settings.NoText) PopupText.NewText(PopupTextContext.ItemPickupToVoidContainer, newItem, newItem.stack, longText: settings.LongText); this.DoCoins(i); if (plr == Main.myPlayer) Recipe.FindRecipes(); AchievementsHelper.NotifyItemPickup(this, returnItem); settings.HandlePostAction(inv[i]); return true; } private bool GetItem_FillEmptyInventorySlot( int plr, Item newItem, GetItemSettings settings, Item returnItem, int i) { if (this.inventory[i].type != 0) return false; if (newItem.IsACoin) SoundEngine.PlaySound(38, (int) this.position.X, (int) this.position.Y); else SoundEngine.PlaySound(7, (int) this.position.X, (int) this.position.Y); this.inventory[i] = returnItem; if (!settings.NoText) PopupText.NewText(PopupTextContext.RegularItemPickup, newItem, newItem.stack, longText: settings.LongText); this.DoCoins(i); if (plr == Main.myPlayer) Recipe.FindRecipes(); AchievementsHelper.NotifyItemPickup(this, returnItem); settings.HandlePostAction(this.inventory[i]); return true; } public void PlaceThing() { if (this.itemTime == 0) this.dontConsumeWand = false; this.PlaceThing_Paintbrush(); this.PlaceThing_PaintRoller(); this.PlaceThing_PaintScrapper(); this.PlaceThing_CannonBall(); this.PlaceThing_XMasTreeTops(); this.PlaceThing_ItemInExtractinator(); if (this.noBuilding) return; this.PlaceThing_Tiles(); this.PlaceThing_Walls(); } private void PlaceThing_Walls() { if (this.inventory[this.selectedItem].createWall < 0 || (double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetX || ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) this.inventory[this.selectedItem].tileBoost - 1.0 + (double) this.blockRange < (double) Player.tileTargetX || (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetY || ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) this.inventory[this.selectedItem].tileBoost - 2.0 + (double) this.blockRange < (double) Player.tileTargetY) return; this.cursorItemIconEnabled = true; if (!this.ItemTimeIsZero || this.itemAnimation <= 0 || !this.controlUseItem || !Main.tile[Player.tileTargetX + 1, Player.tileTargetY].active() && Main.tile[Player.tileTargetX + 1, Player.tileTargetY].wall <= (ushort) 0 && !Main.tile[Player.tileTargetX - 1, Player.tileTargetY].active() && Main.tile[Player.tileTargetX - 1, Player.tileTargetY].wall <= (ushort) 0 && !Main.tile[Player.tileTargetX, Player.tileTargetY + 1].active() && Main.tile[Player.tileTargetX, Player.tileTargetY + 1].wall <= (ushort) 0 && !Main.tile[Player.tileTargetX, Player.tileTargetY - 1].active() && Main.tile[Player.tileTargetX, Player.tileTargetY - 1].wall <= (ushort) 0 || (int) Main.tile[Player.tileTargetX, Player.tileTargetY].wall == this.inventory[this.selectedItem].createWall) return; bool canUse = true; if (this.TileReplacementEnabled) canUse = this.PlaceThing_TryReplacingWalls(canUse); if (!canUse) return; WorldGen.PlaceWall(Player.tileTargetX, Player.tileTargetY, this.inventory[this.selectedItem].createWall); if ((int) Main.tile[Player.tileTargetX, Player.tileTargetY].wall != this.inventory[this.selectedItem].createWall) return; this.ApplyItemTime(this.inventory[this.selectedItem], this.wallSpeed); if (Main.netMode == 1) NetMessage.SendData(17, number: 3, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY), number4: ((float) this.inventory[this.selectedItem].createWall)); this.PlaceThing_Walls_FillEmptySpace(); if (!this.autoPaint || this.builderAccStatus[3] != 0) return; this.TryPainting(Player.tileTargetX, Player.tileTargetY, true, false); } private void PlaceThing_Walls_FillEmptySpace() { if (this.inventory[this.selectedItem].stack <= 1) return; int createWall = this.inventory[this.selectedItem].createWall; for (int index1 = 0; index1 < 4; ++index1) { int tileTargetX = Player.tileTargetX; int tileTargetY = Player.tileTargetY; if (index1 == 0) --tileTargetX; if (index1 == 1) ++tileTargetX; if (index1 == 2) --tileTargetY; if (index1 == 3) ++tileTargetY; if (Main.tile[tileTargetX, tileTargetY].wall == (ushort) 0) { int num = 0; for (int index2 = 0; index2 < 4; ++index2) { int index3 = tileTargetX; int index4 = tileTargetY; if (index2 == 0) --index3; if (index2 == 1) ++index3; if (index2 == 2) --index4; if (index2 == 3) ++index4; if ((int) Main.tile[index3, index4].wall == createWall) ++num; } if (num == 4) { WorldGen.PlaceWall(tileTargetX, tileTargetY, createWall); if ((int) Main.tile[tileTargetX, tileTargetY].wall == createWall) { --this.inventory[this.selectedItem].stack; if (this.inventory[this.selectedItem].stack == 0) this.inventory[this.selectedItem].SetDefaults(); if (Main.netMode == 1) NetMessage.SendData(17, number: 3, number2: ((float) tileTargetX), number3: ((float) tileTargetY), number4: ((float) createWall)); if (this.autoPaint && this.builderAccStatus[3] == 0) this.TryPainting(tileTargetX, tileTargetY, true, false); } } } } } private void PlaceThing_Tiles() { int createTile = this.inventory[this.selectedItem].createTile; if (createTile < 0 || (double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetX || ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) this.inventory[this.selectedItem].tileBoost - 1.0 + (double) this.blockRange < (double) Player.tileTargetX || (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetY || ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) this.inventory[this.selectedItem].tileBoost - 2.0 + (double) this.blockRange < (double) Player.tileTargetY) return; this.cursorItemIconEnabled = true; bool flag = this.PlaceThing_Tiles_CheckLavaBlocking(); bool canUse = this.PlaceThing_Tiles_CheckRopeUsability(this.PlaceThing_Tiles_CheckWandUsability(this.PlaceThing_Tiles_CheckGamepadTorchUsability(true))); if (this.TileReplacementEnabled) canUse = this.PlaceThing_TryReplacingTiles(canUse); Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; if (!canUse || (tile.active() || flag) && (!Main.tileCut[(int) tile.type] || tile.type == (ushort) 484) && (tile.type < (ushort) 373 || tile.type > (ushort) 375) && tile.type != (ushort) 461 && createTile != 199 && createTile != 23 && createTile != 2 && createTile != 109 && createTile != 60 && createTile != 70 && !Main.tileMoss[createTile] && !TileID.Sets.BreakableWhenPlacing[(int) tile.type] || !this.ItemTimeIsZero || this.itemAnimation <= 0 || !this.controlUseItem) return; bool canPlace1 = false; bool newObjectType = false; TileObject objectData = new TileObject(); bool canPlace2; if (TileObjectData.CustomPlace(createTile, this.inventory[this.selectedItem].placeStyle) && createTile != 82 && createTile != 227) { newObjectType = true; canPlace2 = TileObject.CanPlace(Player.tileTargetX, Player.tileTargetY, (int) (ushort) this.inventory[this.selectedItem].createTile, this.inventory[this.selectedItem].placeStyle, this.direction, out objectData); Player.PlaceThing_Tiles_BlockPlacementIfOverPlayers(ref canPlace2, ref objectData); Player.PlaceThing_Tiles_BlockPlacementForRepeatedPigronatas(ref canPlace2, ref objectData); Player.PlaceThing_Tiles_BlockPlacementForRepeatedPumpkins(ref canPlace2, ref objectData); Player.PlaceThing_Tiles_BlockPlacementForRepeatedCoralAndBeachPiles(ref canPlace2, ref objectData); } else canPlace2 = this.PlaceThing_Tiles_BlockPlacementForAssortedThings(canPlace1); if (!canPlace2) return; this.PlaceThing_Tiles_PlaceIt(newObjectType, objectData); } private bool PlaceThing_TryReplacingWalls(bool canUse) { if (canUse && this.itemAnimation > 0 && this.ItemTimeIsZero && this.controlUseItem && this.PlaceThing_ValidWallForReplacement() && WorldGen.NearFriendlyWall(Player.tileTargetX, Player.tileTargetY) && WorldGen.ReplaceWall(Player.tileTargetX, Player.tileTargetY, (ushort) this.HeldItem.createWall)) { canUse = false; this.ApplyItemTime(this.HeldItem, this.wallSpeed); NetMessage.SendData(17, number: 22, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY), number4: ((float) this.HeldItem.createWall)); if (this.autoPaint && this.builderAccStatus[3] == 0) this.TryPainting(Player.tileTargetX, Player.tileTargetY, true, false); } return canUse; } private bool PlaceThing_ValidWallForReplacement() { Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; return Main.tile[Player.tileTargetX, Player.tileTargetY].wall > (ushort) 0; } private bool PlaceThing_TryReplacingTiles(bool canUse) { bool flag = this.PlaceThing_ValidTileForReplacement(); if (flag) TileObject.objectPreview.Reset(); if (this.controlUseItem && ((!canUse || !Main.tile[Player.tileTargetX, Player.tileTargetY].active() || this.itemAnimation <= 0 ? 0 : (this.ItemTimeIsZero ? 1 : 0)) & (flag ? 1 : 0)) != 0) { Item bestPickaxe = this.GetBestPickaxe(); if (bestPickaxe == null) return false; Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; int type = (int) tile.type; int pickaxeDamage = this.GetPickaxeDamage(Player.tileTargetX, Player.tileTargetY, bestPickaxe.pick, type, tile); if (pickaxeDamage == 0 || !WorldGen.IsTileReplacable(Player.tileTargetX, Player.tileTargetY)) return false; if (true) { if (this.hitReplace.AddDamage(this.hitReplace.HitObject(Player.tileTargetX, Player.tileTargetY, 1), pickaxeDamage) >= 100) { this.ClearMiningCacheAt(Player.tileTargetX, Player.tileTargetY, 1); } else { int tileDustAmount = WorldGen.KillTile_GetTileDustAmount(true, tile); for (int index = 0; index < tileDustAmount; ++index) WorldGen.KillTile_MakeTileDust(Player.tileTargetX, Player.tileTargetY, tile); WorldGen.KillTile_PlaySounds(Player.tileTargetX, Player.tileTargetY, true, tile); if (this.HeldItem.consumable) ++this.HeldItem.stack; this.dontConsumeWand = true; this.ApplyItemTime(bestPickaxe, this.pickSpeed); this.SetItemAnimation((int) ((double) bestPickaxe.useTime * (double) this.pickSpeed)); return false; } } int[,] autoAccessoryCache = this.PlaceThing_Tiles_GetAutoAccessoryCache(); if (WorldGen.ReplaceTile(Player.tileTargetX, Player.tileTargetY, (ushort) this.HeldItem.createTile, this.HeldItem.placeStyle)) { canUse = false; NetMessage.SendData(17, number: 21, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY), number4: ((float) this.HeldItem.createTile), number5: this.HeldItem.placeStyle); this.ApplyItemTime(this.HeldItem); this.SetItemAnimation(this.HeldItem.useAnimation); this.PlaceThing_Tiles_PlaceIt_AutoPaintAndActuate(autoAccessoryCache); } } return canUse; } private bool PlaceThing_ValidTileForReplacement() { int createTile = this.HeldItem.createTile; Tile tileCache = Main.tile[Player.tileTargetX, Player.tileTargetY]; if (WorldGen.WouldTileReplacementBeBlockedByLiquid(Player.tileTargetX, Player.tileTargetY, 1) || ItemID.Sets.SortingPriorityRopes[this.HeldItem.type] != -1 || Main.tileMoss[createTile] || TileID.Sets.DoesntPlaceWithTileReplacement[createTile] || TileID.Sets.DoesntGetReplacedWithTileReplacement[(int) tileCache.type] || !this.PlaceThing_CheckSpecificValidtyCaseForBlockSwap(createTile, (int) tileCache.type) || Main.tileCut[(int) tileCache.type]) return false; if (TileID.Sets.Platforms[(int) tileCache.type] && (int) tileCache.type == createTile) return (int) tileCache.frameY != this.HeldItem.placeStyle * 18; if (TileID.Sets.BasicChest[(int) tileCache.type] && TileID.Sets.BasicChest[createTile]) return (int) tileCache.frameX / 36 != this.HeldItem.placeStyle || (int) tileCache.type != createTile; if (TileID.Sets.BasicDresser[(int) tileCache.type] && TileID.Sets.BasicDresser[createTile]) return (int) tileCache.frameX / 54 != this.HeldItem.placeStyle || (int) tileCache.type != createTile; if (Main.tileFrameImportant[createTile] && !TileID.Sets.Platforms[createTile] || (int) Main.tile[Player.tileTargetX, Player.tileTargetY].type == createTile) return false; if (!TileID.Sets.IgnoresTileReplacementDropCheckWhenBeingPlaced[createTile]) { int dropItem; WorldGen.KillTile_GetItemDrops(Player.tileTargetX, Player.tileTargetY, tileCache, out dropItem, out int _, out int _, out int _); if (dropItem == this.HeldItem.type) return false; } return WorldGen.WouldTileReplacementWork((ushort) createTile, Player.tileTargetX, Player.tileTargetY); } private bool PlaceThing_CheckSpecificValidtyCaseForBlockSwap( int tileTypeBeingPlaced, int tileTypeCurrentlyPlaced) { return !((TileID.Sets.Falling[tileTypeBeingPlaced] ? 1 : 0) == 0 & TileID.Sets.Falling[tileTypeCurrentlyPlaced]); } private Item GetBestPickaxe() { Item obj = (Item) null; for (int index = 0; index < 50; ++index) { if (this.inventory[index].stack > 0 && this.inventory[index].pick > 0 && (obj == null || this.inventory[index].pick > obj.pick)) obj = this.inventory[index]; } return obj; } private TileObject PlaceThing_Tiles_PlaceIt(bool newObjectType, TileObject data) { int num = this.inventory[this.selectedItem].placeStyle; if (!newObjectType) num = this.PlaceThing_Tiles_PlaceIt_GetLegacyTileStyle(num); int[,] autoAccessoryCache = this.PlaceThing_Tiles_GetAutoAccessoryCache(); bool forced = false; bool flag; if (newObjectType) { flag = TileObject.Place(data); WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY); if (Main.netMode != 1 || !TileID.Sets.IsAContainer[this.inventory[this.selectedItem].createTile]) SoundEngine.PlaySound(0, Player.tileTargetX * 16, Player.tileTargetY * 16); } else { if (this.UsingBiomeTorches && this.inventory[this.selectedItem].createTile == 4 && num == 0) num = this.BiomeTorchPlaceStyle(num); flag = WorldGen.PlaceTile(Player.tileTargetX, Player.tileTargetY, this.inventory[this.selectedItem].createTile, forced: forced, plr: this.whoAmI, style: num); } if (flag) { this.ApplyItemTime(this.inventory[this.selectedItem], this.tileSpeed); if (newObjectType) { TileObjectData.CallPostPlacementPlayerHook(Player.tileTargetX, Player.tileTargetY, this.inventory[this.selectedItem].createTile, num, this.direction, data.alternate, data); if (Main.netMode == 1 && !Main.tileContainer[this.inventory[this.selectedItem].createTile] && this.inventory[this.selectedItem].createTile != 423) NetMessage.SendObjectPlacment(-1, Player.tileTargetX, Player.tileTargetY, data.type, data.style, data.alternate, data.random, this.direction); } else { NetMessage.SendData(17, number: 1, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY), number4: ((float) this.inventory[this.selectedItem].createTile), number5: num); this.PlaceThing_Tiles_PlaceIt_SpinChairs(); this.PlaceThing_Tiles_PlaceIt_SpinBedsAndBaths(); } this.PlaceThing_Tiles_PlaceIt_AdjustPlants(); this.PlaceThing_Tiles_PlaceIt_SpinTraps(); this.PlaceThing_Tiles_PlaceIt_TriggerLogicLamp(); this.PlaceThing_Tiles_PlaceIt_SpinSmartPlatform(); this.PlaceThing_Tiles_PlaceIt_UnslopeForSolids(); this.PlaceThing_Tiles_PlaceIt_KillGrassForSolids(); this.PlaceThing_Tiles_PlaceIt_AutoPaintAndActuate(autoAccessoryCache); if (PlayerInput.UsingGamepad && ItemID.Sets.SingleUseInGamepad[this.inventory[this.selectedItem].type] && Main.myPlayer == this.whoAmI && !Main.SmartCursorEnabled) Main.blockMouse = true; } return data; } public int BiomeTorchPlaceStyle(int style) { if (!this.UsingBiomeTorches || style != 0) return style; if (this.ZoneDungeon) style = 13; else if ((double) this.position.Y > (double) (Main.UnderworldLayer * 16)) style = 7; else if (this.ZoneHallow) style = 20; else if (this.ZoneCorrupt) style = 18; else if (this.ZoneCrimson) style = 19; else if (this.ZoneSnow) style = 9; else if (this.ZoneJungle) style = 21; else if (this.ZoneDesert && (double) this.position.Y < Main.worldSurface * 16.0 || this.ZoneUndergroundDesert) style = 16; return style; } public int BiomeTorchHoldStyle(int style) { if (!this.UsingBiomeTorches || style != 8) return style; if (this.ZoneDungeon) style = 3004; else if ((double) this.position.Y > (double) (Main.UnderworldLayer * 16)) style = 433; else if (this.ZoneHallow) style = 4387; else if (this.ZoneCorrupt) style = 4385; else if (this.ZoneCrimson) style = 4386; else if (this.ZoneSnow) style = 974; else if (this.ZoneJungle) style = 4388; else if (this.ZoneDesert && (double) this.position.Y < Main.worldSurface * 16.0 || this.ZoneUndergroundDesert) style = 4383; return style; } private int[,] PlaceThing_Tiles_GetAutoAccessoryCache() { int[,] numArray = (int[,]) null; if (this.autoPaint || this.autoActuator) { numArray = new int[11, 11]; for (int index1 = 0; index1 < 11; ++index1) { for (int index2 = 0; index2 < 11; ++index2) { int index3 = Player.tileTargetX - 5 + index1; int index4 = Player.tileTargetY - 5 + index2; numArray[index1, index2] = !Main.tile[index3, index4].active() ? -1 : (int) Main.tile[index3, index4].type; } } } return numArray; } private int PlaceThing_Tiles_PlaceIt_GetLegacyTileStyle(int style) { int createTile = this.inventory[this.selectedItem].createTile; if (createTile == 36) style = Main.rand.Next(7); if (createTile == 212 && this.direction > 0) style = 1; if (createTile == 141) style = Main.rand.Next(2); if (createTile == 128 || createTile == 269 || createTile == 334) style = this.direction >= 0 ? 1 : -1; if (createTile == 241 && this.inventory[this.selectedItem].placeStyle == 0) style = Main.rand.Next(0, 9); if (createTile == 35 && this.inventory[this.selectedItem].placeStyle == 0) style = Main.rand.Next(9); if (createTile == 314 && style == 2 && this.direction == 1) ++style; return style; } private void PlaceThing_Tiles_PlaceIt_UnslopeForSolids() { if (!Main.tileSolid[this.inventory[this.selectedItem].createTile] || this.inventory[this.selectedItem].createTile >= 0 && TileID.Sets.Platforms[this.inventory[this.selectedItem].createTile]) return; int tileTargetX1 = Player.tileTargetX; int j1 = Player.tileTargetY + 1; if (Main.tile[tileTargetX1, j1] != null && !TileID.Sets.Platforms[(int) Main.tile[tileTargetX1, j1].type] && (Main.tile[tileTargetX1, j1].topSlope() || Main.tile[tileTargetX1, j1].halfBrick())) { WorldGen.SlopeTile(tileTargetX1, j1); if (Main.netMode == 1) NetMessage.SendData(17, number: 14, number2: ((float) tileTargetX1), number3: ((float) j1)); } int tileTargetX2 = Player.tileTargetX; int j2 = Player.tileTargetY - 1; if (Main.tile[tileTargetX2, j2] == null || TileID.Sets.Platforms[(int) Main.tile[tileTargetX2, j2].type] || !Main.tile[tileTargetX2, j2].bottomSlope()) return; WorldGen.SlopeTile(tileTargetX2, j2); if (Main.netMode != 1) return; NetMessage.SendData(17, number: 14, number2: ((float) tileTargetX2), number3: ((float) j2)); } private void PlaceThing_Tiles_PlaceIt_KillGrassForSolids() { if (!Main.tileSolid[this.inventory[this.selectedItem].createTile]) return; for (int i1 = Player.tileTargetX - 1; i1 <= Player.tileTargetX + 1; ++i1) { for (int j1 = Player.tileTargetY - 1; j1 <= Player.tileTargetY + 1; ++j1) { if (Main.tile[i1, j1].active() && this.inventory[this.selectedItem].createTile != (int) Main.tile[i1, j1].type && (Main.tile[i1, j1].type == (ushort) 2 || Main.tile[i1, j1].type == (ushort) 23 || Main.tile[i1, j1].type == (ushort) 60 || Main.tile[i1, j1].type == (ushort) 70 || Main.tile[i1, j1].type == (ushort) 109 || Main.tile[i1, j1].type == (ushort) 199 || Main.tile[i1, j1].type == (ushort) 477 || Main.tile[i1, j1].type == (ushort) 492)) { bool flag = true; for (int i2 = i1 - 1; i2 <= i1 + 1; ++i2) { for (int j2 = j1 - 1; j2 <= j1 + 1; ++j2) { if (!WorldGen.SolidTile(i2, j2)) flag = false; } } if (flag) { WorldGen.KillTile(i1, j1, true); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) i1), number3: ((float) j1), number4: 1f); } } } } } private void PlaceThing_Tiles_PlaceIt_AutoPaintAndActuate(int[,] typeCaches) { if (!this.autoPaint && !this.autoActuator) return; int num1 = 0; int num2 = 0; int num3 = 11; int num4 = 11; bool platform = TileID.Sets.Platforms[(int) Main.tile[Player.tileTargetX, Player.tileTargetY].type]; bool flag1 = TileID.Sets.Platforms[(int) Main.tile[Player.tileTargetX, Player.tileTargetY].type] && TileID.Sets.Platforms[this.inventory[this.selectedItem].createTile]; if (!Main.tileFrameImportant[(int) Main.tile[Player.tileTargetX, Player.tileTargetY].type] | platform) { num1 = num2 = 5; num3 = num4 = 6; } for (int index1 = num1; index1 < num3; ++index1) { for (int index2 = num2; index2 < num4; ++index2) { int index3 = Player.tileTargetX - 5 + index1; int index4 = Player.tileTargetY - 5 + index2; if ((Main.tile[index3, index4].active() || typeCaches[index1, index2] != -1) && (!Main.tile[index3, index4].active() || flag1 || typeCaches[index1, index2] != (int) Main.tile[index3, index4].type && (int) Main.tile[index3, index4].type == this.inventory[this.selectedItem].createTile)) { if (this.autoPaint && this.builderAccStatus[3] == 0) this.TryPainting(index3, index4, applyItemAnimation: false); if (this.autoActuator && this.builderAccStatus[2] == 0) { bool flag2 = Main.tileSolid[(int) Main.tile[index3, index4].type] && !TileID.Sets.NotReallySolid[(int) Main.tile[index3, index4].type]; switch (Main.tile[index3, index4].type) { case 314: case 386: case 387: case 388: case 389: flag2 = false; break; } if (flag2) { int index5 = this.FindItem(849); if (index5 > -1 && WorldGen.PlaceActuator(index3, index4)) { NetMessage.SendData(17, number: 8, number2: ((float) index3), number3: ((float) index4)); --this.inventory[index5].stack; if (this.inventory[index5].stack <= 0) this.inventory[index5].SetDefaults(); } } } } } } } private void PlaceThing_Tiles_PlaceIt_SpinSmartPlatform() { if (this.inventory[this.selectedItem].createTile < 0 || !TileID.Sets.Platforms[this.inventory[this.selectedItem].createTile] || !Main.SmartCursorEnabled) return; int tileTargetX = Player.tileTargetX; int tileTargetY = Player.tileTargetY; int slope1 = -1; int num1 = 0; int num2 = 0; bool flag1 = true; for (int index1 = -1; index1 < 2; ++index1) { for (int index2 = -1; index2 < 2; ++index2) { if ((index1 != 0 || index2 != 0) && TileID.Sets.Platforms[(int) Main.tile[tileTargetX + index1, tileTargetY + index2].type]) flag1 = false; } } if (flag1) return; Tile tile1 = Main.tile[tileTargetX - 1, tileTargetY - 1]; if (tile1.active() && TileID.Sets.Platforms[(int) tile1.type] && tile1.slope() != (byte) 2) ++num1; Tile tile2 = Main.tile[tileTargetX - 1, tileTargetY + 1]; if (tile2.active() && TileID.Sets.Platforms[(int) tile2.type] && tile2.slope() != (byte) 1) ++num2; Tile tile3 = Main.tile[tileTargetX + 1, tileTargetY - 1]; if (tile3.active() && TileID.Sets.Platforms[(int) tile3.type] && tile3.slope() != (byte) 1) ++num2; Tile tile4 = Main.tile[tileTargetX + 1, tileTargetY + 1]; if (tile4.active() && TileID.Sets.Platforms[(int) tile4.type] && tile4.slope() != (byte) 2) ++num1; Tile testTile1 = Main.tile[tileTargetX - 1, tileTargetY]; if (WorldGen.SolidTile(testTile1)) { ++num1; if (TileID.Sets.Platforms[(int) testTile1.type] && testTile1.slope() == (byte) 0) ++num1; } Tile testTile2 = Main.tile[tileTargetX + 1, tileTargetY]; if (WorldGen.SolidTile(testTile2)) { ++num2; if (TileID.Sets.Platforms[(int) testTile2.type] && testTile2.slope() == (byte) 0) ++num2; } if (num1 > num2) slope1 = 1; else if (num2 > num1) slope1 = 2; Tile tile5 = Main.tile[tileTargetX - 1, tileTargetY]; if (tile5.active() && TileID.Sets.Platforms[(int) tile5.type]) slope1 = 0; Tile tile6 = Main.tile[tileTargetX + 1, tileTargetY]; if (tile6.active() && TileID.Sets.Platforms[(int) tile6.type]) slope1 = 0; if (slope1 != -1) { WorldGen.SlopeTile(tileTargetX, tileTargetY, slope1, true); int num3 = (int) Main.tile[tileTargetX, tileTargetY].slope(); if (Main.netMode == 1) NetMessage.SendData(17, number: 14, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY), number4: ((float) num3)); int num4; int num5; if (slope1 == 1) { num4 = -1; num5 = -1; } else { num4 = 1; num5 = -1; } Tile tile7 = Main.tile[tileTargetX + num4, tileTargetY + num5]; if (tile7.active() && TileID.Sets.Platforms[(int) tile7.type] && tile7.slope() == (byte) 0 && (!Main.tile[tileTargetX + num4 + num4, tileTargetY + num5].active() || !TileID.Sets.Platforms[(int) Main.tile[tileTargetX + num4 + num4, tileTargetY + num5].type] || !Main.tile[tileTargetX + num4 + num4, tileTargetY + num5].halfBrick())) { WorldGen.SlopeTile(tileTargetX + num4, tileTargetY + num5, slope1); int num6 = (int) tile7.slope(); if (Main.netMode == 1) NetMessage.SendData(17, number: 14, number2: ((float) (tileTargetX + num4)), number3: ((float) (tileTargetY + num5)), number4: ((float) num6)); } int num7; int num8; if (slope1 == 1) { num7 = 1; num8 = 1; } else { num7 = -1; num8 = 1; } Tile tile8 = Main.tile[tileTargetX + num7, tileTargetY + num8]; if (!tile8.active() || !TileID.Sets.Platforms[(int) tile8.type] || tile8.slope() != (byte) 0 || WorldGen.PlatformProperSides(tileTargetX + num7, tileTargetY + num8, true) > 0) return; WorldGen.SlopeTile(tileTargetX + num7, tileTargetY + num8, slope1); int num9 = (int) tile8.slope(); if (Main.netMode != 1) return; NetMessage.SendData(17, number: 14, number2: ((float) (tileTargetX + num7)), number3: ((float) (tileTargetY + num8)), number4: ((float) num9)); } else { int num10 = -1; Tile tile9 = Main.tile[tileTargetX + num10, tileTargetY]; if (tile9.active() && TileID.Sets.Platforms[(int) tile9.type] && tile9.slope() != (byte) 0) { int num11 = (tile9.slope() == (byte) 1).ToDirectionInt() * num10; int slope2 = num11 == -1 ? 0 : (int) tile9.slope(); bool flag2 = true; if (Main.tile[tileTargetX + num10 * 2, tileTargetY + num11].active() && TileID.Sets.Platforms[(int) Main.tile[tileTargetX + num10 * 2, tileTargetY].type] && slope2 == (int) Main.tile[tileTargetX + num10 * 2, tileTargetY + num11].slope()) flag2 = false; if (Main.tile[tileTargetX, tileTargetY - num11].active() && TileID.Sets.Platforms[(int) Main.tile[tileTargetX, tileTargetY - num11].type] && (int) tile9.slope() == (int) Main.tile[tileTargetX, tileTargetY - num11].slope()) flag2 = false; if (flag2) { WorldGen.SlopeTile(tileTargetX + num10, tileTargetY, slope2); int num12 = (int) tile9.slope(); if (Main.netMode == 1) NetMessage.SendData(17, number: 14, number2: ((float) (tileTargetX + num10)), number3: ((float) tileTargetY), number4: ((float) num12)); } } int num13 = 1; int num14 = 0; Tile tile10 = Main.tile[tileTargetX + num13, tileTargetY + num14]; if (tile10.active() && TileID.Sets.Platforms[(int) tile10.type] && tile10.slope() != (byte) 0) { int num15 = (tile10.slope() == (byte) 1).ToDirectionInt() * num13; int slope3 = num15 == -1 ? 0 : (int) tile10.slope(); bool flag3 = true; if (Main.tile[tileTargetX + num13 * 2, tileTargetY + num15].active() && TileID.Sets.Platforms[(int) Main.tile[tileTargetX + num13 * 2, tileTargetY].type] && slope3 == (int) Main.tile[tileTargetX + num13 * 2, tileTargetY + num15].slope()) flag3 = false; if (Main.tile[tileTargetX, tileTargetY - num15].active() && TileID.Sets.Platforms[(int) Main.tile[tileTargetX, tileTargetY - num15].type] && (int) tile10.slope() == (int) Main.tile[tileTargetX, tileTargetY - num15].slope()) flag3 = false; if (flag3) { WorldGen.SlopeTile(tileTargetX + num13, tileTargetY, slope3); int num16 = (int) tile10.slope(); if (Main.netMode == 1) NetMessage.SendData(17, number: 14, number2: ((float) (tileTargetX + num13)), number3: ((float) tileTargetY), number4: ((float) num16)); } } if (num1 != num2 || WorldGen.PlatformProperSides(tileTargetX, tileTargetY) != 0) return; Tile tile11 = Main.tile[tileTargetX, tileTargetY + 1]; if (!tile11.active() || tile11.halfBrick() || tile11.slope() != (byte) 0 || !Main.tileSolid[(int) tile11.type]) return; int slope4 = this.direction == 1 ? 2 : 1; WorldGen.SlopeTile(tileTargetX, tileTargetY, slope4); int num17 = (int) Main.tile[tileTargetX, tileTargetY].slope(); if (Main.netMode != 1) return; NetMessage.SendData(17, number: 14, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY), number4: ((float) num17)); } } private void PlaceThing_Tiles_PlaceIt_TriggerLogicLamp() { if (this.inventory[this.selectedItem].createTile != 419) return; if (Main.netMode == 1) NetMessage.SendData(17, number: 18, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); else Wiring.PokeLogicGate(Player.tileTargetX, Player.tileTargetY); } private void PlaceThing_Tiles_PlaceIt_SpinBedsAndBaths() { if (this.inventory[this.selectedItem].createTile != 79 && this.inventory[this.selectedItem].createTile != 90 || Main.netMode != 1) return; NetMessage.SendTileSquare(-1, Player.tileTargetX, Player.tileTargetY, 5); } private void PlaceThing_Tiles_PlaceIt_SpinChairs() { if (this.inventory[this.selectedItem].createTile != 15) return; if (this.direction == 1) { Main.tile[Player.tileTargetX, Player.tileTargetY].frameX += (short) 18; Main.tile[Player.tileTargetX, Player.tileTargetY - 1].frameX += (short) 18; } if (Main.netMode != 1) return; NetMessage.SendTileSquare(-1, Player.tileTargetX - 1, Player.tileTargetY - 1, 3); } private void PlaceThing_Tiles_PlaceIt_SpinTraps() { if (this.inventory[this.selectedItem].createTile != 137) return; if (this.direction == 1) Main.tile[Player.tileTargetX, Player.tileTargetY].frameX += (short) 18; if (Main.netMode != 1) return; NetMessage.SendTileSquare(-1, Player.tileTargetX, Player.tileTargetY, 1); } private void PlaceThing_Tiles_PlaceIt_AdjustPlants() { if (this.inventory[this.selectedItem].createTile != 3) return; FlowerPacketInfo flowerPacketInfo = ItemID.Sets.flowerPacketInfo[this.inventory[this.selectedItem].type]; if (flowerPacketInfo == null) return; List stylesOnPurity = flowerPacketInfo.stylesOnPurity; if (stylesOnPurity.Count == 0) return; int num = stylesOnPurity[Main.rand.Next(stylesOnPurity.Count)]; Main.tile[Player.tileTargetX, Player.tileTargetY].frameX = (short) (num * 18); if (Main.netMode != 1) return; NetMessage.SendTileSquare(-1, Player.tileTargetX, Player.tileTargetY, 1); } private bool PlaceThing_Tiles_PlaceIt_StaffOfRegrowthCheck(bool placed) { if (this.inventory[this.selectedItem].type == 213 && !placed && Main.tile[Player.tileTargetX, Player.tileTargetY].type == (ushort) 1 && Main.tile[Player.tileTargetX, Player.tileTargetY].active()) { int num1 = 0; int num2 = 0; Point tileCoordinates = this.Center.ToTileCoordinates(); Dictionary resultsOutput = new Dictionary(); WorldUtils.Gen(new Point(tileCoordinates.X - 25, tileCoordinates.Y - 25), (GenShape) new Shapes.Rectangle(50, 50), (GenAction) new Actions.TileScanner(new ushort[18] { (ushort) 182, (ushort) 515, (ushort) 180, (ushort) 513, (ushort) 179, (ushort) 512, (ushort) 183, (ushort) 516, (ushort) 181, (ushort) 514, (ushort) 381, (ushort) 517, (ushort) 534, (ushort) 535, (ushort) 536, (ushort) 537, (ushort) 539, (ushort) 540 }).Output(resultsOutput)); foreach (KeyValuePair keyValuePair in resultsOutput) { if (keyValuePair.Value > num2) { num2 = keyValuePair.Value; num1 = (int) keyValuePair.Key; } } switch (num1) { case 512: num1 = 179; break; case 513: num1 = 180; break; case 514: num1 = 181; break; case 515: num1 = 182; break; case 516: num1 = 183; break; case 517: num1 = 381; break; case 535: num1 = 534; break; case 537: num1 = 536; break; case 540: num1 = 539; break; } if (num2 == 0) num1 = Utils.SelectRandom(Main.rand, 182, 180, 179, 183, 181); if (num1 != 0) { Main.tile[Player.tileTargetX, Player.tileTargetY].type = (ushort) num1; WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY); NetMessage.SendTileSquare(-1, Player.tileTargetX, Player.tileTargetY, 1); placed = true; } } if (this.inventory[this.selectedItem].type == 213 && !placed && Main.tile[Player.tileTargetX, Player.tileTargetY].type == (ushort) 38 && Main.tile[Player.tileTargetX, Player.tileTargetY].active()) { int num3 = 0; int num4 = 0; Point tileCoordinates = this.Center.ToTileCoordinates(); Dictionary resultsOutput = new Dictionary(); WorldUtils.Gen(new Point(tileCoordinates.X - 25, tileCoordinates.Y - 25), (GenShape) new Shapes.Rectangle(50, 50), (GenAction) new Actions.TileScanner(new ushort[18] { (ushort) 182, (ushort) 515, (ushort) 180, (ushort) 513, (ushort) 179, (ushort) 512, (ushort) 183, (ushort) 516, (ushort) 181, (ushort) 514, (ushort) 381, (ushort) 517, (ushort) 534, (ushort) 535, (ushort) 536, (ushort) 537, (ushort) 539, (ushort) 540 }).Output(resultsOutput)); foreach (KeyValuePair keyValuePair in resultsOutput) { if (keyValuePair.Value > num4) { num4 = keyValuePair.Value; num3 = (int) keyValuePair.Key; } } switch (num3) { case 179: num3 = 512; break; case 180: num3 = 513; break; case 181: num3 = 514; break; case 182: num3 = 515; break; case 183: num3 = 516; break; case 381: num3 = 517; break; case 534: num3 = 535; break; case 536: num3 = 537; break; case 539: num3 = 540; break; } if (num4 == 0) num3 = Utils.SelectRandom(Main.rand, 515, 513, 512, 516, 514); if (num3 != 0) { Main.tile[Player.tileTargetX, Player.tileTargetY].type = (ushort) num3; WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY); NetMessage.SendTileSquare(-1, Player.tileTargetX, Player.tileTargetY, 1); placed = true; } } return placed; } private bool PlaceThing_Tiles_BlockPlacementForAssortedThings(bool canPlace) { if (this.inventory[this.selectedItem].type == 213) { if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == (ushort) 0 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == (ushort) 1 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == (ushort) 38) canPlace = true; } else if (this.inventory[this.selectedItem].createTile == 23 || this.inventory[this.selectedItem].createTile == 2 || this.inventory[this.selectedItem].createTile == 109 || this.inventory[this.selectedItem].createTile == 199) { if (Main.tile[Player.tileTargetX, Player.tileTargetY].nactive() && Main.tile[Player.tileTargetX, Player.tileTargetY].type == (ushort) 0) canPlace = true; } else if (this.inventory[this.selectedItem].createTile == 227) canPlace = true; else if (this.inventory[this.selectedItem].createTile >= 373 && this.inventory[this.selectedItem].createTile <= 375) { int tileTargetX = Player.tileTargetX; int index = Player.tileTargetY - 1; if (Main.tile[tileTargetX, index].nactive() && Main.tileSolid[(int) Main.tile[tileTargetX, index].type] && !Main.tileSolidTop[(int) Main.tile[tileTargetX, index].type]) canPlace = true; } else if (this.inventory[this.selectedItem].createTile == 461) { int tileTargetX = Player.tileTargetX; int index = Player.tileTargetY - 1; if (Main.tile[tileTargetX, index].nactive() && Main.tileSolid[(int) Main.tile[tileTargetX, index].type] && !Main.tileSolidTop[(int) Main.tile[tileTargetX, index].type]) canPlace = true; } else if (this.inventory[this.selectedItem].createTile == 60 || this.inventory[this.selectedItem].createTile == 70) { if (Main.tile[Player.tileTargetX, Player.tileTargetY].nactive() && Main.tile[Player.tileTargetX, Player.tileTargetY].type == (ushort) 59) canPlace = true; } else if (this.inventory[this.selectedItem].createTile == 4 || this.inventory[this.selectedItem].createTile == 136) { if (Main.tile[Player.tileTargetX, Player.tileTargetY].wall > (ushort) 0) { canPlace = true; } else { if (!WorldGen.SolidTileNoAttach(Player.tileTargetX, Player.tileTargetY + 1) && !WorldGen.SolidTileNoAttach(Player.tileTargetX - 1, Player.tileTargetY) && !WorldGen.SolidTileNoAttach(Player.tileTargetX + 1, Player.tileTargetY)) { if (!WorldGen.SolidTileNoAttach(Player.tileTargetX, Player.tileTargetY + 1) && (Main.tile[Player.tileTargetX, Player.tileTargetY + 1].halfBrick() || Main.tile[Player.tileTargetX, Player.tileTargetY + 1].slope() != (byte) 0)) { if (!TileID.Sets.Platforms[(int) Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type]) { WorldGen.SlopeTile(Player.tileTargetX, Player.tileTargetY + 1); if (Main.netMode == 1) NetMessage.SendData(17, number: 14, number2: ((float) Player.tileTargetX), number3: ((float) (Player.tileTargetY + 1))); } } else if (!WorldGen.SolidTileNoAttach(Player.tileTargetX, Player.tileTargetY + 1) && !WorldGen.SolidTileNoAttach(Player.tileTargetX - 1, Player.tileTargetY) && (Main.tile[Player.tileTargetX - 1, Player.tileTargetY].halfBrick() || Main.tile[Player.tileTargetX - 1, Player.tileTargetY].slope() != (byte) 0)) { if (!TileID.Sets.Platforms[(int) Main.tile[Player.tileTargetX - 1, Player.tileTargetY].type]) { WorldGen.SlopeTile(Player.tileTargetX - 1, Player.tileTargetY); if (Main.netMode == 1) NetMessage.SendData(17, number: 14, number2: ((float) (Player.tileTargetX - 1)), number3: ((float) Player.tileTargetY)); } } else if (!WorldGen.SolidTileNoAttach(Player.tileTargetX, Player.tileTargetY + 1) && !WorldGen.SolidTileNoAttach(Player.tileTargetX + 1, Player.tileTargetY) && (Main.tile[Player.tileTargetX + 1, Player.tileTargetY].halfBrick() || Main.tile[Player.tileTargetX + 1, Player.tileTargetY].slope() != (byte) 0) && !TileID.Sets.Platforms[(int) Main.tile[Player.tileTargetX + 1, Player.tileTargetY].type]) { WorldGen.SlopeTile(Player.tileTargetX + 1, Player.tileTargetY); if (Main.netMode == 1) NetMessage.SendData(17, number: 14, number2: ((float) (Player.tileTargetX + 1)), number3: ((float) Player.tileTargetY)); } } int index = (int) Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type; if (Main.tile[Player.tileTargetX, Player.tileTargetY].halfBrick()) index = -1; int tree1 = (int) Main.tile[Player.tileTargetX - 1, Player.tileTargetY].type; int tree2 = (int) Main.tile[Player.tileTargetX + 1, Player.tileTargetY].type; int tree3 = (int) Main.tile[Player.tileTargetX - 1, Player.tileTargetY - 1].type; int tree4 = (int) Main.tile[Player.tileTargetX + 1, Player.tileTargetY - 1].type; int tree5 = (int) Main.tile[Player.tileTargetX - 1, Player.tileTargetY - 1].type; int tree6 = (int) Main.tile[Player.tileTargetX + 1, Player.tileTargetY + 1].type; if (!Main.tile[Player.tileTargetX, Player.tileTargetY + 1].nactive()) index = -1; if (!Main.tile[Player.tileTargetX - 1, Player.tileTargetY].nactive()) tree1 = -1; if (!Main.tile[Player.tileTargetX + 1, Player.tileTargetY].nactive()) tree2 = -1; if (!Main.tile[Player.tileTargetX - 1, Player.tileTargetY - 1].nactive()) tree3 = -1; if (!Main.tile[Player.tileTargetX + 1, Player.tileTargetY - 1].nactive()) tree4 = -1; if (!Main.tile[Player.tileTargetX - 1, Player.tileTargetY + 1].nactive()) tree5 = -1; if (!Main.tile[Player.tileTargetX + 1, Player.tileTargetY + 1].nactive()) tree6 = -1; if (index >= 0 && Main.tileSolid[index] && (!Main.tileNoAttach[index] || index >= 0 && TileID.Sets.Platforms[index])) canPlace = true; else if (tree1 >= 0 && Main.tileSolid[tree1] && !Main.tileNoAttach[tree1] || WorldGen.IsTreeType(tree1) && WorldGen.IsTreeType(tree3) && WorldGen.IsTreeType(tree5) || tree1 >= 0 && TileID.Sets.IsBeam[tree1]) canPlace = true; else if (tree2 >= 0 && Main.tileSolid[tree2] && !Main.tileNoAttach[tree2] || WorldGen.IsTreeType(tree2) && WorldGen.IsTreeType(tree4) && WorldGen.IsTreeType(tree6) || tree2 >= 0 && TileID.Sets.IsBeam[tree2]) canPlace = true; } } else if (this.inventory[this.selectedItem].createTile == 78 || this.inventory[this.selectedItem].createTile == 98 || this.inventory[this.selectedItem].createTile == 100 || this.inventory[this.selectedItem].createTile == 173 || this.inventory[this.selectedItem].createTile == 174 || this.inventory[this.selectedItem].createTile == 324) { if (Main.tile[Player.tileTargetX, Player.tileTargetY + 1].nactive() && (Main.tileSolid[(int) Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type] || Main.tileTable[(int) Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type])) canPlace = true; } else if (this.inventory[this.selectedItem].createTile == 419) { if (Main.tile[Player.tileTargetX, Player.tileTargetY + 1].active() && (Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type == (ushort) 419 || this.inventory[this.selectedItem].placeStyle != 2 && Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type == (ushort) 420)) canPlace = true; } else if (this.inventory[this.selectedItem].createTile == 13 || this.inventory[this.selectedItem].createTile == 29 || this.inventory[this.selectedItem].createTile == 33 || this.inventory[this.selectedItem].createTile == 49 || this.inventory[this.selectedItem].createTile == 50 || this.inventory[this.selectedItem].createTile == 103) { if (Main.tile[Player.tileTargetX, Player.tileTargetY + 1].nactive() && Main.tileTable[(int) Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type]) canPlace = true; } else if (this.inventory[this.selectedItem].createTile == 275 || this.inventory[this.selectedItem].createTile == 276 || this.inventory[this.selectedItem].createTile == 277) canPlace = true; else if (this.inventory[this.selectedItem].createTile == 51 || this.inventory[this.selectedItem].createTile == 330 || this.inventory[this.selectedItem].createTile == 331 || this.inventory[this.selectedItem].createTile == 332 || this.inventory[this.selectedItem].createTile == 333 || this.inventory[this.selectedItem].createTile == 336 || this.inventory[this.selectedItem].createTile == 340 || this.inventory[this.selectedItem].createTile == 342 || this.inventory[this.selectedItem].createTile == 341 || this.inventory[this.selectedItem].createTile == 343 || this.inventory[this.selectedItem].createTile == 344 || this.inventory[this.selectedItem].createTile == 379 || this.inventory[this.selectedItem].createTile == 351) { if (Main.tile[Player.tileTargetX + 1, Player.tileTargetY].active() || Main.tile[Player.tileTargetX + 1, Player.tileTargetY].wall > (ushort) 0 || Main.tile[Player.tileTargetX - 1, Player.tileTargetY].active() || Main.tile[Player.tileTargetX - 1, Player.tileTargetY].wall > (ushort) 0 || Main.tile[Player.tileTargetX, Player.tileTargetY + 1].active() || Main.tile[Player.tileTargetX, Player.tileTargetY + 1].wall > (ushort) 0 || Main.tile[Player.tileTargetX, Player.tileTargetY - 1].active() || Main.tile[Player.tileTargetX, Player.tileTargetY - 1].wall > (ushort) 0) canPlace = true; } else if (this.inventory[this.selectedItem].createTile == 314) { for (int index1 = Player.tileTargetX - 1; index1 <= Player.tileTargetX + 1; ++index1) { for (int index2 = Player.tileTargetY - 1; index2 <= Player.tileTargetY + 1; ++index2) { Tile tile = Main.tile[index1, index2]; if (tile.active() || tile.wall > (ushort) 0) { canPlace = true; break; } } } } else { Tile tile1 = Main.tile[Player.tileTargetX - 1, Player.tileTargetY]; Tile tile2 = Main.tile[Player.tileTargetX + 1, Player.tileTargetY]; Tile tile3 = Main.tile[Player.tileTargetX, Player.tileTargetY - 1]; Tile tile4 = Main.tile[Player.tileTargetX, Player.tileTargetY + 1]; if (tile2.active() && (Main.tileSolid[(int) tile2.type] || Main.tileRope[(int) tile2.type] || tile2.type == (ushort) 314) || tile2.wall > (ushort) 0 || tile1.active() && (Main.tileSolid[(int) tile1.type] || Main.tileRope[(int) tile1.type] || tile1.type == (ushort) 314) || tile1.wall > (ushort) 0 || tile4.active() && (Main.tileSolid[(int) tile4.type] || TileID.Sets.IsBeam[(int) tile4.type] || Main.tileRope[(int) tile4.type] || tile4.type == (ushort) 314) || tile4.wall > (ushort) 0 || tile3.active() && (Main.tileSolid[(int) tile3.type] || TileID.Sets.IsBeam[(int) tile3.type] || Main.tileRope[(int) tile3.type] || tile3.type == (ushort) 314) || tile3.wall > (ushort) 0) canPlace = true; else if (Main.tile[Player.tileTargetX, Player.tileTargetY].wall > (ushort) 0) canPlace = true; } if (this.inventory[this.selectedItem].type == 213 && Main.tile[Player.tileTargetX, Player.tileTargetY].active()) { int tileTargetX = Player.tileTargetX; int tileTargetY = Player.tileTargetY; if (Main.tile[tileTargetX, tileTargetY].type == (ushort) 3 || Main.tile[tileTargetX, tileTargetY].type == (ushort) 73 || Main.tile[tileTargetX, tileTargetY].type == (ushort) 84) { WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY); if (!Main.tile[Player.tileTargetX, Player.tileTargetY].active() && Main.netMode == 1) NetMessage.SendData(17, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } else if (Main.tile[tileTargetX, tileTargetY].type == (ushort) 83) { bool flag = false; int num = (int) Main.tile[tileTargetX, tileTargetY].frameX / 18; if (num == 0 && Main.dayTime) flag = true; if (num == 1 && !Main.dayTime) flag = true; if (num == 3 && !Main.dayTime && (Main.bloodMoon || Main.moonPhase == 0)) flag = true; if (num == 4 && (Main.raining || (double) Main.cloudAlpha > 0.0)) flag = true; if (num == 5 && !Main.raining && Main.dayTime && Main.time > 40500.0) flag = true; if (flag) { WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY); NetMessage.SendData(17, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } } } if (Main.tileAlch[this.inventory[this.selectedItem].createTile]) canPlace = true; if (Main.tile[Player.tileTargetX, Player.tileTargetY].active() && (Main.tileCut[(int) Main.tile[Player.tileTargetX, Player.tileTargetY].type] || TileID.Sets.BreakableWhenPlacing[(int) Main.tile[Player.tileTargetX, Player.tileTargetY].type] || Main.tile[Player.tileTargetX, Player.tileTargetY].type >= (ushort) 373 && Main.tile[Player.tileTargetX, Player.tileTargetY].type <= (ushort) 375 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == (ushort) 461)) { if ((int) Main.tile[Player.tileTargetX, Player.tileTargetY].type != this.inventory[this.selectedItem].createTile) { int num = Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type == (ushort) 78 || Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type == (ushort) 380 ? 0 : (Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type != (ushort) 579 ? 1 : 0); bool flag1 = Main.tile[Player.tileTargetX, Player.tileTargetY].type == (ushort) 3 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == (ushort) 73; bool flag2 = Main.tileAlch[(int) Main.tile[Player.tileTargetX, Player.tileTargetY].type] && WorldGen.IsHarvestableHerbWithSeed((int) Main.tile[Player.tileTargetX, Player.tileTargetY].type, (int) Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18); bool flag3 = Main.tileAlch[this.inventory[this.selectedItem].createTile]; if (num != 0 || (flag1 | flag2) & flag3) { WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY); if (!Main.tile[Player.tileTargetX, Player.tileTargetY].active() && Main.netMode == 1) NetMessage.SendData(17, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } else canPlace = false; } else canPlace = false; } if (!canPlace && this.inventory[this.selectedItem].createTile >= 0 && TileID.Sets.Platforms[this.inventory[this.selectedItem].createTile]) { for (int index3 = Player.tileTargetX - 1; index3 <= Player.tileTargetX + 1; ++index3) { for (int index4 = Player.tileTargetY - 1; index4 <= Player.tileTargetY + 1; ++index4) { if (Main.tile[index3, index4].active()) { canPlace = true; break; } } } } if (this.inventory[this.selectedItem].createTile == 3) { canPlace = WorldGen.IsFitToPlaceFlowerIn(Player.tileTargetX, Player.tileTargetY, 3); if (canPlace) { WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY); if (Main.netMode == 1 && !Main.tile[Player.tileTargetX, Player.tileTargetY].active()) NetMessage.SendData(17, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } } return canPlace; } private static void PlaceThing_Tiles_BlockPlacementForRepeatedPumpkins( ref bool canPlace, ref TileObject data) { if (data.type != 254) return; for (int index1 = -1; index1 < 1; ++index1) { for (int index2 = -1; index2 < 1; ++index2) { if (!WorldGen.CanCutTile(Player.tileTargetX + index2, Player.tileTargetY + index1, TileCuttingContext.TilePlacement)) canPlace = false; } } } private static void PlaceThing_Tiles_BlockPlacementForRepeatedCoralAndBeachPiles( ref bool canPlace, ref TileObject data) { if (data.type != 81 && data.type != 324) return; Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; if (!tile.active() || !Main.tileCut[(int) tile.type] && !TileID.Sets.BreakableWhenPlacing[(int) tile.type] && (tile.type < (ushort) 373 || tile.type > (ushort) 375) && tile.type != (ushort) 461) return; canPlace = false; } private static void PlaceThing_Tiles_BlockPlacementForRepeatedPigronatas( ref bool canPlace, ref TileObject data) { if (data.type != 454) return; for (int index = -2; index < 2; ++index) { Tile tile = Main.tile[Player.tileTargetX + index, Player.tileTargetY]; if (tile.active() && tile.type == (ushort) 454) canPlace = false; } } private static void PlaceThing_Tiles_BlockPlacementIfOverPlayers( ref bool canPlace, ref TileObject data) { int width = 0; int height = 0; int x = 0; int y = 0; switch (data.type) { case 138: width = 32; height = 32; x = data.xCoord * 16; y = data.yCoord * 16; break; case 235: width = 48; height = 16; x = data.xCoord * 16; y = data.yCoord * 16; break; case 387: width = 32; height = 16; x = data.xCoord * 16; y = data.yCoord * 16; break; case 476: width = 16; height = 16; x = data.xCoord * 16; y = data.yCoord * 16; break; case 484: width = 32; height = 32; x = data.xCoord * 16; y = data.yCoord * 16; break; } if (width == 0 || height == 0) return; Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(x, y, width, height); for (int index = 0; index < (int) byte.MaxValue; ++index) { Player player = Main.player[index]; if (player.active && !player.dead && player.Hitbox.Intersects(rectangle)) { canPlace = false; break; } } } private bool PlaceThing_Tiles_CheckLavaBlocking() { bool flag = false; if (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid > (byte) 0 && Main.tile[Player.tileTargetX, Player.tileTargetY].lava()) { if (Main.tileSolid[this.inventory[this.selectedItem].createTile]) flag = true; else if (!TileObjectData.CheckLiquidPlacement(this.inventory[this.selectedItem].createTile, this.inventory[this.selectedItem].placeStyle, Main.tile[Player.tileTargetX, Player.tileTargetY])) flag = true; } return flag; } private bool PlaceThing_Tiles_CheckRopeUsability(bool canUse) { if (Main.tileRope[this.inventory[this.selectedItem].createTile] && canUse && Main.tile[Player.tileTargetX, Player.tileTargetY].active() && Main.tileRope[(int) Main.tile[Player.tileTargetX, Player.tileTargetY].type]) { int tileTargetY = Player.tileTargetY; int tileTargetX = Player.tileTargetX; int createTile = this.inventory[this.selectedItem].createTile; while (Main.tile[tileTargetX, tileTargetY].active() && Main.tileRope[(int) Main.tile[tileTargetX, tileTargetY].type] && tileTargetY < Main.maxTilesX - 5 && Main.tile[tileTargetX, tileTargetY + 2] != null && !Main.tile[tileTargetX, tileTargetY + 1].lava()) { ++tileTargetY; if (Main.tile[tileTargetX, tileTargetY] == null) { canUse = false; tileTargetY = Player.tileTargetY; break; } } if (!Main.tile[tileTargetX, tileTargetY].active()) Player.tileTargetY = tileTargetY; } return canUse; } private bool PlaceThing_Tiles_CheckWandUsability(bool canUse) { if (this.inventory[this.selectedItem].tileWand > 0) { int tileWand = this.inventory[this.selectedItem].tileWand; canUse = false; for (int index = 0; index < 58; ++index) { if (tileWand == this.inventory[index].type && this.inventory[index].stack > 0) { canUse = true; break; } } } return canUse; } private bool PlaceThing_Tiles_CheckGamepadTorchUsability(bool canUse) { if (PlayerInput.UsingGamepad && this.inventory[this.selectedItem].createTile == 4 && Main.SmartCursorEnabled && !Main.SmartCursorShowing) canUse = false; return canUse; } private void PlaceThing_ItemInExtractinator() { if (ItemID.Sets.ExtractinatorMode[this.inventory[this.selectedItem].type] < 0 || !Main.tile[Player.tileTargetX, Player.tileTargetY].active() || Main.tile[Player.tileTargetX, Player.tileTargetY].type != (ushort) 219 || (double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetX || ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) this.inventory[this.selectedItem].tileBoost - 1.0 + (double) this.blockRange < (double) Player.tileTargetX || (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetY || ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) this.inventory[this.selectedItem].tileBoost - 2.0 + (double) this.blockRange < (double) Player.tileTargetY || !this.ItemTimeIsZero || this.itemAnimation <= 0 || !this.controlUseItem) return; this.ApplyItemTime(this.inventory[this.selectedItem]); SoundEngine.PlaySound(7); this.ExtractinatorUse(ItemID.Sets.ExtractinatorMode[this.inventory[this.selectedItem].type]); } private void PlaceThing_XMasTreeTops() { if (this.inventory[this.selectedItem].type < 1874 || this.inventory[this.selectedItem].type > 1905 || !Main.tile[Player.tileTargetX, Player.tileTargetY].active() || Main.tile[Player.tileTargetX, Player.tileTargetY].type != (ushort) 171 || (double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetX || ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) this.inventory[this.selectedItem].tileBoost - 1.0 + (double) this.blockRange < (double) Player.tileTargetX || (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetY || ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) this.inventory[this.selectedItem].tileBoost - 2.0 + (double) this.blockRange < (double) Player.tileTargetY || !this.ItemTimeIsZero || this.itemAnimation <= 0 || !this.controlUseItem) return; int type = this.inventory[this.selectedItem].type; if (type >= 1874 && type <= 1877) { int style = type - 1873; if (WorldGen.checkXmasTreeDrop(Player.tileTargetX, Player.tileTargetY, 0) == style) return; this.ApplyItemTime(this.inventory[this.selectedItem]); WorldGen.dropXmasTree(Player.tileTargetX, Player.tileTargetY, 0); WorldGen.setXmasTree(Player.tileTargetX, Player.tileTargetY, 0, style); int tileTargetX = Player.tileTargetX; int tileTargetY = Player.tileTargetY; if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameX < (short) 10) { tileTargetX -= (int) Main.tile[Player.tileTargetX, Player.tileTargetY].frameX; tileTargetY -= (int) Main.tile[Player.tileTargetX, Player.tileTargetY].frameY; } NetMessage.SendTileSquare(-1, tileTargetX, tileTargetY, 1); } else if (type >= 1878 && type <= 1883) { int style = type - 1877; if (WorldGen.checkXmasTreeDrop(Player.tileTargetX, Player.tileTargetY, 1) == style) return; this.ApplyItemTime(this.inventory[this.selectedItem]); WorldGen.dropXmasTree(Player.tileTargetX, Player.tileTargetY, 1); WorldGen.setXmasTree(Player.tileTargetX, Player.tileTargetY, 1, style); int tileTargetX = Player.tileTargetX; int tileTargetY = Player.tileTargetY; if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameX < (short) 10) { tileTargetX -= (int) Main.tile[Player.tileTargetX, Player.tileTargetY].frameX; tileTargetY -= (int) Main.tile[Player.tileTargetX, Player.tileTargetY].frameY; } NetMessage.SendTileSquare(-1, tileTargetX, tileTargetY, 1); } else if (type >= 1884 && type <= 1894) { int style = type - 1883; if (WorldGen.checkXmasTreeDrop(Player.tileTargetX, Player.tileTargetY, 2) == style) return; this.ApplyItemTime(this.inventory[this.selectedItem]); WorldGen.dropXmasTree(Player.tileTargetX, Player.tileTargetY, 2); WorldGen.setXmasTree(Player.tileTargetX, Player.tileTargetY, 2, style); int tileTargetX = Player.tileTargetX; int tileTargetY = Player.tileTargetY; if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameX < (short) 10) { tileTargetX -= (int) Main.tile[Player.tileTargetX, Player.tileTargetY].frameX; tileTargetY -= (int) Main.tile[Player.tileTargetX, Player.tileTargetY].frameY; } NetMessage.SendTileSquare(-1, tileTargetX, tileTargetY, 1); } else { if (type < 1895 || type > 1905) return; int style = type - 1894; if (WorldGen.checkXmasTreeDrop(Player.tileTargetX, Player.tileTargetY, 3) == style) return; this.ApplyItemTime(this.inventory[this.selectedItem]); WorldGen.dropXmasTree(Player.tileTargetX, Player.tileTargetY, 3); WorldGen.setXmasTree(Player.tileTargetX, Player.tileTargetY, 3, style); int tileTargetX = Player.tileTargetX; int tileTargetY = Player.tileTargetY; if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameX < (short) 10) { tileTargetX -= (int) Main.tile[Player.tileTargetX, Player.tileTargetY].frameX; tileTargetY -= (int) Main.tile[Player.tileTargetX, Player.tileTargetY].frameY; } NetMessage.SendTileSquare(-1, tileTargetX, tileTargetY, 1); } } private void PlaceThing_CannonBall() { if (this.inventory[this.selectedItem].type != 929 && this.inventory[this.selectedItem].type != 1338 && this.inventory[this.selectedItem].type != 1345 || (double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetX || ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) this.inventory[this.selectedItem].tileBoost - 1.0 + (double) this.blockRange < (double) Player.tileTargetX || (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetY || ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) this.inventory[this.selectedItem].tileBoost - 2.0 + (double) this.blockRange < (double) Player.tileTargetY) return; int tileTargetX = Player.tileTargetX; int tileTargetY = Player.tileTargetY; if (!Main.tile[tileTargetX, tileTargetY].active() || Main.tile[tileTargetX, tileTargetY].type != (ushort) 209) return; this.ShootFromCannon(tileTargetX, tileTargetY); } private void PlaceThing_PaintScrapper() { if (!ItemID.Sets.IsPaintScraper[this.inventory[this.selectedItem].type] || (double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetX || ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) this.inventory[this.selectedItem].tileBoost - 1.0 + (double) this.blockRange < (double) Player.tileTargetX || (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetY || ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) this.inventory[this.selectedItem].tileBoost - 2.0 + (double) this.blockRange < (double) Player.tileTargetY) return; int tileTargetX = Player.tileTargetX; int tileTargetY = Player.tileTargetY; if (Main.tile[tileTargetX, tileTargetY] == null) return; if (Main.tile[tileTargetX, tileTargetY].wallColor() > (byte) 0 && Main.tile[tileTargetX, tileTargetY].wall > (ushort) 0 || Main.tile[tileTargetX, tileTargetY].color() > (byte) 0 && Main.tile[tileTargetX, tileTargetY].active()) { this.cursorItemIconEnabled = true; if (this.ItemTimeIsZero && this.itemAnimation > 0 && this.controlUseItem) { if (Main.tile[tileTargetX, tileTargetY].color() > (byte) 0 && Main.tile[tileTargetX, tileTargetY].active() && WorldGen.paintTile(tileTargetX, tileTargetY, (byte) 0, true)) this.ApplyItemTime(this.inventory[this.selectedItem], this.tileSpeed); else if (Main.tile[tileTargetX, tileTargetY].wallColor() > (byte) 0 && Main.tile[tileTargetX, tileTargetY].wall > (ushort) 0 && WorldGen.paintWall(tileTargetX, tileTargetY, (byte) 0, true)) this.ApplyItemTime(this.inventory[this.selectedItem], this.wallSpeed); } } if (Main.tile[tileTargetX, tileTargetY].type != (ushort) 184) return; this.cursorItemIconEnabled = true; if (!this.ItemTimeIsZero || this.itemAnimation <= 0 || !this.controlUseItem) return; int type = (int) Main.tile[tileTargetX, tileTargetY].type; int frameX = (int) Main.tile[tileTargetX, tileTargetY].frameX; WorldGen.KillTile(tileTargetX, tileTargetY); if (Main.tile[tileTargetX, tileTargetY].active()) return; this.ApplyItemTime(this.inventory[this.selectedItem]); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) tileTargetX), number3: ((float) tileTargetY)); if (Main.rand.Next(9) != 0) return; int Type = 4349 + frameX / 22; switch (frameX / 22) { case 6: Type = 4377; break; case 7: Type = 4378; break; case 8: Type = 4389; break; } NetMessage.SendData(21, number: Item.NewItem(tileTargetX * 16, tileTargetY * 16, 16, 16, Type), number2: 1f); } private void PlaceThing_PaintRoller() { if (this.inventory[this.selectedItem].type != 1072 && this.inventory[this.selectedItem].type != 1544 || (double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetX || ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) this.inventory[this.selectedItem].tileBoost - 1.0 + (double) this.blockRange < (double) Player.tileTargetX || (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetY || ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) this.inventory[this.selectedItem].tileBoost - 2.0 + (double) this.blockRange < (double) Player.tileTargetY) return; int tileTargetX = Player.tileTargetX; int tileTargetY = Player.tileTargetY; if (Main.tile[tileTargetX, tileTargetY] == null || Main.tile[tileTargetX, tileTargetY].wall <= (ushort) 0) return; this.cursorItemIconEnabled = true; if (!this.ItemTimeIsZero || this.itemAnimation <= 0 || !this.controlUseItem) return; this.TryPainting(tileTargetX, tileTargetY, true); } private void PlaceThing_Paintbrush() { if (this.inventory[this.selectedItem].type != 1071 && this.inventory[this.selectedItem].type != 1543 || (double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetX || ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) this.inventory[this.selectedItem].tileBoost - 1.0 + (double) this.blockRange < (double) Player.tileTargetX || (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) this.inventory[this.selectedItem].tileBoost - (double) this.blockRange > (double) Player.tileTargetY || ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) this.inventory[this.selectedItem].tileBoost - 2.0 + (double) this.blockRange < (double) Player.tileTargetY) return; int tileTargetX = Player.tileTargetX; int tileTargetY = Player.tileTargetY; if (Main.tile[tileTargetX, tileTargetY] == null || !Main.tile[tileTargetX, tileTargetY].active()) return; this.cursorItemIconEnabled = true; if (!this.ItemTimeIsZero || this.itemAnimation <= 0 || !this.controlUseItem) return; this.TryPainting(tileTargetX, tileTargetY); } private void TryPainting(int x, int y, bool paintingAWall = false, bool applyItemAnimation = true) { byte color = byte.MaxValue; Item obj = (Item) null; for (int index = 54; index < 58; ++index) { if (this.inventory[index].stack > 0 && this.inventory[index].paint > (byte) 0) { obj = this.inventory[index]; color = obj.paint; break; } } if (color == byte.MaxValue) { for (int index = 0; index < 58; ++index) { if (this.inventory[index].stack > 0 && this.inventory[index].paint > (byte) 0) { obj = this.inventory[index]; color = obj.paint; break; } } } if (paintingAWall) { if (color == byte.MaxValue || (int) Main.tile[x, y].wallColor() == (int) color || !WorldGen.paintWall(x, y, color, true)) return; --obj.stack; if (obj.stack <= 0) obj.SetDefaults(); if (!applyItemAnimation) return; this.ApplyItemTime(this.inventory[this.selectedItem], this.wallSpeed); } else { if (color == byte.MaxValue || (int) Main.tile[x, y].color() == (int) color || !WorldGen.paintTile(x, y, color, true)) return; --obj.stack; if (obj.stack <= 0) obj.SetDefaults(); if (!applyItemAnimation) return; this.ApplyItemTime(this.inventory[this.selectedItem], this.tileSpeed); } } private void ShootFromCannon(int x, int y) { int ammo = 0; if (Main.tile[x, y].frameX < (short) 72) { if (this.inventory[this.selectedItem].type == 929) ammo = 1; } else if (Main.tile[x, y].frameX < (short) 144) { if (this.inventory[this.selectedItem].type == 1338) ammo = 2; } else if (Main.tile[x, y].frameX < (short) 288 && this.inventory[this.selectedItem].type == 1345) ammo = 3; if (ammo <= 0) return; this.cursorItemIconEnabled = true; if (!this.ItemTimeIsZero || this.itemAnimation <= 0 || !this.controlUseItem) return; int num1 = (int) Main.tile[x, y].frameX / 18; int num2 = 0; int angle = 0; for (; num1 >= 4; num1 -= 4) ++num2; int x1 = x - num1; int num3; for (num3 = (int) Main.tile[x, y].frameY / 18; num3 >= 3; num3 -= 3) ++angle; int y1 = y - num3; this.ApplyItemTime(this.inventory[this.selectedItem]); WorldGen.ShootFromCannon(x1, y1, angle, ammo, this.inventory[this.selectedItem].damage, 8f, Main.myPlayer); } private void ExtractinatorUse(int extractType) { int maxValue1 = 5000; int maxValue2 = 25; int maxValue3 = 50; int maxValue4 = -1; if (extractType == 1) { maxValue1 /= 3; maxValue2 *= 2; maxValue3 = 20; maxValue4 = 10; } int Stack = 1; int Type; if (maxValue4 != -1 && Main.rand.Next(maxValue4) == 0) { Type = 3380; if (Main.rand.Next(5) == 0) Stack += Main.rand.Next(2); if (Main.rand.Next(10) == 0) Stack += Main.rand.Next(3); if (Main.rand.Next(15) == 0) Stack += Main.rand.Next(4); } else if (Main.rand.Next(2) == 0) { if (Main.rand.Next(12000) == 0) { Type = 74; if (Main.rand.Next(14) == 0) Stack += Main.rand.Next(0, 2); if (Main.rand.Next(14) == 0) Stack += Main.rand.Next(0, 2); if (Main.rand.Next(14) == 0) Stack += Main.rand.Next(0, 2); } else if (Main.rand.Next(800) == 0) { Type = 73; if (Main.rand.Next(6) == 0) Stack += Main.rand.Next(1, 21); if (Main.rand.Next(6) == 0) Stack += Main.rand.Next(1, 21); if (Main.rand.Next(6) == 0) Stack += Main.rand.Next(1, 21); if (Main.rand.Next(6) == 0) Stack += Main.rand.Next(1, 21); if (Main.rand.Next(6) == 0) Stack += Main.rand.Next(1, 20); } else if (Main.rand.Next(60) == 0) { Type = 72; if (Main.rand.Next(4) == 0) Stack += Main.rand.Next(5, 26); if (Main.rand.Next(4) == 0) Stack += Main.rand.Next(5, 26); if (Main.rand.Next(4) == 0) Stack += Main.rand.Next(5, 26); if (Main.rand.Next(4) == 0) Stack += Main.rand.Next(5, 25); } else { Type = 71; if (Main.rand.Next(3) == 0) Stack += Main.rand.Next(10, 26); if (Main.rand.Next(3) == 0) Stack += Main.rand.Next(10, 26); if (Main.rand.Next(3) == 0) Stack += Main.rand.Next(10, 26); if (Main.rand.Next(3) == 0) Stack += Main.rand.Next(10, 25); } } else if (maxValue1 != -1 && Main.rand.Next(maxValue1) == 0) Type = 1242; else if (maxValue2 != -1 && Main.rand.Next(maxValue2) == 0) { switch (Main.rand.Next(6)) { case 0: Type = 181; break; case 1: Type = 180; break; case 2: Type = 177; break; case 3: Type = 179; break; case 4: Type = 178; break; default: Type = 182; break; } if (Main.rand.Next(20) == 0) Stack += Main.rand.Next(0, 2); if (Main.rand.Next(30) == 0) Stack += Main.rand.Next(0, 3); if (Main.rand.Next(40) == 0) Stack += Main.rand.Next(0, 4); if (Main.rand.Next(50) == 0) Stack += Main.rand.Next(0, 5); if (Main.rand.Next(60) == 0) Stack += Main.rand.Next(0, 6); } else if (maxValue3 != -1 && Main.rand.Next(maxValue3) == 0) { Type = 999; if (Main.rand.Next(20) == 0) Stack += Main.rand.Next(0, 2); if (Main.rand.Next(30) == 0) Stack += Main.rand.Next(0, 3); if (Main.rand.Next(40) == 0) Stack += Main.rand.Next(0, 4); if (Main.rand.Next(50) == 0) Stack += Main.rand.Next(0, 5); if (Main.rand.Next(60) == 0) Stack += Main.rand.Next(0, 6); } else if (Main.rand.Next(3) == 0) { if (Main.rand.Next(5000) == 0) { Type = 74; if (Main.rand.Next(10) == 0) Stack += Main.rand.Next(0, 3); if (Main.rand.Next(10) == 0) Stack += Main.rand.Next(0, 3); if (Main.rand.Next(10) == 0) Stack += Main.rand.Next(0, 3); if (Main.rand.Next(10) == 0) Stack += Main.rand.Next(0, 3); if (Main.rand.Next(10) == 0) Stack += Main.rand.Next(0, 3); } else if (Main.rand.Next(400) == 0) { Type = 73; if (Main.rand.Next(5) == 0) Stack += Main.rand.Next(1, 21); if (Main.rand.Next(5) == 0) Stack += Main.rand.Next(1, 21); if (Main.rand.Next(5) == 0) Stack += Main.rand.Next(1, 21); if (Main.rand.Next(5) == 0) Stack += Main.rand.Next(1, 21); if (Main.rand.Next(5) == 0) Stack += Main.rand.Next(1, 20); } else if (Main.rand.Next(30) == 0) { Type = 72; if (Main.rand.Next(3) == 0) Stack += Main.rand.Next(5, 26); if (Main.rand.Next(3) == 0) Stack += Main.rand.Next(5, 26); if (Main.rand.Next(3) == 0) Stack += Main.rand.Next(5, 26); if (Main.rand.Next(3) == 0) Stack += Main.rand.Next(5, 25); } else { Type = 71; if (Main.rand.Next(2) == 0) Stack += Main.rand.Next(10, 26); if (Main.rand.Next(2) == 0) Stack += Main.rand.Next(10, 26); if (Main.rand.Next(2) == 0) Stack += Main.rand.Next(10, 26); if (Main.rand.Next(2) == 0) Stack += Main.rand.Next(10, 25); } } else { switch (Main.rand.Next(8)) { case 0: Type = 12; break; case 1: Type = 11; break; case 2: Type = 14; break; case 3: Type = 13; break; case 4: Type = 699; break; case 5: Type = 700; break; case 6: Type = 701; break; default: Type = 702; break; } if (Main.rand.Next(20) == 0) Stack += Main.rand.Next(0, 2); if (Main.rand.Next(30) == 0) Stack += Main.rand.Next(0, 3); if (Main.rand.Next(40) == 0) Stack += Main.rand.Next(0, 4); if (Main.rand.Next(50) == 0) Stack += Main.rand.Next(0, 5); if (Main.rand.Next(60) == 0) Stack += Main.rand.Next(0, 6); } if (Type <= 0) return; Vector2 vector2 = Main.ReverseGravitySupport(Main.MouseScreen) + Main.screenPosition; if (Main.SmartCursorEnabled || PlayerInput.UsingGamepad) vector2 = this.Center; int number = Item.NewItem((int) vector2.X, (int) vector2.Y, 1, 1, Type, Stack, pfix: -1); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } public void ChangeDir(int dir) { if (!this.pulley || this.pulleyDir != (byte) 2) { this.direction = dir; } else { if (this.pulleyDir == (byte) 2 && dir == this.direction) return; int num = (int) ((double) this.position.X + (double) (this.width / 2)) / 16 * 16 + 8 - this.width / 2; if (Collision.SolidCollision(new Vector2((float) num, this.position.Y), this.width, this.height)) return; if (this.whoAmI == Main.myPlayer) Main.cameraX = Main.cameraX + this.position.X - (float) num; this.pulleyDir = (byte) 1; this.position.X = (float) num; this.direction = dir; } } public Microsoft.Xna.Framework.Rectangle getRect() => new Microsoft.Xna.Framework.Rectangle((int) this.position.X, (int) this.position.Y, this.width, this.height); private void pumpkinSword(int i, int dmg, float kb) { int checkScreenHeight = Main.LogicCheckScreenHeight; int checkScreenWidth = Main.LogicCheckScreenWidth; int num1 = Main.rand.Next(100, 300); int num2 = Main.rand.Next(100, 300); int num3 = Main.rand.Next(2) != 0 ? num1 + (checkScreenWidth / 2 - num1) : num1 - (checkScreenWidth / 2 + num1); int num4 = Main.rand.Next(2) != 0 ? num2 + (checkScreenHeight / 2 - num2) : num2 - (checkScreenHeight / 2 + num2); int num5 = num3 + (int) this.position.X; int num6 = num4 + (int) this.position.Y; Vector2 vector2 = new Vector2((float) num5, (float) num6); float num7 = Main.npc[i].position.X - vector2.X; float num8 = Main.npc[i].position.Y - vector2.Y; float num9 = (float) (8.0 / Math.Sqrt((double) num7 * (double) num7 + (double) num8 * (double) num8)); float SpeedX = num7 * num9; float SpeedY = num8 * num9; Projectile.NewProjectile((float) num5, (float) num6, SpeedX, SpeedY, 321, dmg, kb, this.whoAmI, (float) i); } public void PutItemInInventoryFromItemUsage(int type, int selItem = -1) { for (int index = 0; index < 58; ++index) { Item obj = this.inventory[index]; if (obj.stack > 0 && obj.type == type && obj.stack < obj.maxStack) { ++obj.stack; return; } } if (selItem >= 0 && (this.inventory[selItem].type == 0 || this.inventory[selItem].stack <= 0)) { this.inventory[selItem].SetDefaults(type); } else { Item newItem = new Item(); newItem.SetDefaults(type); if (this.GetItem(this.whoAmI, newItem, GetItemSettings.ItemCreatedFromItemUsage).stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, type, noGrabDelay: true); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } else { newItem.position.X = this.Center.X - (float) (newItem.width / 2); newItem.position.Y = this.Center.Y - (float) (newItem.height / 2); newItem.active = true; PopupText.NewText(PopupTextContext.RegularItemPickup, newItem, 0); } } } public bool SummonItemCheck() { int type = this.inventory[this.selectedItem].type; for (int index = 0; index < 200; ++index) { NPC npc = Main.npc[index]; if (npc.active && (type == 43 && npc.type == 4 || type == 70 && npc.type == 13 || type == 560 & npc.type == 50 || type == 544 && npc.type == 125 || type == 544 && npc.type == 126 || type == 556 && npc.type == 134 || type == 557 && npc.type == (int) sbyte.MaxValue || type == 1133 && npc.type == 222 || type == 1331 && npc.type == 266 || type == 4988 && npc.type == 657)) return false; } return true; } public PlayerFishingConditions GetFishingConditions() { PlayerFishingConditions fishingConditions = new PlayerFishingConditions(); this.Fishing_GetBestFishingPole(out fishingConditions.PolePower, out fishingConditions.PoleItemType); this.Fishing_GetBait(out fishingConditions.BaitPower, out fishingConditions.BaitItemType); if (fishingConditions.BaitItemType == 2673 || fishingConditions.BaitPower == 0 || fishingConditions.PolePower == 0) return fishingConditions; int num = fishingConditions.BaitPower + fishingConditions.PolePower + this.fishingSkill; fishingConditions.LevelMultipliers = Player.Fishing_GetPowerMultiplier(); fishingConditions.FinalFishingLevel = (int) ((double) num * (double) fishingConditions.LevelMultipliers); return fishingConditions; } private static float Fishing_GetPowerMultiplier() { float num = 1f; if (Main.raining) num *= 1.2f; if ((double) Main.cloudBGAlpha > 0.0) num *= 1.1f; if (Main.dayTime && (Main.time < 5400.0 || Main.time > 48600.0)) num *= 1.3f; if (Main.dayTime && Main.time > 16200.0 && Main.time < 37800.0) num *= 0.8f; if (!Main.dayTime && Main.time > 6480.0 && Main.time < 25920.0) num *= 0.8f; if (Main.moonPhase == 0) num *= 1.1f; if (Main.moonPhase == 1 || Main.moonPhase == 7) num *= 1.05f; if (Main.moonPhase == 3 || Main.moonPhase == 5) num *= 0.95f; if (Main.moonPhase == 4) num *= 0.9f; if (Main.bloodMoon) num *= 1.1f; return num; } private void Fishing_GetBait(out int baitPower, out int baitType) { baitPower = 0; baitType = 0; for (int index = 54; index < 58; ++index) { if (this.inventory[index].stack > 0 && this.inventory[index].bait > 0) { baitPower = this.inventory[index].bait; baitType = this.inventory[index].type; break; } } if (baitPower != 0 || baitType != 0) return; for (int index = 0; index < 50; ++index) { if (this.inventory[index].stack > 0 && this.inventory[index].bait > 0) { baitPower = this.inventory[index].bait; baitType = this.inventory[index].type; break; } } } private void Fishing_GetBestFishingPole(out int fishingPolePower, out int fishingPoleType) { fishingPolePower = this.inventory[this.selectedItem].fishingPole; fishingPoleType = this.inventory[this.selectedItem].type; if (fishingPolePower != 0) return; for (int index = 0; index < 58; ++index) { if (this.inventory[index].fishingPole > fishingPolePower) { fishingPolePower = this.inventory[index].fishingPole; fishingPoleType = this.inventory[index].type; } } } public bool HasUnityPotion() { for (int index = 0; index < 58; ++index) { if (this.inventory[index].type == 2997 && this.inventory[index].stack > 0) return true; } return false; } public void TakeUnityPotion() { for (int index = 0; index < 400; ++index) { if (this.inventory[index].type == 2997 && this.inventory[index].stack > 0) { --this.inventory[index].stack; if (this.inventory[index].stack > 0) break; this.inventory[index].SetDefaults(); break; } } } public void UnityTeleport(Vector2 telePos) { int num = 3; if (Main.netMode == 0) this.Teleport(telePos, num); else NetMessage.SendData(65, number: 2, number2: ((float) this.whoAmI), number3: telePos.X, number4: telePos.Y, number5: num); } private void PayDD2CrystalsBeforeUse(Item item) { int dd2CrystalsToUse = this.GetRequiredDD2CrystalsToUse(item); for (int index = 0; index < dd2CrystalsToUse; ++index) this.ConsumeItem(3822, true); } private bool CheckDD2CrystalPaymentLock(Item item) { if (!DD2Event.Ongoing) return true; int dd2CrystalsToUse = this.GetRequiredDD2CrystalsToUse(item); return this.CountItem(3822, dd2CrystalsToUse) >= dd2CrystalsToUse; } private int GetRequiredDD2CrystalsToUse(Item item) { switch (item.type) { case 3818: case 3819: case 3820: return 10; case 3824: case 3825: case 3826: return 10; case 3829: case 3830: case 3831: return 10; case 3832: case 3833: case 3834: return 10; default: return 0; } } public void SporeSac() { int Damage = 70; float KnockBack = 1.5f; if (Main.rand.Next(15) != 0) return; int num1 = 0; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI && (Main.projectile[index].type == 567 || Main.projectile[index].type == 568)) ++num1; } if (Main.rand.Next(15) < num1 || num1 >= 10) return; int num2 = 50; int num3 = 24; int num4 = 90; for (int index1 = 0; index1 < num2; ++index1) { int num5 = Main.rand.Next(200 - index1 * 2, 400 + index1 * 2); Vector2 center = this.Center; center.X += (float) Main.rand.Next(-num5, num5 + 1); center.Y += (float) Main.rand.Next(-num5, num5 + 1); if (!Collision.SolidCollision(center, num3, num3) && !Collision.WetCollision(center, num3, num3)) { center.X += (float) (num3 / 2); center.Y += (float) (num3 / 2); if (Collision.CanHit(new Vector2(this.Center.X, this.position.Y), 1, 1, center, 1, 1) || Collision.CanHit(new Vector2(this.Center.X, this.position.Y - 50f), 1, 1, center, 1, 1)) { int index2 = (int) center.X / 16; int index3 = (int) center.Y / 16; bool flag = false; if (Main.rand.Next(3) == 0 && Main.tile[index2, index3] != null && Main.tile[index2, index3].wall > (ushort) 0) { flag = true; } else { center.X -= (float) (num4 / 2); center.Y -= (float) (num4 / 2); if (Collision.SolidCollision(center, num4, num4)) { center.X += (float) (num4 / 2); center.Y += (float) (num4 / 2); flag = true; } else if (Main.tile[index2, index3] != null && Main.tile[index2, index3].active() && Main.tile[index2, index3].type == (ushort) 19) flag = true; } if (flag) { for (int index4 = 0; index4 < 1000; ++index4) { if (Main.projectile[index4].active && Main.projectile[index4].owner == this.whoAmI && Main.projectile[index4].aiStyle == 105 && (double) (center - Main.projectile[index4].Center).Length() < 48.0) { flag = false; break; } } if (flag && Main.myPlayer == this.whoAmI) { Projectile.NewProjectile(center.X, center.Y, 0.0f, 0.0f, 567 + Main.rand.Next(2), Damage, KnockBack, this.whoAmI); break; } } } } } } public void VolatileGelatin() { if (Main.myPlayer != this.whoAmI) return; ++this.volatileGelatinCounter; if (this.volatileGelatinCounter <= 50) return; this.volatileGelatinCounter = 0; int Damage = 65; float KnockBack = 7f; float num1 = 640f; NPC npc1 = (NPC) null; for (int index = 0; index < 200; ++index) { NPC npc2 = Main.npc[index]; if (npc2 != null && npc2.active && npc2.CanBeChasedBy((object) this) && Collision.CanHit((Entity) this, (Entity) npc2)) { float num2 = Vector2.Distance(npc2.Center, this.Center); if ((double) num2 < (double) num1) { num1 = num2; npc1 = npc2; } } } if (npc1 == null) return; Vector2 vector2 = (npc1.Center - this.Center).SafeNormalize(Vector2.Zero) * 6f; vector2.Y -= 2f; Projectile.NewProjectile(this.Center.X, this.Center.Y, vector2.X, vector2.Y, 937, Damage, KnockBack, this.whoAmI); } public bool CanHit(Entity ent) => Collision.CanHit(this.position, this.width, this.height, ent.position, ent.width, ent.height) || Collision.CanHitLine(this.Center + new Vector2((float) (this.direction * this.width / 2), (float) ((double) this.gravDir * (double) -this.height / 3.0)), 0, 0, ent.Center + new Vector2(0.0f, (float) (-ent.height / 3)), 0, 0) || Collision.CanHitLine(this.Center + new Vector2((float) (this.direction * this.width / 2), (float) ((double) this.gravDir * (double) -this.height / 3.0)), 0, 0, ent.Center, 0, 0) || Collision.CanHitLine(this.Center + new Vector2((float) (this.direction * this.width / 2), 0.0f), 0, 0, ent.Center + new Vector2(0.0f, (float) (ent.height / 3)), 0, 0); public Microsoft.Xna.Framework.Rectangle GetItemDrawFrame(int type) { Main.instance.LoadItem(type); return type == 75 ? TextureAssets.Item[type].Frame(verticalFrames: 8) : TextureAssets.Item[type].Frame(); } public void ItemCheck(int i) { if (this.CCed) { this.channel = false; this.itemAnimation = this.itemAnimationMax = 0; } else { bool consumptionFailed = false; float offsetHitboxCenter = this.HeightOffsetHitboxCenter; Item sItem1 = this.inventory[this.selectedItem]; if (Main.myPlayer == i && PlayerInput.ShouldFastUseItem) this.controlUseItem = true; this.ItemCheck_HandleMount(); int weaponDamage = this.GetWeaponDamage(sItem1); this.ItemCheck_HandleMPItemAnimation(sItem1); this.ItemCheck_HackHoldStyles(sItem1); if (this.itemAnimation < 0) this.itemAnimation = 0; if (this.itemTime < 0) this.itemTime = 0; if (this.itemAnimation == 0 && this.reuseDelay > 0) this.ApplyReuseDelay(); if (Main.myPlayer == i && this.itemAnimation == 0 && TileObjectData.CustomPlace(sItem1.createTile, sItem1.placeStyle)) TileObject.CanPlace(Player.tileTargetX, Player.tileTargetY, sItem1.createTile, sItem1.placeStyle, this.direction, out TileObject _, true); if (this.itemAnimation == 0 && this.altFunctionUse == 2) this.altFunctionUse = 0; bool flag1 = true; if ((double) this.gravDir == -1.0 && GolfHelper.IsPlayerHoldingClub(this)) flag1 = false; if (flag1 && this.controlUseItem && this.releaseUseItem && this.itemAnimation == 0 && sItem1.useStyle != 0) { if (this.altFunctionUse == 1) this.altFunctionUse = 2; if (sItem1.shoot == 0) this.itemRotation = 0.0f; bool flag2 = this.ItemCheck_CheckCanUse(sItem1); if (sItem1.potion & flag2) this.ApplyPotionDelay(sItem1); if (sItem1.mana > 0 & flag2 && this.whoAmI == Main.myPlayer && sItem1.buffType != 0 && sItem1.buffTime != 0) this.AddBuff(sItem1.buffType, sItem1.buffTime); if ((sItem1.shoot <= 0 || !ProjectileID.Sets.MinionTargettingFeature[sItem1.shoot] ? 0 : (this.altFunctionUse == 2 ? 1 : 0)) == 0) this.ItemCheck_ApplyPetBuffs(sItem1); if (this.whoAmI == Main.myPlayer && (double) this.gravDir == 1.0 && sItem1.mountType != -1 && this.mount.CanMount(sItem1.mountType, this)) this.mount.SetMount(sItem1.mountType, this); if ((sItem1.shoot <= 0 || !ProjectileID.Sets.MinionTargettingFeature[sItem1.shoot] ? 0 : (this.altFunctionUse == 2 ? 1 : 0)) == 0 & flag2 && this.whoAmI == Main.myPlayer && sItem1.shoot >= 0 && sItem1.shoot < 950 && (ProjectileID.Sets.LightPet[sItem1.shoot] || Main.projPet[sItem1.shoot])) this.FreeUpPetsAndMinions(sItem1); if (flag2) this.ItemCheck_StartActualUse(sItem1); } if (!this.controlUseItem) this.channel = false; Item sItem2 = this.itemAnimation > 0 ? this.lastVisualizedSelectedItem : sItem1; Microsoft.Xna.Framework.Rectangle drawHitbox = Item.GetDrawHitbox(sItem2.type, this); this.compositeFrontArm.enabled = false; this.compositeBackArm.enabled = false; if (this.itemAnimation > 0) { if (sItem1.mana > 0) this.ItemCheck_ApplyManaRegenDelay(sItem1); if (Main.dedServ) { this.itemHeight = sItem1.height; this.itemWidth = sItem1.width; } else { this.itemHeight = drawHitbox.Height; this.itemWidth = drawHitbox.Width; } --this.itemAnimation; } if (this.itemAnimation > 0) this.ItemCheck_ApplyUseStyle(offsetHitboxCenter, sItem2, drawHitbox); else this.ItemCheck_ApplyHoldStyle(offsetHitboxCenter, sItem2, drawHitbox); this.releaseUseItem = !this.controlUseItem; if (this.itemTime > 0) { --this.itemTime; if (this.ItemTimeIsZero && this.whoAmI == Main.myPlayer) { if (!this.JustDroppedAnItem) { switch (sItem1.type) { case 65: case 676: case 723: case 724: case 989: case 1226: case 1227: this.EmitMaxManaEffect(); break; } } PlayerInput.TryEndingFastUse(); } } if (!this.JustDroppedAnItem) { this.ItemCheck_EmitHeldItemLight(sItem1); this.ItemCheck_EmitFoodParticles(sItem1); this.ItemCheck_EmitDrinkParticles(sItem1); if (this.whoAmI == Main.myPlayer) { bool cShoot = true; int type = sItem1.type; if ((type == 65 || type == 676 || type == 723 || type == 724 || type == 757 || type == 674 || type == 675 || type == 989 || type == 1226 || type == 1227) && this.itemAnimation != this.itemAnimationMax - 1) cShoot = false; if (type == 3852) { if (this.itemAnimation < this.itemAnimationMax - 12) cShoot = false; if (this.altFunctionUse == 2 && this.itemAnimation != this.itemAnimationMax - 1) cShoot = false; } if (type == 4956 && this.itemAnimation < this.itemAnimationMax - 3 * sItem1.useTime) cShoot = false; if (type == 4952 && this.itemAnimation < this.itemAnimationMax - 8) cShoot = false; if (type == 4953 && this.itemAnimation < this.itemAnimationMax - 10) cShoot = false; this.ItemCheck_TurretAltFeatureUse(sItem1, cShoot); this.ItemCheck_MinionAltFeatureUse(sItem1, cShoot); if (((sItem1.shoot <= 0 || this.itemAnimation <= 0 ? 0 : (this.ItemTimeIsZero ? 1 : 0)) & (cShoot ? 1 : 0)) != 0) this.ItemCheck_Shoot(i, sItem1, weaponDamage); this.ItemCheck_UseWiringTools(sItem1); this.ItemCheck_UseLawnMower(sItem1); this.ItemCheck_PlayInstruments(sItem1); this.ItemCheck_UseBuckets(sItem1); if (!this.channel) { this.toolTime = this.itemTime; } else { --this.toolTime; if (this.toolTime < 0) this.toolTime = sItem1.useTime; } this.ItemCheck_UseMiningTools(sItem1); this.ItemCheck_UseRodOfDiscord(sItem1); this.ItemCheck_UseLifeCrystal(sItem1); this.ItemCheck_UseLifeFruit(sItem1); this.ItemCheck_UseManaCrystal(sItem1); this.ItemCheck_UseDemonHeart(sItem1); this.ItemCheck_UseTorchGodsFavor(sItem1); this.ItemCheck_UseEventItems(sItem1); this.ItemCheck_UseBossSpawners(this.whoAmI, sItem1); this.ItemCheck_UseCombatBook(sItem1); this.ItemCheck_UsePetLicenses(sItem1); if (sItem1.type == 4095 && this.itemAnimation == 2) Main.LocalGolfState.ResetGolfBall(); this.PlaceThing(); if (sItem1.makeNPC > (short) 0) { if (!Main.GamepadDisableCursorItemIcon && (double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) sItem1.tileBoost <= (double) Player.tileTargetX && ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) sItem1.tileBoost - 1.0 >= (double) Player.tileTargetX && (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) sItem1.tileBoost <= (double) Player.tileTargetY && ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) sItem1.tileBoost - 2.0 >= (double) Player.tileTargetY) { this.cursorItemIconEnabled = true; Main.ItemIconCacheUpdate(sItem1.type); } if (this.ItemTimeIsZero && this.itemAnimation > 0 && this.controlUseItem) consumptionFailed = this.ItemCheck_ReleaseCritter(consumptionFailed, sItem1); } } if ((sItem1.damage >= 0 && sItem1.type > 0 && !sItem1.noMelee || sItem1.type == 1450 || sItem1.type == 1991 || sItem1.type == 3183 || sItem1.type == 4821 || sItem1.type == 3542 || sItem1.type == 3779) && this.itemAnimation > 0) { bool dontAttack; Microsoft.Xna.Framework.Rectangle itemRectangle1; this.ItemCheck_GetMeleeHitbox(sItem1, drawHitbox, out dontAttack, out itemRectangle1); if (!dontAttack) { Microsoft.Xna.Framework.Rectangle itemRectangle2 = this.ItemCheck_EmitUseVisuals(sItem1, itemRectangle1); if (Main.myPlayer == this.whoAmI && (sItem1.type == 1991 || sItem1.type == 3183 || sItem1.type == 4821)) itemRectangle2 = this.ItemCheck_CatchCritters(sItem1, itemRectangle2); if (sItem1.type == 3183 || sItem1.type == 4821) { List tileCutIgnoreList = Player.ItemCheck_GetTileCutIgnoreList(sItem1); Player.ItemCheck_CutTiles(sItem1, itemRectangle2, tileCutIgnoreList); } if (Main.myPlayer == i && sItem1.damage > 0) { int num1 = weaponDamage; float knockBack1 = sItem1.knockBack; float num2 = 1f; if (this.kbGlove) ++num2; if (this.kbBuff) num2 += 0.5f; float knockBack2 = knockBack1 * num2; if (this.inventory[this.selectedItem].type == 3106) knockBack2 += knockBack2 * (1f - this.stealth); List tileCutIgnoreList = Player.ItemCheck_GetTileCutIgnoreList(sItem1); Player.ItemCheck_CutTiles(sItem1, itemRectangle2, tileCutIgnoreList); this.ItemCheck_MeleeHitNPCs(sItem1, itemRectangle2, num1, knockBack2); this.ItemCheck_MeleeHitPVP(sItem1, itemRectangle2, num1, knockBack2); this.ItemCheck_EmitHammushProjectiles(i, sItem1, itemRectangle2, num1); } } } if (this.ItemTimeIsZero && this.itemAnimation > 0) { if (sItem1.hairDye >= (short) 0) { this.ApplyItemTime(sItem1); if (this.whoAmI == Main.myPlayer) { this.hairDye = (byte) sItem1.hairDye; NetMessage.SendData(4, number: this.whoAmI); } } if (sItem1.healLife > 0) { this.statLife += sItem1.healLife; this.ApplyItemTime(sItem1); if (Main.myPlayer == this.whoAmI) this.HealEffect(sItem1.healLife); } if (sItem1.healMana > 0) { this.statMana += sItem1.healMana; this.ApplyItemTime(sItem1); if (Main.myPlayer == this.whoAmI) { this.AddBuff(94, Player.manaSickTime); this.ManaEffect(sItem1.healMana); } } if (sItem1.buffType > 0) { if (this.whoAmI == Main.myPlayer && sItem1.buffType != 90 && sItem1.buffType != 27) this.AddBuff(sItem1.buffType, sItem1.buffTime); this.ApplyItemTime(sItem1); } if (sItem1.type == 678) { if (Main.getGoodWorld) { this.ApplyItemTime(sItem1); if (this.whoAmI == Main.myPlayer) { for (int index = 0; index < 3; ++index) { int type = 0; int timeToAdd = 108000; switch (Main.rand.Next(18)) { case 0: type = 16; break; case 1: type = 111; break; case 2: type = 114; break; case 3: type = 8; break; case 4: type = 105; break; case 5: type = 17; break; case 6: type = 116; break; case 7: type = 5; break; case 8: type = 113; break; case 9: type = 7; break; case 10: type = 6; break; case 11: type = 104; break; case 12: type = 115; break; case 13: type = 2; break; case 14: type = 9; break; case 15: type = 3; break; case 16: type = 117; break; case 17: type = 1; break; } this.AddBuff(type, timeToAdd); } } } else { this.ApplyItemTime(sItem1); if (this.whoAmI == Main.myPlayer) { this.AddBuff(20, 216000); this.AddBuff(22, 216000); this.AddBuff(23, 216000); this.AddBuff(24, 216000); this.AddBuff(30, 216000); this.AddBuff(31, 216000); this.AddBuff(32, 216000); this.AddBuff(33, 216000); this.AddBuff(35, 216000); this.AddBuff(36, 216000); this.AddBuff(68, 216000); } } } } if ((sItem1.type == 50 || sItem1.type == 3124 || sItem1.type == 3199) && this.itemAnimation > 0) { if (Main.rand.Next(2) == 0) Dust.NewDust(this.position, this.width, this.height, 15, Alpha: 150, Scale: 1.1f); if (this.ItemTimeIsZero) this.ApplyItemTime(sItem1); else if (this.itemTime == sItem1.useTime / 2) { for (int index = 0; index < 70; ++index) Dust.NewDust(this.position, this.width, this.height, 15, this.velocity.X * 0.5f, this.velocity.Y * 0.5f, 150, Scale: 1.5f); this.RemoveAllGrapplingHooks(); this.Spawn(PlayerSpawnContext.RecallFromItem); for (int index = 0; index < 70; ++index) Dust.NewDust(this.position, this.width, this.height, 15, Alpha: 150, Scale: 1.5f); } } if (sItem1.type == 4263 && this.itemAnimation > 0) { Vector2 vector2 = Vector2.UnitY.RotatedBy((double) this.itemAnimation * 6.28318548202515 / 30.0) * new Vector2(15f, 0.0f); for (int index = 0; index < 2; ++index) { if (Main.rand.Next(3) == 0) { Dust dust = Dust.NewDustPerfect(this.Bottom + vector2, Dust.dustWater()); dust.velocity.Y *= 0.0f; dust.velocity.Y -= 4.5f; dust.velocity.X *= 1.5f; dust.scale = 0.8f; dust.alpha = 130; dust.noGravity = true; dust.fadeIn = 1.1f; } } if (this.ItemTimeIsZero) this.ApplyItemTime(sItem1); else if (this.itemTime == 2) { switch (Main.netMode) { case 0: this.MagicConch(); break; case 1: if (this.whoAmI == Main.myPlayer) { NetMessage.SendData(73, number: 1); break; } break; } } } if (sItem1.type == 4819 && this.itemAnimation > 0) { Vector2 vector2 = Vector2.UnitY.RotatedBy((double) this.itemAnimation * 6.28318548202515 / 30.0) * new Vector2(15f, 0.0f); for (int index = 0; index < 2; ++index) { if (Main.rand.Next(3) == 0) { Dust dust = Dust.NewDustPerfect(this.Bottom + vector2, 35); dust.velocity.Y *= 0.0f; dust.velocity.Y -= 4.5f; dust.velocity.X *= 1.5f; dust.scale = 0.8f; dust.alpha = 130; dust.noGravity = true; dust.fadeIn = 1.1f; } } if (this.ItemTimeIsZero) this.ApplyItemTime(sItem1); else if (this.itemTime == 2) { switch (Main.netMode) { case 0: this.DemonConch(); break; case 1: if (this.whoAmI == Main.myPlayer) { NetMessage.SendData(73, number: 2); break; } break; } } } if (sItem1.type == 2350 && this.itemAnimation > 0) { if (this.ItemTimeIsZero) { this.ApplyItemTime(sItem1); SoundEngine.PlaySound(SoundID.Item3, this.position); for (int index = 0; index < 10; ++index) Main.dust[Dust.NewDust(this.position, this.width, this.height, 15, this.velocity.X * 0.2f, this.velocity.Y * 0.2f, 150, Color.Cyan, 1.2f)].velocity *= 0.5f; } else if (this.itemTime == 20) { SoundEngine.PlaySound(this.HeldItem.UseSound, this.position); for (int index = 0; index < 70; ++index) Main.dust[Dust.NewDust(this.position, this.width, this.height, 15, this.velocity.X * 0.2f, this.velocity.Y * 0.2f, 150, Color.Cyan, 1.2f)].velocity *= 0.5f; this.RemoveAllGrapplingHooks(); bool immune = this.immune; int immuneTime = this.immuneTime; this.Spawn(PlayerSpawnContext.RecallFromItem); this.immune = immune; this.immuneTime = immuneTime; for (int index = 0; index < 70; ++index) Main.dust[Dust.NewDust(this.position, this.width, this.height, 15, Alpha: 150, newColor: Color.Cyan, Scale: 1.2f)].velocity *= 0.5f; if (sItem1.stack > 0) --sItem1.stack; } } if (sItem1.type == 4870 && this.itemAnimation > 0) { if (this.ItemTimeIsZero) { this.ApplyItemTime(sItem1); SoundEngine.PlaySound(SoundID.Item3, this.position); for (int index = 0; index < 10; ++index) Main.dust[Dust.NewDust(this.position, this.width, this.height, 15, this.velocity.X * 0.2f, this.velocity.Y * 0.2f, 150, Color.Cyan, 1.2f)].velocity *= 0.5f; } else if (this.itemTime == 20) { SoundEngine.PlaySound(this.HeldItem.UseSound, this.position); for (int index = 0; index < 70; ++index) Main.dust[Dust.NewDust(this.position, this.width, this.height, 15, this.velocity.X * 0.2f, this.velocity.Y * 0.2f, 150, Color.Cyan, 1.2f)].velocity *= 0.5f; this.DoPotionOfReturnTeleportationAndSetTheComebackPoint(); for (int index = 0; index < 70; ++index) Main.dust[Dust.NewDust(this.position, this.width, this.height, 15, Alpha: 150, newColor: Color.Cyan, Scale: 1.2f)].velocity *= 0.5f; if (sItem1.stack > 0) --sItem1.stack; } } if (sItem1.type == 2351 && this.itemAnimation > 0) { if (this.ItemTimeIsZero) this.ApplyItemTime(sItem1); else if (this.itemTime == 2) { switch (Main.netMode) { case 0: this.TeleportationPotion(); break; case 1: if (this.whoAmI == Main.myPlayer) { NetMessage.SendData(73); break; } break; } if (sItem1.stack > 0) --sItem1.stack; } } if (sItem1.type == 2756 && this.itemAnimation > 0) { if (this.ItemTimeIsZero) this.ApplyItemTime(sItem1); else if (this.itemTime == 2) { if (this.whoAmI == Main.myPlayer) { this.Male = !this.Male; if (Main.netMode == 1) NetMessage.SendData(4, number: this.whoAmI); } if (sItem1.stack > 0) --sItem1.stack; } else { float useTime = (float) sItem1.useTime; float num3 = (useTime - (float) this.itemTime) / useTime; float num4 = 44f; Vector2 vector2 = new Vector2(15f, 0.0f).RotatedBy(9.42477798461914 * (double) num3); vector2.X *= (float) this.direction; for (int index1 = 0; index1 < 2; ++index1) { int Type = 221; if (index1 == 1) { vector2.X *= -1f; Type = 219; } Vector2 Position = new Vector2(vector2.X, num4 * (1f - num3) - num4 + (float) (this.height / 2)); Position += this.Center; int index2 = Dust.NewDust(Position, 0, 0, Type, Alpha: 100); Main.dust[index2].position = Position; Main.dust[index2].noGravity = true; Main.dust[index2].velocity = Vector2.Zero; Main.dust[index2].scale = 1.3f; Main.dust[index2].customData = (object) this; } } } if (i == Main.myPlayer) { if (((this.itemTimeMax == 0 ? 0 : (this.itemTime == this.itemTimeMax ? 1 : 0)) | (sItem1.IsAir ? 0 : (sItem1.IsNotTheSameAs(this.lastVisualizedSelectedItem) ? 1 : 0))) != 0) this.lastVisualizedSelectedItem = sItem1.Clone(); } else this.lastVisualizedSelectedItem = sItem1.Clone(); if (i == Main.myPlayer) { if (!this.dontConsumeWand && this.itemTime == (int) ((double) sItem1.useTime * (double) this.tileSpeed) && sItem1.tileWand > 0) { int tileWand = sItem1.tileWand; for (int index = 0; index < 58; ++index) { if (tileWand == this.inventory[index].type && this.inventory[index].stack > 0) { --this.inventory[index].stack; if (this.inventory[index].stack <= 0) { this.inventory[index] = new Item(); break; } break; } } } if (this.itemTimeMax != 0 && this.itemTime == this.itemTimeMax && sItem1.consumable && !consumptionFailed) { bool flag3 = true; if (sItem1.ranged) { if (this.chloroAmmoCost80 && Main.rand.Next(5) == 0) flag3 = false; if (this.ammoCost80 && Main.rand.Next(5) == 0) flag3 = false; if (this.ammoCost75 && Main.rand.Next(4) == 0) flag3 = false; } if (sItem1.IsACoin) flag3 = true; bool? nullable = ItemID.Sets.ForceConsumption[sItem1.type]; if (nullable.HasValue) flag3 = nullable.Value; if (flag3) { if (sItem1.stack > 0) --sItem1.stack; if (sItem1.stack <= 0) { this.itemTime = this.itemAnimation; Main.blockMouse = true; } } } if (sItem1.stack <= 0 && this.itemAnimation == 0) this.inventory[this.selectedItem] = new Item(); if (this.selectedItem == 58 && this.itemAnimation != 0) Main.mouseItem = sItem1.Clone(); } } if (this.itemAnimation != 0) return; this.JustDroppedAnItem = false; } } private void ItemCheck_EmitFoodParticles(Item sItem) { if (this.itemAnimation < 1) return; Color[] foodParticleColor = ItemID.Sets.FoodParticleColors[sItem.type]; if (foodParticleColor == null || foodParticleColor.Length == 0 || Main.rand.Next(2) == 0) return; Dust.NewDustPerfect(this.RotatedRelativePoint(this.MountedCenter, addGfxOffY: false) + new Vector2((float) (this.direction * 8), this.gravDir * -4f).RotatedBy((double) this.fullRotation) + Main.rand.NextVector2Square(-4f, 4f), 284, new Vector2?(1.3f * new Vector2((float) this.direction, (float) (-(double) this.gravDir * 0.800000011920929)).RotatedBy(0.628318548202515 * (double) Main.rand.NextFloatDirection())), newColor: foodParticleColor[Main.rand.Next(foodParticleColor.Length)], Scale: ((float) (0.800000011920929 + 0.200000002980232 * (double) Main.rand.NextFloat()))).fadeIn = 0.0f; } private void ItemCheck_EmitDrinkParticles(Item sItem) { if (this.itemAnimation < 1) return; Color[] drinkParticleColor = ItemID.Sets.DrinkParticleColors[sItem.type]; if (drinkParticleColor == null || drinkParticleColor.Length == 0) return; Dust.NewDustPerfect(this.RotatedRelativePoint(this.MountedCenter, addGfxOffY: false) + new Vector2((float) (this.direction * 8), this.gravDir * -4f).RotatedBy((double) this.fullRotation) + Main.rand.NextVector2Square(-4f, 4f), 284, new Vector2?(1.3f * new Vector2((float) this.direction * 0.1f, (float) (-(double) this.gravDir * 0.100000001490116)).RotatedBy(-0.628318548202515 * (double) Main.rand.NextFloatDirection())), newColor: (drinkParticleColor[Main.rand.Next(drinkParticleColor.Length)] * 0.7f), Scale: ((float) (0.800000011920929 + 0.200000002980232 * (double) Main.rand.NextFloat()))).fadeIn = 0.0f; } private void ItemCheck_UseBossSpawners(int onWhichPlayer, Item sItem) { if (!this.ItemTimeIsZero || this.itemAnimation <= 0 || sItem.type != 43 && sItem.type != 70 && sItem.type != 544 && sItem.type != 556 && sItem.type != 557 && sItem.type != 560 && sItem.type != 1133 && sItem.type != 1331 && sItem.type != 4988 || !this.SummonItemCheck()) return; if (sItem.type == 560) { this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) NPC.SpawnOnPlayer(onWhichPlayer, 50); else NetMessage.SendData(61, number: this.whoAmI, number2: 50f); } else if (sItem.type == 43) { if (Main.dayTime) return; this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) NPC.SpawnOnPlayer(onWhichPlayer, 4); else NetMessage.SendData(61, number: this.whoAmI, number2: 4f); } else if (sItem.type == 70) { if (!this.ZoneCorrupt) return; this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) NPC.SpawnOnPlayer(onWhichPlayer, 13); else NetMessage.SendData(61, number: this.whoAmI, number2: 13f); } else if (sItem.type == 544) { if (Main.dayTime) return; this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) { NPC.SpawnOnPlayer(onWhichPlayer, 125); NPC.SpawnOnPlayer(onWhichPlayer, 126); } else { NetMessage.SendData(61, number: this.whoAmI, number2: 125f); NetMessage.SendData(61, number: this.whoAmI, number2: 126f); } } else if (sItem.type == 556) { if (Main.dayTime) return; this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) NPC.SpawnOnPlayer(onWhichPlayer, 134); else NetMessage.SendData(61, number: this.whoAmI, number2: 134f); } else if (sItem.type == 557) { if (Main.dayTime) return; this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) NPC.SpawnOnPlayer(onWhichPlayer, (int) sbyte.MaxValue); else NetMessage.SendData(61, number: this.whoAmI, number2: ((float) sbyte.MaxValue)); } else if (sItem.type == 1133) { this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) NPC.SpawnOnPlayer(onWhichPlayer, 222); else NetMessage.SendData(61, number: this.whoAmI, number2: 222f); } else if (sItem.type == 1331) { if (!this.ZoneCrimson) return; this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) NPC.SpawnOnPlayer(onWhichPlayer, 266); else NetMessage.SendData(61, number: this.whoAmI, number2: 266f); } else { if (sItem.type != 4988 || !this.ZoneHallow) return; this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) NPC.SpawnOnPlayer(onWhichPlayer, 657); else NetMessage.SendData(61, number: this.whoAmI, number2: 657f); } } private void ItemCheck_UseEventItems(Item sItem) { if (this.ItemTimeIsZero && this.itemAnimation > 0 && sItem.type == 361 && Main.CanStartInvasion(ignoreDelay: true)) { this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) { if (Main.invasionType == 0) { Main.invasionDelay = 0; Main.StartInvasion(); } } else NetMessage.SendData(61, number: this.whoAmI, number2: -1f); } if (this.ItemTimeIsZero && this.itemAnimation > 0 && sItem.type == 602 && Main.CanStartInvasion(2, true)) { this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) { if (Main.invasionType == 0) { Main.invasionDelay = 0; Main.StartInvasion(2); } } else NetMessage.SendData(61, number: this.whoAmI, number2: -2f); } if (this.ItemTimeIsZero && this.itemAnimation > 0 && sItem.type == 1315 && Main.CanStartInvasion(3, true)) { this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) { if (Main.invasionType == 0) { Main.invasionDelay = 0; Main.StartInvasion(3); } } else NetMessage.SendData(61, number: this.whoAmI, number2: -3f); } if (this.ItemTimeIsZero && this.itemAnimation > 0 && sItem.type == 1844 && !Main.dayTime && !Main.pumpkinMoon && !Main.snowMoon && !DD2Event.Ongoing) { this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) { Main.NewText(Lang.misc[31].Value, (byte) 50, B: (byte) 130); Main.startPumpkinMoon(); } else NetMessage.SendData(61, number: this.whoAmI, number2: -4f); } if (this.ItemTimeIsZero && this.itemAnimation > 0 && sItem.type == 2767 && Main.dayTime && !Main.eclipse) { SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); this.ApplyItemTime(sItem); if (Main.netMode == 0) { Main.eclipse = true; Main.NewText(Lang.misc[20].Value, (byte) 50, B: (byte) 130); } else NetMessage.SendData(61, number: this.whoAmI, number2: -6f); } if (this.ItemTimeIsZero && this.itemAnimation > 0 && sItem.type == 4271 && !Main.dayTime && !Main.bloodMoon) { SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); this.ApplyItemTime(sItem); if (Main.netMode == 0) { AchievementsHelper.NotifyProgressionEvent(4); Main.bloodMoon = true; if (Main.GetMoonPhase() == MoonPhase.Empty) Main.moonPhase = 5; Main.NewText(Lang.misc[8].Value, (byte) 50, B: (byte) 130); } else NetMessage.SendData(61, number: this.whoAmI, number2: -10f); } if (this.ItemTimeIsZero && this.itemAnimation > 0 && sItem.type == 3601 && NPC.downedGolemBoss && Main.hardMode && !NPC.AnyDanger() && !NPC.AnyoneNearCultists()) { SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); this.ApplyItemTime(sItem); if (Main.netMode == 0) WorldGen.StartImpendingDoom(); else NetMessage.SendData(61, number: this.whoAmI, number2: -8f); } if (!this.ItemTimeIsZero || this.itemAnimation <= 0 || sItem.type != 1958 || Main.dayTime || Main.pumpkinMoon || Main.snowMoon || DD2Event.Ongoing) return; this.ApplyItemTime(sItem); SoundEngine.PlaySound(15, (int) this.position.X, (int) this.position.Y, 0); if (Main.netMode != 1) { Main.NewText(Lang.misc[34].Value, (byte) 50, B: (byte) 130); Main.startSnowMoon(); } else NetMessage.SendData(61, number: this.whoAmI, number2: -5f); } private bool ItemCheck_ReleaseCritter(bool consumptionFailed, Item sItem) { if (sItem.makeNPC == (short) 614) { this.ApplyItemTime(sItem); NPC.ReleaseNPC((int) this.Center.X, (int) this.Bottom.Y, (int) sItem.makeNPC, sItem.placeStyle, this.whoAmI); } else if ((double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) sItem.tileBoost <= (double) Player.tileTargetX && ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) sItem.tileBoost - 1.0 >= (double) Player.tileTargetX && (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) sItem.tileBoost <= (double) Player.tileTargetY && ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) sItem.tileBoost - 2.0 >= (double) Player.tileTargetY) { int x = Main.mouseX + (int) Main.screenPosition.X; int y = Main.mouseY + (int) Main.screenPosition.Y; this.ApplyItemTime(sItem); if (!WorldGen.SolidTile(x / 16, y / 16)) NPC.ReleaseNPC(x, y, (int) sItem.makeNPC, sItem.placeStyle, this.whoAmI); else consumptionFailed = true; } return consumptionFailed; } private void ItemCheck_MeleeHitPVP( Item sItem, Microsoft.Xna.Framework.Rectangle itemRectangle, int damage, float knockBack) { if (!this.hostile) return; for (int index1 = 0; index1 < (int) byte.MaxValue; ++index1) { Player player = Main.player[index1]; if ((index1 == this.whoAmI || !player.active || !player.hostile || player.immune ? 0 : (!player.dead ? 1 : 0)) != 0 && (this.team == 0 ? 1 : (this.team != player.team ? 1 : 0)) != 0 && itemRectangle.Intersects(player.Hitbox) && this.CanHit((Entity) player)) { bool flag = false; if (Main.rand.Next(1, 101) <= 10) flag = true; int num1 = Main.DamageVar((float) damage, this.luck); this.StatusToPlayerPvP(sItem.type, index1); this.OnHit(player.Center.X, player.Center.Y, (Entity) player); PlayerDeathReason playerDeathReason = PlayerDeathReason.ByPlayer(this.whoAmI); int num2 = (int) player.Hurt(playerDeathReason, num1, this.direction, true, Crit: flag); if (this.inventory[this.selectedItem].type == 3211) { Vector2 vector2_1 = new Vector2((float) (this.direction * 100 + Main.rand.Next(-25, 26)), (float) Main.rand.Next(-75, 76)); vector2_1.Normalize(); vector2_1 *= (float) Main.rand.Next(30, 41) * 0.1f; Vector2 vector2_2 = new Vector2((float) (itemRectangle.X + Main.rand.Next(itemRectangle.Width)), (float) (itemRectangle.Y + Main.rand.Next(itemRectangle.Height))); vector2_2 = (vector2_2 + player.Center * 2f) / 3f; Projectile.NewProjectile(vector2_2.X, vector2_2.Y, vector2_1.X, vector2_1.Y, 524, (int) ((double) damage * 0.7), knockBack * 0.7f, this.whoAmI); } if (this.beetleOffense) { this.beetleCounter += (float) num2; this.beetleCountdown = 0; } if (this.meleeEnchant == (byte) 7) Projectile.NewProjectile(player.Center.X, player.Center.Y, player.velocity.X, player.velocity.Y, 289, 0, 0.0f, this.whoAmI); if (sItem.type == 1123) { int num3 = Main.rand.Next(1, 4); if (this.strongBees && Main.rand.Next(3) == 0) ++num3; for (int index2 = 0; index2 < num3; ++index2) { float num4 = (float) (this.direction * 2) + (float) Main.rand.Next(-35, 36) * 0.02f; float num5 = (float) Main.rand.Next(-35, 36) * 0.02f; float SpeedX = num4 * 0.2f; float SpeedY = num5 * 0.2f; Projectile.NewProjectile((float) (itemRectangle.X + itemRectangle.Width / 2), (float) (itemRectangle.Y + itemRectangle.Height / 2), SpeedX, SpeedY, this.beeType(), this.beeDamage(num1 / 3), this.beeKB(0.0f), this.whoAmI); } } if (this.inventory[this.selectedItem].type == 3106) { this.stealth = 1f; if (Main.netMode == 1) NetMessage.SendData(84, number: this.whoAmI); } if (sItem.type == 1826 && (double) Main.npc[index1].value > 0.0) this.pumpkinSword(index1, (int) ((double) damage * 1.5), knockBack); if (Main.netMode != 0) NetMessage.SendPlayerHurt(index1, playerDeathReason, num1, this.direction, flag, true, -1); this.attackCD = (int) ((double) this.itemAnimationMax * 0.33); } } } public bool HasNPCBannerBuff(int bannerType) => Main.SceneMetrics.NPCBannerBuff[bannerType]; private void ItemCheck_MeleeHitNPCs( Item sItem, Microsoft.Xna.Framework.Rectangle itemRectangle, int originalDamage, float knockBack) { for (int index = 0; index < 200; ++index) { if (Main.npc[index].active && Main.npc[index].immune[this.whoAmI] == 0 && this.attackCD == 0) { NPC npc1 = Main.npc[index]; npc1.position = npc1.position + Main.npc[index].netOffset; if (!Main.npc[index].dontTakeDamage && this.CanNPCBeHitByPlayerOrPlayerProjectile(Main.npc[index])) { if (!Main.npc[index].friendly || Main.npc[index].type == 22 && this.killGuide || Main.npc[index].type == 54 && this.killClothier) { Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle((int) Main.npc[index].position.X, (int) Main.npc[index].position.Y, Main.npc[index].width, Main.npc[index].height); if (itemRectangle.Intersects(rectangle) && (Main.npc[index].noTileCollide || this.CanHit((Entity) Main.npc[index]))) { int damage = originalDamage; bool crit = false; int weaponCrit = this.GetWeaponCrit(sItem); if (Main.rand.Next(1, 101) <= weaponCrit) crit = true; int num1 = Item.NPCtoBanner(Main.npc[index].BannerID()); if (num1 > 0 && this.HasNPCBannerBuff(num1)) damage = !Main.expertMode ? (int) ((double) damage * (double) ItemID.Sets.BannerStrength[Item.BannerToItem(num1)].NormalDamageDealt) : (int) ((double) damage * (double) ItemID.Sets.BannerStrength[Item.BannerToItem(num1)].ExpertDamageDealt); if (this.parryDamageBuff && sItem.melee) { damage *= 5; this.parryDamageBuff = false; this.ClearBuff(198); } if (sItem.type == 426 && (double) Main.npc[index].life >= (double) Main.npc[index].lifeMax * 0.899999976158142) damage = (int) ((double) damage * 2.0); if (sItem.type == 671) { float num2 = 1.5f * Utils.GetLerpValue(1f, 0.1f, (float) Main.npc[index].life / (float) Main.npc[index].lifeMax, true); damage = (int) ((double) damage * (1.0 + (double) num2)); Vector2 vector2_1 = itemRectangle.Center.ToVector2(); Vector2 vector2_2 = Main.npc[index].Hitbox.ClosestPointInRect(vector2_1); ParticleOrchestrator.RequestParticleSpawn(false, ParticleOrchestraType.Keybrand, new ParticleOrchestraSettings() { PositionInWorld = vector2_2 }, new int?(this.whoAmI)); } int num3 = Main.DamageVar((float) damage, this.luck); this.StatusToNPC(sItem.type, index); if (Main.npc[index].life > 5) this.OnHit(Main.npc[index].Center.X, Main.npc[index].Center.Y, (Entity) Main.npc[index]); if (this.armorPenetration > 0) num3 += Main.npc[index].checkArmorPenetration(this.armorPenetration); int dmgDone = (int) Main.npc[index].StrikeNPC(num3, knockBack, this.direction, crit); this.ApplyNPCOnHitEffects(sItem, itemRectangle, damage, knockBack, index, num3, dmgDone); int num4 = Item.NPCtoBanner(Main.npc[index].BannerID()); if (num4 >= 0) this.lastCreatureHit = num4; if (Main.netMode != 0) { if (crit) NetMessage.SendData(28, number: index, number2: ((float) num3), number3: knockBack, number4: ((float) this.direction), number5: 1); else NetMessage.SendData(28, number: index, number2: ((float) num3), number3: knockBack, number4: ((float) this.direction)); } if (this.accDreamCatcher) this.addDPS(num3); Main.npc[index].immune[this.whoAmI] = this.itemAnimation; this.attackCD = Math.Max(1, (int) ((double) this.itemAnimationMax * 0.33)); } } } else if (Main.npc[index].type == 63 || Main.npc[index].type == 64 || Main.npc[index].type == 103 || Main.npc[index].type == 242) { Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle((int) Main.npc[index].position.X, (int) Main.npc[index].position.Y, Main.npc[index].width, Main.npc[index].height); if (itemRectangle.Intersects(rectangle) && (Main.npc[index].noTileCollide || this.CanHit((Entity) Main.npc[index]))) { this.Hurt(PlayerDeathReason.LegacyDefault(), (int) ((double) Main.npc[index].damage * 1.3), -this.direction); Main.npc[index].immune[this.whoAmI] = this.itemAnimation; this.attackCD = (int) ((double) this.itemAnimationMax * 0.33); } } NPC npc2 = Main.npc[index]; npc2.position = npc2.position - Main.npc[index].netOffset; } } } private void ApplyNPCOnHitEffects( Item sItem, Microsoft.Xna.Framework.Rectangle itemRectangle, int damage, float knockBack, int npcIndex, int dmgRandomized, int dmgDone) { bool flag = !Main.npc[npcIndex].immortal; if (this.inventory[this.selectedItem].type == 3211) { Vector2 vector2_1 = new Vector2((float) (this.direction * 100 + Main.rand.Next(-25, 26)), (float) Main.rand.Next(-75, 76)); vector2_1.Normalize(); vector2_1 *= (float) Main.rand.Next(30, 41) * 0.1f; Vector2 vector2_2 = (new Vector2((float) (itemRectangle.X + Main.rand.Next(itemRectangle.Width)), (float) (itemRectangle.Y + Main.rand.Next(itemRectangle.Height))) + Main.npc[npcIndex].Center * 2f) / 3f; Projectile.NewProjectile(vector2_2.X, vector2_2.Y, vector2_1.X, vector2_1.Y, 524, (int) ((double) damage * 0.7), knockBack * 0.7f, this.whoAmI); } if (this.beetleOffense & flag) { this.beetleCounter += (float) dmgDone; this.beetleCountdown = 0; } if (sItem.type == 1826 && ((double) Main.npc[npcIndex].value > 0.0 || Main.npc[npcIndex].damage > 0 && !Main.npc[npcIndex].friendly)) this.pumpkinSword(npcIndex, (int) ((double) damage * 1.5), knockBack); if (this.meleeEnchant == (byte) 7) Projectile.NewProjectile(Main.npc[npcIndex].Center.X, Main.npc[npcIndex].Center.Y, Main.npc[npcIndex].velocity.X, Main.npc[npcIndex].velocity.Y, 289, 0, 0.0f, this.whoAmI); if (this.inventory[this.selectedItem].type == 3106) { this.stealth = 1f; if (Main.netMode == 1) NetMessage.SendData(84, number: this.whoAmI); } if (sItem.type == 1123 & flag) { int num1 = Main.rand.Next(1, 4); if (this.strongBees && Main.rand.Next(3) == 0) ++num1; for (int index = 0; index < num1; ++index) { float num2 = (float) (this.direction * 2) + (float) Main.rand.Next(-35, 36) * 0.02f; float num3 = (float) Main.rand.Next(-35, 36) * 0.02f; float SpeedX = num2 * 0.2f; float SpeedY = num3 * 0.2f; Projectile.NewProjectile((float) (itemRectangle.X + itemRectangle.Width / 2), (float) (itemRectangle.Y + itemRectangle.Height / 2), SpeedX, SpeedY, this.beeType(), this.beeDamage(dmgRandomized / 3), this.beeKB(0.0f), this.whoAmI); } } if ((double) Main.npc[npcIndex].value <= 0.0 || !this.coins || Main.rand.Next(5) != 0) return; int Type = 71; if (Main.rand.Next(10) == 0) Type = 72; if (Main.rand.Next(100) == 0) Type = 73; int number = Item.NewItem((int) Main.npc[npcIndex].position.X, (int) Main.npc[npcIndex].position.Y, Main.npc[npcIndex].width, Main.npc[npcIndex].height, Type); Main.item[number].stack = Main.rand.Next(1, 11); Main.item[number].velocity.Y = (float) Main.rand.Next(-20, 1) * 0.2f; Main.item[number].velocity.X = (float) Main.rand.Next(10, 31) * 0.2f * (float) this.direction; if (Main.netMode != 1) return; NetMessage.SendData(21, number: number); } private void ItemCheck_EmitHammushProjectiles( int i, Item sItem, Microsoft.Xna.Framework.Rectangle itemRectangle, int damage) { if (sItem.type != 787) return; int itemAnimationMax = this.itemAnimationMax; if (this.itemAnimation != (int) ((double) itemAnimationMax * 0.1) && this.itemAnimation != (int) ((double) itemAnimationMax * 0.3) && this.itemAnimation != (int) ((double) itemAnimationMax * 0.5) && this.itemAnimation != (int) ((double) itemAnimationMax * 0.7) && this.itemAnimation != (int) ((double) itemAnimationMax * 0.9)) return; float num1 = 0.0f; float num2 = 0.0f; float num3 = 0.0f; float num4 = 0.0f; if (this.itemAnimation == (int) ((double) itemAnimationMax * 0.9)) num1 = -7f; if (this.itemAnimation == (int) ((double) itemAnimationMax * 0.7)) { num1 = -6f; num2 = 2f; } if (this.itemAnimation == (int) ((double) itemAnimationMax * 0.5)) { num1 = -4f; num2 = 4f; } if (this.itemAnimation == (int) ((double) itemAnimationMax * 0.3)) { num1 = -2f; num2 = 6f; } if (this.itemAnimation == (int) ((double) itemAnimationMax * 0.1)) num2 = 7f; if (this.itemAnimation == (int) ((double) itemAnimationMax * 0.7)) num4 = 26f; if (this.itemAnimation == (int) ((double) itemAnimationMax * 0.3)) { num4 -= 4f; num3 -= 20f; } if (this.itemAnimation == (int) ((double) itemAnimationMax * 0.1)) num3 += 6f; if (this.direction == -1) { if (this.itemAnimation == (int) ((double) itemAnimationMax * 0.9)) num4 -= 8f; if (this.itemAnimation == (int) ((double) itemAnimationMax * 0.7)) num4 -= 6f; } float num5 = num1 * 1.5f; float num6 = num2 * 1.5f; float num7 = num4 * (float) this.direction; float num8 = num3 * this.gravDir; Projectile.NewProjectile((float) (itemRectangle.X + itemRectangle.Width / 2) + num7, (float) (itemRectangle.Y + itemRectangle.Height / 2) + num8, (float) this.direction * num6, num5 * this.gravDir, 131, damage / 2, 0.0f, i); } private static List ItemCheck_GetTileCutIgnoreList(Item sItem) { List ushortList = (List) null; if (sItem.type == 213) ushortList = new List((IEnumerable) new ushort[23] { (ushort) 3, (ushort) 24, (ushort) 52, (ushort) 61, (ushort) 62, (ushort) 71, (ushort) 73, (ushort) 74, (ushort) 82, (ushort) 83, (ushort) 84, (ushort) 110, (ushort) 113, (ushort) 115, (ushort) 184, (ushort) 205, (ushort) 201, (ushort) 519, (ushort) 518, (ushort) 528, (ushort) 529, (ushort) 530, (ushort) 549 }); return ushortList; } private static void ItemCheck_CutTiles( Item sItem, Microsoft.Xna.Framework.Rectangle itemRectangle, List ignoreList) { int minX = itemRectangle.X / 16; int maxX = (itemRectangle.X + itemRectangle.Width) / 16 + 1; int minY = itemRectangle.Y / 16; int maxY = (itemRectangle.Y + itemRectangle.Height) / 16 + 1; Utils.ClampWithinWorld(ref minX, ref minY, ref maxX, ref maxY); for (int index1 = minX; index1 < maxX; ++index1) { for (int index2 = minY; index2 < maxY; ++index2) { if (Main.tile[index1, index2] != null && Main.tileCut[(int) Main.tile[index1, index2].type] && (ignoreList == null || !ignoreList.Contains(Main.tile[index1, index2].type)) && WorldGen.CanCutTile(index1, index2, TileCuttingContext.AttackMelee)) { if (sItem.type == 1786) { int type = (int) Main.tile[index1, index2].type; WorldGen.KillTile(index1, index2); if (!Main.tile[index1, index2].active()) { int Stack = 0; if (type == 3 || type == 24 || type == 61 || type == 110 || type == 201) Stack = Main.rand.Next(1, 3); if (type == 73 || type == 74 || type == 113) Stack = Main.rand.Next(2, 5); if (Stack > 0) { int number = Item.NewItem(index1 * 16, index2 * 16, 16, 16, 1727, Stack); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); } } if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) index1), number3: ((float) index2)); } else { WorldGen.KillTile(index1, index2); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) index1), number3: ((float) index2)); } } } } } private Microsoft.Xna.Framework.Rectangle ItemCheck_CatchCritters( Item sItem, Microsoft.Xna.Framework.Rectangle itemRectangle) { bool flag = sItem.type == 3183 || sItem.type == 4821; for (int index = 0; index < 200; ++index) { if (Main.npc[index].active && Main.npc[index].catchItem > (short) 0) { Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle((int) Main.npc[index].position.X, (int) Main.npc[index].position.Y, Main.npc[index].width, Main.npc[index].height); if (itemRectangle.Intersects(rectangle)) { if (!flag && ItemID.Sets.IsLavaBait[(int) Main.npc[index].catchItem]) { if (Main.myPlayer == this.whoAmI) { this.Hurt(PlayerDeathReason.ByNPC(index), 1, (double) Main.npc[index].Center.X < (double) this.Center.X ? 1 : -1, cooldownCounter: 3); this.AddBuff(24, 300, false); } } else if (Main.npc[index].type == 585 || Main.npc[index].type == 583 || Main.npc[index].type == 584) { if ((double) Main.npc[index].ai[2] <= 1.0) NPC.CatchNPC(index, this.whoAmI); } else NPC.CatchNPC(index, this.whoAmI); } } } return itemRectangle; } private Microsoft.Xna.Framework.Rectangle ItemCheck_EmitUseVisuals( Item sItem, Microsoft.Xna.Framework.Rectangle itemRectangle) { if (sItem.type == 989 && Main.rand.Next(5) == 0) { int Type; switch (Main.rand.Next(3)) { case 0: Type = 15; break; case 1: Type = 57; break; default: Type = 58; break; } int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, Type, (float) (this.direction * 2), Alpha: 150, Scale: 1.3f); Main.dust[index].velocity *= 0.2f; } if (sItem.type == 2880 && Main.rand.Next(2) == 0) { int Type = Utils.SelectRandom(Main.rand, 226, 229); int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, Type, (float) (this.direction * 2), Alpha: 150); Main.dust[index].velocity *= 0.2f; Main.dust[index].noGravity = true; } if ((sItem.type == 44 || sItem.type == 45 || sItem.type == 46 || sItem.type == 103 || sItem.type == 104) && Main.rand.Next(15) == 0) Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 14, (float) (this.direction * 2), Alpha: 150, Scale: 1.3f); if (sItem.type == 273 || sItem.type == 675) { if (Main.rand.Next(5) == 0) Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 14, (float) (this.direction * 2), Alpha: 150, Scale: 1.4f); int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 27, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 100, Scale: 1.2f); Main.dust[index].noGravity = true; Main.dust[index].velocity.X /= 2f; Main.dust[index].velocity.Y /= 2f; } if (sItem.type == 723 && Main.rand.Next(2) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 64, Alpha: 150, Scale: 1.2f); Main.dust[index].noGravity = true; } if (sItem.type == 65) { if (Main.rand.Next(5) == 0) Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 58, Alpha: 150, Scale: 1.2f); if (Main.rand.Next(10) == 0) Gore.NewGore(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), new Vector2(), Main.rand.Next(16, 18)); } if (sItem.type == 3065) { int index1 = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 58, Alpha: 150, Scale: 1.2f); Main.dust[index1].velocity *= 0.5f; if (Main.rand.Next(8) == 0) { int index2 = Gore.NewGore(new Vector2((float) itemRectangle.Center.X, (float) itemRectangle.Center.Y), new Vector2(), 16); Main.gore[index2].velocity *= 0.5f; Main.gore[index2].velocity += new Vector2((float) this.direction, 0.0f); } } if (sItem.type == 190) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 40, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, Scale: 1.2f); Main.dust[index].noGravity = true; } else if (sItem.type == 213) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 3, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, Scale: 1.2f); Main.dust[index].noGravity = true; } if (sItem.type == 121) { for (int index3 = 0; index3 < 2; ++index3) { int index4 = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 6, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 100, Scale: 2.5f); Main.dust[index4].noGravity = true; Main.dust[index4].velocity.X *= 2f; Main.dust[index4].velocity.Y *= 2f; } } if (sItem.type == 122 || sItem.type == 217) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 6, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 100, Scale: 1.9f); Main.dust[index].noGravity = true; } if (sItem.type == 155) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 172, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 100, Scale: 0.9f); Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.1f; } if (sItem.type == 676 && Main.rand.Next(3) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 67, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 90, Scale: 1.5f); Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.2f; } if (sItem.type == 3063) { int index = Dust.NewDust(itemRectangle.TopLeft(), itemRectangle.Width, itemRectangle.Height, 66, Alpha: 150, newColor: Color.Transparent, Scale: 0.85f); Main.dust[index].color = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.5f); Main.dust[index].noGravity = true; Main.dust[index].velocity /= 2f; } if (sItem.type == 3823) { Dust dust = Dust.NewDustDirect(itemRectangle.TopLeft(), itemRectangle.Width, itemRectangle.Height, 6, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 100, Color.Transparent, 0.7f); dust.noGravity = true; dust.velocity *= 2f; dust.fadeIn = 0.9f; } if (sItem.type == 724 && Main.rand.Next(5) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 67, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 90, Scale: 1.5f); Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.2f; } if (sItem.type >= 795 && sItem.type <= 802 && Main.rand.Next(3) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 115, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 140, Scale: 1.5f); Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.25f; } if (sItem.type == 367 || sItem.type == 368 || sItem.type == 674) { if (Main.rand.Next(3) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 57, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 100, Scale: 1.1f); Main.dust[index].noGravity = true; Main.dust[index].velocity.X /= 2f; Main.dust[index].velocity.Y /= 2f; Main.dust[index].velocity.X += (float) (this.direction * 2); } if (Main.rand.Next(4) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 43, Alpha: 254, Scale: 0.3f); Main.dust[index].velocity *= 0.0f; } } if (sItem.type == 4258 || sItem.type == 4259 || sItem.type >= 198 && sItem.type <= 203 || sItem.type >= 3764 && sItem.type <= 3769) { float r = 0.5f; float g = 0.5f; float b = 0.5f; if (sItem.type == 198 || sItem.type == 3764) { r *= 0.1f; g *= 0.5f; b *= 1.2f; } else if (sItem.type == 199 || sItem.type == 3765) { r *= 1f; g *= 0.2f; b *= 0.1f; } else if (sItem.type == 200 || sItem.type == 3766) { r *= 0.1f; g *= 1f; b *= 0.2f; } else if (sItem.type == 201 || sItem.type == 3767) { r *= 0.8f; g *= 0.1f; b *= 1f; } else if (sItem.type == 202 || sItem.type == 3768) { r *= 0.8f; g *= 0.9f; b *= 1f; } else if (sItem.type == 203 || sItem.type == 3769) { r *= 0.8f; g *= 0.8f; b *= 0.0f; } else if (sItem.type == 4258 || sItem.type == 4259) { r *= 0.9f; g *= 0.5f; b *= 0.0f; } Lighting.AddLight((int) (((double) this.itemLocation.X + 6.0 + (double) this.velocity.X) / 16.0), (int) (((double) this.itemLocation.Y - 14.0) / 16.0), r, g, b); } if (this.frostBurn && sItem.melee && !sItem.noMelee && !sItem.noUseGraphic && Main.rand.Next(2) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 135, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 100, Scale: 2.5f); Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.7f; Main.dust[index].velocity.Y -= 0.5f; } if (sItem.melee && !sItem.noMelee && !sItem.noUseGraphic && this.meleeEnchant > (byte) 0) { if (this.meleeEnchant == (byte) 1) { if (Main.rand.Next(3) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 171, Alpha: 100); Main.dust[index].noGravity = true; Main.dust[index].fadeIn = 1.5f; Main.dust[index].velocity *= 0.25f; } } else if (this.meleeEnchant == (byte) 2) { if (Main.rand.Next(2) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 75, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 100, Scale: 2.5f); Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.7f; Main.dust[index].velocity.Y -= 0.5f; } } else if (this.meleeEnchant == (byte) 3) { if (Main.rand.Next(2) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 6, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 100, Scale: 2.5f); Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.7f; Main.dust[index].velocity.Y -= 0.5f; } } else if (this.meleeEnchant == (byte) 4) { if (Main.rand.Next(2) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 57, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 100, Scale: 1.1f); Main.dust[index].noGravity = true; Main.dust[index].velocity.X /= 2f; Main.dust[index].velocity.Y /= 2f; } } else if (this.meleeEnchant == (byte) 5) { if (Main.rand.Next(2) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 169, Alpha: 100); Main.dust[index].velocity.X += (float) this.direction; Main.dust[index].velocity.Y += 0.2f; Main.dust[index].noGravity = true; } } else if (this.meleeEnchant == (byte) 6) { if (Main.rand.Next(2) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 135, Alpha: 100); Main.dust[index].velocity.X += (float) this.direction; Main.dust[index].velocity.Y += 0.2f; Main.dust[index].noGravity = true; } } else if (this.meleeEnchant == (byte) 7) { if (Main.rand.Next(20) == 0) { int Type = Main.rand.Next(139, 143); int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, Type, this.velocity.X, this.velocity.Y, Scale: 1.2f); Main.dust[index].velocity.X *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.dust[index].velocity.Y *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.dust[index].velocity.X += (float) Main.rand.Next(-50, 51) * 0.05f; Main.dust[index].velocity.Y += (float) Main.rand.Next(-50, 51) * 0.05f; Main.dust[index].scale *= (float) (1.0 + (double) Main.rand.Next(-30, 31) * 0.00999999977648258); } if (Main.rand.Next(40) == 0) { int Type = Main.rand.Next(276, 283); int index = Gore.NewGore(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), this.velocity, Type); Main.gore[index].velocity.X *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.gore[index].velocity.Y *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Main.gore[index].scale *= (float) (1.0 + (double) Main.rand.Next(-20, 21) * 0.00999999977648258); Main.gore[index].velocity.X += (float) Main.rand.Next(-50, 51) * 0.05f; Main.gore[index].velocity.Y += (float) Main.rand.Next(-50, 51) * 0.05f; } } else if (this.meleeEnchant == (byte) 8 && Main.rand.Next(4) == 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 46, Alpha: 100); Main.dust[index].noGravity = true; Main.dust[index].fadeIn = 1.5f; Main.dust[index].velocity *= 0.25f; } } if (this.magmaStone && sItem.melee && !sItem.noMelee && !sItem.noUseGraphic && Main.rand.Next(3) != 0) { int index = Dust.NewDust(new Vector2((float) itemRectangle.X, (float) itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 6, this.velocity.X * 0.2f + (float) (this.direction * 3), this.velocity.Y * 0.2f, 100, Scale: 2.5f); Main.dust[index].noGravity = true; Main.dust[index].velocity.X *= 2f; Main.dust[index].velocity.Y *= 2f; } return itemRectangle; } private void ItemCheck_GetMeleeHitbox( Item sItem, Microsoft.Xna.Framework.Rectangle heldItemFrame, out bool dontAttack, out Microsoft.Xna.Framework.Rectangle itemRectangle) { dontAttack = false; itemRectangle = new Microsoft.Xna.Framework.Rectangle((int) this.itemLocation.X, (int) this.itemLocation.Y, 32, 32); if (!Main.dedServ) itemRectangle = new Microsoft.Xna.Framework.Rectangle((int) this.itemLocation.X, (int) this.itemLocation.Y, heldItemFrame.Width, heldItemFrame.Height); itemRectangle.Width = (int) ((double) itemRectangle.Width * (double) sItem.scale); itemRectangle.Height = (int) ((double) itemRectangle.Height * (double) sItem.scale); if (this.direction == -1) itemRectangle.X -= itemRectangle.Width; if ((double) this.gravDir == 1.0) itemRectangle.Y -= itemRectangle.Height; if (sItem.useStyle == 1) { if ((double) this.itemAnimation < (double) this.itemAnimationMax * 0.333) { if (this.direction == -1) itemRectangle.X -= (int) ((double) itemRectangle.Width * 1.4 - (double) itemRectangle.Width); itemRectangle.Width = (int) ((double) itemRectangle.Width * 1.4); itemRectangle.Y += (int) ((double) itemRectangle.Height * 0.5 * (double) this.gravDir); itemRectangle.Height = (int) ((double) itemRectangle.Height * 1.1); } else if ((double) this.itemAnimation >= (double) this.itemAnimationMax * 0.666) { if (this.direction == 1) itemRectangle.X -= (int) ((double) itemRectangle.Width * 1.2); itemRectangle.Width *= 2; itemRectangle.Y -= (int) (((double) itemRectangle.Height * 1.4 - (double) itemRectangle.Height) * (double) this.gravDir); itemRectangle.Height = (int) ((double) itemRectangle.Height * 1.4); } } else if (sItem.useStyle == 3) { if ((double) this.itemAnimation > (double) this.itemAnimationMax * 0.666) { dontAttack = true; } else { if (this.direction == -1) itemRectangle.X -= (int) ((double) itemRectangle.Width * 1.4 - (double) itemRectangle.Width); itemRectangle.Width = (int) ((double) itemRectangle.Width * 1.4); itemRectangle.Y += (int) ((double) itemRectangle.Height * 0.6); itemRectangle.Height = (int) ((double) itemRectangle.Height * 0.6); if (sItem.type == 946 || sItem.type == 4707) { itemRectangle.Height += 14; itemRectangle.Width -= 10; if (this.direction == -1) itemRectangle.X += 10; } } } if (sItem.type == 1450 && Main.rand.Next(3) == 0) { int index = -1; float x = (float) (itemRectangle.X + Main.rand.Next(itemRectangle.Width)); float y = (float) (itemRectangle.Y + Main.rand.Next(itemRectangle.Height)); if (Main.rand.Next(500) == 0) index = Gore.NewGore(new Vector2(x, y), new Vector2(), 415, (float) Main.rand.Next(51, 101) * 0.01f); else if (Main.rand.Next(250) == 0) index = Gore.NewGore(new Vector2(x, y), new Vector2(), 414, (float) Main.rand.Next(51, 101) * 0.01f); else if (Main.rand.Next(80) == 0) index = Gore.NewGore(new Vector2(x, y), new Vector2(), 413, (float) Main.rand.Next(51, 101) * 0.01f); else if (Main.rand.Next(10) == 0) index = Gore.NewGore(new Vector2(x, y), new Vector2(), 412, (float) Main.rand.Next(51, 101) * 0.01f); else if (Main.rand.Next(3) == 0) index = Gore.NewGore(new Vector2(x, y), new Vector2(), 411, (float) Main.rand.Next(51, 101) * 0.01f); if (index >= 0) { Main.gore[index].velocity.X += (float) (this.direction * 2); Main.gore[index].velocity.Y *= 0.3f; } } if (sItem.type == 3542) dontAttack = true; if (sItem.type != 3779) return; dontAttack = true; Vector2 vector2_1 = this.itemLocation + new Vector2((float) (this.direction * 30), -8f); Vector2 vector2_2 = vector2_1 - this.position; for (float amount = 0.0f; (double) amount < 1.0; amount += 0.2f) { Vector2 vector2_3 = Vector2.Lerp(this.oldPosition + vector2_2 + new Vector2(0.0f, this.gfxOffY), vector2_1, amount); Dust dust = Main.dust[Dust.NewDust(vector2_1 - Vector2.One * 8f, 16, 16, 27, SpeedY: -2f)]; dust.noGravity = true; dust.position = vector2_3; dust.velocity = new Vector2(0.0f, (float) (-(double) this.gravDir * 2.0)); dust.scale = 1.2f; dust.alpha = 200; } } private void ItemCheck_UseDemonHeart(Item sItem) { if (sItem.type != 3335 || this.itemAnimation <= 0 || this.extraAccessory || !Main.expertMode || !this.ItemTimeIsZero) return; this.ApplyItemTime(sItem); this.extraAccessory = true; NetMessage.SendData(4, number: this.whoAmI); } private void ItemCheck_UseTorchGodsFavor(Item sItem) { if (sItem.type != 5043 || this.itemAnimation <= 0 || this.unlockedBiomeTorches || !this.ItemTimeIsZero) return; this.ApplyItemTime(sItem); this.unlockedBiomeTorches = true; this.UsingBiomeTorches = true; NetMessage.SendData(4, number: this.whoAmI); } private void ItemCheck_UseManaCrystal(Item sItem) { if (sItem.type != 109 || this.itemAnimation <= 0 || this.statManaMax >= 200 || !this.ItemTimeIsZero) return; this.ApplyItemTime(sItem); this.statManaMax += 20; this.statManaMax2 += 20; this.statMana += 20; if (Main.myPlayer == this.whoAmI) this.ManaEffect(20); AchievementsHelper.HandleSpecialEvent(this, 1); } private void ItemCheck_UseLifeFruit(Item sItem) { if (sItem.type != 1291 || this.itemAnimation <= 0 || this.statLifeMax < 400 || this.statLifeMax >= 500 || !this.ItemTimeIsZero) return; this.ApplyItemTime(sItem); this.statLifeMax += 5; this.statLifeMax2 += 5; this.statLife += 5; if (Main.myPlayer == this.whoAmI) this.HealEffect(5); AchievementsHelper.HandleSpecialEvent(this, 2); } private void ItemCheck_UseLifeCrystal(Item sItem) { if (sItem.type != 29 || this.itemAnimation <= 0 || this.statLifeMax >= 400 || !this.ItemTimeIsZero) return; this.ApplyItemTime(sItem); this.statLifeMax += 20; this.statLifeMax2 += 20; this.statLife += 20; if (Main.myPlayer == this.whoAmI) this.HealEffect(20); AchievementsHelper.HandleSpecialEvent(this, 0); } private void ItemCheck_UseCombatBook(Item sItem) { if (NPC.combatBookWasUsed || sItem.type != 4382 || this.itemAnimation <= 0 || !this.ItemTimeIsZero) return; this.ApplyItemTime(sItem); if (Main.netMode == 0) { NPC.combatBookWasUsed = true; Main.NewText(Language.GetTextValue("Misc.CombatBookUsed"), (byte) 50, B: (byte) 130); } else NetMessage.SendData(61, number: this.whoAmI, number2: -11f); } private void ItemCheck_UsePetLicenses(Item sItem) { if (sItem.type == 4829 && !NPC.boughtCat && this.itemAnimation > 0 && this.ItemTimeIsZero) { this.ApplyItemTime(sItem); if (Main.netMode == 0) { NPC.boughtCat = true; Main.NewText(Language.GetTextValue("Misc.LicenseCatUsed"), (byte) 50, B: (byte) 130); } else NetMessage.SendData(61, number: this.whoAmI, number2: -12f); } if (sItem.type == 4830 && !NPC.boughtDog && this.itemAnimation > 0 && this.ItemTimeIsZero) { this.ApplyItemTime(sItem); if (Main.netMode == 0) { NPC.boughtDog = true; Main.NewText(Language.GetTextValue("Misc.LicenseDogUsed"), (byte) 50, B: (byte) 130); } else NetMessage.SendData(61, number: this.whoAmI, number2: -13f); } if (sItem.type != 4910 || NPC.boughtBunny || this.itemAnimation <= 0 || !this.ItemTimeIsZero) return; this.ApplyItemTime(sItem); if (Main.netMode == 0) { NPC.boughtBunny = true; Main.NewText(Language.GetTextValue("Misc.LicenseBunnyUsed"), (byte) 50, B: (byte) 130); } else NetMessage.SendData(61, number: this.whoAmI, number2: -14f); } private void ItemCheck_UseRodOfDiscord(Item sItem) { if (Main.myPlayer != this.whoAmI || sItem.type != 1326 || this.itemAnimation <= 0 || !this.ItemTimeIsZero) return; this.ApplyItemTime(sItem); Vector2 vector2; vector2.X = (float) Main.mouseX + Main.screenPosition.X; vector2.Y = (double) this.gravDir != 1.0 ? Main.screenPosition.Y + (float) Main.screenHeight - (float) Main.mouseY : (float) Main.mouseY + Main.screenPosition.Y - (float) this.height; vector2.X -= (float) (this.width / 2); if ((double) vector2.X <= 50.0 || (double) vector2.X >= (double) (Main.maxTilesX * 16 - 50) || (double) vector2.Y <= 50.0 || (double) vector2.Y >= (double) (Main.maxTilesY * 16 - 50)) return; int index1 = (int) ((double) vector2.X / 16.0); int index2 = (int) ((double) vector2.Y / 16.0); if (Main.tile[index1, index2].wall == (ushort) 87 && (double) index2 > Main.worldSurface && !NPC.downedPlantBoss || Collision.SolidCollision(vector2, this.width, this.height)) return; this.Teleport(vector2, 1); NetMessage.SendData(65, number2: ((float) this.whoAmI), number3: vector2.X, number4: vector2.Y, number5: 1); if (this.chaosState) { this.statLife -= this.statLifeMax2 / 7; PlayerDeathReason damageSource = PlayerDeathReason.ByOther(13); if (Main.rand.Next(2) == 0) damageSource = PlayerDeathReason.ByOther(this.Male ? 14 : 15); if (this.statLife <= 0) this.KillMe(damageSource, 1.0, 0); this.lifeRegenCount = 0; this.lifeRegenTime = 0; } this.AddBuff(88, 360); } private bool IsTilePoundable(Tile targetTile) => !Main.tileHammer[(int) targetTile.type] && !Main.tileSolid[(int) targetTile.type] && targetTile.type != (ushort) 314 && targetTile.type != (ushort) 424 && targetTile.type != (ushort) 442 && targetTile.type != (ushort) 351; private void UseShovel(Player user, Item item, int sX, int sY) { for (int x = sX - 1; x <= sX + 1; ++x) { for (int y = sY - 1; y <= sY + 1; ++y) this.DamageTileWithShovel(user, item, x, y); } this.itemTime = (int) ((double) item.useTime * (double) this.pickSpeed); } private void DamageTileWithShovel(Player user, Item item, int x, int y) { Tile tileSafely = Framing.GetTileSafely(x, y); if (!TileID.Sets.CanBeDugByShovel[(int) tileSafely.type]) return; int pickPower = 30; if (tileSafely.active() && TileID.Sets.Conversion.Grass[(int) tileSafely.type]) this.PickTile(x, y, 100); this.PickTile(x, y, pickPower); } private void ItemCheck_UseMiningTools(Item sItem) { Player.SpecialToolUsageSettings toolUsageSettings = new Player.SpecialToolUsageSettings(); if (sItem.type == 4711) toolUsageSettings = new Player.SpecialToolUsageSettings() { IsAValidTool = true, UsageAction = new Player.SpecialToolUsageSettings.UseToolAction(this.UseShovel) }; if ((sItem.pick > 0 || sItem.axe > 0 || sItem.hammer > 0 ? 1 : (toolUsageSettings.IsAValidTool ? 1 : 0)) == 0) return; bool flag = this.IsTargetTileInItemRange(sItem); if (this.noBuilding) flag = false; if (flag && toolUsageSettings.UsageCondition != null) flag = toolUsageSettings.UsageCondition(this, sItem, Player.tileTargetX, Player.tileTargetY); if (this.toolTime == 0 && this.itemAnimation > 0 && this.controlUseItem) { Tile targetTile = Main.tile[Player.tileTargetX, Player.tileTargetY]; if (!targetTile.active() || this.IsTilePoundable(targetTile)) this.poundRelease = false; } if (!flag) return; if (!Main.GamepadDisableCursorItemIcon) { this.cursorItemIconEnabled = true; Main.ItemIconCacheUpdate(sItem.type); } bool canHitWalls = false; if (this.toolTime == 0 && this.itemAnimation > 0 && this.controlUseItem) { if (toolUsageSettings.UsageAction != null) { toolUsageSettings.UsageAction(this, sItem, Player.tileTargetX, Player.tileTargetY); return; } this.ItemCheck_UseMiningTools_ActuallyUseMiningTool(sItem, out canHitWalls, Player.tileTargetX, Player.tileTargetY); } if (this.releaseUseItem) this.poundRelease = true; if (this.toolTime != 0 || this.itemAnimation <= 0 || !this.controlUseItem || !canHitWalls) return; int wX; int wY; Player.ItemCheck_UseMiningTools_TryFindingWallToHammer(out wX, out wY); this.ItemCheck_UseMiningTools_TryHittingWall(sItem, wX, wY); } private void ItemCheck_UseMiningTools_ActuallyUseMiningTool( Item sItem, out bool canHitWalls, int x, int y) { int num1 = 0; canHitWalls = true; Tile tile = Main.tile[x, y]; if (!tile.active()) return; if (sItem.pick > 0 && !Main.tileAxe[(int) tile.type] && !Main.tileHammer[(int) tile.type] || sItem.axe > 0 && Main.tileAxe[(int) tile.type] || sItem.hammer > 0 && Main.tileHammer[(int) tile.type]) canHitWalls = false; int num2 = this.hitTile.HitObject(x, y, 1); if (Main.tileNoFail[(int) tile.type]) num1 = 100; if (Main.tileHammer[(int) tile.type]) { canHitWalls = false; if (sItem.hammer > 0) { int damageAmount = num1 + sItem.hammer; if (!WorldGen.CanKillTile(x, y)) damageAmount = 0; if (tile.type == (ushort) 26 && (sItem.hammer < 80 || !Main.hardMode)) { damageAmount = 0; this.Hurt(PlayerDeathReason.ByOther(4), this.statLife / 2, -this.direction); } AchievementsHelper.CurrentlyMining = true; if (this.hitTile.AddDamage(num2, damageAmount) >= 100) { this.ClearMiningCacheAt(x, y, 1); WorldGen.KillTile(x, y); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) x), number3: ((float) y)); } else { WorldGen.KillTile(x, y, true); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) x), number3: ((float) y), number4: 1f); } if (damageAmount != 0) this.hitTile.Prune(); this.ApplyItemTime(sItem); AchievementsHelper.CurrentlyMining = false; } } else if (Main.tileAxe[(int) tile.type]) { int damageAmount = tile.type != (ushort) 80 ? num1 + (int) ((double) sItem.axe * 1.20000004768372) : num1 + (int) ((double) (sItem.axe * 3) * 1.20000004768372); if (sItem.axe > 0) { AchievementsHelper.CurrentlyMining = true; if (!WorldGen.CanKillTile(x, y)) damageAmount = 0; if (this.hitTile.AddDamage(num2, damageAmount) >= 100) { this.ClearMiningCacheAt(x, y, 1); WorldGen.KillTile(x, y); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) x), number3: ((float) y)); } else { WorldGen.KillTile(x, y, true); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) x), number3: ((float) y), number4: 1f); } if (damageAmount != 0) this.hitTile.Prune(); this.ApplyItemTime(sItem); AchievementsHelper.CurrentlyMining = false; } } else if (sItem.pick > 0) this.PickTile(x, y, sItem.pick); if (sItem.pick > 0) this.itemTime = (int) ((double) sItem.useTime * (double) this.pickSpeed); this.ItemCheck_UseMiningTools_TryPoundingTile(sItem, num2, ref canHitWalls, x, y); } private static void ItemCheck_UseMiningTools_TryFindingWallToHammer(out int wX, out int wY) { wX = Player.tileTargetX; wY = Player.tileTargetY; bool flag = true; if (Main.tile[wX, wY].wall > (ushort) 0) { if (!Main.wallHouse[(int) Main.tile[wX, wY].wall]) { for (int index1 = wX - 1; index1 < wX + 2; ++index1) { for (int index2 = wY - 1; index2 < wY + 2; ++index2) { if ((int) Main.tile[index1, index2].wall != (int) Main.tile[wX, wY].wall) { flag = false; break; } } } } else flag = false; } if (!flag || Main.tile[wX, wY].active()) return; int num1 = -1; if (((double) Main.mouseX + (double) Main.screenPosition.X) / 16.0 < Math.Round(((double) Main.mouseX + (double) Main.screenPosition.X) / 16.0)) num1 = 0; int num2 = -1; if (((double) Main.mouseY + (double) Main.screenPosition.Y) / 16.0 < Math.Round(((double) Main.mouseY + (double) Main.screenPosition.Y) / 16.0)) num2 = 0; for (int index3 = Player.tileTargetX + num1; index3 <= Player.tileTargetX + num1 + 1; ++index3) { for (int index4 = Player.tileTargetY + num2; index4 <= Player.tileTargetY + num2 + 1; ++index4) { if (flag) { wX = index3; wY = index4; if (Main.tile[wX, wY].wall > (ushort) 0) { if (!Main.wallHouse[(int) Main.tile[wX, wY].wall]) { for (int index5 = wX - 1; index5 < wX + 2; ++index5) { for (int index6 = wY - 1; index6 < wY + 2; ++index6) { if ((int) Main.tile[index5, index6].wall != (int) Main.tile[wX, wY].wall) { flag = false; break; } } } } else flag = false; } } } } } private void ItemCheck_UseMiningTools_TryHittingWall(Item sItem, int wX, int wY) { if (Main.tile[wX, wY].wall <= (ushort) 0 || Main.tile[wX, wY].active() && wX == Player.tileTargetX && wY == Player.tileTargetY && (Main.tileHammer[(int) Main.tile[wX, wY].type] || this.poundRelease) || this.toolTime != 0 || this.itemAnimation <= 0 || !this.controlUseItem || sItem.hammer <= 0) return; bool flag = true; if (!Main.wallHouse[(int) Main.tile[wX, wY].wall]) { flag = false; for (int index1 = wX - 1; index1 < wX + 2; ++index1) { for (int index2 = wY - 1; index2 < wY + 2; ++index2) { if (Main.tile[index1, index2].wall == (ushort) 0 || Main.wallHouse[(int) Main.tile[index1, index2].wall]) { flag = true; break; } } } } if (!flag) return; int tileId = this.hitTile.HitObject(wX, wY, 2); int damageAmount = (int) ((double) sItem.hammer * 1.5); if (this.hitTile.AddDamage(tileId, damageAmount) >= 100) { this.hitTile.Clear(tileId); this.ClearMiningCacheAt(wX, wY, 2); WorldGen.KillWall(wX, wY); if (Main.netMode == 1) NetMessage.SendData(17, number: 2, number2: ((float) wX), number3: ((float) wY)); } else { WorldGen.KillWall(wX, wY, true); if (Main.netMode == 1) NetMessage.SendData(17, number: 2, number2: ((float) wX), number3: ((float) wY), number4: 1f); } if (damageAmount != 0) this.hitTile.Prune(); this.itemTime = sItem.useTime / 2; } private void ItemCheck_UseMiningTools_TryPoundingTile( Item sItem, int tileHitId, ref bool hitWall, int x, int y) { Tile tile1 = Main.tile[x, y]; if (sItem.hammer > 0 && tile1.active() && (Main.tileSolid[(int) tile1.type] || tile1.type == (ushort) 314 || tile1.type == (ushort) 351 || tile1.type == (ushort) 424 || tile1.type == (ushort) 442) && this.poundRelease) { hitWall = false; this.ApplyItemTime(sItem); int damageAmount = 100; if (WorldGen.IsLockedDoor(x, y - 1) || WorldGen.IsLockedDoor(x, y + 1)) damageAmount = 0; if (this.hitTile.AddDamage(tileHitId, damageAmount) >= 100) { this.ClearMiningCacheAt(x, y, 1); if (!this.poundRelease) return; if (TileID.Sets.Platforms[(int) Main.tile[x, y].type]) { if (tile1.halfBrick()) { WorldGen.PoundTile(x, y); if (Main.netMode == 1) NetMessage.SendData(17, number: 7, number2: ((float) x), number3: ((float) y), number4: 1f); } else { int slope1 = 1; int slope2 = 2; if (TileID.Sets.Platforms[(int) Main.tile[x + 1, y - 1].type] || TileID.Sets.Platforms[(int) Main.tile[x - 1, y + 1].type] || WorldGen.SolidTile(x + 1, y) && !WorldGen.SolidTile(x - 1, y)) { slope1 = 2; slope2 = 1; } if (Main.tile[x, y].slope() == (byte) 0) { WorldGen.SlopeTile(x, y, slope1); int num = (int) Main.tile[x, y].slope(); if (Main.netMode == 1) NetMessage.SendData(17, number: 14, number2: ((float) x), number3: ((float) y), number4: ((float) num)); } else if ((int) Main.tile[x, y].slope() == slope1) { WorldGen.SlopeTile(x, y, slope2); int num = (int) Main.tile[x, y].slope(); if (Main.netMode == 1) NetMessage.SendData(17, number: 14, number2: ((float) x), number3: ((float) y), number4: ((float) num)); } else { WorldGen.SlopeTile(x, y); int num = (int) Main.tile[x, y].slope(); if (Main.netMode == 1) NetMessage.SendData(17, number: 14, number2: ((float) x), number3: ((float) y), number4: ((float) num)); WorldGen.PoundTile(x, y); if (Main.netMode == 1) NetMessage.SendData(17, number: 7, number2: ((float) x), number3: ((float) y), number4: 1f); } } } else if (Main.tile[x, y].type == (ushort) 314) { if (Minecart.FrameTrack(x, y, true) && Main.netMode == 1) NetMessage.SendData(17, number: 15, number2: ((float) x), number3: ((float) y), number4: 1f); } else if (Main.tile[x, y].type == (ushort) 137) { int num = 0; switch ((int) Main.tile[x, y].frameY / 18) { case 0: case 1: case 2: switch ((int) Main.tile[x, y].frameX / 18) { case 0: num = 2; break; case 1: num = 3; break; case 2: num = 4; break; case 3: num = 5; break; case 4: num = 1; break; case 5: num = 0; break; } break; case 3: case 4: switch ((int) Main.tile[x, y].frameX / 18) { case 0: case 1: num = 3; break; case 2: num = 4; break; case 3: num = 2; break; case 4: num = 0; break; } break; } Main.tile[x, y].frameX = (short) (num * 18); if (Main.netMode == 1) NetMessage.SendTileSquare(-1, x, y, 1); } else if (Main.tile[x, y].type == (ushort) 424) { Main.tile[x, y].frameX = Main.tile[x, y].frameX != (short) 0 ? (Main.tile[x, y].frameX != (short) 18 ? (short) 0 : (short) 36) : (short) 18; if (Main.netMode == 1) NetMessage.SendTileSquare(-1, x, y, 1); } else if (Main.tile[x, y].type == (ushort) 442) { Tile tile2 = Main.tile[x, y - 1]; Tile tile3 = Main.tile[x, y + 1]; Tile tile4 = Main.tile[x - 1, y]; Tile tile5 = Main.tile[x + 1, y]; Tile tile6 = Main.tile[x - 1, y + 1]; Tile tile7 = Main.tile[x + 1, y + 1]; Tile tile8 = Main.tile[x - 1, y - 1]; Tile tile9 = Main.tile[x + 1, y - 1]; int index1 = -1; int index2 = -1; int tree1 = -1; int tree2 = -1; int tree3 = -1; int tree4 = -1; int tree5 = -1; int tree6 = -1; if (tile2 != null && tile2.nactive() && !tile2.bottomSlope()) index2 = (int) tile2.type; if (tile3 != null && tile3.nactive() && !tile3.halfBrick() && !tile3.topSlope()) index1 = (int) tile3.type; if (tile4 != null && tile4.nactive() && (tile4.slope() == (byte) 0 || (int) tile4.slope() % 2 != 1)) tree1 = (int) tile4.type; if (tile5 != null && tile5.nactive() && (tile5.slope() == (byte) 0 || (int) tile5.slope() % 2 != 0)) tree2 = (int) tile5.type; if (tile6 != null && tile6.nactive()) tree3 = (int) tile6.type; if (tile7 != null && tile7.nactive()) tree4 = (int) tile7.type; if (tile8 != null && tile8.nactive()) tree5 = (int) tile8.type; if (tile9 != null && tile9.nactive()) tree6 = (int) tile9.type; bool flag1 = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; if (index1 >= 0 && Main.tileSolid[index1] && (!Main.tileNoAttach[index1] || TileID.Sets.Platforms[index1]) && (tile3.bottomSlope() || tile3.slope() == (byte) 0) && !tile3.halfBrick()) flag4 = true; if (index2 >= 0 && Main.tileSolid[index2] && (!Main.tileNoAttach[index2] || TileID.Sets.Platforms[index2] && tile2.halfBrick()) && (tile2.topSlope() || tile2.slope() == (byte) 0 || tile2.halfBrick())) flag1 = true; if (tree1 >= 0 && Main.tileSolid[tree1] && !Main.tileNoAttach[tree1] && (tile4.leftSlope() || tile4.slope() == (byte) 0) && !tile4.halfBrick() || tree1 >= 0 && TileID.Sets.IsBeam[tree1] || WorldGen.IsTreeType(tree1) && WorldGen.IsTreeType(tree5) && WorldGen.IsTreeType(tree3)) flag2 = true; if (tree2 >= 0 && Main.tileSolid[tree2] && !Main.tileNoAttach[tree2] && (tile5.rightSlope() || tile5.slope() == (byte) 0) && !tile5.halfBrick() || tree2 >= 0 && TileID.Sets.IsBeam[tree2] || WorldGen.IsTreeType(tree2) && WorldGen.IsTreeType(tree6) && WorldGen.IsTreeType(tree4)) flag3 = true; int num1 = (int) Main.tile[x, y].frameX / 22; short num2 = -2; switch (num1) { case 0: num2 = !flag2 ? (!flag1 ? (!flag3 ? (short) -1 : (short) 3) : (short) 1) : (short) 2; break; case 1: num2 = !flag3 ? (!flag4 ? (!flag2 ? (short) -1 : (short) 2) : (short) 0) : (short) 3; break; case 2: num2 = !flag1 ? (!flag3 ? (!flag4 ? (short) -1 : (short) 0) : (short) 3) : (short) 1; break; case 3: num2 = !flag4 ? (!flag2 ? (!flag1 ? (short) -1 : (short) 1) : (short) 2) : (short) 0; break; } switch (num2) { case -2: num2 = (short) 0; break; case -1: goto label_106; } Main.tile[x, y].frameX = (short) (22 * (int) num2); if (Main.netMode == 1) NetMessage.SendTileSquare(-1, x, y, 1); } else if ((Main.tile[x, y].halfBrick() || Main.tile[x, y].slope() != (byte) 0) && !Main.tileSolidTop[(int) Main.tile[x, y].type]) { int num3 = 1; int slope3 = 1; int slope4 = 2; if ((WorldGen.SolidTile(x + 1, y) || Main.tile[x + 1, y].slope() == (byte) 1 || Main.tile[x + 1, y].slope() == (byte) 3) && !WorldGen.SolidTile(x - 1, y)) { slope3 = 2; slope4 = 1; } if (WorldGen.SolidTile(x, y - 1) && !WorldGen.SolidTile(x, y + 1)) num3 = -1; if (num3 == 1) { if (Main.tile[x, y].slope() == (byte) 0) WorldGen.SlopeTile(x, y, slope3); else if ((int) Main.tile[x, y].slope() == slope3) WorldGen.SlopeTile(x, y, slope4); else if ((int) Main.tile[x, y].slope() == slope4) WorldGen.SlopeTile(x, y, slope3 + 2); else if ((int) Main.tile[x, y].slope() == slope3 + 2) WorldGen.SlopeTile(x, y, slope4 + 2); else WorldGen.SlopeTile(x, y); } else if (Main.tile[x, y].slope() == (byte) 0) WorldGen.SlopeTile(x, y, slope3 + 2); else if ((int) Main.tile[x, y].slope() == slope3 + 2) WorldGen.SlopeTile(x, y, slope4 + 2); else if ((int) Main.tile[x, y].slope() == slope4 + 2) WorldGen.SlopeTile(x, y, slope3); else if ((int) Main.tile[x, y].slope() == slope3) WorldGen.SlopeTile(x, y, slope4); else WorldGen.SlopeTile(x, y); int num4 = (int) Main.tile[x, y].slope(); if (Main.netMode == 1) NetMessage.SendData(17, number: 14, number2: ((float) x), number3: ((float) y), number4: ((float) num4)); } else { WorldGen.PoundTile(x, y); if (Main.netMode == 1) NetMessage.SendData(17, number: 7, number2: ((float) x), number3: ((float) y), number4: 1f); } label_106: this.poundRelease = false; } else { WorldGen.KillTile(x, y, true, true); SoundEngine.PlaySound(0, x * 16, y * 16); } } else this.poundRelease = false; } private bool IsTargetTileInItemRange(Item sItem) => (double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) sItem.tileBoost <= (double) Player.tileTargetX && ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) sItem.tileBoost - 1.0 >= (double) Player.tileTargetX && (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) sItem.tileBoost <= (double) Player.tileTargetY && ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) sItem.tileBoost - 2.0 >= (double) Player.tileTargetY; private void ItemCheck_UseBuckets(Item sItem) { if ((sItem.type < 205 || sItem.type > 207) && sItem.type != 1128 && sItem.type != 3031 && sItem.type != 3032 && sItem.type != 4820 && sItem.type != 4872 || this.noBuilding || (double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) sItem.tileBoost > (double) Player.tileTargetX || ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) sItem.tileBoost - 1.0 < (double) Player.tileTargetX || (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) sItem.tileBoost > (double) Player.tileTargetY || ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) sItem.tileBoost - 2.0 < (double) Player.tileTargetY) return; if (!Main.GamepadDisableCursorItemIcon) { this.cursorItemIconEnabled = true; Main.ItemIconCacheUpdate(sItem.type); } if (!this.ItemTimeIsZero || this.itemAnimation <= 0 || !this.controlUseItem) return; if (sItem.type == 205 || sItem.type == 3032 && Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType() == (byte) 0 || sItem.type == 4872 && Main.tile[Player.tileTargetX, Player.tileTargetY].lava()) { int num1 = (int) Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType(); int num2 = 0; for (int index1 = Player.tileTargetX - 1; index1 <= Player.tileTargetX + 1; ++index1) { for (int index2 = Player.tileTargetY - 1; index2 <= Player.tileTargetY + 1; ++index2) { if ((int) Main.tile[index1, index2].liquidType() == num1) num2 += (int) Main.tile[index1, index2].liquid; } } if (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid <= (byte) 0 || num2 <= 100 && sItem.type != 3032 && sItem.type != 4872) return; int liquidType = (int) Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType(); if (sItem.type != 3032 && sItem.type != 4872) { if (!Main.tile[Player.tileTargetX, Player.tileTargetY].lava()) { if (Main.tile[Player.tileTargetX, Player.tileTargetY].honey()) { --sItem.stack; this.PutItemInInventoryFromItemUsage(1128, this.selectedItem); } else { --sItem.stack; this.PutItemInInventoryFromItemUsage(206, this.selectedItem); } } else { --sItem.stack; this.PutItemInInventoryFromItemUsage(207, this.selectedItem); } } SoundEngine.PlaySound(19, (int) this.position.X, (int) this.position.Y); this.ApplyItemTime(sItem); int liquid = (int) Main.tile[Player.tileTargetX, Player.tileTargetY].liquid; Main.tile[Player.tileTargetX, Player.tileTargetY].liquid = (byte) 0; Main.tile[Player.tileTargetX, Player.tileTargetY].lava(false); Main.tile[Player.tileTargetX, Player.tileTargetY].honey(false); WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY, false); if (Main.netMode == 1) NetMessage.sendWater(Player.tileTargetX, Player.tileTargetY); else Liquid.AddWater(Player.tileTargetX, Player.tileTargetY); for (int index3 = Player.tileTargetX - 1; index3 <= Player.tileTargetX + 1; ++index3) { for (int index4 = Player.tileTargetY - 1; index4 <= Player.tileTargetY + 1; ++index4) { if (liquid < 256 && (int) Main.tile[index3, index4].liquidType() == num1) { int num3 = (int) Main.tile[index3, index4].liquid; if (num3 + liquid > (int) byte.MaxValue) num3 = (int) byte.MaxValue - liquid; liquid += num3; Main.tile[index3, index4].liquid -= (byte) num3; Main.tile[index3, index4].liquidType(liquidType); if (Main.tile[index3, index4].liquid == (byte) 0) { Main.tile[index3, index4].lava(false); Main.tile[index3, index4].honey(false); } WorldGen.SquareTileFrame(index3, index4, false); if (Main.netMode == 1) NetMessage.sendWater(index3, index4); else Liquid.AddWater(index3, index4); } } } } else { if (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid >= (byte) 200 || Main.tile[Player.tileTargetX, Player.tileTargetY].nactive() && Main.tileSolid[(int) Main.tile[Player.tileTargetX, Player.tileTargetY].type] && !Main.tileSolidTop[(int) Main.tile[Player.tileTargetX, Player.tileTargetY].type] && Main.tile[Player.tileTargetX, Player.tileTargetY].type != (ushort) 546) return; if (sItem.type == 207 || sItem.type == 4820) { if (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid != (byte) 0 && Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType() != (byte) 1) return; SoundEngine.PlaySound(19, (int) this.position.X, (int) this.position.Y); Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType(1); Main.tile[Player.tileTargetX, Player.tileTargetY].liquid = byte.MaxValue; WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY); if (sItem.type != 4820) { --sItem.stack; this.PutItemInInventoryFromItemUsage(205, this.selectedItem); } this.ApplyItemTime(sItem); if (Main.netMode != 1) return; NetMessage.sendWater(Player.tileTargetX, Player.tileTargetY); } else if (sItem.type == 206 || sItem.type == 3031) { if (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid != (byte) 0 && Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType() != (byte) 0) return; SoundEngine.PlaySound(19, (int) this.position.X, (int) this.position.Y); Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType(0); Main.tile[Player.tileTargetX, Player.tileTargetY].liquid = byte.MaxValue; WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY); if (sItem.type != 3031) { --sItem.stack; this.PutItemInInventoryFromItemUsage(205, this.selectedItem); } this.ApplyItemTime(sItem); if (Main.netMode != 1) return; NetMessage.sendWater(Player.tileTargetX, Player.tileTargetY); } else { if (sItem.type != 1128 || Main.tile[Player.tileTargetX, Player.tileTargetY].liquid != (byte) 0 && Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType() != (byte) 2) return; SoundEngine.PlaySound(19, (int) this.position.X, (int) this.position.Y); Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType(2); Main.tile[Player.tileTargetX, Player.tileTargetY].liquid = byte.MaxValue; WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY); --sItem.stack; this.PutItemInInventoryFromItemUsage(205, this.selectedItem); this.ApplyItemTime(sItem); if (Main.netMode != 1) return; NetMessage.sendWater(Player.tileTargetX, Player.tileTargetY); } } } private void ItemCheck_PlayInstruments(Item sItem) { if (this.itemAnimation > 0 && this.ItemTimeIsZero && (sItem.type == 508 || sItem.type == 507)) { this.ApplyItemTime(sItem); Vector2 vector2 = new Vector2(this.position.X + (float) this.width * 0.5f, this.position.Y + (float) this.height * 0.5f); double num1 = (double) Main.mouseX + (double) Main.screenPosition.X - (double) vector2.X; float num2 = (float) Main.mouseY + Main.screenPosition.Y - vector2.Y; float num3 = (float) Math.Sqrt(num1 * num1 + (double) num2 * (double) num2) / ((float) Main.screenHeight / Main.GameViewMatrix.Zoom.Y / 2f); if ((double) num3 > 1.0) num3 = 1f; float num4 = (float) ((double) num3 * 2.0 - 1.0); if ((double) num4 < -1.0) num4 = -1f; if ((double) num4 > 1.0) num4 = 1f; float number2 = (float) Math.Round((double) num4 * (double) Player.musicNotes) / (float) Player.musicNotes; Main.musicPitch = number2; LegacySoundStyle type = SoundID.Item26; if (sItem.type == 507) type = SoundID.Item35; SoundEngine.PlaySound(type, this.position); NetMessage.SendData(58, number: this.whoAmI, number2: number2); } if (this.itemAnimation <= 0 || this.mouseInterface) return; if (Main.mouseLeft && Main.mouseLeftRelease) { if (sItem.type == 1305) { Vector2 vector2 = new Vector2(this.position.X + (float) this.width * 0.5f, this.position.Y + (float) this.height * 0.5f); double num5 = (double) Main.mouseX + (double) Main.screenPosition.X - (double) vector2.X; float num6 = (float) Main.mouseY + Main.screenPosition.Y - vector2.Y; float num7 = (float) Math.Sqrt(num5 * num5 + (double) num6 * (double) num6) / ((float) Main.screenHeight / Main.GameViewMatrix.Zoom.Y / 2f); if ((double) num7 > 1.0) num7 = 1f; float num8 = (float) ((double) num7 * 2.0 - 1.0); if ((double) num8 < -1.0) num8 = -1f; if ((double) num8 > 1.0) num8 = 1f; float number2 = (float) Math.Round((double) num8 * (double) Player.musicNotes) / (float) Player.musicNotes; Main.musicPitch = number2; SoundEngine.PlaySound(SoundID.Item47, this.position); NetMessage.SendData(58, number: this.whoAmI, number2: number2); } else if (sItem.type == 4057 || sItem.type == 4372) { Vector2 vector2 = new Vector2(this.position.X + (float) this.width * 0.5f, this.position.Y + (float) this.height * 0.5f); double num9 = (double) Main.mouseX + (double) Main.screenPosition.X - (double) vector2.X; float num10 = (float) Main.mouseY + Main.screenPosition.Y - vector2.Y; float num11 = (float) Math.Sqrt(num9 * num9 + (double) num10 * (double) num10) / ((float) Main.screenHeight / Main.GameViewMatrix.Zoom.Y / 2f); if ((double) num11 > 1.0) num11 = 1f; this.PlayGuitarChord(num11); NetMessage.SendData(58, number: this.whoAmI, number2: num11); } } if (sItem.type == 4715 && ((!Main.mouseLeft ? 0 : (Main.mouseLeftRelease ? 1 : 0)) | (this.itemAnimation == this.itemAnimationMax - 1 ? 1 : 0)) != 0) { Vector2 vector2 = new Vector2(this.position.X + (float) this.width * 0.5f, this.position.Y + (float) this.height * 0.5f); double num12 = (double) Main.mouseX + (double) Main.screenPosition.X - (double) vector2.X; float num13 = (float) Main.mouseY + Main.screenPosition.Y - vector2.Y; float num14 = (float) Math.Sqrt(num12 * num12 + (double) num13 * (double) num13) / ((float) Main.screenHeight / Main.GameViewMatrix.Zoom.Y / 2f); if ((double) num14 > 1.0) num14 = 1f; this.PlayGuitarChord(num14); NetMessage.SendData(58, number: this.whoAmI, number2: num14); } if (sItem.type != 4673) return; int x = (int) this.Center.X / 16; int y = (int) this.Center.Y / 16; if (!WorldGen.InWorld(x, y) || Main.tile[x, y] == null || Main.tile[x, y].type != (ushort) 486 || (!Main.mouseLeft || !Main.mouseLeftRelease) && (!Main.mouseRight || !Main.mouseRightRelease)) return; Vector2 vector2_1 = new Vector2(this.position.X + (float) this.width * 0.5f, this.position.Y + (float) this.height * 0.5f); double num15 = (double) Main.mouseX + (double) Main.screenPosition.X - (double) vector2_1.X; float num16 = (float) Main.mouseY + Main.screenPosition.Y - vector2_1.Y; float num17 = (float) Math.Sqrt(num15 * num15 + (double) num16 * (double) num16) / ((float) Main.screenHeight / Main.GameViewMatrix.Zoom.Y / 2f); if ((double) num17 > 1.0) num17 = 1f; this.PlayDrums(num17); NetMessage.SendData(58, number: this.whoAmI, number2: num17); } private bool GetSparkleGuitarTarget(out List validTargets) { validTargets = new List(); Microsoft.Xna.Framework.Rectangle rectangle = Utils.CenteredRectangle(this.Center, new Vector2(1000f, 800f)); for (int index = 0; index < 200; ++index) { NPC npc = Main.npc[index]; if (npc.CanBeChasedBy((object) this) && npc.Hitbox.Intersects(rectangle)) validTargets.Add(npc); } return validTargets.Count != 0; } private bool GetZenithTarget(Vector2 searchCenter, float maxDistance, out int npcTargetIndex) { npcTargetIndex = 0; int? nullable = new int?(); float num1 = maxDistance; for (int index = 0; index < 200; ++index) { NPC npc = Main.npc[index]; if (npc.CanBeChasedBy((object) this)) { float num2 = searchCenter.Distance(npc.Center); if ((double) num1 > (double) num2) { nullable = new int?(index); num1 = num2; } } } if (!nullable.HasValue) return false; npcTargetIndex = nullable.Value; return true; } public void PlayGuitarChord(float range) { float num = 1f / 6f; if ((double) range > (double) num * 5.0) SoundEngine.PlaySound(51, this.Center); else if ((double) range > (double) num * 4.0) SoundEngine.PlaySound(47, this.Center); else if ((double) range > (double) num * 3.0) SoundEngine.PlaySound(48, this.Center); else if ((double) range > (double) num * 2.0) SoundEngine.PlaySound(49, this.Center); else if ((double) range > (double) num * 1.0) SoundEngine.PlaySound(50, this.Center); else SoundEngine.PlaySound(52, this.Center); } public void PlayDrums(float range) { float num = 1f / 10f; if ((double) range > (double) num * 9.0) SoundEngine.PlaySound(59, this.Center); else if ((double) range > (double) num * 8.0) SoundEngine.PlaySound(58, this.Center); else if ((double) range > (double) num * 7.0) SoundEngine.PlaySound(53, this.Center); else if ((double) range > (double) num * 6.0) SoundEngine.PlaySound(57, this.Center); else if ((double) range > (double) num * 5.0) SoundEngine.PlaySound(62, this.Center); else if ((double) range > (double) num * 4.0) SoundEngine.PlaySound(61, this.Center); else if ((double) range > (double) num * 3.0) SoundEngine.PlaySound(54, this.Center); else if ((double) range > (double) num * 2.0) SoundEngine.PlaySound(56, this.Center); else if ((double) range > (double) num * 1.0) SoundEngine.PlaySound(55, this.Center); else SoundEngine.PlaySound(60, this.Center); } private void ItemCheck_UseWiringTools(Item sItem) { if (sItem.type != 509 && sItem.type != 510 && sItem.type != 849 && sItem.type != 850 && sItem.type != 851 && sItem.type != 3612 && sItem.type != 3620 && sItem.type != 3625 || (double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) sItem.tileBoost - (double) this.blockRange > (double) Player.tileTargetX || ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) sItem.tileBoost - 1.0 + (double) this.blockRange < (double) Player.tileTargetX || (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) sItem.tileBoost - (double) this.blockRange > (double) Player.tileTargetY || ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) sItem.tileBoost - 2.0 + (double) this.blockRange < (double) Player.tileTargetY) return; if (!Main.GamepadDisableCursorItemIcon) { this.cursorItemIconEnabled = true; Main.ItemIconCacheUpdate(sItem.type); } if (this.itemAnimation <= 0 || !this.ItemTimeIsZero || !this.controlUseItem) return; int tileTargetX = Player.tileTargetX; int tileTargetY = Player.tileTargetY; if (sItem.type == 509) { int index1 = -1; for (int index2 = 0; index2 < 58; ++index2) { if (this.inventory[index2].stack > 0 && this.inventory[index2].type == 530) { index1 = index2; break; } } if (index1 >= 0 && WorldGen.PlaceWire(tileTargetX, tileTargetY)) { --this.inventory[index1].stack; if (this.inventory[index1].stack <= 0) this.inventory[index1].SetDefaults(); this.ApplyItemTime(sItem); NetMessage.SendData(17, number: 5, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } } else if (sItem.type == 850) { int index3 = -1; for (int index4 = 0; index4 < 58; ++index4) { if (this.inventory[index4].stack > 0 && this.inventory[index4].type == 530) { index3 = index4; break; } } if (index3 >= 0 && WorldGen.PlaceWire2(tileTargetX, tileTargetY)) { --this.inventory[index3].stack; if (this.inventory[index3].stack <= 0) this.inventory[index3].SetDefaults(); this.ApplyItemTime(sItem); NetMessage.SendData(17, number: 10, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } } if (sItem.type == 851) { int index5 = -1; for (int index6 = 0; index6 < 58; ++index6) { if (this.inventory[index6].stack > 0 && this.inventory[index6].type == 530) { index5 = index6; break; } } if (index5 >= 0 && WorldGen.PlaceWire3(tileTargetX, tileTargetY)) { --this.inventory[index5].stack; if (this.inventory[index5].stack <= 0) this.inventory[index5].SetDefaults(); this.ApplyItemTime(sItem); NetMessage.SendData(17, number: 12, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } } if (sItem.type == 3612) { int index7 = -1; for (int index8 = 0; index8 < 58; ++index8) { if (this.inventory[index8].stack > 0 && this.inventory[index8].type == 530) { index7 = index8; break; } } if (index7 >= 0 && WorldGen.PlaceWire4(tileTargetX, tileTargetY)) { --this.inventory[index7].stack; if (this.inventory[index7].stack <= 0) this.inventory[index7].SetDefaults(); this.ApplyItemTime(sItem); NetMessage.SendData(17, number: 16, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } } else if (sItem.type == 510) { if (WorldGen.KillActuator(tileTargetX, tileTargetY)) { this.ApplyItemTime(sItem); NetMessage.SendData(17, number: 9, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } else if (WorldGen.KillWire4(tileTargetX, tileTargetY)) { this.ApplyItemTime(sItem); NetMessage.SendData(17, number: 17, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } else if (WorldGen.KillWire3(tileTargetX, tileTargetY)) { this.ApplyItemTime(sItem); NetMessage.SendData(17, number: 13, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } else if (WorldGen.KillWire2(tileTargetX, tileTargetY)) { this.ApplyItemTime(sItem); NetMessage.SendData(17, number: 11, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } else if (WorldGen.KillWire(tileTargetX, tileTargetY)) { this.ApplyItemTime(sItem); NetMessage.SendData(17, number: 6, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } } else if (sItem.type == 849 && sItem.stack > 0 && WorldGen.PlaceActuator(tileTargetX, tileTargetY)) { this.ApplyItemTime(sItem); NetMessage.SendData(17, number: 8, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); --sItem.stack; if (sItem.stack <= 0) sItem.SetDefaults(); } if (sItem.type == 3620) { Tile tile = Main.tile[tileTargetX, tileTargetY]; if (tile != null && tile.actuator()) { bool flag = tile.inActive(); if ((!this.ActuationRodLock || this.ActuationRodLockSetting == tile.inActive()) && Wiring.Actuate(tileTargetX, tileTargetY) && flag != tile.inActive()) { this.ActuationRodLock = true; this.ActuationRodLockSetting = !tile.inActive(); this.ApplyItemTime(sItem); NetMessage.SendData(17, number: 19, number2: ((float) Player.tileTargetX), number3: ((float) Player.tileTargetY)); } } } if (sItem.type != 3625) return; Point point = new Point(Player.tileTargetX, Player.tileTargetY); this.ApplyItemTime(sItem); int toolMode = (int) WiresUI.Settings.ToolMode; WiresUI.Settings.ToolMode &= ~WiresUI.Settings.MultiToolMode.Actuator; if (Main.netMode == 1) NetMessage.SendData(109, number: point.X, number2: ((float) point.Y), number3: ((float) point.X), number4: ((float) point.Y), number5: ((int) WiresUI.Settings.ToolMode)); else Wiring.MassWireOperation(point, point, this); WiresUI.Settings.ToolMode = (WiresUI.Settings.MultiToolMode) toolMode; } private void ItemCheck_UseLawnMower(Item sItem) { if (sItem.type != 4049 || (double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) sItem.tileBoost - (double) this.blockRange > (double) Player.tileTargetX || ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) sItem.tileBoost - 1.0 + (double) this.blockRange < (double) Player.tileTargetX || (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) sItem.tileBoost - (double) this.blockRange > (double) Player.tileTargetY || ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) sItem.tileBoost - 2.0 + (double) this.blockRange < (double) Player.tileTargetY || this.itemAnimation <= 0 || !this.ItemTimeIsZero || !this.controlUseItem) return; this.MowGrassTile(new Point(Player.tileTargetX, Player.tileTargetY).ToWorldCoordinates()); this.ApplyItemTime(sItem); } private void DestroyOldestProximityMinesOverMinesCap(int minesCap) { Player._oldestProjCheckList.Clear(); for (int index = 0; index < 1000; ++index) { Projectile projectile = Main.projectile[index]; if (projectile.active && projectile.owner == this.whoAmI) { switch (projectile.type) { case 135: case 138: case 141: case 144: case 778: case 782: case 786: case 789: case 792: case 795: case 798: case 801: Player._oldestProjCheckList.Add(projectile); continue; default: continue; } } } while (Player._oldestProjCheckList.Count > minesCap) { Projectile oldestProjCheck = Player._oldestProjCheckList[0]; for (int index = 1; index < Player._oldestProjCheckList.Count; ++index) { if (Player._oldestProjCheckList[index].timeLeft < oldestProjCheck.timeLeft) oldestProjCheck = Player._oldestProjCheckList[index]; } oldestProjCheck.Kill(); Player._oldestProjCheckList.Remove(oldestProjCheck); } Player._oldestProjCheckList.Clear(); } private void ItemCheck_Shoot(int i, Item sItem, int weaponDamage) { int projToShoot = sItem.shoot; float shootSpeed = sItem.shootSpeed; int damage = sItem.damage; if (sItem.melee && projToShoot != 699 && projToShoot != 707) shootSpeed /= this.meleeSpeed; bool canShoot = false; int Damage1 = weaponDamage; float knockBack = sItem.knockBack; if (projToShoot == 13 || projToShoot == 32 || projToShoot == 315 || projToShoot >= 230 && projToShoot <= 235 || projToShoot == 331) { this.grappling[0] = -1; this.grapCount = 0; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == i) { if (Main.projectile[index].type == 13) Main.projectile[index].Kill(); if (Main.projectile[index].type == 331) Main.projectile[index].Kill(); if (Main.projectile[index].type == 315) Main.projectile[index].Kill(); if (Main.projectile[index].type >= 230 && Main.projectile[index].type <= 235) Main.projectile[index].Kill(); } } } if (sItem.useAmmo > 0) this.PickAmmo(sItem, ref projToShoot, ref shootSpeed, ref canShoot, ref Damage1, ref knockBack, ItemID.Sets.gunProj[sItem.type]); else canShoot = true; if (ItemID.Sets.gunProj[sItem.type]) { knockBack = sItem.knockBack; Damage1 = weaponDamage; shootSpeed = sItem.shootSpeed; } if (sItem.IsACoin) canShoot = false; if (sItem.type == 1254 && projToShoot == 14) projToShoot = 242; if (sItem.type == 1255 && projToShoot == 14) projToShoot = 242; if (sItem.type == 1265 && projToShoot == 14) projToShoot = 242; if (sItem.type == 3542) { if (Main.rand.Next(100) < 20) { ++projToShoot; Damage1 *= 3; } else --shootSpeed; } if (sItem.type == 1928) Damage1 /= 2; if (projToShoot == 73) { for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == i) { if (Main.projectile[index].type == 73) projToShoot = 74; if (projToShoot == 74 && Main.projectile[index].type == 74) canShoot = false; } } } if (canShoot) { float num1 = this.GetWeaponKnockback(sItem, knockBack); if (projToShoot == 228) num1 = 0.0f; if (projToShoot == 1 && sItem.type == 120) projToShoot = 2; if (sItem.type == 682) projToShoot = 117; if (sItem.type == 725) projToShoot = 120; if (sItem.type == 2796) projToShoot = 442; if (sItem.type == 2223) projToShoot = 357; this.ApplyItemTime(sItem); Vector2 vector2_1 = this.RotatedRelativePoint(this.MountedCenter, true); bool flag1 = true; if (sItem.type == 3611) flag1 = false; Vector2 vector2_2 = Vector2.UnitX.RotatedBy((double) this.fullRotation); Vector2 v1 = Main.MouseWorld - vector2_1; Vector2 v2 = this.itemRotation.ToRotationVector2() * (float) this.direction; if (sItem.type == 3852 && this.itemAnimation != this.itemAnimationMax - 1) v1 = (v2.ToRotation() + this.fullRotation).ToRotationVector2(); if (v1 != Vector2.Zero) v1.Normalize(); Vector2 vector2_3 = v1; float num2 = Vector2.Dot(vector2_2, vector2_3); if (flag1) { if ((double) num2 > 0.0) this.ChangeDir(1); else this.ChangeDir(-1); } if (sItem.type == 3094 || sItem.type == 3378 || sItem.type == 3543) vector2_1.Y = this.position.Y + (float) (this.height / 3); if (sItem.type == 2611) { Vector2 vector2_4 = v1; if (vector2_4 != Vector2.Zero) vector2_4.Normalize(); vector2_1 += vector2_4; } if (sItem.type == 3827) vector2_1 += v1.SafeNormalize(Vector2.Zero).RotatedBy((double) this.direction * -1.57079637050629) * 24f; if (projToShoot == 9) { vector2_1 = new Vector2((float) ((double) this.position.X + (double) this.width * 0.5 + (double) (Main.rand.Next(201) * -this.direction) + ((double) Main.mouseX + (double) Main.screenPosition.X - (double) this.position.X)), this.MountedCenter.Y - 600f); num1 = 0.0f; Damage1 *= 2; } if (sItem.type == 986 || sItem.type == 281) { vector2_1.X += (float) (6 * this.direction); vector2_1.Y -= 6f * this.gravDir; } if (sItem.type == 3007) { vector2_1.X -= (float) (4 * this.direction); vector2_1.Y -= 2f * this.gravDir; } float f1 = (float) Main.mouseX + Main.screenPosition.X - vector2_1.X; float f2 = (float) Main.mouseY + Main.screenPosition.Y - vector2_1.Y; if (sItem.type == 3852 && this.itemAnimation != this.itemAnimationMax - 1) { Vector2 vector2_5 = v1; f1 = vector2_5.X; f2 = vector2_5.Y; } if ((double) this.gravDir == -1.0) f2 = Main.screenPosition.Y + (float) Main.screenHeight - (float) Main.mouseY - vector2_1.Y; float num3 = (float) Math.Sqrt((double) f1 * (double) f1 + (double) f2 * (double) f2); float num4 = num3; float num5; if (float.IsNaN(f1) && float.IsNaN(f2) || (double) f1 == 0.0 && (double) f2 == 0.0) { f1 = (float) this.direction; f2 = 0.0f; num5 = shootSpeed; } else num5 = shootSpeed / num3; if (sItem.type == 1929 || sItem.type == 2270) { f1 += (float) Main.rand.Next(-50, 51) * 0.03f / num5; f2 += (float) Main.rand.Next(-50, 51) * 0.03f / num5; } float num6 = f1 * num5; float num7 = f2 * num5; if (sItem.type == 757) Damage1 = (int) ((double) Damage1 * 1.25); if (projToShoot == 250) { for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI && (Main.projectile[index].type == 250 || Main.projectile[index].type == 251)) Main.projectile[index].Kill(); } } if (projToShoot == 12 && Collision.CanHitLine(this.Center, 0, 0, vector2_1 + new Vector2(num6, num7) * 4f, 0, 0)) vector2_1 += new Vector2(num6, num7) * 3f; if (projToShoot == 728 && !Collision.CanHitLine(this.Center, 0, 0, vector2_1 + new Vector2(num6, num7) * 2f, 0, 0)) { vector2_1 = this.Center - new Vector2(num6, num7); num6 *= 0.5f; num7 *= 0.5f; } if (projToShoot == 802 || projToShoot == 842) { Vector2 v3 = new Vector2(num6, num7); float num8 = 0.7853982f; Vector2 vector2_6 = v3.SafeNormalize(Vector2.Zero).RotatedBy((double) num8 * ((double) Main.rand.NextFloat() - 0.5)) * (v3.Length() - Main.rand.NextFloatDirection() * 0.7f); num6 = vector2_6.X; num7 = vector2_6.Y; } if (sItem.useStyle == 5) { if (sItem.type == 3029) { Vector2 vector2_7 = new Vector2(num6, num7); vector2_7.X = (float) Main.mouseX + Main.screenPosition.X - vector2_1.X; vector2_7.Y = (float) ((double) Main.mouseY + (double) Main.screenPosition.Y - (double) vector2_1.Y - 1000.0); this.itemRotation = (float) Math.Atan2((double) vector2_7.Y * (double) this.direction, (double) vector2_7.X * (double) this.direction); NetMessage.SendData(13, number: this.whoAmI); NetMessage.SendData(41, number: this.whoAmI); } if (sItem.type == 4381) { Vector2 vector2_8 = new Vector2(num6, num7); vector2_8.X = (float) Main.mouseX + Main.screenPosition.X - vector2_1.X; vector2_8.Y = (float) ((double) Main.mouseY + (double) Main.screenPosition.Y - (double) vector2_1.Y - 1000.0); this.itemRotation = (float) Math.Atan2((double) vector2_8.Y * (double) this.direction, (double) vector2_8.X * (double) this.direction); NetMessage.SendData(13, number: this.whoAmI); NetMessage.SendData(41, number: this.whoAmI); } else if (sItem.type == 3779) { this.itemRotation = 0.0f; NetMessage.SendData(13, number: this.whoAmI); NetMessage.SendData(41, number: this.whoAmI); } else { this.itemRotation = (float) Math.Atan2((double) num7 * (double) this.direction, (double) num6 * (double) this.direction) - this.fullRotation; NetMessage.SendData(13, number: this.whoAmI); NetMessage.SendData(41, number: this.whoAmI); } } if (sItem.useStyle == 13) { this.itemRotation = (float) Math.Atan2((double) num7 * (double) this.direction, (double) num6 * (double) this.direction) - this.fullRotation; NetMessage.SendData(13, number: this.whoAmI); NetMessage.SendData(41, number: this.whoAmI); } if (projToShoot == 17) { vector2_1.X = (float) Main.mouseX + Main.screenPosition.X; vector2_1.Y = (float) Main.mouseY + Main.screenPosition.Y; if ((double) this.gravDir == -1.0) vector2_1.Y = Main.screenPosition.Y + (float) Main.screenHeight - (float) Main.mouseY; } if (projToShoot == 76) { projToShoot += Main.rand.Next(3); float num9 = (float) Main.screenHeight / Main.GameViewMatrix.Zoom.Y; float num10 = num4 / (num9 / 2f); if ((double) num10 > 1.0) num10 = 1f; float num11 = num6 + (float) Main.rand.Next(-40, 41) * 0.01f; float num12 = num7 + (float) Main.rand.Next(-40, 41) * 0.01f; float SpeedX = num11 * (num10 + 0.25f); float SpeedY = num12 * (num10 + 0.25f); int number = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); Main.projectile[number].ai[1] = 1f; float num13 = (float) ((double) num10 * 2.0 - 1.0); if ((double) num13 < -1.0) num13 = -1f; if ((double) num13 > 1.0) num13 = 1f; float num14 = (float) Math.Round((double) num13 * (double) Player.musicNotes) / (float) Player.musicNotes; Main.projectile[number].ai[0] = num14; NetMessage.SendData(27, number: number); } else if (sItem.type == 3029) { int num15 = 3; if (projToShoot == 91 || projToShoot == 4 || projToShoot == 5 || projToShoot == 41) { if (Main.rand.Next(3) == 0) --num15; } else if (Main.rand.Next(3) == 0) ++num15; for (int index1 = 0; index1 < num15; ++index1) { vector2_1 = new Vector2((float) ((double) this.position.X + (double) this.width * 0.5 + (double) (Main.rand.Next(201) * -this.direction) + ((double) Main.mouseX + (double) Main.screenPosition.X - (double) this.position.X)), this.MountedCenter.Y - 600f); vector2_1.X = (float) (((double) vector2_1.X * 10.0 + (double) this.Center.X) / 11.0) + (float) Main.rand.Next(-100, 101); vector2_1.Y -= (float) (150 * index1); float num16 = (float) Main.mouseX + Main.screenPosition.X - vector2_1.X; float num17 = (float) Main.mouseY + Main.screenPosition.Y - vector2_1.Y; if ((double) num17 < 0.0) num17 *= -1f; if ((double) num17 < 20.0) num17 = 20f; float num18 = (float) Math.Sqrt((double) num16 * (double) num16 + (double) num17 * (double) num17); float num19 = shootSpeed / num18; float num20 = num16 * num19; float num21 = num17 * num19; float num22 = num20 + (float) Main.rand.Next(-40, 41) * 0.03f; float SpeedY = num21 + (float) Main.rand.Next(-40, 41) * 0.03f; float SpeedX = num22 * ((float) Main.rand.Next(75, 150) * 0.01f); vector2_1.X += (float) Main.rand.Next(-50, 51); int index2 = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); Main.projectile[index2].noDropItem = true; } } else if (sItem.type == 4381) { int num23 = Main.rand.Next(1, 3); if (Main.rand.Next(3) == 0) ++num23; for (int index3 = 0; index3 < num23; ++index3) { vector2_1 = new Vector2((float) ((double) this.position.X + (double) this.width * 0.5 + (double) (Main.rand.Next(61) * -this.direction) + ((double) Main.mouseX + (double) Main.screenPosition.X - (double) this.position.X)), this.MountedCenter.Y - 600f); vector2_1.X = (float) (((double) vector2_1.X * 10.0 + (double) this.Center.X) / 11.0) + (float) Main.rand.Next(-30, 31); vector2_1.Y -= 150f * Main.rand.NextFloat(); float num24 = (float) Main.mouseX + Main.screenPosition.X - vector2_1.X; float num25 = (float) Main.mouseY + Main.screenPosition.Y - vector2_1.Y; if ((double) num25 < 0.0) num25 *= -1f; if ((double) num25 < 20.0) num25 = 20f; float num26 = (float) Math.Sqrt((double) num24 * (double) num24 + (double) num25 * (double) num25); float num27 = shootSpeed / num26; float num28 = num24 * num27; float num29 = num25 * num27; float num30 = num28 + (float) Main.rand.Next(-20, 21) * 0.03f; float SpeedY = num29 + (float) Main.rand.Next(-40, 41) * 0.03f; float SpeedX = num30 * ((float) Main.rand.Next(55, 80) * 0.01f); vector2_1.X += (float) Main.rand.Next(-50, 51); int index4 = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); Main.projectile[index4].noDropItem = true; } } else if (sItem.type == 98 || sItem.type == 533) { float SpeedX = num6 + (float) Main.rand.Next(-40, 41) * 0.01f; float SpeedY = num7 + (float) Main.rand.Next(-40, 41) * 0.01f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } else if (sItem.type == 1319) { float SpeedX = num6 + (float) Main.rand.Next(-40, 41) * 0.02f; float SpeedY = num7 + (float) Main.rand.Next(-40, 41) * 0.02f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } else if (sItem.type == 3107) { float SpeedX = num6 + (float) Main.rand.Next(-40, 41) * 0.02f; float SpeedY = num7 + (float) Main.rand.Next(-40, 41) * 0.02f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } else if (ProjectileID.Sets.IsAGolfBall[projToShoot]) { Vector2 vector2_9 = new Vector2((float) Main.mouseX + Main.screenPosition.X, (float) Main.mouseY + Main.screenPosition.Y); Vector2 vector2_10 = vector2_9 - this.Center; bool flag2 = false; if ((double) vector2_10.Length() < 100.0) flag2 = this.TryPlacingAGolfBallNearANearbyTee(vector2_9); if (flag2) return; if ((double) vector2_10.Length() > 100.0 || !Collision.CanHit(this.Center, 1, 1, vector2_9, 1, 1)) Projectile.NewProjectile(vector2_1.X, vector2_1.Y, num6, num7, projToShoot, Damage1, num1, i); else Projectile.NewProjectile(vector2_9.X, vector2_9.Y, 0.0f, 0.0f, projToShoot, Damage1, num1, i); } else if (sItem.type == 3053) { Vector2 vector2_11 = new Vector2(num6, num7); vector2_11.Normalize(); Vector2 vector2_12 = new Vector2((float) Main.rand.Next(-100, 101), (float) Main.rand.Next(-100, 101)); vector2_12.Normalize(); Vector2 vector2_13 = vector2_11 * 4f + vector2_12; vector2_13.Normalize(); vector2_13 *= sItem.shootSpeed; float ai1 = (float) Main.rand.Next(10, 80) * (1f / 1000f); if (Main.rand.Next(2) == 0) ai1 *= -1f; float ai0 = (float) Main.rand.Next(10, 80) * (1f / 1000f); if (Main.rand.Next(2) == 0) ai0 *= -1f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, vector2_13.X, vector2_13.Y, projToShoot, Damage1, num1, i, ai0, ai1); } else if (sItem.type == 3019) { Vector2 vector2_14 = new Vector2(num6, num7); float num31 = vector2_14.Length(); vector2_14.X += (float) ((double) Main.rand.Next(-100, 101) * 0.00999999977648258 * (double) num31 * 0.150000005960464); vector2_14.Y += (float) ((double) Main.rand.Next(-100, 101) * 0.00999999977648258 * (double) num31 * 0.150000005960464); float num32 = num6 + (float) Main.rand.Next(-40, 41) * 0.03f; float num33 = num7 + (float) Main.rand.Next(-40, 41) * 0.03f; vector2_14.Normalize(); vector2_14 *= num31; Vector2 vector2_15 = new Vector2(num32 * ((float) Main.rand.Next(50, 150) * 0.01f), num33 * ((float) Main.rand.Next(50, 150) * 0.01f)); vector2_15.X += (float) Main.rand.Next(-100, 101) * 0.025f; vector2_15.Y += (float) Main.rand.Next(-100, 101) * 0.025f; vector2_15.Normalize(); Vector2 vector2_16 = vector2_15 * num31; float x = vector2_16.X; float y = vector2_16.Y; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, x, y, projToShoot, Damage1, num1, i, vector2_14.X, vector2_14.Y); } else if (sItem.type == 2797) { Vector2 vector2_17 = Vector2.Normalize(new Vector2(num6, num7)) * 40f * sItem.scale; if (Collision.CanHit(vector2_1, 0, 0, vector2_1 + vector2_17, 0, 0)) vector2_1 += vector2_17; float rotation = new Vector2(num6, num7).ToRotation(); float num34 = 2.094395f; int num35 = Main.rand.Next(4, 5); if (Main.rand.Next(4) == 0) ++num35; for (int index5 = 0; index5 < num35; ++index5) { float num36 = (float) (Main.rand.NextDouble() * 0.200000002980232 + 0.0500000007450581); Vector2 vector2_18 = new Vector2(num6, num7).RotatedBy((double) num34 * Main.rand.NextDouble() - (double) num34 / 2.0) * num36; int index6 = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, vector2_18.X, vector2_18.Y, 444, Damage1, num1, i, rotation); Main.projectile[index6].localAI[0] = (float) projToShoot; Main.projectile[index6].localAI[1] = shootSpeed; } } else if (sItem.type == 2270) { float SpeedX = num6 + (float) Main.rand.Next(-40, 41) * 0.05f; float SpeedY = num7 + (float) Main.rand.Next(-40, 41) * 0.05f; if (Main.rand.Next(3) == 0) { SpeedX *= (float) (1.0 + (double) Main.rand.Next(-30, 31) * 0.0199999995529652); SpeedY *= (float) (1.0 + (double) Main.rand.Next(-30, 31) * 0.0199999995529652); } Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } else if (sItem.type == 1930) { int num37 = 2 + Main.rand.Next(3); for (int index = 0; index < num37; ++index) { float num38 = num6; float num39 = num7; float num40 = 0.025f * (float) index; float num41 = num38 + (float) Main.rand.Next(-35, 36) * num40; float num42 = num39 + (float) Main.rand.Next(-35, 36) * num40; float num43 = (float) Math.Sqrt((double) num41 * (double) num41 + (double) num42 * (double) num42); float num44 = shootSpeed / num43; float SpeedX = num41 * num44; float SpeedY = num42 * num44; Projectile.NewProjectile(vector2_1.X + (float) ((double) num6 * (double) (num37 - index) * 1.75), vector2_1.Y + (float) ((double) num7 * (double) (num37 - index) * 1.75), SpeedX, SpeedY, projToShoot, Damage1, num1, i, (float) Main.rand.Next(0, 10 * (index + 1))); } } else if (sItem.type == 1931) { int num45 = 2; for (int index = 0; index < num45; ++index) { vector2_1 = new Vector2((float) ((double) this.position.X + (double) this.width * 0.5 + (double) (Main.rand.Next(201) * -this.direction) + ((double) Main.mouseX + (double) Main.screenPosition.X - (double) this.position.X)), this.MountedCenter.Y - 600f); vector2_1.X = (float) (((double) vector2_1.X + (double) this.Center.X) / 2.0) + (float) Main.rand.Next(-200, 201); vector2_1.Y -= (float) (100 * index); float num46 = (float) Main.mouseX + Main.screenPosition.X - vector2_1.X; float num47 = (float) Main.mouseY + Main.screenPosition.Y - vector2_1.Y; if ((double) this.gravDir == -1.0) num47 = Main.screenPosition.Y + (float) Main.screenHeight - (float) Main.mouseY - vector2_1.Y; if ((double) num47 < 0.0) num47 *= -1f; if ((double) num47 < 20.0) num47 = 20f; float num48 = (float) Math.Sqrt((double) num46 * (double) num46 + (double) num47 * (double) num47); float num49 = shootSpeed / num48; float num50 = num46 * num49; float num51 = num47 * num49; float SpeedX = num50 + (float) Main.rand.Next(-40, 41) * 0.02f; float SpeedY = num51 + (float) Main.rand.Next(-40, 41) * 0.02f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i, ai1: ((float) Main.rand.Next(5))); } } else if (sItem.type == 2750) { int num52 = 1; for (int index = 0; index < num52; ++index) { vector2_1 = new Vector2((float) ((double) this.position.X + (double) this.width * 0.5 + (double) (Main.rand.Next(201) * -this.direction) + ((double) Main.mouseX + (double) Main.screenPosition.X - (double) this.position.X)), this.MountedCenter.Y - 600f); vector2_1.X = (float) (((double) vector2_1.X + (double) this.Center.X) / 2.0) + (float) Main.rand.Next(-200, 201); vector2_1.Y -= (float) (100 * index); float num53 = (float) ((double) Main.mouseX + (double) Main.screenPosition.X - (double) vector2_1.X + (double) Main.rand.Next(-40, 41) * 0.0299999993294477); float num54 = (float) Main.mouseY + Main.screenPosition.Y - vector2_1.Y; if ((double) this.gravDir == -1.0) num54 = Main.screenPosition.Y + (float) Main.screenHeight - (float) Main.mouseY - vector2_1.Y; if ((double) num54 < 0.0) num54 *= -1f; if ((double) num54 < 20.0) num54 = 20f; float num55 = (float) Math.Sqrt((double) num53 * (double) num53 + (double) num54 * (double) num54); float num56 = shootSpeed / num55; float num57 = num53 * num56; float num58 = num54 * num56; float num59 = num57; float num60 = num58 + (float) Main.rand.Next(-40, 41) * 0.02f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, num59 * 0.75f, num60 * 0.75f, projToShoot + Main.rand.Next(3), Damage1, num1, i, ai1: ((float) (0.5 + Main.rand.NextDouble() * 0.300000011920929))); } } else if (sItem.type == 3570) { int num61 = 3; for (int index = 0; index < num61; ++index) { vector2_1 = new Vector2((float) ((double) this.position.X + (double) this.width * 0.5 + (double) (Main.rand.Next(201) * -this.direction) + ((double) Main.mouseX + (double) Main.screenPosition.X - (double) this.position.X)), this.MountedCenter.Y - 600f); vector2_1.X = (float) (((double) vector2_1.X + (double) this.Center.X) / 2.0) + (float) Main.rand.Next(-200, 201); vector2_1.Y -= (float) (100 * index); float num62 = (float) Main.mouseX + Main.screenPosition.X - vector2_1.X; float num63 = (float) Main.mouseY + Main.screenPosition.Y - vector2_1.Y; float ai1 = num63 + vector2_1.Y; if ((double) num63 < 0.0) num63 *= -1f; if ((double) num63 < 20.0) num63 = 20f; float num64 = (float) Math.Sqrt((double) num62 * (double) num62 + (double) num63 * (double) num63); float num65 = shootSpeed / num64; Vector2 vector2_19 = new Vector2(num62 * num65, num63 * num65) / 2f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, vector2_19.X, vector2_19.Y, projToShoot, Damage1, num1, i, ai1: ai1); } } else if (sItem.type == 3065) { Vector2 vector2_20 = Main.screenPosition + new Vector2((float) Main.mouseX, (float) Main.mouseY); float ai1 = vector2_20.Y; if ((double) ai1 > (double) this.Center.Y - 200.0) ai1 = this.Center.Y - 200f; for (int index = 0; index < 3; ++index) { vector2_1 = this.Center + new Vector2((float) (-Main.rand.Next(0, 401) * this.direction), -600f); vector2_1.Y -= (float) (100 * index); Vector2 vector2_21 = vector2_20 - vector2_1; if ((double) vector2_21.Y < 0.0) vector2_21.Y *= -1f; if ((double) vector2_21.Y < 20.0) vector2_21.Y = 20f; vector2_21.Normalize(); Vector2 vector2_22 = vector2_21 * shootSpeed; float x = vector2_22.X; float y = vector2_22.Y; float SpeedX = x; float SpeedY = y + (float) Main.rand.Next(-40, 41) * 0.02f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1 * 2, num1, i, ai1: ai1); } } else if (sItem.type == 2624) { float num66 = 0.3141593f; int num67 = 5; Vector2 spinningpoint = new Vector2(num6, num7); spinningpoint.Normalize(); spinningpoint *= 40f; bool flag3 = Collision.CanHit(vector2_1, 0, 0, vector2_1 + spinningpoint, 0, 0); for (int index7 = 0; index7 < num67; ++index7) { float num68 = (float) index7 - (float) (((double) num67 - 1.0) / 2.0); Vector2 vector2_23 = spinningpoint.RotatedBy((double) num66 * (double) num68); if (!flag3) vector2_23 -= spinningpoint; int index8 = Projectile.NewProjectile(vector2_1.X + vector2_23.X, vector2_1.Y + vector2_23.Y, num6, num7, projToShoot, Damage1, num1, i); Main.projectile[index8].noDropItem = true; } } else if (sItem.type == 1929) { float SpeedX = num6 + (float) Main.rand.Next(-40, 41) * 0.03f; float SpeedY = num7 + (float) Main.rand.Next(-40, 41) * 0.03f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } else if (sItem.type == 1553) { float SpeedX = num6 + (float) Main.rand.Next(-40, 41) * 0.005f; float SpeedY = num7 + (float) Main.rand.Next(-40, 41) * 0.005f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } else if (sItem.type == 518) { float num69 = num6; float num70 = num7; float SpeedX = num69 + (float) Main.rand.Next(-40, 41) * 0.04f; float SpeedY = num70 + (float) Main.rand.Next(-40, 41) * 0.04f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } else if (sItem.type == 1265) { float num71 = num6; float num72 = num7; float SpeedX = num71 + (float) Main.rand.Next(-30, 31) * 0.03f; float SpeedY = num72 + (float) Main.rand.Next(-30, 31) * 0.03f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } else if (sItem.type == 4262) { float num73 = 2.666667f; Vector2 bottom = this.Bottom; int num74 = (int) this.Bottom.X / 16; float num75 = Math.Abs((float) Main.mouseX + Main.screenPosition.X - this.position.X) / 16f; if (this.direction < 0) ++num75; int num76 = (int) num75; if (num76 > 15) num76 = 15; Point tileCoordinates = this.Center.ToTileCoordinates(); int maxDistance = 31; for (int index9 = num76; index9 >= 0; --index9) { if (Collision.CanHitLine(this.Center, 1, 1, this.Center + new Vector2((float) (16 * index9 * this.direction), 0.0f), 1, 1)) { Point result; if (WorldUtils.Find(new Point(tileCoordinates.X + this.direction * index9, tileCoordinates.Y), Searches.Chain((GenSearch) new Searches.Down(maxDistance), (GenCondition) new Conditions.MysticSnake()), out result)) { int num77 = result.Y; while (Main.tile[result.X, num77 - 1].active()) { --num77; if (Main.tile[result.X, num77 - 1] == null || num77 < 10 || result.Y - num77 > 7) { num77 = -1; break; } } if (num77 >= 10) { result.Y = num77; for (int index10 = 0; index10 < 1000; ++index10) { Projectile projectile = Main.projectile[index10]; if (projectile.active && projectile.owner == this.whoAmI && projectile.type == projToShoot) { if ((double) projectile.ai[1] == 2.0) projectile.timeLeft = 4; else projectile.Kill(); } } Projectile.NewProjectile((float) (result.X * 16 + 8), (float) (result.Y * 16 + 8 - 16), 0.0f, -num73, projToShoot, Damage1, num1, i, (float) (result.Y * 16 + 8 - 16)); break; } } } } } else if (sItem.type == 4952) { Vector2 vector2_24 = Main.rand.NextVector2Circular(1f, 1f) + Main.rand.NextVector2CircularEdge(3f, 3f); if ((double) vector2_24.Y > 0.0) vector2_24.Y *= -1f; float num78 = (float) ((double) this.itemAnimation / (double) this.itemAnimationMax * 0.660000026226044) + this.miscCounterNormalized; vector2_1 = this.MountedCenter + new Vector2((float) (this.direction * 15), this.gravDir * 3f); Projectile.NewProjectile(vector2_1.X, vector2_1.Y, vector2_24.X, vector2_24.Y, projToShoot, Damage1, num1, i, -1f, num78 % 1f); } else if (sItem.type == 4953) { float num79 = 0.3141593f; int num80 = 5; Vector2 spinningpoint = new Vector2(num6, num7); spinningpoint.Normalize(); spinningpoint *= 40f; int num81 = Collision.CanHit(vector2_1, 0, 0, vector2_1 + spinningpoint, 0, 0) ? 1 : 0; int num82 = (this.itemAnimationMax - this.itemAnimation) / 2; int num83 = num82; if (this.direction == 1) num83 = 4 - num82; float num84 = (float) num83 - (float) (((double) num80 - 1.0) / 2.0); Vector2 vector2_25 = spinningpoint.RotatedBy((double) num79 * (double) num84); if (num81 == 0) vector2_25 -= spinningpoint; Vector2 mouseWorld = Main.MouseWorld; Vector2 vector2_26 = vector2_1 + vector2_25; Vector2 vector2_27 = vector2_26.DirectionTo(mouseWorld).SafeNormalize(-Vector2.UnitY); Vector2 vector2_28 = this.Center.DirectionTo(this.Center + new Vector2(num6, num7)).SafeNormalize(-Vector2.UnitY); float lerpValue = Utils.GetLerpValue(100f, 40f, mouseWorld.Distance(this.Center), true); if ((double) lerpValue > 0.0) vector2_27 = Vector2.Lerp(vector2_27, vector2_28, lerpValue).SafeNormalize(new Vector2(num6, num7).SafeNormalize(-Vector2.UnitY)); Vector2 vector2_29 = vector2_27 * shootSpeed; if (num82 == 2) { projToShoot = 932; Damage1 *= 2; } if (projToShoot == 932) { float ai1 = (float) ((double) this.miscCounterNormalized * 12.0 % 1.0); Vector2 velocity = vector2_29.SafeNormalize(Vector2.Zero) * (shootSpeed * 2f); Projectile.NewProjectile(vector2_26, velocity, projToShoot, Damage1, num1, i, ai1: ai1); } else { int index = Projectile.NewProjectile(vector2_26, vector2_29, projToShoot, Damage1, num1, i); Main.projectile[index].noDropItem = true; } } else if (sItem.type == 534) { int num85 = Main.rand.Next(4, 6); for (int index = 0; index < num85; ++index) { float num86 = num6; float num87 = num7; float SpeedX = num86 + (float) Main.rand.Next(-40, 41) * 0.05f; float SpeedY = num87 + (float) Main.rand.Next(-40, 41) * 0.05f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } } else if (sItem.type == 4703) { float num88 = 1.570796f; for (int index = 0; index < 4; ++index) { Vector2 v4 = new Vector2(num6, num7); float num89 = v4.Length(); v4 = (v4 + v4.SafeNormalize(Vector2.Zero).RotatedBy((double) num88 * (double) Main.rand.NextFloat()) * Main.rand.NextFloatDirection() * 6f).SafeNormalize(Vector2.Zero) * num89; float x = v4.X; float y = v4.Y; float SpeedX = x + (float) Main.rand.Next(-40, 41) * 0.05f; float SpeedY = y + (float) Main.rand.Next(-40, 41) * 0.05f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } } else if (sItem.type == 4270) { Vector2 targetSpot = Main.MouseWorld + Main.rand.NextVector2Circular(8f, 8f); Vector2 worldCoordinates = this.FindSharpTearsSpot(targetSpot).ToWorldCoordinates((float) Main.rand.Next(17), (float) Main.rand.Next(17)); Vector2 vector2_30 = (targetSpot - worldCoordinates).SafeNormalize(-Vector2.UnitY) * 16f; Projectile.NewProjectile(worldCoordinates.X, worldCoordinates.Y, vector2_30.X, vector2_30.Y, projToShoot, Damage1, num1, i, ai1: ((float) ((double) Main.rand.NextFloat() * 0.5 + 0.5))); } else if (sItem.type == 4715) { Vector2 vector2_31 = Main.MouseWorld; List validTargets; int num90 = this.GetSparkleGuitarTarget(out validTargets) ? 1 : 0; if (num90 != 0) { NPC npc = validTargets[Main.rand.Next(validTargets.Count)]; vector2_31 = npc.Center + npc.velocity * 20f; } Vector2 vector2_32 = vector2_31 - this.Center; if (num90 == 0) { vector2_31 += Main.rand.NextVector2Circular(24f, 24f); if ((double) vector2_32.Length() > 700.0) { vector2_32 *= 700f / vector2_32.Length(); vector2_31 = this.Center + vector2_32; } } Vector2 vector2_33 = Main.rand.NextVector2CircularEdge(1f, 1f); if ((double) vector2_33.Y > 0.0) vector2_33 *= -1f; if ((double) Math.Abs(vector2_33.Y) < 0.5) vector2_33.Y = (float) (-(double) Main.rand.NextFloat() * 0.5 - 0.5); Vector2 vector2_34 = vector2_33 * (vector2_32.Length() * 2f); Projectile.NewProjectile(vector2_1.X, vector2_1.Y, vector2_34.X, vector2_34.Y, projToShoot, Damage1, num1, i, vector2_31.X, vector2_31.Y); } else if (sItem.type == 4722) { Vector2 vector2_35 = Main.MouseWorld; List validTargets; bool sparkleGuitarTarget = this.GetSparkleGuitarTarget(out validTargets); if (sparkleGuitarTarget) { NPC npc = validTargets[Main.rand.Next(validTargets.Count)]; vector2_35 = npc.Center + npc.velocity * 20f; } Vector2 vector2_36 = vector2_35 - this.Center; Vector2 vector2_37 = Main.rand.NextVector2CircularEdge(1f, 1f); float num91 = 1f; int num92 = 1; for (int index11 = 0; index11 < num92; ++index11) { if (!sparkleGuitarTarget) { vector2_35 += Main.rand.NextVector2Circular(24f, 24f); if ((double) vector2_36.Length() > 700.0) { vector2_36 *= 700f / vector2_36.Length(); vector2_35 = this.Center + vector2_36; } float num93 = Utils.GetLerpValue(0.0f, 6f, this.velocity.Length(), true) * 0.8f; vector2_37 = (vector2_37 * (1f - num93) + this.velocity * num93).SafeNormalize(Vector2.UnitX); } float num94 = 60f; float num95 = (float) ((double) Main.rand.NextFloatDirection() * 3.14159274101257 * (1.0 / (double) num94) * 0.5) * num91; float num96 = num94 / 2f; float num97 = (float) (12.0 + (double) Main.rand.NextFloat() * 2.0); Vector2 vector2_38 = vector2_37 * num97; Vector2 vector2_39 = new Vector2(0.0f, 0.0f); Vector2 spinningpoint = vector2_38; for (int index12 = 0; (double) index12 < (double) num96; ++index12) { vector2_39 += spinningpoint; spinningpoint = spinningpoint.RotatedBy((double) num95); } Vector2 vector2_40 = -vector2_39; Vector2 position = vector2_35 + vector2_40; float lerpValue = Utils.GetLerpValue((float) this.itemAnimationMax, 0.0f, (float) this.itemAnimation, true); Vector2 velocity = vector2_38; int Type = projToShoot; int Damage2 = Damage1; double num98 = (double) num1; int Owner = i; double num99 = (double) num95; double num100 = (double) lerpValue; Projectile.NewProjectile(position, velocity, Type, Damage2, (float) num98, Owner, (float) num99, (float) num100); } } else if (sItem.type == 4607) Player.SpawnMinionOnCursor(i, projToShoot, damage, num1); else if (sItem.type == 2188) { int num101 = 4; if (Main.rand.Next(3) == 0) ++num101; if (Main.rand.Next(4) == 0) ++num101; if (Main.rand.Next(5) == 0) ++num101; for (int index = 0; index < num101; ++index) { float num102 = num6; float num103 = num7; float num104 = 0.05f * (float) index; float num105 = num102 + (float) Main.rand.Next(-35, 36) * num104; float num106 = num103 + (float) Main.rand.Next(-35, 36) * num104; float num107 = (float) Math.Sqrt((double) num105 * (double) num105 + (double) num106 * (double) num106); float num108 = shootSpeed / num107; float SpeedX = num105 * num108; float SpeedY = num106 * num108; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } } else if (sItem.type == 1308) { int num109 = 3; if (Main.rand.Next(3) == 0) ++num109; for (int index = 0; index < num109; ++index) { float num110 = num6; float num111 = num7; float num112 = 0.05f * (float) index; float num113 = num110 + (float) Main.rand.Next(-35, 36) * num112; float num114 = num111 + (float) Main.rand.Next(-35, 36) * num112; float num115 = (float) Math.Sqrt((double) num113 * (double) num113 + (double) num114 * (double) num114); float num116 = shootSpeed / num115; float SpeedX = num113 * num116; float SpeedY = num114 * num116; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } } else if (sItem.type == 1258) { float num117 = num6; float num118 = num7; float SpeedX = num117 + (float) Main.rand.Next(-40, 41) * 0.01f; float SpeedY = num118 + (float) Main.rand.Next(-40, 41) * 0.01f; vector2_1.X += (float) Main.rand.Next(-40, 41) * 0.05f; vector2_1.Y += (float) Main.rand.Next(-45, 36) * 0.05f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } else if (sItem.type == 964) { int num119 = Main.rand.Next(3, 5); for (int index = 0; index < num119; ++index) { float num120 = num6; float num121 = num7; float SpeedX = num120 + (float) Main.rand.Next(-35, 36) * 0.04f; float SpeedY = num121 + (float) Main.rand.Next(-35, 36) * 0.04f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } } else if (sItem.type == 1569) { int num122 = 4; if (Main.rand.Next(2) == 0) ++num122; if (Main.rand.Next(4) == 0) ++num122; if (Main.rand.Next(8) == 0) ++num122; if (Main.rand.Next(16) == 0) ++num122; for (int index = 0; index < num122; ++index) { float num123 = num6; float num124 = num7; float num125 = 0.05f * (float) index; float num126 = num123 + (float) Main.rand.Next(-35, 36) * num125; float num127 = num124 + (float) Main.rand.Next(-35, 36) * num125; float num128 = (float) Math.Sqrt((double) num126 * (double) num126 + (double) num127 * (double) num127); float num129 = shootSpeed / num128; float SpeedX = num126 * num129; float SpeedY = num127 * num129; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } } else if (sItem.type == 1572 || sItem.type == 2366 || sItem.type == 3571 || sItem.type == 3569) { int num130 = sItem.type == 3571 ? 1 : (sItem.type == 3569 ? 1 : 0); int i1 = (int) ((double) Main.mouseX + (double) Main.screenPosition.X) / 16; int j = (int) ((double) Main.mouseY + (double) Main.screenPosition.Y) / 16; if ((double) this.gravDir == -1.0) j = (int) ((double) Main.screenPosition.Y + (double) Main.screenHeight - (double) Main.mouseY) / 16; if (num130 == 0) { while (j < Main.maxTilesY - 10 && Main.tile[i1, j] != null && !WorldGen.SolidTile2(i1, j) && Main.tile[i1 - 1, j] != null && !WorldGen.SolidTile2(i1 - 1, j) && Main.tile[i1 + 1, j] != null && !WorldGen.SolidTile2(i1 + 1, j)) ++j; --j; } int index = Projectile.NewProjectile((float) Main.mouseX + Main.screenPosition.X, (float) (j * 16 - 24), 0.0f, 15f, projToShoot, Damage1, num1, i); Main.projectile[index].originalDamage = damage; this.UpdateMaxTurrets(); } else if (sItem.type == 1244 || sItem.type == 1256) { int index = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, num6, num7, projToShoot, Damage1, num1, i); Main.projectile[index].ai[0] = (float) Main.mouseX + Main.screenPosition.X; Main.projectile[index].ai[1] = (float) Main.mouseY + Main.screenPosition.Y; } else if (sItem.type == 1229) { int num131 = 2; if (Main.rand.Next(3) == 0) ++num131; for (int index13 = 0; index13 < num131; ++index13) { float SpeedX = num6; float SpeedY = num7; if (index13 > 0) { SpeedX += (float) Main.rand.Next(-35, 36) * 0.04f; SpeedY += (float) Main.rand.Next(-35, 36) * 0.04f; } if (index13 > 1) { SpeedX += (float) Main.rand.Next(-35, 36) * 0.04f; SpeedY += (float) Main.rand.Next(-35, 36) * 0.04f; } if (index13 > 2) { SpeedX += (float) Main.rand.Next(-35, 36) * 0.04f; SpeedY += (float) Main.rand.Next(-35, 36) * 0.04f; } int index14 = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); Main.projectile[index14].noDropItem = true; } } else if (sItem.type == 1121) { int num132 = Main.rand.Next(1, 4); if (Main.rand.Next(6) == 0) ++num132; if (Main.rand.Next(6) == 0) ++num132; if (this.strongBees && Main.rand.Next(3) == 0) ++num132; for (int index15 = 0; index15 < num132; ++index15) { float num133 = num6; float num134 = num7; float SpeedX = num133 + (float) Main.rand.Next(-35, 36) * 0.02f; float SpeedY = num134 + (float) Main.rand.Next(-35, 36) * 0.02f; int index16 = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, this.beeType(), this.beeDamage(Damage1), this.beeKB(num1), i); Main.projectile[index16].magic = true; } } else if (sItem.type == 1155) { int num135 = Main.rand.Next(2, 5); for (int index = 0; index < num135; ++index) { float num136 = num6; float num137 = num7; float SpeedX = num136 + (float) Main.rand.Next(-35, 36) * 0.02f; float SpeedY = num137 + (float) Main.rand.Next(-35, 36) * 0.02f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } } else if (sItem.type == 1801) { int num138 = Main.rand.Next(2, 4); for (int index = 0; index < num138; ++index) { float num139 = num6; float num140 = num7; float SpeedX = num139 + (float) Main.rand.Next(-35, 36) * 0.05f; float SpeedY = num140 + (float) Main.rand.Next(-35, 36) * 0.05f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } } else if (sItem.type == 679) { for (int index = 0; index < 6; ++index) { float num141 = num6; float num142 = num7; float SpeedX = num141 + (float) Main.rand.Next(-40, 41) * 0.05f; float SpeedY = num142 + (float) Main.rand.Next(-40, 41) * 0.05f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } } else if (sItem.type == 1156) { for (int index = 0; index < 3; ++index) { float num143 = num6; float num144 = num7; float SpeedX = num143 + (float) Main.rand.Next(-40, 41) * 0.05f; float SpeedY = num144 + (float) Main.rand.Next(-40, 41) * 0.05f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } } else if (sItem.type == 4682) { for (int index = 0; index < 3; ++index) { float num145 = num6; float num146 = num7; float SpeedX = num145 + (float) Main.rand.Next(-20, 21) * 0.1f; float SpeedY = num146 + (float) Main.rand.Next(-20, 21) * 0.1f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } } else if (sItem.type == 2623) { for (int index = 0; index < 3; ++index) { float num147 = num6; float num148 = num7; float SpeedX = num147 + (float) Main.rand.Next(-40, 41) * 0.1f; float SpeedY = num148 + (float) Main.rand.Next(-40, 41) * 0.1f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } } else if (sItem.type == 3210) { Vector2 vector2_41 = new Vector2(num6, num7); vector2_41.X += (float) Main.rand.Next(-30, 31) * 0.04f; vector2_41.Y += (float) Main.rand.Next(-30, 31) * 0.03f; vector2_41.Normalize(); vector2_41 *= (float) Main.rand.Next(70, 91) * 0.1f; vector2_41.X += (float) Main.rand.Next(-30, 31) * 0.04f; vector2_41.Y += (float) Main.rand.Next(-30, 31) * 0.03f; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, vector2_41.X, vector2_41.Y, projToShoot, Damage1, num1, i, (float) Main.rand.Next(20)); } else if (sItem.type == 434) { float SpeedX = num6; float SpeedY = num7; if (this.itemAnimation < 5) { float num149 = SpeedX + (float) Main.rand.Next(-40, 41) * 0.01f; float num150 = SpeedY + (float) Main.rand.Next(-40, 41) * 0.01f; SpeedX = num149 * 1.1f; SpeedY = num150 * 1.1f; } else if (this.itemAnimation < 10) { float num151 = SpeedX + (float) Main.rand.Next(-20, 21) * 0.01f; float num152 = SpeedY + (float) Main.rand.Next(-20, 21) * 0.01f; SpeedX = num151 * 1.05f; SpeedY = num152 * 1.05f; } Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); } else if (sItem.type == 1157) { projToShoot = Main.rand.Next(191, 195); int index = Player.SpawnMinionOnCursor(i, projToShoot, damage, num1); Main.projectile[index].localAI[0] = 30f; } else if (sItem.type == 1802) Player.SpawnMinionOnCursor(i, projToShoot, damage, num1); else if (sItem.type == 2364 || sItem.type == 2365) Player.SpawnMinionOnCursor(i, projToShoot, damage, num1); else if (sItem.type == 2535) { Vector2 vector2_42 = new Vector2(0.0f, 0.0f).RotatedBy(1.57079637050629); Player.SpawnMinionOnCursor(i, projToShoot, damage, num1, vector2_42, vector2_42); Vector2 vector2_43 = vector2_42.RotatedBy(-3.14159274101257); Player.SpawnMinionOnCursor(i, projToShoot + 1, damage, num1, vector2_43, vector2_43); } else if (sItem.type == 2551) Player.SpawnMinionOnCursor(i, projToShoot + Main.rand.Next(3), damage, num1); else if (sItem.type == 2584) Player.SpawnMinionOnCursor(i, projToShoot + Main.rand.Next(3), damage, num1); else if (sItem.type == 2621) Player.SpawnMinionOnCursor(i, projToShoot, damage, num1); else if (sItem.type == 2749 || sItem.type == 3249 || sItem.type == 3474 || sItem.type == 4273 || sItem.type == 4281) Player.SpawnMinionOnCursor(i, projToShoot, damage, num1); else if (sItem.type == 3531) { int num153 = -1; int index17 = -1; for (int index18 = 0; index18 < 1000; ++index18) { if (Main.projectile[index18].active && Main.projectile[index18].owner == Main.myPlayer) { if (num153 == -1 && Main.projectile[index18].type == 625) num153 = index18; if (index17 == -1 && Main.projectile[index18].type == 628) index17 = index18; if (num153 != -1 && index17 != -1) break; } } if (num153 == -1 && index17 == -1) { float SpeedX = 0.0f; float SpeedY = 0.0f; vector2_1.X = (float) Main.mouseX + Main.screenPosition.X; vector2_1.Y = (float) Main.mouseY + Main.screenPosition.Y; int index19 = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot, Damage1, num1, i); int index20 = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot + 1, Damage1, num1, i, (float) index19); int index21 = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot + 2, Damage1, num1, i, (float) index20); int index22 = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, projToShoot + 3, Damage1, num1, i, (float) index21); Main.projectile[index20].localAI[1] = (float) index21; Main.projectile[index21].localAI[1] = (float) index22; Main.projectile[index19].originalDamage = damage; Main.projectile[index20].originalDamage = damage; Main.projectile[index21].originalDamage = damage; Main.projectile[index22].originalDamage = damage; } else { if (num153 == -1 || index17 == -1) return; int num154 = (int) Main.projectile[index17].ai[0]; int index23 = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, num6, num7, projToShoot + 1, Damage1, num1, i, (float) num154); int index24 = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, num6, num7, projToShoot + 2, Damage1, num1, i, (float) index23); Main.projectile[index23].localAI[1] = (float) index24; Main.projectile[index23].netUpdate = true; Main.projectile[index23].ai[1] = 1f; Main.projectile[index24].localAI[1] = (float) index17; Main.projectile[index24].netUpdate = true; Main.projectile[index24].ai[1] = 1f; Main.projectile[index17].ai[0] = (float) index24; Main.projectile[index17].netUpdate = true; Main.projectile[index17].ai[1] = 1f; Main.projectile[index23].originalDamage = damage; Main.projectile[index24].originalDamage = damage; Main.projectile[index17].originalDamage = damage; } } else if (sItem.type == 1309 || sItem.type == 4758 || sItem.type == 4269 || sItem.type == 5005) Player.SpawnMinionOnCursor(i, projToShoot, damage, num1); else if (sItem.shoot > 0 && (Main.projPet[sItem.shoot] || sItem.shoot == 72 || sItem.shoot == 18 || sItem.shoot == 500 || sItem.shoot == 650) && !sItem.summon) { for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI) { if (sItem.shoot == 72) { if (Main.projectile[index].type == 72 || Main.projectile[index].type == 86 || Main.projectile[index].type == 87) Main.projectile[index].Kill(); } else if (sItem.shoot == Main.projectile[index].type) Main.projectile[index].Kill(); } } Projectile.NewProjectile(vector2_1.X, vector2_1.Y, num6, num7, projToShoot, 0, 0.0f, i); } else if (sItem.type == 3006) { Vector2 vector2_44 = Main.ReverseGravitySupport(Main.MouseScreen) + Main.screenPosition; int num155 = 0; float num156 = new Vector2(num6, num7).Length(); float num157 = (vector2_44 - vector2_1).Length(); while (Collision.CanHitLine(this.position, this.width, this.height, vector2_1, 1, 1)) { ++num155; vector2_1.X += num6; vector2_1.Y += num7; if ((double) (vector2_1 - vector2_44).Length() < 20.0 + (double) Math.Abs(num6) + (double) Math.Abs(num7)) { vector2_1 = vector2_44; break; } if ((double) num156 * (double) num155 >= (double) num157) { vector2_1 = vector2_44; break; } } Projectile.NewProjectile(vector2_1.X, vector2_1.Y, 0.0f, 0.0f, projToShoot, Damage1, num1, i); } else if (sItem.type == 3014) { Vector2 vector2_45; vector2_45.X = (float) Main.mouseX + Main.screenPosition.X; vector2_45.Y = (float) Main.mouseY + Main.screenPosition.Y; while (Collision.CanHitLine(this.position, this.width, this.height, vector2_1, 1, 1)) { vector2_1.X += num6; vector2_1.Y += num7; if ((double) (vector2_1 - vector2_45).Length() < 20.0 + (double) Math.Abs(num6) + (double) Math.Abs(num7)) { vector2_1 = vector2_45; break; } } bool flag4 = false; int j1 = (int) vector2_1.Y / 16; int i2 = (int) vector2_1.X / 16; int num158 = j1; while (j1 < Main.maxTilesY - 10 && j1 - num158 < 30 && !WorldGen.SolidTile(i2, j1) && !TileID.Sets.Platforms[(int) Main.tile[i2, j1].type]) ++j1; if (!WorldGen.SolidTile(i2, j1) && !TileID.Sets.Platforms[(int) Main.tile[i2, j1].type]) flag4 = true; float num159 = (float) (j1 * 16); int j2 = num158; while (j2 > 10 && num158 - j2 < 30 && !WorldGen.SolidTile(i2, j2)) --j2; float num160 = (float) (j2 * 16 + 16); float ai1 = num159 - num160; int num161 = 15; if ((double) ai1 > (double) (16 * num161)) ai1 = (float) (16 * num161); float ai0 = num159 - ai1; vector2_1.X = (float) ((int) ((double) vector2_1.X / 16.0) * 16); if (flag4) return; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, 0.0f, 0.0f, projToShoot, Damage1, num1, i, ai0, ai1); } else if (sItem.type == 3384) { int num162 = this.altFunctionUse == 2 ? 1 : 0; Projectile.NewProjectile(vector2_1.X, vector2_1.Y, num6, num7, projToShoot, Damage1, num1, i, ai1: ((float) num162)); } else if (sItem.type == 3473) { float ai1 = (float) (((double) Main.rand.NextFloat() - 0.5) * 0.785398185253143); Vector2 vector2_46 = new Vector2(num6, num7); Projectile.NewProjectile(vector2_1.X, vector2_1.Y, vector2_46.X, vector2_46.Y, projToShoot, Damage1, num1, i, ai1: ai1); } else if (sItem.type == 4956) { int num163 = (this.itemAnimationMax - this.itemAnimation) / this.itemTime; Vector2 velocity = new Vector2(num6, num7); int num164 = FinalFractalHelper.GetRandomProfileIndex(); if (num163 == 0) num164 = 4956; Vector2 vector2_47 = Main.MouseWorld - this.MountedCenter; if (num163 == 1 || num163 == 2) { int npcTargetIndex; bool zenithTarget = this.GetZenithTarget(Main.MouseWorld, 400f, out npcTargetIndex); if (zenithTarget) vector2_47 = Main.npc[npcTargetIndex].Center - this.MountedCenter; bool flag5 = num163 == 2; if (num163 == 1 && !zenithTarget) flag5 = true; if (flag5) vector2_47 += Main.rand.NextVector2Circular(150f, 150f); } velocity = vector2_47 / 2f; float ai0 = (float) Main.rand.Next(-100, 101); Projectile.NewProjectile(vector2_1, velocity, projToShoot, Damage1, num1, i, ai0, (float) num164); } else if (sItem.type == 3836) { float ai0 = (float) ((double) Main.rand.NextFloat() * (double) shootSpeed * 0.75) * (float) this.direction; Vector2 velocity = new Vector2(num6, num7); Projectile.NewProjectile(vector2_1, velocity, projToShoot, Damage1, num1, i, ai0); } else if (sItem.type == 3858) { int num165 = this.altFunctionUse == 2 ? 1 : 0; Vector2 velocity1 = new Vector2(num6, num7); if (num165 != 0) { Vector2 velocity2 = velocity1 * 1.5f; float ai0 = (float) ((0.300000011920929 + 0.699999988079071 * (double) Main.rand.NextFloat()) * (double) shootSpeed * 1.75) * (float) this.direction; Projectile.NewProjectile(vector2_1, velocity2, 708, (int) ((double) Damage1 * 0.75), num1 + 4f, i, ai0); } else Projectile.NewProjectile(vector2_1, velocity1, projToShoot, Damage1, num1, i); } else if (sItem.type == 3859) { Vector2 vector2_48 = new Vector2(num6, num7); projToShoot = 710; Damage1 = (int) ((double) Damage1 * 0.699999988079071); Vector2 v5 = vector2_48 * 0.8f; Vector2 vector2_49 = v5.SafeNormalize(-Vector2.UnitY); float num166 = (float) Math.PI / 180f * (float) -this.direction; for (float num167 = -2.5f; (double) num167 < 3.0; ++num167) Projectile.NewProjectile(vector2_1, (v5 + vector2_49 * num167 * 0.5f).RotatedBy((double) num167 * (double) num166), projToShoot, Damage1, num1, i); } else if (sItem.type == 3870) { Vector2 vector2_50 = Vector2.Normalize(new Vector2(num6, num7)) * 40f * sItem.scale; if (Collision.CanHit(vector2_1, 0, 0, vector2_1 + vector2_50, 0, 0)) vector2_1 += vector2_50; Vector2 v6 = new Vector2(num6, num7) * 0.8f; Vector2 vector2_51 = v6.SafeNormalize(-Vector2.UnitY); float num168 = (float) Math.PI / 180f * (float) -this.direction; for (int index = 0; index <= 2; ++index) Projectile.NewProjectile(vector2_1, (v6 + vector2_51 * (float) index * 1f).RotatedBy((double) index * (double) num168), projToShoot, Damage1, num1, i); } else if (sItem.type == 3542) { float num169 = (float) (((double) Main.rand.NextFloat() - 0.5) * 0.785398185253143 * 0.699999988079071); for (int index = 0; index < 10 && !Collision.CanHit(vector2_1, 0, 0, vector2_1 + new Vector2(num6, num7).RotatedBy((double) num169) * 100f, 0, 0); ++index) num169 = (float) (((double) Main.rand.NextFloat() - 0.5) * 0.785398185253143 * 0.699999988079071); Vector2 vector2_52 = new Vector2(num6, num7).RotatedBy((double) num169) * (float) (0.949999988079071 + (double) Main.rand.NextFloat() * 0.300000011920929); Projectile.NewProjectile(vector2_1.X, vector2_1.Y, vector2_52.X, vector2_52.Y, projToShoot, Damage1, num1, i); } else if (sItem.type == 3779) { float num170 = Main.rand.NextFloat() * 6.283185f; for (int index = 0; index < 10 && !Collision.CanHit(vector2_1, 0, 0, vector2_1 + new Vector2(num6, num7).RotatedBy((double) num170) * 100f, 0, 0); ++index) num170 = Main.rand.NextFloat() * 6.283185f; Vector2 vector2_53 = new Vector2(num6, num7).RotatedBy((double) num170) * (float) (0.949999988079071 + (double) Main.rand.NextFloat() * 0.300000011920929); Projectile.NewProjectile(vector2_1 + vector2_53 * 30f, Vector2.Zero, projToShoot, Damage1, num1, i, -2f); } else if (sItem.type == 3787) { float f3 = Main.rand.NextFloat() * 6.283185f; float num171 = 20f; float num172 = 60f; Vector2 position = vector2_1 + f3.ToRotationVector2() * MathHelper.Lerp(num171, num172, Main.rand.NextFloat()); for (int index = 0; index < 50; ++index) { position = vector2_1 + f3.ToRotationVector2() * MathHelper.Lerp(num171, num172, Main.rand.NextFloat()); if (!Collision.CanHit(vector2_1, 0, 0, position + (position - vector2_1).SafeNormalize(Vector2.UnitX) * 8f, 0, 0)) f3 = Main.rand.NextFloat() * 6.283185f; else break; } Vector2 v7 = Main.MouseWorld - position; Vector2 defaultValue = new Vector2(num6, num7).SafeNormalize(Vector2.UnitY) * shootSpeed; Vector2 velocity = Vector2.Lerp(v7.SafeNormalize(defaultValue) * shootSpeed, defaultValue, 0.25f); Projectile.NewProjectile(position, velocity, projToShoot, Damage1, num1, i); } else if (sItem.type == 3788) { Vector2 v8 = new Vector2(num6, num7); float num173 = 0.7853982f; for (int index = 0; index < 2; ++index) { Projectile.NewProjectile(vector2_1, v8 + v8.SafeNormalize(Vector2.Zero).RotatedBy((double) num173 * ((double) Main.rand.NextFloat() * 0.5 + 0.5)) * Main.rand.NextFloatDirection() * 2f, projToShoot, Damage1, num1, i); Projectile.NewProjectile(vector2_1, v8 + v8.SafeNormalize(Vector2.Zero).RotatedBy(-(double) num173 * ((double) Main.rand.NextFloat() * 0.5 + 0.5)) * Main.rand.NextFloatDirection() * 2f, projToShoot, Damage1, num1, i); } Projectile.NewProjectile(vector2_1, v8.SafeNormalize(Vector2.UnitX * (float) this.direction) * (shootSpeed * 1.3f), 661, Damage1 * 2, num1, i); } else if (sItem.type == 4463 || sItem.type == 486) Projectile.NewProjectile(vector2_1, new Vector2(num6, num7), projToShoot, Damage1, num1, i); else if (sItem.type == 3475) Projectile.NewProjectile(vector2_1.X, vector2_1.Y, num6, num7, 615, Damage1, num1, i, (float) (5 * Main.rand.Next(0, 20))); else if (sItem.type == 3930) Projectile.NewProjectile(vector2_1.X, vector2_1.Y, num6, num7, 714, Damage1, num1, i, (float) (5 * Main.rand.Next(0, 20))); else if (sItem.type == 3540) Projectile.NewProjectile(vector2_1.X, vector2_1.Y, num6, num7, 630, Damage1, num1, i); else if (sItem.type == 3854) Projectile.NewProjectile(vector2_1.X, vector2_1.Y, num6, num7, 705, Damage1, num1, i); else if (sItem.type == 3546) { for (int index = 0; index < 2; ++index) { float num174 = num6; float num175 = num7; float num176 = num174 + (float) Main.rand.Next(-40, 41) * 0.05f; float num177 = num175 + (float) Main.rand.Next(-40, 41) * 0.05f; Vector2 vector2_54 = vector2_1 + Vector2.Normalize(new Vector2(num176, num177).RotatedBy(-1.57079637050629 * (double) this.direction)) * 6f; Projectile.NewProjectile(vector2_54.X, vector2_54.Y, num176, num177, 167 + Main.rand.Next(4), Damage1, num1, i, ai1: 1f); } } else if (sItem.type == 3350) { float num178 = num6; float num179 = num7; float num180 = num178 + (float) Main.rand.Next(-1, 2) * 0.5f; float num181 = num179 + (float) Main.rand.Next(-1, 2) * 0.5f; if (Collision.CanHitLine(this.Center, 0, 0, vector2_1 + new Vector2(num180, num181) * 2f, 0, 0)) vector2_1 += new Vector2(num180, num181); Projectile.NewProjectile(vector2_1.X, vector2_1.Y - this.gravDir * 4f, num180, num181, projToShoot, Damage1, num1, i, ai1: ((float) Main.rand.Next(12) / 6f)); } else if (sItem.type == 3852) { if (this.altFunctionUse == 2) Projectile.NewProjectile(vector2_1.X, this.Bottom.Y - 100f, (float) this.direction * shootSpeed, 0.0f, 704, Damage1 * 2, num1, i); else Projectile.NewProjectile(vector2_1.X, vector2_1.Y, num6, num7, projToShoot, Damage1, num1, i); } else if (sItem.type == 3818 || sItem.type == 3819 || sItem.type == 3820 || sItem.type == 3824 || sItem.type == 3825 || sItem.type == 3826 || sItem.type == 3829 || sItem.type == 3830 || sItem.type == 3831 || sItem.type == 3832 || sItem.type == 3833 || sItem.type == 3834) { this.PayDD2CrystalsBeforeUse(sItem); int worldX; int worldY; int pushYUp; this.FindSentryRestingSpot(sItem.shoot, out worldX, out worldY, out pushYUp); int index = Projectile.NewProjectile((float) worldX, (float) (worldY - pushYUp), 0.0f, 0.0f, projToShoot, Damage1, num1, i); Main.projectile[index].originalDamage = damage; this.UpdateMaxTurrets(); } else { int index = Projectile.NewProjectile(vector2_1.X, vector2_1.Y, num6, num7, projToShoot, Damage1, num1, i); if (sItem.type == 726) Main.projectile[index].magic = true; if (sItem.type == 724 || sItem.type == 676) Main.projectile[index].melee = true; if (projToShoot == 80) { Main.projectile[index].ai[0] = (float) Player.tileTargetX; Main.projectile[index].ai[1] = (float) Player.tileTargetY; } if (sItem.type == 760) this.DestroyOldestProximityMinesOverMinesCap(20); if (projToShoot == 442) { Main.projectile[index].ai[0] = (float) Player.tileTargetX; Main.projectile[index].ai[1] = (float) Player.tileTargetY; } if (projToShoot == 826) Main.projectile[index].ai[1] = (float) Main.rand.Next(3); if (sItem.type == 949) Main.projectile[index].ai[1] = 1f; if (Main.projectile[index].aiStyle != 99) return; AchievementsHelper.HandleSpecialEvent(this, 7); } } else { if (sItem.useStyle != 5 && sItem.useStyle != 13) return; this.itemRotation = 0.0f; NetMessage.SendData(41, number: this.whoAmI); } } private static int SpawnMinionOnCursor( int ownerIndex, int minionProjectileId, int originalDamageNotScaledByMinionDamage, float KnockBack, Vector2 offsetFromCursor = default (Vector2), Vector2 velocityOnSpawn = default (Vector2)) { int index = Projectile.NewProjectile(Main.MouseWorld + offsetFromCursor, velocityOnSpawn, minionProjectileId, originalDamageNotScaledByMinionDamage, KnockBack, ownerIndex); Main.projectile[index].originalDamage = originalDamageNotScaledByMinionDamage; return index; } private Point FindSharpTearsSpot(Vector2 targetSpot) { targetSpot.ToTileCoordinates(); Vector2 center = this.Center; Vector2 endPoint = targetSpot; int samplesToTake = 3; float samplingWidth = 4f; Vector2 vectorTowardsTarget; float[] samples; Collision.AimingLaserScan(center, endPoint, samplingWidth, samplesToTake, out vectorTowardsTarget, out samples); float num = float.PositiveInfinity; for (int index = 0; index < samples.Length; ++index) { if ((double) samples[index] < (double) num) num = samples[index]; } targetSpot = center + vectorTowardsTarget.SafeNormalize(Vector2.Zero) * num; Point tileCoordinates = targetSpot.ToTileCoordinates(); Microsoft.Xna.Framework.Rectangle rectangle1 = new Microsoft.Xna.Framework.Rectangle(tileCoordinates.X, tileCoordinates.Y, 1, 1); rectangle1.Inflate(6, 16); Microsoft.Xna.Framework.Rectangle rectangle2 = new Microsoft.Xna.Framework.Rectangle(0, 0, Main.maxTilesX, Main.maxTilesY); rectangle2.Inflate(-Main.Map.BlackEdgeWidth, -Main.Map.BlackEdgeWidth); rectangle1 = Microsoft.Xna.Framework.Rectangle.Intersect(rectangle1, rectangle2); List pointList1 = new List(); List pointList2 = new List(); for (int left = rectangle1.Left; left <= rectangle1.Right; ++left) { for (int top = rectangle1.Top; top <= rectangle1.Bottom; ++top) { if (WorldGen.SolidTile(left, top)) { Vector2 vector2 = new Vector2((float) (left * 16 + 8), (float) (top * 16 + 8)); if ((double) Vector2.Distance(targetSpot, vector2) <= 200.0) { if (this.FindSharpTearsOpening(left, top, left > tileCoordinates.X, left < tileCoordinates.X, top > tileCoordinates.Y, top < tileCoordinates.Y)) pointList1.Add(new Point(left, top)); else pointList2.Add(new Point(left, top)); } } } } if (pointList1.Count == 0 && pointList2.Count == 0) pointList1.Add((this.Center.ToTileCoordinates().ToVector2() + Main.rand.NextVector2Square(-2f, 2f)).ToPoint()); List pointList3 = pointList1; if (pointList3.Count == 0) pointList3 = pointList2; int index1 = Main.rand.Next(pointList3.Count); return pointList3[index1]; } private bool FindSharpTearsOpening( int x, int y, bool acceptLeft, bool acceptRight, bool acceptUp, bool acceptDown) { return acceptLeft && !WorldGen.SolidTile(x - 1, y) || acceptRight && !WorldGen.SolidTile(x + 1, y) || acceptUp && !WorldGen.SolidTile(x, y - 1) || acceptDown && !WorldGen.SolidTile(x, y + 1); } public bool TryPlacingAGolfBallNearANearbyTee(Vector2 placePosition) { int num1 = 0; int num2 = (int) ((double) placePosition.X / 16.0) - Player.tileRangeX - num1 + 1; int num3 = (int) ((double) placePosition.X / 16.0) + Player.tileRangeX + num1 - 1; int num4 = (int) ((double) placePosition.Y / 16.0) - Player.tileRangeY - num1 + 1; int num5 = (int) ((double) placePosition.Y / 16.0) + Player.tileRangeY + num1 - 2; int lx = Utils.Clamp(num2, 10, Main.maxTilesX - 10); int hx = Utils.Clamp(num3, 10, Main.maxTilesX - 10); int ly = Utils.Clamp(num4, 10, Main.maxTilesY - 10); int hy = Utils.Clamp(num5, 10, Main.maxTilesY - 10); Vector2 vector2 = Main.screenPosition + new Vector2((float) Main.mouseX, (float) Main.mouseY); if ((double) this.gravDir == -1.0) vector2.Y = Main.screenPosition.Y + (float) Main.screenHeight - (float) Main.mouseY; Point tileCoordinates = placePosition.ToTileCoordinates(); List> tupleList = new List>(); for (int index1 = -2; index1 <= 2; ++index1) { for (int index2 = -2; index2 <= 2; ++index2) { int num6 = tileCoordinates.X + index1; int num7 = tileCoordinates.Y + index2; if (WorldGen.InWorld(num6, num7, 1)) { Tile tileSafely = Framing.GetTileSafely(num6, num7); if (tileSafely.active() && tileSafely.type == (ushort) 494) { tupleList.Add(new Tuple(num6, num7)); break; } } } } bool flag = false; if (tupleList.Count > 0) { float num8 = -1f; Tuple tuple = tupleList[0]; for (int index = 0; index < tupleList.Count; ++index) { float num9 = Vector2.Distance(new Vector2((float) tupleList[index].Item1, (float) tupleList[index].Item2) * 16f + Vector2.One * 8f, vector2); if ((double) num8 == -1.0 || (double) num9 < (double) num8) { num8 = num9; tuple = tupleList[index]; } } if (Collision.InTileBounds(tuple.Item1, tuple.Item2, lx, ly, hx, hy)) { flag = true; for (int index = 0; index < 1000; ++index) { if (ProjectileID.Sets.IsAGolfBall[Main.projectile[index].type] && Main.projectile[index].owner == this.whoAmI) Main.projectile[index].Kill(); } int projType; this.GetPreferredGolfBallToUse(out projType); Projectile.NewProjectile((float) (tuple.Item1 * 16) + 8.5f, (float) (tuple.Item2 * 16 + 6), 0.0f, 0.0f, projType, 0, 0.0f, this.whoAmI, ai1: -1f); } } return flag; } public void GetPreferredGolfBallToUse(out int projType) { projType = 721; Item obj1 = this.inventory[this.selectedItem]; if (!obj1.IsAir && obj1.shoot > 0 && ProjectileID.Sets.IsAGolfBall[obj1.shoot]) { projType = obj1.shoot; } else { for (int slot = 19; slot >= 0; --slot) { if (this.IsAValidEquipmentSlotForIteration(slot)) { int num = slot % 10; Item obj2 = this.armor[slot]; if (!obj2.IsAir && obj2.shoot > 0 && ProjectileID.Sets.IsAGolfBall[obj2.shoot]) { projType = obj2.shoot; return; } } } for (int index = 0; index < 50; ++index) { Item obj3 = this.inventory[index]; if (!obj3.IsAir && obj3.shoot > 0 && ProjectileID.Sets.IsAGolfBall[obj3.shoot]) { projType = obj3.shoot; break; } } } } private void ItemCheck_MinionAltFeatureUse(Item sItem, bool cShoot) { if (sItem.shoot <= 0 || !ProjectileID.Sets.MinionTargettingFeature[sItem.shoot] || this.altFunctionUse != 2 || !cShoot || !this.ItemTimeIsZero) return; this.ApplyItemTime(sItem); this.MinionNPCTargetAim(false); } private void ItemCheck_TurretAltFeatureUse(Item sItem, bool cShoot) { if (sItem.shoot <= 0 || !ProjectileID.Sets.TurretFeature[sItem.shoot] || this.altFunctionUse != 2 || !cShoot || !this.ItemTimeIsZero) return; this.ApplyItemTime(sItem); for (int index = 0; index < 1000; ++index) { Projectile projectile = Main.projectile[index]; if (projectile.active && projectile.owner == Main.myPlayer && ProjectileID.Sets.TurretFeature[projectile.type]) projectile.Kill(); } } private void EmitMaxManaEffect() { SoundEngine.PlaySound(25); for (int index1 = 0; index1 < 5; ++index1) { int index2 = Dust.NewDust(this.position, this.width, this.height, 45, Alpha: ((int) byte.MaxValue), Scale: ((float) Main.rand.Next(20, 26) * 0.1f)); Main.dust[index2].noLight = true; Main.dust[index2].noGravity = true; Main.dust[index2].velocity *= 0.5f; } } private void ItemCheck_EmitHeldItemLight(Item sItem) { if ((ItemID.Sets.Torches[sItem.type] && !this.wet || ItemID.Sets.WaterTorches[sItem.type]) && !this.pulley && !this.happyFunTorchTime) { float R = 1f; float G = 0.95f; float B = 0.8f; int torchID = 0; int num = this.BiomeTorchHoldStyle(sItem.type); if (num == 523) torchID = 8; else if (num == 974) torchID = 9; else if (num == 1245) torchID = 10; else if (num == 1333) torchID = 11; else if (num == 2274) torchID = 12; else if (num == 3004) torchID = 13; else if (num == 3045) torchID = 14; else if (num == 3114) torchID = 15; else if (num == 4383) torchID = 16; else if (num == 4384) torchID = 17; else if (num == 4385) torchID = 18; else if (num == 4386) torchID = 19; else if (num == 4387) torchID = 20; else if (num == 4388) torchID = 21; else if (num >= 427) torchID = num - 426; TorchID.TorchColor(torchID, out R, out G, out B); int Type = TorchID.Dust[torchID]; int maxValue = 30; if (this.itemAnimation > 0) maxValue = 7; if (this.direction == -1) { if (Main.rand.Next(maxValue) == 0) { int index = Dust.NewDust(new Vector2(this.itemLocation.X - 16f, this.itemLocation.Y - 14f * this.gravDir), 4, 4, Type, Alpha: 100); if (Main.rand.Next(3) != 0) Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.3f; Main.dust[index].velocity.Y -= 1.5f; Main.dust[index].position = this.RotatedRelativePoint(Main.dust[index].position); if (Type == 66) { Main.dust[index].color = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); Main.dust[index].noGravity = true; } } Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X - 12f + this.velocity.X, this.itemLocation.Y - 14f + this.velocity.Y)), R, G, B); } else { if (Main.rand.Next(maxValue) == 0) { int index = Dust.NewDust(new Vector2(this.itemLocation.X + 6f, this.itemLocation.Y - 14f * this.gravDir), 4, 4, Type, Alpha: 100); if (Main.rand.Next(3) != 0) Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.3f; Main.dust[index].velocity.Y -= 1.5f; Main.dust[index].position = this.RotatedRelativePoint(Main.dust[index].position); if (Type == 66) { Main.dust[index].color = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); Main.dust[index].noGravity = true; } } Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X + 12f + this.velocity.X, this.itemLocation.Y - 14f + this.velocity.Y)), R, G, B); } } if ((sItem.type == 105 || sItem.type == 713) && !this.wet && !this.pulley) { int maxValue = 20; if (this.itemAnimation > 0) maxValue = 7; if (this.direction == -1) { if (Main.rand.Next(maxValue) == 0) { int index = Dust.NewDust(new Vector2(this.itemLocation.X - 12f, this.itemLocation.Y - 20f * this.gravDir), 4, 4, 6, Alpha: 100); if (Main.rand.Next(3) != 0) Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.3f; Main.dust[index].velocity.Y -= 1.5f; Main.dust[index].position = this.RotatedRelativePoint(Main.dust[index].position); } Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X - 16f + this.velocity.X, this.itemLocation.Y - 14f)), 1f, 0.95f, 0.8f); } else { if (Main.rand.Next(maxValue) == 0) { int index = Dust.NewDust(new Vector2(this.itemLocation.X + 4f, this.itemLocation.Y - 20f * this.gravDir), 4, 4, 6, Alpha: 100); if (Main.rand.Next(3) != 0) Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.3f; Main.dust[index].velocity.Y -= 1.5f; Main.dust[index].position = this.RotatedRelativePoint(Main.dust[index].position); } Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X + 6f + this.velocity.X, this.itemLocation.Y - 14f)), 1f, 0.95f, 0.8f); } } else if (sItem.type == 148 && !this.wet) { int maxValue = 10; if (this.itemAnimation > 0) maxValue = 7; if (this.direction == -1) { if (Main.rand.Next(maxValue) == 0) { int index = Dust.NewDust(new Vector2(this.itemLocation.X - 12f, this.itemLocation.Y - 20f * this.gravDir), 4, 4, 172, Alpha: 100); if (Main.rand.Next(3) != 0) Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.3f; Main.dust[index].velocity.Y -= 1.5f; Main.dust[index].position = this.RotatedRelativePoint(Main.dust[index].position); } Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X - 16f + this.velocity.X, this.itemLocation.Y - 14f)), 0.0f, 0.5f, 1f); } else { if (Main.rand.Next(maxValue) == 0) { int index = Dust.NewDust(new Vector2(this.itemLocation.X + 4f, this.itemLocation.Y - 20f * this.gravDir), 4, 4, 172, Alpha: 100); if (Main.rand.Next(3) != 0) Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.3f; Main.dust[index].velocity.Y -= 1.5f; Main.dust[index].position = this.RotatedRelativePoint(Main.dust[index].position); } Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X + 6f + this.velocity.X, this.itemLocation.Y - 14f)), 0.0f, 0.5f, 1f); } } else if (sItem.type == 3117 && !this.wet) { this.itemLocation.X -= (float) (this.direction * 4); int maxValue = 10; if (this.itemAnimation > 0) maxValue = 7; if (this.direction == -1) { if (Main.rand.Next(maxValue) == 0) { int index = Dust.NewDust(new Vector2(this.itemLocation.X - 10f, this.itemLocation.Y - 20f * this.gravDir), 4, 4, 242, Alpha: 100); if (Main.rand.Next(3) != 0) Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.3f; Main.dust[index].velocity.Y -= 1.5f; Main.dust[index].position = this.RotatedRelativePoint(Main.dust[index].position); } Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X - 16f + this.velocity.X, this.itemLocation.Y - 14f)), 0.9f, 0.1f, 0.75f); } else { if (Main.rand.Next(maxValue) == 0) { int index = Dust.NewDust(new Vector2(this.itemLocation.X + 6f, this.itemLocation.Y - 20f * this.gravDir), 4, 4, 242, Alpha: 100); if (Main.rand.Next(3) != 0) Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.3f; Main.dust[index].velocity.Y -= 1.5f; Main.dust[index].position = this.RotatedRelativePoint(Main.dust[index].position); } Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X + 6f + this.velocity.X, this.itemLocation.Y - 14f)), 0.9f, 0.1f, 0.75f); } } if (sItem.type == 282 && !this.pulley) { if (this.direction == -1) Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X - 16f + this.velocity.X, this.itemLocation.Y - 14f)), 0.7f, 1f, 0.8f); else Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X + 6f + this.velocity.X, this.itemLocation.Y - 14f)), 0.7f, 1f, 0.8f); } if (sItem.type == 3002 && !this.pulley) { float r = 1.05f; float g = 0.95f; float b = 0.55f; if (this.direction == -1) Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X - 16f + this.velocity.X, this.itemLocation.Y - 14f)), r, g, b); else Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X + 6f + this.velocity.X, this.itemLocation.Y - 14f)), r, g, b); ++this.spelunkerTimer; if (this.spelunkerTimer >= (byte) 10) { this.spelunkerTimer = (byte) 0; Main.instance.SpelunkerProjectileHelper.AddSpotToCheck(this.Center); } } if (sItem.type == 286 && !this.pulley) { if (this.direction == -1) Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X - 16f + this.velocity.X, this.itemLocation.Y - 14f)), 0.7f, 0.8f, 1f); else Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X + 6f + this.velocity.X, this.itemLocation.Y - 14f)), 0.7f, 0.8f, 1f); } if (sItem.type == 3112 && !this.pulley) { if (this.direction == -1) Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X - 16f + this.velocity.X, this.itemLocation.Y - 14f)), 1f, 0.6f, 0.85f); else Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X + 6f + this.velocity.X, this.itemLocation.Y - 14f)), 1f, 0.6f, 0.85f); } if (sItem.type == 4776 && !this.pulley) { if (this.direction == -1) Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X - 16f + this.velocity.X, this.itemLocation.Y - 14f)), 0.7f, 0.0f, 1f); else Lighting.AddLight(this.RotatedRelativePoint(new Vector2(this.itemLocation.X + 6f + this.velocity.X, this.itemLocation.Y - 14f)), 0.7f, 0.0f, 1f); } if (sItem.type == 3542) { Vector2 vector2_1 = Main.OffsetsPlayerOnhand[this.bodyFrame.Y / 56] * 2f; if (this.direction != 1) vector2_1.X = (float) this.bodyFrame.Width - vector2_1.X; if ((double) this.gravDir != 1.0) vector2_1.Y = (float) this.bodyFrame.Height - vector2_1.Y; Vector2 vector2_2 = this.RotatedRelativePoint(this.MountedCenter - new Vector2(20f, 42f) / 2f + (vector2_1 - new Vector2((float) (this.bodyFrame.Width - this.width), (float) (this.bodyFrame.Height - 42)) / 2f)) - this.velocity; for (int index = 0; index < 4; ++index) { Dust dust = Main.dust[Dust.NewDust(this.Center, 0, 0, 242, (float) (this.direction * 2), Alpha: 150, Scale: 1.3f)]; dust.position = vector2_2; dust.velocity *= 0.0f; dust.noGravity = true; dust.fadeIn = 1f; dust.velocity += this.velocity; if (Main.rand.Next(2) == 0) { dust.position += Utils.RandomVector2(Main.rand, -4f, 4f); dust.scale += Main.rand.NextFloat(); if (Main.rand.Next(2) == 0) dust.customData = (object) this; } } } if (sItem.type != 4952 || this.pulley) return; Vector2 pos = this.itemLocation + new Vector2((float) (8 * this.direction), -10f * this.gravDir); Vector3 rgb = new Vector3(1f, 0.7f, 0.8f) * 1.3f; Vector2 vector2_3 = this.RotatedRelativePoint(pos); Lighting.AddLight(vector2_3, rgb); if (Main.rand.Next(40) != 0) return; Vector2 vector2_4 = Main.rand.NextVector2Circular(4f, 4f); Dust dust1 = Dust.NewDustPerfect(vector2_3 + vector2_4, 43, new Vector2?(Vector2.Zero), 254, new Color((int) byte.MaxValue, (int) byte.MaxValue, 0, (int) byte.MaxValue), 0.3f); if (vector2_4 != Vector2.Zero) dust1.velocity = vector2_3.DirectionTo(dust1.position) * 0.2f; dust1.fadeIn = 0.3f; dust1.noLightEmittence = true; dust1.customData = (object) this; } public bool CanVisuallyHoldItem(Item item) => item.holdStyle != 4 || !this.pulley && (double) this.gravDir != -1.0 && (double) this.velocity.Y == 0.0 && !this.mount.Active; private void ItemCheck_ApplyHoldStyle(float mountOffset, Item sItem, Microsoft.Xna.Framework.Rectangle heldItemFrame) { if (!this.CanVisuallyHoldItem(sItem)) return; if (this.isPettingAnimal) { int num1 = this.miscCounter % 14 / 7; Player.CompositeArmStretchAmount stretch = Player.CompositeArmStretchAmount.ThreeQuarters; if (num1 == 1) stretch = Player.CompositeArmStretchAmount.Full; float num2 = 0.3f; if (this.isTheAnimalBeingPetSmall) num2 = 0.2f; this.SetCompositeArmBack(true, stretch, -6.283185f * num2 * (float) this.direction); } else if (sItem.holdStyle == 1 && !this.pulley) { if (Main.dedServ) this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 + 20.0 * (double) this.direction); else if (sItem.type == 930) { this.itemLocation.X = (float) ((double) this.position.X + (double) (this.width / 2) * 0.5 - 12.0) - (float) (2 * this.direction); float x = this.position.X + (float) (this.width / 2) + (float) (38 * this.direction); if (this.direction == 1) x -= 10f; float y = this.MountedCenter.Y - 4f * this.gravDir; if ((double) this.gravDir == -1.0) y -= 8f; this.RotateRelativePoint(ref x, ref y); int Type = 0; for (int index = 54; index < 58; ++index) { if (this.inventory[index].stack > 0 && this.inventory[index].ammo == 931) { Type = this.inventory[index].type; break; } } if (Type == 0) { for (int index = 0; index < 54; ++index) { if (this.inventory[index].stack > 0 && this.inventory[index].ammo == 931) { Type = this.inventory[index].type; break; } } } if (Type == 931) Type = (int) sbyte.MaxValue; else if (Type == 1614) Type = 187; if (Type > 0) { int index = Dust.NewDust(new Vector2(x, y + this.gfxOffY), 6, 6, Type, Alpha: 100, Scale: 1.6f); Main.dust[index].noGravity = true; Main.dust[index].velocity.Y -= 4f * this.gravDir; } } else if (sItem.type == 968) { this.itemLocation.X = this.position.X + (float) this.width * 0.5f + (float) (8 * this.direction); if (this.whoAmI == Main.myPlayer) { int index1 = (int) ((double) this.itemLocation.X + (double) heldItemFrame.Width * 0.800000011920929 * (double) this.direction) / 16; int index2 = (int) ((double) this.itemLocation.Y + (double) mountOffset + (double) (heldItemFrame.Height / 2)) / 16; if (Main.tile[index1, index2] == null) Main.tile[index1, index2] = new Tile(); if (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 215 && Main.tile[index1, index2].frameY < (short) 54) { ++this.miscTimer; if (Main.rand.Next(5) == 0) ++this.miscTimer; if (this.miscTimer > 900) { this.miscTimer = 0; sItem.SetDefaults(969); if (this.selectedItem == 58) Main.mouseItem.SetDefaults(969); for (int index3 = 0; index3 < 58; ++index3) { if (this.inventory[index3].type == sItem.type && index3 != this.selectedItem && this.inventory[index3].stack < this.inventory[index3].maxStack) { SoundEngine.PlaySound(7); ++this.inventory[index3].stack; sItem.SetDefaults(); if (this.selectedItem == 58) Main.mouseItem.SetDefaults(); } } } } else this.miscTimer = 0; } } else if (sItem.type == 856) this.itemLocation.X = this.position.X + (float) this.width * 0.5f + (float) (4 * this.direction); else if (sItem.fishingPole > 0) { this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 + (double) heldItemFrame.Width * 0.180000007152557 * (double) this.direction); } else { this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 + ((double) heldItemFrame.Width * 0.5 + 2.0) * (double) this.direction); if (sItem.type == 282 || sItem.type == 286 || sItem.type == 3112 || sItem.type == 4776) { this.itemLocation.X -= (float) (this.direction * 2); this.itemLocation.Y += 4f; } else if (sItem.type == 3002) { this.itemLocation.X -= (float) (4 * this.direction); this.itemLocation.Y += 2f; } } this.itemLocation.Y = this.position.Y + 24f + mountOffset; if (sItem.type == 856) this.itemLocation.Y = this.position.Y + 34f + mountOffset; if (sItem.type == 930) this.itemLocation.Y = this.position.Y + 9f + mountOffset; if (sItem.fishingPole > 0) this.itemLocation.Y += 4f; else if (sItem.type == 3476) { this.itemLocation.X = this.Center.X + (float) (14 * this.direction); this.itemLocation.Y = this.MountedCenter.Y; } else if (sItem.type == 3779) { this.itemLocation.X = this.Center.X + (float) (6 * this.direction); this.itemLocation.Y = this.MountedCenter.Y + 6f; } else if (sItem.type == 4952) { this.itemLocation.X = this.Center.X + (float) (2 * this.direction); this.itemLocation.Y = this.MountedCenter.Y + 26f; } else if (sItem.type == 353) { this.itemLocation.X = this.Center.X + (float) (6 * this.direction); this.itemLocation.Y = this.MountedCenter.Y + 11f; } else if (ItemID.Sets.IsFood[sItem.type]) { this.itemLocation.X = this.Center.X + (float) (4 * this.direction); this.itemLocation.Y = this.MountedCenter.Y + (float) (heldItemFrame.Height / 2); } else if (sItem.type == 4049 && Main.rand.Next(4) == 0) { Dust dust = Dust.NewDustPerfect(this.Center + new Vector2((float) (this.direction * 23), this.gravDir * 6f), 31, new Vector2?(Vector2.Zero), (int) sbyte.MaxValue, Scale: 0.7f); dust.noGravity = true; dust.velocity = Main.rand.NextVector2Circular(1f, 1f) + new Vector2(0.0f, -1f); } this.itemRotation = 0.0f; if ((double) this.gravDir != -1.0) return; this.itemRotation = -this.itemRotation; this.itemLocation.Y = (float) ((double) this.position.Y + (double) this.height + ((double) this.position.Y - (double) this.itemLocation.Y)) + mountOffset; if (sItem.type != 930) return; this.itemLocation.Y -= 24f; } else if (sItem.holdStyle == 2 && !this.pulley) { if (sItem.type == 946 || sItem.type == 4707) { this.itemRotation = 0.0f; this.itemLocation.X = this.position.X + (float) this.width * 0.5f - (float) (16 * this.direction); this.itemLocation.Y = this.position.Y + 22f + mountOffset; this.fallStart = (int) ((double) this.position.Y / 16.0); if ((double) this.gravDir == -1.0) { this.itemRotation = -this.itemRotation; this.itemLocation.Y = (float) ((double) this.position.Y + (double) this.height + ((double) this.position.Y - (double) this.itemLocation.Y)); if ((double) this.velocity.Y >= -2.0 || this.controlDown) return; this.velocity.Y = -2f; } else { if ((double) this.velocity.Y <= 2.0 || this.controlDown) return; this.velocity.Y = 2f; } } else { this.itemLocation.X = this.position.X + (float) this.width * 0.5f + (float) (6 * this.direction); this.itemLocation.Y = this.position.Y + 16f + mountOffset; this.itemRotation = 0.79f * (float) -this.direction; if ((double) this.gravDir != -1.0) return; this.itemRotation = -this.itemRotation; this.itemLocation.Y = (float) ((double) this.position.Y + (double) this.height + ((double) this.position.Y - (double) this.itemLocation.Y)); } } else if (sItem.holdStyle == 3 && !this.pulley) { if (Main.dedServ) return; this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 - (double) heldItemFrame.Width * 0.5) - (float) (this.direction * 2); this.itemLocation.Y = this.MountedCenter.Y - (float) heldItemFrame.Height * 0.5f; this.itemRotation = 0.0f; } else if (sItem.holdStyle == 4) { if (Main.dedServ) return; this.itemRotation = new Vector2((float) (10 * this.direction), 10f).ToRotation() + 0.7853982f; if (this.direction == -1) this.itemRotation += 1.570796f; Player.CompositeArmStretchAmount stretch1 = Player.CompositeArmStretchAmount.Full; Player.CompositeArmStretchAmount stretch2 = Player.CompositeArmStretchAmount.ThreeQuarters; float num3 = -0.3141593f; if (this.direction == -1) num3 *= -1f; float num4 = (float) ((double) this.itemRotation - 0.785398185253143 + 3.14159274101257); if (this.direction == 1) num4 += 1.570796f; float rotation1 = num4 + num3; float rotation2 = num4 - num3; Vector2 vector2 = (num4 + 1.570796f).ToRotationVector2() * 2f; this.itemLocation = this.MountedCenter.Floor() + vector2; this.SetCompositeArmFront(true, stretch1, rotation1); this.SetCompositeArmBack(true, stretch2, rotation2); this.FlipItemLocationAndRotationForGravity(); } else if (sItem.holdStyle == 5 && !this.pulley) { if (Main.dedServ) return; this.itemRotation = 0.0f; this.itemLocation.X = this.Center.X - (float) (8 * this.direction); this.itemLocation.Y = this.position.Y + 40f + mountOffset; this.itemLocation += Main.OffsetsPlayerHeadgear[this.bodyFrame.Y / 56]; this.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Quarter, -0.7853982f * (float) this.direction); this.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, -0.3926991f * (float) this.direction); this.FlipItemLocationAndRotationForGravity(); } else { if (sItem.holdStyle != 6 || this.pulley || Main.dedServ) return; this.itemRotation = 0.0f; this.itemLocation.X = this.Center.X + (float) (8 * this.direction); this.itemLocation.Y = (float) ((double) this.position.Y + 40.0 + (double) mountOffset - 2.0); this.itemLocation += Main.OffsetsPlayerHeadgear[this.bodyFrame.Y / 56]; this.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.ThreeQuarters, -1.884956f * (float) this.direction); this.FlipItemLocationAndRotationForGravity(); } } private void ItemCheck_ApplyManaRegenDelay(Item sItem) { if (this.spaceGun && (sItem.type == (int) sbyte.MaxValue || sItem.type == 4347 || sItem.type == 4348)) return; this.manaRegenDelay = (int) this.maxRegenDelay; } private Vector2 GetFrontHandPosition( Player.CompositeArmStretchAmount stretch, float rotation) { float num = rotation + 1.570796f; Vector2 vector2 = new Vector2((float) Math.Cos((double) num), (float) Math.Sin((double) num)); switch (stretch) { case Player.CompositeArmStretchAmount.Full: vector2 *= 10f; break; case Player.CompositeArmStretchAmount.None: vector2 *= 4f; break; case Player.CompositeArmStretchAmount.Quarter: vector2 *= 6f; break; case Player.CompositeArmStretchAmount.ThreeQuarters: vector2 *= 8f; break; } return this.MountedCenter + (this.direction != -1 ? vector2 + new Vector2(-4f, -2f) + new Vector2(0.0f, 3f).RotatedBy((double) rotation + 1.57079637050629) : vector2 + new Vector2(4f, -2f) + new Vector2(0.0f, -3f).RotatedBy((double) rotation + 1.57079637050629)); } private Vector2 GetBackHandPosition( Player.CompositeArmStretchAmount stretch, float rotation) { float num = rotation + 1.570796f; Vector2 vector2 = new Vector2((float) Math.Cos((double) num), (float) Math.Sin((double) num)); switch (stretch) { case Player.CompositeArmStretchAmount.Full: vector2 *= new Vector2(10f, 12f); break; case Player.CompositeArmStretchAmount.None: vector2 *= new Vector2(4f, 6f); break; case Player.CompositeArmStretchAmount.Quarter: vector2 *= new Vector2(6f, 8f); break; case Player.CompositeArmStretchAmount.ThreeQuarters: vector2 *= new Vector2(8f, 10f); break; } return this.MountedCenter + (this.direction != -1 ? vector2 + new Vector2(6f, -2f) : vector2 + new Vector2(-6f, -2f)); } public void ItemCheck_ApplyUseStyle(float mountOffset, Item sItem, Microsoft.Xna.Framework.Rectangle heldItemFrame) { if (Main.dedServ) return; if (sItem.useStyle == 1) { if (sItem.type > -1 && Item.claw[sItem.type]) { if ((double) this.itemAnimation < (double) this.itemAnimationMax * 0.333) { float num = 10f; this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 + ((double) heldItemFrame.Width * 0.5 - (double) num) * (double) this.direction); this.itemLocation.Y = this.position.Y + 26f + mountOffset; } else if ((double) this.itemAnimation < (double) this.itemAnimationMax * 0.666) { float num = 8f; this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 + ((double) heldItemFrame.Width * 0.5 - (double) num) * (double) this.direction); this.itemLocation.Y = this.position.Y + 24f + mountOffset; } else { float num = 6f; this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 - ((double) heldItemFrame.Width * 0.5 - (double) num) * (double) this.direction); this.itemLocation.Y = this.position.Y + 20f + mountOffset; } this.itemRotation = (float) (((double) this.itemAnimation / (double) this.itemAnimationMax - 0.5) * (double) -this.direction * 3.5 - (double) this.direction * 0.300000011920929); } else { if ((double) this.itemAnimation < (double) this.itemAnimationMax * 0.333) { float num = 10f; if (heldItemFrame.Width > 32) num = 14f; if (heldItemFrame.Width >= 52) num = 24f; if (heldItemFrame.Width >= 64) num = 28f; if (heldItemFrame.Width >= 92) num = 38f; if (sItem.type == 2330 || sItem.type == 2320 || sItem.type == 2341) num += 8f; if (sItem.type == 671) num += 12f; this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 + ((double) heldItemFrame.Width * 0.5 - (double) num) * (double) this.direction); this.itemLocation.Y = this.position.Y + 24f + mountOffset; } else if ((double) this.itemAnimation < (double) this.itemAnimationMax * 0.666) { float num1 = 10f; if (heldItemFrame.Width > 32) num1 = 18f; if (heldItemFrame.Width >= 52) num1 = 24f; if (heldItemFrame.Width >= 64) num1 = 28f; if (heldItemFrame.Width >= 92) num1 = 38f; if (sItem.type == 2330 || sItem.type == 2320 || sItem.type == 2341) num1 += 4f; if (sItem.type == 671) num1 += 6f; this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 + ((double) heldItemFrame.Width * 0.5 - (double) num1) * (double) this.direction); float num2 = 10f; if (heldItemFrame.Height > 32) num2 = 8f; if (heldItemFrame.Height > 52) num2 = 12f; if (heldItemFrame.Height > 64) num2 = 14f; if (sItem.type == 2330 || sItem.type == 2320 || sItem.type == 2341) num2 += 4f; if (sItem.type == 671) num2 += 10f; this.itemLocation.Y = this.position.Y + num2 + mountOffset; } else { float num3 = 6f; if (heldItemFrame.Width > 32) num3 = 14f; if (heldItemFrame.Width >= 48) num3 = 18f; if (heldItemFrame.Width >= 52) num3 = 24f; if (heldItemFrame.Width >= 64) num3 = 28f; if (heldItemFrame.Width >= 92) num3 = 38f; if (sItem.type == 2330 || sItem.type == 2320 || sItem.type == 2341) num3 += 4f; if (sItem.type == 671) num3 += 8f; this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 - ((double) heldItemFrame.Width * 0.5 - (double) num3) * (double) this.direction); float num4 = 10f; if (heldItemFrame.Height > 32) num4 = 10f; if (heldItemFrame.Height > 52) num4 = 12f; if (heldItemFrame.Height > 64) num4 = 14f; if (sItem.type == 2330 || sItem.type == 2320 || sItem.type == 2341) num4 += 4f; if (sItem.type == 671) num4 += 8f; this.itemLocation.Y = this.position.Y + num4 + mountOffset; } this.itemRotation = (float) (((double) this.itemAnimation / (double) this.itemAnimationMax - 0.5) * (double) -this.direction * 3.5 - (double) this.direction * 0.300000011920929); } if ((double) this.gravDir != -1.0) return; this.itemRotation = -this.itemRotation; this.itemLocation.Y = (float) ((double) this.position.Y + (double) this.height + ((double) this.position.Y - (double) this.itemLocation.Y)); } else if (sItem.useStyle == 7) { this.itemRotation = (float) ((double) this.itemAnimation / (double) this.itemAnimationMax * (double) this.direction * 2.0 + -1.39999997615814 * (double) this.direction); if ((double) this.itemAnimation < (double) this.itemAnimationMax * 0.5) { this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 + ((double) heldItemFrame.Width * 0.5 - 9.0 - (double) this.itemRotation * 12.0 * (double) this.direction) * (double) this.direction); this.itemLocation.Y = (float) ((double) this.position.Y + 38.0 + (double) this.itemRotation * (double) this.direction * 4.0) + mountOffset; } else { this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 + ((double) heldItemFrame.Width * 0.5 - 9.0 - (double) this.itemRotation * 16.0 * (double) this.direction) * (double) this.direction); this.itemLocation.Y = (float) ((double) this.position.Y + 38.0 + (double) this.itemRotation * (double) this.direction) + mountOffset; } if ((double) this.gravDir != -1.0) return; this.itemRotation = -this.itemRotation; this.itemLocation.Y = (float) ((double) this.position.Y + (double) this.height + ((double) this.position.Y - (double) this.itemLocation.Y)); } else if (sItem.useStyle == 9) { float lerpValue = Utils.GetLerpValue(0.0f, 0.7f, 1f - (float) this.itemAnimation / (float) this.itemAnimationMax, true); this.itemRotation = (float) ((double) lerpValue * (double) -this.direction * 2.0 + 0.699999988079071 * (double) this.direction); this.itemLocation = this.MountedCenter + new Vector2((float) (this.direction * 10) * ((float) this.itemAnimation / (float) this.itemAnimationMax), 0.0f); float num5 = 8f; float num6 = 7f; float num7 = 1.256637f; float f = (float) (-(double) num7 * 0.5 + (1.0 - (double) lerpValue) * (double) num7) + 0.3141593f; this.itemLocation = this.Center + new Vector2((float) this.direction * num5, 0.0f) + f.ToRotationVector2() * num6 * new Vector2((float) this.direction, 1f); float rotation = f - 1.570796f; if (this.direction == -1) rotation = -rotation; this.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); this.itemLocation = this.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, rotation); this.itemLocation -= this.MountedCenter; this.itemLocation *= MathHelper.Lerp(1.5f, 1.2f, lerpValue); this.itemLocation += this.MountedCenter; this.itemLocation.X += (float) this.direction * MathHelper.Lerp(8f, 2f, lerpValue); if ((double) this.gravDir != -1.0) return; this.itemRotation = -this.itemRotation; this.itemLocation.Y = (float) ((double) this.position.Y + (double) this.height + ((double) this.position.Y - (double) this.itemLocation.Y)); } else if (sItem.useStyle == 6) { float num = (float) (1.0 - (double) this.itemAnimation / (double) this.itemAnimationMax) * 6f; if ((double) num > 1.0) num = 1f; this.itemRotation = (float) ((1.0 - (double) num) * (double) this.direction * 2.0 - 1.39999997615814 * (double) this.direction); if ((double) num >= 0.5) { this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 + ((double) heldItemFrame.Width * 0.5 - 9.0 - (double) this.itemRotation * 12.0 * (double) this.direction) * (double) this.direction); this.itemLocation.Y = (float) ((double) this.position.Y + 38.0 + (double) this.itemRotation * (double) this.direction * 4.0) + mountOffset; } else { this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 + ((double) heldItemFrame.Width * 0.5 - 9.0 - (double) this.itemRotation * 16.0 * (double) this.direction) * (double) this.direction); this.itemLocation.Y = (float) ((double) this.position.Y + 38.0 + (double) this.itemRotation * (double) this.direction) + mountOffset; } if ((double) this.gravDir != -1.0) return; this.itemRotation = -this.itemRotation; this.itemLocation.Y = (float) ((double) this.position.Y + (double) this.height + ((double) this.position.Y - (double) this.itemLocation.Y)); } else if (sItem.useStyle == 2) { this.itemLocation = this.MountedCenter + new Vector2((float) (10 * this.direction), -10f).RotatedBy((double) this.itemRotation + 0.785398185253143 * (double) this.direction); float num8 = (float) (1.0 - (double) this.itemAnimation / (double) this.itemAnimationMax); Player.CompositeArmStretchAmount stretch = Player.CompositeArmStretchAmount.Full; if ((double) num8 > 0.25 && (double) num8 <= 0.5) stretch = Player.CompositeArmStretchAmount.ThreeQuarters; if ((double) num8 > 0.5 && (double) num8 <= 0.75) stretch = Player.CompositeArmStretchAmount.Quarter; if ((double) num8 > 0.75 && (double) num8 <= 1.0) stretch = Player.CompositeArmStretchAmount.None; this.SetCompositeArmFront(true, stretch, -1.570796f * (float) this.direction); this.SetCompositeArmBack(true, stretch, -1.570796f * (float) this.direction); int num9 = 8; switch (stretch) { case Player.CompositeArmStretchAmount.Full: num9 = 8; break; case Player.CompositeArmStretchAmount.None: num9 = 2; break; case Player.CompositeArmStretchAmount.Quarter: num9 = 4; break; case Player.CompositeArmStretchAmount.ThreeQuarters: num9 = 6; break; } this.itemLocation = this.MountedCenter + new Vector2((float) ((num9 + 10 - heldItemFrame.Width / 2) * this.direction), (float) (heldItemFrame.Height / 2 - 4)); if ((double) this.gravDir != -1.0) return; this.itemRotation = -this.itemRotation; this.itemLocation.Y = (float) ((double) this.position.Y + (double) this.height + ((double) this.position.Y - (double) this.itemLocation.Y)); } else if (sItem.useStyle == 11) { float num10 = (float) (1.0 - (double) this.itemAnimation / (double) this.itemAnimationMax) * 2f; Player.CompositeArmStretchAmount stretch = Player.CompositeArmStretchAmount.Full; if ((double) num10 > 0.25 && (double) num10 <= 0.5) stretch = Player.CompositeArmStretchAmount.ThreeQuarters; if ((double) num10 > 0.5 && (double) num10 <= 0.75) stretch = Player.CompositeArmStretchAmount.Quarter; if ((double) num10 > 0.75 && (double) num10 <= 1.25) stretch = Player.CompositeArmStretchAmount.None; if ((double) num10 > 1.25 && (double) num10 <= 1.5) stretch = Player.CompositeArmStretchAmount.Quarter; if ((double) num10 > 1.5 && (double) num10 <= 1.75) stretch = Player.CompositeArmStretchAmount.ThreeQuarters; if ((double) num10 > 1.75 && (double) num10 <= 2.0) stretch = Player.CompositeArmStretchAmount.Full; this.SetCompositeArmFront(true, stretch, -0.7853982f * (float) this.direction); this.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, -0.1963495f); int num11 = 8; switch (stretch) { case Player.CompositeArmStretchAmount.Full: num11 = 8; break; case Player.CompositeArmStretchAmount.None: num11 = 2; break; case Player.CompositeArmStretchAmount.Quarter: num11 = 4; break; case Player.CompositeArmStretchAmount.ThreeQuarters: num11 = 6; break; } this.itemLocation = this.MountedCenter + new Vector2((float) ((num11 + 22 - heldItemFrame.Width / 2) * this.direction), (float) (heldItemFrame.Height / 2 - 8)); if ((double) this.gravDir != -1.0) return; this.itemRotation = -this.itemRotation; this.itemLocation.Y = (float) ((double) this.position.Y + (double) this.height + ((double) this.position.Y - (double) this.itemLocation.Y)); } else if (sItem.useStyle == 3) { if ((double) this.itemAnimation > (double) this.itemAnimationMax * 0.666) { this.itemLocation.X = -1000f; this.itemLocation.Y = -1000f; this.itemRotation = -1.3f * (float) this.direction; } else { this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 + ((double) heldItemFrame.Width * 0.5 - 4.0) * (double) this.direction); this.itemLocation.Y = this.position.Y + 24f + mountOffset; float num = (float) ((double) this.itemAnimation / (double) this.itemAnimationMax * (double) heldItemFrame.Width * (double) this.direction * (double) sItem.scale * 1.20000004768372) - (float) (10 * this.direction); if ((double) num > -4.0 && this.direction == -1) num = -8f; if ((double) num < 4.0 && this.direction == 1) num = 8f; this.itemLocation.X -= num; this.itemRotation = 0.8f * (float) this.direction; if (sItem.type == 946 || sItem.type == 4707) this.itemLocation.X -= (float) (6 * this.direction); } if ((double) this.gravDir != -1.0) return; this.itemRotation = -this.itemRotation; this.itemLocation.Y = (float) ((double) this.position.Y + (double) this.height + ((double) this.position.Y - (double) this.itemLocation.Y)); } else if (sItem.useStyle == 4) { int num12 = 0; int num13 = 0; if (sItem.type == 3601) num12 = 10; this.itemRotation = 0.0f; this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 + ((double) heldItemFrame.Width * 0.5 - 9.0 - (double) this.itemRotation * 14.0 * (double) this.direction - 4.0 - (double) num12) * (double) this.direction); this.itemLocation.Y = (float) ((double) this.position.Y + (double) heldItemFrame.Height * 0.5 + 4.0) + mountOffset + (float) num13; if ((double) this.gravDir != -1.0) return; this.itemRotation = -this.itemRotation; this.itemLocation.Y = (float) ((double) this.position.Y + (double) this.height + ((double) this.position.Y - (double) this.itemLocation.Y)); } else if (sItem.useStyle == 5) { if (sItem.type == 3779) { this.itemRotation = 0.0f; this.itemLocation.X = this.Center.X + (float) (6 * this.direction); this.itemLocation.Y = this.MountedCenter.Y + 6f; } else if (sItem.type == 4262) { this.itemRotation = 0.0f; this.itemLocation.X = this.Center.X + (float) -heldItemFrame.Width * 0.5f + (float) (this.direction * -6); this.itemLocation.Y = this.MountedCenter.Y - 6f; if (Main.rand.Next(20) != 0) return; int Type = Main.rand.Next(570, 573); Vector2 Position = new Vector2((float) ((double) this.Center.X + (double) (this.direction * 30) - 6.0), this.itemLocation.Y - 30f); Vector2 Velocity = new Vector2((float) ((double) Main.WindForVisuals * 2.0 + (double) this.direction * 0.300000011920929), -0.5f); Velocity.X *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); Velocity.Y *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.00999999977648258); if (Type == 572) Position.X -= 8f; if (Type == 571) Position.X -= 4f; Gore.NewGore(Position, Velocity, Type, 0.8f); } else if (Item.staff[sItem.type]) { float num = 6f; if (sItem.type == 3476) num = 14f; this.itemLocation = this.MountedCenter; this.itemLocation += (this.itemRotation.ToRotationVector2() * num * (float) this.direction).Floor(); } else { this.itemLocation.X = (float) ((double) this.position.X + (double) this.width * 0.5 - (double) heldItemFrame.Width * 0.5) - (float) (this.direction * 2); this.itemLocation.Y = this.MountedCenter.Y - (float) heldItemFrame.Height * 0.5f; } } else if (sItem.useStyle == 13) { int num14 = this.itemAnimationMax; if (this.itemTimeMax != 0) num14 = this.itemTimeMax; if (num14 == 0) num14 = sItem.useAnimation; float num15 = (float) (1.0 - (double) (this.itemAnimation % num14) / (double) num14); Player.CompositeArmStretchAmount stretch = Player.CompositeArmStretchAmount.Quarter; if ((double) num15 > 0.330000013113022 && (double) num15 <= 0.660000026226044) stretch = Player.CompositeArmStretchAmount.ThreeQuarters; if ((double) num15 > 0.660000026226044 && (double) num15 <= 1.0) stretch = Player.CompositeArmStretchAmount.Full; float rotation = this.itemRotation - 1.570796f * (float) this.direction; this.SetCompositeArmFront(true, stretch, rotation); } else if (sItem.useStyle == 8) { Projectile projectile1 = (Projectile) null; if (this.ownedProjectileCounts[722] > 0) { for (int index = 0; index < 1000; ++index) { Projectile projectile2 = Main.projectile[index]; if (projectile2.active && projectile2.owner == this.whoAmI && projectile2.type == 722) { projectile1 = projectile2; break; } } } float num16 = 1f; if (projectile1 != null) num16 = MathHelper.Lerp(0.6f, 1f, Utils.GetLerpValue(0.0f, 800f, Vector2.Distance(this.MountedCenter, projectile1.Center), true)); float num17 = 1f; if (this.itemAnimation >= sItem.useAnimation - 1 && this.itemAnimation <= sItem.useAnimation) { this.itemRotation = new Vector2((float) (10 * this.direction), 10f).ToRotation() + 0.7853982f; if (this.direction == -1) this.itemRotation += 1.570796f; double num18 = 1.0 - (double) this.itemAnimation / (double) this.itemAnimationMax; Player.CompositeArmStretchAmount stretch1 = Player.CompositeArmStretchAmount.Full; Player.CompositeArmStretchAmount stretch2 = Player.CompositeArmStretchAmount.ThreeQuarters; float num19 = -0.3141593f; if (this.direction == -1) num19 *= -1f; float num20 = (float) ((double) this.itemRotation - 0.785398185253143 + 3.14159274101257); if (this.direction == 1) num20 += 1.570796f; float rotation1 = num20 + num19; float rotation2 = num20 - num19; this.itemLocation = (this.MountedCenter + (num20 + 1.570796f).ToRotationVector2() * -2f).Floor(); this.SetCompositeArmFront(true, stretch1, rotation1); this.SetCompositeArmBack(true, stretch2, rotation2); } else if (this.itemAnimation > sItem.useAnimation) { float num21 = -Utils.GetLerpValue((float) this.itemAnimationMax, (float) (this.itemAnimationMax * 5), (float) this.itemAnimation, true) * num17; Player.CompositeArmStretchAmount stretch3 = Player.CompositeArmStretchAmount.Full; Player.CompositeArmStretchAmount stretch4 = Player.CompositeArmStretchAmount.ThreeQuarters; float num22 = -0.3141593f * -num21; this.itemRotation = (float) (1.57079637050629 * (double) -this.direction + 3.14159274101257 + 3.14159274101257 * (double) num21 * (double) -this.direction); double num23 = -0.628318548202515 * (double) this.direction; if (this.direction < 1) num22 *= -1f; float rotation3 = (float) num23 + num22; float rotation4 = (float) num23 - num22; this.itemLocation = (this.MountedCenter + new Vector2((float) (10 * this.direction), num21 * -6f)).Floor(); this.SetCompositeArmFront(true, stretch3, rotation3); this.SetCompositeArmBack(true, stretch4, rotation4); } else { float num24 = (float) (1.0 - (double) this.itemAnimation / (double) this.itemAnimationMax); Player.CompositeArmStretchAmount stretch5 = Player.CompositeArmStretchAmount.Full; Player.CompositeArmStretchAmount stretch6 = Player.CompositeArmStretchAmount.ThreeQuarters; if ((double) num24 > 0.600000023841858) stretch6 = Player.CompositeArmStretchAmount.Quarter; float num25 = -0.3141593f; if (this.direction == -1) num25 *= -1f; float num26 = num25 * (float) (1.0 - (double) num24 * 2.20000004768372); this.itemRotation = (float) (((double) num24 * 3.14159274101257 * 1.60000002384186 - 1.57079637050629) * (double) num17 * (double) -this.direction + 3.14159274101257); float num27 = (float) (((double) num24 * 3.14159274101257 * 0.600000023841858 + 1.25663709640503) * (double) -this.direction + 3.14159274101257 - 0.785398185253143 + 3.14159274101257); if (this.direction == 1) num27 += 1.570796f; float rotation5 = num27 + num26; float rotation6 = num27 - num26; this.itemLocation = (this.MountedCenter + (num27 + 1.570796f).ToRotationVector2() * (float) (-5.0 * (1.0 - (double) num24))).Floor(); this.SetCompositeArmFront(true, stretch5, rotation5); this.SetCompositeArmBack(true, stretch6, rotation6); } this.FlipItemLocationAndRotationForGravity(); } else if (sItem.useStyle == 12) { this.itemRotation = 0.0f; this.itemLocation.X = this.MountedCenter.X - (float) (8 * this.direction); this.itemLocation.Y = this.position.Y + 40f + mountOffset; this.itemLocation += Main.OffsetsPlayerHeadgear[this.bodyFrame.Y / 56]; float num28 = (float) this.itemAnimationMax; if ((double) num28 == 0.0) num28 = (float) sItem.useAnimation; float num29 = (float) (1.0 - (double) this.itemAnimation / (double) num28) * 2f; float num30 = (float) Math.Cos((double) num29 * 3.14159274101257) * 0.2f; Player.CompositeArmStretchAmount stretch = Player.CompositeArmStretchAmount.Full; if ((double) num29 > 0.25 && (double) num29 <= 0.5) stretch = Player.CompositeArmStretchAmount.ThreeQuarters; if ((double) num29 > 0.5 && (double) num29 <= 0.75) stretch = Player.CompositeArmStretchAmount.Quarter; if ((double) num29 > 0.75 && (double) num29 <= 1.25) stretch = Player.CompositeArmStretchAmount.None; if ((double) num29 > 1.25 && (double) num29 <= 1.5) stretch = Player.CompositeArmStretchAmount.Quarter; if ((double) num29 > 1.5 && (double) num29 <= 1.75) stretch = Player.CompositeArmStretchAmount.ThreeQuarters; if ((double) num29 > 1.75 && (double) num29 <= 2.0) stretch = Player.CompositeArmStretchAmount.Full; this.SetCompositeArmFront(true, stretch, (num30 - 0.7853982f) * (float) this.direction); this.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Quarter, (float) (-0.785398185253143 - (double) num30 * 0.5) * (float) this.direction); this.FlipItemLocationAndRotationForGravity(); if (sItem.type != 4715 || stretch != Player.CompositeArmStretchAmount.ThreeQuarters) return; Vector2 Position = this.itemLocation + new Vector2((float) heldItemFrame.Width, (float) -heldItemFrame.Height) * new Vector2((float) this.direction, this.gravDir) * 0.3f; Dust dust1 = Dust.NewDustPerfect(Position, 228, new Vector2?(Main.rand.NextVector2CircularEdge(1f, 1f))); dust1.noGravity = true; dust1.noLight = true; dust1.velocity *= 2f; float num31 = 0.5f; for (float num32 = 0.0f; (double) num32 < 1.0; num32 += 0.5f) { if (Main.rand.Next(3) == 0) { Dust dust2 = Dust.NewDustPerfect(Position, 278, new Vector2?(Vector2.UnitY.RotatedBy((double) num32 * 6.28318548202515 + (double) Main.rand.NextFloat() * (double) num31 - (double) num31 * 0.5 + 1.57079637050629) * (float) (2.0 + (double) Main.rand.NextFloat() * 1.0)), 150, Color.Lerp(Color.White, Color.HotPink, (float) ((double) Main.rand.NextFloat() * 0.5 + 0.5)), 0.45f); dust2.noGravity = true; dust2.velocity *= 0.5f; dust2.customData = (object) this; dust2.position += dust2.velocity * 6f; } } for (float num33 = 0.0f; (double) num33 < 1.0; num33 += 0.5f) { if (Main.rand.Next(3) == 0) { Dust dust3 = Dust.NewDustPerfect(Position, 278, new Vector2?(Vector2.UnitY.RotatedBy((double) num33 * 6.28318548202515 + (double) Main.rand.NextFloat() * (double) num31 - (double) num31 * 0.5 + 1.57079637050629) * (float) (0.5 + (double) Main.rand.NextFloat() * 1.0)), 150, Color.Lerp(Color.White, Color.Gold, (float) ((double) Main.rand.NextFloat() * 0.5 + 0.5)), 0.45f); dust3.noGravity = true; dust3.velocity *= 0.5f; dust3.customData = (object) this; dust3.position += dust3.velocity * 6f; } } } else { if (sItem.useStyle != 14 || Main.dedServ) return; this.itemRotation = 0.0f; this.itemLocation.X = this.Center.X + (float) (6 * this.direction); this.itemLocation.Y = (float) ((double) this.position.Y + 40.0 + (double) mountOffset - 8.0); this.itemLocation += Main.OffsetsPlayerHeadgear[this.bodyFrame.Y / 56]; this.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, -2.356194f * (float) this.direction); this.FlipItemLocationAndRotationForGravity(); } } public void FlipItemLocationAndRotationForGravity() { if ((double) this.gravDir != -1.0) return; this.itemRotation = -this.itemRotation; this.itemLocation.Y = this.Bottom.Y + (this.position.Y - this.itemLocation.Y); } private void ItemCheck_StartActualUse(Item sItem) { bool flag1 = sItem.type == 4711; if (((sItem.pick > 0 || sItem.axe > 0 ? 1 : (sItem.hammer > 0 ? 1 : 0)) | (flag1 ? 1 : 0)) != 0) this.toolTime = 1; if (this.grappling[0] > -1) { this.pulley = false; this.pulleyDir = (byte) 1; if (this.controlRight) this.direction = 1; else if (this.controlLeft) this.direction = -1; } this.channel = sItem.channel; this.attackCD = 0; this.ApplyItemAnimation(sItem); bool flag2 = ItemID.Sets.SkipsInitialUseSound[sItem.type]; if (sItem.UseSound == null || flag2) return; SoundEngine.PlaySound(sItem.UseSound, this.Center); } private void FreeUpPetsAndMinions(Item sItem) { if (ProjectileID.Sets.MinionSacrificable[sItem.shoot]) { List intList = new List(); float num1 = 0.0f; for (int index1 = 0; index1 < 1000; ++index1) { if (Main.projectile[index1].active && Main.projectile[index1].owner == this.whoAmI && Main.projectile[index1].minion) { int index2; for (index2 = 0; index2 < intList.Count; ++index2) { if ((double) Main.projectile[intList[index2]].minionSlots > (double) Main.projectile[index1].minionSlots) { intList.Insert(index2, index1); break; } } if (index2 == intList.Count) intList.Add(index1); num1 += Main.projectile[index1].minionSlots; } } float num2 = (float) ItemID.Sets.StaffMinionSlotsRequired[sItem.type]; float num3 = 0.0f; int num4 = 388; int index3 = -1; for (int index4 = 0; index4 < intList.Count; ++index4) { int type = Main.projectile[intList[index4]].type; if (type == 626) { intList.RemoveAt(index4); --index4; } if (type == 627) { if (Main.projectile[(int) Main.projectile[intList[index4]].localAI[1]].type == 628) index3 = intList[index4]; intList.RemoveAt(index4); --index4; } } if (index3 != -1) { intList.Add(index3); intList.Add(Projectile.GetByUUID(Main.projectile[index3].owner, Main.projectile[index3].ai[0])); } for (int index5 = 0; index5 < intList.Count && (double) num1 - (double) num3 > (double) this.maxMinions - (double) num2; ++index5) { int type = Main.projectile[intList[index5]].type; if (type != num4 && type != 625 && type != 628 && type != 623) { if (type == 388 && num4 == 387) num4 = 388; if (type == 387 && num4 == 388) num4 = 387; num3 += Main.projectile[intList[index5]].minionSlots; if (type == 626 || type == 627) { Projectile projectile1 = Main.projectile[intList[index5]]; int byUuid = Projectile.GetByUUID(projectile1.owner, projectile1.ai[0]); if (Main.projectile.IndexInRange(byUuid)) { Projectile projectile2 = Main.projectile[byUuid]; if (projectile2.type != 625) projectile2.localAI[1] = projectile1.localAI[1]; Projectile projectile3 = Main.projectile[(int) projectile1.localAI[1]]; projectile3.ai[0] = projectile1.ai[0]; projectile3.ai[1] = 1f; projectile3.netUpdate = true; } } Main.projectile[intList[index5]].Kill(); } } intList.Clear(); if ((double) num1 + (double) num2 < 9.0) return; AchievementsHelper.HandleSpecialEvent(this, 6); } else { for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI && Main.projectile[index].type == sItem.shoot) Main.projectile[index].Kill(); if (sItem.shoot == 72) { if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI && Main.projectile[index].type == 86) Main.projectile[index].Kill(); if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI && Main.projectile[index].type == 87) Main.projectile[index].Kill(); } } } } private void ApplyPotionDelay(Item sItem) { if (sItem.type == 227) { this.potionDelay = this.restorationDelayTime; this.AddBuff(21, this.potionDelay); } else { this.potionDelay = this.potionDelayTime; this.AddBuff(21, this.potionDelay); } } private bool ItemCheck_CheckCanUse(Item sItem) { int whoAmI = this.whoAmI; bool canUse = true; int i = (int) ((double) Main.mouseX + (double) Main.screenPosition.X) / 16; int j = (int) ((double) Main.mouseY + (double) Main.screenPosition.Y) / 16; if ((double) this.gravDir == -1.0) j = (int) ((double) Main.screenPosition.Y + (double) Main.screenHeight - (double) Main.mouseY) / 16; if (sItem.type == 3335 && (this.extraAccessory || !Main.expertMode)) canUse = false; if (this.pulley && sItem.fishingPole > 0) canUse = false; if (this.pulley && ItemID.Sets.IsAKite[sItem.type]) canUse = false; if (sItem.type == 3611 && (WiresUI.Settings.ToolMode & (WiresUI.Settings.MultiToolMode.Red | WiresUI.Settings.MultiToolMode.Green | WiresUI.Settings.MultiToolMode.Blue | WiresUI.Settings.MultiToolMode.Yellow | WiresUI.Settings.MultiToolMode.Actuator)) == (WiresUI.Settings.MultiToolMode) 0) canUse = false; if ((sItem.type == 3611 || sItem.type == 3625) && this.wireOperationsCooldown > 0) canUse = false; if (!this.CheckDD2CrystalPaymentLock(sItem)) canUse = false; if (sItem.shoot > -1 && ProjectileID.Sets.IsADD2Turret[sItem.shoot] && !this.downedDD2EventAnyDifficulty && !DD2Event.Ongoing) canUse = false; if (sItem.shoot > -1 && ProjectileID.Sets.IsADD2Turret[sItem.shoot] && DD2Event.Ongoing && whoAmI == Main.myPlayer) { int worldX; int worldY; this.FindSentryRestingSpot(sItem.shoot, out worldX, out worldY, out int _); if (Player.WouldSpotOverlapWithSentry(worldX, worldY, sItem.shoot == 688 || sItem.shoot == 689 || sItem.shoot == 690)) canUse = false; } if (sItem.shoot > -1 && ProjectileID.Sets.IsADD2Turret[sItem.shoot] && whoAmI == Main.myPlayer) { int worldX; int worldY; this.FindSentryRestingSpot(sItem.shoot, out worldX, out worldY, out int _); int num = worldX / 16; worldY /= 16; --worldY; if (sItem.shoot == 688 || sItem.shoot == 689 || sItem.shoot == 690) { if (Collision.SolidTiles(num, num, worldY - 2, worldY)) canUse = false; } else if (WorldGen.SolidTile(num, worldY)) canUse = false; } if (this.wet && (sItem.shoot == 85 || sItem.shoot == 15 || sItem.shoot == 34)) canUse = false; if (sItem.makeNPC > (short) 0 && !NPC.CanReleaseNPCs(this.whoAmI)) canUse = false; if (this.whoAmI == Main.myPlayer && sItem.type == 603 && !Main.runningCollectorsEdition) canUse = false; if (sItem.type == 1071 || sItem.type == 1072) { bool flag = false; for (int index = 0; index < 58; ++index) { if (this.inventory[index].paint > (byte) 0) { flag = true; break; } } if (!flag) canUse = false; } if (this.noItems) canUse = false; if (sItem.tileWand > 0) { int tileWand = sItem.tileWand; canUse = false; for (int index = 0; index < 58; ++index) { if (tileWand == this.inventory[index].type && this.inventory[index].stack > 0) { canUse = true; break; } } } if ((sItem.shoot == 6 || sItem.shoot == 19 || sItem.shoot == 33 || sItem.shoot == 52 || sItem.shoot == 113 || sItem.shoot == 320 || sItem.shoot == 333 || sItem.shoot == 383 || sItem.shoot == 491 || sItem.shoot == 867 || sItem.shoot == 902 ? 1 : (sItem.shoot == 866 ? 1 : 0)) != 0) { for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && Main.projectile[index].type == sItem.shoot) canUse = false; } } if (sItem.shoot == 106) { int num = 0; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && Main.projectile[index].type == sItem.shoot) ++num; } if (num >= sItem.stack) canUse = false; } if (sItem.shoot == 272) { int num = 0; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && Main.projectile[index].type == sItem.shoot) ++num; } if (num >= sItem.stack) canUse = false; } if (sItem.shoot == 13 || sItem.shoot == 32 || sItem.shoot >= 230 && sItem.shoot <= 235 || sItem.shoot == 315 || sItem.shoot == 331 || sItem.shoot == 372) { for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && Main.projectile[index].type == sItem.shoot && (double) Main.projectile[index].ai[0] != 2.0) canUse = false; } } if (sItem.shoot == 332) { int num = 0; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && Main.projectile[index].type == sItem.shoot && (double) Main.projectile[index].ai[0] != 2.0) ++num; } if (num >= 3) canUse = false; } if (sItem.potion && this.potionDelay > 0) canUse = false; if (sItem.mana > 0 && this.silence) canUse = false; if (sItem.mana > 0 & canUse) canUse = this.ItemCheck_PayMana(sItem, canUse); if (sItem.type == 43 && Main.dayTime) canUse = false; if (sItem.type == 544 && Main.dayTime) canUse = false; if (sItem.type == 556 && Main.dayTime) canUse = false; if (sItem.type == 557 && Main.dayTime) canUse = false; if (sItem.type == 70 && !this.ZoneCorrupt) canUse = false; if (sItem.type == 1133 && !this.ZoneJungle) canUse = false; if (sItem.type == 1844 && (Main.dayTime || Main.pumpkinMoon || Main.snowMoon || DD2Event.Ongoing)) canUse = false; if (sItem.type == 1958 && (Main.dayTime || Main.pumpkinMoon || Main.snowMoon || DD2Event.Ongoing)) canUse = false; if (sItem.type == 2767 && (!Main.dayTime || Main.eclipse || !Main.hardMode)) canUse = false; if (sItem.type == 4271 && (Main.dayTime || Main.bloodMoon)) canUse = false; if (sItem.type == 3601 && (!NPC.downedGolemBoss || !Main.hardMode || NPC.AnyDanger() || NPC.AnyoneNearCultists())) canUse = false; if (!this.SummonItemCheck()) canUse = false; if (sItem.shoot == 17 & canUse && whoAmI == Main.myPlayer && !Player.ItemCheck_IsValidDirtRodTarget(Main.tile[i, j])) canUse = false; if (sItem.fishingPole > 0) canUse = this.ItemCheck_CheckFishingBobbers(canUse); if (ItemID.Sets.HasAProjectileThatHasAUsabilityCheck[sItem.type]) canUse = this.ItemCheck_CheckUsabilityOfProjectiles(canUse); if (sItem.shoot == 17 & canUse && whoAmI == Main.myPlayer) { if (Player.ItemCheck_IsValidDirtRodTarget(Main.tile[i, j])) { WorldGen.KillTile(i, j, noItem: true); if (!Main.tile[i, j].active()) { if (Main.netMode == 1) NetMessage.SendData(17, number: 4, number2: ((float) i), number3: ((float) j)); } else canUse = false; } else canUse = false; } if (canUse) canUse = this.HasAmmo(sItem, canUse); return canUse; } private bool ItemCheck_CheckUsabilityOfProjectiles(bool canUse) { for (int index = 0; index < 1000; ++index) { Projectile projectile = Main.projectile[index]; if (projectile.active && projectile.owner == this.whoAmI) projectile.CheckUsability(this, ref canUse); } return canUse; } private bool ItemCheck_CheckFishingBobbers(bool canUse) { for (int index = 0; index < 1000; ++index) { Projectile bobber = Main.projectile[index]; if (bobber.active && bobber.owner == this.whoAmI && bobber.bobber) { canUse = false; if (this.whoAmI == Main.myPlayer && (double) bobber.ai[0] == 0.0) { bobber.ai[0] = 1f; float num = -10f; if (bobber.wet && (double) bobber.velocity.Y > (double) num) bobber.velocity.Y = num; bobber.netUpdate2 = true; if ((double) bobber.ai[1] < 0.0 && (double) bobber.localAI[1] != 0.0) { bool pullTheBobber; int baitTypeUsed; this.ItemCheck_CheckFishingBobber_PickAndConsumeBait(bobber, out pullTheBobber, out baitTypeUsed); if (pullTheBobber) this.ItemCheck_CheckFishingBobber_PullBobber(bobber, baitTypeUsed); } } } } return canUse; } private void ItemCheck_CheckFishingBobber_PullBobber(Projectile bobber, int baitTypeUsed) { if (baitTypeUsed == 2673) { if (Main.netMode != 1) NPC.SpawnOnPlayer(this.whoAmI, 370); else NetMessage.SendData(61, number: this.whoAmI, number2: 370f); bobber.ai[0] = 2f; } else if ((double) bobber.localAI[1] < 0.0) { Point point = new Point((int) bobber.position.X, (int) bobber.position.Y); int Type = (int) -(double) bobber.localAI[1]; if (Type == 618) point.Y += 64; if (Main.netMode == 1) { NetMessage.SendData(130, number: (point.X / 16), number2: ((float) (point.Y / 16)), number3: ((float) Type)); } else { NPC.NewNPC(point.X, point.Y, Type); bobber.ai[0] = 2f; } } else if (Main.rand.Next(7) == 0 && !this.accFishingLine) bobber.ai[0] = 2f; else bobber.ai[1] = bobber.localAI[1]; bobber.netUpdate = true; } private void ItemCheck_CheckFishingBobber_PickAndConsumeBait( Projectile bobber, out bool pullTheBobber, out int baitTypeUsed) { pullTheBobber = false; baitTypeUsed = 0; int index1 = -1; for (int index2 = 54; index2 < 58; ++index2) { if (this.inventory[index2].stack > 0 && this.inventory[index2].bait > 0) { index1 = index2; break; } } if (index1 == -1) { for (int index3 = 0; index3 < 50; ++index3) { if (this.inventory[index3].stack > 0 && this.inventory[index3].bait > 0) { index1 = index3; break; } } } if (index1 <= -1) return; Item obj1 = this.inventory[index1]; bool flag = false; float num = (float) (1.0 + (double) obj1.bait / 6.0); if ((double) num < 1.0) num = 1f; if (this.accTackleBox) ++num; if ((double) Main.rand.NextFloat() * (double) num < 1.0) flag = true; if ((double) bobber.localAI[1] == -1.0) flag = true; if ((double) bobber.localAI[1] > 0.0) { Item obj2 = new Item(); obj2.SetDefaults((int) bobber.localAI[1]); if (obj2.rare < 0) flag = false; } baitTypeUsed = obj1.type; if (baitTypeUsed == 2673) flag = true; if (flag) { if (obj1.type == 4361 || obj1.type == 4362) NPC.LadyBugKilled(this.Center, obj1.type == 4362); --obj1.stack; if (obj1.stack <= 0) obj1.SetDefaults(); } pullTheBobber = true; } private static bool ItemCheck_IsValidDirtRodTarget(Tile t) { if (!t.active()) return false; return t.type == (ushort) 0 || t.type == (ushort) 2 || t.type == (ushort) 23 || t.type == (ushort) 109 || t.type == (ushort) 199 || t.type == (ushort) 477 || t.type == (ushort) 492; } private bool ItemCheck_PayMana(Item sItem, bool canUse) { bool flag1 = this.altFunctionUse == 2; bool flag2 = false; int num = (int) ((double) sItem.mana * (double) this.manaCost); if (sItem.type == 2795) flag2 = true; if (sItem.type == 3852 & flag1) num = (int) ((double) (sItem.mana * 2) * (double) this.manaCost); if (((sItem.shoot <= 0 ? 0 : (ProjectileID.Sets.TurretFeature[sItem.shoot] ? 1 : 0)) & (flag1 ? 1 : 0)) != 0) flag2 = true; if (((sItem.shoot <= 0 ? 0 : (ProjectileID.Sets.MinionTargettingFeature[sItem.shoot] ? 1 : 0)) & (flag1 ? 1 : 0)) != 0) flag2 = true; if (sItem.type != 3269 && (!this.spaceGun || sItem.type != (int) sbyte.MaxValue && sItem.type != 4347 && sItem.type != 4348)) { if (this.statMana >= num) { if (!flag2) this.statMana -= num; } else if (this.manaFlower) { this.QuickMana(); if (this.statMana >= num) { if (!flag2) this.statMana -= num; } else canUse = false; } else canUse = false; } return canUse; } private void ItemCheck_TryPlacingWearablesOnMannequins(Item sItem) { if (!this.controlUseItem || !this.releaseUseItem || sItem.headSlot <= 0 && sItem.bodySlot <= 0 && sItem.legSlot <= 0) return; if (sItem.useStyle == 0) this.releaseUseItem = false; if ((double) this.position.X / 16.0 - (double) Player.tileRangeX - (double) sItem.tileBoost > (double) Player.tileTargetX || ((double) this.position.X + (double) this.width) / 16.0 + (double) Player.tileRangeX + (double) sItem.tileBoost - 1.0 < (double) Player.tileTargetX || (double) this.position.Y / 16.0 - (double) Player.tileRangeY - (double) sItem.tileBoost > (double) Player.tileTargetY || ((double) this.position.Y + (double) this.height) / 16.0 + (double) Player.tileRangeY + (double) sItem.tileBoost - 2.0 < (double) Player.tileTargetY) return; int tileTargetX = Player.tileTargetX; int tileTargetY = Player.tileTargetY; if (!Main.tile[tileTargetX, tileTargetY].active() || Main.tile[tileTargetX, tileTargetY].type != (ushort) 128 && Main.tile[tileTargetX, tileTargetY].type != (ushort) 269) return; int frameY = (int) Main.tile[tileTargetX, tileTargetY].frameY; int num1 = 0; if (sItem.bodySlot >= 0) num1 = 1; if (sItem.legSlot >= 0) num1 = 2; int num2; for (num2 = frameY / 18; num1 > num2; num2 = (int) Main.tile[tileTargetX, tileTargetY].frameY / 18) ++tileTargetY; for (; num1 < num2; num2 = (int) Main.tile[tileTargetX, tileTargetY].frameY / 18) --tileTargetY; int frameX1 = (int) Main.tile[tileTargetX, tileTargetY].frameX; while (frameX1 >= 100) frameX1 -= 100; if (frameX1 >= 36) frameX1 -= 36; int index = tileTargetX - frameX1 / 18; int frameX2 = (int) Main.tile[index, tileTargetY].frameX; WorldGen.KillTile(index, tileTargetY, true); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) index), number3: ((float) tileTargetY), number4: 1f); while (frameX2 >= 100) frameX2 -= 100; if (num2 == 0 && sItem.headSlot >= 0) { Main.blockMouse = true; Main.tile[index, tileTargetY].frameX = (short) (frameX2 + sItem.headSlot * 100); if (Main.netMode == 1) NetMessage.SendTileSquare(-1, index, tileTargetY, 1); --sItem.stack; if (sItem.stack <= 0) { sItem.SetDefaults(); Main.mouseItem.SetDefaults(); } if (this.selectedItem == 58) Main.mouseItem = sItem.Clone(); this.releaseUseItem = false; this.mouseInterface = true; } else if (num2 == 1 && sItem.bodySlot >= 0) { Main.blockMouse = true; Main.tile[index, tileTargetY].frameX = (short) (frameX2 + sItem.bodySlot * 100); if (Main.netMode == 1) NetMessage.SendTileSquare(-1, index, tileTargetY, 1); --sItem.stack; if (sItem.stack <= 0) { sItem.SetDefaults(); Main.mouseItem.SetDefaults(); } if (this.selectedItem == 58) Main.mouseItem = sItem.Clone(); this.releaseUseItem = false; this.mouseInterface = true; } else { if (num2 != 2 || sItem.legSlot < 0 || ArmorIDs.Legs.Sets.MannequinIncompatible.Contains(sItem.legSlot)) return; Main.blockMouse = true; Main.tile[index, tileTargetY].frameX = (short) (frameX2 + sItem.legSlot * 100); if (Main.netMode == 1) NetMessage.SendTileSquare(-1, index, tileTargetY, 1); --sItem.stack; if (sItem.stack <= 0) { sItem.SetDefaults(); Main.mouseItem.SetDefaults(); } if (this.selectedItem == 58) Main.mouseItem = sItem.Clone(); this.releaseUseItem = false; this.mouseInterface = true; } } private void ApplyReuseDelay() { this.itemAnimation = this.reuseDelay; this.itemTime = this.reuseDelay; this.reuseDelay = 0; } private void ItemCheck_HackHoldStyles(Item sItem) { if (sItem.fishingPole > 0) { sItem.holdStyle = 0; if (this.ItemTimeIsZero && this.itemAnimation == 0) { for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI && Main.projectile[index].bobber) sItem.holdStyle = 1; } } } if (!ItemID.Sets.IsAKite[sItem.type]) return; sItem.holdStyle = 0; if (!this.ItemTimeIsZero || this.itemAnimation != 0) return; for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI && Main.projectile[index].type == sItem.shoot) sItem.holdStyle = 1; } } private void ItemCheck_HandleMPItemAnimation(Item sItem) { if (sItem.autoReuse && !this.noItems) { this.releaseUseItem = true; if (this.itemAnimation == 1 && sItem.stack > 0) { if (sItem.shoot > 0 && this.whoAmI != Main.myPlayer && this.controlUseItem && sItem.useStyle == 5 && sItem.reuseDelay == 0) { this.ApplyItemAnimation(sItem); if (sItem.UseSound != null) SoundEngine.PlaySound(sItem.UseSound, this.Center); } else this.itemAnimation = 0; } } this.TryAllowingItemReuse(sItem); } private void TryAllowingItemReuse(Item sItem) { bool flag = false; if (this.kbGlove) flag = ((flag | sItem.melee ? 1 : 0) | (!sItem.summon ? 0 : (ItemID.Sets.SummonerWeaponThatScalesWithAttackSpeed[sItem.type] ? 1 : 0))) != 0; if (!flag) return; this.releaseUseItem = true; } private void ItemCheck_HandleMount() { if (!this.mount.Active) return; if (this.mount.Type == 8) { this.noItems = true; if (this.controlUseItem) { this.channel = true; if (this.releaseUseItem) this.mount.UseAbility(this, Vector2.Zero, true); this.releaseUseItem = false; } } if (this.whoAmI != Main.myPlayer || (double) this.gravDir != -1.0) return; this.mount.Dismount(this); } public static bool WouldSpotOverlapWithSentry(int worldX, int worldY, bool lightningAura) { Point point1 = new Point(worldX, worldY - 8); Point point2 = new Point(worldX + 16, worldY - 8); Point point3 = new Point(worldX - 16, worldY - 8); bool flag = false; for (int index = 0; index < 1000; ++index) { Projectile projectile = Main.projectile[index]; if (projectile.active && projectile.sentry) { Microsoft.Xna.Framework.Rectangle hitbox = projectile.Hitbox; if (!lightningAura && hitbox.X > 30) { hitbox.X += hitbox.Width / 2; hitbox.Width = 30; hitbox.X -= hitbox.Width / 2; } if (hitbox.Contains(point1) || hitbox.Contains(point2) || hitbox.Contains(point3)) { flag = true; break; } } } return flag; } public void FindSentryRestingSpot( int checkProj, out int worldX, out int worldY, out int pushYUp) { bool flag = false; int i = (int) ((double) Main.mouseX + (double) Main.screenPosition.X) / 16; int j = (int) ((double) Main.mouseY + (double) Main.screenPosition.Y) / 16; if ((double) this.gravDir == -1.0) j = (int) ((double) Main.screenPosition.Y + (double) Main.screenHeight - (double) Main.mouseY) / 16; worldX = i * 16 + 8; pushYUp = 41; switch (checkProj) { case 663: worldX += this.direction; break; case 665: pushYUp += 2; break; case 667: pushYUp += 3; break; case 677: worldX += this.direction; break; case 678: worldX += this.direction; break; case 691: case 692: case 693: pushYUp = 20; worldX += this.direction; pushYUp += 2; break; } if (!flag) { while (j < Main.maxTilesY - 10 && Main.tile[i, j] != null && !WorldGen.SolidTile2(i, j) && Main.tile[i - 1, j] != null && !WorldGen.SolidTile2(i - 1, j) && Main.tile[i + 1, j] != null && !WorldGen.SolidTile2(i + 1, j)) ++j; ++j; } int num = j - 1; pushYUp -= 14; worldY = num * 16; } public void WipeOldestTurret() { List projectileList = new List(); for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].WipableTurret) projectileList.Add(Main.projectile[index]); } if (projectileList.Count == 0) return; Projectile projectile = projectileList[0]; for (int index = 1; index < projectileList.Count; ++index) { if (projectileList[index].timeLeft < projectile.timeLeft) projectile = projectileList[index]; } projectile.Kill(); } public void UpdateMaxTurrets() { List projectileList = new List(); for (int index = 0; index < 1000; ++index) { if (Main.projectile[index].WipableTurret) projectileList.Add(Main.projectile[index]); } int num = 0; while (projectileList.Count > this.maxTurrets && ++num < 1000) { Projectile projectile = projectileList[0]; for (int index = 1; index < projectileList.Count; ++index) { if (projectileList[index].timeLeft < projectile.timeLeft) projectile = projectileList[index]; } projectile.Kill(); projectileList.Remove(projectile); } } private void ItemCheck_ApplyPetBuffs(Item sItem) { if (this.whoAmI == Main.myPlayer && sItem.type == 603 && Main.runningCollectorsEdition) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 669) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 115) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 3060) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 3628) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 3062) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 3577) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 425) { int type = Main.rand.Next(3); if (type == 0) type = 27; if (type == 1) type = 101; if (type == 2) type = 102; for (int b = 0; b < 22; ++b) { if (this.buffType[b] == 27 || this.buffType[b] == 101 || this.buffType[b] == 102) { this.DelBuff(b); --b; } } this.AddBuff(type, 3600); } if (this.whoAmI == Main.myPlayer && sItem.type == 753) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 994) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1169) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1170) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1171) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1172) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1180) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1181) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1182) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1183) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1242) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1157) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1309) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1311) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1837) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1312) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1798) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1799) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1802) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1810) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1927) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 1959) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 2364) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 2365) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 3043) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer && sItem.type == 2420) this.AddBuff(sItem.buffType, 3600); if (this.whoAmI == Main.myPlayer) { switch (sItem.type) { case 2535: case 2551: case 2584: case 2587: case 2621: case 2749: case 3249: case 3474: case 3531: case 4269: case 4273: case 4281: case 4607: case 4758: case 5005: this.AddBuff(sItem.buffType, 3600); break; } } if (this.whoAmI != Main.myPlayer) return; int type1 = sItem.type; if (type1 <= 4605) { if (type1 <= 4366) { if ((uint) (type1 - 3855) > 2U && (uint) (type1 - 4365) > 1U) return; } else if (type1 != 4425 && (uint) (type1 - 4550) > 1U && (uint) (type1 - 4603) > 2U) return; } else if (type1 <= 4737) { if (type1 != 4701 && (uint) (type1 - 4735) > 2U) return; } else if (type1 != 4777 && (uint) (type1 - 4797) > 20U && type1 != 4960) return; this.AddBuff(sItem.buffType, 3600); } public float GetWeaponKnockback(Item sItem, float KnockBack) { if (sItem.summon) KnockBack += this.minionKB; if (sItem.melee && this.kbGlove) KnockBack *= 2f; if (this.kbBuff) KnockBack *= 1.5f; if (sItem.ranged && this.shroomiteStealth) KnockBack *= (float) (1.0 + (1.0 - (double) this.stealth) * 0.5); if (sItem.ranged && this.setVortex) KnockBack *= (float) (1.0 + (1.0 - (double) this.stealth) * 0.5); return KnockBack; } public int GetWeaponCrit(Item sItem) { if (sItem.melee) return this.meleeCrit; if (sItem.ranged) return this.rangedCrit; return sItem.magic ? this.magicCrit : 0; } public int GetWeaponDamage(Item sItem) { int num = sItem.damage; if (num > 0) { if (sItem.melee) num = (int) ((double) num * (double) this.meleeDamage + 4.99999987368938E-06); else if (sItem.ranged) { num = (int) ((double) num * (double) this.rangedDamage + 4.99999987368938E-06); if (sItem.useAmmo == AmmoID.Arrow || sItem.useAmmo == AmmoID.Stake) num = (int) ((double) num * (double) this.arrowDamage + 4.99999987368938E-06); if (sItem.useAmmo == AmmoID.Bullet || sItem.useAmmo == AmmoID.CandyCorn) num = (int) ((double) num * (double) this.bulletDamage + 4.99999987368938E-06); if (sItem.useAmmo == AmmoID.Rocket || sItem.useAmmo == AmmoID.StyngerBolt || sItem.useAmmo == AmmoID.JackOLantern || sItem.useAmmo == AmmoID.NailFriendly) num = (int) ((double) num * (double) this.rocketDamage + 4.99999987368938E-06); } else if (sItem.magic) num = (int) ((double) num * (double) this.magicDamage + 4.99999987368938E-06); else if (sItem.summon) num = (int) ((double) num * (double) this.minionDamage); } return num; } public bool HasAmmo(Item sItem, bool canUse) { if (sItem.useAmmo > 0) { canUse = false; for (int index = 0; index < 58; ++index) { if (this.inventory[index].ammo == sItem.useAmmo && this.inventory[index].stack > 0) { canUse = true; break; } } } return canUse; } private bool PickAmmo_TryFindingSpecificMatches( int launcher, int ammo, out int pickedProjectileId) { pickedProjectileId = 0; Dictionary dictionary; return AmmoID.Sets.SpecificLauncherAmmoProjectileMatches.TryGetValue(launcher, out dictionary) && dictionary.TryGetValue(ammo, out pickedProjectileId); } public void PickAmmo( Item sItem, ref int projToShoot, ref float speed, ref bool canShoot, ref int Damage, ref float KnockBack, bool dontConsume = false) { Item obj = new Item(); bool flag1 = false; for (int index = 54; index < 58; ++index) { if (this.inventory[index].ammo == sItem.useAmmo && this.inventory[index].stack > 0) { obj = this.inventory[index]; canShoot = true; flag1 = true; break; } } if (!flag1) { for (int index = 0; index < 54; ++index) { if (this.inventory[index].ammo == sItem.useAmmo && this.inventory[index].stack > 0) { obj = this.inventory[index]; canShoot = true; break; } } } if (!canShoot) return; int pickedProjectileId = -1; if (this.PickAmmo_TryFindingSpecificMatches(sItem.type, obj.type, out pickedProjectileId)) projToShoot = pickedProjectileId; else if (sItem.type == 1946) projToShoot = 338 + obj.type - 771; else if (sItem.type == 3930) projToShoot = 715 + obj.type - AmmoID.Rocket; else if (sItem.useAmmo == AmmoID.Rocket) projToShoot += obj.shoot; else if (sItem.useAmmo == 780) projToShoot += obj.shoot; else if (obj.shoot > 0) projToShoot = obj.shoot; if (sItem.type == 3019 && projToShoot == 1) projToShoot = 485; if (sItem.type == 3052) projToShoot = 495; if (sItem.type == 4953 && projToShoot == 1) projToShoot = 932; if (sItem.type == 4381) projToShoot = 819; if (sItem.type == 3245 && projToShoot == 21) projToShoot = 532; if (sItem.type == 4058 && projToShoot == 474) projToShoot = 117; if (projToShoot == 42) { if (obj.type == 370) { projToShoot = 65; Damage += 5; } else if (obj.type == 408) { projToShoot = 68; Damage += 5; } else if (obj.type == 1246) { projToShoot = 354; Damage += 5; } } if (this.inventory[this.selectedItem].type == 2888 && projToShoot == 1) projToShoot = 469; if (this.hasMoltenQuiver && projToShoot == 1) projToShoot = 2; if (this.magicQuiver && (sItem.useAmmo == AmmoID.Arrow || sItem.useAmmo == AmmoID.Stake)) { KnockBack = (float) (int) ((double) KnockBack * 1.1); speed *= 1.1f; } speed += obj.shootSpeed; if (obj.ranged) { if (obj.damage > 0) Damage += (int) ((double) obj.damage * (double) this.rangedDamage); } else Damage += obj.damage; if ((sItem.useAmmo == AmmoID.Arrow || sItem.useAmmo == AmmoID.Stake) && this.archery) { if ((double) speed < 20.0) { speed *= 1.2f; if ((double) speed > 20.0) speed = 20f; } Damage = (int) ((double) Damage * 1.2); } KnockBack += obj.knockBack; bool flag2 = dontConsume; if (sItem.type == 3245 && Main.rand.Next(3) == 0) flag2 = true; if (sItem.type == 3475 && Main.rand.Next(3) != 0) flag2 = true; if (sItem.type == 3930 && Main.rand.Next(2) == 0) flag2 = true; if (sItem.type == 3540 && Main.rand.Next(3) != 0) flag2 = true; if (this.magicQuiver && (sItem.useAmmo == AmmoID.Arrow || sItem.useAmmo == AmmoID.Stake) && Main.rand.Next(5) == 0) flag2 = true; if (this.ammoBox && Main.rand.Next(5) == 0) flag2 = true; if (this.ammoPotion && Main.rand.Next(5) == 0) flag2 = true; if (sItem.type == 1782 && Main.rand.Next(3) == 0) flag2 = true; if (sItem.type == 98 && Main.rand.Next(3) == 0) flag2 = true; if (sItem.type == 2270 && Main.rand.Next(2) == 0) flag2 = true; if (sItem.type == 533 && Main.rand.Next(2) == 0) flag2 = true; if (sItem.type == 1929 && Main.rand.Next(2) == 0) flag2 = true; if (sItem.type == 1553 && Main.rand.Next(3) != 0) flag2 = true; if (sItem.type == 434 && this.itemAnimation < sItem.useAnimation - 2) flag2 = true; if (sItem.type == 4953 && this.itemAnimation > sItem.useAnimation - 8) flag2 = true; if (this.chloroAmmoCost80 && Main.rand.Next(5) == 0) flag2 = true; if (this.ammoCost80 && Main.rand.Next(5) == 0) flag2 = true; if (this.ammoCost75 && Main.rand.Next(4) == 0) flag2 = true; if (projToShoot == 85 && this.itemAnimation < this.itemAnimationMax - 6) flag2 = true; if ((projToShoot == 145 || projToShoot == 146 || projToShoot == 147 || projToShoot == 148 || projToShoot == 149) && this.itemAnimation < this.itemAnimationMax - 5) flag2 = true; if (flag2 || !obj.consumable) return; --obj.stack; if (obj.stack > 0) return; obj.active = false; obj.TurnToAir(); } public void GetOtherPlayersPickTile(int x, int y, int pickDamage) => this.hitTile.AddDamage(this.hitTile.HitObject(x, y, 1), pickDamage); public void PickTile(int x, int y, int pickPower) { int tileId = this.hitTile.HitObject(x, y, 1); Tile tileTarget = Main.tile[x, y]; if (tileTarget.type == (ushort) 504) return; int num1 = this.GetPickaxeDamage(x, y, pickPower, tileId, tileTarget); if (!WorldGen.CanKillTile(x, y)) num1 = 0; if (Main.getGoodWorld) num1 *= 2; if (this.DoesPickTargetTransformOnKill(this.hitTile, num1, x, y, pickPower, tileId, tileTarget)) num1 = 0; if (this.hitTile.AddDamage(tileId, num1) >= 100) { AchievementsHelper.CurrentlyMining = true; this.ClearMiningCacheAt(x, y, 1); if (Main.netMode == 1 && Main.tileContainer[(int) Main.tile[x, y].type]) { if (Main.tile[x, y].type == (ushort) 470 || Main.tile[x, y].type == (ushort) 475) { NetMessage.SendData(17, number: 20, number2: ((float) x), number3: ((float) y)); } else { WorldGen.KillTile(x, y, true); NetMessage.SendData(17, number2: ((float) x), number3: ((float) y), number4: 1f); } if (Main.tile[x, y].type == (ushort) 21) NetMessage.SendData(34, number: 1, number2: ((float) x), number3: ((float) y)); if (Main.tile[x, y].type == (ushort) 467) NetMessage.SendData(34, number: 5, number2: ((float) x), number3: ((float) y)); if (Main.tile[x, y].type == (ushort) 88) NetMessage.SendData(34, number: 3, number2: ((float) x), number3: ((float) y)); } else { int j = y; int num2 = Main.tile[x, j].active() ? 1 : 0; WorldGen.KillTile(x, j); if (num2 != 0 && !Main.tile[x, j].active()) AchievementsHelper.HandleMining(); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) x), number3: ((float) j)); } AchievementsHelper.CurrentlyMining = false; } else { WorldGen.KillTile(x, y, true); if (Main.netMode == 1) { NetMessage.SendData(17, number2: ((float) x), number3: ((float) y), number4: 1f); NetMessage.SendData(125, number: Main.myPlayer, number2: ((float) x), number3: ((float) y), number4: ((float) num1)); } } if (num1 == 0) return; this.hitTile.Prune(); } private void ClearMiningCacheAt(int x, int y, int hitTileCacheType) { this.hitReplace.TryClearingAndPruning(x, y, 1); this.hitTile.TryClearingAndPruning(x, y, 1); } public bool isNearFairy() { if (NPC.npcsFoundForCheckActive[583] || NPC.npcsFoundForCheckActive[584] || NPC.npcsFoundForCheckActive[585]) { for (int index = 0; index < 200; ++index) { if (Main.npc[index].active && (Main.npc[index].type == 583 || Main.npc[index].type == 584 || Main.npc[index].type == 585) && (double) Vector2.Distance(Main.npc[index].Center, this.Center) < (double) NPC.sWidth) return true; } } return false; } public bool isNearNPC(int type, float range = -1f) { if ((double) range == -1.0) range = (float) NPC.sWidth; if (NPC.npcsFoundForCheckActive[type]) { for (int index = 0; index < 200; ++index) { if (Main.npc[index].active && Main.npc[index].type == type && (double) Vector2.Distance(Main.npc[index].Center, this.Center) < (double) range) return true; } } return false; } public bool HasEnoughPickPowerToHurtTile(int x, int y) { Item bestPickaxe = this.GetBestPickaxe(); if (bestPickaxe == null) return false; Tile tileTarget = Main.tile[x, y]; int type = (int) tileTarget.type; return this.GetPickaxeDamage(Player.tileTargetX, Player.tileTargetY, bestPickaxe.pick, type, tileTarget) != 0; } private int GetPickaxeDamage(int x, int y, int pickPower, int tileId, Tile tileTarget) { int num1 = 0; if (Main.tileNoFail[(int) tileTarget.type]) num1 = 100; int num2 = Main.tileDungeon[(int) tileTarget.type] || tileTarget.type == (ushort) 25 || tileTarget.type == (ushort) 58 || tileTarget.type == (ushort) 117 || tileTarget.type == (ushort) 203 ? num1 + pickPower / 2 : (tileTarget.type != (ushort) 85 ? (tileTarget.type == (ushort) 48 || tileTarget.type == (ushort) 232 ? num1 + pickPower * 2 : (tileTarget.type != (ushort) 226 ? (tileTarget.type == (ushort) 107 || tileTarget.type == (ushort) 221 ? num1 + pickPower / 2 : (tileTarget.type == (ushort) 108 || tileTarget.type == (ushort) 222 ? num1 + pickPower / 3 : (tileTarget.type == (ushort) 111 || tileTarget.type == (ushort) 223 ? num1 + pickPower / 4 : (tileTarget.type != (ushort) 211 ? num1 + pickPower : num1 + pickPower / 5)))) : num1 + pickPower / 4)) : num1 + pickPower / 3); if (tileTarget.type == (ushort) 211 && pickPower < 200) num2 = 0; if ((tileTarget.type == (ushort) 25 || tileTarget.type == (ushort) 203) && pickPower < 65) num2 = 0; else if (tileTarget.type == (ushort) 117 && pickPower < 65) num2 = 0; else if (tileTarget.type == (ushort) 37 && pickPower < 50) num2 = 0; else if ((tileTarget.type == (ushort) 22 || tileTarget.type == (ushort) 204) && (double) y > Main.worldSurface && pickPower < 55) num2 = 0; else if (tileTarget.type == (ushort) 56 && pickPower < 65) num2 = 0; else if (tileTarget.type == (ushort) 77 && pickPower < 65 && y >= Main.UnderworldLayer) num2 = 0; else if (tileTarget.type == (ushort) 58 && pickPower < 65) num2 = 0; else if ((tileTarget.type == (ushort) 226 || tileTarget.type == (ushort) 237) && pickPower < 210) num2 = 0; else if (tileTarget.type == (ushort) 137 && pickPower < 210) { switch ((int) tileTarget.frameY / 18) { case 1: case 2: case 3: case 4: num2 = 0; break; } } else if (Main.tileDungeon[(int) tileTarget.type] && pickPower < 100 && (double) y > Main.worldSurface) { if ((double) x < (double) Main.maxTilesX * 0.35 || (double) x > (double) Main.maxTilesX * 0.65) num2 = 0; } else if (tileTarget.type == (ushort) 107 && pickPower < 100) num2 = 0; else if (tileTarget.type == (ushort) 108 && pickPower < 110) num2 = 0; else if (tileTarget.type == (ushort) 111 && pickPower < 150) num2 = 0; else if (tileTarget.type == (ushort) 221 && pickPower < 100) num2 = 0; else if (tileTarget.type == (ushort) 222 && pickPower < 110) num2 = 0; else if (tileTarget.type == (ushort) 223 && pickPower < 150) num2 = 0; if (tileTarget.type == (ushort) 147 || tileTarget.type == (ushort) 0 || tileTarget.type == (ushort) 40 || tileTarget.type == (ushort) 53 || tileTarget.type == (ushort) 57 || tileTarget.type == (ushort) 59 || tileTarget.type == (ushort) 123 || tileTarget.type == (ushort) 224 || tileTarget.type == (ushort) 397) num2 += pickPower; if (tileTarget.type == (ushort) 404) num2 += 5; if (tileTarget.type == (ushort) 165 || Main.tileRope[(int) tileTarget.type] || tileTarget.type == (ushort) 199) num2 = 100; if (tileTarget.type == (ushort) 128 || tileTarget.type == (ushort) 269) { if (tileTarget.frameX == (short) 18 || tileTarget.frameX == (short) 54) { --x; tileTarget = Main.tile[x, y]; this.hitTile.UpdatePosition(tileId, x, y); } if (tileTarget.frameX >= (short) 100) { num2 = 0; Main.blockMouse = true; } } if (tileTarget.type == (ushort) 334) { if (tileTarget.frameY == (short) 0) { ++y; tileTarget = Main.tile[x, y]; this.hitTile.UpdatePosition(tileId, x, y); } if (tileTarget.frameY == (short) 36) { --y; tileTarget = Main.tile[x, y]; this.hitTile.UpdatePosition(tileId, x, y); } int frameX1 = (int) tileTarget.frameX; bool flag1 = frameX1 >= 5000; bool flag2 = false; if (!flag1) { int num3 = frameX1 / 18 % 3; x -= num3; tileTarget = Main.tile[x, y]; if (tileTarget.frameX >= (short) 5000) flag1 = true; } if (flag1) { int frameX2 = (int) tileTarget.frameX; int num4 = 0; while (frameX2 >= 5000) { frameX2 -= 5000; ++num4; } if (num4 != 0) flag2 = true; } if (flag2) { num2 = 0; Main.blockMouse = true; } } return num2; } private bool DoesPickTargetTransformOnKill( HitTile hitCounter, int damage, int x, int y, int pickPower, int tileId, Tile tileTarget) { return hitCounter.AddDamage(tileId, damage, false) >= 100 && (tileTarget.type == (ushort) 2 || tileTarget.type == (ushort) 477 || tileTarget.type == (ushort) 492 || tileTarget.type == (ushort) 23 || tileTarget.type == (ushort) 60 || tileTarget.type == (ushort) 70 || tileTarget.type == (ushort) 109 || tileTarget.type == (ushort) 199 || Main.tileMoss[(int) tileTarget.type] || TileID.Sets.tileMossBrick[(int) tileTarget.type]); } public bool ItemFitsWeaponRack(Item i) { bool flag = false; if (i.fishingPole > 0) flag = true; switch (i.netID) { case 905: case 1326: flag = true; break; } return i.damage > 0 | flag && i.useStyle != 0 && i.stack > 0; } public void PlaceWeapon(int x, int y) { if (!Main.tile[x, y].active() || Main.tile[x, y].type != (ushort) 334) return; int frameY = (int) Main.tile[x, y].frameY; int num1 = 1; int num2; for (num2 = frameY / 18; num1 > num2; num2 = (int) Main.tile[x, y].frameY / 18) ++y; for (; num1 < num2; num2 = (int) Main.tile[x, y].frameY / 18) --y; int num3 = (int) Main.tile[x, y].frameX; int num4 = 0; while (num3 >= 5000) { num3 -= 5000; ++num4; } if (num4 != 0) num3 = (num4 - 1) * 18; bool flag = false; if (num3 >= 54) { num3 -= 54; flag = true; } x -= num3 / 18; int frameX = (int) Main.tile[x, y].frameX; WorldGen.KillTile(x, y, true); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) x), number3: ((float) y), number4: 1f); if (Main.netMode == 1) NetMessage.SendData(17, number2: ((float) (x + 1)), number3: ((float) y), number4: 1f); while (frameX >= 5000) frameX -= 5000; Main.blockMouse = true; int num5 = 5000; int num6 = 10000; if (flag) { num5 = 20000; num6 = 25000; } Main.tile[x, y].frameX = (short) (this.inventory[this.selectedItem].netID + num5 + 100); Main.tile[x + 1, y].frameX = (short) ((int) this.inventory[this.selectedItem].prefix + num6); if (Main.netMode == 1) NetMessage.SendTileSquare(-1, x, y, 1); if (Main.netMode == 1) NetMessage.SendTileSquare(-1, x + 1, y, 1); --this.inventory[this.selectedItem].stack; if (this.inventory[this.selectedItem].stack <= 0) { this.inventory[this.selectedItem].SetDefaults(); Main.mouseItem.SetDefaults(); } if (this.selectedItem == 58) Main.mouseItem = this.inventory[this.selectedItem].Clone(); this.releaseUseItem = false; this.mouseInterface = true; } public bool ItemFitsItemFrame(Item i) => i.stack > 0; public Color GetImmuneAlpha(Color newColor, float alphaReduction) { float scale = (float) ((int) byte.MaxValue - this.immuneAlpha) / (float) byte.MaxValue; if ((double) alphaReduction > 0.0) scale *= 1f - alphaReduction; return this.immuneAlpha > 125 ? Color.Transparent : Color.Multiply(newColor, scale); } public Color GetImmuneAlphaPure(Color newColor, float alphaReduction) { float scale = (float) ((int) byte.MaxValue - this.immuneAlpha) / (float) byte.MaxValue; if ((double) alphaReduction > 0.0) scale *= 1f - alphaReduction; return Color.Multiply(newColor, scale); } public Color GetDeathAlpha(Color newColor) { int r = (int) newColor.R + (int) ((double) this.immuneAlpha * 0.9); int num1 = (int) newColor.G + (int) ((double) this.immuneAlpha * 0.5); int num2 = (int) newColor.B + (int) ((double) this.immuneAlpha * 0.5); int num3 = (int) newColor.A + (int) ((double) this.immuneAlpha * 0.4); if (num3 < 0) num3 = 0; if (num3 > (int) byte.MaxValue) num3 = (int) byte.MaxValue; int g = num1; int b = num2; int a = num3; return new Color(r, g, b, a); } public void addDPS(int dmg) { if (this.dpsStarted) { this.dpsLastHit = DateTime.Now; this.dpsDamage += dmg; this.dpsEnd = DateTime.Now; } else { this.dpsStarted = true; this.dpsStart = DateTime.Now; this.dpsEnd = DateTime.Now; this.dpsLastHit = DateTime.Now; this.dpsDamage = dmg; } } public void checkDPSTime() { int num = 3; if (!this.dpsStarted || (DateTime.Now - this.dpsLastHit).Seconds < num) return; this.dpsStarted = false; } public int getDPS() { TimeSpan timeSpan1 = this.dpsEnd - this.dpsStart; float num = (float) timeSpan1.Milliseconds / 1000f + (float) timeSpan1.Seconds + (float) timeSpan1.Minutes / 60f; if ((double) num >= 3.0) { this.dpsStart = DateTime.Now; this.dpsStart = this.dpsStart.AddSeconds(-1.0); this.dpsDamage = (int) ((double) this.dpsDamage / (double) num); TimeSpan timeSpan2 = this.dpsEnd - this.dpsStart; num = (float) timeSpan2.Milliseconds / 1000f + (float) timeSpan2.Seconds + (float) timeSpan2.Minutes / 60f; } if ((double) num < 1.0) num = 1f; return (int) ((double) this.dpsDamage / (double) num); } public int DropCoins() { int num1 = 0; for (int index = 0; index < 59; ++index) { if (this.inventory[index].IsACoin) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, this.inventory[index].type); int num2 = this.inventory[index].stack / 2; if (Main.expertMode) num2 = (int) ((double) this.inventory[index].stack * 0.25); if (Main.masterMode) num2 = 0; int num3 = this.inventory[index].stack - num2; this.inventory[index].stack -= num3; if (this.inventory[index].type == 71) num1 += num3; if (this.inventory[index].type == 72) num1 += num3 * 100; if (this.inventory[index].type == 73) num1 += num3 * 10000; if (this.inventory[index].type == 74) num1 += num3 * 1000000; if (this.inventory[index].stack <= 0) this.inventory[index] = new Item(); Main.item[number].stack = num3; Main.item[number].velocity.Y = (float) Main.rand.Next(-20, 1) * 0.2f; Main.item[number].velocity.X = (float) Main.rand.Next(-20, 21) * 0.2f; Main.item[number].noGrabDelay = 100; if (Main.netMode == 1) NetMessage.SendData(21, number: number); if (index == 58) Main.mouseItem = this.inventory[index].Clone(); } } this.lostCoins = num1; this.lostCoinString = Main.ValueToCoins(this.lostCoins); return num1; } public void DropItems() { for (int index = 0; index < 59; ++index) { if (this.inventory[index].stack > 0) { bool flag = true; if (this.inventory[index].type == 3507 || this.inventory[index].type == 3506 || this.inventory[index].type == 3509) flag = false; if (flag) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, this.inventory[index].type); Main.item[number].netDefaults(this.inventory[index].netID); Main.item[number].Prefix((int) this.inventory[index].prefix); Main.item[number].stack = this.inventory[index].stack; Main.item[number].velocity.Y = (float) Main.rand.Next(-20, 1) * 0.2f; Main.item[number].velocity.X = (float) Main.rand.Next(-20, 21) * 0.2f; Main.item[number].noGrabDelay = 100; Main.item[number].newAndShiny = false; if (Main.netMode == 1) NetMessage.SendData(21, number: number); } } this.inventory[index].TurnToAir(); if (index < this.armor.Length) { if (this.armor[index].stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, this.armor[index].type); Main.item[number].netDefaults(this.armor[index].netID); Main.item[number].Prefix((int) this.armor[index].prefix); Main.item[number].stack = this.armor[index].stack; Main.item[number].velocity.Y = (float) Main.rand.Next(-20, 1) * 0.2f; Main.item[number].velocity.X = (float) Main.rand.Next(-20, 21) * 0.2f; Main.item[number].noGrabDelay = 100; Main.item[number].newAndShiny = false; if (Main.netMode == 1) NetMessage.SendData(21, number: number); } this.armor[index] = new Item(); } if (index < this.dye.Length) { if (this.dye[index].stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, this.dye[index].type); Main.item[number].netDefaults(this.dye[index].netID); Main.item[number].Prefix((int) this.dye[index].prefix); Main.item[number].stack = this.dye[index].stack; Main.item[number].velocity.Y = (float) Main.rand.Next(-20, 1) * 0.2f; Main.item[number].velocity.X = (float) Main.rand.Next(-20, 21) * 0.2f; Main.item[number].noGrabDelay = 100; Main.item[number].newAndShiny = false; if (Main.netMode == 1) NetMessage.SendData(21, number: number); } this.dye[index].TurnToAir(); } if (index < this.miscEquips.Length) { if (this.miscEquips[index].stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, this.miscEquips[index].type); Main.item[number].netDefaults(this.miscEquips[index].netID); Main.item[number].Prefix((int) this.miscEquips[index].prefix); Main.item[number].stack = this.miscEquips[index].stack; Main.item[number].velocity.Y = (float) Main.rand.Next(-20, 1) * 0.2f; Main.item[number].velocity.X = (float) Main.rand.Next(-20, 21) * 0.2f; Main.item[number].noGrabDelay = 100; Main.item[number].newAndShiny = false; if (Main.netMode == 1) NetMessage.SendData(21, number: number); } this.miscEquips[index].TurnToAir(); } if (index < this.miscDyes.Length) { if (this.miscDyes[index].stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, this.miscDyes[index].type); Main.item[number].netDefaults(this.miscDyes[index].netID); Main.item[number].Prefix((int) this.miscDyes[index].prefix); Main.item[number].stack = this.miscDyes[index].stack; Main.item[number].velocity.Y = (float) Main.rand.Next(-20, 1) * 0.2f; Main.item[number].velocity.X = (float) Main.rand.Next(-20, 21) * 0.2f; Main.item[number].noGrabDelay = 100; Main.item[number].newAndShiny = false; if (Main.netMode == 1) NetMessage.SendData(21, number: number); } this.miscDyes[index].TurnToAir(); } } this.inventory[0].SetDefaults(3507); this.inventory[0].Prefix(-1); this.inventory[1].SetDefaults(3509); this.inventory[1].Prefix(-1); this.inventory[2].SetDefaults(3506); this.inventory[2].Prefix(-1); Main.mouseItem.TurnToAir(); } public object Clone() => this.MemberwiseClone(); public void CopyVisuals(Player other) { this.skinVariant = other.skinVariant; this.direction = other.direction; this.selectedItem = other.selectedItem; this.extraAccessory = other.extraAccessory; this.skinColor = other.skinColor; this.eyeColor = other.eyeColor; this.hair = other.hair; this.hairColor = other.hairColor; this.shirtColor = other.shirtColor; this.underShirtColor = other.underShirtColor; this.pantsColor = other.pantsColor; this.shoeColor = other.shoeColor; this.position = other.position; this.velocity = other.velocity; this.statLife = other.statLife; this.statLifeMax = other.statLifeMax; this.statLifeMax2 = other.statLifeMax2; this.statMana = other.statMana; this.statManaMax = other.statManaMax; this.statManaMax2 = other.statManaMax2; this.hideMisc = other.hideMisc; for (int index = 0; index < 59; ++index) { this.inventory[index] = other.inventory[index].Clone(); if (index < this.armor.Length) this.armor[index] = other.armor[index].Clone(); if (index < this.dye.Length) this.dye[index] = other.dye[index].Clone(); if (index < this.miscEquips.Length) this.miscEquips[index] = other.miscEquips[index].Clone(); if (index < this.miscDyes.Length) this.miscDyes[index] = other.miscDyes[index].Clone(); if (index < this.hideVisibleAccessory.Length) this.hideVisibleAccessory[index] = other.hideVisibleAccessory[index]; } } public object clientClone() { Player player = new Player(); player.zone1 = this.zone1; player.zone2 = this.zone2; player.zone3 = this.zone3; player.zone4 = this.zone4; player.voidVaultInfo = this.voidVaultInfo; player.luck = this.luck; player.extraAccessory = this.extraAccessory; player.MinionRestTargetPoint = this.MinionRestTargetPoint; player.MinionAttackTargetNPC = this.MinionAttackTargetNPC; player.direction = this.direction; player.selectedItem = this.selectedItem; player.controlUp = this.controlUp; player.controlDown = this.controlDown; player.controlLeft = this.controlLeft; player.controlRight = this.controlRight; player.controlJump = this.controlJump; player.controlUseItem = this.controlUseItem; player.statLife = this.statLife; player.statLifeMax = this.statLifeMax; player.statMana = this.statMana; player.statManaMax = this.statManaMax; player.position.X = this.position.X; player.tileEntityAnchor = this.tileEntityAnchor; player.chest = this.chest; player.talkNPC = this.talkNPC; player.hideVisibleAccessory = this.hideVisibleAccessory; player.hideMisc = this.hideMisc; player.shieldRaised = this.shieldRaised; for (int index = 0; index < 59; ++index) { player.inventory[index] = this.inventory[index].Clone(); if (index < this.armor.Length) player.armor[index] = this.armor[index].Clone(); if (index < this.dye.Length) player.dye[index] = this.dye[index].Clone(); if (index < this.miscEquips.Length) player.miscEquips[index] = this.miscEquips[index].Clone(); if (index < this.miscDyes.Length) player.miscDyes[index] = this.miscDyes[index].Clone(); if (index < this.bank.item.Length) player.bank.item[index] = this.bank.item[index].Clone(); if (index < this.bank2.item.Length) player.bank2.item[index] = this.bank2.item[index].Clone(); if (index < this.bank3.item.Length) player.bank3.item[index] = this.bank3.item[index].Clone(); if (index < this.bank4.item.Length) player.bank4.item[index] = this.bank4.item[index].Clone(); } player.trashItem = this.trashItem.Clone(); for (int index = 0; index < 22; ++index) { player.buffType[index] = this.buffType[index]; player.buffTime[index] = this.buffTime[index]; } this.DpadRadial.CopyTo(player.DpadRadial); this.CircularRadial.CopyTo(player.CircularRadial); return (object) player; } public static bool CheckSpawn(int x, int y) { if (x < 10 || x > Main.maxTilesX - 10 || y < 10 || y > Main.maxTilesX - 10 || Main.tile[x, y - 1] == null || !Main.tile[x, y - 1].active() || Main.tile[x, y - 1].type != (ushort) 79) return false; for (int index1 = x - 1; index1 <= x + 1; ++index1) { for (int index2 = y - 3; index2 < y; ++index2) { if (Main.tile[index1, index2] == null) return false; if (Main.tile[index1, index2].nactive() && Main.tileSolid[(int) Main.tile[index1, index2].type] && !Main.tileSolidTop[(int) Main.tile[index1, index2].type]) { Main.NewText(Language.GetTextValue("Game.BedObstructed"), G: (byte) 240, B: (byte) 20); return false; } } } return WorldGen.StartRoomCheck(x, y - 1); } public void FindSpawn() { for (int index = 0; index < 200; ++index) { if (this.spN[index] == null) { this.SpawnX = -1; this.SpawnY = -1; break; } if (this.spN[index] == Main.worldName && this.spI[index] == Main.worldID) { this.SpawnX = this.spX[index]; this.SpawnY = this.spY[index]; break; } } } public void RemoveSpawn() { this.SpawnX = -1; this.SpawnY = -1; for (int index1 = 0; index1 < 200 && this.spN[index1] != null; ++index1) { if (this.spN[index1] == Main.worldName && this.spI[index1] == Main.worldID) { for (int index2 = index1; index2 < 199; ++index2) { this.spN[index2] = this.spN[index2 + 1]; this.spI[index2] = this.spI[index2 + 1]; this.spX[index2] = this.spX[index2 + 1]; this.spY[index2] = this.spY[index2 + 1]; } this.spN[199] = (string) null; this.spI[199] = 0; this.spX[199] = 0; this.spY[199] = 0; break; } } } public void ChangeSpawn(int x, int y) { for (int index1 = 0; index1 < 200 && this.spN[index1] != null; ++index1) { if (this.spN[index1] == Main.worldName && this.spI[index1] == Main.worldID) { for (int index2 = index1; index2 > 0; --index2) { this.spN[index2] = this.spN[index2 - 1]; this.spI[index2] = this.spI[index2 - 1]; this.spX[index2] = this.spX[index2 - 1]; this.spY[index2] = this.spY[index2 - 1]; } this.spN[0] = Main.worldName; this.spI[0] = Main.worldID; this.spX[0] = x; this.spY[0] = y; this.FindSpawn(); return; } } for (int index = 199; index > 0; --index) { if (this.spN[index - 1] != null) { this.spN[index] = this.spN[index - 1]; this.spI[index] = this.spI[index - 1]; this.spX[index] = this.spX[index - 1]; this.spY[index] = this.spY[index - 1]; } } this.spN[0] = Main.worldName; this.spI[0] = Main.worldID; this.spX[0] = x; this.spY[0] = y; this.FindSpawn(); } public static void SavePlayer(PlayerFileData playerFile, bool skipMapSave = false) { try { Main.Achievements.Save(); Player.InternalSaveMap(playerFile.IsCloudSave); if (Main.ServerSideCharacter) return; FileUtilities.ProtectedInvoke((Action) (() => Player.InternalSavePlayerFile(playerFile))); } catch (Exception ex) { string path = playerFile.Path; FancyErrorPrinter.ShowFileSavingFailError(ex, path); throw; } } private static void InternalSavePlayerFile(PlayerFileData playerFile) { string path = playerFile.Path; Player player = playerFile.Player; bool isCloudSave = playerFile.IsCloudSave; if (path == null || path == "") return; if (FileUtilities.Exists(path, isCloudSave)) FileUtilities.Copy(path, path + ".bak", isCloudSave); RijndaelManaged rijndaelManaged = new RijndaelManaged(); using (Stream stream = isCloudSave ? (Stream) new MemoryStream(2000) : (Stream) new FileStream(path, FileMode.Create)) { using (CryptoStream cryptoStream = new CryptoStream(stream, rijndaelManaged.CreateEncryptor(Player.ENCRYPTION_KEY, Player.ENCRYPTION_KEY), CryptoStreamMode.Write)) { using (BinaryWriter writer = new BinaryWriter((Stream) cryptoStream)) { writer.Write(230); playerFile.Metadata.Write(writer); writer.Write(player.name); writer.Write(player.difficulty); writer.Write(playerFile.GetPlayTime().Ticks); writer.Write(player.hair); writer.Write(player.hairDye); BitsByte bitsByte1 = (BitsByte) (byte) 0; for (int key = 0; key < 8; ++key) bitsByte1[key] = player.hideVisibleAccessory[key]; writer.Write((byte) bitsByte1); BitsByte bitsByte2 = (BitsByte) (byte) 0; for (int key = 0; key < 2; ++key) bitsByte2[key] = player.hideVisibleAccessory[key + 8]; writer.Write((byte) bitsByte2); writer.Write((byte) player.hideMisc); writer.Write((byte) player.skinVariant); writer.Write(player.statLife); writer.Write(player.statLifeMax); writer.Write(player.statMana); writer.Write(player.statManaMax); writer.Write(player.extraAccessory); writer.Write(player.unlockedBiomeTorches); writer.Write(player.UsingBiomeTorches); writer.Write(player.downedDD2EventAnyDifficulty); writer.Write(player.taxMoney); writer.Write(player.hairColor.R); writer.Write(player.hairColor.G); writer.Write(player.hairColor.B); writer.Write(player.skinColor.R); writer.Write(player.skinColor.G); writer.Write(player.skinColor.B); writer.Write(player.eyeColor.R); writer.Write(player.eyeColor.G); writer.Write(player.eyeColor.B); writer.Write(player.shirtColor.R); writer.Write(player.shirtColor.G); writer.Write(player.shirtColor.B); writer.Write(player.underShirtColor.R); writer.Write(player.underShirtColor.G); writer.Write(player.underShirtColor.B); writer.Write(player.pantsColor.R); writer.Write(player.pantsColor.G); writer.Write(player.pantsColor.B); writer.Write(player.shoeColor.R); writer.Write(player.shoeColor.G); writer.Write(player.shoeColor.B); for (int index = 0; index < player.armor.Length; ++index) { writer.Write(player.armor[index].netID); writer.Write(player.armor[index].prefix); } for (int index = 0; index < player.dye.Length; ++index) { writer.Write(player.dye[index].netID); writer.Write(player.dye[index].prefix); } for (int index = 0; index < 58; ++index) { writer.Write(player.inventory[index].netID); writer.Write(player.inventory[index].stack); writer.Write(player.inventory[index].prefix); writer.Write(player.inventory[index].favorited); } for (int index = 0; index < player.miscEquips.Length; ++index) { writer.Write(player.miscEquips[index].netID); writer.Write(player.miscEquips[index].prefix); writer.Write(player.miscDyes[index].netID); writer.Write(player.miscDyes[index].prefix); } for (int index = 0; index < 40; ++index) { writer.Write(player.bank.item[index].netID); writer.Write(player.bank.item[index].stack); writer.Write(player.bank.item[index].prefix); } for (int index = 0; index < 40; ++index) { writer.Write(player.bank2.item[index].netID); writer.Write(player.bank2.item[index].stack); writer.Write(player.bank2.item[index].prefix); } for (int index = 0; index < 40; ++index) { writer.Write(player.bank3.item[index].netID); writer.Write(player.bank3.item[index].stack); writer.Write(player.bank3.item[index].prefix); } for (int index = 0; index < 40; ++index) { writer.Write(player.bank4.item[index].netID); writer.Write(player.bank4.item[index].stack); writer.Write(player.bank4.item[index].prefix); } writer.Write((byte) player.voidVaultInfo); for (int index = 0; index < 22; ++index) { if (Main.buffNoSave[player.buffType[index]]) { writer.Write(0); writer.Write(0); } else { writer.Write(player.buffType[index]); writer.Write(player.buffTime[index]); } } for (int index = 0; index < 200; ++index) { if (player.spN[index] == null) { writer.Write(-1); break; } writer.Write(player.spX[index]); writer.Write(player.spY[index]); writer.Write(player.spI[index]); writer.Write(player.spN[index]); } writer.Write(player.hbLocked); for (int index = 0; index < player.hideInfo.Length; ++index) writer.Write(player.hideInfo[index]); writer.Write(player.anglerQuestsFinished); for (int index = 0; index < player.DpadRadial.Bindings.Length; ++index) writer.Write(player.DpadRadial.Bindings[index]); for (int index = 0; index < player.builderAccStatus.Length; ++index) writer.Write(player.builderAccStatus[index]); writer.Write(player.bartenderQuestLog); writer.Write(player.dead); if (player.dead) writer.Write(player.respawnTimer); long binary = DateTime.UtcNow.ToBinary(); writer.Write(binary); writer.Write(player.golferScoreAccumulated); player.creativeTracker.Save(writer); player.SaveTemporaryItemSlotContents(writer); CreativePowerManager.Instance.SaveToPlayer(player, writer); writer.Flush(); cryptoStream.FlushFinalBlock(); stream.Flush(); if (!isCloudSave || SocialAPI.Cloud == null) return; SocialAPI.Cloud.Write(playerFile.Path, ((MemoryStream) stream).ToArray()); } } } } private void SaveTemporaryItemSlotContents(BinaryWriter writer) { Item itemByIndex = Main.CreativeMenu.GetItemByIndex(0); BitsByte bitsByte = (BitsByte) (byte) 0; bitsByte[0] = !Main.mouseItem.IsAir; bitsByte[1] = !itemByIndex.IsAir; ItemSerializationContext context = ItemSerializationContext.SavingAndLoading; writer.Write((byte) bitsByte); if (bitsByte[0]) Main.mouseItem.Serialize(writer, context); if (!bitsByte[1]) return; itemByIndex.Serialize(writer, context); } private void LoadTemporaryItemSlotContents(BinaryReader reader) { BitsByte bitsByte = (BitsByte) reader.ReadByte(); ItemSerializationContext context = ItemSerializationContext.SavingAndLoading; if (bitsByte[0]) { this._temporaryItemSlots[0] = new Item(); this._temporaryItemSlots[0].DeserializeFrom(reader, context); } if (!bitsByte[1]) return; this._temporaryItemSlots[1] = new Item(); this._temporaryItemSlots[1].DeserializeFrom(reader, context); } public void SetPlayerDataToOutOfClassFields() { Item obj1 = new Item(); if (this._temporaryItemSlots[0] != null) obj1 = this._temporaryItemSlots[0].Clone(); Main.mouseItem = obj1; Item obj2 = new Item(); if (this._temporaryItemSlots[1] != null) obj2 = this._temporaryItemSlots[1].Clone(); Main.CreativeMenu.SetItembyIndex(obj2, 0); CreativePowerManager.Instance.ApplyLoadedDataToPlayer(this); } public static void ClearPlayerTempInfo() { Main.mouseItem.TurnToAir(); Main.CreativeMenu.GetItemByIndex(0).TurnToAir(); } private static void InternalSaveMap(bool isCloudSave) { if (string.IsNullOrEmpty(Main.playerPathName)) return; try { if (Main.mapEnabled) Main.Map.Save(); } catch { } if (isCloudSave) return; Utils.TryCreatingDirectory(Main.PlayerPath); } public static PlayerFileData LoadPlayer(string playerPath, bool cloudSave) { PlayerFileData playerFileData = new PlayerFileData(playerPath, cloudSave); if (cloudSave && SocialAPI.Cloud == null) return playerFileData; if (Main.rand == null) Main.rand = new UnifiedRandom((int) DateTime.Now.Ticks); Player player1 = new Player(); try { RijndaelManaged rijndaelManaged = new RijndaelManaged(); rijndaelManaged.Padding = PaddingMode.None; using (MemoryStream memoryStream = new MemoryStream(FileUtilities.ReadAllBytes(playerPath, cloudSave))) { using (CryptoStream cryptoStream = new CryptoStream((Stream) memoryStream, rijndaelManaged.CreateDecryptor(Player.ENCRYPTION_KEY, Player.ENCRYPTION_KEY), CryptoStreamMode.Read)) { using (BinaryReader binaryReader = new BinaryReader((Stream) cryptoStream)) { int num1 = binaryReader.ReadInt32(); if (num1 >= 135) playerFileData.Metadata = FileMetadata.Read(binaryReader, FileType.Player); else playerFileData.Metadata = FileMetadata.FromCurrentSettings(FileType.Player); if (num1 > 230) { player1.loadStatus = 1; player1.name = binaryReader.ReadString(); playerFileData.Player = player1; return playerFileData; } player1.name = binaryReader.ReadString(); if (num1 >= 10) { if (num1 >= 17) player1.difficulty = binaryReader.ReadByte(); else if (binaryReader.ReadBoolean()) player1.difficulty = (byte) 2; } if (num1 >= 138) playerFileData.SetPlayTime(new TimeSpan(binaryReader.ReadInt64())); else playerFileData.SetPlayTime(TimeSpan.Zero); player1.hair = binaryReader.ReadInt32(); if (num1 >= 82) player1.hairDye = binaryReader.ReadByte(); if (num1 >= 124) { BitsByte bitsByte = (BitsByte) binaryReader.ReadByte(); for (int key = 0; key < 8; ++key) player1.hideVisibleAccessory[key] = bitsByte[key]; bitsByte = (BitsByte) binaryReader.ReadByte(); for (int key = 0; key < 2; ++key) player1.hideVisibleAccessory[key + 8] = bitsByte[key]; } else if (num1 >= 83) { BitsByte bitsByte = (BitsByte) binaryReader.ReadByte(); for (int key = 0; key < 8; ++key) player1.hideVisibleAccessory[key] = bitsByte[key]; } if (num1 >= 119) player1.hideMisc = (BitsByte) binaryReader.ReadByte(); if (num1 <= 17) player1.Male = player1.hair != 5 && player1.hair != 6 && player1.hair != 9 && player1.hair != 11; else if (num1 < 107) player1.Male = binaryReader.ReadBoolean(); else player1.skinVariant = (int) binaryReader.ReadByte(); if (num1 < 161 && player1.skinVariant == 7) player1.skinVariant = 9; player1.statLife = binaryReader.ReadInt32(); player1.statLifeMax = binaryReader.ReadInt32(); if (player1.statLifeMax > 500) player1.statLifeMax = 500; player1.statMana = binaryReader.ReadInt32(); player1.statManaMax = binaryReader.ReadInt32(); if (player1.statManaMax > 200) player1.statManaMax = 200; if (player1.statMana > 400) player1.statMana = 400; if (num1 >= 125) player1.extraAccessory = binaryReader.ReadBoolean(); if (num1 >= 229) { player1.unlockedBiomeTorches = binaryReader.ReadBoolean(); player1.UsingBiomeTorches = binaryReader.ReadBoolean(); } if (num1 >= 182) player1.downedDD2EventAnyDifficulty = binaryReader.ReadBoolean(); if (num1 >= 128) player1.taxMoney = binaryReader.ReadInt32(); player1.hairColor = binaryReader.ReadRGB(); player1.skinColor = binaryReader.ReadRGB(); player1.eyeColor = binaryReader.ReadRGB(); player1.shirtColor = binaryReader.ReadRGB(); player1.underShirtColor = binaryReader.ReadRGB(); player1.pantsColor = binaryReader.ReadRGB(); player1.shoeColor = binaryReader.ReadRGB(); Main.player[Main.myPlayer].shirtColor = player1.shirtColor; Main.player[Main.myPlayer].pantsColor = player1.pantsColor; Main.player[Main.myPlayer].hairColor = player1.hairColor; if (num1 >= 38) { if (num1 < 124) { int num2 = 11; if (num1 >= 81) num2 = 16; for (int index1 = 0; index1 < num2; ++index1) { int index2 = index1; if (index2 >= 8) index2 += 2; player1.armor[index2].netDefaults(binaryReader.ReadInt32()); player1.armor[index2].Prefix((int) binaryReader.ReadByte()); } } else { int num3 = 20; for (int index = 0; index < num3; ++index) { player1.armor[index].netDefaults(binaryReader.ReadInt32()); player1.armor[index].Prefix((int) binaryReader.ReadByte()); } } if (num1 >= 47) { int num4 = 3; if (num1 >= 81) num4 = 8; if (num1 >= 124) num4 = 10; for (int index3 = 0; index3 < num4; ++index3) { int index4 = index3; player1.dye[index4].netDefaults(binaryReader.ReadInt32()); player1.dye[index4].Prefix((int) binaryReader.ReadByte()); } } if (num1 >= 58) { for (int index = 0; index < 58; ++index) { int type = binaryReader.ReadInt32(); if (type >= 5045) { player1.inventory[index].netDefaults(0); binaryReader.ReadInt32(); int num5 = (int) binaryReader.ReadByte(); if (num1 >= 114) binaryReader.ReadBoolean(); } else { player1.inventory[index].netDefaults(type); player1.inventory[index].stack = binaryReader.ReadInt32(); player1.inventory[index].Prefix((int) binaryReader.ReadByte()); if (num1 >= 114) player1.inventory[index].favorited = binaryReader.ReadBoolean(); } } } else { for (int index = 0; index < 48; ++index) { int type = binaryReader.ReadInt32(); if (type >= 5045) { player1.inventory[index].netDefaults(0); binaryReader.ReadInt32(); int num6 = (int) binaryReader.ReadByte(); } else { player1.inventory[index].netDefaults(type); player1.inventory[index].stack = binaryReader.ReadInt32(); player1.inventory[index].Prefix((int) binaryReader.ReadByte()); } } } if (num1 >= 117) { if (num1 < 136) { for (int index = 0; index < 5; ++index) { if (index != 1) { int type1 = binaryReader.ReadInt32(); if (type1 >= 5045) { player1.miscEquips[index].netDefaults(0); int num7 = (int) binaryReader.ReadByte(); } else { player1.miscEquips[index].netDefaults(type1); player1.miscEquips[index].Prefix((int) binaryReader.ReadByte()); } int type2 = binaryReader.ReadInt32(); if (type2 >= 5045) { player1.miscDyes[index].netDefaults(0); int num8 = (int) binaryReader.ReadByte(); } else { player1.miscDyes[index].netDefaults(type2); player1.miscDyes[index].Prefix((int) binaryReader.ReadByte()); } } } } else { for (int index = 0; index < 5; ++index) { int type3 = binaryReader.ReadInt32(); if (type3 >= 5045) { player1.miscEquips[index].netDefaults(0); int num9 = (int) binaryReader.ReadByte(); } else { player1.miscEquips[index].netDefaults(type3); player1.miscEquips[index].Prefix((int) binaryReader.ReadByte()); } int type4 = binaryReader.ReadInt32(); if (type4 >= 5045) { player1.miscDyes[index].netDefaults(0); int num10 = (int) binaryReader.ReadByte(); } else { player1.miscDyes[index].netDefaults(type4); player1.miscDyes[index].Prefix((int) binaryReader.ReadByte()); } } } } if (num1 >= 58) { for (int index = 0; index < 40; ++index) { player1.bank.item[index].netDefaults(binaryReader.ReadInt32()); player1.bank.item[index].stack = binaryReader.ReadInt32(); player1.bank.item[index].Prefix((int) binaryReader.ReadByte()); } for (int index = 0; index < 40; ++index) { player1.bank2.item[index].netDefaults(binaryReader.ReadInt32()); player1.bank2.item[index].stack = binaryReader.ReadInt32(); player1.bank2.item[index].Prefix((int) binaryReader.ReadByte()); } } else { for (int index = 0; index < 20; ++index) { player1.bank.item[index].netDefaults(binaryReader.ReadInt32()); player1.bank.item[index].stack = binaryReader.ReadInt32(); player1.bank.item[index].Prefix((int) binaryReader.ReadByte()); } for (int index = 0; index < 20; ++index) { player1.bank2.item[index].netDefaults(binaryReader.ReadInt32()); player1.bank2.item[index].stack = binaryReader.ReadInt32(); player1.bank2.item[index].Prefix((int) binaryReader.ReadByte()); } } if (num1 >= 182) { for (int index = 0; index < 40; ++index) { player1.bank3.item[index].netDefaults(binaryReader.ReadInt32()); player1.bank3.item[index].stack = binaryReader.ReadInt32(); player1.bank3.item[index].Prefix((int) binaryReader.ReadByte()); } } if (num1 >= 198) { for (int index = 0; index < 40; ++index) { player1.bank4.item[index].netDefaults(binaryReader.ReadInt32()); player1.bank4.item[index].stack = binaryReader.ReadInt32(); player1.bank4.item[index].Prefix((int) binaryReader.ReadByte()); } } if (num1 >= 199) player1.voidVaultInfo = (BitsByte) binaryReader.ReadByte(); } else { for (int index = 0; index < 8; ++index) { player1.armor[index].SetDefaults((int) ItemID.FromLegacyName(binaryReader.ReadString(), num1)); if (num1 >= 36) player1.armor[index].Prefix((int) binaryReader.ReadByte()); } if (num1 >= 6) { for (int index = 8; index < 11; ++index) { player1.armor[index].SetDefaults((int) ItemID.FromLegacyName(binaryReader.ReadString(), num1)); if (num1 >= 36) player1.armor[index].Prefix((int) binaryReader.ReadByte()); } } for (int index = 0; index < 44; ++index) { player1.inventory[index].SetDefaults((int) ItemID.FromLegacyName(binaryReader.ReadString(), num1)); player1.inventory[index].stack = binaryReader.ReadInt32(); if (num1 >= 36) player1.inventory[index].Prefix((int) binaryReader.ReadByte()); } if (num1 >= 15) { for (int index = 44; index < 48; ++index) { player1.inventory[index].SetDefaults((int) ItemID.FromLegacyName(binaryReader.ReadString(), num1)); player1.inventory[index].stack = binaryReader.ReadInt32(); if (num1 >= 36) player1.inventory[index].Prefix((int) binaryReader.ReadByte()); } } for (int index = 0; index < 20; ++index) { player1.bank.item[index].SetDefaults((int) ItemID.FromLegacyName(binaryReader.ReadString(), num1)); player1.bank.item[index].stack = binaryReader.ReadInt32(); if (num1 >= 36) player1.bank.item[index].Prefix((int) binaryReader.ReadByte()); } if (num1 >= 20) { for (int index = 0; index < 20; ++index) { player1.bank2.item[index].SetDefaults((int) ItemID.FromLegacyName(binaryReader.ReadString(), num1)); player1.bank2.item[index].stack = binaryReader.ReadInt32(); if (num1 >= 36) player1.bank2.item[index].Prefix((int) binaryReader.ReadByte()); } } } if (num1 < 58) { for (int index = 40; index < 48; ++index) { player1.inventory[index + 10] = player1.inventory[index].Clone(); player1.inventory[index].SetDefaults(); } } if (num1 >= 11) { int num11 = 22; if (num1 < 74) num11 = 10; for (int index = 0; index < num11; ++index) { player1.buffType[index] = binaryReader.ReadInt32(); player1.buffTime[index] = binaryReader.ReadInt32(); if (player1.buffType[index] == 0) { --index; --num11; } } } for (int index = 0; index < 200; ++index) { int num12 = binaryReader.ReadInt32(); if (num12 != -1) { player1.spX[index] = num12; player1.spY[index] = binaryReader.ReadInt32(); player1.spI[index] = binaryReader.ReadInt32(); player1.spN[index] = binaryReader.ReadString(); } else break; } if (num1 >= 16) player1.hbLocked = binaryReader.ReadBoolean(); if (num1 >= 115) { int num13 = 13; for (int index = 0; index < num13; ++index) player1.hideInfo[index] = binaryReader.ReadBoolean(); } if (num1 >= 98) player1.anglerQuestsFinished = binaryReader.ReadInt32(); if (num1 >= 162) { for (int index = 0; index < 4; ++index) player1.DpadRadial.Bindings[index] = binaryReader.ReadInt32(); } if (num1 >= 164) { int num14 = 8; if (num1 >= 167) num14 = 10; if (num1 >= 197) num14 = 11; if (num1 >= 230) num14 = 12; for (int index = 0; index < num14; ++index) player1.builderAccStatus[index] = binaryReader.ReadInt32(); if (num1 < 210) player1.builderAccStatus[0] = 1; } if (num1 >= 181) player1.bartenderQuestLog = binaryReader.ReadInt32(); if (num1 >= 200) { player1.dead = binaryReader.ReadBoolean(); if (player1.dead) player1.respawnTimer = Utils.Clamp(binaryReader.ReadInt32(), 0, 60000); } player1.lastTimePlayerWasSaved = 0L; player1.lastTimePlayerWasSaved = num1 < 202 ? DateTime.UtcNow.ToBinary() : binaryReader.ReadInt64(); if (num1 >= 206) player1.golferScoreAccumulated = binaryReader.ReadInt32(); if (num1 >= 218) player1.creativeTracker.Load(binaryReader, num1); if (num1 >= 214) player1.LoadTemporaryItemSlotContents(binaryReader); player1.savedPerPlayerFieldsThatArentInThePlayerClass = new Player.SavedPlayerDataWithAnnoyingRules(); CreativePowerManager.Instance.ResetDataForNewPlayer(player1); if (num1 >= 220) CreativePowerManager.Instance.LoadToPlayer(player1, binaryReader, num1); Player.LoadPlayer_LastMinuteFixes(player1); } } } player1.PlayerFrame(); player1.loadStatus = 0; playerFileData.Player = player1; return playerFileData; } catch { } Player player2 = new Player(); player2.loadStatus = 2; if (player1.name != "") { player2.name = player1.name; } else { string[] strArray = playerPath.Split(Path.DirectorySeparatorChar); player1.name = strArray[strArray.Length - 1].Split('.')[0]; } playerFileData.Player = player2; return playerFileData; } private static void AdjustRespawnTimerForWorldJoining(Player newPlayer) { if (Main.myPlayer != newPlayer.whoAmI || !newPlayer.dead) return; long ticks = DateTime.UtcNow.ToBinary() - newPlayer.lastTimePlayerWasSaved; if (ticks <= 0L) return; int num = Utils.Clamp((int) (Utils.Clamp(new TimeSpan(ticks).TotalSeconds, 0.0, 1000.0) * 60.0), 0, newPlayer.respawnTimer); newPlayer.respawnTimer -= num; if (newPlayer.respawnTimer != 0) return; newPlayer.dead = false; } private static void LoadPlayer_LastMinuteFixes(Player newPlayer) { newPlayer.skinVariant = (int) MathHelper.Clamp((float) newPlayer.skinVariant, 0.0f, 11f); for (int index = 3; index < 10; ++index) { int type = newPlayer.armor[index].type; if (type == 908 || type == 4874 || type == 5000) newPlayer.lavaMax += 420; if (type == 906 || type == 4038) newPlayer.lavaMax += 420; if (newPlayer.wingsLogic == 0 && newPlayer.armor[index].wingSlot >= (sbyte) 0) newPlayer.wingsLogic = (int) newPlayer.armor[index].wingSlot; if (type == 158 || type == 396 || type == 1250 || type == 1251 || type == 1252) newPlayer.noFallDmg = true; newPlayer.lavaTime = newPlayer.lavaMax; } } public static PlayerFileData GetFileData(string file, bool cloudSave) { if (file == null || cloudSave && SocialAPI.Cloud == null) return (PlayerFileData) null; PlayerFileData playerFileData = Player.LoadPlayer(file, cloudSave); if (playerFileData.Player == null) return (PlayerFileData) null; if (playerFileData.Player.loadStatus != 0 && playerFileData.Player.loadStatus != 1) { if (FileUtilities.Exists(file + ".bak", cloudSave)) FileUtilities.Move(file + ".bak", file, cloudSave); playerFileData = Player.LoadPlayer(file, cloudSave); if (playerFileData.Player == null) return (PlayerFileData) null; } return playerFileData; } public Color GetHairColor(bool useLighting = true) { Color color = Lighting.GetColor((int) ((double) this.position.X + (double) this.width * 0.5) / 16, (int) (((double) this.position.Y + (double) this.height * 0.25) / 16.0)); return GameShaders.Hair.GetColor((short) this.hairDye, this, useLighting ? color : Color.White); } public bool HasItem(int type) { for (int index = 0; index < 58; ++index) { if (type == this.inventory[index].type && this.inventory[index].stack > 0) return true; } return false; } public int FindItem(int netid) { for (int index = 0; index < 58; ++index) { if (netid == this.inventory[index].netID && this.inventory[index].stack > 0) return index; } return -1; } public int FindItem(List netids) { for (int index = 0; index < 58; ++index) { if (this.inventory[index].stack > 0 && netids.Contains(this.inventory[index].netID)) return index; } return -1; } public int FindItem(bool[] validtypes) { for (int index = 0; index < 58; ++index) { if (this.inventory[index].stack > 0 && validtypes[this.inventory[index].type]) return index; } return -1; } public Player() { this.width = 20; this.height = 42; this.name = string.Empty; this.bodyFrame.Width = 40; this.bodyFrame.Height = 56; this.legFrame.Width = 40; this.legFrame.Height = 56; this.tileEntityAnchor.Clear(); this.doorHelper = new DoorOpeningHelper(); for (int index = 0; index < 59; ++index) { if (index < this.armor.Length) this.armor[index] = new Item(); this.inventory[index] = new Item(); } for (int index = 0; index < 40; ++index) { this.bank.item[index] = new Item(); this.bank2.item[index] = new Item(); this.bank3.item[index] = new Item(); this.bank4.item[index] = new Item(); } for (int index = 0; index < this.dye.Length; ++index) this.dye[index] = new Item(); for (int index = 0; index < this.miscEquips.Length; ++index) this.miscEquips[index] = new Item(); for (int index = 0; index < this.miscDyes.Length; ++index) this.miscDyes[index] = new Item(); this.trashItem = new Item(); this.lastVisualizedSelectedItem = new Item(); this.grappling[0] = -1; this.statManaMax = 20; this.extraAccessory = false; for (int index = 0; index < 623; ++index) { this.adjTile[index] = false; this.oldAdjTile[index] = false; } this.hitTile = new HitTile(); this.hitReplace = new HitTile(); this.mount = new Mount(); this.talkNPC = -1; this.creativeTracker = new CreativeUnlocksTracker(); } public void MagicConch() { bool flag1 = (double) this.position.X / 16.0 < (double) (Main.maxTilesX / 2); int num1 = 50; int num2 = 50; int num3 = WorldGen.beachDistance - num1 - num2; int num4 = !flag1 ? num3 - num2 / 2 : Main.maxTilesX - num3 - 1 - num2; double num5 = (double) Main.maxTilesY / 1200.0; double num6 = (double) Main.maxTilesY / 1200.0; Player.RandomTeleportationAttemptSettings teleportationAttemptSettings = new Player.RandomTeleportationAttemptSettings() { avoidAnyLiquid = true, avoidHurtTiles = true, attemptsBeforeGivingUp = 1000, maximumFallDistanceFromOrignalPoint = 300 }; Vector2 vector2 = Vector2.Zero; int directionInt = flag1.ToDirectionInt(); int startX1 = flag1 ? Main.maxTilesX - 50 : 50; bool flag2 = true; Point landingPoint; if (!TeleportHelpers.RequestMagicConchTeleportPosition(this, -directionInt, startX1, out landingPoint)) { flag2 = false; int startX2 = !flag1 ? Main.maxTilesX - 50 : 50; if (TeleportHelpers.RequestMagicConchTeleportPosition(this, directionInt, startX2, out landingPoint)) flag2 = true; } if (flag2) vector2 = landingPoint.ToWorldCoordinates(autoAddY: 16f) - new Vector2((float) (this.width / 2), (float) this.height); if (flag2) { Vector2 newPos = vector2; this.Teleport(newPos, 5); this.velocity = Vector2.Zero; if (Main.netMode != 2) return; RemoteClient.CheckSection(this.whoAmI, this.position); NetMessage.SendData(65, number2: ((float) this.whoAmI), number3: newPos.X, number4: newPos.Y, number5: 5); } else { Vector2 position = this.position; this.Teleport(position, 5); this.velocity = Vector2.Zero; if (Main.netMode != 2) return; RemoteClient.CheckSection(this.whoAmI, this.position); NetMessage.SendData(65, number2: ((float) this.whoAmI), number3: position.X, number4: position.Y, number5: 5, number6: 1); } } public void DemonConch() { bool canSpawn = false; int num = Main.maxTilesX / 2; int teleportRangeX1 = 100; int teleportRangeX2 = teleportRangeX1 / 2; int teleportStartY = Main.UnderworldLayer + 20; int teleportRangeY = 80; Player.RandomTeleportationAttemptSettings settings = new Player.RandomTeleportationAttemptSettings() { mostlySolidFloor = true, avoidAnyLiquid = true, avoidLava = true, avoidHurtTiles = true, avoidWalls = true, attemptsBeforeGivingUp = 1000, maximumFallDistanceFromOrignalPoint = 30 }; Vector2 vector2 = this.CheckForGoodTeleportationSpot(ref canSpawn, num - teleportRangeX2, teleportRangeX1, teleportStartY, teleportRangeY, settings); if (!canSpawn) vector2 = this.CheckForGoodTeleportationSpot(ref canSpawn, num - teleportRangeX1, teleportRangeX2, teleportStartY, teleportRangeY, settings); if (!canSpawn) vector2 = this.CheckForGoodTeleportationSpot(ref canSpawn, num + teleportRangeX2, teleportRangeX2, teleportStartY, teleportRangeY, settings); if (canSpawn) { Vector2 newPos = vector2; this.Teleport(newPos, 7); this.velocity = Vector2.Zero; if (Main.netMode != 2) return; RemoteClient.CheckSection(this.whoAmI, this.position); NetMessage.SendData(65, number2: ((float) this.whoAmI), number3: newPos.X, number4: newPos.Y, number5: 7); } else { Vector2 position = this.position; this.Teleport(position, 7); this.velocity = Vector2.Zero; if (Main.netMode != 2) return; RemoteClient.CheckSection(this.whoAmI, this.position); NetMessage.SendData(65, number2: ((float) this.whoAmI), number3: position.X, number4: position.Y, number5: 7, number6: 1); } } public void TeleportationPotion() { bool canSpawn = false; int teleportStartX = 100; int teleportRangeX = Main.maxTilesX - 200; int teleportStartY = 100; int underworldLayer = Main.UnderworldLayer; Vector2 vector2 = this.CheckForGoodTeleportationSpot(ref canSpawn, teleportStartX, teleportRangeX, teleportStartY, underworldLayer, new Player.RandomTeleportationAttemptSettings() { avoidLava = true, avoidHurtTiles = true, maximumFallDistanceFromOrignalPoint = 100, attemptsBeforeGivingUp = 1000 }); if (canSpawn) { Vector2 newPos = vector2; this.Teleport(newPos, 2); this.velocity = Vector2.Zero; if (Main.netMode != 2) return; RemoteClient.CheckSection(this.whoAmI, this.position); NetMessage.SendData(65, number2: ((float) this.whoAmI), number3: newPos.X, number4: newPos.Y, number5: 2); } else { Vector2 position = this.position; this.Teleport(position, 2); this.velocity = Vector2.Zero; if (Main.netMode != 2) return; RemoteClient.CheckSection(this.whoAmI, this.position); NetMessage.SendData(65, number2: ((float) this.whoAmI), number3: position.X, number4: position.Y, number5: 2, number6: 1); } } private Vector2 CheckForGoodTeleportationSpot( ref bool canSpawn, int teleportStartX, int teleportRangeX, int teleportStartY, int teleportRangeY, Player.RandomTeleportationAttemptSettings settings) { int num1 = 0; int num2 = 0; int num3 = 0; int width = this.width; Vector2 Position = new Vector2((float) num2, (float) num3) * 16f + new Vector2((float) (-width / 2 + 8), (float) -this.height); while (!canSpawn && num1 < settings.attemptsBeforeGivingUp) { ++num1; int num4 = teleportStartX + Main.rand.Next(teleportRangeX); int num5 = teleportStartY + Main.rand.Next(teleportRangeY); int num6 = 5; int index1 = (int) MathHelper.Clamp((float) num4, (float) num6, (float) (Main.maxTilesX - num6)); int index2 = (int) MathHelper.Clamp((float) num5, (float) num6, (float) (Main.maxTilesY - num6)); Position = new Vector2((float) index1, (float) index2) * 16f + new Vector2((float) (-width / 2 + 8), (float) -this.height); if (!Collision.SolidCollision(Position, width, this.height)) { if (Main.tile[index1, index2] == null) Main.tile[index1, index2] = new Tile(); if ((!settings.avoidWalls || Main.tile[index1, index2].wall <= (ushort) 0) && (Main.tile[index1, index2].wall != (ushort) 87 || (double) index2 <= Main.worldSurface || NPC.downedPlantBoss) && (!Main.wallDungeon[(int) Main.tile[index1, index2].wall] || (double) index2 <= Main.worldSurface || NPC.downedBoss3)) { int num7 = 0; while (num7 < settings.maximumFallDistanceFromOrignalPoint) { if (Main.tile[index1, index2 + num7] == null) Main.tile[index1, index2 + num7] = new Tile(); Tile tile = Main.tile[index1, index2 + num7]; Position = new Vector2((float) index1, (float) (index2 + num7)) * 16f + new Vector2((float) (-width / 2 + 8), (float) -this.height); Collision.SlopeCollision(Position, this.velocity, width, this.height, this.gravDir); if (!Collision.SolidCollision(Position, width, this.height)) ++num7; else if (!tile.active() || tile.inActive() || !Main.tileSolid[(int) tile.type]) ++num7; else break; } Position.Y -= 16f; int i1 = (int) Position.X / 16; int j1 = (int) Position.Y / 16; int i2 = (int) ((double) Position.X + (double) width * 0.5) / 16; int j2 = (int) ((double) Position.Y + (double) this.height) / 16; Tile tileSafely1 = Framing.GetTileSafely(i1, j1); Tile tileSafely2 = Framing.GetTileSafely(i2, j2); if (!settings.avoidAnyLiquid || tileSafely2.liquid <= (byte) 0) { if (settings.mostlySolidFloor) { Tile tileSafely3 = Framing.GetTileSafely(i2 - 1, j2); Tile tileSafely4 = Framing.GetTileSafely(i2 + 1, j2); if ((!tileSafely3.active() || tileSafely3.inActive() || !Main.tileSolid[(int) tileSafely3.type] || Main.tileSolidTop[(int) tileSafely3.type] || !tileSafely4.active() || tileSafely4.inActive() || !Main.tileSolid[(int) tileSafely4.type] ? 0 : (!Main.tileSolidTop[(int) tileSafely4.type] ? 1 : 0)) == 0) continue; } if ((!settings.avoidWalls || tileSafely1.wall <= (ushort) 0) && (!settings.avoidAnyLiquid || !Collision.WetCollision(Position, width, this.height)) && (!settings.avoidLava || !Collision.LavaCollision(Position, width, this.height)) && (!settings.avoidHurtTiles || (double) Collision.HurtTiles(Position, this.velocity, width, this.height).Y <= 0.0) && !Collision.SolidCollision(Position, width, this.height) && num7 < settings.maximumFallDistanceFromOrignalPoint - 1) { Vector2 Velocity1 = Vector2.UnitX * 16f; if (!(Collision.TileCollision(Position - Velocity1, Velocity1, this.width, this.height, gravDir: ((int) this.gravDir)) != Velocity1)) { Vector2 Velocity2 = -Vector2.UnitX * 16f; if (!(Collision.TileCollision(Position - Velocity2, Velocity2, this.width, this.height, gravDir: ((int) this.gravDir)) != Velocity2)) { Vector2 Velocity3 = Vector2.UnitY * 16f; if (!(Collision.TileCollision(Position - Velocity3, Velocity3, this.width, this.height, gravDir: ((int) this.gravDir)) != Velocity3)) { Vector2 Velocity4 = -Vector2.UnitY * 16f; if (!(Collision.TileCollision(Position - Velocity4, Velocity4, this.width, this.height, gravDir: ((int) this.gravDir)) != Velocity4)) { canSpawn = true; int num8 = index2 + num7; break; } } } } } } } } } return Position; } public void GetAnglerReward() { Item newItem1 = new Item(); newItem1.type = 0; int anglerQuestsFinished = this.anglerQuestsFinished; float num1 = 1f; float num2 = (anglerQuestsFinished > 50 ? (anglerQuestsFinished > 100 ? (anglerQuestsFinished > 150 ? 0.15f : (float) (0.25 - (double) (anglerQuestsFinished - 100) * (1.0 / 500.0))) : (float) (0.5 - (double) (anglerQuestsFinished - 50) * 0.00499999988824129)) : num1 - (float) anglerQuestsFinished * 0.01f) * 0.9f * ((float) (this.currentShoppingSettings.PriceAdjustment + 1.0) / 2f); switch (anglerQuestsFinished) { case 5: newItem1.SetDefaults(2428); break; case 10: newItem1.SetDefaults(2367); break; case 15: newItem1.SetDefaults(2368); break; case 20: newItem1.SetDefaults(2369); break; case 30: newItem1.SetDefaults(2294); break; default: List itemIdsOfAccsWeWant1 = new List() { 2373, 2374, 2375 }; List itemIdsOfAccsWeWant2 = new List() { 3120, 3037, 3096 }; if (anglerQuestsFinished > 75 && Main.rand.Next((int) (250.0 * (double) num2)) == 0) { newItem1.SetDefaults(2294); break; } if (Main.hardMode && anglerQuestsFinished > 25 && Main.rand.Next((int) (100.0 * (double) num2)) == 0) { newItem1.SetDefaults(2422); break; } if (Main.hardMode && anglerQuestsFinished > 10 && Main.rand.Next((int) (70.0 * (double) num2)) == 0) { newItem1.SetDefaults(2494); break; } if (Main.hardMode && anglerQuestsFinished > 10 && Main.rand.Next((int) (70.0 * (double) num2)) == 0) { newItem1.SetDefaults(3031); break; } if (Main.hardMode && anglerQuestsFinished > 10 && Main.rand.Next((int) (70.0 * (double) num2)) == 0) { newItem1.SetDefaults(3032); break; } if (Main.rand.Next((int) (80.0 * (double) num2)) == 0) { newItem1.SetDefaults(3183); break; } if (Main.rand.Next((int) (60.0 * (double) num2)) == 0) { newItem1.SetDefaults(2360); break; } if (Main.rand.Next((int) (60.0 * (double) num2)) == 0) { newItem1.SetDefaults(4067); break; } bool botheredRollingForADrop1; int itemIdToDrop1; if (this.DropAnglerAccByMissing(itemIdsOfAccsWeWant1, (int) (40.0 * (double) num2), out botheredRollingForADrop1, out itemIdToDrop1)) { newItem1.SetDefaults(itemIdToDrop1); break; } if (!botheredRollingForADrop1 && Main.rand.Next((int) (40.0 * (double) num2)) == 0) { newItem1.SetDefaults(2373); break; } if (!botheredRollingForADrop1 && Main.rand.Next((int) (40.0 * (double) num2)) == 0) { newItem1.SetDefaults(2374); break; } if (!botheredRollingForADrop1 && Main.rand.Next((int) (40.0 * (double) num2)) == 0) { newItem1.SetDefaults(2375); break; } bool botheredRollingForADrop2; int itemIdToDrop2; if (this.DropAnglerAccByMissing(itemIdsOfAccsWeWant2, (int) (30.0 * (double) num2), out botheredRollingForADrop2, out itemIdToDrop2)) { newItem1.SetDefaults(itemIdToDrop2); break; } if (!botheredRollingForADrop2 && Main.rand.Next((int) (30.0 * (double) num2)) == 0) { newItem1.SetDefaults(3120); break; } if (!botheredRollingForADrop2 && Main.rand.Next((int) (30.0 * (double) num2)) == 0) { newItem1.SetDefaults(3037); break; } if (!botheredRollingForADrop2 && Main.rand.Next((int) (30.0 * (double) num2)) == 0) { newItem1.SetDefaults(3096); break; } if (Main.rand.Next((int) (40.0 * (double) num2)) == 0) { newItem1.SetDefaults(2417); break; } if (Main.rand.Next((int) (40.0 * (double) num2)) == 0) { newItem1.SetDefaults(2498); break; } switch (Main.rand.Next(70)) { case 0: newItem1.SetDefaults(2442); break; case 1: newItem1.SetDefaults(2443); break; case 2: newItem1.SetDefaults(2444); break; case 3: newItem1.SetDefaults(2445); break; case 4: newItem1.SetDefaults(2497); break; case 5: newItem1.SetDefaults(2495); break; case 6: newItem1.SetDefaults(2446); break; case 7: newItem1.SetDefaults(2447); break; case 8: newItem1.SetDefaults(2448); break; case 9: newItem1.SetDefaults(2449); break; case 10: newItem1.SetDefaults(2490); break; case 12: newItem1.SetDefaults(2496); break; default: switch (Main.rand.Next(3)) { case 0: newItem1.SetDefaults(2354); newItem1.stack = Main.rand.Next(2, 6); break; case 1: newItem1.SetDefaults(2355); newItem1.stack = Main.rand.Next(2, 6); break; default: newItem1.SetDefaults(2356); newItem1.stack = Main.rand.Next(2, 6); break; } break; } break; } newItem1.position = this.Center; GetItemSettings inventorySettings = GetItemSettings.NPCEntityToPlayerInventorySettings; Item obj1 = this.GetItem(this.whoAmI, newItem1, inventorySettings); if (obj1.stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, obj1.type, obj1.stack, noGrabDelay: true); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); } if (newItem1.type == 2417) { Item newItem2 = new Item(); Item newItem3 = new Item(); newItem2.SetDefaults(2418); newItem2.position = this.Center; Item obj2 = this.GetItem(this.whoAmI, newItem2, inventorySettings); if (obj2.stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, obj2.type, obj2.stack, noGrabDelay: true); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); } newItem3.SetDefaults(2419); newItem3.position = this.Center; Item obj3 = this.GetItem(this.whoAmI, newItem3, inventorySettings); if (obj3.stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, obj3.type, obj3.stack, noGrabDelay: true); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); } } else if (newItem1.type == 2498) { Item newItem4 = new Item(); Item newItem5 = new Item(); newItem4.SetDefaults(2499); newItem4.position = this.Center; Item obj4 = this.GetItem(this.whoAmI, newItem4, inventorySettings); if (obj4.stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, obj4.type, obj4.stack, noGrabDelay: true); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); } newItem5.SetDefaults(2500); newItem5.position = this.Center; Item obj5 = this.GetItem(this.whoAmI, newItem5, inventorySettings); if (obj5.stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, obj5.type, obj5.stack, noGrabDelay: true); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); } } Item newItem6 = new Item(); int num3 = (int) ((double) (int) ((double) ((anglerQuestsFinished + 50) / 2 * Main.rand.Next(50, 201)) * 0.0149999996647239) * 1.5); if (Main.expertMode) num3 *= 2; if (num3 > 100) { int num4 = num3 / 100; if (num4 > 10) num4 = 10; if (num4 < 1) num4 = 1; newItem6.SetDefaults(73); newItem6.stack = num4; } else { if (num3 > 99) num3 = 99; if (num3 < 1) num3 = 1; newItem6.SetDefaults(72); newItem6.stack = num3; } newItem6.position = this.Center; Item obj6 = this.GetItem(this.whoAmI, newItem6, inventorySettings); if (obj6.stack > 0) { int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, obj6.type, obj6.stack, noGrabDelay: true); if (Main.netMode == 1) NetMessage.SendData(21, number: number, number2: 1f); } if (Main.rand.Next((int) (100.0 * (double) num2)) > 50) return; Item newItem7 = new Item(); if (Main.rand.Next((int) (15.0 * (double) num2)) == 0) newItem7.SetDefaults(2676); else if (Main.rand.Next((int) (5.0 * (double) num2)) == 0) newItem7.SetDefaults(2675); else newItem7.SetDefaults(2674); if (Main.rand.Next(25) <= anglerQuestsFinished) ++newItem7.stack; if (Main.rand.Next(50) <= anglerQuestsFinished) ++newItem7.stack; if (Main.rand.Next(100) <= anglerQuestsFinished) ++newItem7.stack; if (Main.rand.Next(150) <= anglerQuestsFinished) ++newItem7.stack; if (Main.rand.Next(200) <= anglerQuestsFinished) ++newItem7.stack; if (Main.rand.Next(250) <= anglerQuestsFinished) ++newItem7.stack; newItem7.position = this.Center; Item obj7 = this.GetItem(this.whoAmI, newItem7, GetItemSettings.NPCEntityToPlayerInventorySettings); if (obj7.stack <= 0) return; int number1 = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, obj7.type, obj7.stack, noGrabDelay: true); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number1, number2: 1f); } public bool DropAnglerAccByMissing( List itemIdsOfAccsWeWant, int randomChanceForASingleAcc, out bool botheredRollingForADrop, out int itemIdToDrop) { botheredRollingForADrop = false; itemIdToDrop = 0; foreach (Item itemToTestAgainst in this.inventory) this.RemoveAnglerAccOptionsFromRewardPool(itemIdsOfAccsWeWant, itemToTestAgainst); foreach (Item itemToTestAgainst in this.armor) this.RemoveAnglerAccOptionsFromRewardPool(itemIdsOfAccsWeWant, itemToTestAgainst); foreach (Item itemToTestAgainst in this.bank.item) this.RemoveAnglerAccOptionsFromRewardPool(itemIdsOfAccsWeWant, itemToTestAgainst); foreach (Item itemToTestAgainst in this.bank2.item) this.RemoveAnglerAccOptionsFromRewardPool(itemIdsOfAccsWeWant, itemToTestAgainst); foreach (Item itemToTestAgainst in this.bank3.item) this.RemoveAnglerAccOptionsFromRewardPool(itemIdsOfAccsWeWant, itemToTestAgainst); foreach (Item itemToTestAgainst in this.bank4.item) this.RemoveAnglerAccOptionsFromRewardPool(itemIdsOfAccsWeWant, itemToTestAgainst); if (itemIdsOfAccsWeWant.Count == 0) return false; bool flag = false; for (int index = 0; index < itemIdsOfAccsWeWant.Count; ++index) flag |= Main.rand.Next(randomChanceForASingleAcc) == 0; botheredRollingForADrop = true; if (!flag) return false; itemIdToDrop = Main.rand.NextFromList(itemIdsOfAccsWeWant.ToArray()); return true; } private void RemoveAnglerAccOptionsFromRewardPool( List itemIdsOfAccsWeWant, Item itemToTestAgainst) { if (itemToTestAgainst.IsAir) return; switch (itemToTestAgainst.type) { case 3036: case 3123: case 3124: itemIdsOfAccsWeWant.Remove(3120); itemIdsOfAccsWeWant.Remove(3037); itemIdsOfAccsWeWant.Remove(3096); break; case 3721: itemIdsOfAccsWeWant.Remove(2373); itemIdsOfAccsWeWant.Remove(2375); itemIdsOfAccsWeWant.Remove(2374); break; default: itemIdsOfAccsWeWant.Remove(itemToTestAgainst.type); break; } } public void GetDyeTraderReward() { List intList = new List() { 3560, 3028, 3041, 3040, 3025, 3190, 3027, 3026, 3554, 3553, 3555, 2872, 3534, 2871 }; if (Main.hardMode) { intList.Add(3039); intList.Add(3038); intList.Add(3598); intList.Add(3597); intList.Add(3600); intList.Add(3042); intList.Add(3533); intList.Add(3561); if (NPC.downedMechBossAny) { intList.Add(2883); intList.Add(2869); intList.Add(2873); intList.Add(2870); } if (NPC.downedPlantBoss) { intList.Add(2878); intList.Add(2879); intList.Add(2884); intList.Add(2885); } if (NPC.downedMartians) { intList.Add(2864); intList.Add(3556); } if (NPC.downedMoonlord) intList.Add(3024); } int Type = intList[Main.rand.Next(intList.Count)]; Item newItem = new Item(); newItem.SetDefaults(Type); newItem.stack = 3; newItem.position = this.Center; Item obj = this.GetItem(this.whoAmI, newItem, GetItemSettings.NPCEntityToPlayerInventorySettings); if (obj.stack <= 0) return; int number = Item.NewItem((int) this.position.X, (int) this.position.Y, this.width, this.height, obj.type, obj.stack, noGrabDelay: true); if (Main.netMode != 1) return; NetMessage.SendData(21, number: number, number2: 1f); } public bool CheckMana(int amount, bool pay = false, bool blockQuickMana = false) { int num = (int) ((double) amount * (double) this.manaCost); if (this.statMana >= num) { if (pay) this.statMana -= num; return true; } if (!this.manaFlower || blockQuickMana) return false; this.QuickMana(); if (this.statMana < num) return false; if (pay) this.statMana -= num; return true; } public void TryPortalJumping() { if (this.mount.Active || this.dead || this.isLockedToATile) return; PortalHelper.TryGoingThroughPortals((Entity) this); } public bool ConsumeSolarFlare() { if (!this.setSolar || this.solarShields <= 0) return false; --this.solarShields; for (int b = 0; b < 22; ++b) { if (this.buffType[b] >= 170 && this.buffType[b] <= 172) this.DelBuff(b); } if (this.solarShields > 0 && this.whoAmI == Main.myPlayer) this.AddBuff(170 + this.solarShields - 1, 5, false); this.solarCounter = 0; return true; } public void KeyDoubleTap(int keyDir) { int num = 0; if (Main.ReversedUpDownArmorSetBonuses) num = 1; if (keyDir != num) return; if (this.setVortex && !this.mount.Active) this.vortexStealthActive = !this.vortexStealthActive; if (!this.setForbidden) return; this.MinionRestTargetAim(); if (this.setForbiddenCooldownLocked) return; this.CommandForbiddenStorm(); } public void UpdateForbiddenSetLock() { List intList = new List(); for (int index = 0; index < 1000; ++index) { Projectile projectile = Main.projectile[index]; if (projectile.active && projectile.type == 656 && projectile.owner == this.whoAmI) intList.Add(index); } this.setForbiddenCooldownLocked = intList.Count > 1; } public void CommandForbiddenStorm() { List intList = new List(); for (int index = 0; index < 1000; ++index) { Projectile projectile = Main.projectile[index]; if (projectile.active && projectile.type == 656 && projectile.owner == this.whoAmI) intList.Add(index); } bool flag1 = StrayMethods.CanSpawnSandstormFriendly(this.MinionRestTargetPoint, 30, 30); int num1 = this.MinionRestTargetPoint == Vector2.Zero ? 1 : 0; Vector2 center = this.Center; Vector2 endPoint = this.MinionRestTargetPoint; if (num1 != 0) endPoint = center; int samplesToTake = 10; float samplingWidth = 60f; Vector2 vectorTowardsTarget; float[] samples; Collision.AimingLaserScan(center, endPoint, samplingWidth, samplesToTake, out vectorTowardsTarget, out samples); bool flag2 = false; foreach (float num2 in samples) { if ((double) Math.Abs(num2 - vectorTowardsTarget.Length()) < 10.0) { flag2 = true; break; } } float num3 = 0.0f; for (int index = 0; index < samples.Length; ++index) { if ((double) samples[index] > (double) num3) num3 = samples[index]; } if (intList.Count <= 1) { Vector2 Position1 = center + vectorTowardsTarget.SafeNormalize(Vector2.Zero) * num3; Vector2 vector2 = Position1 - center; if ((double) vector2.Length() > 0.0) { for (float num4 = 0.0f; (double) num4 < (double) vector2.Length(); num4 += 15f) { Vector2 Position2 = center + vector2 * (num4 / vector2.Length()); Dust dust = Main.dust[Dust.NewDust(Position2, 0, 0, 269)]; dust.position = Position2; dust.fadeIn = 0.5f; dust.scale = 0.7f; dust.velocity *= 0.4f; dust.noLight = true; } } for (float num5 = 0.0f; (double) num5 < 6.28318548202515; num5 += 0.2094395f) { Dust dust = Main.dust[Dust.NewDust(Position1, 0, 0, 269)]; dust.position = Position1; dust.fadeIn = 1f; dust.scale = 0.3f; dust.noLight = true; } } bool flag3 = flag1 & intList.Count <= 1 & flag2; if (flag3) { flag3 = this.CheckMana(20, true); if (flag3) this.manaRegenDelay = (int) this.maxRegenDelay; } if (!flag3) return; foreach (int index in intList) { Projectile projectile = Main.projectile[index]; if ((double) projectile.ai[0] < 780.0) { projectile.ai[0] = (float) (780.0 + (double) projectile.ai[0] % 60.0); projectile.netUpdate = true; } } int Damage = (int) (20.0 * (1.0 + (double) this.magicDamage + (double) this.minionDamage - 2.0)); Projectile projectile1 = Main.projectile[Projectile.NewProjectile(this.MinionRestTargetPoint, Vector2.Zero, 656, Damage, 0.0f, Main.myPlayer)]; } public void KeyHoldDown(int keyDir, int holdTime) { int num = 0; if (Main.ReversedUpDownArmorSetBonuses) num = 1; if (keyDir != num) return; if (this.setStardust && holdTime >= 60) this.MinionRestTargetPoint = Vector2.Zero; if (!this.setForbidden || holdTime < 60) return; this.MinionRestTargetPoint = Vector2.Zero; } public void MinionNPCTargetAim(bool doNotDisableIfTheTargetIsTheSame) { Vector2 mouseWorld = Main.MouseWorld; int index1 = -1; for (int index2 = 0; index2 < 200; ++index2) { if (Main.npc[index2].CanBeChasedBy((object) this) && (index1 == -1 || (double) Main.npc[index2].Hitbox.Distance(mouseWorld) < (double) Main.npc[index1].Hitbox.Distance(mouseWorld))) index1 = index2; } if (this.MinionAttackTargetNPC == index1 && !doNotDisableIfTheTargetIsTheSame) this.MinionAttackTargetNPC = -1; else this.MinionAttackTargetNPC = index1; } public void MinionRestTargetAim() { Vector2 mouseWorld = Main.MouseWorld; float y = mouseWorld.Y; int i = (int) mouseWorld.X / 16; int index1 = (int) y / 16; int num1 = 0; if ((!Main.tile[i, index1].nactive() || !Main.tileSolid[(int) Main.tile[i, index1].type] ? 0 : (!Main.tileSolidTop[(int) Main.tile[i, index1].type] ? 1 : 0)) != 0) { int num2 = 0; for (int index2 = 0; index2 > -20 && index1 + index2 > 1; --index2) { int index3 = index1 + index2; if ((!Main.tile[i, index3].nactive() || !Main.tileSolid[(int) Main.tile[i, index3].type] ? 0 : (!Main.tileSolidTop[(int) Main.tile[i, index3].type] ? 1 : 0)) != 0) { num2 = index2; } else { num2 = index2; break; } } int num3 = 0; for (int index4 = 0; index4 < 20 && index1 + index4 < Main.maxTilesY; ++index4) { int index5 = index1 + index4; if ((!Main.tile[i, index5].nactive() || !Main.tileSolid[(int) Main.tile[i, index5].type] ? 0 : (!Main.tileSolidTop[(int) Main.tile[i, index5].type] ? 1 : 0)) != 0) { num3 = index4; } else { num3 = index4; break; } } num1 = num3 <= -num2 ? num3 + 3 : num2 - 2; } int num4 = index1 + num1; bool flag = false; for (int j = num4; j < num4 + 5; ++j) { if (WorldGen.SolidTileAllowBottomSlope(i, j)) flag = true; } while (!flag) { ++num4; for (int j = num4; j < num4 + 5; ++j) { if (WorldGen.SolidTileAllowBottomSlope(i, j)) flag = true; } } Vector2 Other = new Vector2((float) (i * 16 + 8), (float) (num4 * 16)); if ((double) this.Distance(Other) > 1000.0) return; this.MinionRestTargetPoint = Other; } public void UpdateMinionTarget() { if (this.whoAmI != Main.myPlayer) return; if ((double) this.Distance(this.MinionRestTargetPoint) > 1000.0) this.MinionRestTargetPoint = Vector2.Zero; if (this.MinionAttackTargetNPC != -1 && (!Main.npc[this.MinionAttackTargetNPC].CanBeChasedBy((object) this) || (double) Main.npc[this.MinionAttackTargetNPC].Hitbox.Distance(this.Center) > 3000.0)) this.MinionAttackTargetNPC = -1; if (!this.stardustGuardian || !this.HasMinionRestTarget) return; Vector2 minionRestTargetPoint = this.MinionRestTargetPoint; float num1 = (float) this.miscCounter / 150f; float num2 = 2.094395f; for (int index1 = 0; index1 < 3; ++index1) { int index2 = Dust.NewDust(minionRestTargetPoint, 0, 0, 135, Alpha: 100, Scale: 1.5f); Main.dust[index2].noGravity = true; Main.dust[index2].velocity = Vector2.Zero; Main.dust[index2].noLight = true; Main.dust[index2].position = minionRestTargetPoint + ((float) ((double) num1 * 6.28318548202515 + (double) num2 * (double) index1)).ToRotationVector2() * 4f; Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(this.cPet, this); } } public void NebulaLevelup(int type) { if (this.whoAmI != Main.myPlayer) return; int timeToAdd = 480; for (int b = 0; b < 22; ++b) { if (this.buffType[b] >= type && this.buffType[b] < type + 3) this.DelBuff(b); } switch (type) { case 173: this.nebulaLevelLife = (int) MathHelper.Clamp((float) (this.nebulaLevelLife + 1), 0.0f, 3f); this.AddBuff(type + this.nebulaLevelLife - 1, timeToAdd); break; case 176: this.nebulaLevelMana = (int) MathHelper.Clamp((float) (this.nebulaLevelMana + 1), 0.0f, 3f); this.AddBuff(type + this.nebulaLevelMana - 1, timeToAdd); break; case 179: this.nebulaLevelDamage = (int) MathHelper.Clamp((float) (this.nebulaLevelDamage + 1), 0.0f, 3f); this.AddBuff(type + this.nebulaLevelDamage - 1, timeToAdd); break; } } public void UpdateTouchingTiles() { this.TouchedTiles.Clear(); List pointList1 = (List) null; List pointList2 = (List) null; if (!Collision.IsClearSpotTest(this.position + this.velocity, 16f, this.width, this.height, gravDir: ((int) this.gravDir), checkSlopes: true)) pointList1 = Collision.FindCollisionTile(Math.Sign(this.velocity.Y) == 1 ? 2 : 3, this.position + this.velocity, 16f, this.width, this.height, gravDir: ((int) this.gravDir)); if (!Collision.IsClearSpotTest(this.position, Math.Abs(this.velocity.Y), this.width, this.height, gravDir: ((int) this.gravDir), checkSlopes: true)) pointList2 = Collision.FindCollisionTile(Math.Sign(this.velocity.Y) == 1 ? 2 : 3, this.position, Math.Abs(this.velocity.Y), this.width, this.height, gravDir: ((int) this.gravDir), checkSlopes: true); if (pointList1 != null && pointList2 != null) { for (int index = 0; index < pointList2.Count; ++index) { if (!pointList1.Contains(pointList2[index])) pointList1.Add(pointList2[index]); } } if (pointList1 == null && pointList2 != null) pointList1 = pointList2; if (pointList1 == null) return; this.TouchedTiles = pointList1; } public static class BuilderAccToggleIDs { public const int RulerLine = 0; public const int RulerGrid = 1; public const int AutoActuate = 2; public const int AutoPaint = 3; public const int WireVisibility_Red = 4; public const int WireVisibility_Green = 5; public const int WireVisibility_Blue = 6; public const int WireVisibility_Yellow = 7; public const int HideAllWires = 8; public const int WireVisibility_Actuators = 9; public const int BlockSwap = 10; public const int TorchBiome = 11; public const int Count = 12; } public struct RabbitOrderFrameHelper { public int DisplayFrame; private int _frameCounter; private int _aiState; private const int AIState_Idle = 0; private const int AIState_LookingAtCamera = 1; private const int AIState_Resting = 2; private const int AIState_EatingCarrot = 3; public void Update() { switch (this._aiState) { case 0: this.UpdateFrame(0, 0, Main.rand.Next(1, 4), Main.rand.Next(180, 3600)); break; case 1: this.UpdateFrame(7, 9, 0, 20); break; case 2: int gameFramesPerDisplayFrame = 8; if (this.DisplayFrame == 13) gameFramesPerDisplayFrame = 120; this.UpdateFrame(10, 16, 0, gameFramesPerDisplayFrame); break; case 3: this.UpdateFrame(17, 26, 0, 4); break; } } public void Reset() => this.ChangeToAIState(0); private void ChangeToAIState(int aiState) { this._aiState = aiState; this._frameCounter = 0; this.Update(); } private void UpdateFrame( int displayFrameMin, int displayFrameMax, int exitAIState, int gameFramesPerDisplayFrame) { this.DisplayFrame = Utils.Clamp(this.DisplayFrame, displayFrameMin, displayFrameMax); if (this._frameCounter++ < gameFramesPerDisplayFrame) return; this._frameCounter = 0; if (this.DisplayFrame++ < displayFrameMax) return; this.ChangeToAIState(exitAIState); } } public enum CompositeArmStretchAmount { Full, None, Quarter, ThreeQuarters, } public struct CompositeArmData { public bool enabled; public Player.CompositeArmStretchAmount stretch; public float rotation; public CompositeArmData( bool enabled, Player.CompositeArmStretchAmount intendedStrech, float rotation) { this.enabled = enabled; this.stretch = intendedStrech; this.rotation = rotation; } } public struct ItemSpaceStatus { public readonly bool CanTakeItem; public readonly bool ItemIsGoingToVoidVault; public bool CanTakeItemToPersonalInventory => this.CanTakeItem && !this.ItemIsGoingToVoidVault; public ItemSpaceStatus(bool CanTakeItem, bool ItemIsGoingToVoidVault = false) { this.CanTakeItem = CanTakeItem; this.ItemIsGoingToVoidVault = ItemIsGoingToVoidVault; } } private struct SpecialToolUsageSettings { public bool IsAValidTool; public Player.SpecialToolUsageSettings.CanUseToolCondition UsageCondition; public Player.SpecialToolUsageSettings.UseToolAction UsageAction; public delegate bool CanUseToolCondition(Player user, Item item, int targetX, int targetY); public delegate void UseToolAction(Player user, Item item, int targetX, int targetY); } public class SavedPlayerDataWithAnnoyingRules { public bool godmodePowerEnabled; public bool farPlacementRangePowerEnabled; public float spawnRatePowerSliderValue; } private class RandomTeleportationAttemptSettings { public bool mostlySolidFloor; public bool avoidLava; public bool avoidAnyLiquid; public bool avoidHurtTiles; public bool avoidWalls; public int attemptsBeforeGivingUp; public int maximumFallDistanceFromOrignalPoint; } public static class Hooks { public static event Action OnEnterWorld; public static void PlayerConnect(int playerIndex) => PressurePlateHelper.ResetPlayer(playerIndex); public static void PlayerDisconnect(int playerIndex) => PressurePlateHelper.ResetPlayer(playerIndex); public static void EnterWorld(int playerIndex) { if (Player.Hooks.OnEnterWorld == null) return; Player.Hooks.OnEnterWorld(Main.player[playerIndex]); } } public class SmartCursorSettings { public static bool SmartBlocksEnabled; public static bool SmartAxeAfterPickaxe; } public class Settings { public static Player.Settings.HoverControlMode HoverControl; public static void CycleHoverControl() { switch (Player.Settings.HoverControl) { case Player.Settings.HoverControlMode.Hold: Player.Settings.HoverControl = Player.Settings.HoverControlMode.Click; break; case Player.Settings.HoverControlMode.Click: Player.Settings.HoverControl = Player.Settings.HoverControlMode.Hold; break; } } public enum HoverControlMode { Hold, Click, } } public class SelectionRadial { private int _SelectedBinding = -1; public int RadialCount; public int[] Bindings; public Player.SelectionRadial.SelectionMode Mode; public int SelectedBinding => this._SelectedBinding; public int SelectedItem => this._SelectedBinding == -1 ? -1 : this.Bindings[this._SelectedBinding]; public SelectionRadial(Player.SelectionRadial.SelectionMode mode = Player.SelectionRadial.SelectionMode.Dpad4) { this.Mode = mode; int num = 0; switch (mode) { case Player.SelectionRadial.SelectionMode.Dpad4: num = 4; break; case Player.SelectionRadial.SelectionMode.RadialCircular: num = 10; break; case Player.SelectionRadial.SelectionMode.RadialQuicks: num = 4; break; } this.RadialCount = num; this.Bindings = new int[this.RadialCount]; for (int index = 0; index < this.RadialCount; ++index) this.Bindings[index] = -1; } public void Update() { switch (this.Mode) { case Player.SelectionRadial.SelectionMode.Dpad4: if (PlayerInput.Triggers.JustPressed.DpadRadial1) this.ChangeSelection(0); if (PlayerInput.Triggers.JustPressed.DpadRadial2) this.ChangeSelection(1); if (PlayerInput.Triggers.JustPressed.DpadRadial3) this.ChangeSelection(2); if (!PlayerInput.Triggers.JustPressed.DpadRadial4) break; this.ChangeSelection(3); break; case Player.SelectionRadial.SelectionMode.RadialCircular: case Player.SelectionRadial.SelectionMode.RadialQuicks: for (int index = 0; index < this.RadialCount; ++index) this.Bindings[index] = index; if ((this.Mode != Player.SelectionRadial.SelectionMode.RadialCircular || !PlayerInput.Triggers.Current.RadialHotbar ? (this.Mode != Player.SelectionRadial.SelectionMode.RadialQuicks ? 0 : (PlayerInput.Triggers.Current.RadialQuickbar ? 1 : 0)) : 1) == 0) break; bool flag = this.Mode == Player.SelectionRadial.SelectionMode.RadialCircular; float num = (float) (6.28318548202515 / (double) this.RadialCount / 2.0); Vector2 v = PlayerInput.GamepadThumbstickRight.RotatedBy((double) num - 1.57079637050629); if ((double) v.Length() == 0.0) v = PlayerInput.GamepadThumbstickLeft.RotatedBy((double) num - 1.57079637050629); int to = -1; if ((double) v.Length() > 0.300000011920929) { to = (int) (((double) v.ToRotation() + 3.14159274101257) / (6.28318548202515 / (double) this.RadialCount)); if (to >= this.RadialCount) to -= this.RadialCount; } if (to == -1 && flag || this._SelectedBinding == to || to == -1 && v != Vector2.Zero) break; this.ChangeSelection(to); break; } } public void ChangeBinding(int itemSlot) { if (itemSlot < 0 || itemSlot >= 50 || this.Mode != Player.SelectionRadial.SelectionMode.Dpad4) return; if (PlayerInput.Triggers.JustPressed.DpadRadial1) this.Bind(itemSlot, 0); if (PlayerInput.Triggers.JustPressed.DpadRadial2) this.Bind(itemSlot, 1); if (PlayerInput.Triggers.JustPressed.DpadRadial3) this.Bind(itemSlot, 2); if (!PlayerInput.Triggers.JustPressed.DpadRadial4) return; this.Bind(itemSlot, 3); } public void ChangeSelection(int to) { if (this._SelectedBinding == to) this._SelectedBinding = -1; else this._SelectedBinding = to; } private void Bind(int itemslot, int radialslot) { this.ChangeSelection(-1); if (this.Bindings[radialslot] == itemslot) { this.Bindings[radialslot] = -1; } else { for (int index = 0; index < this.RadialCount; ++index) { if (this.Bindings[index] == itemslot) this.Bindings[index] = -1; } this.Bindings[radialslot] = itemslot; } } public int GetDrawMode(int itemslot) { if (this.SelectedBinding != -1 && this.Bindings[this.SelectedBinding] == itemslot) return 2; for (int index = 0; index < this.RadialCount; ++index) { if (this.Bindings[index] == itemslot) return 1; } return 0; } public void CopyTo(Player.SelectionRadial that) { that._SelectedBinding = this._SelectedBinding; that.Mode = this.Mode; that.RadialCount = this.RadialCount; Array.Resize(ref that.Bindings, this.RadialCount); for (int index = 0; index < this.RadialCount; ++index) that.Bindings[index] = this.Bindings[index]; } public enum SelectionMode { Dpad4, RadialCircular, RadialQuicks, } } public struct OverheadMessage { public string chatText; public TextSnippet[] snippets; public Vector2 messageSize; public int timeLeft; public Color color; public void NewMessage(string message, int displayTime) { this.chatText = message; this.snippets = ChatManager.ParseMessage(this.chatText, Color.White).ToArray(); this.messageSize = ChatManager.GetStringSize(FontAssets.MouseText.Value, this.snippets, Vector2.One); this.timeLeft = displayTime; } } } }