From 03263273a684952abad5e4a5eb8b3c549d53682f Mon Sep 17 00:00:00 2001 From: cheeeeeeeeeen Date: Sun, 10 Nov 2019 23:10:14 +0800 Subject: [PATCH] Fix #147: Change all readonly non-dynamic variables to const --- .../Options/Miscellaneous/OptionSeed.cs | 6 ++-- NPCs/BigCoreCustom.cs | 32 +++++++++--------- NPCs/Ducker.cs | 29 ++++++++-------- NPCs/Garun.cs | 25 +++++++------- NPCs/Grazia.cs | 12 +++---- NPCs/Moai.cs | 13 ++++---- NPCs/Sagna.cs | 32 +++++++++--------- NPCs/Zalk.cs | 33 ++++++++++--------- Projectiles/Enemies/MoaiBubble.cs | 11 ++++--- Projectiles/Forces/NeedleForce.cs | 6 ++-- .../Charge/ChargeMultipleBaseObject.cs | 27 +++++++-------- .../Options/Charge/ChargeMultipleMissile.cs | 23 +++++++------ .../Options/Charge/ChargeMultipleTrail.cs | 9 ++--- .../Options/Miscellaneous/OptionSeedObject.cs | 12 +++---- build.txt | 2 +- description.txt | 2 ++ forum.txt | 11 ++++++- 17 files changed, 152 insertions(+), 133 deletions(-) diff --git a/Items/Accessories/Options/Miscellaneous/OptionSeed.cs b/Items/Accessories/Options/Miscellaneous/OptionSeed.cs index 2c38e46..d26f458 100644 --- a/Items/Accessories/Options/Miscellaneous/OptionSeed.cs +++ b/Items/Accessories/Options/Miscellaneous/OptionSeed.cs @@ -8,7 +8,7 @@ namespace ChensGradiusMod.Items.Accessories.Options.Miscellaneous { public class OptionSeed : ParentGradiusAccessory { - private readonly string projectileName = "OptionSeedObject"; + private const string ProjectileName = "OptionSeedObject"; public override void SetStaticDefaults() { @@ -35,10 +35,10 @@ public override void UpdateAccessory(Player player, bool hideVisual) if (GradiusHelper.IsSameClientOwner(player)) { - if (player.ownedProjectileCounts[mod.ProjectileType(projectileName)] <= 0) + if (player.ownedProjectileCounts[mod.ProjectileType(ProjectileName)] <= 0) { int pInd = Projectile.NewProjectile(player.Center.X + OptionSeedObject.SeedDistance * player.direction, - player.Center.Y, 0f, 0f, mod.ProjectileType(projectileName), 0, 0f, + player.Center.Y, 0f, 0f, mod.ProjectileType(ProjectileName), 0, 0f, player.whoAmI, 0f, 0f); ModOwner(player).seedProjectile = Main.projectile[pInd]; } diff --git a/NPCs/BigCoreCustom.cs b/NPCs/BigCoreCustom.cs index 0b8a9ae..8b17025 100644 --- a/NPCs/BigCoreCustom.cs +++ b/NPCs/BigCoreCustom.cs @@ -14,19 +14,19 @@ public class BigCoreCustom : GradiusEnemy { private const int FrameWidth = 192; private const int FrameHeight = 130; + private const float RegularAssaultMaxSpeed = 30f; + private const float RegularAssaultAcceleration = 1f; + private const float RegularAssaultHorizontalGap = 600f; + private const int OpenCoreTime = 1200; + private const int MaxFrameIndex = 4; + private const int FireRate = 25; - private readonly int openCoreTime = 1200; - private readonly int maxFrameIndex = 4; - private readonly int fireRate = 25; private bool openCore = false; private States mode = States.RegularAssault; private int fireTick = 0; private int existenceTick = 0; private int frameCounterX = 7; - private readonly float regularAssaultMaxSpeed = 30f; - private readonly float regularAssaultAcceleration = 1f; - private readonly float regularAssaultHorizontalGap = 600f; private float regularAssaultXCurrentSpeed = 0f; private float regularAssaultYCurrentSpeed = 0f; private int regularAssaultDirection = 0; @@ -202,13 +202,13 @@ private void RegularAssaultBehavior() if (target.Center.Y > npc.Center.Y) { - regularAssaultYCurrentSpeed += regularAssaultAcceleration; - regularAssaultYCurrentSpeed = Math.Min(regularAssaultYCurrentSpeed, regularAssaultMaxSpeed); + regularAssaultYCurrentSpeed += RegularAssaultAcceleration; + regularAssaultYCurrentSpeed = Math.Min(regularAssaultYCurrentSpeed, RegularAssaultMaxSpeed); } else if (target.Center.Y < npc.Center.Y) { - regularAssaultYCurrentSpeed -= regularAssaultAcceleration; - regularAssaultYCurrentSpeed = Math.Max(regularAssaultYCurrentSpeed, -regularAssaultMaxSpeed); + regularAssaultYCurrentSpeed -= RegularAssaultAcceleration; + regularAssaultYCurrentSpeed = Math.Max(regularAssaultYCurrentSpeed, -RegularAssaultMaxSpeed); } npc.position.Y += regularAssaultYCurrentSpeed; if (GradiusHelper.IsNotMultiplayerClient() && @@ -217,9 +217,9 @@ private void RegularAssaultBehavior() npc.netUpdate = true; } - float destinationX = target.Center.X + regularAssaultHorizontalGap * -regularAssaultDirection; - regularAssaultXCurrentSpeed += regularAssaultAcceleration; - regularAssaultXCurrentSpeed = Math.Min(regularAssaultXCurrentSpeed, regularAssaultMaxSpeed); + float destinationX = target.Center.X + RegularAssaultHorizontalGap * -regularAssaultDirection; + regularAssaultXCurrentSpeed += RegularAssaultAcceleration; + regularAssaultXCurrentSpeed = Math.Min(regularAssaultXCurrentSpeed, RegularAssaultMaxSpeed); float newX = GradiusHelper.ApproachValue(npc.Center.X, destinationX, regularAssaultXCurrentSpeed); if (newX == destinationX) regularAssaultXCurrentSpeed = 0f; npc.Center = new Vector2(newX, npc.Center.Y); @@ -229,7 +229,7 @@ private void PerformAttack() { if (GradiusHelper.IsNotMultiplayerClient() && mode != States.Exit) { - if (++fireTick >= fireRate) + if (++fireTick >= FireRate) { fireTick = 0; @@ -289,12 +289,12 @@ private void CoreManagement() FrameCounter--; } } - else if (mode != States.Exit && !openCore && existenceTick >= openCoreTime) + else if (mode != States.Exit && !openCore && existenceTick >= OpenCoreTime) { if (++FrameTick >= FrameSpeed) { FrameTick = 0; - if (++FrameCounter >= maxFrameIndex) openCore = true; + if (++FrameCounter >= MaxFrameIndex) openCore = true; } } } diff --git a/NPCs/Ducker.cs b/NPCs/Ducker.cs index 06922c7..b7f1359 100644 --- a/NPCs/Ducker.cs +++ b/NPCs/Ducker.cs @@ -13,12 +13,11 @@ public class Ducker : GradiusEnemy private const float CustomGravity = 8f; private const int CancelThreshold = 500; private const float AttackAngleDifference = 13f; - - private readonly float runSpeed = 4f; - private readonly float fallSpeedYAccel = .5f; - private readonly float fallSpeedXAccel = .1f; - private readonly float targetDistance = 500f; - private readonly int syncRate = 30; + private const float RunSpeed = 4f; + private const float FallSpeedYAccel = .5f; + private const float FallSpeedXAccel = .1f; + private const float TargetDistance = 500f; + private const int SyncRate = 30; private States mode = States.Run; private States oldMode = States.Run; @@ -199,11 +198,11 @@ public override void AI() case States.Fall: npc.velocity += new Vector2 { - X = fallSpeedXAccel * persistDirection, - Y = fallSpeedYAccel * yDirection + X = FallSpeedXAccel * persistDirection, + Y = FallSpeedYAccel * yDirection }; - if (persistDirection > 0) npc.velocity.X = Math.Min(npc.velocity.X, runSpeed); - else npc.velocity.X = Math.Max(npc.velocity.X, -runSpeed); + if (persistDirection > 0) npc.velocity.X = Math.Min(npc.velocity.X, RunSpeed); + else npc.velocity.X = Math.Max(npc.velocity.X, -RunSpeed); if (yDirection > 0) npc.velocity.Y = Math.Min(npc.velocity.Y, CustomGravity); else npc.velocity.Y = Math.Max(npc.velocity.Y, -CustomGravity); @@ -229,7 +228,7 @@ public override void AI() npc.velocity = new Vector2(0, 20f * -yDirection); hasJumped = true; } - else npc.velocity += new Vector2(fallSpeedXAccel * persistDirection, fallSpeedYAccel * yDirection); + else npc.velocity += new Vector2(FallSpeedXAccel * persistDirection, FallSpeedYAccel * yDirection); if (hasJumped && ((yDirection > 0 && npc.velocity.Y >= 0) || (yDirection < 0 && npc.velocity.Y <= 0))) @@ -254,7 +253,7 @@ public override void AI() public override void PostAI() { base.PostAI(); - if (!ConstantSync(ref syncTick, syncRate) && GradiusHelper.IsNotMultiplayerClient() + if (!ConstantSync(ref syncTick, SyncRate) && GradiusHelper.IsNotMultiplayerClient() && oldMode != mode) { npc.netUpdate = true; @@ -287,7 +286,7 @@ public override void ReceiveExtraAI(BinaryReader reader) yDirection = reader.ReadInt32(); hasJumped = reader.ReadBoolean(); targetLastSeen = reader.ReadVector2(); - } + } protected override int FrameSpeed { get; set; } = 5; @@ -323,7 +322,7 @@ private void UsualMovement() { npc.velocity = new Vector2 { - X = runSpeed * persistDirection, + X = RunSpeed * persistDirection, Y = CustomGravity * yDirection }; } @@ -332,7 +331,7 @@ private bool ConfirmTarget() { npc.TargetClosest(false); targetLastSeen = Target.Center; - return Vector2.Distance(Target.Center, npc.Center) <= targetDistance + return Vector2.Distance(Target.Center, npc.Center) <= TargetDistance && ((yDirection > 0 && npc.Center.Y >= Target.Center.Y) || (yDirection < 0 && npc.Center.Y <= Target.Center.Y)); } diff --git a/NPCs/Garun.cs b/NPCs/Garun.cs index 1b0ba88..e740884 100644 --- a/NPCs/Garun.cs +++ b/NPCs/Garun.cs @@ -9,12 +9,13 @@ namespace ChensGradiusMod.NPCs { public class Garun : GradiusEnemy { - private readonly float waveFrequency = .05f; - private readonly float waveAmplitude = 150f; - private readonly float travelSpeed = 5f; - private readonly float attackDistance = 1200; - private readonly int fireRate = 20; - private readonly int syncRate = 120; + private const float WaveFrequency = .05f; + private const float WaveAmplitude = 150f; + private const float TravelSpeed = 5f; + private const float AttackDistance = 1200; + private const int FireRate = 20; + private const int SyncRate = 120; + private int timerTick = 0; private bool targetDetermined = false; private int persistDirection = 0; @@ -66,13 +67,13 @@ public override void AI() float xTo = (float)Math.Cos(GetDirection()); float yTo = (float)Math.Sin(GetDirection()); - float wobble = waveAmplitude * (float)Math.Cos(waveFrequency * timerTick++) * waveFrequency; - npc.velocity.X += xTo * travelSpeed - yTo * wobble; - npc.velocity.Y += -yTo * travelSpeed + xTo * wobble; + float wobble = WaveAmplitude * (float)Math.Cos(WaveFrequency * timerTick++) * WaveFrequency; + npc.velocity.X += xTo * TravelSpeed - yTo * wobble; + npc.velocity.Y += -yTo * TravelSpeed + xTo * wobble; PerformAttack(); - ConstantSync(ref syncTick, syncRate); + ConstantSync(ref syncTick, SyncRate); } public override float SpawnChance(NPCSpawnInfo spawnInfo) @@ -115,12 +116,12 @@ private double GetDirection() private void PerformAttack() { if (GradiusHelper.IsNotMultiplayerClient() && - Vector2.Distance(npc.Center, Main.player[npc.target].Center) <= attackDistance) + Vector2.Distance(npc.Center, Main.player[npc.target].Center) <= AttackDistance) { if ((npc.direction >= 0 && npc.Center.X <= Main.player[npc.target].Center.X) || (npc.direction <= 0 && npc.Center.X >= Main.player[npc.target].Center.X)) { - if (++fireTick >= fireRate) + if (++fireTick >= FireRate) { fireTick = 0; Vector2 vel = GradiusHelper.MoveToward(npc.Center, Main.player[npc.target].Center, GradiusEnemyBullet.Spd); diff --git a/NPCs/Grazia.cs b/NPCs/Grazia.cs index 6218a5d..b749fab 100644 --- a/NPCs/Grazia.cs +++ b/NPCs/Grazia.cs @@ -11,6 +11,9 @@ public class Grazia : GradiusEnemy private const float DetectionRange = 800f; private const int PersistDirection = -1; private const float CustomGravity = 5f; + private const int FireRate = 50; + private const int CancelDeployThreshold = 500; + private const int SyncRate = 300; private readonly int[] directLowerAngleAim = { 0, 21, 41, 61, 81, 100, 120, 140, 160 }; private readonly int[] directHigherAngleAim = { 20, 40, 60, 80, 99, 119, 139, 159, 180 }; @@ -18,9 +21,6 @@ public class Grazia : GradiusEnemy private readonly int[] inverseLowerAngleAim = { 180, 201, 221, 241, 261, 280, 300, 320, 340 }; private readonly int[] inverseHigherAngleAim = { 200, 220, 240, 260, 279, 299, 319, 339, 360 }; private readonly int[] inverseFrameAngleAim = { 17, 16, 15, 14, 13, 12, 11, 10, 9 }; - private readonly int fireRate = 50; - private readonly int cancelDeployThreshold = 500; - private readonly int syncRate = 600; private int yDirection = 0; private int fireTick = 0; @@ -66,7 +66,7 @@ public override void AI() if (yDirection == 0) { - yDirection = DecideYDeploy(npc.height * .5f, cancelDeployThreshold); + yDirection = DecideYDeploy(npc.height * .5f, CancelDeployThreshold); if (yDirection == 0) return; if (yDirection < 0) npc.frame.Y = 416; } @@ -82,7 +82,7 @@ public override void AI() else fireTick = 0; } - ConstantSync(ref syncTick, syncRate); + ConstantSync(ref syncTick, SyncRate); } public override void FindFrame(int frameHeight) @@ -167,7 +167,7 @@ private int DetectTarget() private void PerformAttack() { - if (++fireTick >= fireRate) + if (++fireTick >= FireRate) { fireTick = 0; Vector2 vel = GradiusHelper.MoveToward(npc.Center, Main.player[npc.target].Center, GradiusEnemyBullet.Spd); diff --git a/NPCs/Moai.cs b/NPCs/Moai.cs index 1bbf887..e9925c1 100644 --- a/NPCs/Moai.cs +++ b/NPCs/Moai.cs @@ -11,10 +11,9 @@ namespace ChensGradiusMod.NPCs public class Moai : GradiusEnemy { private const float DetectionRange = 1400f; - - private readonly int attackTickDelay = 5; - private readonly int restingTime = 40; - private readonly int vulnerableTime = 10; + private const int AttackTickDelay = 5; + private const int RestingTime = 40; + private const int VulnerableTime = 20; private int persistDirection = 0; private int mode = (int)States.Dormant; @@ -81,7 +80,7 @@ public override void AI() } break; case (int)States.Aggressive: - if (++attackTick >= attackTickDelay) + if (++attackTick >= AttackTickDelay) { attackTick = 0; PerformAttack(); @@ -93,14 +92,14 @@ public override void AI() } break; case (int)States.Vulnerable: - if (++vulnerableTick >= vulnerableTime) + if (++vulnerableTick >= VulnerableTime) { vulnerableTick = 0; mode = (int)States.Resting; } break; case (int)States.Resting: - if (++restTick >= restingTime) + if (++restTick >= RestingTime) { restTick = 0; mode = (int)States.Dormant; diff --git a/NPCs/Sagna.cs b/NPCs/Sagna.cs index 7032c55..61c29d3 100644 --- a/NPCs/Sagna.cs +++ b/NPCs/Sagna.cs @@ -9,12 +9,12 @@ namespace ChensGradiusMod.NPCs { public class Sagna : GradiusEnemy { - private readonly int cancelDeployThreshold = 500; - private readonly float xSpeed = 3f; - private readonly float yGravity = .1f; - private readonly float maxYSpeed = 5f; - private readonly int jumpCountForSpray = 1; - private readonly int syncRate = 60; + private const int CancelDeployThreshold = 500; + private const float XSpeed = 3f; + private const float YGravity = .1f; + private const float MaxYSpeed = 5f; + private const int JumpCountForSpray = 1; + private const int SyncRate = 60; private bool initialized = false; private int persistDirection = 0; @@ -67,7 +67,7 @@ public override bool PreAI() if (npc.Center.X > Main.player[npc.target].Center.X) persistDirection = -1; else persistDirection = 1; xDirection = persistDirection; - yDirection = DecideYDeploy(npc.height, cancelDeployThreshold, false, true, 1); + yDirection = DecideYDeploy(npc.height, CancelDeployThreshold, false, true, 1); if (yDirection < 0) { startFrame = 8; @@ -88,13 +88,13 @@ public override void AI() MoveVertically(); if (mode != States.Spray) AdjustMovementBehavior(); - + } public override void PostAI() { base.PostAI(); - if (!ConstantSync(ref syncTick, syncRate) && GradiusHelper.IsNotMultiplayerClient() + if (!ConstantSync(ref syncTick, SyncRate) && GradiusHelper.IsNotMultiplayerClient() && oldMode != mode) { npc.netUpdate = true; @@ -172,7 +172,7 @@ private void MoveHorizontally() { case States.Hop: case States.Fall: - npc.velocity.X = xSpeed * xDirection; + npc.velocity.X = XSpeed * xDirection; break; case States.Spray: npc.velocity.X = 0f; @@ -185,14 +185,14 @@ private void MoveVertically() switch (mode) { case States.Hop: - npc.velocity.Y += yGravity * yDirection; + npc.velocity.Y += YGravity * yDirection; if (yDirection > 0) npc.velocity.Y = Math.Min(npc.velocity.Y, 0f); else npc.velocity.Y = Math.Max(npc.velocity.Y, 0f); break; case States.Fall: - npc.velocity.Y += yGravity * yDirection; - if (yDirection > 0) npc.velocity.Y = Math.Min(npc.velocity.Y, maxYSpeed); - else npc.velocity.Y = Math.Max(npc.velocity.Y, -maxYSpeed); + npc.velocity.Y += YGravity * yDirection; + if (yDirection > 0) npc.velocity.Y = Math.Min(npc.velocity.Y, MaxYSpeed); + else npc.velocity.Y = Math.Max(npc.velocity.Y, -MaxYSpeed); break; case States.Spray: npc.velocity.Y = 0f; @@ -214,7 +214,7 @@ private void AdjustMovementBehavior() yDirection < 0 && npc.velocity.Y <= 0f) { npc.velocity.Y = 0f; - if (++jumpCount >= jumpCountForSpray) + if (++jumpCount >= JumpCountForSpray) { jumpCount = 0; mode = States.Spray; @@ -226,7 +226,7 @@ private void AdjustMovementBehavior() if (beforeVelocity.Y != npc.velocity.Y) { mode = States.Hop; - npc.velocity.Y = maxYSpeed * -yDirection; + npc.velocity.Y = MaxYSpeed * -yDirection; } break; } diff --git a/NPCs/Zalk.cs b/NPCs/Zalk.cs index 74ddd7d..8bf0814 100644 --- a/NPCs/Zalk.cs +++ b/NPCs/Zalk.cs @@ -8,13 +8,14 @@ namespace ChensGradiusMod.NPCs { public class Zalk : GradiusEnemy { - private readonly float travelSpeed = 5f; - private readonly float xDistanceToIntercept = 120f; - private readonly float yThresholdToRetreat = .01f; - private readonly float xDistanceSeries = 60f; - private readonly int fireRate = 57; - private readonly float attackDistance = 1200; - private readonly int randomFireInterval = 30; + private const float TravelSpeed = 5f; + private const float XDistanceToIntercept = 120f; + private const float YThresholdToRetreat = .01f; + private const float XDistanceSeries = 60f; + private const int FireRate = 57; + private const float AttackDistance = 1200; + private const int RandomFireInterval = 30; + private bool targetDetermined = false; private int persistDirection = 0; private States mode = States.Attack; @@ -90,10 +91,10 @@ public override void AI() case States.Fire: if (GradiusHelper.IsNotMultiplayerClient()) { - if (Vector2.Distance(npc.Center, Main.player[npc.target].Center) <= attackDistance) + if (Vector2.Distance(npc.Center, Main.player[npc.target].Center) <= AttackDistance) { - int adjustRate = fireRate; - if (fireTick <= 0) setFireInterval = Main.rand.Next(0, randomFireInterval + 1); + int adjustRate = FireRate; + if (fireTick <= 0) setFireInterval = Main.rand.Next(0, RandomFireInterval + 1); adjustRate += setFireInterval; if (mode == States.Retreat) adjustRate = GradiusHelper.RoundOffToWhole(adjustRate * .5f); PerformAttack(adjustRate); @@ -127,14 +128,14 @@ public override float SpawnChance(NPCSpawnInfo spawnInfo) private bool AttackBehavior() { - npc.velocity = new Vector2(persistDirection, 0f) * travelSpeed; + npc.velocity = new Vector2(persistDirection, 0f) * TravelSpeed; return true; } private bool AttackToIntercept() { float xCurrentDistance = Math.Abs(npc.Center.X - TargetPlayer.Center.X); - return xCurrentDistance <= xDistanceToIntercept; + return xCurrentDistance <= XDistanceToIntercept; } private bool InterceptBehavior() @@ -158,7 +159,7 @@ private bool InterceptBehavior() { X = (float)Math.Cos(MathHelper.ToRadians(angleDirection)), Y = (float)-Math.Sin(MathHelper.ToRadians(angleDirection)) - } * travelSpeed; + } * TravelSpeed; return true; } @@ -167,12 +168,12 @@ private bool InterceptToRetreat() { return GradiusHelper.IsEqualWithThreshold(npc.Center.Y, TargetPlayer.Center.Y, - travelSpeed + yThresholdToRetreat); + TravelSpeed + YThresholdToRetreat); } private bool RetreatBehavior() { - npc.velocity = new Vector2(-persistDirection, 0f) * travelSpeed * 2; + npc.velocity = new Vector2(-persistDirection, 0f) * TravelSpeed * 2; return true; } @@ -182,7 +183,7 @@ private void CreateSeries() { for (int i = 1; i <= SeriesCount; i++) { - GradiusHelper.NewNPC(npc.Bottom.X + (xDistanceSeries * i * -persistDirection), + GradiusHelper.NewNPC(npc.Bottom.X + (XDistanceSeries * i * -persistDirection), npc.Bottom.Y, ModContent.NPCType(), 0, 1); } } diff --git a/Projectiles/Enemies/MoaiBubble.cs b/Projectiles/Enemies/MoaiBubble.cs index 8254f30..dfc3ecb 100644 --- a/Projectiles/Enemies/MoaiBubble.cs +++ b/Projectiles/Enemies/MoaiBubble.cs @@ -11,8 +11,9 @@ public class MoaiBubble : ModProjectile public const int Dmg = 100; public const float Kb = 20f; - private readonly int expertMaxLife = 2; - private readonly int normalMaxLife = 1; + private const int ExpertMaxLife = 2; + private const int NormalMaxLife = 1; + private int life = 3; public override void SetStaticDefaults() @@ -34,10 +35,10 @@ public override void SetDefaults() public override bool PreAI() { - if (life > expertMaxLife) + if (life > ExpertMaxLife) { - if (Main.expertMode) life = expertMaxLife; - else life = normalMaxLife; + if (Main.expertMode) life = ExpertMaxLife; + else life = NormalMaxLife; } return true; diff --git a/Projectiles/Forces/NeedleForce.cs b/Projectiles/Forces/NeedleForce.cs index d4f9485..ac66afa 100644 --- a/Projectiles/Forces/NeedleForce.cs +++ b/Projectiles/Forces/NeedleForce.cs @@ -8,8 +8,10 @@ namespace ChensGradiusMod.Projectiles.Forces public class NeedleForce : ForceBase { private const float StatReduction = 1f; - private readonly float angleIncrease = 6f; + private const float AngleIncrease = 6f; + private readonly int[] detachedCooldown = { 2, 2, 2 }; + private float shootAngle = 0f; private int angleDirection = 1; @@ -23,7 +25,7 @@ public override void PerformAttack() { vX = (float)Math.Cos(MathHelper.ToRadians(shootAngle)); vY = (float)-Math.Sin(MathHelper.ToRadians(shootAngle)); - shootAngle += angleIncrease * angleDirection; + shootAngle += AngleIncrease * angleDirection; } else { diff --git a/Projectiles/Options/Charge/ChargeMultipleBaseObject.cs b/Projectiles/Options/Charge/ChargeMultipleBaseObject.cs index e95e488..60d3f99 100644 --- a/Projectiles/Options/Charge/ChargeMultipleBaseObject.cs +++ b/Projectiles/Options/Charge/ChargeMultipleBaseObject.cs @@ -8,12 +8,13 @@ namespace ChensGradiusMod.Projectiles.Options.Charge { public abstract class ChargeMultipleBaseObject : OptionBaseObject { - private readonly int maxCharge = 180; - private readonly int minCharge = 30; - private readonly int chargeDustId = 71; - private readonly int maxChargeDustId = 124; - private readonly int chargeSoundRate = 60; - private readonly int dustRate = 3; + private const int MaxCharge = 180; + private const int MinCharge = 30; + private const int ChargeDustId = 71; + private const int MaxChargeDustId = 124; + private const int ChargeSoundRate = 60; + private const int DustRate = 3; + private int chargeTime = 0; private int chargeSoundTick = 0; private int dustTick = 0; @@ -26,7 +27,7 @@ public override bool PreAI() if (baseResult && ModOwner.chargeMode == (int)ChargeMultipleBase.States.Dying) { - if (chargeTime > minCharge) + if (chargeTime > MinCharge) { if (GradiusHelper.IsSameClientOwner(projectile)) { @@ -77,23 +78,23 @@ public override void AI() if (ModOwner.chargeMode == (int)ChargeMultipleBase.States.Charging) { - chargeTime = Math.Min(maxCharge, ++chargeTime); + chargeTime = Math.Min(MaxCharge, ++chargeTime); - if (++dustTick >= dustRate && chargeTime <= maxCharge) + if (++dustTick >= DustRate && chargeTime <= MaxCharge) { dustTick = 0; - Dust.NewDust(projectile.position, projectile.width, projectile.height, chargeDustId); + Dust.NewDust(projectile.position, projectile.width, projectile.height, ChargeDustId); - if (chargeTime == maxCharge) + if (chargeTime == MaxCharge) { - Dust.NewDust(projectile.position, projectile.width, projectile.height, maxChargeDustId); + Dust.NewDust(projectile.position, projectile.width, projectile.height, MaxChargeDustId); } } if (Position <= 1) { - if (++chargeSoundTick >= chargeSoundRate) chargeSoundTick = 0; + if (++chargeSoundTick >= ChargeSoundRate) chargeSoundTick = 0; else if (chargeSoundTick <= 1) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Options/OptionCharging"), diff --git a/Projectiles/Options/Charge/ChargeMultipleMissile.cs b/Projectiles/Options/Charge/ChargeMultipleMissile.cs index c7d2056..78c6195 100644 --- a/Projectiles/Options/Charge/ChargeMultipleMissile.cs +++ b/Projectiles/Options/Charge/ChargeMultipleMissile.cs @@ -9,14 +9,17 @@ namespace ChensGradiusMod.Projectiles.Options.Charge public class ChargeMultipleMissile : ModProjectile { public const float Spd = 18f; + public Item clonedAccessory = null; + private const float DetectionRange = 600f; + private const float AngleSpeed = 20f; + private const float AngleVariation = 5f; + private const int DelayToRotate = 10; + private readonly int[] dustIds = new int[2] { 55, 112 }; private readonly int trailType = ModContent.ProjectileType(); - private readonly float detectionRange = 600f; - private readonly float angleSpeed = 20f; - private readonly float angleVariation = 5f; - private readonly int delayToRotate = 10; + private float oldCurrentAngle = 0f; private float currentAngle = 0f; private int oldEnemyTarget = -1; @@ -108,7 +111,7 @@ private void ProjectileAnimate() private void SeekEnemy() { Player owner = Main.player[projectile.owner]; - float shortestDistance = detectionRange; + float shortestDistance = DetectionRange; enemyTarget = -1; for (int i = 0; i < Main.maxNPCs; i++) @@ -117,7 +120,7 @@ private void SeekEnemy() float distance = Vector2.Distance(projectile.Center, selectNpc.Center); float enemyDistance = Vector2.Distance(owner.Center, selectNpc.Center); - if (enemyDistance <= detectionRange && distance < shortestDistance && + if (enemyDistance <= DetectionRange && distance < shortestDistance && !selectNpc.friendly && selectNpc.active) { shortestDistance = distance; @@ -134,7 +137,7 @@ private void SeekEnemy() private void RotateTowardsTarget() { - if (++delayTick >= delayToRotate) + if (++delayTick >= DelayToRotate) { float targetAngle; Vector2 targetVector; @@ -152,9 +155,9 @@ private void RotateTowardsTarget() targetAngle = GradiusHelper.GetBearing(projectile.Center, targetVector); if (GradiusHelper.IsSameClientOwner(projectile)) { - float chosenVariant = Main.rand.NextFloat(angleVariation); + float chosenVariant = Main.rand.NextFloat(AngleVariation); currentAngle = GradiusHelper.AngularRotate(currentAngle, targetAngle, GradiusHelper.MinRotate, - GradiusHelper.MaxRotate, angleSpeed - chosenVariant); + GradiusHelper.MaxRotate, AngleSpeed - chosenVariant); if (oldCurrentAngle != currentAngle) { oldCurrentAngle = currentAngle; @@ -162,7 +165,7 @@ private void RotateTowardsTarget() } } else currentAngle = GradiusHelper.AngularRotate(currentAngle, targetAngle, GradiusHelper.MinRotate, - GradiusHelper.MaxRotate, angleSpeed); + GradiusHelper.MaxRotate, AngleSpeed); projectile.rotation = MathHelper.ToRadians(currentAngle); projectile.velocity = Spd * new Vector2 diff --git a/Projectiles/Options/Charge/ChargeMultipleTrail.cs b/Projectiles/Options/Charge/ChargeMultipleTrail.cs index 37aec2b..9768c92 100644 --- a/Projectiles/Options/Charge/ChargeMultipleTrail.cs +++ b/Projectiles/Options/Charge/ChargeMultipleTrail.cs @@ -5,8 +5,9 @@ namespace ChensGradiusMod.Projectiles.Options.Charge { public class ChargeMultipleTrail : ModProjectile { - private readonly int dustId = 112; - private readonly int dustRate = 5; + private const int DustId = 112; + private const int DustRate = 5; + private int dustTick = 0; public override void SetStaticDefaults() @@ -42,10 +43,10 @@ public override void AI() if (++projectile.frame >= Main.projFrames[projectile.type]) projectile.frame = 0; } - if (++dustTick >= dustRate) + if (++dustTick >= DustRate) { dustTick = 0; - Dust.NewDust(projectile.position, projectile.width, projectile.height, dustId); + Dust.NewDust(projectile.position, projectile.width, projectile.height, DustId); } } } diff --git a/Projectiles/Options/Miscellaneous/OptionSeedObject.cs b/Projectiles/Options/Miscellaneous/OptionSeedObject.cs index 75867f6..3664d2d 100644 --- a/Projectiles/Options/Miscellaneous/OptionSeedObject.cs +++ b/Projectiles/Options/Miscellaneous/OptionSeedObject.cs @@ -11,9 +11,9 @@ public class OptionSeedObject : OptionBaseObject public int rotateDirection = 0; - private readonly int fireRate = 23; - private readonly float rotateSpeed = 7f; - private readonly int inBattleDuration = 180; + private const int FireRate = 23; + private const float RotateSpeed = 7f; + private const int InBattleDuration = 180; private bool isSpawning = true; private float currentAngle = 0f; @@ -62,7 +62,7 @@ public override void AI() OptionAnimate(); if (inBattle) { - if (++inBattleTick >= inBattleDuration) inBattle = false; + if (++inBattleTick >= InBattleDuration) inBattle = false; } if (inBattle && SetProjectileToSpawn()) PerformAttack(); MoveSeed(); @@ -117,7 +117,7 @@ private void PerformAttack(bool fireNow = false) { if (GradiusHelper.IsSameClientOwner(projectile)) { - if (++fireTick >= fireRate || fireNow) + if (++fireTick >= FireRate || fireNow) { fireTick = 0; @@ -148,7 +148,7 @@ private void MoveSeed() }; projectile.velocity = Vector2.Zero; - currentAngle += rotateSpeed * rotateDirection; + currentAngle += RotateSpeed * rotateDirection; GradiusHelper.NormalizeAngleDegrees(ref currentAngle); } } diff --git a/build.txt b/build.txt index 37f0a88..c0c1a99 100644 --- a/build.txt +++ b/build.txt @@ -1,6 +1,6 @@ displayName = Chen's Gradius Mod author = blancfaye7 -version = 0.8.5 +version = 0.9.0 homepage = https://forums.terraria.org/index.php?threads/chens-gradius-mod.83289/ hideCode = true hideResources = true diff --git a/description.txt b/description.txt index a204cc6..46f3970 100644 --- a/description.txt +++ b/description.txt @@ -32,6 +32,8 @@ Added Music with music box: Added Music without music boxes yet: 1. Aircraft Carrier (Gradius Slot version, only played during Big Core Custom fight) +Cross Mod Content API is available already! Check the homepage for more info. + The mod is quite young, so the mod will focus in implementing features rather than balance, for now. Contact us if you have any suggestions and bug reports. For changelogs, please visit the homepage. Complete information can be found in there. There are plenty of ways in the homepage that you can help us with! \ No newline at end of file diff --git a/forum.txt b/forum.txt index 0c4f12c..b193d1b 100644 --- a/forum.txt +++ b/forum.txt @@ -1,7 +1,7 @@ Hello. I decided to share my mod here in the forums. I'm not very good at documenting, but it will improve as time passes. Without further ado... [ATTACH type="full" alt="ChensGradiusModBannerCropped.png"]228045[/ATTACH] -[B][U][SIZE=6]Mod Version: 0.8.5 +[B][U][SIZE=6]Mod Version: 0.9.0 tModLoader: 0.11.5[/SIZE][/U][/B] I have always been a fan of the classic side-scrollers, so I made a mod related to it. On top of that, I want to learn C# as well. It is still a small mod, so content is not abundant. @@ -187,6 +187,15 @@ If you are curious about what our current plans are, you can look them up on the Here is the link: [URL='https://github.com/cheeeeeeeeeen/Chens-Gradius-Mod/projects/1']Gradius Mod Project Board[/URL] [SPOILER="Changelogs"] +0.9.0 + - Optimize Option Rule list code execution + - Create Cross Mod Content API for adding Option rules + - Also create API for supporting custom damage types + - By default, support rogue weapons from Calamity Mod + - Fix Ducker desync issue + - Improve Sagna sync code for it to be smoother in multiplayer + - Increase spawn chance of Zalk, Sagna and Ducker + 0.8.5 - Implement Ducker - Nerf Zalk enemies by reducing their fire rate and reducing their retaliation bullets