Decompiled source of LTOWVisibleTimersMod v1.2.1

LTOWVisibleTimersMod.dll

Decompiled a month ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[CreateAssetMenu(menuName = "LTOWVisibleTimersMod/TimerConfigDefaults")]
public class TimerConfigDefaults : ScriptableObject
{
	[Tooltip("The name of the timer to be used in the ConfigFile as this timer's category.")]
	public string timerName;

	[Space]
	[Tooltip("Enables a visible timer on this object.\nWill destroy the timer on Start() if set to false.")]
	public bool timerEnabled = true;

	[Tooltip("Set how the timer will be visualized.")]
	public TimerType timerType;

	[Tooltip("Set which teams can see this timer.")]
	public VisibilityType visibilityType;

	[Tooltip("Set the color of the timer at its beginning.\nx = Red.\ny = Green.\nz = Blue.\nw = Opacity.")]
	public Vector4 timerColorPrimary = new Vector4(1f, 1f, 1f, 1f);

	[Tooltip("Set the color of the timer at its end.\nx = Red.\ny = Green.\nz = Blue.\nw = Opacity.")]
	public Vector4 timerColorSecondary = new Vector4(0f, 0f, 0f, 0.5f);

	[Tooltip("Set how large the timer will be.")]
	public Vector3 timerObjectSize = new Vector3(1f, 1f, 1f);

	[Tooltip("Set how high above the object the timer will be displayed.")]
	public float timerVerticalOffset = 1f;

	[Tooltip("Show an arrow pointing from the timer to the object.")]
	public bool timerShowsArrow = true;

	[Tooltip("If [Timer Type] is set to Text, set how many decimals are behind the comma.")]
	[Range(0f, 4f)]
	public int timerTextDecimals = 2;

	[Tooltip("If [Timer Type] is set to Text, set whether time will be displayed in Minutes:Seconds or only in seconds.")]
	public bool timerTextMinutes = true;

	[Tooltip("If [Timer Type] is set to Bar, set how opaque the background of the visible timer is.\n0 = Invisible.\n100 = Fully visible.")]
	[Range(0f, 100f)]
	public int timerBackgroundOpacity = 25;

	[Tooltip("If [Starting Color Timer] and [Ending Color Timer] are different values, set how often the color should update, in seconds.\nHigher values look less fluid but could result in better performance.")]
	public float timerRecoloringInterval = 1f;

	[Tooltip("Set per how many frames the timer should read out its in-game values.\nSetting this to 1 checks every frame. Higher values look less fluid but could result in better performance.")]
	[Range(0f, 60f)]
	public int timerRefreshRate = 1;

	[Space]
	[Tooltip("Set to true manually to use these in-editor values.\nIf left false, this will automatically be set to true in code when generating this timer's default values.")]
	public bool hasDefaultValues;
}
public class TimerHUDComponents : MonoBehaviour
{
	private static ManualLogSource Logger;

	public TextMeshProUGUI textContainer;

	public Image arrowImage;

	public Transform arrowOffset;

	public Image circleFillImage;

	public Image circleBorderImage;

	public Image barFillImage;

	public Image barBackerImage;

	public void GetTimerHUDComponents(VisibleTimerBase timerScript)
	{
		if ((Object)(object)timerScript == (Object)null)
		{
			Logger.LogError((object)"failed to find timerScript!");
			return;
		}
		timerScript.textContainer = textContainer;
		timerScript.arrowImage = arrowImage;
		timerScript.circleFillImage = circleFillImage;
		timerScript.circleBorderImage = circleBorderImage;
		timerScript.barFillImage = barFillImage;
		timerScript.barBackerImage = barBackerImage;
	}
}
public class TimersManager : MonoBehaviour
{
	private static ManualLogSource Logger;

	public static TimersManager Singleton;

	public List<VisibleTimerBase> allTimers;

	[Space]
	public Transform aboveGroundCanvas;

	public Transform underGroundCanvas;

	private void Awake()
	{
		if (Object.op_Implicit((Object)(object)Singleton))
		{
			Object.Destroy((Object)(object)this);
		}
		else
		{
			Singleton = this;
		}
		allTimers = new List<VisibleTimerBase>();
	}

	public void AddTimer(VisibleTimerBase timerToAdd)
	{
		if (!allTimers.Contains(timerToAdd))
		{
			allTimers.Add(timerToAdd);
		}
	}

	public void RemoveTimer(VisibleTimerBase timerToRemove)
	{
		if (allTimers.Contains(timerToRemove))
		{
			allTimers.Remove(timerToRemove);
		}
	}
}
public enum TimerType
{
	Text,
	Circle,
	Bar
}
public enum VisibilityType
{
	Everyone,
	PardnersOnly,
	WormsOnly
}
internal class VTAssetsCollection
{
	public static GameObject managerPrefab;

	public static GameObject timerHUDPrefab;

	public static GameObject dynamiteVisibleTimer;

	public static GameObject tumbleweedVisibleTimer;

	public static GameObject sunVisibleTimer;

	public static GameObject staminaVisibleTimer;

	public static GameObject leverVisibleTimer;

	public static GameObject icespikeVisibleTimer;

	public static GameObject eggVisibleTimer;

	public static GameObject coffeeVisibleTimer;

	public static GameObject bomberVisibleTimer;

	public static GameObject sinkholeVisibleTimer;

	public static GameObject blindnessVisibleTimer;

	public static string dynamiteCategoryName = "Dynamite";

	public static string tumbleweedCategoryName = "Tumbleweed";

	public static string sunCategoryName = "Sun";

	public static string staminaCategoryName = "Infinite Stamina";

	public static string leverCategoryName = "Train Lever";

	public static string icespikeCategoryName = "Ice Spike";

	public static string eggCategoryName = "Wormling Egg";

	public static string coffeeCategoryName = "Coffee";

	public static string bomberCategoryName = "Bomber";

	public static string sinkholeCategoryName = "Sinkhole";

	public static string blindnessCategoryName = "Disoriented Worms";

	public static string wormEffectHandlerName = "LTOWVisibleTimersMod - WormStatusEffectsHandler";

	public static Material materialUI;

	public static TMP_FontAsset turncoatFont;

	public static Sprite arrowSprite;

	public static Sprite gripFullSprite;

	public static Sprite gripBorderSprite;

	public static Sprite sprintHealthSprite;

	public static void GetAssetsAssetBundle(AssetBundle __instance)
	{
		managerPrefab = __instance.LoadAsset<GameObject>("Assets/LTOWVisibleTimersMod/Prefabs/LTOWVisibleTimersMod.prefab");
		timerHUDPrefab = __instance.LoadAsset<GameObject>("Assets/LTOWVisibleTimersMod/Prefabs/TimerHUDComponents.prefab");
		dynamiteVisibleTimer = __instance.LoadAsset<GameObject>("Assets/LTOWVisibleTimersMod/Prefabs/VisibleTimerBase/DynamiteTimerPrefab.prefab");
		tumbleweedVisibleTimer = __instance.LoadAsset<GameObject>("Assets/LTOWVisibleTimersMod/Prefabs/VisibleTimerBase/TumbleweedTimerPrefab.prefab");
		sunVisibleTimer = __instance.LoadAsset<GameObject>("Assets/LTOWVisibleTimersMod/Prefabs/VisibleTimerBase/SunTimerPrefab.prefab");
		staminaVisibleTimer = __instance.LoadAsset<GameObject>("Assets/LTOWVisibleTimersMod/Prefabs/VisibleTimerBase/StaminaTimerPrefab.prefab");
		leverVisibleTimer = __instance.LoadAsset<GameObject>("Assets/LTOWVisibleTimersMod/Prefabs/VisibleTimerBase/LeverTimerPrefab.prefab");
		icespikeVisibleTimer = __instance.LoadAsset<GameObject>("Assets/LTOWVisibleTimersMod/Prefabs/VisibleTimerBase/IcespikeTimerPrefab.prefab");
		eggVisibleTimer = __instance.LoadAsset<GameObject>("Assets/LTOWVisibleTimersMod/Prefabs/VisibleTimerBase/EggTimerPrefab.prefab");
		coffeeVisibleTimer = __instance.LoadAsset<GameObject>("Assets/LTOWVisibleTimersMod/Prefabs/VisibleTimerBase/CoffeeTimerPrefab.prefab");
		bomberVisibleTimer = __instance.LoadAsset<GameObject>("Assets/LTOWVisibleTimersMod/Prefabs/VisibleTimerBase/BomberTimerPrefab.prefab");
		sinkholeVisibleTimer = __instance.LoadAsset<GameObject>("Assets/LTOWVisibleTimersMod/Prefabs/VisibleTimerBase/SinkholeTimerPrefab.prefab");
		blindnessVisibleTimer = __instance.LoadAsset<GameObject>("Assets/LTOWVisibleTimersMod/Prefabs/VisibleTimerBase/BlindnessTimerPrefab.prefab");
	}

	public static void GetAssetsHudManager(HudManager __instance)
	{
		Image component = ((Component)__instance.pickupPopUp_Object.transform.Find("Arrow Image")).GetComponent<Image>();
		materialUI = ((Graphic)component).material;
		arrowSprite = component.sprite;
		gripFullSprite = __instance.gripMeter_Fill.sprite;
		gripBorderSprite = ((Component)((Component)__instance.gripMeter_Fill).transform.parent).GetComponent<Image>().sprite;
		sprintHealthSprite = __instance.sprintBarParent.GetComponent<Image>().sprite;
		turncoatFont = __instance.heldObjectHintText.font;
	}
}
public class VTComponentContainer : MonoBehaviour
{
	private static ManualLogSource Logger;

	public MonoBehaviour script;

	public GameObject instantiate;

	private void Start()
	{
		if (Object.op_Implicit((Object)(object)instantiate))
		{
			Logger.LogDebug((object)$"{((Component)this).gameObject} // instantiate: {instantiate}");
			Object.Instantiate<GameObject>(instantiate, ((Component)this).gameObject.transform);
		}
	}
}
public class BasicTimer : VisibleTimerBase
{
}
public class BlindnessTimer : VisibleTimerBase
{
	public WormPlayer wormScript;

	public Wormling_Base wormlingScript;

	public float localTime;

	public override void Start()
	{
		wormScript = ((Component)this).GetComponentInParent<WormPlayer>();
		wormlingScript = ((Component)this).GetComponentInParent<Wormling_Base>();
		base.Start();
	}

	public override void GenerateDefaultConfigData(string configName = null, bool defaultDisplayed = true, TimerType defaultType = TimerType.Text, VisibilityType defaultVisibility = VisibilityType.Everyone, Vector4 defaultColorPrimary = default(Vector4), Vector4 defaultColorSecondary = default(Vector4), Vector3 defaultObjectSize = default(Vector3), float defaultVerticalOffset = 1f, bool defaultShowArrow = true, int defaultTextDecimals = 2, bool defaultMinuteNotation = true, int defaultBackgroundOpacity = 50, float defaultRecolorInterval = 1f, int defaultRefreshRate = 1)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: 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)
		configName = VTAssetsCollection.blindnessCategoryName;
		defaultDisplayed = true;
		defaultType = TimerType.Bar;
		defaultVisibility = VisibilityType.WormsOnly;
		((Vector4)(ref defaultColorPrimary))..ctor(0.75f, 0.75f, 0.75f, 1f);
		((Vector4)(ref defaultColorSecondary))..ctor(1f, 0f, 1f, 0.5f);
		((Vector3)(ref defaultObjectSize))..ctor(2.5f, 2.5f, 2.5f);
		defaultVerticalOffset = 0f;
		defaultShowArrow = false;
		defaultTextDecimals = 1;
		defaultMinuteNotation = false;
		defaultBackgroundOpacity = 50;
		defaultRecolorInterval = 0.25f;
		defaultRefreshRate = 1;
		base.GenerateDefaultConfigData(configName, defaultDisplayed, defaultType, defaultVisibility, defaultColorPrimary, defaultColorSecondary, defaultObjectSize, defaultVerticalOffset, defaultShowArrow, defaultTextDecimals, defaultMinuteNotation, defaultBackgroundOpacity, defaultRecolorInterval, defaultRefreshRate);
	}

	public override void Update()
	{
		if (Object.op_Implicit((Object)(object)wormScript) && wormScript.isBlinded.Value)
		{
			if (((NetworkBehaviour)wormScript).IsHost)
			{
				localTime = wormScript.blindDuration_Curr;
			}
			else
			{
				localTime -= Time.deltaTime;
			}
		}
		else if (Object.op_Implicit((Object)(object)wormlingScript) && wormlingScript.isBlinded_Synced.Value)
		{
			if (((NetworkBehaviour)wormlingScript).IsOwner)
			{
				localTime = wormlingScript.blindedTimeOut - wormlingScript.blindedTimeOut_Curr;
			}
			else
			{
				localTime -= Time.deltaTime;
			}
		}
		base.Update();
	}

	public override void RetrieveTimerCurrent()
	{
		if (currentlyVisible)
		{
			SetTimerCurrent(localTime);
		}
	}

	public void AddToLocalTime(float time, bool addOrSnap)
	{
		if (addOrSnap)
		{
			localTime += time;
		}
		else
		{
			localTime = time;
		}
		if (Application.isEditor)
		{
			VisibleTimerBase.Logger.LogWarning((object)$"addOrSnap? {addOrSnap} // wormScript: {wormScript} & wormlingScript: {wormlingScript} // with {time} to {localTime}");
		}
		SetTimerCurrent(localTime);
		if (GetTimerCurrent() == 0f || GetTimerCurrent() > GetTimerMax())
		{
			SetTimerMax(localTime);
		}
	}

	public static void Replicate_FindWormsInRadiusAndBlindThem(Vector3 blindPos, float blindDuration, float aoeRadius)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)TimersManager.Singleton))
		{
			return;
		}
		if (Application.isEditor)
		{
			VisibleTimerBase.Logger.LogInfo((object)$"Replicate_FindWormsInRadiusAndBlindThem(): {blindPos}, {blindDuration}, {aoeRadius}");
		}
		foreach (WormPlayer wormPlayerScript in GameManager.Singleton.wormPlayerScripts)
		{
			if (Object.op_Implicit((Object)(object)wormPlayerScript))
			{
				FindBlindnessTimerOnTransform(blindPos, aoeRadius, blindDuration, addOrSnap: true, wormPlayerScript);
			}
		}
		foreach (Wormling_Base allWormling in GameManager.Singleton.AllWormlings)
		{
			if (Object.op_Implicit((Object)(object)allWormling))
			{
				FindBlindnessTimerOnTransform(blindPos, aoeRadius, allWormling.blindedTimeOut, addOrSnap: false, null, allWormling);
			}
		}
	}

	private static void FindBlindnessTimerOnTransform(Vector3 blindPos, float aoeRadius, float blindDuration, bool addOrSnap, WormPlayer worm = null, Wormling_Base wormling = null)
	{
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)worm) && !Object.op_Implicit((Object)(object)wormling))
		{
			if (Application.isEditor)
			{
				VisibleTimerBase.Logger.LogWarning((object)"FindBlindnessTimerOnTransform(): A");
			}
			return;
		}
		Transform val = (Object.op_Implicit((Object)(object)worm) ? ((Component)worm).transform : (Object.op_Implicit((Object)(object)wormling) ? ((Component)wormling).transform : null));
		if (!Object.op_Implicit((Object)(object)val))
		{
			if (Application.isEditor)
			{
				VisibleTimerBase.Logger.LogWarning((object)"FindBlindnessTimerOnTransform(): B");
			}
			return;
		}
		if (Vector3.Distance(val.position, blindPos) > aoeRadius)
		{
			if (Application.isEditor)
			{
				VisibleTimerBase.Logger.LogWarning((object)"FindBlindnessTimerOnTransform(): C");
			}
			return;
		}
		Transform val2 = val;
		if (Object.op_Implicit((Object)(object)worm) && Object.op_Implicit((Object)(object)GameManager.Singleton.localWormScript) && (Object)(object)GameManager.Singleton.localWormScript == (Object)(object)worm && Object.op_Implicit((Object)(object)worm.wormCam))
		{
			val2 = ((Component)worm.wormCam).transform;
		}
		Transform val3 = val2.Find(VTAssetsCollection.wormEffectHandlerName);
		if (!Object.op_Implicit((Object)(object)val3))
		{
			if (Application.isEditor)
			{
				VisibleTimerBase.Logger.LogWarning((object)"FindBlindnessTimerOnTransform(): D");
			}
			return;
		}
		if (Application.isEditor)
		{
			VisibleTimerBase.Logger.LogDebug((object)"FindBlindnessTimerOnTransform(): E");
		}
		BlindnessTimer blindnessTimer = null;
		for (int i = 0; i < TimersManager.Singleton.allTimers.Count; i++)
		{
			VisibleTimerBase visibleTimerBase = TimersManager.Singleton.allTimers[i];
			if (Object.op_Implicit((Object)(object)visibleTimerBase) && visibleTimerBase is BlindnessTimer && Object.op_Implicit((Object)(object)visibleTimerBase.followObject) && (Object)(object)visibleTimerBase.followObject == (Object)(object)((Component)val3).gameObject)
			{
				blindnessTimer = visibleTimerBase as BlindnessTimer;
				break;
			}
		}
		if (Object.op_Implicit((Object)(object)blindnessTimer))
		{
			blindnessTimer.AddToLocalTime(blindDuration, addOrSnap);
		}
	}

	public static void ToggleVisibilityOnBlindValueChanged(Transform onParent, bool setTo)
	{
		if (!VTConfigs.DisplayTimer(VTAssetsCollection.blindnessCategoryName))
		{
			if (Application.isEditor)
			{
				VisibleTimerBase.Logger.LogWarning((object)"ToggleVisibilityOnBlindValueChanged(): A");
			}
			return;
		}
		if (!Object.op_Implicit((Object)(object)onParent))
		{
			if (Application.isEditor)
			{
				VisibleTimerBase.Logger.LogWarning((object)"ToggleVisibilityOnBlindValueChanged(): B");
			}
			return;
		}
		Transform val = onParent.Find(VTAssetsCollection.wormEffectHandlerName);
		if (!Object.op_Implicit((Object)(object)val))
		{
			if (Application.isEditor)
			{
				VisibleTimerBase.Logger.LogWarning((object)"ToggleVisibilityOnBlindValueChanged(): C");
			}
			return;
		}
		if (Application.isEditor)
		{
			VisibleTimerBase.Logger.LogDebug((object)"ToggleVisibilityOnBlindValueChanged(): D");
		}
		BlindnessTimer blindnessTimer = null;
		for (int i = 0; i < TimersManager.Singleton.allTimers.Count; i++)
		{
			VisibleTimerBase visibleTimerBase = TimersManager.Singleton.allTimers[i];
			if (Object.op_Implicit((Object)(object)visibleTimerBase) && visibleTimerBase is BlindnessTimer && Object.op_Implicit((Object)(object)visibleTimerBase.followObject) && (Object)(object)visibleTimerBase.followObject == (Object)(object)((Component)val).gameObject)
			{
				blindnessTimer = visibleTimerBase as BlindnessTimer;
				break;
			}
		}
		if (Object.op_Implicit((Object)(object)blindnessTimer))
		{
			blindnessTimer.SetVisibility(setTo);
			if (!setTo)
			{
				blindnessTimer.AddToLocalTime(0f, addOrSnap: false);
			}
		}
	}
}
public class BomberTimer : VisibleTimerBase
{
	public Wormling_Bomber wormlingScript;

	public float localTime;

	public override void Start()
	{
		wormlingScript = ((Component)((Component)this).transform.parent).GetComponent<Wormling_Bomber>();
		localTime = wormlingScript.explosionCountDown;
		SetTimerMax(wormlingScript.explosionCountDown);
		startVisible = wormlingScript.fuseParticles.activeSelf;
		base.Start();
	}

	public override void GenerateDefaultConfigData(string configName = null, bool defaultDisplayed = true, TimerType defaultType = TimerType.Text, VisibilityType defaultVisibility = VisibilityType.Everyone, Vector4 defaultColorPrimary = default(Vector4), Vector4 defaultColorSecondary = default(Vector4), Vector3 defaultObjectSize = default(Vector3), float defaultVerticalOffset = 1f, bool defaultShowArrow = true, int defaultTextDecimals = 2, bool defaultMinuteNotation = true, int defaultBackgroundOpacity = 50, float defaultRecolorInterval = 1f, int defaultRefreshRate = 1)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: 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)
		configName = VTAssetsCollection.bomberCategoryName;
		defaultDisplayed = true;
		defaultType = TimerType.Bar;
		defaultVisibility = VisibilityType.Everyone;
		((Vector4)(ref defaultColorPrimary))..ctor(1f, 1f, 1f, 1f);
		((Vector4)(ref defaultColorSecondary))..ctor(1f, 0f, 0f, 1f);
		((Vector3)(ref defaultObjectSize))..ctor(0.75f, 0.75f, 0.75f);
		defaultVerticalOffset = 1.25f;
		defaultShowArrow = true;
		defaultTextDecimals = 1;
		defaultMinuteNotation = false;
		defaultBackgroundOpacity = 25;
		defaultRecolorInterval = 0.1f;
		defaultRefreshRate = 1;
		base.GenerateDefaultConfigData(configName, defaultDisplayed, defaultType, defaultVisibility, defaultColorPrimary, defaultColorSecondary, defaultObjectSize, defaultVerticalOffset, defaultShowArrow, defaultTextDecimals, defaultMinuteNotation, defaultBackgroundOpacity, defaultRecolorInterval, defaultRefreshRate);
	}

	public override void Update()
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)wormlingScript))
		{
			if (((NetworkBehaviour)wormlingScript).IsHost)
			{
				localTime = wormlingScript.explosionCountDown;
			}
			else if (wormlingScript.fuseParticles.activeSelf && followObject.transform.position.y > GameManager.Singleton.CalculateSurfacedYPosition(followObject.transform.position))
			{
				localTime -= Time.deltaTime;
			}
		}
		base.Update();
	}

	public override void RetrieveTimerCurrent()
	{
		SetTimerCurrent(localTime);
	}
}
public class CoffeeTimer : VisibleTimerBase
{
	public StatusEffect effectScript;

	public bool handlerLocal;

	public float localTime;

	public override void Start()
	{
		if (!Object.op_Implicit((Object)(object)StatusEffectsBank.Singleton) || StatusEffectsBank.Singleton.statusEffects == null)
		{
			VisibleTimerBase.Logger.LogDebug((object)"failed to find BANK on coffee");
			DisableSelf();
			return;
		}
		StatusEffect val = null;
		for (int i = 0; i < StatusEffectsBank.Singleton.statusEffects.Count; i++)
		{
			StatusEffect val2 = StatusEffectsBank.Singleton.statusEffects[i];
			if (Object.op_Implicit((Object)(object)val2) && val2 is StatusEffect_Coffee)
			{
				val = val2;
				break;
			}
		}
		if (!Object.op_Implicit((Object)(object)val))
		{
			VisibleTimerBase.Logger.LogDebug((object)"failed to find effect on coffee");
			DisableSelf();
		}
		else
		{
			effectScript = val;
			SetTimerMax(effectScript.duration);
			base.Start();
		}
	}

	public override void GenerateDefaultConfigData(string configName = null, bool defaultDisplayed = true, TimerType defaultType = TimerType.Text, VisibilityType defaultVisibility = VisibilityType.Everyone, Vector4 defaultColorPrimary = default(Vector4), Vector4 defaultColorSecondary = default(Vector4), Vector3 defaultObjectSize = default(Vector3), float defaultVerticalOffset = 1f, bool defaultShowArrow = true, int defaultTextDecimals = 2, bool defaultMinuteNotation = true, int defaultBackgroundOpacity = 50, float defaultRecolorInterval = 1f, int defaultRefreshRate = 1)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: 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)
		configName = VTAssetsCollection.coffeeCategoryName;
		defaultDisplayed = true;
		defaultType = TimerType.Bar;
		defaultVisibility = VisibilityType.Everyone;
		((Vector4)(ref defaultColorPrimary))..ctor(0.66f, 0.33f, 0f, 1f);
		((Vector4)(ref defaultColorSecondary))..ctor(0.66f, 0.33f, 0f, 0.25f);
		((Vector3)(ref defaultObjectSize))..ctor(1f, 1f, 1f);
		defaultVerticalOffset = 1.9f;
		defaultShowArrow = false;
		defaultTextDecimals = 2;
		defaultMinuteNotation = false;
		defaultBackgroundOpacity = 25;
		defaultRecolorInterval = 0.25f;
		defaultRefreshRate = 1;
		base.GenerateDefaultConfigData(configName, defaultDisplayed, defaultType, defaultVisibility, defaultColorPrimary, defaultColorSecondary, defaultObjectSize, defaultVerticalOffset, defaultShowArrow, defaultTextDecimals, defaultMinuteNotation, defaultBackgroundOpacity, defaultRecolorInterval, defaultRefreshRate);
	}

	public override void Update()
	{
		if (Object.op_Implicit((Object)(object)effectScript))
		{
			localTime = (handlerLocal ? effectScript.duration_Curr : localTime);
			if (localTime > 0f)
			{
				if (!handlerLocal)
				{
					localTime -= Time.deltaTime;
				}
				if (!currentlyVisible)
				{
					SetVisibility(visible: true);
				}
			}
			else if (currentlyVisible)
			{
				SetVisibility(visible: false);
			}
		}
		base.Update();
	}

	public override void RetrieveTimerCurrent()
	{
		if (currentlyVisible)
		{
			SetTimerCurrent(localTime);
		}
	}

	public void StartTimer()
	{
		if (!handlerLocal)
		{
			localTime = effectScript.duration;
		}
	}
}
public class DynamiteTimer : VisibleTimerBase
{
	public Dynamite dynamiteScript;

	public DynamiteTimer mainScript;

	public float localTime;

	public override void Start()
	{
		ref Dynamite reference = ref dynamiteScript;
		MonoBehaviour script = ((Component)((Component)this).transform.parent).GetComponent<VTComponentContainer>().script;
		reference = (Dynamite)(object)((script is Dynamite) ? script : null);
		VTComponentContainer component = ((Component)dynamiteScript).GetComponent<VTComponentContainer>();
		if (!Object.op_Implicit((Object)(object)component))
		{
			((Component)dynamiteScript).gameObject.AddComponent<VTComponentContainer>().script = (MonoBehaviour)(object)this;
		}
		else
		{
			mainScript = component.script as DynamiteTimer;
		}
		localTime = dynamiteScript.dynamiteMaxFuseTime;
		SetTimerCurrent(localTime);
		SetTimerMax(dynamiteScript.dynamiteMaxFuseTime);
		startVisible = dynamiteScript.fuseParticles.activeSelf;
		base.Start();
	}

	public override void GenerateDefaultConfigData(string configName = null, bool defaultDisplayed = true, TimerType defaultType = TimerType.Text, VisibilityType defaultVisibility = VisibilityType.Everyone, Vector4 defaultColorPrimary = default(Vector4), Vector4 defaultColorSecondary = default(Vector4), Vector3 defaultObjectSize = default(Vector3), float defaultVerticalOffset = 1f, bool defaultShowArrow = true, int defaultTextDecimals = 2, bool defaultMinuteNotation = true, int defaultBackgroundOpacity = 50, float defaultRecolorInterval = 1f, int defaultRefreshRate = 1)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: 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)
		configName = VTAssetsCollection.dynamiteCategoryName;
		defaultDisplayed = true;
		defaultType = TimerType.Bar;
		defaultVisibility = VisibilityType.Everyone;
		((Vector4)(ref defaultColorPrimary))..ctor(1f, 1f, 1f, 1f);
		((Vector4)(ref defaultColorSecondary))..ctor(1f, 0f, 0f, 1f);
		((Vector3)(ref defaultObjectSize))..ctor(1f, 1f, 1f);
		defaultVerticalOffset = 0.75f;
		defaultShowArrow = true;
		defaultTextDecimals = 1;
		defaultMinuteNotation = false;
		defaultBackgroundOpacity = 25;
		defaultRecolorInterval = 0.1f;
		defaultRefreshRate = 1;
		base.GenerateDefaultConfigData(configName, defaultDisplayed, defaultType, defaultVisibility, defaultColorPrimary, defaultColorSecondary, defaultObjectSize, defaultVerticalOffset, defaultShowArrow, defaultTextDecimals, defaultMinuteNotation, defaultBackgroundOpacity, defaultRecolorInterval, defaultRefreshRate);
	}

	public override void Update()
	{
		if (Object.op_Implicit((Object)(object)dynamiteScript))
		{
			if (((NetworkBehaviour)dynamiteScript).IsHost)
			{
				localTime = dynamiteScript.dynamiteFuseTime_Current;
			}
			else if (Object.op_Implicit((Object)(object)mainScript))
			{
				localTime = mainScript.GetTimerCurrent();
			}
			else if (dynamiteScript.fuseParticles.activeSelf)
			{
				localTime -= Time.deltaTime;
			}
		}
		base.Update();
	}

	public override void RetrieveTimerCurrent()
	{
		if (currentlyVisible)
		{
			SetTimerCurrent(localTime);
		}
	}

	public void Replicate_MultiplyFuseTime(float fuseMult)
	{
		if (Application.isEditor)
		{
			VisibleTimerBase.Logger.LogDebug((object)$"!!! Replicate_MultiplyFuseTime(): {localTime} * {fuseMult} = {localTime * fuseMult}");
		}
		((MonoBehaviour)this).StartCoroutine(MultiplyLocalTimeOnDelay(fuseMult));
	}

	private IEnumerator MultiplyLocalTimeOnDelay(float multiplier)
	{
		float timeWaited = 0f;
		for (float waitIntervals = 0.1f; timeWaited < 2.5f; timeWaited += waitIntervals)
		{
			if (dynamiteScript.fuseParticles.activeSelf)
			{
				break;
			}
			yield return (object)new WaitForSeconds(waitIntervals);
		}
		if (!dynamiteScript.fuseParticles.activeSelf)
		{
			if (Application.isEditor)
			{
				VisibleTimerBase.Logger.LogError((object)"MultiplyLocalTimeOnDelay()");
			}
		}
		else
		{
			localTime *= multiplier;
		}
	}

	public static void DoCheckForDynamiteTimer(NetworkBehaviour netObj, Vector3 _explosionPosition, float _radius)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)netObj) || netObj.IsHost || !Object.op_Implicit((Object)(object)TimersManager.Singleton))
		{
			return;
		}
		if (Application.isEditor)
		{
			VisibleTimerBase.Logger.LogInfo((object)$"DoCheckForDynamiteTimer: {_explosionPosition} & {_radius}");
		}
		for (int i = 0; i < TimersManager.Singleton.allTimers.Count; i++)
		{
			VisibleTimerBase visibleTimerBase = TimersManager.Singleton.allTimers[i];
			if (!Object.op_Implicit((Object)(object)visibleTimerBase) || !Object.op_Implicit((Object)(object)visibleTimerBase.followObject) || !(visibleTimerBase is DynamiteTimer))
			{
				continue;
			}
			DynamiteTimer dynamiteTimer = visibleTimerBase as DynamiteTimer;
			if (!dynamiteTimer.dynamiteScript.fuseParticles.activeSelf)
			{
				float num = Vector3.Distance(visibleTimerBase.followObject.transform.position, _explosionPosition);
				if (num <= _radius)
				{
					dynamiteTimer.Replicate_MultiplyFuseTime(0.2f + 0.6f * (num / _radius));
				}
			}
		}
	}
}
public class EggTimer : VisibleTimerBase
{
	public WormlingEgg eggScript;

	public EggTimer mainScript;

	public float localTime;

	public float divideBy;

	private int startingValue;

	public override void Start()
	{
		ref WormlingEgg reference = ref eggScript;
		MonoBehaviour script = ((Component)((Component)this).transform.parent).GetComponent<VTComponentContainer>().script;
		reference = (WormlingEgg)(object)((script is WormlingEgg) ? script : null);
		VTComponentContainer component = ((Component)eggScript).GetComponent<VTComponentContainer>();
		if (!Object.op_Implicit((Object)(object)component))
		{
			((Component)eggScript).gameObject.AddComponent<VTComponentContainer>().script = (MonoBehaviour)(object)this;
		}
		else
		{
			mainScript = component.script as EggTimer;
		}
		divideBy = WormlingSpawnManager.Singleton.hatchSpeeds[MatchSettingsManager.Singleton.wormlingHatchingSpeedMulti_DifficultySetting.Value];
		if (divideBy == 0f)
		{
			divideBy = 1f;
		}
		startingValue = eggScript.eggHealth_Synced.Value;
		SetTimerMax(eggScript.eggHealth_Starting / divideBy);
		startVisible = true;
		base.Start();
	}

	public override void GenerateDefaultConfigData(string configName = null, bool defaultDisplayed = true, TimerType defaultType = TimerType.Text, VisibilityType defaultVisibility = VisibilityType.Everyone, Vector4 defaultColorPrimary = default(Vector4), Vector4 defaultColorSecondary = default(Vector4), Vector3 defaultObjectSize = default(Vector3), float defaultVerticalOffset = 1f, bool defaultShowArrow = true, int defaultTextDecimals = 2, bool defaultMinuteNotation = true, int defaultBackgroundOpacity = 50, float defaultRecolorInterval = 1f, int defaultRefreshRate = 1)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: 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)
		configName = VTAssetsCollection.eggCategoryName;
		defaultDisplayed = true;
		defaultType = TimerType.Circle;
		defaultVisibility = VisibilityType.Everyone;
		((Vector4)(ref defaultColorPrimary))..ctor(0.7f, 0.25f, 0.1f, 0.5f);
		((Vector4)(ref defaultColorSecondary))..ctor(1f, 0.25f, 0.1f, 1f);
		((Vector3)(ref defaultObjectSize))..ctor(1.5f, 1.5f, 1.5f);
		defaultVerticalOffset = 1.75f;
		defaultShowArrow = false;
		defaultTextDecimals = 0;
		defaultMinuteNotation = true;
		defaultBackgroundOpacity = 25;
		defaultRecolorInterval = 2f;
		defaultRefreshRate = 1;
		base.GenerateDefaultConfigData(configName, defaultDisplayed, defaultType, defaultVisibility, defaultColorPrimary, defaultColorSecondary, defaultObjectSize, defaultVerticalOffset, defaultShowArrow, defaultTextDecimals, defaultMinuteNotation, defaultBackgroundOpacity, defaultRecolorInterval, defaultRefreshRate);
	}

	public override void Update()
	{
		if (Object.op_Implicit((Object)(object)eggScript))
		{
			if (((NetworkBehaviour)eggScript).IsHost)
			{
				localTime = eggScript.eggHealth_Local;
			}
			else if (Object.op_Implicit((Object)(object)mainScript))
			{
				localTime = mainScript.localTime;
			}
			else
			{
				localTime -= Time.deltaTime * divideBy;
			}
		}
		base.Update();
	}

	public override void RetrieveTimerCurrent()
	{
		SetTimerCurrent(localTime / divideBy);
	}

	public void SnapLocalTimeUsingLatestPercentile()
	{
		float num = eggScript.eggHealth_Starting;
		float num2 = (float)(int)eggScript.eggHealth_Synced.Value + 0.5f;
		float num3 = startingValue;
		localTime = num * (num2 / num3);
		if (Application.isEditor)
		{
			VisibleTimerBase.Logger.LogDebug((object)$"SnapLocalTimeUsingLatestPercentile(): {num} * ({num2} / {num3}) = {localTime}");
		}
	}
}
public class IcespikeTimer : VisibleTimerBase
{
	public WormlingIceSpike icespikeScript;

	public float localTime;

	public override void Start()
	{
		icespikeScript = ((Component)this).GetComponentInParent<WormlingIceSpike>();
		localTime = icespikeScript.lifeTime;
		SetTimerMax(icespikeScript.lifeTime);
		startVisible = true;
		base.Start();
	}

	public override void GenerateDefaultConfigData(string configName = null, bool defaultDisplayed = true, TimerType defaultType = TimerType.Text, VisibilityType defaultVisibility = VisibilityType.Everyone, Vector4 defaultColorPrimary = default(Vector4), Vector4 defaultColorSecondary = default(Vector4), Vector3 defaultObjectSize = default(Vector3), float defaultVerticalOffset = 1f, bool defaultShowArrow = true, int defaultTextDecimals = 2, bool defaultMinuteNotation = true, int defaultBackgroundOpacity = 50, float defaultRecolorInterval = 1f, int defaultRefreshRate = 1)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: 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)
		configName = VTAssetsCollection.icespikeCategoryName;
		defaultDisplayed = true;
		defaultType = TimerType.Circle;
		defaultVisibility = VisibilityType.Everyone;
		((Vector4)(ref defaultColorPrimary))..ctor(0.5f, 1f, 1f, 1f);
		((Vector4)(ref defaultColorSecondary))..ctor(0.75f, 1f, 1f, 0.5f);
		((Vector3)(ref defaultObjectSize))..ctor(1f, 1f, 1f);
		defaultVerticalOffset = 5f;
		defaultShowArrow = true;
		defaultTextDecimals = 2;
		defaultMinuteNotation = false;
		defaultBackgroundOpacity = 50;
		defaultRecolorInterval = 1f;
		defaultRefreshRate = 1;
		base.GenerateDefaultConfigData(configName, defaultDisplayed, defaultType, defaultVisibility, defaultColorPrimary, defaultColorSecondary, defaultObjectSize, defaultVerticalOffset, defaultShowArrow, defaultTextDecimals, defaultMinuteNotation, defaultBackgroundOpacity, defaultRecolorInterval, defaultRefreshRate);
	}

	public override void Update()
	{
		if (Object.op_Implicit((Object)(object)icespikeScript))
		{
			if (((NetworkBehaviour)icespikeScript).IsHost)
			{
				localTime = icespikeScript.lifeTime;
			}
			else
			{
				localTime -= Time.deltaTime;
			}
		}
		base.Update();
	}

	public override void RetrieveTimerCurrent()
	{
		SetTimerCurrent(localTime);
	}
}
public class InfinistaminaTimer : VisibleTimerBase
{
	public StatusEffect effectScript;

	public bool handlerLocal;

	public float localTime;

	public override void Start()
	{
		if (!Object.op_Implicit((Object)(object)StatusEffectsBank.Singleton) || StatusEffectsBank.Singleton.statusEffects == null)
		{
			VisibleTimerBase.Logger.LogDebug((object)"failed to find BANK on infinistamina");
			DisableSelf();
			return;
		}
		StatusEffect val = null;
		for (int i = 0; i < StatusEffectsBank.Singleton.statusEffects.Count; i++)
		{
			StatusEffect val2 = StatusEffectsBank.Singleton.statusEffects[i];
			if (Object.op_Implicit((Object)(object)val2) && val2 is StatusEffect_Adrenaline)
			{
				val = val2;
				break;
			}
		}
		if (!Object.op_Implicit((Object)(object)val))
		{
			VisibleTimerBase.Logger.LogDebug((object)"failed to find EFFECT on infinistamina");
			DisableSelf();
		}
		else
		{
			effectScript = val;
			SetTimerMax(effectScript.duration);
			base.Start();
		}
	}

	public override void GenerateDefaultConfigData(string configName = null, bool defaultDisplayed = true, TimerType defaultType = TimerType.Text, VisibilityType defaultVisibility = VisibilityType.Everyone, Vector4 defaultColorPrimary = default(Vector4), Vector4 defaultColorSecondary = default(Vector4), Vector3 defaultObjectSize = default(Vector3), float defaultVerticalOffset = 1f, bool defaultShowArrow = true, int defaultTextDecimals = 2, bool defaultMinuteNotation = true, int defaultBackgroundOpacity = 50, float defaultRecolorInterval = 1f, int defaultRefreshRate = 1)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: 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)
		configName = VTAssetsCollection.staminaCategoryName;
		defaultDisplayed = true;
		defaultType = TimerType.Bar;
		defaultVisibility = VisibilityType.Everyone;
		((Vector4)(ref defaultColorPrimary))..ctor(0f, 1f, 1f, 1f);
		((Vector4)(ref defaultColorSecondary))..ctor(0f, 1f, 1f, 0f);
		((Vector3)(ref defaultObjectSize))..ctor(1f, 1f, 1f);
		defaultVerticalOffset = 1.75f;
		defaultShowArrow = false;
		defaultTextDecimals = 1;
		defaultMinuteNotation = false;
		defaultBackgroundOpacity = 25;
		defaultRecolorInterval = 0.25f;
		defaultRefreshRate = 1;
		base.GenerateDefaultConfigData(configName, defaultDisplayed, defaultType, defaultVisibility, defaultColorPrimary, defaultColorSecondary, defaultObjectSize, defaultVerticalOffset, defaultShowArrow, defaultTextDecimals, defaultMinuteNotation, defaultBackgroundOpacity, defaultRecolorInterval, defaultRefreshRate);
	}

	public override void Update()
	{
		if (Object.op_Implicit((Object)(object)effectScript))
		{
			localTime = (handlerLocal ? effectScript.duration_Curr : localTime);
			if (localTime > 0f)
			{
				if (!handlerLocal)
				{
					localTime -= Time.deltaTime;
				}
				if (!currentlyVisible)
				{
					SetVisibility(visible: true);
				}
			}
			else if (currentlyVisible)
			{
				SetVisibility(visible: false);
			}
		}
		base.Update();
	}

	public override void RetrieveTimerCurrent()
	{
		if (currentlyVisible)
		{
			SetTimerCurrent(localTime);
		}
	}

	public void StartTimer()
	{
		if (!handlerLocal)
		{
			localTime = effectScript.duration;
		}
	}
}
public class LeverTimer : VisibleTimerBase
{
	public float localTime;

	public override void Start()
	{
		SetTimerMax(GameManager.Singleton.trainHornLeverDisabledTimer_Max);
		base.Start();
	}

	public override void GenerateDefaultConfigData(string configName = null, bool defaultDisplayed = true, TimerType defaultType = TimerType.Text, VisibilityType defaultVisibility = VisibilityType.Everyone, Vector4 defaultColorPrimary = default(Vector4), Vector4 defaultColorSecondary = default(Vector4), Vector3 defaultObjectSize = default(Vector3), float defaultVerticalOffset = 1f, bool defaultShowArrow = true, int defaultTextDecimals = 2, bool defaultMinuteNotation = true, int defaultBackgroundOpacity = 50, float defaultRecolorInterval = 1f, int defaultRefreshRate = 1)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: 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)
		configName = VTAssetsCollection.leverCategoryName;
		defaultDisplayed = true;
		defaultType = TimerType.Circle;
		defaultVisibility = VisibilityType.Everyone;
		((Vector4)(ref defaultColorPrimary))..ctor(1f, 0f, 0f, 1f);
		((Vector4)(ref defaultColorSecondary))..ctor(0f, 1f, 0f, 0.5f);
		((Vector3)(ref defaultObjectSize))..ctor(0.5f, 0.5f, 0.5f);
		defaultVerticalOffset = -0.33f;
		defaultShowArrow = false;
		defaultTextDecimals = 2;
		defaultMinuteNotation = false;
		defaultBackgroundOpacity = 25;
		defaultRecolorInterval = 0.33f;
		defaultRefreshRate = 1;
		base.GenerateDefaultConfigData(configName, defaultDisplayed, defaultType, defaultVisibility, defaultColorPrimary, defaultColorSecondary, defaultObjectSize, defaultVerticalOffset, defaultShowArrow, defaultTextDecimals, defaultMinuteNotation, defaultBackgroundOpacity, defaultRecolorInterval, defaultRefreshRate);
	}

	public override void Update()
	{
		localTime = (((NetworkBehaviour)GameManager.Singleton).IsHost ? GameManager.Singleton.trainHornLeverDisabledTimer_Curr : localTime);
		if (localTime > 0f)
		{
			if (!((NetworkBehaviour)GameManager.Singleton).IsHost)
			{
				localTime -= Time.deltaTime;
			}
			if (!currentlyVisible)
			{
				SetVisibility(visible: true);
			}
		}
		else if (currentlyVisible)
		{
			SetVisibility(visible: false);
		}
		base.Update();
	}

	public override void RetrieveTimerCurrent()
	{
		if (currentlyVisible)
		{
			SetTimerCurrent(localTime);
		}
	}

	public void StartTimer()
	{
		localTime = GameManager.Singleton.trainHornLeverDisabledTimer_Max;
	}
}
public class SinkholeTimer : VisibleTimerBase
{
	public ShiftingSands_SandShifter sinkholeScript;

	public override void Start()
	{
		sinkholeScript = ((Component)((Component)this).transform.parent).GetComponent<ShiftingSands_SandShifter>();
		SetTimerMax(sinkholeScript.lifetime);
		startVisible = true;
		base.Start();
	}

	public override void GenerateDefaultConfigData(string configName = null, bool defaultDisplayed = true, TimerType defaultType = TimerType.Text, VisibilityType defaultVisibility = VisibilityType.Everyone, Vector4 defaultColorPrimary = default(Vector4), Vector4 defaultColorSecondary = default(Vector4), Vector3 defaultObjectSize = default(Vector3), float defaultVerticalOffset = 1f, bool defaultShowArrow = true, int defaultTextDecimals = 2, bool defaultMinuteNotation = true, int defaultBackgroundOpacity = 50, float defaultRecolorInterval = 1f, int defaultRefreshRate = 1)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: 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)
		configName = VTAssetsCollection.sinkholeCategoryName;
		defaultDisplayed = true;
		defaultType = TimerType.Text;
		defaultVisibility = VisibilityType.WormsOnly;
		((Vector4)(ref defaultColorPrimary))..ctor(0.25f, 0.25f, 0.25f, 1f);
		((Vector4)(ref defaultColorSecondary))..ctor(0.25f, 0.25f, 0.25f, 1f);
		((Vector3)(ref defaultObjectSize))..ctor(15f, 15f, 15f);
		defaultVerticalOffset = -5f;
		defaultShowArrow = true;
		defaultTextDecimals = 1;
		defaultMinuteNotation = false;
		defaultBackgroundOpacity = 25;
		defaultRecolorInterval = 1f;
		defaultRefreshRate = 1;
		base.GenerateDefaultConfigData(configName, defaultDisplayed, defaultType, defaultVisibility, defaultColorPrimary, defaultColorSecondary, defaultObjectSize, defaultVerticalOffset, defaultShowArrow, defaultTextDecimals, defaultMinuteNotation, defaultBackgroundOpacity, defaultRecolorInterval, defaultRefreshRate);
	}

	public override void Update()
	{
		if (Object.op_Implicit((Object)(object)sinkholeScript) && sinkholeScript.lifetime <= 0f && currentlyVisible)
		{
			SetVisibility(visible: false);
		}
		base.Update();
	}

	public override void RetrieveTimerCurrent()
	{
		SetTimerCurrent(sinkholeScript.lifetime);
	}
}
public class SunTimer : VisibleTimerBase
{
	public override void GenerateDefaultConfigData(string configName = null, bool defaultDisplayed = true, TimerType defaultType = TimerType.Text, VisibilityType defaultVisibility = VisibilityType.Everyone, Vector4 defaultColorPrimary = default(Vector4), Vector4 defaultColorSecondary = default(Vector4), Vector3 defaultObjectSize = default(Vector3), float defaultVerticalOffset = 1f, bool defaultShowArrow = true, int defaultTextDecimals = 2, bool defaultMinuteNotation = true, int defaultBackgroundOpacity = 50, float defaultRecolorInterval = 1f, int defaultRefreshRate = 1)
	{
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		configName = VTAssetsCollection.sunCategoryName;
		defaultDisplayed = false;
		defaultType = TimerType.Text;
		defaultVisibility = VisibilityType.Everyone;
		((Vector4)(ref defaultColorPrimary))..ctor(1f, 1f, 0f, 1f);
		((Vector4)(ref defaultColorSecondary))..ctor(1f, 0f, 1f, 1f);
		((Vector3)(ref defaultObjectSize))..ctor(120f, 120f, 120f);
		defaultVerticalOffset = 90f;
		defaultShowArrow = false;
		defaultTextDecimals = 0;
		defaultMinuteNotation = true;
		defaultBackgroundOpacity = 25;
		defaultRecolorInterval = 60f;
		defaultRefreshRate = 30;
		base.GenerateDefaultConfigData(configName, defaultDisplayed, defaultType, defaultVisibility, defaultColorPrimary, defaultColorSecondary, defaultObjectSize, defaultVerticalOffset, defaultShowArrow, defaultTextDecimals, defaultMinuteNotation, defaultBackgroundOpacity, defaultRecolorInterval, defaultRefreshRate);
	}

	public override void RetrieveTimerCurrent()
	{
		if (currentlyVisible)
		{
			SetTimerCurrent(TimeOfDayManager.Singleton.timeUntilSundown_Current);
		}
	}

	public void SetNewMaxTimer()
	{
		((MonoBehaviour)this).StartCoroutine(SetNewMaxTimerOnDelay());
	}

	private IEnumerator SetNewMaxTimerOnDelay()
	{
		yield return (object)new WaitUntil((Func<bool>)(() => TimeOfDayManager.Singleton.hasRecievedSundownTimerFromServer));
		float timeUntilSundown_Starting = TimeOfDayManager.Singleton.timeUntilSundown_Starting;
		SetTimerMax(timeUntilSundown_Starting);
		VisibleTimerBase.Logger.LogDebug((object)$"set new max timer: {timeUntilSundown_Starting}");
		if (MatchSettingsManager.Singleton.sundownNever)
		{
			VisibleTimerBase.Logger.LogDebug((object)"no sundown detected, returning");
			SetVisibility(visible: false);
		}
		else
		{
			SetVisibility(visible: true);
		}
	}
}
public class TumbleweedTimer : VisibleTimerBase
{
	public Tumbleweed tumbleweedScript;

	public TumbleweedTimer mainScript;

	public float localTime;

	public override void Start()
	{
		ref Tumbleweed reference = ref tumbleweedScript;
		MonoBehaviour script = ((Component)((Component)this).transform.parent).GetComponent<VTComponentContainer>().script;
		reference = (Tumbleweed)(object)((script is Tumbleweed) ? script : null);
		VTComponentContainer component = ((Component)tumbleweedScript).GetComponent<VTComponentContainer>();
		if (!Object.op_Implicit((Object)(object)component))
		{
			((Component)tumbleweedScript).gameObject.AddComponent<VTComponentContainer>().script = (MonoBehaviour)(object)this;
		}
		else
		{
			mainScript = component.script as TumbleweedTimer;
		}
		localTime = tumbleweedScript.burnLifeTime_Max;
		SetTimerCurrent(localTime);
		SetTimerMax(tumbleweedScript.burnLifeTime_Max);
		startVisible = tumbleweedScript.fireParticles.activeSelf;
		base.Start();
	}

	public override void GenerateDefaultConfigData(string configName = null, bool defaultDisplayed = true, TimerType defaultType = TimerType.Text, VisibilityType defaultVisibility = VisibilityType.Everyone, Vector4 defaultColorPrimary = default(Vector4), Vector4 defaultColorSecondary = default(Vector4), Vector3 defaultObjectSize = default(Vector3), float defaultVerticalOffset = 1f, bool defaultShowArrow = true, int defaultTextDecimals = 2, bool defaultMinuteNotation = true, int defaultBackgroundOpacity = 50, float defaultRecolorInterval = 1f, int defaultRefreshRate = 1)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: 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)
		configName = VTAssetsCollection.tumbleweedCategoryName;
		defaultDisplayed = true;
		defaultType = TimerType.Circle;
		defaultVisibility = VisibilityType.Everyone;
		((Vector4)(ref defaultColorPrimary))..ctor(1f, 1f, 1f, 1f);
		((Vector4)(ref defaultColorSecondary))..ctor(0f, 0f, 0f, 1f);
		((Vector3)(ref defaultObjectSize))..ctor(1f, 1f, 1f);
		defaultVerticalOffset = 1f;
		defaultShowArrow = true;
		defaultTextDecimals = 0;
		defaultMinuteNotation = true;
		defaultBackgroundOpacity = 25;
		defaultRecolorInterval = 1f;
		defaultRefreshRate = 1;
		base.GenerateDefaultConfigData(configName, defaultDisplayed, defaultType, defaultVisibility, defaultColorPrimary, defaultColorSecondary, defaultObjectSize, defaultVerticalOffset, defaultShowArrow, defaultTextDecimals, defaultMinuteNotation, defaultBackgroundOpacity, defaultRecolorInterval, defaultRefreshRate);
	}

	public override void Update()
	{
		if (Object.op_Implicit((Object)(object)tumbleweedScript))
		{
			if (((NetworkBehaviour)tumbleweedScript).IsHost)
			{
				localTime = tumbleweedScript.burnLifeTime;
			}
			else if (Object.op_Implicit((Object)(object)mainScript))
			{
				localTime = mainScript.GetTimerCurrent();
			}
			else if (tumbleweedScript.fireParticles.activeSelf)
			{
				localTime -= Time.deltaTime;
			}
		}
		base.Update();
	}

	public override void RetrieveTimerCurrent()
	{
		if (currentlyVisible)
		{
			SetTimerCurrent(localTime);
		}
	}
}
public abstract class VisibleTimerBase : MonoBehaviour
{
	public static ManualLogSource Logger;

	[Header("Timer")]
	public TimerConfigDefaults timerData;

	[Space]
	public TextMeshProUGUI textContainer;

	public Image arrowImage;

	public Image circleFillImage;

	public Image circleBorderImage;

	public Image barFillImage;

	public Image barBackerImage;

	private Image[] allImages;

	private float timerCurrent;

	private float timerMax;

	private TimerHUDComponents hudComponents;

	[Space(3f)]
	[Header("Runtime")]
	public bool startVisible;

	public bool currentlyVisible;

	public GameObject followObject;

	private Renderer followObjectRenderer;

	private Camera playerCam;

	private TimerType lastTimerType;

	private bool setUpInitialVisibility;

	private int framesWaited;

	private float gradientCooldown;

	private float specialVisualsTimer;

	private bool undergroundAtCheckPrevious;

	private bool forceVisibilityOff;

	private void Awake()
	{
		if (Object.op_Implicit((Object)(object)TimersManager.Singleton))
		{
			TimersManager.Singleton.AddTimer(this);
		}
		hudComponents = Object.Instantiate<GameObject>(VTAssetsCollection.timerHUDPrefab, ((Component)this).transform).GetComponent<TimerHUDComponents>();
		if (!Object.op_Implicit((Object)(object)hudComponents))
		{
			Logger.LogError((object)"did not spawn with TimerHUDComponents");
			DisableSelf();
		}
		else
		{
			hudComponents.GetTimerHUDComponents(this);
			allImages = ((Component)this).GetComponentsInChildren<Image>(true);
			ApplyAssets();
		}
	}

	public virtual void Start()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: 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_0019: 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)
		GenerateDefaultConfigData();
	}

	public virtual void Update()
	{
		//IL_0392: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_03df: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0403: Unknown result type (might be due to invalid IL or missing references)
		//IL_0408: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
		if (!setUpInitialVisibility)
		{
			SetUpInitialVisibility();
		}
		if (currentlyVisible)
		{
			framesWaited++;
			if (framesWaited >= timerData.timerRefreshRate)
			{
				RetrieveTimerCurrent();
				framesWaited = 0;
			}
			float currentTimerPercentage = GetCurrentTimerPercentage();
			switch (timerData.timerType)
			{
			case TimerType.Text:
			{
				string text = "";
				if (timerData.timerTextMinutes)
				{
					TimeSpan timeSpan = TimeSpan.FromSeconds(timerCurrent);
					string text2 = "";
					string text3 = ((timerMax >= 36000f) ? "hh" : "h");
					string text4 = ((timerMax >= 600f) ? "mm" : "m");
					string text5 = "";
					if (timerData.timerTextDecimals > 0)
					{
						for (int i = 0; i < timerData.timerTextDecimals; i++)
						{
							text5 += "f";
						}
					}
					text2 = ((timerMax >= 3600f && timerData.timerTextDecimals > 0) ? (text3 + "\\:" + text4 + "\\:ss\\," + text5) : ((timerMax >= 3600f && timerData.timerTextDecimals <= 0) ? (text3 + "\\:" + text4 + "\\:ss") : ((!(timerMax < 3600f) || timerData.timerTextDecimals <= 0) ? (text4 + "\\:ss") : (text4 + "\\:ss\\," + text5))));
					text = timeSpan.ToString(text2);
				}
				else
				{
					text = timerCurrent.ToString($"F{timerData.timerTextDecimals}");
				}
				((TMP_Text)textContainer).text = text;
				break;
			}
			case TimerType.Circle:
				circleFillImage.fillAmount = currentTimerPercentage;
				break;
			case TimerType.Bar:
				barFillImage.fillAmount = currentTimerPercentage;
				break;
			}
			if (timerData.timerColorPrimary != timerData.timerColorSecondary)
			{
				if (gradientCooldown <= 0f)
				{
					Vector4 val = Vector4.Lerp(timerData.timerColorPrimary, timerData.timerColorSecondary, 1f - currentTimerPercentage);
					Image[] array = allImages;
					for (int j = 0; j < array.Length; j++)
					{
						((Graphic)array[j]).color = Color.op_Implicit(val);
					}
					((Graphic)textContainer).color = Color.op_Implicit(val);
					gradientCooldown = timerData.timerRecoloringInterval;
					KeepBarBackerOpacity();
					if (timerData.timerType != lastTimerType)
					{
						SetVisibility(visible: true);
						lastTimerType = timerData.timerType;
						Logger.LogDebug((object)$"!!detected timerType change to {lastTimerType}!!");
					}
				}
				else
				{
					gradientCooldown -= Time.deltaTime;
				}
			}
			if (timerData.visibilityType != VisibilityType.PardnersOnly)
			{
				if (specialVisualsTimer > 0f)
				{
					specialVisualsTimer -= Time.deltaTime;
				}
				else
				{
					specialVisualsTimer = 0.25f;
					DoSpecialVisualsCheck();
				}
			}
		}
		if (Object.op_Implicit((Object)(object)followObject))
		{
			if (currentlyVisible)
			{
				((Component)this).transform.position = followObject.transform.position + Vector3.up * timerData.timerVerticalOffset;
				if (Object.op_Implicit((Object)(object)playerCam))
				{
					((Component)this).transform.LookAt(((Component)this).transform.position + ((Component)playerCam).transform.rotation * Vector3.forward, ((Component)playerCam).transform.rotation * Vector3.up);
				}
			}
		}
		else
		{
			DisableSelf();
		}
	}

	private void SetUpInitialVisibility()
	{
		//IL_0035: 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_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		setUpInitialVisibility = true;
		lastTimerType = timerData.timerType;
		framesWaited = timerData.timerRefreshRate;
		((Component)this).transform.localScale = new Vector3(((Component)this).transform.localScale.x * timerData.timerObjectSize.x, ((Component)this).transform.localScale.y * timerData.timerObjectSize.y, ((Component)this).transform.localScale.z * timerData.timerObjectSize.z);
		SetStartingColor();
		SetVisibility(startVisible);
		SetFollowObject(((Component)((Component)this).transform.parent).gameObject);
		((MonoBehaviour)this).StartCoroutine(GetLocalPlayerCamOnDelay());
	}

	private IEnumerator GetLocalPlayerCamOnDelay()
	{
		yield return (object)new WaitUntil((Func<bool>)(() => Object.op_Implicit((Object)(object)GameManager.Singleton) && (Object.op_Implicit((Object)(object)GameManager.Singleton.localPlayerObject) || (int)GameManager.Singleton.playerType == 2)));
		if ((timerData.visibilityType == VisibilityType.PardnersOnly && (int)GameManager.Singleton.playerType == 1) || (timerData.visibilityType == VisibilityType.WormsOnly && (int)GameManager.Singleton.playerType == 0))
		{
			Logger.LogDebug((object)$"INCOMPATIBLE VisibilityType ON {this}: visibilityType = {timerData.visibilityType} && playerType = {GameManager.Singleton.playerType}");
			DisableSelf();
		}
		else
		{
			SetPlayerCam(GameManager.Singleton.activeCamera);
		}
		DoSpecialVisualsCheck(forceParent: true);
	}

	private void DoSpecialVisualsCheck(bool forceParent = false)
	{
		bool flag = false;
		if (Object.op_Implicit((Object)(object)GameManager.Singleton) && Object.op_Implicit((Object)(object)GameManager.Singleton.localWormScript))
		{
			if (!GameManager.Singleton.localWormScript.aboveGround.Value)
			{
				flag = true;
			}
			if (Object.op_Implicit((Object)(object)followObjectRenderer) && Object.op_Implicit((Object)(object)followObjectRenderer.material) && followObjectRenderer.material.HasFloat("_Dissolve"))
			{
				if (followObjectRenderer.material.GetFloat("_Dissolve") >= 1f)
				{
					if (!forceVisibilityOff)
					{
						SetForceVisibilityOff(fVisibility: true);
					}
				}
				else if (forceVisibilityOff)
				{
					SetForceVisibilityOff(fVisibility: false);
				}
			}
		}
		if (forceParent || flag != undergroundAtCheckPrevious)
		{
			((Component)this).transform.SetParent(flag ? TimersManager.Singleton.underGroundCanvas : TimersManager.Singleton.aboveGroundCanvas, false);
			undergroundAtCheckPrevious = flag;
		}
	}

	public void ApplyAssets()
	{
		arrowImage.sprite = VTAssetsCollection.arrowSprite;
		circleFillImage.sprite = VTAssetsCollection.gripFullSprite;
		circleBorderImage.sprite = VTAssetsCollection.gripBorderSprite;
		barFillImage.sprite = VTAssetsCollection.sprintHealthSprite;
		barBackerImage.sprite = VTAssetsCollection.sprintHealthSprite;
		((TMP_Text)textContainer).font = VTAssetsCollection.turncoatFont;
		Image[] array = allImages;
		for (int i = 0; i < array.Length; i++)
		{
			((Graphic)array[i]).material = VTAssetsCollection.materialUI;
		}
	}

	public void DisableSelf()
	{
		Logger.LogDebug((object)("DisableSelf() on " + ((Object)this).name));
		if (Object.op_Implicit((Object)(object)TimersManager.Singleton))
		{
			TimersManager.Singleton.RemoveTimer(this);
		}
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}

	private float GetCurrentTimerPercentage()
	{
		return timerCurrent / timerMax;
	}

	public virtual void RetrieveTimerCurrent()
	{
	}

	public void SetForceVisibilityOff(bool fVisibility)
	{
		forceVisibilityOff = fVisibility;
		SetVisibility(currentlyVisible);
	}

	public void SetVisibility(bool visible)
	{
		currentlyVisible = visible;
		Logger.LogDebug((object)$"{((Object)this).name} currentlyVisible? {currentlyVisible} // forceVisibilityOff? {forceVisibilityOff}");
		if (!visible || forceVisibilityOff)
		{
			((Behaviour)textContainer).enabled = false;
			Image[] array = allImages;
			for (int i = 0; i < array.Length; i++)
			{
				((Behaviour)array[i]).enabled = false;
			}
		}
		else
		{
			((Behaviour)textContainer).enabled = timerData.timerType == TimerType.Text;
			((Behaviour)circleBorderImage).enabled = timerData.timerType == TimerType.Circle;
			((Behaviour)circleFillImage).enabled = timerData.timerType == TimerType.Circle;
			((Behaviour)barBackerImage).enabled = timerData.timerType == TimerType.Bar;
			((Behaviour)barFillImage).enabled = timerData.timerType == TimerType.Bar;
			((Behaviour)arrowImage).enabled = timerData.timerShowsArrow;
			SetStartingColor();
			SetArrowOffset();
		}
	}

	public void SetFollowObject(GameObject gObject)
	{
		followObject = gObject;
		followObjectRenderer = gObject.GetComponentInChildren<Renderer>(false);
		if (Application.isEditor)
		{
			Logger.LogDebug((object)$"SetFollowObject(): followObject = {followObject} // followObjectRenderer = {followObjectRenderer}");
		}
	}

	public void SetPlayerCam(Camera pCam)
	{
		playerCam = pCam;
		if (Application.isEditor)
		{
			Logger.LogDebug((object)$"SetPlayerCam(): playerCam = {playerCam}");
		}
	}

	private void SetStartingColor()
	{
		//IL_0014: 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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		Image[] array = allImages;
		for (int i = 0; i < array.Length; i++)
		{
			((Graphic)array[i]).color = Color.op_Implicit(timerData.timerColorPrimary);
		}
		((Graphic)textContainer).color = Color.op_Implicit(timerData.timerColorPrimary);
		KeepBarBackerOpacity();
		gradientCooldown = 0f;
	}

	private void KeepBarBackerOpacity()
	{
		//IL_000c: 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_002c: 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_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		((Graphic)barBackerImage).color = Color.op_Implicit(new Vector4(((Graphic)barBackerImage).color.r, ((Graphic)barBackerImage).color.g, ((Graphic)barBackerImage).color.b, ((Graphic)barBackerImage).color.a * ((float)timerData.timerBackgroundOpacity / 100f)));
	}

	private void SetArrowOffset()
	{
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: 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)
		Transform arrowOffset = hudComponents.arrowOffset;
		float num = 0f;
		if (timerData.timerShowsArrow)
		{
			if (timerData.timerVerticalOffset >= 0f)
			{
				num = 75f;
				((Component)arrowImage).transform.localEulerAngles = new Vector3(0f, 0f, 0f);
			}
			else
			{
				num = -75f;
				((Component)arrowImage).transform.localEulerAngles = new Vector3(0f, 0f, 180f);
			}
		}
		arrowOffset.localPosition = new Vector3(arrowOffset.localPosition.x, num, arrowOffset.localPosition.z);
	}

	public void SetTimerMax(float tMax)
	{
		timerMax = tMax;
	}

	public float GetTimerMax()
	{
		return timerMax;
	}

	public void SetTimerCurrent(float tCurrent)
	{
		timerCurrent = tCurrent;
	}

	public float GetTimerCurrent()
	{
		return timerCurrent;
	}

	public virtual void GenerateDefaultConfigData(string configName = null, bool defaultDisplayed = true, TimerType defaultType = TimerType.Text, VisibilityType defaultVisibility = VisibilityType.Everyone, Vector4 defaultColorPrimary = default(Vector4), Vector4 defaultColorSecondary = default(Vector4), Vector3 defaultObjectSize = default(Vector3), float defaultVerticalOffset = 1f, bool defaultShowArrow = true, int defaultTextDecimals = 2, bool defaultMinuteNotation = true, int defaultBackgroundOpacity = 25, float defaultRecolorInterval = 1f, int defaultRefreshRate = 1)
	{
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: 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)
		if (string.IsNullOrEmpty(configName))
		{
			configName = ((Object)((Component)this).gameObject).name.Replace("(Clone)", "") ?? "";
		}
		if (!Object.op_Implicit((Object)(object)timerData))
		{
			timerData = VTConfigs.RetrieveTimerData(configName);
			if (!Object.op_Implicit((Object)(object)timerData))
			{
				Logger.LogError((object)("Failed to RetrieveTimerData using configName: \"" + configName + "\""));
				return;
			}
		}
		if (!timerData.timerEnabled)
		{
			DisableSelf();
			return;
		}
		if (timerData.hasDefaultValues)
		{
			if (Application.isEditor)
			{
				Logger.LogDebug((object)$"{this} already has timerData, not overwriting it");
			}
			return;
		}
		timerData.timerName = configName;
		timerData.timerEnabled = defaultDisplayed;
		timerData.timerType = defaultType;
		timerData.visibilityType = defaultVisibility;
		timerData.timerColorPrimary = defaultColorPrimary;
		timerData.timerColorSecondary = defaultColorSecondary;
		timerData.timerObjectSize = defaultObjectSize;
		timerData.timerVerticalOffset = defaultVerticalOffset;
		timerData.timerShowsArrow = defaultShowArrow;
		timerData.timerTextDecimals = defaultTextDecimals;
		timerData.timerTextMinutes = defaultMinuteNotation;
		timerData.timerBackgroundOpacity = defaultBackgroundOpacity;
		timerData.timerRecoloringInterval = defaultRecolorInterval;
		timerData.timerRefreshRate = defaultRefreshRate;
		VTConfigs.AutoGenerateConfigsForVisibleTimer(this);
		timerData.hasDefaultValues = true;
	}
}
internal class VTConfigs
{
	private static ManualLogSource Logger;

	public static ConfigFile runtimeConfigFile;

	private static List<TimerConfigDefaults> allRegisteredTimers = new List<TimerConfigDefaults>();

	private static Dictionary<string, TimerConfigDefaults> autoGeneratedData = new Dictionary<string, TimerConfigDefaults>();

	public static void AutoGenerateConfigsForVisibleTimer(VisibleTimerBase timer)
	{
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Expected O, but got Unknown
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Expected O, but got Unknown
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Expected O, but got Unknown
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Expected O, but got Unknown
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Expected O, but got Unknown
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Expected O, but got Unknown
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Expected O, but got Unknown
		//IL_0290: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Expected O, but got Unknown
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Expected O, but got Unknown
		//IL_030f: Unknown result type (might be due to invalid IL or missing references)
		//IL_031a: Expected O, but got Unknown
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0356: Expected O, but got Unknown
		//IL_038e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0399: Expected O, but got Unknown
		if (!Object.op_Implicit((Object)(object)timer) || !Object.op_Implicit((Object)(object)timer.timerData) || allRegisteredTimers == null)
		{
			return;
		}
		for (int i = 0; i < allRegisteredTimers.Count; i++)
		{
			TimerConfigDefaults timerConfigDefaults = allRegisteredTimers[i];
			if (Object.op_Implicit((Object)(object)timerConfigDefaults) && (Object)(object)timerConfigDefaults == (Object)(object)timer.timerData)
			{
				return;
			}
		}
		string timerName = timer.timerData.timerName;
		timer.timerData.timerEnabled = (bool)BindConfig(timerName, "Display Timer", timer.timerData.timerEnabled, new ConfigDescription("Enable a visible timer on the " + timerName + ".", (AcceptableValueBase)null, Array.Empty<object>()));
		timer.timerData.timerType = (TimerType)BindConfig(timerName, "Timer Type", timer.timerData.timerType, new ConfigDescription("Set how the timer will be visualized.", (AcceptableValueBase)null, Array.Empty<object>()));
		timer.timerData.visibilityType = (VisibilityType)BindConfig(timerName, "Visible To", timer.timerData.visibilityType, new ConfigDescription("Set which teams can see this timer.", (AcceptableValueBase)null, Array.Empty<object>()));
		timer.timerData.timerColorPrimary = (Vector4)BindConfig(timerName, "Starting Color Timer", timer.timerData.timerColorPrimary, new ConfigDescription("Set the color of the timer at its beginning.\nx = Red.\ny = Green.\nz = Blue.\nw = Opacity.", (AcceptableValueBase)null, Array.Empty<object>()));
		timer.timerData.timerColorSecondary = (Vector4)BindConfig(timerName, "Ending Color Timer", timer.timerData.timerColorSecondary, new ConfigDescription("Set the color of the timer at its end.\nx = Red.\ny = Green.\nz = Blue.\nw = Opacity.", (AcceptableValueBase)null, Array.Empty<object>()));
		timer.timerData.timerObjectSize = (Vector3)BindConfig(timerName, "Size of Timer", timer.timerData.timerObjectSize, new ConfigDescription("Set how large the timer will be.", (AcceptableValueBase)null, Array.Empty<object>()));
		timer.timerData.timerVerticalOffset = (float)BindConfig(timerName, "Height of Timer", timer.timerData.timerVerticalOffset, new ConfigDescription("Set how high above the " + timerName + " the timer will be displayed.", (AcceptableValueBase)null, Array.Empty<object>()));
		timer.timerData.timerShowsArrow = (bool)BindConfig(timerName, "Arrow below Timer", timer.timerData.timerShowsArrow, new ConfigDescription("Show an arrow pointing from the timer to the " + timerName + ".", (AcceptableValueBase)null, Array.Empty<object>()));
		timer.timerData.timerTextDecimals = (int)BindConfig(timerName, "Decimals of Timer", timer.timerData.timerTextDecimals, new ConfigDescription("If [Timer Type] is set to Text, set how many decimals are behind the comma.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 4), Array.Empty<object>()));
		timer.timerData.timerTextMinutes = (bool)BindConfig(timerName, "Timer Minute Notation", timer.timerData.timerTextMinutes, new ConfigDescription("If [Timer Type] is set to Text, set whether time will be displayed in Minutes:Seconds or only in seconds.", (AcceptableValueBase)null, Array.Empty<object>()));
		timer.timerData.timerBackgroundOpacity = (int)BindConfig(timerName, "Bar Opacity Timer", timer.timerData.timerBackgroundOpacity, new ConfigDescription("If [Timer Type] is set to Bar, set how opaque the background of the visible timer is.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
		timer.timerData.timerRecoloringInterval = (float)BindConfig(timerName, "Interval Recolor Timer", timer.timerData.timerRecoloringInterval, new ConfigDescription("If [Starting Color Timer] and [Ending Color Timer] are different values, set how often the color should update, in seconds.\nHigher values look less fluid but could result in better performance.", (AcceptableValueBase)null, Array.Empty<object>()));
		timer.timerData.timerRefreshRate = (int)BindConfig(timerName, "Check Timer per X Frames", timer.timerData.timerRefreshRate, new ConfigDescription("Set per how many frames the timer should read out its in-game values.\nSetting this to 1 checks every frame. Higher values look less fluid but could result in better performance.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 60), Array.Empty<object>()));
		allRegisteredTimers.Add(timer.timerData);
		runtimeConfigFile.Save();
	}

	public static object BindConfig(string categoryName, string configName, object defaultValue, ConfigDescription configDescription, bool saveOnSuccess = false)
	{
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		if (string.IsNullOrEmpty(categoryName) || string.IsNullOrEmpty(configName))
		{
			if (Application.isEditor)
			{
				Logger.LogError((object)"BindConfigs(): A");
			}
			return null;
		}
		Type type = defaultValue.GetType();
		if (type == typeof(bool))
		{
			defaultValue = runtimeConfigFile.Bind<bool>(categoryName, configName, (bool)defaultValue, configDescription).Value;
		}
		else if (type == typeof(int))
		{
			defaultValue = runtimeConfigFile.Bind<int>(categoryName, configName, (int)defaultValue, configDescription).Value;
		}
		else if (type == typeof(float))
		{
			defaultValue = runtimeConfigFile.Bind<float>(categoryName, configName, (float)defaultValue, configDescription).Value;
		}
		else if (type == typeof(Vector3))
		{
			defaultValue = runtimeConfigFile.Bind<Vector3>(categoryName, configName, (Vector3)defaultValue, configDescription).Value;
		}
		else if (type == typeof(Vector4))
		{
			defaultValue = runtimeConfigFile.Bind<Vector4>(categoryName, configName, (Vector4)defaultValue, configDescription).Value;
		}
		else if (type == typeof(TimerType))
		{
			defaultValue = runtimeConfigFile.Bind<TimerType>(categoryName, configName, (TimerType)defaultValue, configDescription).Value;
		}
		else
		{
			if (!(type == typeof(VisibilityType)))
			{
				if (Application.isEditor)
				{
					Logger.LogError((object)"BindConfigs(): B");
				}
				return null;
			}
			defaultValue = runtimeConfigFile.Bind<VisibilityType>(categoryName, configName, (VisibilityType)defaultValue, configDescription).Value;
		}
		Logger.LogDebug((object)$"Successfully bound Config \"{GetFullName(categoryName, configName)}\" with Value {defaultValue}.");
		return defaultValue;
	}

	public static TimerConfigDefaults GetConfigValue(string timerName)
	{
		if (!string.IsNullOrEmpty(timerName) && allRegisteredTimers != null && allRegisteredTimers.Count != 0)
		{
			for (int i = 0; i < allRegisteredTimers.Count; i++)
			{
				TimerConfigDefaults timerConfigDefaults = allRegisteredTimers[i];
				if (Object.op_Implicit((Object)(object)timerConfigDefaults) && !string.IsNullOrEmpty(timerName) && timerConfigDefaults.timerName == timerName)
				{
					return timerConfigDefaults;
				}
			}
		}
		return RetrieveTimerData(timerName);
	}

	public static TimerConfigDefaults RetrieveTimerData(string configName)
	{
		if (autoGeneratedData == null || string.IsNullOrEmpty(configName))
		{
			return null;
		}
		if (autoGeneratedData.TryGetValue(configName, out var value))
		{
			return value;
		}
		TimerConfigDefaults timerConfigDefaults = ScriptableObject.CreateInstance<TimerConfigDefaults>();
		((Object)timerConfigDefaults).name = configName;
		autoGeneratedData.Add(configName, timerConfigDefaults);
		Logger.LogDebug((object)$"Generated and registered new TimerConfigDefaults \"{timerConfigDefaults}\".");
		return timerConfigDefaults;
	}

	private static string GetFullName(string categoryName, string configName)
	{
		return categoryName + " - " + configName;
	}

	public static bool DisplayTimer(string categoryName)
	{
		TimerConfigDefaults configValue = GetConfigValue(categoryName);
		if (!Object.op_Implicit((Object)(object)configValue))
		{
			return false;
		}
		return configValue.timerEnabled;
	}
}
internal class VTHarmonyPatches
{
	[HarmonyPatch(typeof(HudManager))]
	public class VisibleTimersPatch_HudManager
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		public static void Awake_Postfix(HudManager __instance)
		{
			VTAssetsCollection.GetAssetsHudManager(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPatch("ShowSunHasSetWarningToPardner")]
		public static void ShowSunHasSetWarningToPardner_Postfix()
		{
			Logger.LogDebug((object)"sunset warning");
			if (!VTConfigs.DisplayTimer(VTAssetsCollection.sunCategoryName) || !Object.op_Implicit((Object)(object)TimersManager.Singleton))
			{
				return;
			}
			SunTimer sunTimer = null;
			foreach (VisibleTimerBase allTimer in TimersManager.Singleton.allTimers)
			{
				if (Object.op_Implicit((Object)(object)allTimer) && allTimer is SunTimer)
				{
					sunTimer = allTimer as SunTimer;
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)sunTimer))
			{
				sunTimer.SetVisibility(visible: false);
			}
		}
	}

	[HarmonyPatch(typeof(LootManager))]
	public class VisibleTimersPatch_LootManager
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		public static void Awake_Postfix(LootManager __instance)
		{
			Dynamite_DummyHandler componentInChildren = __instance.dynamitePrefab.GetComponentInChildren<Dynamite_DummyHandler>();
			if (Object.op_Implicit((Object)(object)componentInChildren) && !Object.op_Implicit((Object)(object)((Component)componentInChildren).GetComponent<VTComponentContainer>()))
			{
				((Component)componentInChildren).gameObject.AddComponent<VTComponentContainer>().script = (MonoBehaviour)(object)__instance.dynamitePrefab.GetComponent<Dynamite>();
			}
		}
	}

	[HarmonyPatch(typeof(ObjectiveHandler))]
	public class VisibleTimersPatch_ObjectiveHandler
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		public static void Awake_Postfix(ObjectiveHandler __instance)
		{
			Tumbleweed_DummyHandler componentInChildren = __instance.tumbleweed_Prefab.GetComponentInChildren<Tumbleweed_DummyHandler>();
			if (Object.op_Implicit((Object)(object)componentInChildren) && !Object.op_Implicit((Object)(object)((Component)componentInChildren).GetComponent<VTComponentContainer>()))
			{
				((Component)componentInChildren).gameObject.AddComponent<VTComponentContainer>().script = (MonoBehaviour)(object)__instance.tumbleweed_Prefab.GetComponent<Tumbleweed>();
			}
			Tumbleweed_DummyHandler componentInChildren2 = __instance.winterTumbleweed_Prefab.GetComponentInChildren<Tumbleweed_DummyHandler>();
			if (Object.op_Implicit((Object)(object)componentInChildren2) && !Object.op_Implicit((Object)(object)((Component)componentInChildren2).GetComponent<VTComponentContainer>()))
			{
				((Component)componentInChildren2).gameObject.AddComponent<VTComponentContainer>().script = (MonoBehaviour)(object)__instance.winterTumbleweed_Prefab.GetComponent<Tumbleweed>();
			}
		}
	}

	[HarmonyPatch(typeof(Dynamite))]
	public class VisibleTimersPatch_Dynamite
	{
		[HarmonyPostfix]
		[HarmonyPatch("ShowFuseParticles")]
		public static void ShowFuseParticles_Postfix(Dynamite __instance)
		{
			Logger.LogDebug((object)"light DYNAMITE on MAIN");
			if (!VTConfigs.DisplayTimer(VTAssetsCollection.dynamiteCategoryName) || !Object.op_Implicit((Object)(object)TimersManager.Singleton))
			{
				return;
			}
			Dynamite_DummyHandler componentInChildren = ((Component)__instance).GetComponentInChildren<Dynamite_DummyHandler>();
			if (!Object.op_Implicit((Object)(object)componentInChildren))
			{
				Logger.LogError((object)$"failed to find dummy on #{((NetworkBehaviour)__instance).NetworkObjectId}");
				return;
			}
			DynamiteTimer dynamiteTimer = null;
			foreach (VisibleTimerBase allTimer in TimersManager.Singleton.allTimers)
			{
				if (Object.op_Implicit((Object)(object)allTimer) && (Object)(object)allTimer.followObject == (Object)(object)((Component)componentInChildren).gameObject && allTimer is DynamiteTimer)
				{
					dynamiteTimer = allTimer as DynamiteTimer;
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)dynamiteTimer))
			{
				dynamiteTimer.SetVisibility(visible: true);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("MakeBoomBoom_ClientRPC")]
		public static void MakeBoomBoom_ClientRPC_Postfix(Dynamite __instance, Vector3 _explosionPosition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			DynamiteTimer.DoCheckForDynamiteTimer((NetworkBehaviour)(object)__instance, _explosionPosition, Dynamite.CONST_dynamiteRadius);
		}
	}

	[HarmonyPatch(typeof(Dynamite_DummyHandler))]
	public class VisibleTimersPatch_Dynamite_DummyHandler
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void Start_Postfix(Dynamite_DummyHandler __instance)
		{
			Logger.LogDebug((object)"adding timer to dynamite");
			Object.Instantiate<GameObject>(VTAssetsCollection.dynamiteVisibleTimer, ((Component)__instance).transform);
		}

		[HarmonyPostfix]
		[HarmonyPatch("LightDummyFuse")]
		public static void LightDummyFuse_Postfix(Dynamite_DummyHandler __instance)
		{
			Logger.LogDebug((object)"light DYNAMITE on DUMMY");
			if (!VTConfigs.DisplayTimer(VTAssetsCollection.dynamiteCategoryName) || !Object.op_Implicit((Object)(object)TimersManager.Singleton))
			{
				return;
			}
			DynamiteTimer dynamiteTimer = null;
			foreach (VisibleTimerBase allTimer in TimersManager.Singleton.allTimers)
			{
				if (Object.op_Implicit((Object)(object)allTimer) && (Object)(object)allTimer.followObject == (Object)(object)((Component)__instance).gameObject && allTimer is DynamiteTimer)
				{
					dynamiteTimer = allTimer as DynamiteTimer;
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)dynamiteTimer))
			{
				dynamiteTimer.SetVisibility(visible: true);
			}
		}
	}

	[HarmonyPatch(typeof(Tumbleweed))]
	public class VisibleTimersPatch_Tumbleweed
	{
		[HarmonyPostfix]
		[HarmonyPatch("ShowFireParticles")]
		public static void ShowFireParticles_Postfix(Tumbleweed __instance)
		{
			Logger.LogDebug((object)"light TUMBLEWEED on MAIN");
			if (!VTConfigs.DisplayTimer(VTAssetsCollection.tumbleweedCategoryName) || !Object.op_Implicit((Object)(object)TimersManager.Singleton))
			{
				return;
			}
			Tumbleweed_DummyHandler componentInChildren = ((Component)__instance).GetComponentInChildren<Tumbleweed_DummyHandler>();
			if (!Object.op_Implicit((Object)(object)componentInChildren))
			{
				Logger.LogError((object)$"failed to find dummy on #{((NetworkBehaviour)__instance).NetworkObjectId}");
				return;
			}
			TumbleweedTimer tumbleweedTimer = null;
			foreach (VisibleTimerBase allTimer in TimersManager.Singleton.allTimers)
			{
				if (Object.op_Implicit((Object)(object)allTimer) && (Object)(object)allTimer.followObject == (Object)(object)((Component)componentInChildren).gameObject && allTimer is TumbleweedTimer)
				{
					tumbleweedTimer = allTimer as TumbleweedTimer;
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)tumbleweedTimer))
			{
				tumbleweedTimer.SetVisibility(visible: true);
			}
		}
	}

	[HarmonyPatch(typeof(Tumbleweed_DummyHandler))]
	public class VisibleTimersPatch_Tumbleweed_DummyHandler
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void Start_Postfix(Tumbleweed_DummyHandler __instance)
		{
			Logger.LogDebug((object)"adding timer to tumbleweed");
			Object.Instantiate<GameObject>(VTAssetsCollection.tumbleweedVisibleTimer, ((Component)__instance).transform);
		}

		[HarmonyPostfix]
		[HarmonyPatch("LightDummyFuse")]
		public static void LightDummyFuse_Postfix(Tumbleweed_DummyHandler __instance)
		{
			Logger.LogDebug((object)"light TUMBLEWEED on DUMMY");
			if (!VTConfigs.DisplayTimer(VTAssetsCollection.tumbleweedCategoryName) || !Object.op_Implicit((Object)(object)TimersManager.Singleton))
			{
				return;
			}
			TumbleweedTimer tumbleweedTimer = null;
			foreach (VisibleTimerBase allTimer in TimersManager.Singleton.allTimers)
			{
				if (Object.op_Implicit((Object)(object)allTimer) && (Object)(object)allTimer.followObject == (Object)(object)((Component)__instance).gameObject && allTimer is TumbleweedTimer)
				{
					tumbleweedTimer = allTimer as TumbleweedTimer;
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)tumbleweedTimer))
			{
				tumbleweedTimer.SetVisibility(visible: true);
			}
		}
	}

	[HarmonyPatch(typeof(TimeOfDayManager))]
	public class VisibleTimersPatch_TimeOfDayManager
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		public static void Awake_Postfix(TimeOfDayManager __instance)
		{
			Logger.LogDebug((object)"adding timer to sun");
			Object.Instantiate<GameObject>(VTAssetsCollection.sunVisibleTimer, __instance.sunObject.transform);
		}

		[HarmonyPostfix]
		[HarmonyPatch("SetSundownTimerFromMatchSettings")]
		public static void SetSundownTimerFromMatchSettings_Postfix()
		{
			if (!VTConfigs.DisplayTimer(VTAssetsCollection.sunCategoryName) || !Object.op_Implicit((Object)(object)TimersManager.Singleton))
			{
				return;
			}
			SunTimer sunTimer = null;
			foreach (VisibleTimerBase allTimer in TimersManager.Singleton.allTimers)
			{
				if (Object.op_Implicit((Object)(object)allTimer) && allTimer is SunTimer)
				{
					sunTimer = allTimer as SunTimer;
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)sunTimer))
			{
				sunTimer.SetNewMaxTimer();
			}
		}
	}

	[HarmonyPatch(typeof(StatusEffectsHandler))]
	public class VisibleTimersPatch_StatusEffectsHandler
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void Start_Postfix(StatusEffectsHandler __instance)
		{
			Logger.LogDebug((object)"adding timers to status effect handler");
			Object.Instantiate<GameObject>(VTAssetsCollection.staminaVisibleTimer, ((Component)__instance).transform).GetComponent<InfinistaminaTimer>().handlerLocal = __instance.ourNetworkObject.IsOwner;
			Object.Instantiate<GameObject>(VTAssetsCollection.coffeeVisibleTimer, ((Component)__instance).transform).GetComponent<CoffeeTimer>().handlerLocal = __instance.ourNetworkObject.IsOwner;
		}

		[HarmonyPostfix]
		[HarmonyPatch("AddParticleEffect_Local")]
		public static void AddParticleEffect_Local_Postfix(StatusEffectsHandler __instance, int _particleEnum)
		{
			if (!Object.op_Implicit((Object)(object)TimersManager.Singleton) || !Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.ourPlayer) || _particleEnum != 3 || !VTConfigs.DisplayTimer(VTAssetsCollection.staminaCategoryName))
			{
				return;
			}
			InfinistaminaTimer infinistaminaTimer = null;
			foreach (VisibleTimerBase allTimer in TimersManager.Singleton.allTimers)
			{
				if (Object.op_Implicit((Object)(object)allTimer) && (Object)(object)allTimer.followObject == (Object)(object)((Component)__instance.ourPlayer).gameObject && allTimer is InfinistaminaTimer)
				{
					infinistaminaTimer = allTimer as InfinistaminaTimer;
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)infinistaminaTimer))
			{
				infinistaminaTimer.StartTimer();
			}
		}
	}

	[HarmonyPatch(typeof(CoffeeShakesHandler))]
	public class VisibleTimersPatch_CoffeeShakesHandler
	{
		[HarmonyPostfix]
		[HarmonyPatch("OnCoffeeShakes_ValueChanged")]
		public static void OnCoffeeShakes_ValueChanged_Postfix(CoffeeShakesHandler __instance)
		{
			if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.pScript) || !__instance.pScript.syncedHasCoffeeShakes.Value || !VTConfigs.DisplayTimer(VTAssetsCollection.coffeeCategoryName))
			{
				return;
			}
			CoffeeTimer coffeeTimer = null;
			foreach (VisibleTimerBase allTimer in TimersManager.Singleton.allTimers)
			{
				if (Object.op_Implicit((Object)(object)allTimer) && (Object)(object)allTimer.followObject == (Object)(object)((Component)__instance.pScript).gameObject && allTimer is CoffeeTimer)
				{
					coffeeTimer = allTimer as CoffeeTimer;
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)coffeeTimer))
			{
				coffeeTimer.StartTimer();
			}
		}
	}

	[HarmonyPatch(typeof(GameManager))]
	public class VisibleTimersPatch_GameManager
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		public static void Awake_Postfix(GameManager __instance)
		{
			Logger.LogDebug((object)"!!spawning TimersManager");
			Object.Instantiate<GameObject>(VTAssetsCollection.managerPrefab);
			Logger.LogDebug((object)"adding timer to train lever");
			Object.Instantiate<GameObject>(VTAssetsCollection.leverVisibleTimer, __instance.trainLeverImage_CannotUse.transform);
		}

		[HarmonyPostfix]
		[HarmonyPatch("CreateExplosionAtPosition_ClientRPC")]
		public static void CreateExplosionAtPosition_ClientRPC_Postfix(GameManager __instance, Vector3 _explosionPosition, float _radius)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			DynamiteTimer.DoCheckForDynamiteTimer((NetworkBehaviour)(object)__instance, _explosionPosition, _radius);
		}
	}

	[HarmonyPatch(typeof(TrainHornManager))]
	public class VisibleTimersPatch_TrainHornManager
	{
		[HarmonyPostfix]
		[HarmonyPatch("ActivateTrainHorn_Locally")]
		public static void ActivateTrainHorn_Locally_Postfix(TrainHornManager __instance)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)__instance))
			{
				return;
			}
			if (VTConfigs.DisplayTimer(VTAssetsCollection.leverCategoryName) && Object.op_Implicit((Object)(object)TimersManager.Singleton))
			{
				Logger.LogDebug((object)"trying to start TrainLever VisibleTimer");
				GameObject trainLeverImage_CannotUse = GameManager.Singleton.trainLeverImage_CannotUse;
				LeverTimer leverTimer = null;
				foreach (VisibleTimerBase allTimer in TimersManager.Singleton.allTimers)
				{
					if (Object.op_Implicit((Object)(object)allTimer) && (Object)(object)allTimer.followObject == (Object)(object)trainLeverImage_CannotUse && allTimer is LeverTimer)
					{
						leverTimer = allTimer as LeverTimer;
						break;
					}
				}
				if (Object.op_Implicit((Object)(object)leverTimer))
				{
					leverTimer.StartTimer();
				}
			}
			if (VTConfigs.DisplayTimer(VTAssetsCollection.blindnessCategoryName))
			{
				BlindnessTimer.Replicate_FindWormsInRadiusAndBlindThem(((Component)__instance).transform.position, __instance.blindDuration, __instance.aoeRadius);
			}
		}
	}

	[HarmonyPatch(typeof(WormlingIceSpike))]
	public class VisibleTimersPatch_WormlingIceSpike
	{
		[HarmonyPostfix]
		[HarmonyPatch("OnNetworkSpawn")]
		public static void OnNetworkSpawn_Postfix(WormlingIceSpike __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance) && __instance.syncedMaxScale.Value == 1f)
			{
				Logger.LogDebug((object)"adding timer to ice spike");
				Object.Instantiate<GameObject>(VTAssetsCollection.icespikeVisibleTimer, ((Component)__instance).transform);
			}
		}
	}

	[HarmonyPatch(typeof(WormlingEgg))]
	public class VisibleTimersPatch_WormlingEgg
	{
		[HarmonyPostfix]
		[HarmonyPatch("OnNetworkSpawn")]
		public static void OnNetworkSpawn_Postfix(WormlingEgg __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.ourPickUpScript) && Object.op_Implicit((Object)(object)__instance.ourPickUpScript.art))
			{
				VTComponentContainer vTComponentContainer = __instance.ourPickUpScript.art.AddComponent<VTComponentContainer>();
				vTComponentContainer.script = (MonoBehaviour)(object)__instance;
				vTComponentContainer.instantiate = VTAssetsCollection.eggVisibleTimer;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("UpdateEggHealthVisuals")]
		public static void UpdateEggHealthVisuals_Postfix(WormlingEgg __instance)
		{
			if (!Object.op_Implicit((Object)(object)__instance) || ((NetworkBehaviour)__instance).IsHost || !Object.op_Implicit((Object)(object)TimersManager.Singleton) || !Object.op_Implicit((Object)(object)GameManager.Singleton) || !Object.op_Implicit((Object)(object)GameManager.Singleton.localPlayerObject))
			{
				return;
			}
			PlayerGrabber component = GameManager.Singleton.localPlayerObject.GetComponent<PlayerGrabber>();
			for (int i = 0; i < TimersManager.Singleton.allTimers.Count; i++)
			{
				VisibleTimerBase visibleTimerBase = TimersManager.Singleton.allTimers[i];
				if (Object.op_Implicit((Object)(object)visibleTimerBase) && Object.op_Implicit((Object)(object)visibleTimerBase.followObject) && visibleTimerBase is EggTimer)
				{
					EggTimer eggTimer = visibleTimerBase as EggTimer;
					if ((Object)(object)eggTimer.followObject == (Object)(object)__instance.ourPickUpScript.art)
					{
						eggTimer.SnapLocalTimeUsingLatestPercentile();
					}
					if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.heldObjectDummy) && (Object)(object)eggTimer.followObject == (Object)(object)component.heldObjectDummy)
					{
						eggTimer.SnapLocalTimeUsingLatestPercentile();
					}
				}
			}
		}
	}

	[HarmonyPatch(typeof(Wormling_Bomber))]
	public class VisibleTimersPatch_Wormling_Bomber
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void Start_Postfix(Wormling_Bomber __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance))
			{
				Logger.LogDebug((object)"adding timer to bomber");
				VTComponentContainer vTComponentContainer = ((Component)__instance).gameObject.AddComponent<VTComponentContainer>();
				BomberTimer component = Object.Instantiate<GameObject>(VTAssetsCollection.bomberVisibleTimer, ((Component)__instance).transform).GetComponent<BomberTimer>();
				vTComponentContainer.script = (MonoBehaviour)(object)component;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("BeginExplosionCountDown_ClientRPC")]
		public static void BeginExplosionCountDown_ClientRPC_Postfix(Wormling_Bomber __instance)
		{
			if (!VTConfigs.DisplayTimer(VTAssetsCollection.bomberCategoryName) || !Object.op_Implicit((Object)(object)__instance))
			{
				return;
			}
			VTComponentContainer component = ((Component)__instance).GetComponent<VTComponentContainer>();
			if (Object.op_Implicit((Object)(object)component))
			{
				BomberTimer bomberTimer = component.script as BomberTimer;
				if (Object.op_Implicit((Object)(object)bomberTimer))
				{
					bomberTimer.SetVisibility(visible: true);
				}
			}
		}
	}

	[HarmonyPatch(typeof(ShiftingSands_SandShifter))]
	public class VisibleTimersPatch_ShiftingSands_SandShifter
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void Start_Postfix(ShiftingSands_SandShifter __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance))
			{
				Logger.LogDebug((object)"adding timer to sinkhole");
				Object.Instantiate<GameObject>(VTAssetsCollection.sinkholeVisibleTimer, ((Component)__instance).transform);
			}
		}
	}

	[HarmonyPatch(typeof(WormPlayer))]
	public class VisibleTimersPatch_WormPlayer
	{
		[HarmonyPostfix]
		[HarmonyPatch("OnNetworkSpawn")]
		public static void OnNetworkSpawn_Postfix(WormPlayer __instance)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.wormCam))
			{
				return;
			}
			Logger.LogDebug((object)"adding timer to worm player");
			GameObject val = new GameObject(VTAssetsCollection.wormEffectHandlerName);
			Transform transform = ((Component)__instance).transform;
			float num = 0f;
			float num2 = 0f;
			float num3 = 0f;
			if (Object.op_Implicit((Object)(object)GameManager.Singleton.localWormScript) && (Object)(object)GameManager.Singleton.localWormScript == (Object)(object)__instance)
			{
				num = 0f;
				num2 = 1f;
				num3 = 3f;
				if (Object.op_Implicit((Object)(object)__instance.wormCam))
				{
					transform = ((Component)__instance.wormCam).transform;
				}
			}
			else
			{
				num = 0f;
				num2 = 2f;
				num3 = 0f;
			}
			val.transform.localPosition = new Vector3(num, num2, num3);
			val.transform.SetParent(transform, false);
			Object.Instantiate<GameObject>(VTAssetsCollection.blindnessVisibleTimer, val.transform);
		}

		[HarmonyPostfix]
		[HarmonyPatch("OnBlinded")]
		public static void OnBlinded_Postfix(WormPlayer __instance, bool _newVal)
		{
			if (Object.op_Implicit((Object)(object)__instance))
			{
				Transform transform = ((Component)__instance).transform;
				if (Object.op_Implicit((Object)(object)GameManager.Singleton.localWormScript) && (Object)(object)GameManager.Singleton.localWormScript == (Object)(object)__instance && Object.op_Implicit((Object)(object)__instance.wormCam))
				{
					transform = ((Component)__instance.wormCam).transform;
				}
				BlindnessTimer.ToggleVisibilityOnBlindValueChanged(transform, _newVal);
			}
		}
	}

	[HarmonyPatch(typeof(Wormling_Base))]
	public class VisibleTimersPatch_Wormling_Base
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void Start_Postfix(Wormling_Base __instance)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogDebug((object)"adding timer to wormling");
			GameObject val = new GameObject(VTAssetsCollection.wormEffectHandlerName);
			float num = 0f;
			float num2 = 2f;
			float num3 = 0f;
			val.transform.localPosition = new Vector3(num, num2, num3);
			val.transform.SetParent(((Component)__instance).transform, false);
			Object.Instantiate<GameObject>(VTAssetsCollection.blindnessVisibleTimer, val.transform);
		}

		[HarmonyPostfix]
		[HarmonyPatch("Blinded_OnValueChanged")]
		public static void Blinded_OnValueChanged_Postfix(Wormling_Base __instance, bool _newValue)
		{
			if (Object.op_Implicit((Object)(object)__instance))
			{
				BlindnessTimer.ToggleVisibilityOnBlindValueChanged(((Component)__instance).transform, _newValue);
			}
		}
	}

	[HarmonyPatch(typeof(ThrownCymbalMonkey))]
	public class VisibleTimersPatch_ThrownCymbalMonkey
	{
		[HarmonyPostfix]
		[HarmonyPatch("DoOnCymbalCrashEffects_Locally")]
		public static void DoOnCymbalCrashEffects_Locally_Postfix(ThrownCymbalMonkey __instance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)__instance) && VTConfigs.DisplayTimer(VTAssetsCollection.blindnessCategoryName))
			{
				BlindnessTimer.Replicate_FindWormsInRadiusAndBlindThem(((Component)__instance).transform.position, __instance.blindDuration, __instance.aoeRadius);
			}
		}
	}

	private static ManualLogSource Logger;
}
[BepInPlugin("local.SimonTendo.LTOWVisibleTimersMod", "LTOWVisibleTimersMod", "1.2.1")]
internal class VTPlugin : BaseUnityPlugin
{
	internal static ManualLogSource Logger;

	private void Awake()
	{
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		Logger = ((BaseUnityPlugin)this).Logger;
		Logger.LogInfo((object)"Plugin LTOWVisibleTimersMod is loaded!");
		AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "visibletimersbundle"));
		if ((Object)(object)val == (Object)null)
		{
			Logger.LogError((object)"Failed to load AssetBundle");
			return;
		}
		Logger.LogDebug((object)"Successfully loaded AssetBundle");
		SendLoggers();
		VTAssetsCollection.GetAssetsAssetBundle(val);
		new Harmony("LTOWVisibleTimersMod").PatchAll();
		VTConfigs.runtimeConfigFile = ((BaseUnityPlugin)this).Config;
	}

	private static void SendLoggers()
	{
		Type[] types = Assembly.GetExecutingAssembly().GetTypes();
		foreach (Type type in types)
		{
			FieldInfo[] fields = type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)