private static void MessageCallback(IChatEmote emote, byte count) { if ((mode == Mode.Menu && Settings.menuRain) || (mode == Mode.Play && Settings.songRain)) { SharedCoroutineStarter.instance.StartCoroutine(WaitForCollection(emote, count)); } }
public static TwitchEmote?AsTwitchEmote(this IChatEmote emote) { return(emote as TwitchEmote); }
private static IEnumerator EnqueueEmote(IChatEmote emote, byte count) { yield return(null); RequestCoordinator.EmoteQueue(emote, count); }
private static IEnumerator <WaitUntil> WaitForCollection(IChatEmote emote, byte count) { float time = Time.time; EnhancedImageInfo enhancedImageInfo = default; yield return(new WaitUntil(() => ChatImageProvider.instance.CachedImageInfo.TryGetValue(emote.Id, out enhancedImageInfo) && mode != Mode.None)); //Log($"Continuing after {Time.time - time} seconds..."); TimeoutScript cloneTimer; PS_Prefab_Pair ps_Prefab_Pair = particleSystems[mode]; if (!ps_Prefab_Pair.Item1.ContainsKey(emote.Id)) { cloneTimer = UnityEngine.Object.Instantiate(ps_Prefab_Pair.Item2).GetComponent <TimeoutScript>(); var main = cloneTimer.PS.main; if (mode == Mode.Menu) { main.startSize = Settings.menuSize; } if (mode == Mode.Play) { main.startSize = Settings.songSize; } main.startSpeed = Settings.emoteFallspeed; main.startLifetime = (8 / (Settings.emoteFallspeed - 1)) + 1; cloneTimer.key = emote.Id; cloneTimer.mode = mode; SceneManager.MoveGameObjectToScene(cloneTimer.gameObject, myScene); ps_Prefab_Pair.Item1.Add(emote.Id, cloneTimer); //sorta working animated emotes if (emote.IsAnimated) { var tex = cloneTimer.PS.textureSheetAnimation; tex.enabled = true; tex.mode = ParticleSystemAnimationMode.Sprites; tex.timeMode = ParticleSystemAnimationTimeMode.Lifetime; int spriteCount = enhancedImageInfo.AnimControllerData.sprites.Length - 1; float timeForEmote = 0; for (int i = 0; i < spriteCount; i++) { tex.AddSprite(enhancedImageInfo.AnimControllerData.sprites[i]); timeForEmote += enhancedImageInfo.AnimControllerData.delays[i]; } //float lifeTime = cloneTimer.PS.main.startLifetime.constant * 1000; AnimationCurve curve = new AnimationCurve(); float singleFramePercentage = 1.0f / spriteCount; float currentTimePercentage = 0; float currentFramePercentage = 0; for (int frameCounter = 0; currentTimePercentage <= 1; frameCounter++) { if (frameCounter > spriteCount) { frameCounter = 0; currentFramePercentage = 0; } curve.AddKey(currentTimePercentage, currentFramePercentage); currentTimePercentage += enhancedImageInfo.AnimControllerData.delays[frameCounter] / timeForEmote; currentFramePercentage += singleFramePercentage; } tex.frameOverTime = new ParticleSystem.MinMaxCurve(1.0f, curve); tex.cycleCount = (int)(cloneTimer.PS.main.startLifetime.constant * 1000 / timeForEmote); } //end of animated emotes //Log("Assigning texture..."); cloneTimer.PSR.material.mainTexture = enhancedImageInfo.Sprite.texture; } else { cloneTimer = ps_Prefab_Pair.Item1[emote.Id]; } cloneTimer.Emit(count); //Log("ParticleSystems notified! "); }