diff --git a/Buffs/Pets/ArcherofLunamoon.png b/Buffs/Pets/ArcherofLunamoon.png index 726d2ab0d5..a3a5614f8a 100644 Binary files a/Buffs/Pets/ArcherofLunamoon.png and b/Buffs/Pets/ArcherofLunamoon.png differ diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index c187ea3dce..2a8e2f38c6 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -59,6 +59,7 @@ namespace CalamityMod.CalPlayer Rectangle screenArea = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 50, Main.screenWidth + 1000, Main.screenHeight + 100); int dustDrawn = 0; float maxShroomDust = Main.maxDustToDraw / 2; + Color shroomColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); for (int i = 0; i < Main.maxDustToDraw; i++) { Dust dust = Main.dust[i]; @@ -67,7 +68,7 @@ namespace CalamityMod.CalPlayer // Only draw dust near the screen, for performance reasons. if (new Rectangle((int)dust.position.X, (int)dust.position.Y, 4, 4).Intersects(screenArea)) { - dust.color = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); + dust.color = shroomColor; for (int j = 0; j < 4; j++) { Vector2 dustDrawPosition = dust.position; @@ -84,8 +85,8 @@ namespace CalamityMod.CalPlayer if (j == 0 || j == 1) dustDrawPosition.Y = Player.Center.Y + distanceY; - - else dustDrawPosition.Y = Player.Center.Y - distanceY; + else + dustDrawPosition.Y = Player.Center.Y - distanceY; dustDrawPosition.Y -= 4f; Main.spriteBatch.Draw(TextureAssets.Dust.Value, dustDrawPosition - Main.screenPosition, dust.frame, dust.color, dust.rotation, new Vector2(4f), dust.scale, SpriteEffects.None, 0f); diff --git a/CalPlayer/DrawLayers/AuricSetTrailLayer.cs b/CalPlayer/DrawLayers/AuricSetTrailLayer.cs index 24c742e3de..05ec02fc47 100644 --- a/CalPlayer/DrawLayers/AuricSetTrailLayer.cs +++ b/CalPlayer/DrawLayers/AuricSetTrailLayer.cs @@ -24,11 +24,12 @@ namespace CalamityMod.CalPlayer.DrawLayers { Player drawPlayer = drawInfo.drawPlayer; List existingDrawData = drawInfo.DrawDataCache; - for (float i = 0f; i < drawPlayer.Calamity().OldPositions.Length; i+=0.8f) + float movementSpeedInterpolant = CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); + for (float i = 0f; i < drawPlayer.Calamity().OldPositions.Length; i += 0.8f) { float completionRatio = i / (float)drawPlayer.Calamity().OldPositions.Length; float scale = MathHelper.Lerp(1f, 0.7f, completionRatio); - float opacity = MathHelper.Lerp(0.18f, 0.06f, completionRatio) * CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); + float opacity = MathHelper.Lerp(0.18f, 0.06f, completionRatio) * movementSpeedInterpolant; List afterimages = new List(); for (int j = 0; j < existingDrawData.Count; j++) { diff --git a/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs b/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs index 0a8c3bfca5..7c44e6a59b 100644 --- a/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs +++ b/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs @@ -24,11 +24,12 @@ namespace CalamityMod.CalPlayer.DrawLayers { Player drawPlayer = drawInfo.drawPlayer; List existingDrawData = drawInfo.DrawDataCache; + float movementSpeedInterpolant = CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); for (int i = 0; i < drawPlayer.Calamity().OldPositions.Length; i++) { float completionRatio = i / (float)drawPlayer.Calamity().OldPositions.Length; float scale = MathHelper.Lerp(1f, 0.5f, completionRatio); - float opacity = MathHelper.Lerp(0.23f, 0.07f, completionRatio) * CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); + float opacity = MathHelper.Lerp(0.23f, 0.07f, completionRatio) * movementSpeedInterpolant; List afterimages = new List(); for (int j = 0; j < existingDrawData.Count; j++) { diff --git a/CalPlayer/DrawLayers/ForbiddenSignLayer.cs b/CalPlayer/DrawLayers/ForbiddenSignLayer.cs index 0e283ad12c..288ee55479 100644 --- a/CalPlayer/DrawLayers/ForbiddenSignLayer.cs +++ b/CalPlayer/DrawLayers/ForbiddenSignLayer.cs @@ -56,10 +56,12 @@ namespace CalamityMod.CalPlayer.DrawLayers drawInfo.DrawDataCache.Add(drawData); // Draw 4 semi-transparent copies. + float timeX4 = sinusoidalTime * 4f; + Vector2 origin = texture.Size() * 0.5f; for (float i = 0f; i < 4f; i++) { - float angle = MathHelper.TwoPi / 4f * i; - drawData = new(glowmask, position + angle.ToRotationVector2() * sinusoidalTime * 4f, null, afterimageColor, drawPlayer.bodyRotation, texture.Size() * 0.5f, 1f, spriteEffects, 0); + float angle = MathHelper.PiOver2 * i; + drawData = new(glowmask, position + angle.ToRotationVector2() * timeX4, null, afterimageColor, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0); drawInfo.DrawDataCache.Add(drawData); } } diff --git a/CalPlayer/DrawLayers/GemTechGemLayer.cs b/CalPlayer/DrawLayers/GemTechGemLayer.cs index 71dae348e0..4c49822018 100644 --- a/CalPlayer/DrawLayers/GemTechGemLayer.cs +++ b/CalPlayer/DrawLayers/GemTechGemLayer.cs @@ -22,6 +22,9 @@ namespace CalamityMod.CalPlayer.DrawLayers { Player drawPlayer = drawInfo.drawPlayer; CalamityPlayer modPlayer = drawPlayer.Calamity(); + float opacity = MathHelper.Lerp(0.85f, 1.05f, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 2.3f) * 0.5f + 0.5f); + float time = Main.GlobalTimeWrappedHourly * 0.61f; + float gemTime = Main.GlobalTimeWrappedHourly * 3.41f; for (int i = 5; i >= 0; i--) { Texture2D gemTexture; @@ -61,11 +64,11 @@ namespace CalamityMod.CalPlayer.DrawLayers if (!modPlayer.GemTechState.GemIsActive(gemType)) continue; - float drawOffsetAngle = modPlayer.GemTechState.CalculateGemOffsetAngle(gemType); - float gemOpacity = MathHelper.Lerp(0.85f, 1.05f, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 2.3f) * 0.5f + 0.5f); + float drawOffsetAngle = modPlayer.GemTechState.CalculateGemOffsetAngle(gemType, gemTime); + float gemOpacity = opacity; // Incorporate a sinusoidal pulse into the pulse factor. - pulseFactor *= (float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.61f + drawOffsetAngle); + pulseFactor *= (float)Math.Cos(time + drawOffsetAngle); // Somewhat unorthodox way of creating an illusion of gems being drawn behind the player via orbiting. // Instead of actually messing with a Z position it simply fades away when the sine of the draw @@ -75,12 +78,15 @@ namespace CalamityMod.CalPlayer.DrawLayers Vector2 baseDrawPosition = modPlayer.GemTechState.CalculateGemPosition(gemType) - Main.screenPosition; // Draw back afterimages. + float afterimageTime = Main.GlobalTimeWrappedHourly * 0.47f; + float backAfterImageOpacity = gemOpacity * 0.24f; + Vector2 origin = gemTexture.Size() * 0.5f; for (int j = 0; j < 5; j++) { - Color backAfterimageColor = Main.hslToRgb((Main.GlobalTimeWrappedHourly * 0.47f + j / 5f) % 1f, 1f, 0.67f); - backAfterimageColor = Color.Lerp(backAfterimageColor, Color.White, 0.64f) * gemOpacity * 0.24f; + Color backAfterimageColor = Main.hslToRgb((afterimageTime + j / 5f) % 1f, 1f, 0.67f); + backAfterimageColor = Color.Lerp(backAfterimageColor, Color.White, 0.64f) * backAfterImageOpacity; Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * j / 5f).ToRotationVector2() * pulseFactor; - DrawData gemBackDrawData = new DrawData(gemTexture, drawPosition, null, backAfterimageColor, 0f, gemTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0); + DrawData gemBackDrawData = new DrawData(gemTexture, drawPosition, null, backAfterimageColor, 0f, origin, 1f, SpriteEffects.None, 0); drawInfo.DrawDataCache.Add(gemBackDrawData); } diff --git a/Cooldowns/SandsmokeBomb.cs b/Cooldowns/SandsmokeBomb.cs index 730ca12fa7..971383af77 100644 --- a/Cooldowns/SandsmokeBomb.cs +++ b/Cooldowns/SandsmokeBomb.cs @@ -31,13 +31,15 @@ namespace CalamityMod.Cooldowns public override void OnCompleted() { + Vector2 playerVelocity = instance.player.velocity / 8f; + Vector2 particleGravity = Vector2.UnitY * 0.03f; for (int i = 0; i < 16; i++) { Vector2 dustDisplace = Main.rand.NextVector2Circular(80f, 50f); Vector2 dustPosition = instance.player.MountedCenter + dustDisplace; - Vector2 dustSpeed = Main.rand.NextVector2Circular(0.5f, 0.5f) + instance.player.velocity / 8f - Vector2.UnitY.RotatedByRandom(MathHelper.PiOver4) * 0.06f; + Vector2 dustSpeed = Main.rand.NextVector2Circular(0.5f, 0.5f) + playerVelocity - Vector2.UnitY.RotatedByRandom(MathHelper.PiOver4) * 0.06f; dustSpeed.X += 1.4f * (float)Math.Sin(((dustDisplace.X + 80f) / 160f) * MathHelper.Pi) * (Main.rand.NextBool() ? -1 : 1); - Particle dust = new SandyDustParticle(dustPosition, dustSpeed, Color.White, Main.rand.NextFloat(0.7f, 1.2f), Main.rand.Next(20, 50), 0.03f, Vector2.UnitY * 0.03f); + Particle dust = new SandyDustParticle(dustPosition, dustSpeed, Color.White, Main.rand.NextFloat(0.7f, 1.2f), Main.rand.Next(20, 50), 0.03f, particleGravity); GeneralParticleHandler.SpawnParticle(dust); } } diff --git a/DataStructures/GemTechArmorState.cs b/DataStructures/GemTechArmorState.cs index adb167e9e2..7626e78b26 100644 --- a/DataStructures/GemTechArmorState.cs +++ b/DataStructures/GemTechArmorState.cs @@ -342,14 +342,15 @@ namespace CalamityMod.DataStructures Owner.manaRegen += GemTechHeadgear.NonMagicItemManaRegenBoost; } - public float CalculateGemOffsetAngle(GemTechArmorGemType gemType) + public float CalculateGemOffsetAngle(GemTechArmorGemType gemType, float time) { - return MathHelper.TwoPi * (int)gemType / 6f + Main.GlobalTimeWrappedHourly * 3.41f; + return MathHelper.TwoPi * (int)gemType / 6f + time; } public Vector2 CalculateGemPosition(GemTechArmorGemType gemType) { - Vector2 baseDrawOffsetDirection = CalculateGemOffsetAngle(gemType).ToRotationVector2() * new Vector2(1f, 0.2f); + float gemTime = Main.GlobalTimeWrappedHourly * 3.41f; + Vector2 baseDrawOffsetDirection = CalculateGemOffsetAngle(gemType, gemTime).ToRotationVector2() * new Vector2(1f, 0.2f); Vector2 gemPosition = Owner.Center + baseDrawOffsetDirection * Owner.width * 1.25f; gemPosition.Y += Owner.gfxOffY; if (Owner.mount?.Active ?? false) diff --git a/ILEditing/ILHelperMethods.cs b/ILEditing/ILHelperMethods.cs index 86408ea30e..167e4bd24a 100644 --- a/ILEditing/ILHelperMethods.cs +++ b/ILEditing/ILHelperMethods.cs @@ -137,18 +137,32 @@ namespace CalamityMod.ILEditing new Vector2(x + 0.5f, y + 0.5f), }; + float lerpAmt = (1f - SulphuricWaterSafeZoneSystem.NearbySafeTiles[closestSafeZone]) * 21f; for (int i = 0; i < 4; i++) { float distanceToClosest = points[i].Distance(closestSafeZone.ToVector2()); - float acidicWaterInterpolant = Utils.GetLerpValue(12f, 20.5f, distanceToClosest + (1f - SulphuricWaterSafeZoneSystem.NearbySafeTiles[closestSafeZone]) * 21f, true); - if (i == 0) - initialColor.TopLeftColor = Color.Lerp(initialColor.TopLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); - if (i == 1) - initialColor.TopRightColor = Color.Lerp(initialColor.TopRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); - if (i == 2) - initialColor.BottomLeftColor = Color.Lerp(initialColor.BottomLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); - if (i == 3) - initialColor.BottomRightColor = Color.Lerp(initialColor.BottomRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); + float acidicWaterInterpolant = Utils.GetLerpValue(12f, 20.5f, distanceToClosest + lerpAmt, true); + switch (i) + { + case 0: + initialColor.TopLeftColor = Color.Lerp(initialColor.TopLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); + break; + + case 1: + initialColor.TopRightColor = Color.Lerp(initialColor.TopRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); + break; + + case 2: + initialColor.BottomLeftColor = Color.Lerp(initialColor.BottomLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); + break; + + case 3: + initialColor.BottomRightColor = Color.Lerp(initialColor.BottomRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); + break; + + default: + break; + } } } diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index 78ff25d23e..d29db28d50 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -552,13 +552,12 @@ namespace CalamityMod.ILEditing color = Color.Lerp(color, Color.White, 0.75f); float offsetAngleValue = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 6.7f) * 0.99f; - float horizontalAreaValue = (float)horizontalArea * 0.34f; int origin = size / 2; for (int i = -horizontalArea; i <= horizontalArea; i++) { float offsetAngle = offsetAngleValue; - offsetAngle += i / horizontalAreaValue; + offsetAngle += i / (float)horizontalArea * 0.34f; Vector2 velocity = Main.MouseWorld - UIManagementSystem.PreviousMouseWorld; if (velocity.Length() < 64f) { diff --git a/Items/Accessories/AmidiasPendant.cs b/Items/Accessories/AmidiasPendant.cs index b77b2b3309..deec0c23ce 100644 --- a/Items/Accessories/AmidiasPendant.cs +++ b/Items/Accessories/AmidiasPendant.cs @@ -43,11 +43,13 @@ namespace CalamityMod.Items.Accessories Vector2 baseVelocity = player.Center - baseSpawn; baseVelocity.Normalize(); baseVelocity *= speed2; + int spawnOffset = ShardProjectiles * 15; + float spread = -ShardAngleSpread / 2f; for (int i = 0; i < ShardProjectiles; i++) { Vector2 spawn = baseSpawn; - spawn.X = spawn.X + i * 30 - (ShardProjectiles * 15); - Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-ShardAngleSpread / 2 + (ShardAngleSpread * i / (float)ShardProjectiles))); + spawn.X = spawn.X + i * 30 - spawnOffset; + Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(spread + (ShardAngleSpread * i / (float)ShardProjectiles))); velocity.X = velocity.X + 3 * Main.rand.NextFloat() - 1.5f; int type = 0; int damage = 0; @@ -67,7 +69,7 @@ namespace CalamityMod.Items.Accessories break; } int finalDamage = (int)player.GetBestClassDamage().ApplyTo(damage); - Projectile.NewProjectile(source, spawn.X, spawn.Y, velocity.X / 3, velocity.Y / 2, type, finalDamage, 5f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(source, spawn.X, spawn.Y, velocity.X / 3, velocity.Y / 2, type, finalDamage, 5f, Main.myPlayer); } } } diff --git a/Items/Accessories/MarniteRepulsionShield.cs b/Items/Accessories/MarniteRepulsionShield.cs index b269debdfe..d03afe5221 100644 --- a/Items/Accessories/MarniteRepulsionShield.cs +++ b/Items/Accessories/MarniteRepulsionShield.cs @@ -109,12 +109,14 @@ namespace CalamityMod.Items.Accessories Vector2 dustDirection = (Vector2.UnitX * -1 * Owner.direction).RotatedByRandom(MathHelper.PiOver2 * 0.93f); dustOrigin += dustDirection * 14f; float spikeSpeed = Main.rand.NextFloat(1f, 3f); + Vector2 dustVelocity = dustDirection * spikeSpeed + Owner.velocity; + Vector2 dustOriginOffset = dustDirection * 4f; for (int i = 0; i < 5; i++) { - Dust dust = Dust.NewDustPerfect(dustOrigin, 229, dustDirection * spikeSpeed + Owner.velocity, 120, Scale: Main.rand.NextFloat(0.6f, 1f)); + Dust dust = Dust.NewDustPerfect(dustOrigin, 229, dustVelocity, 120, Scale: Main.rand.NextFloat(0.6f, 1f)); dust.noGravity = true; - dustOrigin += dustDirection * 4f; + dustOrigin += dustOriginOffset; } } } diff --git a/Items/Accessories/RoverDrive.cs b/Items/Accessories/RoverDrive.cs index 8dfa6e76d4..bcb757cc18 100644 --- a/Items/Accessories/RoverDrive.cs +++ b/Items/Accessories/RoverDrive.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Items.Accessories float scale = 0.15f + 0.03f * (0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.5f + i * 0.2f)); - if (playerFound == false) + if (!playerFound) { float shieldStrentgh = forcedVisibility ? 1f : (float)Math.Pow(Main.LocalPlayer.GetModPlayer().ProtectionMatrixDurability / (float)ProtectionMatrixDurabilityMax, 0.5f); float noiseScale = MathHelper.Lerp(0.4f, 0.8f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.3f) * 0.5f + 0.5f); diff --git a/Items/Armor/LunicCorps/LunicCorpsHelmet.cs b/Items/Armor/LunicCorps/LunicCorpsHelmet.cs index f110b562b1..a48f245e2f 100644 --- a/Items/Armor/LunicCorps/LunicCorpsHelmet.cs +++ b/Items/Armor/LunicCorps/LunicCorpsHelmet.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Items.Armor.LunicCorps float scale = 0.11f + 0.022f * (0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.5f + i * 0.2f)); - if (playerFound == false) + if (!playerFound) { float shieldStrentgh = (float)Math.Pow(Main.LocalPlayer.GetModPlayer().masterChefShieldDurability / (float)MasterChefShieldDurabilityMax, 0.5f); float noiseScale = MathHelper.Lerp(0.4f, 0.8f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.3f) * 0.5f + 0.5f); diff --git a/Items/Materials/AshesofAnnihilation.cs b/Items/Materials/AshesofAnnihilation.cs index 9ef182d567..7f78bed34a 100644 --- a/Items/Materials/AshesofAnnihilation.cs +++ b/Items/Materials/AshesofAnnihilation.cs @@ -36,11 +36,14 @@ namespace CalamityMod.Items.Materials float outwardness = pulse * baseScale * 8f; Color drawColor = Color.BlueViolet * (float)Math.Sqrt(1f - pulse) * 0.7f; drawColor.A = 0; + float scale = baseScale * MathHelper.Lerp(1f, 1.45f, pulse); + Vector2 drawPositionOffset = Vector2.UnitY * 2f; + float velocity = Item.velocity.X * 0.2f; + Vector2 origin = frame.Size() * 0.5f; for (int i = 0; i < 4; i++) { - float scale = baseScale * MathHelper.Lerp(1f, 1.45f, pulse); - Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * outwardness - Vector2.UnitY * 2f; - spriteBatch.Draw(TextureAssets.Item[Item.type].Value, drawPosition, frame, drawColor, Item.velocity.X * 0.2f, frame.Size() * 0.5f, scale, SpriteEffects.None, 0f); + Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * outwardness - drawPositionOffset; + spriteBatch.Draw(TextureAssets.Item[Item.type].Value, drawPosition, frame, drawColor, velocity, origin, scale, SpriteEffects.None, 0f); } } diff --git a/Items/Materials/ExoPrism.cs b/Items/Materials/ExoPrism.cs index 016b682b82..d3dc3348ef 100644 --- a/Items/Materials/ExoPrism.cs +++ b/Items/Materials/ExoPrism.cs @@ -31,11 +31,13 @@ namespace CalamityMod.Items.Materials float outwardnessFactor = MathHelper.Lerp(0.9f, 1.3f, pulse); Color drawColor = Color.MintCream * (1f - pulse) * 0.27f; drawColor.A = 0; + float scale = baseScale * outwardnessFactor; + float velocity = Item.velocity.X * 0.2f; + Vector2 origin = frame.Size() * 0.5f; for (int i = 0; i < 4; i++) { - float scale = baseScale * outwardnessFactor; Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 4f; - spriteBatch.Draw(TextureAssets.Item[Item.type].Value, drawPosition, frame, drawColor, Item.velocity.X * 0.2f, frame.Size() * 0.5f, scale, SpriteEffects.None, 0f); + spriteBatch.Draw(TextureAssets.Item[Item.type].Value, drawPosition, frame, drawColor, velocity, origin, scale, SpriteEffects.None, 0f); } } diff --git a/Items/Materials/MiracleMatter.cs b/Items/Materials/MiracleMatter.cs index 55c58e03b7..0e77633698 100644 --- a/Items/Materials/MiracleMatter.cs +++ b/Items/Materials/MiracleMatter.cs @@ -43,9 +43,10 @@ namespace CalamityMod.Items.Materials Color drawColor = Color.Lerp(new Color(255, 218, 99), new Color(249, 134, 44), pulse); drawColor *= MathHelper.Lerp(0.35f, 0.67f, CalamityUtils.Convert01To010(pulse)); drawColor.A = 25; + float drawPositionOffset = outwardnessFactor * baseScale * 8f; for (int i = 0; i < 8; i++) { - Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 8f).ToRotationVector2() * outwardnessFactor * baseScale * 8f; + Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 8f).ToRotationVector2() * drawPositionOffset; spriteBatch.Draw(TextureAssets.Item[Item.type].Value, drawPosition, frame, drawColor, 0f, Vector2.Zero, baseScale, SpriteEffects.None, 0f); } } diff --git a/Items/Materials/PlasmaDriveCore.cs b/Items/Materials/PlasmaDriveCore.cs index ba255eecfa..aded54296f 100644 --- a/Items/Materials/PlasmaDriveCore.cs +++ b/Items/Materials/PlasmaDriveCore.cs @@ -37,10 +37,11 @@ namespace CalamityMod.Items.Materials GameShaders.Misc["CalamityMod:BasicTint"].Apply(); float outlineWidth = MathHelper.Lerp(2, 3, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2f) * 0.5f + 0.5f); + float positionOffset = outlineWidth * scale; for (float i = 0; i < 1; i += 0.25f) { - spriteBatch.Draw(tex, position + (i * MathHelper.TwoPi).ToRotationVector2() * outlineWidth * scale, frame, outlineColor, 0f, origin, scale, 0f, 0f); + spriteBatch.Draw(tex, position + (i * MathHelper.TwoPi).ToRotationVector2() * positionOffset, frame, outlineColor, 0f, origin, scale, 0f, 0f); } spriteBatch.End(); diff --git a/Items/Weapons/Melee/Hellkite.cs b/Items/Weapons/Melee/Hellkite.cs index 7f03619fdf..51accfa0b6 100644 --- a/Items/Weapons/Melee/Hellkite.cs +++ b/Items/Weapons/Melee/Hellkite.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Melee } // NOTE: Modded item variants don't seem to be supported as of now, so this is probably temporary (also there is no way around modifiers screwing rarity/value in some way) - public override void ModifyWeaponDamage(Player player, ref StatModifier damage) => damage += (Main.zenithWorld ? (1369f / 180f - 1f) : 0f); + public override void ModifyWeaponDamage(Player player, ref StatModifier damage) => damage += (Main.zenithWorld ? (1669f / 180f - 1f) : 0f); public override void ModifyWeaponKnockback(Player player, ref StatModifier knockback) => knockback += (Main.zenithWorld ? 1.5f : 0f); public override float UseSpeedMultiplier(Player player) => Main.zenithWorld ? 2.5f : 1f; public override void ModifyItemScale(Player player, ref float scale) => scale *= (Main.zenithWorld ? 2.5f : 1f); diff --git a/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson b/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson index 77dff1d251..a7d0e850c6 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson @@ -76,7 +76,7 @@ CryoKey: { Not consumable ''' SpawnNormal: Summons Cryogen when used in the tundra - SpawnGFB: Summons Pryogen...? when used in the tundra + SpawnGFB: Summons Cryogen...? when used in the tundra } DeathWhistle: { diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index e6bd96f69f..bb5889922e 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -4936,6 +4936,7 @@ namespace CalamityMod.NPCs #region Edit Spawn Pool internal static readonly FieldInfo MaxSpawnsField = typeof(NPC).GetField("maxSpawns", BindingFlags.NonPublic | BindingFlags.Static); + public static void AttemptToSpawnLabCritters(Player player) { if (Main.netMode == NetmodeID.MultiplayerClient) @@ -4949,19 +4950,26 @@ namespace CalamityMod.NPCs if (player.nearbyActiveNPCs >= maxSpawnCount) return; + float playerCenterX = player.Center.X / 16f; + float playerCenterY = player.Center.Y / 16f; + Vector2 sunkenSeaLabCenter = CalamityWorld.SunkenSeaLabCenter / 16f; + Vector2 planetoidLabCenter = CalamityWorld.PlanetoidLabCenter / 16f; + Vector2 jungleLabCenter = CalamityWorld.JungleLabCenter / 16f; + Vector2 hellLabCenter = CalamityWorld.HellLabCenter / 16f; + Vector2 iceLabCenter = CalamityWorld.IceLabCenter / 16f; for (int i = 0; i < 8; i++) { - int checkPositionX = (int)(player.Center.X / 16 + Main.rand.Next(30, 54) * Main.rand.NextBool(2).ToDirectionInt()); - int checkPositionY = (int)(player.Center.Y / 16 + Main.rand.Next(24, 45) * Main.rand.NextBool(2).ToDirectionInt()); + int checkPositionX = (int)(playerCenterX + Main.rand.Next(30, 54) * Main.rand.NextBool(2).ToDirectionInt()); + int checkPositionY = (int)(playerCenterY + Main.rand.Next(24, 45) * Main.rand.NextBool(2).ToDirectionInt()); Vector2 checkPosition = new Vector2(checkPositionX, checkPositionY); Tile aboveSpawnTile = CalamityUtils.ParanoidTileRetrieval(checkPositionX, checkPositionY - 1); - bool nearLab = CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.SunkenSeaLabCenter / 16f) < 180f; - nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.PlanetoidLabCenter / 16f) < 180f; - nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.JungleLabCenter / 16f) < 180f; - nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.HellLabCenter / 16f) < 180f; - nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.IceLabCenter / 16f) < 180f; - bool nearPlagueLab = CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.JungleLabCenter / 16f) < 180f; + bool nearLab = CalamityUtils.ManhattanDistance(checkPosition, sunkenSeaLabCenter) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, planetoidLabCenter) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, jungleLabCenter) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, hellLabCenter) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, iceLabCenter) < 180f; + bool nearPlagueLab = CalamityUtils.ManhattanDistance(checkPosition, jungleLabCenter) < 180f; bool isLabWall = aboveSpawnTile.WallType == WallType() || aboveSpawnTile.WallType == WallType() || aboveSpawnTile.WallType == WallType(); isLabWall |= aboveSpawnTile.WallType == WallType() || aboveSpawnTile.WallType == WallType() || aboveSpawnTile.WallType == WallType(); @@ -5784,6 +5792,8 @@ namespace CalamityMod.NPCs alpha15.G = (byte)(alpha15.G * num212); alpha15.B = (byte)(alpha15.B * num212); alpha15.A = (byte)(alpha15.A * num212); + float xOffset = screenPos.X + npc.width / 2 - TextureAssets.Npc[npc.type].Value.Width * npc.scale / 2f + vector11.X * npc.scale; + float yOffset = screenPos.Y + npc.height - TextureAssets.Npc[npc.type].Value.Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + vector11.Y * npc.scale + num66 + npc.gfxOffY; for (int num213 = 0; num213 < 4; num213++) { Vector2 position9 = npc.position; @@ -5791,28 +5801,20 @@ namespace CalamityMod.NPCs float num215 = Math.Abs(npc.Center.Y - Main.LocalPlayer.Center.Y); if (num213 == 0 || num213 == 2) - { position9.X = Main.LocalPlayer.Center.X + num214; - } else - { position9.X = Main.LocalPlayer.Center.X - num214; - } position9.X -= npc.width / 2; if (num213 == 0 || num213 == 1) - { position9.Y = Main.LocalPlayer.Center.Y + num215; - } else - { position9.Y = Main.LocalPlayer.Center.Y - num215; - } position9.Y -= npc.height / 2; - Main.spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position9.X - screenPos.X + npc.width / 2 - TextureAssets.Npc[npc.type].Value.Width * npc.scale / 2f + vector11.X * npc.scale, position9.Y - screenPos.Y + npc.height - TextureAssets.Npc[npc.type].Value.Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + vector11.Y * npc.scale + num66 + npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(npc.frame), alpha15, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Main.spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position9.X - xOffset, position9.Y - yOffset), new Microsoft.Xna.Framework.Rectangle?(npc.frame), alpha15, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } else @@ -6070,16 +6072,18 @@ namespace CalamityMod.NPCs if ((newAI[3] >= 900f && destroyerLifeRatio < 0.5f) || (newAI[1] < 600f && newAI[1] > 60f)) { + Color drawColor2 = new Color(50, 50, 255, 0) * (1f - npc.alpha / 255f); for (int i = 0; i < 3; i++) { spriteBatch.Draw(TextureAssets.Dest[npc.type - NPCID.TheDestroyer].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, - new Color(50, 50, 255, 0) * (1f - npc.alpha / 255f), npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); } } else { + Color drawColor2 = new Color(255, 255, 255, 0) * (1f - npc.alpha / 255f); spriteBatch.Draw(TextureAssets.Dest[npc.type - NPCID.TheDestroyer].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, - new Color(255, 255, 255, 0) * (1f - npc.alpha / 255f), npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); } } } diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 2939744935..73c57d3bb0 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -1279,7 +1279,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { if (giveUpCounter > 1) { - // Spin around the target and fire a bunch of beams (Sans) while also firing other projectiles + // Spin around the target and fire a bunch of beams (Sans) while also firing other projectiles. int blasterTimer = GiveUpCounterMax - giveUpCounter; Vector2 circleOffset = player.Center + (Vector2.UnitY * 640f).RotatedBy(MathHelper.ToRadians(blasterTimer * 3f)); NPC.Center = circleOffset; diff --git a/Particles/ConstellationRing.cs b/Particles/ConstellationRing.cs index b5277b1239..9fa016a6e3 100644 --- a/Particles/ConstellationRing.cs +++ b/Particles/ConstellationRing.cs @@ -50,7 +50,6 @@ namespace CalamityMod.Particles for (int i = 0; i < StarAmount; i++) { - float starHeight = (float)Math.Sin(Offset + Main.GlobalTimeWrappedHourly * SpinSpeed + i * MathHelper.TwoPi / (float)StarAmount); float starWidth = (float)Math.Cos(Offset + Main.GlobalTimeWrappedHourly * SpinSpeed + i * MathHelper.TwoPi / (float)StarAmount); diff --git a/Projectiles/Boss/CirrusPhotonRipperProjectile.cs b/Projectiles/Boss/CirrusPhotonRipperProjectile.cs index c36d645c03..d1ebade1d9 100644 --- a/Projectiles/Boss/CirrusPhotonRipperProjectile.cs +++ b/Projectiles/Boss/CirrusPhotonRipperProjectile.cs @@ -168,11 +168,11 @@ namespace CalamityMod.Projectiles.Boss { Vector2 idealAimDirection = (Main.player[Cirrus.target].Center - cirrusRotatedPosition).SafeNormalize(Vector2.UnitX * Cirrus.direction); - float angularAimVelocity = 0.15f; + float angularAimVelocity = 0.03f; float directionAngularDisparity = Projectile.velocity.AngleBetween(idealAimDirection) / MathHelper.Pi; // Increase the turn speed if close to the ideal direction, since successive linear interpolations are asymptotic. - angularAimVelocity += MathHelper.Lerp(0f, 0.25f, Utils.GetLerpValue(0.28f, 0.08f, directionAngularDisparity, true)); + angularAimVelocity += MathHelper.Lerp(0f, 0.05f, Utils.GetLerpValue(0.28f, 0.08f, directionAngularDisparity, true)); if (directionAngularDisparity > 0.02f) Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealAimDirection, angularAimVelocity); diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 310e53046e..c0505245b5 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -208,7 +208,7 @@ namespace CalamityMod.Projectiles // Reduce secondary yoyo damage if the player has Yoyo Glove // Brief behavior documentation of yoyo AI: ai[0, 1] are the x, y co-ords and localAI[0] is the airtime in frames // All secondary yoyos are spawned with ai[0] of 1 which tells then tell its AI to do secondary yoyo AI - if (Main.player[projectile.owner].yoyoGlove && projectile.aiStyle == 99) + if (Main.player[projectile.owner].yoyoGlove && projectile.aiStyle == ProjAIStyleID.Yoyo) { // Store damage on first frame if (projectile.ai[2] == 0f) @@ -2772,6 +2772,8 @@ namespace CalamityMod.Projectiles Color color9 = new(Main.DiscoR, Main.DiscoG, Main.DiscoB, projectile.alpha); Color alpha15 = projectile.GetAlpha(color9); + float offsetX = Main.screenPosition.X + (projectile.width / 2) - texture.Width * projectile.scale / 2f + vector11.X * projectile.scale; + float offsetY = Main.screenPosition.Y + projectile.height - texture.Height * projectile.scale / Main.projFrames[projectile.type] + 4f + vector11.Y * projectile.scale + projectile.gfxOffY; for (int num213 = 0; num213 < 4; num213++) { Vector2 position9 = projectile.position; @@ -2795,7 +2797,7 @@ namespace CalamityMod.Projectiles position9.Y -= projectile.height / 2; Main.spriteBatch.Draw(texture, - new Vector2(position9.X - Main.screenPosition.X + (projectile.width / 2) - texture.Width * projectile.scale / 2f + vector11.X * projectile.scale, position9.Y - Main.screenPosition.Y + projectile.height - texture.Height * projectile.scale / Main.projFrames[projectile.type] + 4f + vector11.Y * projectile.scale + projectile.gfxOffY), + new Vector2(position9.X - offsetX, position9.Y - offsetY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y, texture.Width, frames)), alpha15, projectile.rotation, vector11, projectile.scale, spriteEffects, 0); } } diff --git a/Skies/DrunkCrabScreenShaderData.cs b/Skies/DrunkCrabScreenShaderData.cs index ac82d87a10..6eee00117e 100644 --- a/Skies/DrunkCrabScreenShaderData.cs +++ b/Skies/DrunkCrabScreenShaderData.cs @@ -25,38 +25,45 @@ namespace CalamityMod.Skies int CrabType = ModContent.NPCType(); int CirrusType = ModContent.NPCType(); bool shouldCheckForCirrus = false; + bool shouldForceDeactivateCirrusShader = false; if (CalamityGlobalNPC.SCal != -1) { if (Main.npc[CalamityGlobalNPC.SCal].active) { if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().cirrus) + { shouldCheckForCirrus = Main.npc[CalamityGlobalNPC.SCal].ModNPC().gettingTired5; + shouldForceDeactivateCirrusShader = Main.npc[CalamityGlobalNPC.SCal].ModNPC().giveUpCounter <= 1; + } } } if (shouldCheckForCirrus) { - if (CirrusIndex >= 0 && Main.npc[CirrusIndex].active && Main.npc[CirrusIndex].type == CirrusType) - { + if (CirrusIndex >= 0 && Main.npc[CirrusIndex].active && Main.npc[CirrusIndex].type == CirrusType && !shouldForceDeactivateCirrusShader) return; - } + CirrusIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) + + if (!shouldForceDeactivateCirrusShader) { - if (Main.npc[i].active && Main.npc[i].type == CirrusType) + for (int i = 0; i < Main.npc.Length; i++) { - CirrusIndex = i; - break; + if (Main.npc[i].active && Main.npc[i].type == CirrusType) + { + CirrusIndex = i; + break; + } } } } else { if (CrabIndex >= 0 && Main.npc[CrabIndex].active && Main.npc[CrabIndex].type == CrabType) - { return; - } + CrabIndex = -1; + for (int i = 0; i < Main.npc.Length; i++) { if (Main.npc[i].active && Main.npc[i].type == CrabType) diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index f2126c15f8..926bee0dd5 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -479,6 +479,8 @@ namespace CalamityMod maxTrailPoints = (int)projectile.localAI[0]; Vector2 cumulativeOffset = Vector2.Zero; + Color alpha = projectile.GetAlpha(lightColor); + float fixedRotation = projectile.rotation + MathHelper.PiOver2; for (int i = 1; i <= (int)projectile.localAI[0]; i++) { Vector2 velToUseThisIter = projectile.velocity; @@ -493,10 +495,9 @@ namespace CalamityMod } } cumulativeOffset += Vector2.Normalize(velToUseThisIter) * spacer; - Color color = projectile.GetAlpha(lightColor); + Color color = alpha; color *= (maxTrailPoints - (float)i) / maxTrailPoints; color.A = 0; - float fixedRotation = projectile.rotation + MathHelper.PiOver2; Main.spriteBatch.Draw(texture, drawPos - cumulativeOffset, null, color, fixedRotation, origin, projectile.scale, spriteEffects, 0f); } } @@ -548,9 +549,10 @@ namespace CalamityMod float time = Main.player[projectile.owner].miscCounter % 216000f / 60f; Color outerColor = outer * 0.2f; outerColor.A = 0; + float rotation = MathHelper.TwoPi * time; for (int o = 0; o < 6; o += 2) { - Vector2 spinStart = drawStartOuter + spinPoint.RotatedBy(MathHelper.TwoPi * time - MathHelper.Pi * o / 3f); + Vector2 spinStart = drawStartOuter + spinPoint.RotatedBy(rotation - MathHelper.Pi * o / 3f); float scaleMultOuter = 1.5f - o * 0.1f; Main.EntitySpriteDraw(aura, spinStart, auraRec, outerColor, auraRotation, auraOrigin, scaleMultOuter, SpriteEffects.None, 0); } @@ -565,9 +567,8 @@ namespace CalamityMod scaleMult = (scaleMult + i) % 1f; float colorMult = scaleMult * 2f; if (colorMult > 1f) - { colorMult = 2f - colorMult; - } + Main.EntitySpriteDraw(aura, drawStartInner, auraRec, innerColor * colorMult, auraRotation, auraOrigin, 0.3f + scaleMult * 0.5f, SpriteEffects.None, 0); } } @@ -596,11 +597,13 @@ namespace CalamityMod } bool canKillWalls = false; + float projectilePositionX = projectile.position.X / 16f; + float projectilePositionY = projectile.position.Y / 16f; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { - Vector2 explodeArea = new Vector2(Math.Abs(x - projectile.position.X / 16f), Math.Abs(y - projectile.position.Y / 16f)); + Vector2 explodeArea = new Vector2(Math.Abs(x - projectilePositionX), Math.Abs(y - projectilePositionY)); float distance = explodeArea.Length(); if (distance < explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].WallType == WallID.None) { @@ -644,7 +647,7 @@ namespace CalamityMod Tile tile = Main.tile[i, j]; bool t = 1 == 1; bool f = 1 == 2; - Vector2 explodeArea = new Vector2(Math.Abs(i - projectile.position.X / 16f), Math.Abs(j - projectile.position.Y / 16f)); + Vector2 explodeArea = new Vector2(Math.Abs(i - projectilePositionX), Math.Abs(j - projectilePositionY)); float distance = explodeArea.Length(); if (distance < explosionRadius) { @@ -654,14 +657,11 @@ namespace CalamityMod if (checkExplosions) { if (Main.tileDungeon[tile.TileType] || explosionCheckList.Contains(tile.TileType)) - { canKillTile = false; - } if (!TileLoader.CanExplode(i, j)) - { canKillTile = false; - } } + if (Main.tileContainer[tile.TileType]) canKillTile = false; if (!TileLoader.CanKillTile(i, j, tile.TileType, ref t) || !TileLoader.CanKillTile(i, j, tile.TileType, ref f)) @@ -673,11 +673,10 @@ namespace CalamityMod { WorldGen.KillTile(i, j, false, false, false); if (!tile.HasTile && Main.netMode != NetmodeID.SinglePlayer) - { NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, i, j, 0f, 0, 0, 0); - } } } + if (canKillTile) { for (int x = i - 1; x <= i + 1; x++) @@ -689,13 +688,12 @@ namespace CalamityMod canExplode = WallLoader.CanExplode(x, y, Main.tile[x, y].WallType); if (wallExcludeList.Any() && wallExcludeList.Contains(Main.tile[x, y].WallType)) canKillWalls = false; + if (Main.tile[x, y] != null && Main.tile[x, y].WallType > WallID.None && canKillWalls && canExplode) { WorldGen.KillWall(x, y, false); if (Main.tile[x, y].WallType == WallID.None && Main.netMode != NetmodeID.SinglePlayer) - { NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 2, x, y, 0f, 0, 0, 0); - } } } } diff --git a/Utilities/TileFraming.cs b/Utilities/TileFraming.cs index b621f6a70c..81c30b5627 100644 --- a/Utilities/TileFraming.cs +++ b/Utilities/TileFraming.cs @@ -206,8 +206,10 @@ namespace CalamityMod return false; for (int i = 0; i < PlantCheckAgainst[plant].Length; ++i) + { if (PlantCheckAgainst[plant][i] == check) return false; + } return true; } diff --git a/Utilities/TileUtils.cs b/Utilities/TileUtils.cs index 24df06d0a1..543f728b5b 100644 --- a/Utilities/TileUtils.cs +++ b/Utilities/TileUtils.cs @@ -62,18 +62,16 @@ namespace CalamityMod { if (xIter < 0 || xIter >= Main.maxTilesX) continue; + for (int yIter = y - 1; yIter <= y + 1; yIter++) { if (yIter < 0 || yIter >= Main.maxTilesY) continue; + if (xIter == x && yIter == y) - { WorldGen.TileFrame(x, y, resetFrame, false); - } else - { WorldGen.TileFrame(xIter, yIter, false, false); - } } } } @@ -82,31 +80,27 @@ namespace CalamityMod { int x = i - Main.tile[i, j].TileFrameX / 18 % tileX; int y = j - Main.tile[i, j].TileFrameY / 18 % tileY; + int tileXX18 = 18 * tileX; for (int l = x; l < x + tileX; l++) { for (int m = y; m < y + tileY; m++) { if (Main.tile[l, m].HasTile && Main.tile[l, m].TileType == type) { - if (Main.tile[l, m].TileFrameX < (18 * tileX)) - { - Main.tile[l, m].TileFrameX += (short)(18 * tileX); - } + if (Main.tile[l, m].TileFrameX < tileXX18) + Main.tile[l, m].TileFrameX += (short)(tileXX18); else - { - Main.tile[l, m].TileFrameX -= (short)(18 * tileX); - } + Main.tile[l, m].TileFrameX -= (short)(tileXX18); } } } + if (Wiring.running) { for (int k = 0; k < tileX; k++) { for (int l = 0; l < tileY; l++) - { Wiring.SkipWire(x + k, y + l); - } } } } @@ -121,12 +115,13 @@ namespace CalamityMod int yOffset = TileObjectData.GetTileData(tile).DrawYOffset; ulong num190 = Main.TileFrameSeed ^ (ulong)((long)j << 32 | (long)(uint)i); - + float drawPositionX = i * 16 - (int)Main.screenPosition.X - (width - 16f) / 2f; + float drawPositionY = j * 16 - (int)Main.screenPosition.Y; for (int c = 0; c < 7; c++) { float shakeX = Utils.RandomInt(ref num190, -10, 11) * 0.15f; float shakeY = Utils.RandomInt(ref num190, -10, 1) * 0.35f; - Main.spriteBatch.Draw(flameTexture, new Vector2(i * 16 - (int)Main.screenPosition.X - (width - 16f) / 2f + shakeX, j * 16 - (int)Main.screenPosition.Y + shakeY + yOffset) + zero, new Rectangle(tile.TileFrameX + offsetX, tile.TileFrameY + offsetY, width, height), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(flameTexture, new Vector2(drawPositionX + shakeX, drawPositionY + shakeY + yOffset) + zero, new Rectangle(tile.TileFrameX + offsetX, tile.TileFrameY + offsetY, width, height), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } } @@ -171,11 +166,13 @@ namespace CalamityMod { int width = flameTexture.Width; int height = flameTexture.Height; + float drawPositionX = item.position.X - Main.screenPosition.X + item.width * 0.5f; + float drawPositionY = item.position.Y - Main.screenPosition.Y + item.height - flameTexture.Height * 0.5f + 2f; for (int c = 0; c < 7; c++) { float shakeX = Main.rand.Next(-10, 11) * 0.15f; float shakeY = Main.rand.Next(-10, 1) * 0.35f; - Main.spriteBatch.Draw(flameTexture, new Vector2(item.position.X - Main.screenPosition.X + item.width * 0.5f + shakeX, item.position.Y - Main.screenPosition.Y + item.height - flameTexture.Height * 0.5f + 2f + shakeY), new Rectangle(0, 0, width, height), new Color(100, 100, 100, 0), 0f, default, 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(flameTexture, new Vector2(drawPositionX + shakeX, drawPositionY + shakeY), new Rectangle(0, 0, width, height), new Color(100, 100, 100, 0), 0f, default, 1f, SpriteEffects.None, 0f); } } @@ -239,6 +236,7 @@ namespace CalamityMod { if (WorldGen.InWorld(i, j)) continue; + if (WorldGen.SolidTile(Framing.GetTileSafely(i, j))) return true; } @@ -254,6 +252,7 @@ namespace CalamityMod { if (!WorldGen.InWorld(i, j)) return false; + if (!WorldGen.SolidTile(Framing.GetTileSafely(i, j))) return false; } @@ -269,6 +268,7 @@ namespace CalamityMod { if (!WorldGen.InWorld(i, j)) return false; + if (!WorldGen.SolidTile(Framing.GetTileSafely(i, j))) return false; } diff --git a/Walls/VoidstoneWall.cs b/Walls/VoidstoneWall.cs index 937ec1998b..21170ca508 100644 --- a/Walls/VoidstoneWall.cs +++ b/Walls/VoidstoneWall.cs @@ -54,10 +54,11 @@ namespace CalamityMod.Walls Vector2 pos = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero; Main.spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8 + xOff, -8), frame, Lighting.GetColor(i, j, Color.White), 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + Color glowColor = drawcolor * 0.4f; for (int k = 0; k < 3; k++) { Vector2 offset = new Vector2(Main.rand.NextFloat(-1, 1f), Main.rand.NextFloat(-1, 1f)) * 0.2f * k; - Main.spriteBatch.Draw(GlowTexture, pos + offset + new Vector2(-8 + xOff, -8), frame, drawcolor * 0.4f, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(GlowTexture, pos + offset + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } } diff --git a/Walls/VoidstoneWallUnsafe.cs b/Walls/VoidstoneWallUnsafe.cs index 4f88ec3d09..a633899346 100644 --- a/Walls/VoidstoneWallUnsafe.cs +++ b/Walls/VoidstoneWallUnsafe.cs @@ -60,10 +60,11 @@ namespace CalamityMod.Walls Vector2 pos = new Vector2((i * 16 - (int)Main.screenPosition.X), (j * 16 - (int)Main.screenPosition.Y)) + zero; Main.spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8 + xOff, -8), frame, Lighting.GetColor(i, j, Color.White), 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + Color glowColor = drawcolor * 0.4f; for (int k = 0; k < 3; k++) { - Vector2 offset = new Vector2(Main.rand.NextFloat(-1, 1f), Main.rand.NextFloat(-1, 1f)) * 0.2f * k; - Main.spriteBatch.Draw(GlowTexture, pos + offset + new Vector2(-8 + xOff, -8), frame, drawcolor * 0.4f, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + Vector2 offset = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)) * 0.2f * k; + Main.spriteBatch.Draw(GlowTexture, pos + offset + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } } diff --git a/World/UndergroundShrines.cs b/World/UndergroundShrines.cs index a508bee98e..88e7c8e8c6 100644 --- a/World/UndergroundShrines.cs +++ b/World/UndergroundShrines.cs @@ -15,6 +15,8 @@ using Terraria.ModLoader; using Terraria.WorldBuilding; using static CalamityMod.Schematics.SchematicManager; +using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Potions; namespace CalamityMod.World { @@ -62,6 +64,22 @@ namespace CalamityMod.World new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), }; + if (Main.zenithWorld) + { + int evil = Utils.SelectRandom(WorldGen.genRand, ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType()); + contents = new List() + { + new ChestItem(ModContent.ItemType(), 1), + new ChestItem(ItemID.RottenChunk, WorldGen.genRand.Next(24, 28 + 1)), + new ChestItem(ItemID.CorruptionKey, 1), + new ChestItem(ItemID.CorruptTorch, WorldGen.genRand.Next(100, 110 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(evil, 1), + new ChestItem(ItemID.RedPotion, WorldGen.genRand.Next(1, 2 + 1)), + new ChestItem(ItemID.GasTrap,1), + }; + } + for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); @@ -136,6 +154,23 @@ namespace CalamityMod.World new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), }; + //Gfb loot change + if (Main.zenithWorld) + { + //Cannot modify the return value of List.this[int] because its not a variable so gotta do this instead + contents = new List() + { + new ChestItem(ModContent.ItemType(), 1), + new ChestItem(ItemID.Vertebrae, WorldGen.genRand.Next(24, 28 + 1)), + new ChestItem(ItemID.CrimsonKey, 1), + new ChestItem(ItemID.CrimsonTorch, WorldGen.genRand.Next(100, 110 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ModContent.ItemType(), WorldGen.genRand.Next(2, 2 + 1)), + new ChestItem(ItemID.RedPotion, WorldGen.genRand.Next(1, 2 + 1)), + new ChestItem(ItemID.GasTrap, 1), + }; + } + for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); @@ -211,6 +246,21 @@ namespace CalamityMod.World new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), }; + if (Main.zenithWorld) + { + int golfClub = Utils.SelectRandom(WorldGen.genRand, ItemID.GolfClubBronzeWedge, ItemID.GolfClubWedge, ItemID.GasTrap); + contents = new List() + { + new ChestItem(ModContent.ItemType(), 1), + new ChestItem(ModContent.ItemType(), WorldGen.genRand.Next(6, 8 + 1)), + new ChestItem(ItemID.DungeonDesertKey, 1), + new ChestItem(ItemID.DesertTorch, WorldGen.genRand.Next(100, 110 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ModContent.ItemType(), 1), + new ChestItem(ItemID.RedPotion, WorldGen.genRand.Next(1, 2 + 1)), + new ChestItem(golfClub, 1), //Implying that the golfer messed with the loot but forgot this, OR its trapped + }; + } for (int i = 0; i < contents.Count; i++) { @@ -267,6 +317,9 @@ namespace CalamityMod.World public static void FillGraniteShrineChest(Chest chest) { int potionType = Utils.SelectRandom(WorldGen.genRand, ItemID.EndurancePotion, ItemID.HeartreachPotion, ItemID.LifeforcePotion); + if (Main.zenithWorld) + potionType = ItemID.RedPotion; + List contents = new List() { new ChestItem(ModContent.ItemType(), 1), @@ -274,7 +327,8 @@ namespace CalamityMod.World new ChestItem(ItemID.BlueTorch, WorldGen.genRand.Next(100, 110 + 1)), new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), - new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), + new ChestItem(potionType, WorldGen.genRand.Next(Main.zenithWorld ? 1 : 10, (Main.zenithWorld ? 2 : 12) + 1)), + new ChestItem((Main.rand.NextBool(2) && Main.zenithWorld) ? ItemID.GasTrap : ItemID.Granite, Main.zenithWorld ? 1 : WorldGen.genRand.Next(7,15+1)), }; for (int i = 0; i < contents.Count; i++) @@ -291,7 +345,7 @@ namespace CalamityMod.World do { int placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.1f), (int)(Main.maxTilesX * 0.9f)); - int placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.3f), (int)(Main.maxTilesY * 0.85f)); + int placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.2f), (int)(Main.maxTilesY * 0.85f)); Point placementPoint = new Point(placementPositionX, placementPositionY); Vector2 schematicSize = new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)); @@ -308,8 +362,10 @@ namespace CalamityMod.World canGenerateInLocation = false; //The granite geode is supposed to fully float in free air. No tile replacements - if (tile.WallType == WallID.GraniteUnsafe && !tile.HasTile) - graniteWallsInArea++; + if (tile.WallType == WallID.GraniteUnsafe && !tile.HasTile && !Main.remixWorld) + graniteWallsInArea++; + else if ((tile.WallType == WallID.MarbleUnsafe || tile.TileType == TileID.Marble) && Main.remixWorld) //Get fixed boi makes it generate in marble biomes + graniteWallsInArea++; } } if (!canGenerateInLocation || graniteWallsInArea < totalTiles * 0.95f || !structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y))) @@ -324,7 +380,7 @@ namespace CalamityMod.World break; } - } while (tries <= 20000); + } while (tries <= 30000); } #endregion @@ -343,6 +399,21 @@ namespace CalamityMod.World new ChestItem(foodType, WorldGen.genRand.Next(10, 12 + 1)), }; + if (Main.zenithWorld) + { + contents = new List() + { + new ChestItem(ModContent.ItemType(), 1), + new ChestItem(ItemID.FlinxFur, WorldGen.genRand.Next(6, 8 + 1)), + new ChestItem(ItemID.FrozenKey, 1), + new ChestItem(ItemID.IceTorch, WorldGen.genRand.Next(100, 110 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemID.Eggnog, WorldGen.genRand.Next(10, 12 + 1)), + new ChestItem(ModContent.ItemType(), WorldGen.genRand.Next(200, 349 + 1)), + new ChestItem(Main.rand.NextBool(2) ? ItemID.GasTrap : ItemID.Marshmallow, 1) + }; + } + for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); @@ -400,6 +471,8 @@ namespace CalamityMod.World public static void FillMarbleShrineChest(Chest chest) { int potionType = Utils.SelectRandom(WorldGen.genRand, ItemID.EndurancePotion, ItemID.HeartreachPotion, ItemID.LifeforcePotion); + if (Main.zenithWorld) + potionType = ItemID.RedPotion; List contents = new List() { new ChestItem(ModContent.ItemType(), 1), @@ -407,7 +480,8 @@ namespace CalamityMod.World new ChestItem(ItemID.WhiteTorch, WorldGen.genRand.Next(100, 110 + 1)), new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), - new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), + new ChestItem(potionType, WorldGen.genRand.Next(Main.zenithWorld ? 1 : 10, (Main.zenithWorld ? 2 : 12) + 1)), + new ChestItem((Main.rand.NextBool(2) && Main.zenithWorld) ? ItemID.GasTrap : ItemID.Marble, Main.zenithWorld ? 1 : WorldGen.genRand.Next(7,15+1)), }; for (int i = 0; i < contents.Count; i++) @@ -424,7 +498,7 @@ namespace CalamityMod.World do { int placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.1f), (int)(Main.maxTilesX * 0.9f)); - int placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.3f), (int)(Main.maxTilesY * 0.85f)); + int placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.2f), (int)(Main.maxTilesY * 0.85f)); Point placementPoint = new Point(placementPositionX, placementPositionY); Vector2 schematicSize = new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)); @@ -443,7 +517,9 @@ namespace CalamityMod.World //Marble biomes either have blocks or walls, occasionally both //This should be near maximum to prevent the structure from overextending - if (tile.TileType == TileID.Marble || tile.WallType == WallID.MarbleUnsafe) + if ((tile.TileType == TileID.Marble || tile.WallType == WallID.MarbleUnsafe) && !Main.zenithWorld) + marbleStuffInArea++; + else if ((tile.WallType == WallID.GraniteUnsafe || tile.TileType == TileID.Granite) && Main.zenithWorld) //Generates in granite in gfb marbleStuffInArea++; //There should be some space between the pillars so it doesn't make pillars in the middle of nowhere zone @@ -466,7 +542,7 @@ namespace CalamityMod.World break; } - } while (tries <= 20000); + } while (tries <= 30000); } #endregion @@ -475,14 +551,31 @@ namespace CalamityMod.World { int potionType = Utils.SelectRandom(WorldGen.genRand, ItemID.ShinePotion, ItemID.MiningPotion, ItemID.BuilderPotion); List contents = new List() - { + { new ChestItem(ModContent.ItemType(), 1), new ChestItem(ItemID.TruffleWorm, 3), new ChestItem(ItemID.MushroomTorch, WorldGen.genRand.Next(100, 110 + 1)), new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), - }; + }; + + // Gfb loot change + if (Main.zenithWorld) + { + //"Cannot modify the return value of List.this[int] because its not a variable" so gotta do this instead, I could add a bunch of bools but I feel this is better for how much is changed + contents = new List() + { + new ChestItem(ModContent.ItemType(), 1), + new ChestItem(ItemID.TruffleWorm, 3), + new ChestItem(ItemID.MushroomTorch, WorldGen.genRand.Next(50, 60 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(4, 6 + 1)), + new ChestItem(ModContent.ItemType(), WorldGen.genRand.Next(2, 3 + 1)), + new ChestItem(ItemID.RedPotion, WorldGen.genRand.Next(1, 2 + 1)), + new ChestItem(ItemID.GasTrap, 1) + }; + } + for (int i = 0; i < contents.Count; i++) { @@ -500,7 +593,7 @@ namespace CalamityMod.World int placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.2f), (int)(Main.maxTilesX * 0.8f)); int placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.2f), (int)(Main.maxTilesY * 0.85f)); - // Gfb and Dont Dig up + // Gfb and remix if (Main.remixWorld) { // Ensure that the shrine doesn't generate too close to the center of the world @@ -509,7 +602,7 @@ namespace CalamityMod.World placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.2f), (int)(Main.maxTilesX * 0.8f)); } while (placementPositionX > (int)(Main.maxTilesX * 0.4f) && placementPositionX < (int)(Main.maxTilesX * 0.6f)); - placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.8f), (int)(Main.maxTilesY * 0.85f)); //Mushroom layer + placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.85f), (int)(Main.maxTilesY * 0.9f)); //Mushroom layer } Point placementPoint = new Point(placementPositionX, placementPositionY); @@ -543,7 +636,7 @@ namespace CalamityMod.World { tries++; } - else if (!canGenerateInLocation && Main.remixWorld) //GFB nor dont dig up will not give a shit about mushrooms or the rectangle + else if (!canGenerateInLocation && Main.remixWorld) //GFB and remix will not give a shit about mushrooms or the rectangle { tries++; } @@ -562,14 +655,17 @@ namespace CalamityMod.World public static void FillSurfaceShrineChest(Chest chest) { int potionType = Utils.SelectRandom(WorldGen.genRand, ItemID.RecallPotion, ItemID.CalmingPotion, ItemID.SwiftnessPotion); + if (Main.zenithWorld) + potionType = ItemID.Sake; List contents = new List() { new ChestItem(ModContent.ItemType(), 1), new ChestItem(ItemID.PinkGel, WorldGen.genRand.Next(12, 15 + 1)), new ChestItem(ItemID.Torch, WorldGen.genRand.Next(50, 60 + 1)), new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(4, 6 + 1)), - new ChestItem(ItemID.LesserHealingPotion, WorldGen.genRand.Next(10, 12 + 1)), + new ChestItem(Main.zenithWorld ? ItemID.RestorationPotion : ItemID.LesserHealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), + new ChestItem(Main.zenithWorld ? ItemID.GasTrap : ItemID.Mushroom, Main.zenithWorld ? 1 : WorldGen.genRand.Next(5,9+1)), }; for (int i = 0; i < contents.Count; i++) @@ -598,6 +694,9 @@ namespace CalamityMod.World //use Main.worldSurface and not WorldGen.WorldSurface, i believe that is why it was genning on the surface so much int placementPositionY = (int)Main.worldSurface + numTilesBelowSurface; + + if (Main.remixWorld) + placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.65f), (int)(Main.maxTilesY * 0.7f)); //above mushroom layer Point placementPoint = new Point(placementPositionX, placementPositionY); Vector2 schematicSize = new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)); @@ -632,49 +731,59 @@ namespace CalamityMod.World } else { - Point result; - Point shrineTunnelPlacementPoint = new Point(placementPoint.X + (int)(schematicSize.X * 0.5f), placementPoint.Y); - bool flag = WorldUtils.Find(shrineTunnelPlacementPoint, Searches.Chain(new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result); - if (WorldUtils.Find(shrineTunnelPlacementPoint, Searches.Chain(new Searches.Up(shrineTunnelPlacementPoint.Y - result.Y), new Conditions.IsTile(TileID.Sand)), out Point _)) + if (!Main.remixWorld) // Make tunnel if its not remix or Gfb { - tries++; - } - else if (!flag) - { - tries++; - } - else - { - result.Y += numTilesBelowSurface; - - bool[] array = new bool[TileID.Sets.GeneralPlacementTiles.Length]; - for (int i = 0; i < array.Length; i++) - array[i] = TileID.Sets.GeneralPlacementTiles[i]; - - array[TileID.Containers] = false; - array[TileID.Containers2] = false; - - if (!structures.CanPlace(new Rectangle(shrineTunnelPlacementPoint.X, result.Y + 10, 1, shrineTunnelPlacementPoint.Y - result.Y - 9), array, 2)) + Point result; + Point shrineTunnelPlacementPoint = new Point(placementPoint.X + (int)(schematicSize.X * 0.5f), placementPoint.Y); + bool flag = WorldUtils.Find(shrineTunnelPlacementPoint, Searches.Chain(new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result); + if (WorldUtils.Find(shrineTunnelPlacementPoint, Searches.Chain(new Searches.Up(shrineTunnelPlacementPoint.Y - result.Y), new Conditions.IsTile(TileID.Sand)), out Point _)) + { + tries++; + } + else if (!flag) { tries++; } else { - bool _ = true; - PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref _, new Action(FillSurfaceShrineChest)); - structures.AddProtectedStructure(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y), 4); + result.Y += numTilesBelowSurface; - // Generate entrance tunnel - ShapeData data = new ShapeData(); - WorldUtils.Gen(new Point(shrineTunnelPlacementPoint.X, result.Y + 10), new Shapes.Rectangle(1, shrineTunnelPlacementPoint.Y - result.Y - 9), Actions.Chain(new Modifiers.Blotches(2, 0.2), new Modifiers.SkipTiles(TileID.LivingWood, TileID.LeafBlock), new Actions.ClearTile().Output(data), new Modifiers.Expand(1), new Modifiers.OnlyTiles(TileID.Sand), new Actions.SetTile(TileID.HardenedSand).Output(data))); - WorldUtils.Gen(new Point(shrineTunnelPlacementPoint.X, result.Y + 10), new ModShapes.All(data), new Actions.SetFrames(frameNeighbors: true)); + bool[] array = new bool[TileID.Sets.GeneralPlacementTiles.Length]; + for (int i = 0; i < array.Length; i++) + array[i] = TileID.Sets.GeneralPlacementTiles[i]; - break; + array[TileID.Containers] = false; + array[TileID.Containers2] = false; + + if (!structures.CanPlace(new Rectangle(shrineTunnelPlacementPoint.X, result.Y + 10, 1, shrineTunnelPlacementPoint.Y - result.Y - 9), array, 2)) + { + tries++; + } + else + { + bool _ = true; + PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref _, new Action(FillSurfaceShrineChest)); + structures.AddProtectedStructure(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y), 4); + + // Generate entrance tunnel + ShapeData data = new ShapeData(); + WorldUtils.Gen(new Point(shrineTunnelPlacementPoint.X, result.Y + 10), new Shapes.Rectangle(1, shrineTunnelPlacementPoint.Y - result.Y - 9), Actions.Chain(new Modifiers.Blotches(2, 0.2), new Modifiers.SkipTiles(TileID.LivingWood, TileID.LeafBlock), new Actions.ClearTile().Output(data), new Modifiers.Expand(1), new Modifiers.OnlyTiles(TileID.Sand), new Actions.SetTile(TileID.HardenedSand).Output(data))); + WorldUtils.Gen(new Point(shrineTunnelPlacementPoint.X, result.Y + 10), new ModShapes.All(data), new Actions.SetFrames(frameNeighbors: true)); + + break; + } } + } else + { + bool _ = true; + PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref _, new Action(FillSurfaceShrineChest)); + structures.AddProtectedStructure(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y), 4); + break; } + } - } while (tries <= 20000); + } while (tries <= 30000); } #endregion