public override bool?DrawHealthBar(NPC npc, byte hbPosition, ref float scale, ref Vector2 position) { if (Shield > 0) { var bright = Lighting.Brightness((int)npc.Center.X / 16, (int)npc.Center.Y / 16); Main.instance.DrawHealthBar((int)position.X, (int)position.Y, npc.life, npc.lifeMax, bright, scale); var tex = ModContent.GetTexture(AssetDirectory.GUI + "ShieldBar1"); var factor = Math.Min(Shield / (float)MaxShield, 1); var source = new Rectangle(0, 0, (int)(factor * tex.Width), tex.Height); var target = new Rectangle((int)(position.X - Main.screenPosition.X), (int)(position.Y - Main.screenPosition.Y), (int)(factor * tex.Width * scale), (int)(tex.Height * scale)); Main.spriteBatch.Draw(tex, target, source, Color.White * bright * 1.5f, 0, new Vector2(tex.Width / 2, 0), 0, 0); if (Shield < MaxShield) { var texLine = ModContent.GetTexture(AssetDirectory.GUI + "ShieldBarLine"); var sourceLine = new Rectangle((int)(tex.Width * factor), 0, 2, tex.Height); var targetLine = new Rectangle((int)(position.X - Main.screenPosition.X) + (int)(tex.Width * factor), (int)(position.Y - Main.screenPosition.Y), (int)(2 * scale), (int)(tex.Height * scale)); Main.spriteBatch.Draw(texLine, targetLine, sourceLine, Color.White * bright * 2, 0, new Vector2(tex.Width / 2, 0), 0, 0); } return(false); } return(base.DrawHealthBar(npc, hbPosition, ref scale, ref position)); }
//////////////// /// <summary> /// Checks for valid brightness of the given tile. /// </summary> /// <param name="tileX"></param> /// <param name="tileY"></param> /// <param name="collideType"></param> /// <returns></returns> public bool CheckBrightness(int tileX, int tileY, out TileCollideType collideType) { if (this.MinimumBrightness.HasValue || this.MaximumBrightness.HasValue) { float brightness = Lighting.Brightness(tileX, tileY); if (this.MinimumBrightness.HasValue) { if (this.MinimumBrightness > brightness) { collideType = TileCollideType.BrightnessLow; return(false); } } if (this.MaximumBrightness.HasValue) { if (this.MaximumBrightness < brightness) { collideType = TileCollideType.BrightnessHigh; return(false); } } } collideType = TileCollideType.None; return(true); }
public override void HoldItem(Player player) { if (player.itemAnimation <= 0) { player.itemLocation.X -= 13 * player.direction; player.itemLocation.Y += 18; } if (player.whoAmI == Main.myPlayer) { for (int i = 0; i < 30; i++) { Vector2 dustPos = Main.MouseWorld + Vector2.UnitX.RotatedBy(i / 30f * MathHelper.TwoPi) * 50; float bright = Lighting.Brightness((int)(dustPos.X / 16), (int)(dustPos.Y / 16)); Dust dust = Dust.NewDustPerfect(dustPos + Main.rand.NextVector2Circular(1, 1), DustType <VoidParticle>(), Vector2.Zero); dust.noGravity = true; dust.velocity = Vector2.Zero; dust.scale = bright * 0.8f; dust = Dust.NewDustPerfect(dustPos, DustType <Crystalline.CrystallineDust>(), Vector2.Zero); dust.noGravity = true; dust.velocity = Vector2.Zero; dust.scale = (1 - bright) * 0.8f; } } }
public override bool?DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { bool?result; if (!showHealthBar) { npc.position -= npc.visualOffset; result = new bool?(false); } else if (realLifeHealthBar) { if (npc.realLife == -1) { result = new bool?(false); } else { float alpha = Lighting.Brightness((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f)); Main.instance.DrawHealthBar(position.X, position.Y, Main.npc[npc.realLife].life, Main.npc[npc.realLife].lifeMax, alpha, scale); npc.position -= npc.visualOffset; result = new bool?(false); } } else { if (npc.boss) { scale = 1.5f; } result = null; } return(result); }
private void drawVitricBackground(On.Terraria.Main.orig_DrawBackgroundBlackFill orig, Terraria.Main self) { orig(self); Player player = Main.LocalPlayer; VitricBackgroundDust.ForEach(BootlegDust => BootlegDust.Update()); VitricBackgroundDust.RemoveAll(BootlegDust => BootlegDust.time <= 0); VitricForegroundDust.ForEach(BootlegDust => BootlegDust.Update()); VitricForegroundDust.RemoveAll(BootlegDust => BootlegDust.time <= 0); if (Main.playerLoaded && player.GetModPlayer <BiomeHandler>().ZoneGlass) { Vector2 basepoint = (LegendWorld.vitricTopLeft != null) ? LegendWorld.vitricTopLeft * 16 + new Vector2(-2000, 1000) : Vector2.Zero; for (int k = 5; k >= 0; k--) { drawLayer(basepoint, ModContent.GetTexture("StarlightRiver/Backgrounds/Glass" + k), k + 1); if (k == 5) { VitricBackgroundDust.ForEach(BootlegDust => BootlegDust.Draw(Main.spriteBatch)); } if (k == 2) { VitricForegroundDust.ForEach(BootlegDust => BootlegDust.Draw(Main.spriteBatch)); } } for (int k = (int)(player.position.X - basepoint.X) - (int)(Main.screenWidth * 1.5f); k <= (int)(player.position.X - basepoint.X) + (int)(Main.screenWidth * 1.5f); k += 30) { if (Main.rand.Next(500) == 0) { BootlegDust dus = new VitricDust(ModContent.GetTexture("StarlightRiver/GUI/Light"), basepoint + new Vector2(-2000, 1000), k, 1.5f, 0.3f, 0.1f); VitricBackgroundDust.Add(dus); } if (Main.rand.Next(400) == 0) { BootlegDust dus2 = new VitricDust(ModContent.GetTexture("StarlightRiver/GUI/Light"), basepoint + new Vector2(-2000, 1000), k, 2.25f, 1f, 0.4f); VitricForegroundDust.Add(dus2); } } for (int i = -2 + (int)(player.position.X - Main.screenWidth / 2) / 16; i <= 2 + (int)(player.position.X + Main.screenWidth / 2) / 16; i++) { for (int j = -2 + (int)(player.position.Y - Main.screenHeight) / 16; j <= 2 + (int)(player.position.Y + Main.screenHeight) / 16; j++) { if (Lighting.Brightness(i, j) == 0 || ((Main.tile[i, j].active() && Main.tile[i, j].collisionType == 1) || Main.tile[i, j].wall != 0)) { Color color = Color.Black * (1 - Lighting.Brightness(i, j) * 2); Main.spriteBatch.Draw(Main.blackTileTexture, new Vector2(i * 16, j * 16) - Main.screenPosition, color); } else if (i % 4 == 0 && j % 4 == 0 && Main.tile[i, j].wall == 0) { Lighting.AddLight(new Vector2(i * 16, j * 16), new Vector3(0.3f, 0.35f, 0.4f) * 2.1f); } } } } }
public override void NearbyEffects(int i, int j, bool closer) { if (Main.gameMenu) { return; //so worldgen dosent crash } Tile tile = Main.tile[i, j]; tile.inActive(Lighting.Brightness(i, j) > 0.25f); }
public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { float brightness = Lighting.Brightness(i, j); if (brightness > 0.05f) { var myworld = ModContent.GetInstance <FMCWorld>(); myworld.QueueManaCrystalShardCheck(i, j, brightness); } }
public override float SpawnChance(NPCSpawnInfo spawnInfo) { var tile = Framing.GetTileSafely(spawnInfo.spawnTileX, spawnInfo.spawnTileY); var spawnPoint = new Vector2(spawnInfo.spawnTileX, spawnInfo.spawnTileY) * 16; return(spawnInfo.player.ZoneCorrupt && tile.wall == WallID.EbonstoneUnsafe && tile.liquid == 0 && Lighting.Brightness(spawnInfo.spawnTileX, spawnInfo.spawnTileY) <= 0.1f && !Main.npc.Any(n => n.type == NPCType <Stalker>() && Vector2.Distance(n.Center, spawnPoint) < 320) ? 1 : 0); }
public override void DrawEffects(PlayerDrawInfo drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright) { var num25 = Main.myPlayer; base.DrawEffects(drawInfo, ref r, ref g, ref b, ref a, ref fullBright); int num26 = 0; if (Main.HealthBarDrawSettings == 1) { num26 = 10; } else if (Main.HealthBarDrawSettings == 2) { num26 = -20; } int x = (int)(Main.player[num25].position.X + (float)(Main.player[num25].width / 2)); int y = (int)(Main.player[num25].position.Y + (float)Main.player[num25].height + Main.player[num25].gfxOffY); int dy = y + num26; int health = Main.player[num25].statLife; int maxHealth = Main.player[num25].statLifeMax2; var brightness = Lighting.Brightness((int)(x / 16f), (int)(y / 16f)); if (Main.player[num25].active && !Main.player[num25].ghost && !Main.player[num25].dead) { if (Main.player[num25].statLife != Main.player[num25].statLifeMax2) { Main.instance.DrawHealthBar(x, dy, health, maxHealth, brightness, 1f); } dy += 10; if (GetInstance <Config>().ShowMana) { if (Main.player[num25].statMana != Main.player[num25].statManaMax2) { DrawManaBar(x, dy, Main.player[num25].statMana, Main.player[num25].statManaMax2, 1f); } } if (GetInstance <Config>().ShowPotionSickness) { if (Main.player[num25].statLife != Main.player[num25].statLifeMax2 || GetInstance <Config>().ShowPotionSicknessAtFullHealth) { for (int i = 0; i < Main.player[num25].buffType.Length; i++) { if (Main.player[num25].buffType[i] == BuffID.PotionSickness) { DrawPotionSickness(x, dy, Main.player[num25].buffTime[i]); } } } } } }
public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { Tile tile = Main.tile[i, j]; int off = i + j; float sin = (float)Math.Sin(StarlightWorld.rottime + off * 0.2f * 0.2f); Color color = new Color(1 - sin * 0.5f, 1, 1); float mult = 0.2f - Lighting.Brightness(i, j) * 0.2f; spriteBatch.Draw(Main.tileTexture[tile.type], (new Vector2(i, j) + Helper.TileAdj) * 16 - Main.screenPosition, new Rectangle(tile.frameX, tile.frameY, 16, 16), color * mult); Lighting.AddLight(new Vector2(i, j) * 16, color.ToVector3() * 0.1f); }
public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { float off = (float)Math.Sin((i + j) * 0.2f) * 300 + (float)Math.Cos(j * 0.15f) * 200; float sin2 = (float)Math.Sin(StarlightWorld.rottime + off * 0.01f * 0.2f); float cos = (float)Math.Cos(StarlightWorld.rottime + off * 0.01f); Color color = new Color(100 * (1 + sin2) / 255f, 140 * (1 + cos) / 255f, 180 / 255f); float mult = Lighting.Brightness(i, j); //if (mult > 0.1f) mult = 0.1f; drawColor = color.MultiplyRGB(Color.White * mult); }
public override bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch) { return(base.PreDraw(i, j, type, spriteBatch)); float b = Lighting.Brightness(i, j); if (b <= 0.05 /*|| (type == TileID.Dirt && !Main.tile[i,j].active())*/) { Vector2 screenLoc = new Vector2(192, 192) + (16f * new Vector2(i, j)) - Main.screenPosition; spriteBatch.Draw(ModContent.GetInstance <StarSailorMod>().pixel, new Rectangle((int)screenLoc.X, (int)screenLoc.Y, 16, 16), Color.Black); } return(base.PreDraw(i, j, type, spriteBatch)); }
private static void DrawBlack() { for (int i = -2 + (int)(Main.screenPosition.X) / 16; i <= 2 + (int)(Main.screenPosition.X + Main.screenWidth) / 16; i++) { for (int j = -2 + (int)(Main.screenPosition.Y) / 16; j <= 2 + (int)(Main.screenPosition.Y + Main.screenHeight) / 16; j++) { if (Lighting.Brightness(i, j) == 0 || ((Main.tile[i, j].active() && Main.tile[i, j].collisionType == 1) || Main.tile[i, j].wall != 0)) { Color color = Color.Black * (1 - Lighting.Brightness(i, j) * 2); Main.spriteBatch.Draw(Main.blackTileTexture, new Vector2(i * 16, j * 16) - Main.screenPosition, color); } } } }
/// <summary> /// Gauges the overall light amount within an area. /// </summary> /// <param name="tileX"></param> /// <param name="tileY"></param> /// <param name="width"></param> /// <param name="height"></param> /// <returns></returns> public static float GaugeBrightnessWithin(int tileX, int tileY, int width, int height) { int i = 0, j = 0; float avg = 0f; for (i = 0; i < width; i++) { for (j = 0; j < height; j++) { avg += Lighting.Brightness(tileX + i, tileY + j); } } return(avg / (i * j)); }
public bool checkValidPosition(int x, int y) { bool playerDistance = false; for (int i = 0; i < Main.player.Length; i++) { Player p = Main.player[i]; if (Vector2.Distance(p.Center / 16, Position.ToVector2()) < 40) { playerDistance = true; Main.NewText("X : " + x + " - Y : " + y + " - Lighting level : " + Lighting.Brightness(x, y)); break; } } return(Main.rand.Next(0, 10) == 1 && playerDistance && Lighting.Brightness(x, y) < 0.50); }
public override void HoldItem(Player player) { int index = -1; for (int i = 0; i < Main.maxProjectiles; i++) { if (Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].type == item.shoot) { index = i; break; } } if (index == -1) { Projectile.NewProjectile(player.Center, Vector2.Zero, item.shoot, item.damage, item.knockBack, player.whoAmI); } else { Main.projectile[index].Center = player.Center; Main.projectile[index].timeLeft = 2; } player.itemLocation.X -= item.width / 2 * player.direction; player.itemLocation += new Vector2(6 * -player.direction, 6); // Add projectile spawn here if (player.whoAmI == Main.myPlayer) { for (int i = 0; i < 50; i++) { Vector2 dustPos = Main.MouseWorld + Vector2.UnitX.RotatedBy(i / 50f * MathHelper.TwoPi) * 100; float bright = Lighting.Brightness((int)(dustPos.X / 16), (int)(dustPos.Y / 16)); Dust dust = Dust.NewDustPerfect(dustPos + Main.rand.NextVector2Circular(1, 1), DustType <NPCs.ErilipahBiome.VoidParticle>(), Vector2.Zero); dust.noGravity = true; dust.velocity = Vector2.Zero; dust.scale = bright * 0.8f; dust = Dust.NewDustPerfect(dustPos, DustType <Crystalline.CrystallineDust>(), Vector2.Zero); dust.noGravity = true; dust.velocity = Vector2.Zero; dust.scale = (1 - bright) * 0.8f; } } }
public static bool FindNearbyRandomAirTile(int tileX, int tileY, int radius, out int toX, out int toY) { Tile tile = null; int wtf = 0; bool isBlocked = false; toX = 0; toY = 0; if (tileX + radius <= 0 || tileX - radius >= Main.mapMaxX) { return(false); } if (tileY + radius <= 0 || tileY - radius >= Main.mapMaxY) { return(false); } do { do { toX = Main.rand.Next(-radius, radius) + tileX; }while(toX <= 0 || toX >= Main.mapMaxX); do { toY = Main.rand.Next(-radius, radius) + tileY; }while(toY <= 0 || toY >= Main.mapMaxY); //tile = Main.tile[toX, toY]; tile = Framing.GetTileSafely(toX, toY); if (wtf++ > 100) { return(false); } bool _; isBlocked = TileHelpers.IsSolid(tile, true, true) || TileWallHelpers.IsDungeon(tile, out _) || TileHelpers.IsWire(tile) || tile.lava(); } while(isBlocked && ((tile != null && tile.type != 0) || Lighting.Brightness(toX, toX) == 0)); return(true); }
public bool NearLight() { for (int x = -5; x < 5; x++) { for (int y = -5; y < 5; y++) { int xPos = (int)(npc.Center.X / 16) + x; int yPos = (int)(npc.Center.Y / 16) + y; if (Lighting.Brightness(xPos, yPos) > 0.15f) { return(true); } } } return(false); }
public static bool FindNearbyRandomAirTile(int tile_x, int tile_y, int radius, out int to_x, out int to_y) { Tile tile = null; int wtf = 0; bool is_blocked = false; to_x = 0; to_y = 0; if (tile_x + radius <= 0 || tile_x - radius >= Main.mapMaxX) { return(false); } if (tile_y + radius <= 0 || tile_y - radius >= Main.mapMaxY) { return(false); } do { do { to_x = Main.rand.Next(-radius, radius) + tile_x; }while(to_x <= 0 || to_x >= Main.mapMaxX); do { to_y = Main.rand.Next(-radius, radius) + tile_y; }while(to_y <= 0 || to_y >= Main.mapMaxY); //tile = Main.tile[to_x, to_y]; tile = Framing.GetTileSafely(to_x, to_y); if (wtf++ > 100) { return(false); } is_blocked = TileHelpers.IsSolid(tile, true, true) || TileWallHelpers.IsDungeon(tile) || TileHelpers.IsWire(tile) || tile.lava(); } while(is_blocked && ((tile != null && tile.type != 0) || Lighting.Brightness(to_x, to_x) == 0)); return(true); }
public override float SpawnChance(NPCSpawnInfo spawnInfo) { if (CanSpawn && !spawnInfo.water && !Main.bloodMoon && !NPC.AnyNPCs(ModContent.NPCType <LiebreNPC>()) && !NpcMod.HasGuardianNPC(GuardianBase.Liebre) && !NpcMod.HasMetGuardian(GuardianBase.Liebre)) { Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; if (Lighting.Brightness(spawnInfo.spawnTileX, spawnInfo.spawnTileY) < 0.15f) { switch (EncounterTimes) { case 0: if (!spawnInfo.player.ZoneDungeon && !spawnInfo.player.ZoneCorrupt && !spawnInfo.player.ZoneCrimson) { return(1f / 200); } break; case 1: if (spawnInfo.player.ZoneCorrupt || spawnInfo.player.ZoneCrimson) { return(1f / 200); } break; case 2: if (spawnInfo.player.ZoneDungeon) { return(1f / 200); } break; case 3: if (spawnInfo.playerInTown) { return(1f / 200); } break; } //Can spawn :D } } return(base.SpawnChance(spawnInfo)); }
public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { Tile tile = Main.tile[i, j]; float off = (float)Math.Sin((i + j) * 0.2f) * 300 + (float)Math.Cos(j * 0.15f) * 200; float sin2 = (float)Math.Sin(StarlightWorld.rottime + off * 0.01f * 0.2f); float cos = (float)Math.Cos(StarlightWorld.rottime + off * 0.01f); Color color = new Color(100 * (1 + sin2) / 255f, 140 * (1 + cos) / 255f, 180 / 255f); float mult = Lighting.Brightness(i, j); if (mult > 0.1f) { mult = 0.1f; } if (mult != 0 && tile.slope() == 0 && !tile.halfBrick()) { spriteBatch.Draw(Main.tileTexture[tile.type], (new Vector2(i, j) + Helper.TileAdj) * 16 - Main.screenPosition, new Rectangle(tile.frameX, tile.frameY, 16, 16), color * mult); } }
private void DrawInterface_PlayerHealthBars() { Player player = Main.player[Main.myPlayer]; if (player.statLife == player.statLifeMax) { return; } Vector2 position = player.position; float positionX = position.X + (float)(player.width / 2); float positionY = position.Y + (float)(player.height) + 10f; float brightness = Lighting.Brightness( (int)(positionX / 16.0), (int)((positionY + (double)player.gfxOffY) / 16.0) ); // float scale = 1f; this.DrawHealthBar(positionX, positionY, player.statLife, player.statLifeMax, brightness); }
private void DrawShieldForPlayers(On.Terraria.Main.orig_DrawInterface_14_EntityHealthBars orig, Main self) { orig(self); for (int k = 0; k < Main.maxPlayers; k++) { var player = Main.player[k]; if (player != null && player.active) { var mp = player.GetModPlayer <ShieldPlayer>(); if (k != Main.myPlayer && player.active && !player.ghost && !player.dead && player.statLife != player.statLifeMax2) { var offset = Main.HealthBarDrawSettings == 1 ? 10 : -20; var tex = ModContent.GetTexture(AssetDirectory.GUI + "ShieldBar1"); var pos = new Vector2(player.position.X - 8, player.position.Y + player.height + offset + player.gfxOffY); var factor = Math.Min(mp.Shield / (float)mp.MaxShield, 1); var source = new Rectangle(0, 0, (int)(factor * tex.Width), tex.Height); var target = new Rectangle((int)(pos.X - Main.screenPosition.X), (int)(pos.Y - Main.screenPosition.Y), (int)(factor * tex.Width), tex.Height); Main.spriteBatch.Draw(tex, target, source, Color.White * Lighting.Brightness((int)player.Center.X / 16, (int)player.Center.Y / 16) * 1.5f); if (mp.Shield < mp.MaxShield && mp.Shield > 0) { var texLine = ModContent.GetTexture(AssetDirectory.GUI + "ShieldBarLine"); var sourceLine = new Rectangle((int)(tex.Width * factor), 0, 2, tex.Height); var targetLine = new Rectangle((int)(pos.X - Main.screenPosition.X) + (int)(tex.Width * factor), (int)(pos.Y - Main.screenPosition.Y), 2, tex.Height); Main.spriteBatch.Draw(texLine, targetLine, sourceLine, Color.White * Lighting.Brightness((int)player.Center.X / 16, (int)player.Center.Y / 16) * 2); } } } } }
public override void PreUpdate() { #region check if pressing the buff key, not needed anymore bool flag = false; bool flag2 = false; Keys[] pressedKeys = Main.keyState.GetPressedKeys(); for (int k = 0; k < pressedKeys.Length; k++) { if (pressedKeys[k] == Keys.LeftShift || pressedKeys[k] == Keys.RightShift) { flag = true; } else if (pressedKeys[k] == Keys.LeftAlt || pressedKeys[k] == Keys.RightAlt) { flag2 = true; } string a = string.Concat(pressedKeys[k]); if (pressedKeys[k] != Keys.Tab || !((flag && SocialAPI.Mode == SocialMode.Steam) | flag2)) { if (a == Main.cBuff) { pressingQuickBuff = true; pressingQuickBuffCD = 1; } } } if (pressingQuickBuff) { QuickBuff(); } pressingQuickBuffCD--; if (pressingQuickBuffCD <= 0) { pressingQuickBuff = false; } #endregion #region darkness Point topLeft = ((player.TopLeft) / 16).ToPoint(); Point bottomRight = ((player.BottomRight) / 16).ToPoint(); for (int i = topLeft.X; i <= bottomRight.X; i++) { for (int j = topLeft.Y; j <= bottomRight.Y; j++) { if (Lighting.Brightness(i, j) > playerBrightestLight) { playerBrightestLight = Lighting.Brightness(i, j); } } } #endregion for (int i = 0; i < potionConsumedCD.Length; i++) { if (potionConsumedCD[i] > 0) { potionsConsumedLastMin++; potionConsumedCD[i]--; } } for (int i = 0; i < salesCD.Length; i++) { if (salesCD[i] > 0) { salesLastMin++; salesCD[i]--; } } for (int i = 0; i < buysCD.Length; i++) { if (buysCD[i] > 0) { buysLastMin++; buysCD[i]--; } } for (int i = 0; i < bossKilledCD.Length; i++) { if (bossKilledCD[i] > 14400) { bossesKilledLastMin++; } if (bossKilledCD[i] > 0) { bossesKilledLastFiveMin++; bossKilledCD[i]--; } } //ElementsAwoken.DebugModeText(potionsConsumedLastMin); if (placingAutoDriller > 0) { placingAutoDriller--; } }
public override void NearbyEffects(int i, int j, bool closer) { Tile tile = Main.tile[i, j]; tile.inActive(Lighting.Brightness(i, j) > 0.25f); }
private static void DrawHealthBar(NPC npc, Vector2 position, float scale) { float alpha = Lighting.Brightness((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f)); Main.instance.DrawHealthBar(position.X, position.Y, npc.life, npc.lifeMax, alpha, scale); }
public override bool PreDraw(SpriteBatch sb, Color drawColor) { Player player = Main.player[npc.target]; npc.spriteDirection = npc.direction; SpriteEffects effects = SpriteEffects.None; if (npc.spriteDirection == -1) { effects = SpriteEffects.FlipHorizontally; } Color buffColor = Color.White; //Lighting.GetColor((int)((double)npc.position.X + (double)npc.width * 0.5) / 16, (int)(((double)npc.position.Y + (double)npc.height * 0.5) / 16.0)); /*if (npc.behindTiles) * { * int num44 = (int)((Body.position.X - 8f) / 16f); * int num45 = (int)((Body.position.X + (float)Body.width + 8f) / 16f); * int num46 = (int)((npc.position.Y - 8f) / 16f); * int num47 = (int)((Body.position.Y + (float)Body.height + 8f) / 16f); * for (int m = num44; m <= num45; m++) * { * for (int n = num46; n <= num47; n++) * { * if (Lighting.Brightness(m, n) == 0f) * { * buffColor = Color.Black; * } * } * } * }*/ Color alpha2 = npc.GetAlpha(buffColor); Texture2D texHead = mod.GetTexture("NPCs/Kraid/Kraid_Head"), texJaw = mod.GetTexture("NPCs/Kraid/Kraid_Jaw"), texNeck = mod.GetTexture("NPCs/Kraid/Kraid_Neck"), texBody = mod.GetTexture("NPCs/Kraid/Kraid_Body"), texBodyOverlay = mod.GetTexture("NPCs/Kraid/Kraid_BodyOverlay"), texLegs = mod.GetTexture("NPCs/Kraid/Kraid_Legs"), texArm1 = mod.GetTexture("NPCs/Kraid/Kraid_Arm1"), texArm2 = mod.GetTexture("NPCs/Kraid/Kraid_Arm2"), texArmFront = mod.GetTexture("NPCs/Kraid/Kraid_ArmFront"), texArmBack = mod.GetTexture("NPCs/Kraid/Kraid_ArmBack"); if (state > 0) { texHead = mod.GetTexture("NPCs/Kraid/Kraid_Head_" + state); texJaw = mod.GetTexture("NPCs/Kraid/Kraid_Jaw_" + state); texNeck = mod.GetTexture("NPCs/Kraid/Kraid_Neck_" + state); texBody = mod.GetTexture("NPCs/Kraid/Kraid_Body_" + state); texBodyOverlay = mod.GetTexture("NPCs/Kraid/Kraid_BodyOverlay_" + state); texLegs = mod.GetTexture("NPCs/Kraid/Kraid_Legs_" + state); texArm1 = mod.GetTexture("NPCs/Kraid/Kraid_Arm1_" + state); texArm2 = mod.GetTexture("NPCs/Kraid/Kraid_Arm2_" + state); texArmFront = mod.GetTexture("NPCs/Kraid/Kraid_ArmFront_" + state); texArmBack = mod.GetTexture("NPCs/Kraid/Kraid_ArmBack_" + state); } if (Body == null || ArmBack == null || ArmFront == null) { return(false); } Vector2 backArm1Pos = npc.Center + new Vector2(37 * npc.direction, 40) + (ArmBack.Center - (npc.Center + new Vector2(234 * npc.direction, 79))) * 0.25f; sb.Draw(texArm1, backArm1Pos + fullOffset - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texArm1.Width, texArm1.Height)), alpha2, 0f, new Vector2(texArm1.Width / 2, texArm1.Height / 2), 1f, effects, 0f); gorePosition[0] = backArm1Pos; Vector2 bvec1 = new Vector2(-94, 42); float bveclength = Vector2.Distance(Vector2.Zero, bvec1); float bvecrot = (float)Math.Atan2(bvec1.Y, bvec1.X) + ArmBack.rotation; Vector2 bvec2 = new Vector2((float)Math.Cos(bvecrot) * bveclength, (float)Math.Sin(bvecrot) * bveclength); Vector2 bArm2Pos1 = backArm1Pos + new Vector2(0f, 30f), bArm2Pos2 = ArmBack.Center + new Vector2(bvec2.X * npc.direction, bvec2.Y); Vector2 backArm2Pos = Vector2.Lerp(bArm2Pos1, bArm2Pos2, 0.5f); float bArmRot = (float)Math.Atan2((bArm2Pos2.Y - bArm2Pos1.Y) * npc.direction, (bArm2Pos2.X - bArm2Pos1.X) * npc.direction) - ((float)Math.PI * 0.375f) * npc.direction; sb.Draw(texArm2, backArm2Pos + fullOffset - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texArm2.Width, texArm2.Height)), alpha2, bArmRot, new Vector2(texArm2.Width / 2, texArm2.Height / 2), 1f, effects, 0f); gorePosition[1] = backArm2Pos; Vector2 bOrigin = new Vector2(109, 80); if (npc.direction == -1) { bOrigin.X = (float)texArmBack.Width - bOrigin.X; } Vector2 armBackPos = fullOffset + ArmBack.Center + new Vector2(-(float)(ArmBack.width / 2) * npc.direction, (float)ArmBack.height / 2 - 14f); sb.Draw(texArmBack, armBackPos - Main.screenPosition, new Rectangle?(new Rectangle(0, (texArmBack.Height / 6) * ArmBack.frame.Y, texArmBack.Width, texArmBack.Height / 6)), alpha2, ArmBack.rotation * npc.direction, bOrigin, 1f, effects, 0f); gorePosition[2] = armBackPos; Vector2 backLegPos = Body.Center + new Vector2((62 + texLegs.Width / 4) * npc.direction, 2) + bLegPos; sb.Draw(texLegs, backLegPos - Main.screenPosition, new Rectangle?(new Rectangle(texLegs.Width / 2, 0, texLegs.Width / 2, texLegs.Height)), alpha2, 0f, new Vector2(texLegs.Width / 4, 0), 1f, effects, 0f); gorePosition[3] = backLegPos; Vector2 bodyPos = fullOffset + Body.Center - new Vector2(117 * npc.direction, 38); sb.Draw(texBody, bodyPos - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texBody.Width, texBody.Height)), alpha2, 0f, new Vector2(texBody.Width / 2, texBody.Height / 2), 1f, effects, 0f); gorePosition[4] = bodyPos; for (int i = 0; i < Main.maxProjectiles; i++) { if (Main.projectile[i].active && Main.projectile[i].type == mod.ProjectileType("KraidBellySpike") && Main.projectile[i].ai[0] == npc.whoAmI && Main.projectile[i].localAI[0] <= 35) { Projectile projectile = Main.projectile[i]; SpriteEffects effects2 = SpriteEffects.None; if (projectile.spriteDirection == -1) { effects2 = SpriteEffects.FlipHorizontally; } Texture2D tex = Main.projectileTexture[projectile.type]; int num108 = tex.Height / Main.projFrames[projectile.type]; int y4 = num108 * projectile.frame; sb.Draw(tex, new Vector2((float)((int)(projectile.Center.X - Main.screenPosition.X)), (float)((int)(projectile.Center.Y - Main.screenPosition.Y + projectile.gfxOffY))), new Rectangle?(new Rectangle(0, y4, tex.Width, num108)), projectile.GetAlpha(Color.White), projectile.rotation, new Vector2((float)tex.Width / 2f, (float)projectile.height / 2f), projectile.scale, effects2, 0f); } } Vector2 bodyOvPos = fullOffset + Body.Center + new Vector2(85 * npc.direction, -7); sb.Draw(texBodyOverlay, bodyOvPos - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texBodyOverlay.Width, texBodyOverlay.Height)), alpha2, 0f, new Vector2(texBodyOverlay.Width / 2, texBodyOverlay.Height / 2), 1f, effects, 0f); Vector2 frontLegPos = Body.Center + new Vector2((-144 + texLegs.Width / 4) * npc.direction, 2) + fLegPos; sb.Draw(texLegs, frontLegPos - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texLegs.Width / 2, texLegs.Height)), alpha2, 0f, new Vector2(texLegs.Width / 4, 0), 1f, effects, 0f); gorePosition[5] = frontLegPos; bLegPrevPos = bLegPos; fLegPrevPos = fLegPos; float targetrotation = (float)Math.Atan2((player.Center.Y - npc.Center.Y) * npc.direction, (player.Center.X - npc.Center.X) * npc.direction); if (player.active && !mouthOpen) { headRot = targetrotation * 0.3f; if (headRot < -0.15f) { headRot = -0.15f; } if (headRot > 0.15f) { headRot = 0.15f; } } /*else if(Math.Abs(headRot) > 0.05f) * { * headRot *= 0.9f; * }*/ else { headRot = 0f; } Vector2 hOffset = new Vector2(headOffset.X * npc.direction, headOffset.Y); Vector2 headPos = fullOffset + npc.Center + new Vector2((29 - texNeck.Width / 2) * npc.direction, -9) + new Vector2((float)Math.Max(Math.Ceiling(headOffset.X * 0.5f), 0f) * npc.direction, (float)Math.Floor(headOffset.Y * 0.5f)); if (mouthOpen) { headPos.X += roarFrame * npc.direction; } sb.Draw(texNeck, headPos - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texNeck.Width, texNeck.Height)), alpha2, 0f, new Vector2(texNeck.Width / 2, 46), 1f, effects, 0f); gorePosition[6] = headPos; headPos = fullOffset + npc.Center + new Vector2(29 * npc.direction, -9) + hOffset; Vector2 hpos1 = headPos; if (mouthOpen) { hpos1 += new Vector2(roarFrame * npc.direction, roarFrame); } sb.Draw(texJaw, hpos1 - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texJaw.Width, texJaw.Height)), alpha2, headRot, new Vector2(texJaw.Width / 2, texJaw.Height / 2), 1f, effects, 0f); gorePosition[7] = hpos1; Vector2 hpos2 = headPos; if (mouthOpen) { hpos2 += new Vector2(roarFrame * npc.direction, -roarFrame); } sb.Draw(texHead, hpos2 - Main.screenPosition, new Rectangle?(new Rectangle(0, (texHead.Height / 6) * npc.frame.Y + (texHead.Height / 2) * npc.frame.X, texHead.Width, texHead.Height / 6)), alpha2, headRot, new Vector2(texHead.Width / 2, texHead.Height / 12), 1f, effects, 0f); gorePosition[8] = hpos2; Vector2 frontArm1Pos = npc.Center + new Vector2(-65 * npc.direction, 78) + (ArmFront.Center - (npc.Center + new Vector2(42 * npc.direction, 131))) * 0.25f; sb.Draw(texArm1, frontArm1Pos + fullOffset - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texArm1.Width, texArm1.Height)), alpha2, 0f, new Vector2(texArm1.Width / 2, texArm1.Height / 2), 1f, effects, 0f); gorePosition[9] = frontArm1Pos; Vector2 vec1 = new Vector2(-92, 62); float veclength = Vector2.Distance(Vector2.Zero, vec1); float vecrot = (float)Math.Atan2(vec1.Y, vec1.X) + ArmFront.rotation; Vector2 vec2 = new Vector2((float)Math.Cos(vecrot) * veclength, (float)Math.Sin(vecrot) * veclength); Vector2 fArm2Pos1 = frontArm1Pos, fArm2Pos2 = ArmFront.Center + new Vector2(vec2.X * npc.direction, vec2.Y); float fArmRot = (float)Math.Atan2((fArm2Pos2.Y - fArm2Pos1.Y) * npc.direction, (fArm2Pos2.X - fArm2Pos1.X) * npc.direction) - ((float)Math.PI / 2) * npc.direction; Vector2 frontArm2Pos = Vector2.Lerp(fArm2Pos1, fArm2Pos2, 0.5f); sb.Draw(texArm2, frontArm2Pos + fullOffset - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texArm2.Width, texArm2.Height)), alpha2, fArmRot, new Vector2(texArm2.Width / 2, texArm2.Height / 2), 1f, effects, 0f); gorePosition[10] = frontArm2Pos; Vector2 fOrigin = new Vector2(106, 63); if (npc.direction == -1) { fOrigin.X = (float)texArmFront.Width - fOrigin.X; } Vector2 armFrontPos = fullOffset + ArmFront.Center; sb.Draw(texArmFront, armFrontPos - Main.screenPosition, new Rectangle?(new Rectangle(0, (texArmFront.Height / 5) * ArmFront.frame.Y, texArmFront.Width, texArmFront.Height / 5)), alpha2, ArmFront.rotation * npc.direction, fOrigin, 1f, effects, 0f); gorePosition[11] = armFrontPos; if (fullAnim <= 0) { fullOffset = Vector2.Zero; } Texture2D rect = mod.GetTexture("Gore/Pixel"); int num44 = (int)((Body.position.X - 240f) / 16f); int num45 = (int)((Body.position.X + (float)Body.width + 240f) / 16f); int num46 = (int)((npc.position.Y - 32f) / 16f); int num47 = (int)((Body.position.Y + (float)Body.height + 16f) / 16f); for (int m = num44; m <= num45; m++) { for (int n = num46; n <= num47; n++) { Tile tile1 = Main.tile[m, n], tile2 = Main.tile[m, n - 1], tile3 = Main.tile[m, n + 1], tile4 = Main.tile[m - 1, n], tile5 = Main.tile[m - 1, n - 1], tile6 = Main.tile[m - 1, n + 1], tile7 = Main.tile[m + 1, n], tile8 = Main.tile[m + 1, n - 1], tile9 = Main.tile[m + 1, n + 1]; if (tile1 != null && tile1.active() && Main.tileSolid[(int)tile1.type] && !Main.tileSolidTop[(int)tile1.type] && tile2 != null && tile2.active() && Main.tileSolid[(int)tile2.type] && !Main.tileSolidTop[(int)tile2.type] && tile3 != null && tile3.active() && Main.tileSolid[(int)tile3.type] && !Main.tileSolidTop[(int)tile3.type] && tile4 != null && tile4.active() && Main.tileSolid[(int)tile4.type] && !Main.tileSolidTop[(int)tile4.type] && tile5 != null && tile5.active() && Main.tileSolid[(int)tile5.type] && !Main.tileSolidTop[(int)tile5.type] && tile6 != null && tile6.active() && Main.tileSolid[(int)tile6.type] && !Main.tileSolidTop[(int)tile6.type] && tile7 != null && tile7.active() && Main.tileSolid[(int)tile7.type] && !Main.tileSolidTop[(int)tile7.type] && tile8 != null && tile8.active() && Main.tileSolid[(int)tile8.type] && !Main.tileSolidTop[(int)tile8.type] && tile9 != null && tile9.active() && Main.tileSolid[(int)tile9.type] && !Main.tileSolidTop[(int)tile9.type]) { sb.Draw(rect, new Rectangle(m * 16 - (int)Main.screenPosition.X, n * 16 - (int)Main.screenPosition.Y, 16, 16), Color.Black); } float num = Lighting.Brightness(m, n); //if(num < 1f) if (num <= 0f) { Color color = Color.Black; color *= 1f - num; sb.Draw(rect, new Rectangle(m * 16 - (int)Main.screenPosition.X, n * 16 - (int)Main.screenPosition.Y, 16, 16), color); } } } return(false); }