From 1979f9b97cdee35a570f2594b60fa345aaac69bd Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 23 Jul 2021 13:31:08 -0500 Subject: [PATCH] Property conversion --- Skies/SCalSky.cs | 78 +++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/Skies/SCalSky.cs b/Skies/SCalSky.cs index b5c718a04f..f397695e3a 100644 --- a/Skies/SCalSky.cs +++ b/Skies/SCalSky.cs @@ -37,21 +37,10 @@ namespace CalamityMod.Skies private bool isActive = false; private float intensity = 0f; private int SCalIndex = -1; - private List Cinders = new List(); - public static float OverridingIntensity = 0f; - - public override void Update(GameTime gameTime) + public List Cinders = new List(); + public static int CinderReleaseChance { - if (isActive && intensity < 1f) - { - intensity += 0.01f; - } - else if (!isActive && intensity > 0f) - { - intensity -= 0.01f; - } - - int getCinderReleaseChance() + get { if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) return int.MaxValue; @@ -77,28 +66,13 @@ namespace CalamityMod.Skies if (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())) return 10; - // Release a moderate amount of cinders idly. + // Release a moderate amount of cinders normally. return 18; } - - Color selectCinderColor() - { - if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) - return Color.Transparent; - - NPC scal = Main.npc[CalamityGlobalNPC.SCal]; - float lifeRatio = scal.life / (float)scal.lifeMax; - if (lifeRatio > 0.5f) - return Color.Lerp(Color.Red, Color.Orange, Main.rand.NextFloat(0.8f)); - else if (lifeRatio > 0.3f) - return Color.Lerp(Color.Blue, Color.DarkBlue, Main.rand.NextFloat() * 0.65f); - else if (lifeRatio > 0.01f) - return Color.Lerp(Color.Red, Color.Yellow, Main.rand.NextFloat(0.2f, 0.9f)); - else - return Color.Gray; - } - - float selectCinderSpeed() + } + public static float CinderSpeed + { + get { if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) return 0f; @@ -122,9 +96,39 @@ namespace CalamityMod.Skies // Move moderately quickly usually. return 5.6f; } + } + public static float OverridingIntensity = 0f; + + public override void Update(GameTime gameTime) + { + if (isActive && intensity < 1f) + { + intensity += 0.01f; + } + else if (!isActive && intensity > 0f) + { + intensity -= 0.01f; + } + + Color selectCinderColor() + { + if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) + return Color.Transparent; + + NPC scal = Main.npc[CalamityGlobalNPC.SCal]; + float lifeRatio = scal.life / (float)scal.lifeMax; + if (lifeRatio > 0.5f) + return Color.Lerp(Color.Red, Color.Orange, Main.rand.NextFloat(0.8f)); + else if (lifeRatio > 0.3f) + return Color.Lerp(Color.Blue, Color.DarkBlue, Main.rand.NextFloat() * 0.65f); + else if (lifeRatio > 0.01f) + return Color.Lerp(Color.Red, Color.Yellow, Main.rand.NextFloat(0.2f, 0.9f)); + else + return Color.Gray; + } // Randomly add cinders. - if (intensity >= 1f && Main.rand.NextBool(getCinderReleaseChance())) + if (intensity >= 1f && Main.rand.NextBool(CinderReleaseChance)) { int lifetime = Main.rand.Next(285, 445); float depth = Main.rand.NextFloat(1.8f, 5f); @@ -139,10 +143,10 @@ namespace CalamityMod.Skies Cinders[i].Scale = Utils.InverseLerp(Cinders[i].Lifetime, Cinders[i].Lifetime - 50, Cinders[i].Time, true) * Utils.InverseLerp(0f, 50f, Cinders[i].Time, true); Cinders[i].Scale *= MathHelper.Lerp(0.55f, 0.8f, Cinders[i].IdentityIndex % 6f / 6f); - Vector2 idealVelocity = -Vector2.UnitY.RotatedBy(MathHelper.Lerp(-0.94f, 0.94f, (float)Math.Sin(Cinders[i].Time / 36f + Cinders[i].IdentityIndex) * 0.5f + 0.5f)) * selectCinderSpeed(); + Vector2 idealVelocity = -Vector2.UnitY.RotatedBy(MathHelper.Lerp(-0.94f, 0.94f, (float)Math.Sin(Cinders[i].Time / 36f + Cinders[i].IdentityIndex) * 0.5f + 0.5f)) * CinderSpeed; float movementInterpolant = MathHelper.Lerp(0.01f, 0.08f, Utils.InverseLerp(45f, 145f, Cinders[i].Time, true)); Cinders[i].Velocity = Vector2.Lerp(Cinders[i].Velocity, idealVelocity, movementInterpolant); - Cinders[i].Velocity = Cinders[i].Velocity.SafeNormalize(-Vector2.UnitY) * selectCinderSpeed(); + Cinders[i].Velocity = Cinders[i].Velocity.SafeNormalize(-Vector2.UnitY) * CinderSpeed; Cinders[i].Time++; Cinders[i].Center += Cinders[i].Velocity;