using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoundsCinematicKO.Patches;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("RoundsCinematicKO")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+46578d29a9a68475fe152bd15d36419fe8f99bc4")]
[assembly: AssemblyProduct("RoundsCinematicKO")]
[assembly: AssemblyTitle("RoundsCinematicKO")]
[assembly: AssemblyVersion("1.0.3.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace RoundsCinematicKO
{
public enum KOType
{
PointWin,
RoundWin,
MatchVictory
}
public class CinematicKOController : MonoBehaviour
{
private struct Confetti
{
public Vector2 pos;
public Vector2 vel;
public float rot;
public float rotSpeed;
public Color color;
public Vector2 size;
}
private AudioSource audioSource;
private AudioClip pointSubBassClip;
private AudioClip roundSubBassClip;
private AudioClip victorySubBassClip;
private bool isCinematicActive;
private KOType currentKOType = KOType.RoundWin;
private float flashAlpha;
private Color flashColor = Color.white;
private float letterboxProgress;
private float bannerProgress;
private float bannerScale = 1f;
private Vector3 originalCamPos;
private float originalCamSize = 20f;
private Vector3 targetCamPos;
private float targetCamSize = 9.5f;
private Vector3 currentCamPos;
private float currentCamSize = 20f;
private bool overrideCamera;
private Transform winnerTransform;
private List<Confetti> confettiList = new List<Confetti>();
private Texture2D whiteTex;
private Texture2D blackTex;
private GUIStyle victoryStyle;
private GUIStyle subTextStyle;
private GUIStyle roundStyle;
public static CinematicKOController Instance { get; private set; }
private void Awake()
{
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Expected O, but got Unknown
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Expected O, but got Unknown
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
Instance = this;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
audioSource.playOnAwake = false;
audioSource.spatialBlend = 0f;
audioSource.volume = 1f;
try
{
pointSubBassClip = CreateWarmSubBass(75f, 32f, 0.35f, addHarmonicShimmer: false);
roundSubBassClip = CreateWarmSubBass(85f, 26f, 0.65f, addHarmonicShimmer: false);
victorySubBassClip = CreateWarmSubBass(95f, 24f, 1.3f, addHarmonicShimmer: true);
}
catch (Exception ex)
{
Debug.LogWarning("[RoundsCinematicKO] Audio synthesis error: " + ex.Message);
}
whiteTex = new Texture2D(1, 1, (TextureFormat)4, false);
whiteTex.SetPixel(0, 0, Color.white);
whiteTex.Apply();
blackTex = new Texture2D(1, 1, (TextureFormat)4, false);
blackTex.SetPixel(0, 0, Color.black);
blackTex.Apply();
try
{
SceneManager.sceneLoaded += delegate
{
CancelCinematic();
};
}
catch
{
}
}
public void TriggerKO(Vector3 killPosition, Vector2 deathDirection, Color killerColor, KOType koType, Transform winner = null)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
if (!isCinematicActive && RoundsCinematicKOPlugin.EnableCinematicKO.Value)
{
((MonoBehaviour)this).StartCoroutine(CoPlayCinematicKO(killPosition, deathDirection, killerColor, koType, winner));
}
}
public void TriggerVictoryScreen(Color winnerColor, Transform winner = null)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (RoundsCinematicKOPlugin.EnableCinematicKO.Value)
{
((MonoBehaviour)this).StopAllCoroutines();
((MonoBehaviour)this).StartCoroutine(CoPlayVictoryScreen(winnerColor, winner));
}
}
private IEnumerator CoPlayVictoryScreen(Color winnerColor, Transform winner)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
isCinematicActive = true;
currentKOType = KOType.MatchVictory;
winnerTransform = winner;
flashColor = Color.Lerp(Color.white, winnerColor, 0.4f);
flashAlpha = 0.65f;
bannerProgress = 0f;
bannerScale = 2.4f;
letterboxProgress = 1f;
try
{
if ((Object)(object)UIHandler.instance != (Object)null && (Object)(object)UIHandler.instance.gameOverText != (Object)null)
{
((Behaviour)UIHandler.instance.gameOverText).enabled = false;
}
}
catch
{
}
SpawnConfetti(winnerColor);
if (RoundsCinematicKOPlugin.EnableSubBassSFX.Value && (Object)(object)audioSource != (Object)null && (Object)(object)victorySubBassClip != (Object)null)
{
audioSource.clip = victorySubBassClip;
audioSource.volume = RoundsCinematicKOPlugin.SFXVolume.Value;
audioSource.Play();
}
Camera cam = (((Object)(object)MainCam.instance != (Object)null) ? MainCam.instance.cam : Camera.main);
if ((Object)(object)cam != (Object)null && (Object)(object)winner != (Object)null && RoundsCinematicKOPlugin.EnableCameraZoom.Value)
{
overrideCamera = true;
originalCamPos = ((Component)cam).transform.position;
originalCamSize = cam.orthographicSize;
targetCamPos = new Vector3(winner.position.x, winner.position.y, originalCamPos.z);
targetCamSize = Mathf.Clamp(originalCamSize * 0.45f, 7.5f, 15f);
currentCamPos = originalCamPos;
currentCamSize = originalCamSize;
}
float elapsed = 0f;
while (elapsed < 0.6f)
{
elapsed += Time.unscaledDeltaTime;
bannerProgress = Mathf.Clamp01(elapsed / 0.4f);
bannerScale = Mathf.Lerp(2.4f, 1f, Mathf.Pow(bannerProgress, 2.5f));
flashAlpha = Mathf.Max(0f, flashAlpha - Time.unscaledDeltaTime * 2.5f);
UpdateConfetti(Time.unscaledDeltaTime);
if (overrideCamera && (Object)(object)cam != (Object)null)
{
float num = Mathf.Clamp01(elapsed / 0.6f);
float num2 = 1f - Mathf.Pow(1f - num, 3f);
currentCamPos = Vector3.Lerp(originalCamPos, targetCamPos, num2);
currentCamSize = Mathf.Lerp(originalCamSize, targetCamSize, num2);
}
yield return null;
}
bannerProgress = 1f;
bannerScale = 1f;
while (isCinematicActive)
{
UpdateConfetti(Time.unscaledDeltaTime);
yield return null;
}
}
public void CancelCinematic()
{
((MonoBehaviour)this).StopAllCoroutines();
isCinematicActive = false;
overrideCamera = false;
flashAlpha = 0f;
letterboxProgress = 0f;
bannerProgress = 0f;
winnerTransform = null;
confettiList.Clear();
try
{
if ((Object)(object)UIHandler.instance != (Object)null && (Object)(object)UIHandler.instance.gameOverText != (Object)null)
{
((Behaviour)UIHandler.instance.gameOverText).enabled = true;
}
}
catch
{
}
if ((Object)(object)TimeHandler.instance != (Object)null)
{
TimeHandler.instance.timeStop = 1f;
}
Time.timeScale = 1f;
}
private IEnumerator CoPlayCinematicKO(Vector3 killPos, Vector2 deathDirection, Color killerColor, KOType koType, Transform winner)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
isCinematicActive = true;
currentKOType = koType;
winnerTransform = winner;
bannerProgress = 0f;
bannerScale = ((koType == KOType.MatchVictory) ? 2.4f : 0f);
if (RoundsCinematicKOPlugin.EnableSubBassSFX.Value && (Object)(object)audioSource != (Object)null)
{
AudioClip val = (AudioClip)(koType switch
{
KOType.RoundWin => roundSubBassClip,
KOType.MatchVictory => victorySubBassClip,
_ => pointSubBassClip,
});
if ((Object)(object)val != (Object)null)
{
float num = koType switch
{
KOType.RoundWin => 0.85f,
KOType.MatchVictory => 1f,
_ => 0.6f,
};
audioSource.clip = val;
audioSource.volume = RoundsCinematicKOPlugin.SFXVolume.Value * num;
audioSource.Play();
}
}
if (RoundsCinematicKOPlugin.EnableImpactFlash.Value)
{
flashColor = Color.Lerp(Color.white, killerColor, 0.4f);
flashAlpha = koType switch
{
KOType.RoundWin => 0.7f,
KOType.MatchVictory => 0.9f,
_ => 0.45f,
};
}
try
{
if ((Object)(object)GamefeelManager.instance != (Object)null)
{
GamefeelManager.GameFeel(((((Vector2)(ref deathDirection)).sqrMagnitude > 0.01f) ? ((Vector2)(ref deathDirection)).normalized : Vector2.up) * koType switch
{
KOType.RoundWin => 7.5f,
KOType.MatchVictory => 11f,
_ => 4f,
});
GamefeelManager.instance.AddUIGameFeelOverTime(20f, (koType == KOType.MatchVictory) ? 0.55f : 0.35f);
}
}
catch
{
}
Camera cam = (((Object)(object)MainCam.instance != (Object)null) ? MainCam.instance.cam : Camera.main);
if ((Object)(object)cam != (Object)null && RoundsCinematicKOPlugin.EnableCameraZoom.Value)
{
overrideCamera = true;
originalCamPos = ((Component)cam).transform.position;
originalCamSize = cam.orthographicSize;
targetCamPos = new Vector3(killPos.x * 0.75f, killPos.y * 0.75f, originalCamPos.z);
targetCamSize = Mathf.Clamp(originalCamSize * 0.45f, koType switch
{
KOType.RoundWin => 9.5f,
KOType.MatchVictory => 7.2f,
_ => 14f,
}, 16f);
currentCamPos = originalCamPos;
currentCamSize = originalCamSize;
}
if (koType == KOType.MatchVictory)
{
SpawnConfetti(killerColor);
}
float hitStopDuration = koType switch
{
KOType.RoundWin => 0.14f,
KOType.MatchVictory => 0.22f,
_ => 0.08f,
};
float elapsedReal = 0f;
if (RoundsCinematicKOPlugin.EnableSlowMotion.Value && (Object)(object)TimeHandler.instance != (Object)null)
{
TimeHandler.instance.timeStop = ((koType == KOType.MatchVictory) ? 0.02f : 0.05f);
}
while (elapsedReal < hitStopDuration)
{
elapsedReal += Time.unscaledDeltaTime;
if (RoundsCinematicKOPlugin.EnableLetterbox.Value)
{
letterboxProgress = Mathf.Clamp01(elapsedReal / (hitStopDuration * 1.2f));
}
yield return null;
}
float slowMoDuration = koType switch
{
KOType.RoundWin => 0.8f,
KOType.MatchVictory => 1.35f,
_ => 0.4f,
};
elapsedReal = 0f;
while (elapsedReal < slowMoDuration)
{
elapsedReal += Time.unscaledDeltaTime;
float num2 = Mathf.Clamp01(elapsedReal / slowMoDuration);
float num3 = 1f - Mathf.Pow(1f - num2, 3f);
bannerProgress = Mathf.Clamp01(elapsedReal / (slowMoDuration * 0.4f));
if (koType == KOType.MatchVictory)
{
bannerScale = Mathf.Lerp(2.4f, 1f, Mathf.Pow(bannerProgress, 2.5f));
}
if (RoundsCinematicKOPlugin.EnableSlowMotion.Value && (Object)(object)TimeHandler.instance != (Object)null)
{
float num4 = ((koType == KOType.MatchVictory) ? 0.06f : 0.12f);
float num5 = ((koType == KOType.MatchVictory) ? 0.5f : 0.7f);
TimeHandler.instance.timeStop = Mathf.Lerp(num4, num5, Mathf.Pow(num2, 1.6f));
}
if (overrideCamera && (Object)(object)cam != (Object)null)
{
Vector3 val2 = ((koType == KOType.MatchVictory && (Object)(object)winnerTransform != (Object)null && num2 > 0.45f) ? Vector3.Lerp(targetCamPos, new Vector3(winnerTransform.position.x, winnerTransform.position.y, originalCamPos.z), (num2 - 0.45f) / 0.55f) : targetCamPos);
currentCamPos = Vector3.Lerp(originalCamPos, val2, num3);
currentCamSize = Mathf.Lerp(originalCamSize, targetCamSize, num3);
}
if (koType == KOType.MatchVictory)
{
UpdateConfetti(Time.unscaledDeltaTime);
}
flashAlpha = Mathf.Max(0f, flashAlpha - Time.unscaledDeltaTime * 4.5f);
yield return null;
}
float returnDuration = ((koType == KOType.MatchVictory) ? 0.5f : 0.35f);
elapsedReal = 0f;
Vector3 zoomedPos = currentCamPos;
float zoomedSize = currentCamSize;
while (elapsedReal < returnDuration)
{
elapsedReal += Time.unscaledDeltaTime;
float num6 = Mathf.Clamp01(elapsedReal / returnDuration);
float num7 = Mathf.SmoothStep(0f, 1f, num6);
if (RoundsCinematicKOPlugin.EnableSlowMotion.Value && (Object)(object)TimeHandler.instance != (Object)null)
{
TimeHandler.instance.timeStop = Mathf.Lerp(0.7f, 1f, num7);
}
if (overrideCamera && (Object)(object)cam != (Object)null)
{
currentCamPos = Vector3.Lerp(zoomedPos, originalCamPos, num7);
currentCamSize = Mathf.Lerp(zoomedSize, originalCamSize, num7);
}
if (RoundsCinematicKOPlugin.EnableLetterbox.Value)
{
letterboxProgress = 1f - num7;
}
bannerProgress = 1f - num7;
if (koType == KOType.MatchVictory)
{
UpdateConfetti(Time.unscaledDeltaTime);
}
yield return null;
}
CancelCinematic();
}
private void SpawnConfetti(Color winnerColor)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
confettiList.Clear();
Color[] array = (Color[])(object)new Color[5]
{
winnerColor,
new Color(1f, 0.85f, 0.2f),
new Color(1f, 0.95f, 0.6f),
Color.white,
new Color(winnerColor.r * 1.2f, winnerColor.g * 1.2f, winnerColor.b * 1.2f)
};
for (int i = 0; i < 48; i++)
{
confettiList.Add(new Confetti
{
pos = new Vector2(Random.Range(0f, (float)Screen.width), Random.Range(-50f, (float)Screen.height * 0.4f)),
vel = new Vector2(Random.Range(-60f, 60f), Random.Range(200f, 480f)),
rot = Random.Range(0f, 360f),
rotSpeed = Random.Range(-240f, 240f),
color = array[Random.Range(0, array.Length)],
size = new Vector2(Random.Range(8f, 16f), Random.Range(14f, 26f))
});
}
}
private void UpdateConfetti(float dt)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < confettiList.Count; i++)
{
Confetti value = confettiList[i];
ref Vector2 pos = ref value.pos;
pos += value.vel * dt;
value.rot += value.rotSpeed * dt;
value.vel.x += Mathf.Sin(value.pos.y * 0.03f) * 15f * dt;
if (value.pos.y > (float)Screen.height + 35f)
{
value.pos = new Vector2(Random.Range(0f, (float)Screen.width), Random.Range(-50f, -10f));
value.vel = new Vector2(Random.Range(-60f, 60f), Random.Range(180f, 420f));
}
confettiList[i] = value;
}
}
private void LateUpdate()
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
if (overrideCamera && isCinematicActive)
{
Camera val = (((Object)(object)MainCam.instance != (Object)null) ? MainCam.instance.cam : Camera.main);
if ((Object)(object)val != (Object)null)
{
val.orthographicSize = currentCamSize;
((Component)val).transform.position = currentCamPos;
}
}
}
private void OnGUI()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_0409: Unknown result type (might be due to invalid IL or missing references)
//IL_044c: Unknown result type (might be due to invalid IL or missing references)
//IL_047e: Unknown result type (might be due to invalid IL or missing references)
//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0517: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_0339: Unknown result type (might be due to invalid IL or missing references)
//IL_0348: Unknown result type (might be due to invalid IL or missing references)
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0624: Unknown result type (might be due to invalid IL or missing references)
//IL_0656: Unknown result type (might be due to invalid IL or missing references)
//IL_068b: Unknown result type (might be due to invalid IL or missing references)
//IL_0695: Unknown result type (might be due to invalid IL or missing references)
//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
//IL_06ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0595: Unknown result type (might be due to invalid IL or missing references)
//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0399: Unknown result type (might be due to invalid IL or missing references)
//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
if (!isCinematicActive)
{
return;
}
InitStyles();
if (flashAlpha > 0.005f && (Object)(object)whiteTex != (Object)null)
{
Color color = GUI.color;
GUI.color = new Color(flashColor.r, flashColor.g, flashColor.b, flashAlpha);
GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)whiteTex);
GUI.color = color;
}
if (currentKOType == KOType.MatchVictory && (Object)(object)whiteTex != (Object)null)
{
for (int i = 0; i < confettiList.Count; i++)
{
Confetti confetti = confettiList[i];
if (!(confetti.pos.y > (float)Screen.height + 30f))
{
Color color2 = GUI.color;
GUI.color = confetti.color;
Matrix4x4 matrix = GUI.matrix;
GUIUtility.RotateAroundPivot(confetti.rot, confetti.pos);
GUI.DrawTexture(new Rect(confetti.pos.x - confetti.size.x * 0.5f, confetti.pos.y - confetti.size.y * 0.5f, confetti.size.x, confetti.size.y), (Texture)(object)whiteTex);
GUI.matrix = matrix;
GUI.color = color2;
}
}
}
if (letterboxProgress > 0.01f && (Object)(object)blackTex != (Object)null)
{
float num = ((currentKOType == KOType.MatchVictory) ? 0.11f : ((currentKOType == KOType.RoundWin) ? 0.085f : 0.045f));
float num2 = (float)Screen.height * num * letterboxProgress;
GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, num2), (Texture)(object)blackTex);
GUI.DrawTexture(new Rect(0f, (float)Screen.height - num2, (float)Screen.width, num2), (Texture)(object)blackTex);
if (currentKOType != KOType.PointWin && (Object)(object)whiteTex != (Object)null)
{
Color color3 = GUI.color;
GUI.color = new Color(1f, 0.85f, 0.25f, 0.65f * letterboxProgress);
GUI.DrawTexture(new Rect(0f, num2 - 2f, (float)Screen.width, 2f), (Texture)(object)whiteTex);
GUI.DrawTexture(new Rect(0f, (float)Screen.height - num2, (float)Screen.width, 2f), (Texture)(object)whiteTex);
GUI.color = color3;
}
}
if (!(bannerProgress > 0.05f))
{
return;
}
if (currentKOType == KOType.MatchVictory)
{
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor((float)Screen.width * 0.5f, (float)Screen.height * 0.44f);
Matrix4x4 matrix2 = GUI.matrix;
GUIUtility.ScaleAroundPivot(new Vector2(bannerScale, bannerScale), val);
if ((Object)(object)blackTex != (Object)null)
{
Color color4 = GUI.color;
GUI.color = new Color(0.02f, 0.02f, 0.02f, 0.65f * bannerProgress);
GUI.DrawTexture(new Rect(0f, val.y - 65f, (float)Screen.width, 145f), (Texture)(object)blackTex);
if ((Object)(object)whiteTex != (Object)null)
{
GUI.color = new Color(1f, 0.85f, 0.25f, 0.7f * bannerProgress);
GUI.DrawTexture(new Rect(0f, val.y - 65f, (float)Screen.width, 2.5f), (Texture)(object)whiteTex);
GUI.DrawTexture(new Rect(0f, val.y + 80f, (float)Screen.width, 2.5f), (Texture)(object)whiteTex);
}
GUI.color = color4;
}
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(0f, val.y - 60f, (float)Screen.width, 90f);
victoryStyle.normal.textColor = new Color(0.05f, 0.05f, 0.05f, 0.9f * bannerProgress);
GUI.Label(new Rect(((Rect)(ref val2)).x + 3f, ((Rect)(ref val2)).y + 4f, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), "VICTORY!", victoryStyle);
victoryStyle.normal.textColor = new Color(1f, 0.9f, 0.2f, bannerProgress);
GUI.Label(val2, "VICTORY!", victoryStyle);
Rect val3 = new Rect(0f, val.y + 35f, (float)Screen.width, 35f);
subTextStyle.normal.textColor = new Color(1f, 1f, 1f, 0.85f * bannerProgress);
GUI.Label(val3, "★ MATCH CHAMPION ★", subTextStyle);
GUI.matrix = matrix2;
}
else if (currentKOType == KOType.RoundWin)
{
float num3 = Mathf.Lerp((float)Screen.height * 0.38f - 40f, (float)Screen.height * 0.38f, bannerProgress);
Rect val4 = default(Rect);
((Rect)(ref val4))..ctor(0f, num3, (float)Screen.width, 60f);
if ((Object)(object)whiteTex != (Object)null)
{
Color color5 = GUI.color;
GUI.color = new Color(flashColor.r, flashColor.g, flashColor.b, 0.28f * bannerProgress);
GUI.DrawTexture(new Rect(0f, num3 + 5f, (float)Screen.width, 50f), (Texture)(object)whiteTex);
GUI.color = color5;
}
roundStyle.normal.textColor = new Color(0f, 0f, 0f, 0.85f * bannerProgress);
GUI.Label(new Rect(((Rect)(ref val4)).x + 2f, ((Rect)(ref val4)).y + 3f, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), "ROUND WON", roundStyle);
roundStyle.normal.textColor = new Color(1f, 1f, 1f, bannerProgress);
GUI.Label(val4, "ROUND WON", roundStyle);
Rect val5 = new Rect(0f, num3 + 45f, (float)Screen.width, 25f);
subTextStyle.normal.textColor = new Color(1f, 0.85f, 0.3f, 0.8f * bannerProgress);
GUI.Label(val5, "CARD SELECTION NEXT", subTextStyle);
}
}
private void InitStyles()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
if (victoryStyle == null)
{
victoryStyle = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)4,
fontSize = Mathf.Clamp(Screen.height / 11, 48, 76),
fontStyle = (FontStyle)1
};
}
if (subTextStyle == null)
{
subTextStyle = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)4,
fontSize = Mathf.Clamp(Screen.height / 38, 16, 26),
fontStyle = (FontStyle)1
};
}
if (roundStyle == null)
{
roundStyle = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)4,
fontSize = Mathf.Clamp(Screen.height / 18, 32, 48),
fontStyle = (FontStyle)1
};
}
}
private static AudioClip CreateWarmSubBass(float startFreq, float endFreq, float duration, bool addHarmonicShimmer)
{
int num = 44100;
int num2 = (int)((float)num * duration);
float[] array = new float[num2];
float num3 = 0f;
float num4 = 0f;
int num5 = (int)((float)num * 0.025f);
for (int i = 0; i < num2; i++)
{
float num6 = (float)i / (float)num2;
float num7 = Mathf.Lerp(startFreq, endFreq, Mathf.Pow(num6, 0.45f));
num3 += MathF.PI * 2f * num7 / (float)num;
float num8 = ((i < num5) ? ((1f - Mathf.Cos(MathF.PI * (float)i / (float)num5)) * 0.5f) : 1f);
float num9 = Mathf.Exp((0f - num6) * 3.8f);
float num10 = num8 * num9;
float num11 = Mathf.Sin(num3);
if (addHarmonicShimmer)
{
num4 += MathF.PI * 440f / (float)num;
float num12 = Mathf.Clamp01(1f - num6) * Mathf.Sin(num6 * MathF.PI);
num11 += Mathf.Sin(num4) * 0.18f * num12;
}
array[i] = num11 * num10 * 0.85f;
}
AudioClip obj = AudioClip.Create($"KO_WarmSub_{duration}", num2, 1, num, false);
obj.SetData(array, 0);
return obj;
}
private void OnDestroy()
{
if ((Object)(object)whiteTex != (Object)null)
{
Object.Destroy((Object)(object)whiteTex);
}
if ((Object)(object)blackTex != (Object)null)
{
Object.Destroy((Object)(object)blackTex);
}
if ((Object)(object)pointSubBassClip != (Object)null)
{
Object.Destroy((Object)(object)pointSubBassClip);
}
if ((Object)(object)roundSubBassClip != (Object)null)
{
Object.Destroy((Object)(object)roundSubBassClip);
}
if ((Object)(object)victorySubBassClip != (Object)null)
{
Object.Destroy((Object)(object)victorySubBassClip);
}
}
}
[BepInPlugin("000_rounds_cinematicko", "RoundsCinematicKO", "1.0.3")]
[BepInProcess("Rounds.exe")]
public class RoundsCinematicKOPlugin : BaseUnityPlugin
{
public const string ModId = "000_rounds_cinematicko";
public const string ModName = "RoundsCinematicKO";
public const string ModVersion = "1.0.3";
public static ConfigEntry<bool> EnableCinematicKO;
public static ConfigEntry<bool> EnableSlowMotion;
public static ConfigEntry<float> SlowMotionDuration;
public static ConfigEntry<bool> EnableCameraZoom;
public static ConfigEntry<float> TargetZoomSize;
public static ConfigEntry<bool> EnableImpactFlash;
public static ConfigEntry<bool> EnableLetterbox;
public static ConfigEntry<bool> EnableSubBassSFX;
public static ConfigEntry<float> SFXVolume;
public static RoundsCinematicKOPlugin Instance { get; private set; }
public static ManualLogSource Logger { get; private set; }
public static Harmony HarmonyInstance { get; private set; }
private void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
InitConfig();
GameObject val = new GameObject("RoundsCinematicKO_Controller");
val.AddComponent<CinematicKOController>();
Object.DontDestroyOnLoad((Object)val);
try
{
HarmonyInstance = new Harmony("000_rounds_cinematicko");
HarmonyInstance.PatchAll();
try
{
Type type = AccessTools.TypeByName("RWF.GameModes.RWFGameMode");
if (type != null)
{
MethodInfo methodInfo = AccessTools.Method(type, "ResetMatch", (Type[])null, (Type[])null);
if (methodInfo != null)
{
HarmonyMethod val2 = new HarmonyMethod(typeof(DeathPatches), "ResetMatch_Postfix", (Type[])null);
HarmonyInstance.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
}
catch
{
}
Logger.LogInfo((object)"[RoundsCinematicKO] v1.0.3 initialized successfully with cinematic finisher pipeline.");
}
catch (Exception arg)
{
Logger.LogError((object)string.Format("[{0}] Failed to apply Harmony patches: {1}", "RoundsCinematicKO", arg));
}
}
private void InitConfig()
{
EnableCinematicKO = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableCinematicKO", true, "Master toggle for cinematic round-ending KO effects.");
EnableSlowMotion = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects", "EnableSlowMotion", true, "Enables dramatic bullet-time slow motion on fatal hit.");
SlowMotionDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Effects", "SlowMotionDuration", 0.85f, "Duration in real-time seconds of the slow motion sequence.");
EnableCameraZoom = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects", "EnableCameraZoom", true, "Enables dynamic camera zoom-in onto the dying player.");
TargetZoomSize = ((BaseUnityPlugin)this).Config.Bind<float>("Effects", "TargetZoomSize", 9.5f, "Camera orthographic size when zoomed in (smaller = closer).");
EnableImpactFlash = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects", "EnableImpactFlash", true, "Enables color-coded impact flash overlay.");
EnableLetterbox = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects", "EnableLetterbox", true, "Enables cinematic black letterbox bars at top/bottom.");
EnableSubBassSFX = ((BaseUnityPlugin)this).Config.Bind<bool>("Audio", "EnableSubBassSFX", true, "Enables soft warm procedural sub-bass impact sound.");
SFXVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "SFXVolume", 0.35f, "Volume of the sub-bass impact sound (0.0 to 1.0, recommended 0.25 - 0.45).");
}
}
}
namespace RoundsCinematicKO.Patches
{
[HarmonyPatch]
public static class DeathPatches
{
private static bool isFinalKillOfRound = false;
private static Color winningTeamColor = Color.white;
private static KOType currentKOType = KOType.PointWin;
private static Transform winningPlayerTransform = null;
private static readonly FieldInfo f_pointsToWin = typeof(GM_ArmsRace).GetField("pointsToWinRound", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo f_roundsToWin = typeof(GM_ArmsRace).GetField("roundsToWinGame", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
[HarmonyPatch(typeof(HealthHandler), "RPCA_Die")]
[HarmonyPrefix]
public static void RPCA_Die_Prefix(HealthHandler __instance, Vector2 deathDirection)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
isFinalKillOfRound = false;
winningTeamColor = Color.white;
currentKOType = KOType.PointWin;
winningPlayerTransform = null;
try
{
if ((Object)(object)__instance == (Object)null)
{
return;
}
Player component = ((Component)__instance).GetComponent<Player>();
if ((Object)(object)component == (Object)null || (Object)(object)component.data == (Object)null || !component.data.isPlaying || component.data.dead || (Object)(object)GameManager.instance == (Object)null || !GameManager.instance.battleOngoing || (Object)(object)PlayerManager.instance == (Object)null || PlayerManager.instance.players == null)
{
return;
}
HashSet<int> hashSet = new HashSet<int>();
Player val = null;
for (int i = 0; i < PlayerManager.instance.players.Count; i++)
{
Player val2 = PlayerManager.instance.players[i];
if ((Object)(object)val2 != (Object)null && (Object)(object)val2.data != (Object)null && !val2.data.dead && val2.data.isPlaying && (Object)(object)val2 != (Object)(object)component)
{
hashSet.Add(val2.teamID);
val = val2;
}
}
if (hashSet.Count >= 2)
{
return;
}
isFinalKillOfRound = true;
if (hashSet.Count == 1)
{
int num = hashSet.First();
Player[] playersInTeam = PlayerManager.instance.GetPlayersInTeam(num);
if (playersInTeam != null && playersInTeam.Length != 0 && (Object)(object)playersInTeam[0] != (Object)null)
{
winningTeamColor = PlayerSkinBank.GetPlayerSkinColors(playersInTeam[0].playerID).color;
winningPlayerTransform = ((Component)playersInTeam[0]).transform;
}
else if ((Object)(object)val != (Object)null)
{
winningTeamColor = PlayerSkinBank.GetPlayerSkinColors(val.playerID).color;
winningPlayerTransform = ((Component)val).transform;
}
currentKOType = DetermineKOType(num);
}
}
catch (Exception ex)
{
Debug.LogWarning("[RoundsCinematicKO] Error checking final kill in RPCA_Die prefix: " + ex.Message);
}
}
public static KOType DetermineKOType(int winTeam)
{
try
{
int num = -1;
int num2 = -1;
int num3 = 2;
int num4 = 5;
bool flag = false;
try
{
Type type = AccessTools.TypeByName("UnboundLib.GameModes.GameModeManager");
if (type != null)
{
object obj = type.GetProperty("CurrentHandler", BindingFlags.Static | BindingFlags.Public)?.GetValue(null);
if (obj != null)
{
MethodInfo method = obj.GetType().GetMethod("GetTeamScore", new Type[1] { typeof(int) });
if (method != null)
{
object obj2 = method.Invoke(obj, new object[1] { winTeam });
if (obj2 != null)
{
FieldInfo field = obj2.GetType().GetField("points");
FieldInfo field2 = obj2.GetType().GetField("rounds");
if (field != null && field2 != null)
{
num = (int)field.GetValue(obj2);
num2 = (int)field2.GetValue(obj2);
flag = true;
}
}
}
object obj3 = obj.GetType().GetProperty("Settings")?.GetValue(obj);
if (obj3 != null)
{
MethodInfo method2 = obj3.GetType().GetMethod("get_Item", new Type[1] { typeof(string) });
if (method2 != null)
{
try
{
num3 = Convert.ToInt32(method2.Invoke(obj3, new object[1] { "pointsToWinRound" }));
}
catch
{
}
try
{
num4 = Convert.ToInt32(method2.Invoke(obj3, new object[1] { "roundsToWinGame" }));
}
catch
{
}
}
}
}
}
}
catch
{
}
if (!flag)
{
try
{
Type type2 = AccessTools.TypeByName("RWF.GameModes.RWFGameMode");
if (type2 != null)
{
object obj7 = type2.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) ?? Object.FindObjectOfType(type2);
if (obj7 != null)
{
FieldInfo? field3 = type2.GetField("teamPoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
FieldInfo field4 = type2.GetField("teamRounds", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
Dictionary<int, int> dictionary = field3?.GetValue(obj7) as Dictionary<int, int>;
Dictionary<int, int> dictionary2 = field4?.GetValue(obj7) as Dictionary<int, int>;
if (dictionary != null && dictionary.TryGetValue(winTeam, out var value))
{
num = value;
flag = true;
}
if (dictionary2 != null && dictionary2.TryGetValue(winTeam, out var value2))
{
num2 = value2;
}
}
}
}
catch
{
}
}
if (!flag)
{
try
{
GM_ArmsRace val = Object.FindObjectOfType<GM_ArmsRace>();
if ((Object)(object)val != (Object)null)
{
num = ((winTeam == 0) ? val.p1Points : val.p2Points);
num2 = ((winTeam == 0) ? val.p1Rounds : val.p2Rounds);
num3 = ((f_pointsToWin != null) ? ((int)f_pointsToWin.GetValue(val)) : 2);
num4 = ((f_roundsToWin != null) ? ((int)f_roundsToWin.GetValue(val)) : 5);
flag = true;
}
}
catch
{
}
}
if (flag && num >= 0)
{
if (num + 1 >= num3)
{
if (num2 >= 0 && num2 + 1 >= num4)
{
return KOType.MatchVictory;
}
return KOType.RoundWin;
}
return KOType.PointWin;
}
return KOType.PointWin;
}
catch
{
return KOType.PointWin;
}
}
[HarmonyPatch(typeof(HealthHandler), "RPCA_Die")]
[HarmonyPostfix]
public static void RPCA_Die_Postfix(HealthHandler __instance, Vector2 deathDirection)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
try
{
if (isFinalKillOfRound && (Object)(object)CinematicKOController.Instance != (Object)null && (Object)(object)__instance != (Object)null)
{
CinematicKOController.Instance.TriggerKO(((Component)__instance).transform.position, deathDirection, winningTeamColor, currentKOType, winningPlayerTransform);
}
}
catch (Exception ex)
{
Debug.LogWarning("[RoundsCinematicKO] Error triggering cinematic in RPCA_Die postfix: " + ex.Message);
}
finally
{
isFinalKillOfRound = false;
}
}
[HarmonyPatch(typeof(UIHandler), "DisplayScreenText", new Type[]
{
typeof(Color),
typeof(string),
typeof(float)
})]
[HarmonyPrefix]
public static void DisplayScreenText_Prefix(Color color, string text, float speed)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
CheckScreenText(text, color);
}
[HarmonyPatch(typeof(UIHandler), "DisplayScreenTextLoop", new Type[]
{
typeof(Color),
typeof(string)
})]
[HarmonyPrefix]
public static void DisplayScreenTextLoop_Color_Prefix(Color color, string text)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
CheckScreenText(text, color);
}
[HarmonyPatch(typeof(UIHandler), "DisplayScreenTextLoop", new Type[] { typeof(string) })]
[HarmonyPrefix]
public static void DisplayScreenTextLoop_Prefix(string text)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
CheckScreenText(text, Color.white);
}
[HarmonyPatch(typeof(UIHandler), "StopScreenTextLoop")]
[HarmonyPostfix]
public static void StopScreenTextLoop_Postfix()
{
try
{
CinematicKOController.Instance?.CancelCinematic();
}
catch
{
}
}
private static void CheckScreenText(string text, Color color)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
try
{
if (!string.IsNullOrEmpty(text))
{
string text2 = text.ToUpper();
if (text2.Contains("VICTORY"))
{
Transform winner = FindWinnerTransform();
CinematicKOController.Instance?.TriggerVictoryScreen(color, winner);
}
else if (text2.Contains("REMATCH"))
{
CinematicKOController.Instance?.CancelCinematic();
}
}
}
catch (Exception ex)
{
Debug.LogWarning("[RoundsCinematicKO] Error in CheckScreenText: " + ex.Message);
}
}
private static Transform FindWinnerTransform()
{
try
{
if ((Object)(object)winningPlayerTransform != (Object)null)
{
return winningPlayerTransform;
}
if ((Object)(object)PlayerManager.instance != (Object)null && PlayerManager.instance.players != null)
{
Player val = ((IEnumerable<Player>)PlayerManager.instance.players).FirstOrDefault((Func<Player, bool>)((Player p) => (Object)(object)p != (Object)null && (Object)(object)p.data != (Object)null && !p.data.dead));
if ((Object)(object)val != (Object)null)
{
return ((Component)val).transform;
}
Player val2 = ((IEnumerable<Player>)PlayerManager.instance.players).FirstOrDefault((Func<Player, bool>)((Player p) => (Object)(object)p != (Object)null));
if ((Object)(object)val2 != (Object)null)
{
return ((Component)val2).transform;
}
}
}
catch
{
}
return null;
}
[HarmonyPatch(typeof(GM_ArmsRace), "ResetMatch")]
[HarmonyPostfix]
public static void ResetMatch_Postfix()
{
try
{
CinematicKOController.Instance?.CancelCinematic();
}
catch
{
}
}
}
}