internal static void Prefix(ref NoteCutParticlesEffect __instance, ref int sparkleParticlesCount, ref int explosionParticlesCount) { ParticleSystem[] sparklesPS; try { sparklesPS = (ParticleSystem[])__instance.GetField("_sparklesPS"); } catch (NullReferenceException) { Plugin.log.Critical("Failed to get _sparklesPS field!"); return; } ParticleSystem explosionPS; try { explosionPS = (ParticleSystem)__instance.GetField("_explosionPS"); } catch (NullReferenceException) { Plugin.log.Critical("Failed to get _explosionPS field!"); return; } float slashMultiplier = Plugin.config.GetFloat("particles", "slash-particles") ?? 1f; float explosionMultiplier = Plugin.config.GetFloat("particles", "explosion-particles") ?? 1f; float lifetimeMultiplier = Plugin.config.GetFloat("particles", "particle-lifetime") ?? 1f; float sparkles = sparkleParticlesCount * slashMultiplier; float explosion = explosionParticlesCount * explosionMultiplier; sparkleParticlesCount = Mathf.FloorToInt(sparkles); explosionParticlesCount = Mathf.FloorToInt(explosion); foreach (ParticleSystem ps in sparklesPS) { ParticleSystem.MainModule psMain = ps.main; psMain.maxParticles = int.MaxValue; psMain.startLifetimeMultiplier = lifetimeMultiplier; } ParticleSystem.MainModule explosionMain = explosionPS.main; explosionMain.maxParticles = int.MaxValue; explosionMain.startLifetimeMultiplier = lifetimeMultiplier; }
static void Prefix(ref NoteCutParticlesEffect __instance, ref int sparkleParticlesCount, ref int explosionParticlesCount) { float slashMulti = Plugin.SlashParticleMultiplier; float exploMulti = Plugin.ExplosionParticleMultiplier; ParticleSystem[] slashPS = (ParticleSystem[])__instance.GetField("_sparklesPS"); foreach (ParticleSystem ps in slashPS) { ParticleSystem.MainModule main = ps.main; main.maxParticles = 150 * Mathf.FloorToInt(slashMulti * 2f); } sparkleParticlesCount = 150 * Mathf.FloorToInt(slashMulti); ParticleSystem.MainModule exploPS = ((ParticleSystem)__instance.GetField("_explosionPS")).main; explosionParticlesCount = 150 * Mathf.FloorToInt(exploMulti); exploPS.maxParticles = 150 * Mathf.FloorToInt(exploMulti * 2f); }
static void Prefix(ref NoteCutParticlesEffect __instance, ref int sparkleParticlesCount, ref int explosionParticlesCount) { if (!ChromaSparksConfig.ParticleManipulationEnabled) { return; } sparkleParticlesCount = Mathf.FloorToInt(150 * ChromaSparksConfig.SlashParticlesMult); explosionParticlesCount = Mathf.FloorToInt(150 * ChromaSparksConfig.ExplosionParticlesMult); ParticleSystem[] sparklesPS = __instance.GetField <ParticleSystem[]>("_sparklesPS"); foreach (ParticleSystem sparklesSubPS in sparklesPS) { ParticleSystem.MainModule sparkles = sparklesSubPS.main; if (ChromaSparksConfig.SlashParticlesMult != 1) { sparkles.maxParticles = Mathf.FloorToInt(150 * Mathf.Max(ChromaSparksConfig.ParticlesGlobalMaxMult, ChromaSparksConfig.SlashParticlesMult)); } if (ChromaSparksConfig.SlashParticlesTimeScale != 1) { sparkles.simulationSpeed = ChromaSparksConfig.SlashParticlesTimeScale; } if (ChromaSparksConfig.SlashParticlesLifeMult != 1) { sparkles.duration = 2f * ChromaSparksConfig.SlashParticlesLifeMult; sparkles.startLifetimeMultiplier = 0.99f * ChromaSparksConfig.SlashParticlesLifeMult; } if (ChromaSparksConfig.SlashParticlesSpeedMult != 1) { sparkles.startSpeedMultiplier = 20 * ChromaSparksConfig.SlashParticlesSpeedMult; } } /*for (int i = 0; i < sparklesPS.Length; i++) { * ParticleSystem sparklesSubPS = sparklesPS[i]; * ChromaLogger.Log(sparklesSubPS.name); * ChromaLogger.Log("sparklesPS Amt : " + sparkleParticlesCount); // 150 * ChromaLogger.Log("sparklesPS max : " + sparklesSubPS.main.maxParticles); //1000 * ChromaLogger.Log("sparklesPS life : " + sparklesSubPS.main.duration); //2 * ChromaLogger.Log("sparklesPS lifetimeMult : " + sparklesSubPS.main.startLifetimeMultiplier); //0.99 * ChromaLogger.Log("sparklesPS speedMult : " + sparklesSubPS.main.startSpeedMultiplier); //20 * }*/ /*ParticleSystem sparklesPS = __instance.GetField<ParticleSystem>("_sparklesPS"); * * ParticleSystem.MainModule sparkles = sparklesPS.main; * if (ChromaConfig.slashParticlesMult != 1) sparkles.maxParticles = 150 * Mathf.FloorToInt(Mathf.Max(ChromaConfig.particlesGlobalMaxMult, ChromaConfig.slashParticlesMult)); * if (ChromaConfig.slashParticlesTimeScale != 1) sparkles.simulationSpeed = ChromaConfig.slashParticlesTimeScale; * if (ChromaConfig.slashParticlesLifeMult != 1) { * sparkles.duration = 2f * ChromaConfig.slashParticlesLifeMult; * sparkles.startLifetimeMultiplier = 1.2f * ChromaConfig.slashParticlesLifeMult; * } * if (ChromaConfig.slashParticlesSpeedMult != 1) sparkles.startSpeedMultiplier = 20 * ChromaConfig.slashParticlesSpeedMult; */ ParticleSystem explosionPS = __instance.GetField <ParticleSystem>("_explosionPS"); ParticleSystem.MainModule explosions = explosionPS.main; if (ChromaSparksConfig.ExplosionParticlesMult != 1) { explosions.maxParticles = Mathf.FloorToInt(150 * Mathf.Max(ChromaSparksConfig.ParticlesGlobalMaxMult, ChromaSparksConfig.ExplosionParticlesMult)); } if (ChromaSparksConfig.ExplosionParticlesTimeScale != 1) { explosions.simulationSpeed = ChromaSparksConfig.ExplosionParticlesTimeScale; } if (ChromaSparksConfig.ExplosionParticlesLifeMult != 1) { explosions.duration = 2f * ChromaSparksConfig.ExplosionParticlesLifeMult; explosions.startLifetimeMultiplier = 0.8f * ChromaSparksConfig.ExplosionParticlesLifeMult; } if (ChromaSparksConfig.ExplosionParticlesSpeedMult != 1) { explosions.startSpeedMultiplier = 12 * ChromaSparksConfig.ExplosionParticlesSpeedMult; } //ChromaLogger.Log("sparklesPS Amt : " + sparkleParticlesCount); // 150 //ChromaLogger.Log("sparklesPS max : " + sparklesPS.main.maxParticles); //1000 //ChromaLogger.Log("sparklesPS life : " + sparklesPS.main.duration); //2 //ChromaLogger.Log("sparklesPS lifetimeMult : " + sparklesPS.main.startLifetimeMultiplier); //1.2 //ChromaLogger.Log("sparklesPS speedMult : " + sparklesPS.main.startSpeedMultiplier); //20 //ChromaLogger.Log("explosionPS Amt : " + sparkleParticlesCount); // 150 //ChromaLogger.Log("explosionPS max : " + explosionPS.main.maxParticles); //1000 //ChromaLogger.Log("explosionPS life : " + explosionPS.main.duration); //2 //ChromaLogger.Log("explosionPS lifetimeMult : " + explosionPS.main.startLifetimeMultiplier); //0.8 //ChromaLogger.Log("explosionPS speedMult : " + explosionPS.main.startSpeedMultiplier); //12 return; }