private static void FixedDrawBreath(On.Terraria.Main.orig_DrawInterface_Resources_Breath orig) { Player localPlayer = Main.LocalPlayer; int breath = localPlayer.breath; int breathMax = localPlayer.breathMax; if (breathMax > 400) { localPlayer.breathMax = 400; localPlayer.breath = breath == breathMax?400:(int)(breath / (breathMax / 400f)); } orig(); localPlayer.breath = breath; localPlayer.breathMax = breathMax; }
private static void BreathUIOverride(On.Terraria.Main.orig_DrawInterface_Resources_Breath orig) { Player lPlayer = Main.LocalPlayer; bool hasLavaBreath = false; if (lPlayer != null) { if (lPlayer.lavaTime < lPlayer.lavaMax) { hasLavaBreath = lPlayer.lavaWet || lPlayer.breath == lPlayer.breathMax; } SubnauticModPlayer subPlayer = lPlayer.GetModPlayer <SubnauticModPlayer>(); if (subPlayer != null) { if (subPlayer.OxygenTank && !hasLavaBreath && !lPlayer.dead && !lPlayer.ghost) { SubnauticMod.Instance.o2Level.visible = true; return; } } } SubnauticMod.Instance.o2Level.visible = false; orig(); }
private void Main_DrawInterface_Resources_Breath(On.Terraria.Main.orig_DrawInterface_Resources_Breath orig) { bool flag = false; Player player = Main.player[Main.myPlayer]; if (player.dead) { return; } if (player.lavaTime < player.lavaMax && player.lavaWet) { flag = true; } else if (player.lavaTime < player.lavaMax && player.breath == player.breathMax) { flag = true; } Vector2 value = player.Top + new Vector2(0f, player.gfxOffY); if (Main.playerInventory && Main.screenHeight < 1000) { value.Y += Main.player[Main.myPlayer].height - 20; } value = Vector2.Transform(value - Main.screenPosition, Main.GameViewMatrix.ZoomMatrix); if (!Main.playerInventory || Main.screenHeight >= 1000) { value.Y -= 100f; } value /= Main.UIScale; if (Main.ingameOptionsWindow || Main.InGameUI.IsVisible) { value = new Vector2(Main.screenWidth / 2, Main.screenHeight / 2 + 236); } if (Main.InGameUI.IsVisible) { value.Y = Main.screenHeight - 64; } if (Main.player[Main.myPlayer].breath < Main.player[Main.myPlayer].breathMax && !Main.player[Main.myPlayer].ghost && !flag) { _ = Main.player[Main.myPlayer].breathMax / 20; int num19 = Main.player[Main.myPlayer].breathMax / 10; for (int j = 1; j < Main.player[Main.myPlayer].breathMax / num19 + 1; j++) { float num24 = 1f; int num25; if (player.breath >= j * num19) { num25 = 255; } else { float num22 = (float)(player.breath - (j - 1) * num19) / num19; num25 = (int)(30f + 225f * num22); if (num25 < 30) { num25 = 30; } num24 = num22 / 4f + 0.75f; if (num24 < 0.75) { num24 = 0.75f; } } int num21 = 0; int num20 = 0; if (j > 10) { num21 -= 260; num20 += 26; } if (player.GetModPlayer <SteviesModPlayer>().extendedLungs) { Main.spriteBatch.Draw(GetTexture("UI/BubbleOverlay"), value + new Vector2((26 * (j - 1) + num21) - 125f, 32f + (Main.bubbleTexture.Height - Main.bubbleTexture.Height * num24) / 2f + num20), new Rectangle(0, 0, Main.bubbleTexture.Width, Main.bubbleTexture.Height), new Color(num25, num25, num25, num25), 0f, default, num24, SpriteEffects.None, 0f);