HeavenStudioPlus/Assets/Scripts/Util/ParticleSystemHelpers.cs
playinful 45cbe1972b Mostly Bugfixes (#823)
UI tweaks:
- Removed "Clear Photo Cache" GameAction, added "Clear Previous Photos" parameter to the Car cues
- Rolled Move T.J., Rotate T.J., and Scale T.J. GameActions into a single GameAction
- Legacy functions still exist for remixes created on previous nightly builds

Bugs fixed:
- Fixed a bug where the spacing of slow cars would be incorrect after a game switch
- Made particles scale with tempo
  - Added functionality for respecting Rate over Distance in ParticleSystemHelpers
- Fixed a bug where the photo cache was not cleared after stopping playback of a remix.
- Fixed a bug where, upon showing photos, if the remix playback was stopped before the photos were removed from the screen, they would remain on the screen until playback started over.
- Removed an unnecessary call to Debug.Log that had been left in by mistake.
- Fixed a bug where cars' idle animations would play too slowly and at inconsistent timings.

Other refactorings:
- Created a "Car" MonoBehavior attached to both the NearCar and FarCar prefabs that handles the movement of cars, removing the need for the "QueuedCars" property of FreezeFrame.
- Added a failsafe in the ShowCrowd function for if the user indicates a crowd index that does not currently exist.
- Converted one SoundByte.PlayOneShot call into a MultiSound.Sound object.
2024-04-05 01:27:59 +00:00

37 lines
1.4 KiB
C#

using UnityEngine;
namespace HeavenStudio.Util
{
public static class ParticleSystemHelpers
{
public static void PlayScaledAsync(this ParticleSystem particleSystem, float timeScale, bool respectDistance = false)
{
SetAsyncScaling(particleSystem, timeScale, respectDistance);
particleSystem.Play();
}
public static void SetAsyncScaling(this ParticleSystem particleSystem, float timeScale, bool respectDistance = false)
{
ParticleSystem.MainModule main = particleSystem.main;
main.simulationSpeed = main.simulationSpeed / Conductor.instance.pitchedSecPerBeat * timeScale;
// addition by Yin
if (respectDistance)
{
ParticleSystem.EmissionModule emission = particleSystem.emission;
emission.rateOverDistanceMultiplier = Conductor.instance.pitchedSecPerBeat * timeScale * 4; // i don't know why 4 is the magic number
}
}
public static void PlayScaledAsyncAllChildren(this ParticleSystem particleSystem, float timeScale)
{
particleSystem.PlayScaledAsync(timeScale);
foreach (var p in particleSystem.GetComponentsInChildren<ParticleSystem>())
{
if (p == particleSystem) continue;
p.PlayScaledAsyncAllChildren(timeScale);
}
}
}
}