Skip to content

Commit

Permalink
Added support for changing SaberClash sparkle effect particle amount …
Browse files Browse the repository at this point in the history
…and lifetime
  • Loading branch information
Shadnix-was-taken committed Sep 20, 2020
1 parent 0286b36 commit df6e6ae
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 17 deletions.
39 changes: 39 additions & 0 deletions ParticleOverdrive/Misc/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ internal static float SlashParticleLifetimeMultiplier
}
}

//static readonly string slashParticleSpeedMultiplier = "SlashParticleSpeedMultiplier";
//internal static float SlashParticleSpeedMultiplier
//{
// get
// {
// return config.GetFloat(sectionParticles, slashParticleSpeedMultiplier, 1.0f, true);
// }
// set
// {
// config.SetFloat(sectionParticles, slashParticleSpeedMultiplier, value);
// }
//}

static readonly string explosionParticleMultiplier = "ExplosionParticleMultiplier";
internal static float ExplosionParticleMultiplier
{
Expand Down Expand Up @@ -83,6 +96,32 @@ internal static bool RainbowParticles
}
}

static readonly string clashParticleMultiplier = "ClashParticleMultiplier";
internal static float ClashParticleMultiplier
{
get
{
return config.GetFloat(sectionParticles, clashParticleMultiplier, 1.0f, true);
}
set
{
config.SetFloat(sectionParticles, clashParticleMultiplier, value);
}
}

static readonly string clashParticleLifetimeMultiplier = "ClashParticleLifetimeMultiplier";
internal static float ClashParticleLifetimeMultiplier
{
get
{
return config.GetFloat(sectionParticles, clashParticleLifetimeMultiplier, 1.0f, true);
}
set
{
config.SetFloat(sectionParticles, clashParticleLifetimeMultiplier, value);
}
}

static readonly string dustParticles = "DustParticles";
internal static bool DustParticles
{
Expand Down
1 change: 1 addition & 0 deletions ParticleOverdrive/ParticleOverdrive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<Compile Include="Misc\Config.cs" />
<Compile Include="Misc\Logger.cs" />
<Compile Include="Patches\NoteCutParticlesEffectSpawnParticles.cs" />
<Compile Include="Patches\SaberClashEffectStart.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Controllers\WorldParticleController.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@ internal static void Prefix(ref NoteCutParticlesEffect __instance, ref Color32 c
sparkleParticlesCount = Mathf.FloorToInt(sparkleParticlesCount * Plugin.SlashParticleMultiplier);
explosionParticlesCount = Mathf.FloorToInt(explosionParticlesCount * Plugin.ExplosionParticleMultiplier);
lifetimeMultiplier *= Plugin.SlashParticleLifetimeMultiplier;

if (Plugin.RainbowParticles)
color = UnityEngine.Random.ColorHSV(0, 1, 1, 1, 1, 1, 1, 1);

for (int i = 0; i < sparklesPSAry.Length; i++)
{
ParticleSystem.MainModule slashMain = sparklesPSAry[i].main;
slashMain.maxParticles = int.MaxValue;
//slashMain.startSpeedMultiplier = 200f;
}

ParticleSystem.MainModule explosionMain = explosionPS.main;
explosionMain.maxParticles = int.MaxValue;
explosionMain.startLifetimeMultiplier = Plugin.ExplosionParticleLifetimeMultiplier;
}

}

}
35 changes: 35 additions & 0 deletions ParticleOverdrive/Patches/SaberClashEffectStart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;


namespace ParticleOverdrive.Patches
{
[HarmonyPatch(typeof(SaberClashEffect), "Start")]
class SaberClashEffectStart
{
[HarmonyPostfix]
internal static void SaberClashEffectStartPostfix(ref SaberClashEffect __instance)
{
ParticleSystem glowPS = Plugin.GetSaberClashGlowPS(__instance);
ParticleSystem sparklePS = Plugin.GetSaberClashSparklePS(__instance);

ParticleSystem.EmissionModule glowEM = glowPS.emission;
ParticleSystem.EmissionModule sparkleEM = sparklePS.emission;

ParticleSystem.MainModule glowMain = glowPS.main;
ParticleSystem.MainModule sparkleMain = sparklePS.main;

glowMain.maxParticles = int.MaxValue;

sparkleEM.rateOverDistanceMultiplier = sparkleEM.rateOverDistanceMultiplier * Plugin.ClashParticleMultiplier;
sparkleEM.rateOverTimeMultiplier = sparkleEM.rateOverTimeMultiplier * Plugin.ClashParticleMultiplier;
sparkleMain.maxParticles = int.MaxValue;
sparkleMain.startLifetimeMultiplier = Plugin.ClashParticleLifetimeMultiplier;
}
}
}
12 changes: 11 additions & 1 deletion ParticleOverdrive/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace ParticleOverdrive
public class Plugin
{
public string Name => "Particle Overdive";
public string Version => "1.4.0";
public string Version => "1.5.0";
IPA.Logging.Logger log;

private static readonly string[] env = { "Init", "MenuViewControllers", "GameCore", "Credits" };
Expand All @@ -31,6 +31,8 @@ public class Plugin
internal static RefGetter<NoteCutParticlesEffect, ParticleSystem[]> GetSparklesPS;
internal static RefGetter<BlueNoiseDitheringUpdater, BlueNoiseDithering> GetBlueNoiseDithering;
internal static RefGetter<BlueNoiseDithering, Texture2D> GetNoiseTexture;
internal static RefGetter<SaberClashEffect, ParticleSystem> GetSaberClashGlowPS;
internal static RefGetter<SaberClashEffect, ParticleSystem> GetSaberClashSparklePS;
#endregion

internal static bool CameraNoiseWorldParticlesEnabled;
Expand All @@ -40,8 +42,11 @@ public class Plugin

public static float SlashParticleMultiplier;
public static float ExplosionParticleMultiplier;
public static float ClashParticleMultiplier;
public static float SlashParticleLifetimeMultiplier;
public static float ExplosionParticleLifetimeMultiplier;
public static float ClashParticleLifetimeMultiplier;
public static float SlashParticleSpeedMultiplier;
public static bool RainbowParticles;

[Init]
Expand All @@ -56,8 +61,11 @@ public void LoadConfig()
{
SlashParticleMultiplier = Config.SlashParticleMultiplier;
ExplosionParticleMultiplier = Config.ExplosionParticleMultiplier;
ClashParticleMultiplier = Config.ClashParticleMultiplier;
SlashParticleLifetimeMultiplier = Config.SlashParticleLifetimeMultiplier;
ExplosionParticleLifetimeMultiplier = Config.ExplosionParticleLifetimeMultiplier;
ClashParticleLifetimeMultiplier = Config.ClashParticleLifetimeMultiplier;
//SlashParticleSpeedMultiplier = Config.SlashParticleSpeedMultiplier;
RainbowParticles = Config.RainbowParticles;
}

Expand All @@ -81,6 +89,8 @@ public void OnStart()
{
GetExplosionPS = Utilities.CreateRefGetter<NoteCutParticlesEffect, ParticleSystem>("_explosionPS");
GetSparklesPS = Utilities.CreateRefGetter<NoteCutParticlesEffect, ParticleSystem[]>("_sparklesPS");
GetSaberClashGlowPS = Utilities.CreateRefGetter<SaberClashEffect, ParticleSystem>("_glowParticleSystem");
GetSaberClashSparklePS = Utilities.CreateRefGetter<SaberClashEffect, ParticleSystem>("_sparkleParticleSystem");
SlashExplosionParticlesEnabled = true;
try
{
Expand Down
4 changes: 2 additions & 2 deletions ParticleOverdrive/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: NeutralResourcesLanguage("en-GB")]

47 changes: 39 additions & 8 deletions ParticleOverdrive/UI/POUI.bsml
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
<settings-container>
<bool-setting text='Camera Noise' value='cameraNoiseEnable'></bool-setting>
<bool-setting text='Global Dust Particles' value='dustParticleEnable'></bool-setting>
<list-setting text='Slash Particles' value='slashParticleChoice' choices='slashParticleChoices' formatter='multiplierFormatter'></list-setting>
<list-setting text='Slash Particle Lifetime' value='slashParticleLifetimeChoice' choices='lifetimeChoices' formatter='multiplierFormatter'></list-setting>
<list-setting text='Explosion Particles' value='explosionParticleChoice' choices='explosionParticleChoices' formatter='multiplierFormatter'></list-setting>
<list-setting text='Explosion Particle Lifetime' value='explosionParticleLifetimeChoice' choices='lifetimeChoices' formatter='multiplierFormatter'></list-setting>
<bool-setting text='Rainbow Particles' value='rainbowParticlesEnable'></bool-setting>
<settings-container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://monkeymanboy.github.io/BSML-Docs/ https://raw.githubusercontent.com/monkeymanboy/BSML-Docs/gh-pages/BSMLSchema.xsd">
<horizontal pref-width='90'>
<text text='Particle Overdrive Settings' font-size='5' align='Center'/>
</horizontal>

<!--World Particles-->
<settings-submenu text='&#62; World Particles...' hover-hint='Enable/Disable world particles and camera noise.'>
<settings-container>
<bool-setting text='Camera Noise' value='cameraNoiseEnable'></bool-setting>
<bool-setting text='Global Dust Particles' value='dustParticleEnable'></bool-setting>

<clickable-text text='&#60; Back' align='Left' click-event='back' />
</settings-container>
</settings-submenu>

<!--Note Cut Particles-->
<settings-submenu text='&#62; Note Cut Particles...' hover-hint='Modify or disable note cut particles.'>
<settings-container>
<list-setting text='Slash Particles' value='slashParticleChoice' choices='slashParticleChoices' formatter='multiplierFormatter'></list-setting>
<list-setting text='Slash Particle Lifetime' value='slashParticleLifetimeChoice' choices='lifetimeChoices' formatter='multiplierFormatter'></list-setting>
<!--<list-setting text='Slash Particle Speed' value='slashParticleSpeedChoice' choices='slashParticleSpeedChoices' formatter='multiplierFormatter'></list-setting>-->
<list-setting text='Explosion Particles' value='explosionParticleChoice' choices='explosionParticleChoices' formatter='multiplierFormatter'></list-setting>
<list-setting text='Explosion Particle Lifetime' value='explosionParticleLifetimeChoice' choices='lifetimeChoices' formatter='multiplierFormatter'></list-setting>
<bool-setting text='Rainbow Particles' value='rainbowParticlesEnable'></bool-setting>

<clickable-text text='&#60; Back' align='Left' click-event='back' />
</settings-container>
</settings-submenu>

<!--Saber Clash Particles-->
<settings-submenu text='&#62; Saber Clash Particles...' hover-hint='Modify or disable saber clash particles.'>
<settings-container>
<list-setting text='Clash Particles' value='clashParticleChoice' choices='clashParticleChoices' formatter='multiplierFormatter'></list-setting>
<list-setting text='Clash Particles Lifetime' value='clashParticleLifetimeChoice' choices='lifetimeChoices' formatter='multiplierFormatter'></list-setting>

<clickable-text text='&#60; Back' align='Left' click-event='back' />
</settings-container>
</settings-submenu>

</settings-container>
46 changes: 43 additions & 3 deletions ParticleOverdrive/UI/POUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,15 @@ public class POUI : PersistentSingleton<POUI>
[UIValue("slashParticleChoices")]
private List<object> _slashParticleMultiplierChoices = particleMultiplierChoicesList;

[UIValue("slashParticleSpeedChoices")]
private List<object> _slashParticleSpeedChoices = particleMultiplierChoicesList;

[UIValue("explosionParticleChoices")]
private List<object> _explosionParticleMultiplierChoices = particleMultiplierChoicesList;

[UIValue("clashParticleChoices")]
private List<object> _clashParticleMultiplierChoices = particleMultiplierChoicesList;

[UIValue("lifetimeChoices")]
private List<object> _lifetimeChoices = LifetimeValues;

Expand Down Expand Up @@ -171,7 +177,6 @@ public bool _dustParticleEnable
[UIValue("slashParticleChoice")]
public float _slashParticleMultiplier
{
//get => Config.SlashParticleMultiplier;
get => Config.SlashParticleMultiplier;
set
{
Expand All @@ -183,7 +188,6 @@ public float _slashParticleMultiplier
[UIValue("slashParticleLifetimeChoice")]
public float _slashParticleLifetimeMultiplier
{
//get => Config.SlashParticleMultiplier;
get => Config.SlashParticleLifetimeMultiplier;
set
{
Expand All @@ -192,6 +196,17 @@ public float _slashParticleLifetimeMultiplier
}
}

//[UIValue("slashParticleSpeedChoice")]
//public float _slashParticleSpeedMultiplier
//{
// get => Config.SlashParticleSpeedMultiplier;
// set
// {
// Plugin.SlashParticleSpeedMultiplier = value;
// Config.SlashParticleSpeedMultiplier = value;
// }
//}

[UIValue("explosionParticleChoice")]
public float _explosionParticleMultiplier
{
Expand All @@ -208,7 +223,7 @@ public float _explosionParticleMultiplier
[UIValue("explosionParticleLifetimeChoice")]
public float _explosionParticleLifetimeMultiplier
{
//get => Config.SlashParticleMultiplier;
//get => Config.ExplosionParticleLifetimeMultiplier;
get => Config.ExplosionParticleLifetimeMultiplier;
set
{
Expand All @@ -229,6 +244,31 @@ public bool _rainbowParticlesEnable
}
}

[UIValue("clashParticleChoice")]
public float _clashParticleMultiplier
{
//get => Config.ClashParticleMultiplier;
get => Config.ClashParticleMultiplier;
set
{
Plugin.ClashParticleMultiplier = value;
Config.ClashParticleMultiplier = value;
}
}


[UIValue("clashParticleLifetimeChoice")]
public float _clashParticleLifetimeMultiplier
{
//get => Config.ClashParticleMultiplier;
get => Config.ClashParticleLifetimeMultiplier;
set
{
Plugin.ClashParticleLifetimeMultiplier = value;
Config.ClashParticleLifetimeMultiplier = value;
}
}

[UIAction("multiplierFormatter")]
public string multiplierDisplay(float multiplier)
{
Expand Down
3 changes: 1 addition & 2 deletions ParticleOverdrive/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
"gameVersion": "1.11.1",
"id": "Particle Overdrive",
"name": "Particle Overdrive",
"version": "1.4.0",
"version": "1.5.0",
"dependsOn": {
"BSIPA": "^4.0.0",
"BeatSaberMarkupLanguage": "^1.2.0",
"BS Utils": "^1.4.11"
},
"loadAfter": [ "BS Utils", "BeatSaberMarkupLanguage" ],
"features": [],
"links": {
"project-home": "https://github.com/Shadnix-was-taken/BeatSaber-ParticleOverdrive"
}
Expand Down

0 comments on commit df6e6ae

Please sign in to comment.