using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BRC_Football_Local")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BRC_Football_Local")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("786896a2-6046-4ce4-b885-6e1e2798b43a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
public enum GoalTeam
{
Red,
Blue
}
[BepInPlugin("com.chimp.brcfootball.fixed", "BRC Football", "3.1.1")]
public class BRC_Football : BaseUnityPlugin
{
private class GoalUI
{
public GameObject root;
public Image bg;
public TextMeshProUGUI text;
public GoalTriggerWatcher watcher;
public Coroutine flashRoutine;
}
[CompilerGenerated]
private sealed class <FlashGoal>d__34 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public GoalUI ui;
public GoalTeam team;
public BRC_Football <>4__this;
private Color <target>5__1;
private Color <original>5__2;
private float <t>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FlashGoal>d__34(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_003f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<target>5__1 = ((team == GoalTeam.Red) ? <>4__this.redColor : <>4__this.blueColor);
<target>5__1.a = 0.8f;
<original>5__2 = new Color(0f, 0f, 0f, 0.6f);
<t>5__3 = 0f;
break;
case 1:
<>1__state = -1;
break;
}
if (<t>5__3 < <>4__this.flashDuration)
{
<t>5__3 += Time.deltaTime;
((Graphic)ui.bg).color = Color.Lerp(<target>5__1, <original>5__2, <t>5__3 / <>4__this.flashDuration);
<>2__current = null;
<>1__state = 1;
return true;
}
((Graphic)ui.bg).color = <original>5__2;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <Init>d__27 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public BRC_Football <>4__this;
private GameObject <resp>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Init>d__27(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<resp>5__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"[BRC-Football] Initializing football...");
break;
case 1:
<>1__state = -1;
break;
}
if ((Object)(object)ball == (Object)null)
{
ball = GameObject.Find("Football") ?? GameObject.Find("Football(Clone)");
<>2__current = null;
<>1__state = 1;
return true;
}
<resp>5__1 = GameObject.Find("BallRespawn");
<>4__this.respawn = (((Object)(object)<resp>5__1 != (Object)null) ? <resp>5__1.transform : ball.transform);
ballRb = ball.GetComponent<Rigidbody>() ?? ball.AddComponent<Rigidbody>();
ballRb.mass = 0.7f;
ballRb.useGravity = true;
ballRb.collisionDetectionMode = (CollisionDetectionMode)2;
ballRb.interpolation = (RigidbodyInterpolation)1;
ball.transform.position = <>4__this.respawn.position + Vector3.up * 2f;
Physics.SyncTransforms();
<>4__this.CreateGoals();
<>4__this.CreateResetUI();
((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"[BRC-Football] Football ready");
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <ResetBall>d__30 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public BRC_Football <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ResetBall>d__30(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>4__this.resetting = true;
ballRb.isKinematic = true;
ballRb.detectCollisions = false;
ball.transform.position = <>4__this.respawn.position + Vector3.up * 2f;
ballRb.velocity = Vector3.zero;
ballRb.angularVelocity = Vector3.zero;
<>2__current = null;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
Physics.SyncTransforms();
<>2__current = (object)new WaitForSeconds(0.25f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
ballRb.isKinematic = false;
ballRb.detectCollisions = true;
<>4__this.resetting = false;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <SceneDetectRoutine>d__25 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public BRC_Football <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SceneDetectRoutine>d__25(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
ball = GameObject.Find("Football") ?? GameObject.Find("Football(Clone)");
<>4__this.isActiveScene = <>4__this.enableMod.Value && (Object)(object)ball != (Object)null;
if (!<>4__this.isActiveScene)
{
((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"[BRC-Football] Not football scene");
return false;
}
<>4__this.initRoutine = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.Init());
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private const string LOG = "[BRC-Football]";
private bool isActiveScene = false;
private Coroutine initRoutine;
public static GameObject ball;
public static Rigidbody ballRb;
public Transform respawn;
private int redScore = 0;
private int blueScore = 0;
private bool resetting;
private ConfigEntry<KeyCode> resetKey;
private ConfigEntry<bool> enableMod;
public float uiScale = 0.01f;
public Vector2 uiSize = new Vector2(200f, 50f);
public float uiHeight = 2.5f;
public Color redColor = Color.red;
public Color blueColor = Color.blue;
public float flashDuration = 0.5f;
private Dictionary<GoalTriggerWatcher, GoalUI> goalUIs = new Dictionary<GoalTriggerWatcher, GoalUI>();
private GameObject resetUIRoot;
private TextMeshProUGUI resetUIText;
private Transform resetAnchor;
private void Awake()
{
resetKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keybinds", "ResetBall", (KeyCode)98, "Reset ball key");
enableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableFootball", true, (ConfigDescription)null);
SceneManager.sceneLoaded += OnSceneLoaded;
((BaseUnityPlugin)this).Logger.LogInfo((object)"[BRC-Football] Loaded");
}
private void OnDestroy()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
Cleanup();
}
private void OnSceneLoaded(Scene s, LoadSceneMode m)
{
Cleanup();
((MonoBehaviour)this).StartCoroutine(SceneDetectRoutine());
}
[IteratorStateMachine(typeof(<SceneDetectRoutine>d__25))]
private IEnumerator SceneDetectRoutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SceneDetectRoutine>d__25(0)
{
<>4__this = this
};
}
private void Cleanup()
{
((MonoBehaviour)this).StopAllCoroutines();
if ((Object)(object)ballRb != (Object)null)
{
Object.Destroy((Object)(object)ballRb);
}
ballRb = null;
ball = null;
resetting = false;
foreach (KeyValuePair<GoalTriggerWatcher, GoalUI> goalUI in goalUIs)
{
if ((Object)(object)goalUI.Value?.root != (Object)null)
{
Object.Destroy((Object)(object)goalUI.Value.root);
}
}
goalUIs.Clear();
if ((Object)(object)resetUIRoot != (Object)null)
{
Object.Destroy((Object)(object)resetUIRoot);
}
resetUIRoot = null;
}
[IteratorStateMachine(typeof(<Init>d__27))]
private IEnumerator Init()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Init>d__27(0)
{
<>4__this = this
};
}
private void Update()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
if (isActiveScene && !((Object)(object)ball == (Object)null) && Input.GetKeyDown(resetKey.Value) && !resetting)
{
((MonoBehaviour)this).StartCoroutine(ResetBall());
}
}
private void LateUpdate()
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
if (!isActiveScene)
{
return;
}
Camera main = Camera.main;
if ((Object)(object)main == (Object)null)
{
return;
}
foreach (KeyValuePair<GoalTriggerWatcher, GoalUI> goalUI in goalUIs)
{
GoalUI value = goalUI.Value;
if (value != null && !((Object)(object)value.root == (Object)null))
{
value.root.transform.position = ((Component)value.watcher).transform.position + Vector3.up * uiHeight;
FaceCamera(value.root, main);
}
}
if ((Object)(object)resetUIRoot != (Object)null)
{
FaceCamera(resetUIRoot, main);
}
}
[IteratorStateMachine(typeof(<ResetBall>d__30))]
private IEnumerator ResetBall()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ResetBall>d__30(0)
{
<>4__this = this
};
}
private void CreateGoals()
{
Transform[] array = Object.FindObjectsOfType<Transform>(true);
Transform[] array2 = array;
foreach (Transform val in array2)
{
if (((Object)val).name.Contains("GoalTrigger"))
{
GoalTriggerWatcher goalTriggerWatcher = ((Component)val).GetComponent<GoalTriggerWatcher>() ?? ((Component)val).gameObject.AddComponent<GoalTriggerWatcher>();
if (((Object)val).name.ToLower().Contains("red"))
{
goalTriggerWatcher.team = GoalTeam.Red;
}
if (((Object)val).name.ToLower().Contains("blue"))
{
goalTriggerWatcher.team = GoalTeam.Blue;
}
goalTriggerWatcher.OnGoal = (Action<GoalTeam>)Delegate.Combine(goalTriggerWatcher.OnGoal, new Action<GoalTeam>(OnGoal));
GoalUI value = CreateGoalUI(goalTriggerWatcher);
goalUIs[goalTriggerWatcher] = value;
}
}
}
private GoalUI CreateGoalUI(GoalTriggerWatcher w)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_001d: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Expected O, but got Unknown
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("GoalUI_" + ((Object)w).name);
val.transform.localScale = Vector3.one * uiScale;
Canvas val2 = val.AddComponent<Canvas>();
val2.renderMode = (RenderMode)2;
val2.worldCamera = Camera.main;
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = uiSize;
GameObject val3 = new GameObject("BG");
val3.transform.SetParent(val.transform, false);
Image val4 = val3.AddComponent<Image>();
((Graphic)val4).color = new Color(0f, 0f, 0f, 0.6f);
val3.GetComponent<RectTransform>().sizeDelta = uiSize;
GameObject val5 = new GameObject("Text");
val5.transform.SetParent(val.transform, false);
TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
((TMP_Text)val6).alignment = (TextAlignmentOptions)514;
((TMP_Text)val6).fontSize = 26f;
((Graphic)val6).color = Color.white;
((TMP_Text)val6).text = ((w.team == GoalTeam.Red) ? "Red: 0" : "Blue: 0");
val5.GetComponent<RectTransform>().sizeDelta = uiSize;
return new GoalUI
{
root = val,
bg = val4,
text = val6,
watcher = w
};
}
private void OnGoal(GoalTeam team)
{
if (team == GoalTeam.Red)
{
redScore++;
}
else
{
blueScore++;
}
foreach (KeyValuePair<GoalTriggerWatcher, GoalUI> goalUI in goalUIs)
{
((TMP_Text)goalUI.Value.text).text = ((goalUI.Key.team == GoalTeam.Red) ? $"Red: {redScore}" : $"Blue: {blueScore}");
}
foreach (KeyValuePair<GoalTriggerWatcher, GoalUI> goalUI2 in goalUIs)
{
if (goalUI2.Key.team == team)
{
if (goalUI2.Value.flashRoutine != null)
{
((MonoBehaviour)this).StopCoroutine(goalUI2.Value.flashRoutine);
}
goalUI2.Value.flashRoutine = ((MonoBehaviour)this).StartCoroutine(FlashGoal(goalUI2.Value, team));
}
}
((MonoBehaviour)this).StartCoroutine(ResetBall());
}
[IteratorStateMachine(typeof(<FlashGoal>d__34))]
private IEnumerator FlashGoal(GoalUI ui, GoalTeam team)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FlashGoal>d__34(0)
{
<>4__this = this,
ui = ui,
team = team
};
}
private void FaceCamera(GameObject obj, Camera cam)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)cam == (Object)null) && !((Object)(object)obj == (Object)null))
{
Vector3 val = ((Component)cam).transform.position - obj.transform.position;
obj.transform.rotation = Quaternion.LookRotation(val);
obj.transform.Rotate(0f, 180f, 0f);
}
}
private void CreateResetUI()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Expected O, but got Unknown
//IL_012b: 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)
GameObject val = GameObject.Find("ResetUI");
if ((Object)(object)val == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"[BRC-Football] ResetUI anchor not found in scene!");
return;
}
resetAnchor = val.transform;
resetUIRoot = new GameObject("ResetUI_Label");
resetUIRoot.transform.SetParent(resetAnchor, false);
resetUIRoot.transform.localScale = Vector3.one * uiScale;
resetUIRoot.transform.localPosition = Vector3.zero;
Canvas val2 = resetUIRoot.AddComponent<Canvas>();
val2.renderMode = (RenderMode)2;
val2.worldCamera = Camera.main;
RectTransform component = resetUIRoot.GetComponent<RectTransform>();
component.sizeDelta = uiSize;
GameObject val3 = new GameObject("Text");
val3.transform.SetParent(resetUIRoot.transform, false);
resetUIText = val3.AddComponent<TextMeshProUGUI>();
((TMP_Text)resetUIText).text = "Press B - Reset Ball";
((TMP_Text)resetUIText).fontSize = 22f;
((Graphic)resetUIText).color = Color.yellow;
((TMP_Text)resetUIText).alignment = (TextAlignmentOptions)514;
val3.GetComponent<RectTransform>().sizeDelta = uiSize;
}
}
public class GoalTriggerWatcher : MonoBehaviour
{
public GoalTeam team;
public Action<GoalTeam> OnGoal;
private void OnTriggerEnter(Collider other)
{
if (((Object)other).name.Contains("Football"))
{
OnGoal?.Invoke(team);
}
}
}