Decompiled source of SourceSauce v0.1.0

ThatTF2SourceSauce.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using LethalLib.Extras;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using ThatTF2SourceSauce.Spawnables;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ThatTF2SourceSauce")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ThatTF2SourceSauce")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e551068f-cb4d-401b-8b2b-b977b01893d5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ThatTF2SourceSauce
{
	public class JiggleBone : MonoBehaviour
	{
		public Transform targetBone;

		public float stiffness = 10f;

		public float damping = 5f;

		public float maxAngle = 45f;

		private Quaternion originalRotation;

		private Vector3 velocity = Vector3.zero;

		private void Start()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)targetBone != (Object)null)
			{
				originalRotation = targetBone.localRotation;
			}
		}

		private void LateUpdate()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)targetBone == (Object)null))
			{
				Quaternion rotation = targetBone.rotation;
				Quaternion val = originalRotation;
				Quaternion val2 = val * Quaternion.Inverse(rotation);
				Vector3 val3 = new Vector3(val2.x, val2.y, val2.z) * stiffness;
				velocity = Vector3.Lerp(velocity, val3, damping * Time.deltaTime);
				targetBone.rotation = Quaternion.Lerp(rotation, val, stiffness * Time.deltaTime);
				ClampRotation(targetBone, maxAngle);
			}
		}

		private void ClampRotation(Transform bone, float maxAngle)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0050: 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)
			Quaternion localRotation = bone.localRotation;
			Vector3 eulerAngles = ((Quaternion)(ref localRotation)).eulerAngles;
			eulerAngles.x = Mathf.Clamp(eulerAngles.x, 0f - maxAngle, maxAngle);
			eulerAngles.y = Mathf.Clamp(eulerAngles.y, 0f - maxAngle, maxAngle);
			eulerAngles.z = Mathf.Clamp(eulerAngles.z, 0f - maxAngle, maxAngle);
			bone.localRotation = Quaternion.Euler(eulerAngles);
		}
	}
	public static class StatueCreator
	{
		public static GameObject CreateRigidStatue(GameObject skinnedModel)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			SkinnedMeshRenderer componentInChildren = skinnedModel.GetComponentInChildren<SkinnedMeshRenderer>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				Debug.LogError((object)"No SkinnedMeshRenderer found on the model.");
				return null;
			}
			Mesh val = new Mesh();
			componentInChildren.BakeMesh(val);
			GameObject val2 = new GameObject(((Object)skinnedModel).name + "_Statue");
			val2.transform.position = skinnedModel.transform.position;
			val2.transform.rotation = skinnedModel.transform.rotation;
			val2.transform.localScale = skinnedModel.transform.localScale;
			MeshFilter val3 = val2.AddComponent<MeshFilter>();
			val3.mesh = val;
			MeshRenderer val4 = val2.AddComponent<MeshRenderer>();
			((Renderer)val4).materials = ((Renderer)componentInChildren).materials;
			MeshCollider val5 = val2.AddComponent<MeshCollider>();
			val5.sharedMesh = val;
			val5.convex = true;
			Rigidbody val6 = val2.AddComponent<Rigidbody>();
			val6.useGravity = true;
			return val2;
		}
	}
	public class AnimationAudioPlayer : MonoBehaviour
	{
		public AudioClip[] clips = (AudioClip[])(object)new AudioClip[1];

		public AudioSource[] sources = (AudioSource[])(object)new AudioSource[1];

		public AudioSource source = null;

		public void PlaySound(int clipID)
		{
			source.clip = clips[clipID];
			source.Play();
		}

		public void SetAudioSource(int id)
		{
			source = sources[id];
		}
	}
	public class AnimationCopier : MonoBehaviour
	{
		public Transform target;

		public Dictionary<string, Transform> bones = new Dictionary<string, Transform>();

		private void Start()
		{
			if ((Object)(object)target == (Object)null)
			{
				Debug.LogError((object)"Target is not assigned.");
			}
			else
			{
				PopulateBonesDictionary(((Component)this).transform, bones);
			}
		}

		private void LateUpdate()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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)
			if ((Object)(object)target == (Object)null || bones == null)
			{
				return;
			}
			foreach (KeyValuePair<string, Transform> bone in bones)
			{
				string key = bone.Key;
				Transform value = bone.Value;
				Transform val = FindBoneByName(target, key);
				if ((Object)(object)val != (Object)null && (Object)(object)value != (Object)null)
				{
					value.position = val.position;
					value.rotation = val.rotation;
					value.localScale = val.localScale;
				}
			}
		}

		private Transform FindBoneByName(Transform root, string name)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			Transform result = null;
			Stack<Transform> stack = new Stack<Transform>();
			stack.Push(root);
			while (stack.Count > 0)
			{
				Transform val = stack.Pop();
				if (((Object)val).name == name)
				{
					result = val;
					break;
				}
				foreach (Transform item2 in val)
				{
					Transform item = item2;
					stack.Push(item);
				}
			}
			return result;
		}

		private void PopulateBonesDictionary(Transform root, Dictionary<string, Transform> boneDict)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			foreach (Transform item in root)
			{
				Transform val = item;
				if (!boneDict.ContainsKey(((Object)val).name))
				{
					boneDict.Add(((Object)val).name, val);
				}
				PopulateBonesDictionary(val, boneDict);
			}
		}
	}
	public class SourceSauceOverseer : MonoBehaviour
	{
		public static SourceSauceOverseer Instance;

		public string path = string.Empty;

		private AssetBundle viewModelsBundle;

		public bool jobDone;

		public HUDManager hudManager;

		private bool isCoroutineRunning = false;

		public GameObject sentryPrefab;

		public GameObject stickyBomb;

		private void Awake()
		{
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)this);
		}

		private void Update()
		{
			if ((Object)(object)hudManager == (Object)null)
			{
				hudManager = Object.FindObjectOfType<HUDManager>();
				if ((Object)(object)hudManager == (Object)null)
				{
					jobDone = false;
				}
			}
			if (!jobDone && !isCoroutineRunning && (Object)(object)hudManager != (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(LoadAndExtractAssetBundles());
			}
		}

		private IEnumerator LoadAndExtractAssetBundles()
		{
			isCoroutineRunning = true;
			string assetBundlePath = Path.Combine(path, "tf_viewmodels");
			AssetBundleCreateRequest viewModelsBundleRequest = AssetBundle.LoadFromFileAsync(assetBundlePath);
			yield return viewModelsBundleRequest;
			viewModelsBundle = viewModelsBundleRequest.assetBundle;
			ExtractAssets();
			isCoroutineRunning = false;
		}

		private void ExtractAssets()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)viewModelsBundle != (Object)null)
			{
				GameObject val = viewModelsBundle.LoadAsset<GameObject>("SillySourceStuff");
				if ((Object)(object)val != (Object)null && (Object)(object)GameNetworkManager.Instance != (Object)null && !jobDone)
				{
					PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
					GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)localPlayerController.gameplayCamera).transform);
					WeaponViewmodelReplacer component = val2.GetComponent<WeaponViewmodelReplacer>();
					component.target = localPlayerController;
					val2.transform.localPosition = Vector3.zero;
					val2.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
					component.LCViewModel = ((Component)localPlayerController.playerModelArmsMetarig.parent.GetChild(0)).GetComponent<SkinnedMeshRenderer>();
					jobDone = true;
				}
			}
		}

		private void OnDestroy()
		{
			AssetBundle obj = viewModelsBundle;
			if (obj != null)
			{
				obj.Unload(false);
			}
		}
	}
	[BepInPlugin("ChubbzCrew.SourceSauce", "TF2 Source Sauce", "0.0.8")]
	[BepInProcess("Lethal Company.exe")]
	public class TF2SourceSauceHost : BaseUnityPlugin
	{
		public AssetBundle weaponBundle;

		public AssetBundle buildsBundle;

		public void OnDestroy()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_007e: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading TF2 Source Sauce");
			GameObject val = new GameObject("SourceSauceOverseer");
			SourceSauceOverseer sourceSauceOverseer = val.AddComponent<SourceSauceOverseer>();
			sourceSauceOverseer.path = Path.Combine(Paths.PluginPath, "ChubbzCrew-SourceSauce");
			string text = Path.Combine(sourceSauceOverseer.path, "tf2_weapons");
			weaponBundle = AssetBundle.LoadFromFile(text);
			sourceSauceOverseer.stickyBomb = weaponBundle.LoadAsset<GameObject>("Assets/TF2Weapons/Spawnables/Sticky.prefab");
			AnimationCurve spawnCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 1f),
				new Keyframe(0.5f, 2f),
				new Keyframe(1f, 10f)
			});
			InitWeapon("sandman", "tf_Sandman", 15, (LevelTypes)(-1), spawnCurve);
			InitWeapon("atomizer", "tf_Atomizer", 15, (LevelTypes)(-1), spawnCurve);
			InitWeapon("atomizer_blue", "tf_BlueAtomizer", 15, (LevelTypes)(-1), spawnCurve);
			InitWeapon("wrench", "tf_Wrench", 15, (LevelTypes)(-1), spawnCurve);
			InitWeapon("aus_wrench", "tf_ausWrench", 5, (LevelTypes)(-1), spawnCurve);
			InitWeapon("pda", "tf_PDA", 15, (LevelTypes)(-1), spawnCurve);
			InitWeapon("toolbox", "tf_Toolbox", 0, (LevelTypes)1, null);
			InitWeapon("stickybomb", "tf_Stickybomb", 15, (LevelTypes)(-1), spawnCurve);
			InitWeapon("sapper", "tf_Sapper", 15, (LevelTypes)(-1), spawnCurve);
			InitWeapon("knife", "tf_Knife", 15, (LevelTypes)(-1), spawnCurve);
			InitWeapon("aus_knife", "tf_ausKnife", 5, (LevelTypes)(-1), spawnCurve);
			InitWeapon("pan", "tf_pan", 8, (LevelTypes)(-1), spawnCurve);
			InitWeapon("goldpan", "tf_goldpan", 1, (LevelTypes)(-1), spawnCurve);
			InitWeapon("terminaltool", "tf_TerminalTool", 0, (LevelTypes)1, null);
		}

		public void InitWeapon(string folder, string name, int rarity, LevelTypes levels, AnimationCurve spawnCurve)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			Item val = weaponBundle.LoadAsset<Item>("Assets/TF2Weapons/" + folder + "/" + name + ".asset");
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Loaded " + ((Object)val).name + " Asset"));
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Utilities.FixMixerGroups(val.spawnPrefab);
			Items.RegisterScrap(val, rarity, levels);
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Registered {((Object)val).name} as scrap with a rarity of {rarity}");
			if (spawnCurve != null)
			{
				SpawnableMapObjectDef val2 = ScriptableObject.CreateInstance<SpawnableMapObjectDef>();
				val2.spawnableMapObject = new SpawnableMapObject();
				val2.spawnableMapObject.prefabToSpawn = val.spawnPrefab;
				MapObjects.RegisterMapObject(val2, levels, (Func<SelectableLevel, AnimationCurve>)((SelectableLevel Level) => spawnCurve));
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Registered " + ((Object)val).name + "'s SpawnableMapObjectDef"));
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val).name + " won't spawn naturally"));
			}
		}

		public static T FindClosestToPoint<T>(Vector3 point) where T : MonoBehaviour
		{
			//IL_0034: 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)
			T result = default(T);
			float num = float.MaxValue;
			T[] array = Object.FindObjectsOfType<T>();
			T[] array2 = array;
			foreach (T val in array2)
			{
				float num2 = Vector3.Distance(((Component)(object)val).transform.position, point);
				if (num2 < num)
				{
					num = num2;
					result = val;
				}
			}
			return result;
		}
	}
	public static class PluginMetadata
	{
		public const string PluginId = "ChubbzCrew.SourceSauce";

		public const string PluginName = "TF2 Source Sauce";

		public const string PluginVersion = "0.0.8";
	}
	public class WeaponViewmodelReplacer : MonoBehaviour
	{
		public static WeaponViewmodelReplacer Instance;

		public List<WeaponModel> weaponModels = new List<WeaponModel>();

		public WeaponModel currentModel;

		public PlayerControllerB target;

		public SkinnedMeshRenderer LCViewModel;

		public GrabbableObject lastItem;

		public GrabbableObject oldItem;

		public List<RuntimeAnimatorController> anims;

		public GrabbableObject[] objs = (GrabbableObject[])(object)new GrabbableObject[4];

		public void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public void Start()
		{
			objs = (GrabbableObject[])(object)new GrabbableObject[target.ItemSlots.Length];
		}

		public void PopulateListHacky(string itemName, Animator viewModel, AnimationCopier weaponModel, int runtimeAnimRef)
		{
			WeaponModel item = new WeaponModel
			{
				name = itemName,
				viewModel = viewModel,
				weaponModel = weaponModel,
				animator = anims[runtimeAnimRef]
			};
			weaponModels.Add(item);
		}

		public void Update()
		{
			GrabbableObject[] array = objs;
			foreach (GrabbableObject item in array)
			{
				if (WeaponIsSpecial(item))
				{
					SetItemVisibility(item, !PlayerHasItem(item));
				}
			}
			objs = (GrabbableObject[])(object)new GrabbableObject[target.ItemSlots.Length];
			if (!((Object)(object)target == (Object)null) && target.ItemSlots != null && target.ItemSlots.Length > target.currentItemSlot)
			{
				GrabbableObject val = target.ItemSlots[target.currentItemSlot];
				if (!((Object)(object)val == (Object)(object)lastItem))
				{
					HandleItemSwap(val);
				}
			}
		}

		private void HandleItemSwap(GrabbableObject currentItem)
		{
			oldItem = lastItem;
			lastItem = currentItem;
			if (!WeaponIsSpecial(currentItem))
			{
				foreach (WeaponModel weaponModel in weaponModels)
				{
					DeactivateViewModel(weaponModel);
				}
				SetItemVisibility(currentItem, visible: true);
				SetItemVisibility(oldItem, !PlayerHasItem(oldItem));
				DeactivateCurrentModel();
				return;
			}
			if ((Object)(object)oldItem != (Object)null)
			{
				SetItemVisibility(oldItem, !PlayerHasItem(oldItem));
			}
			if ((Object)(object)lastItem != (Object)null)
			{
				SetItemVisibility(lastItem, !PlayerHasItem(lastItem));
				UpdateViewmodelForItem(currentItem);
			}
			else
			{
				DeactivateCurrentModel();
				SetItemVisibility(oldItem, !PlayerHasItem(oldItem));
			}
		}

		private void SetItemVisibility(GrabbableObject item, bool visible)
		{
			if (!((Object)(object)item == (Object)null))
			{
				Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren<Renderer>(true);
				Renderer[] array = componentsInChildren;
				foreach (Renderer val in array)
				{
					val.enabled = visible;
				}
			}
		}

		private void UpdateViewmodelForItem(GrabbableObject currentItem)
		{
			((Component)LCViewModel).gameObject.SetActive(true);
			if ((Object)(object)oldItem != (Object)null && !PlayerHasItem(oldItem))
			{
				SetItemVisibility(oldItem, visible: true);
			}
			if ((Object)(object)lastItem != (Object)null)
			{
				SetItemVisibility(lastItem, !PlayerHasItem(lastItem));
			}
			foreach (WeaponModel weaponModel in weaponModels)
			{
				DeactivateViewModel(weaponModel);
			}
			foreach (WeaponModel weaponModel2 in weaponModels)
			{
				if (((Object)currentItem.itemProperties).name == weaponModel2.name)
				{
					currentModel = weaponModel2;
					((Component)LCViewModel).gameObject.SetActive(false);
					((Component)weaponModel2.viewModel).gameObject.SetActive(true);
					((Component)weaponModel2.weaponModel).gameObject.SetActive(true);
					weaponModel2.weaponModel.target = ((Component)weaponModel2.viewModel).gameObject.transform;
					weaponModel2.viewModel.runtimeAnimatorController = weaponModel2.animator;
					((Renderer)((Component)weaponModel2.viewModel).GetComponentInChildren<SkinnedMeshRenderer>()).enabled = true;
					((Renderer)((Component)weaponModel2.weaponModel).GetComponentInChildren<SkinnedMeshRenderer>()).enabled = true;
					((Renderer)((Component)weaponModel2.weaponModel).GetComponentInChildren<SkinnedMeshRenderer>()).materials = ((Renderer)currentItem.mainObjectRenderer).materials;
					if ((Object)(object)lastItem != (Object)null && !PlayerHasItem(lastItem))
					{
						SetItemVisibility(lastItem, visible: false);
					}
					return;
				}
			}
			DeactivateCurrentModel();
			((Component)LCViewModel).gameObject.SetActive(true);
		}

		public void DeactivateViewModel(WeaponModel model)
		{
			if (model != null)
			{
				((Component)model.viewModel).gameObject.SetActive(false);
				((Component)model.weaponModel).gameObject.SetActive(false);
			}
		}

		private void DeactivateCurrentModel()
		{
			DeactivateViewModel(currentModel);
			currentModel = null;
			((Component)LCViewModel).gameObject.SetActive(true);
		}

		public bool PlayerHasItem(GrabbableObject item)
		{
			GrabbableObject[] itemSlots = target.ItemSlots;
			foreach (GrabbableObject val in itemSlots)
			{
				if ((Object)(object)val == (Object)(object)item)
				{
					return true;
				}
			}
			return false;
		}

		public bool WeaponIsSpecial(GrabbableObject item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			foreach (WeaponModel weaponModel in weaponModels)
			{
				if (weaponModel.name == ((Object)item.itemProperties).name)
				{
					return true;
				}
			}
			return false;
		}
	}
	[Serializable]
	public class WeaponModel
	{
		public string name;

		public Animator viewModel;

		public AnimationCopier weaponModel;

		public RuntimeAnimatorController animator;
	}
}
namespace ThatTF2SourceSauce.EngieBuilds
{
	public class Toolbox : GrabbableObject
	{
		public enum ToolboxType
		{
			Sentry,
			Dispenser,
			Teleporter1,
			Teleporter2
		}

		public uint level;

		public uint health;

		public ToolboxType Type { get; set; }

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
		}
	}
	public class BuildBase : NetworkBehaviour, IHittable
	{
		public uint level;

		public GameObject Level1Model;

		public GameObject Level2Model;

		public GameObject Level3Model;

		public virtual void LateUpdate()
		{
			Level1Model.SetActive(level == 0);
			Level2Model.SetActive(level == 1);
			Level3Model.SetActive(level == 2);
		}

		public bool Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			return false;
		}
	}
	public class SentryGun : BuildBase
	{
		public Animator currentAnimator;

		public Transform gunPivotYaw;

		public Transform gunPivotPitch;

		public Vector2 viewAngle;

		public MeshCollider fieldOfView;
	}
}
namespace ThatTF2SourceSauce.Weapons
{
	public class PDAItem : GrabbableObject
	{
		public override void Update()
		{
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			if (base.currentUseCooldown >= 0f)
			{
				base.currentUseCooldown -= Time.deltaTime;
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (base.isBeingUsed && base.itemProperties.requiresBattery)
				{
					if (base.insertedBattery.charge > 0f)
					{
						if (!base.itemProperties.itemIsTrigger)
						{
							Battery insertedBattery = base.insertedBattery;
							insertedBattery.charge -= Time.deltaTime / base.itemProperties.batteryUsage;
						}
					}
					else if (!base.insertedBattery.empty)
					{
						base.insertedBattery.empty = true;
						if (base.isBeingUsed)
						{
							Debug.Log((object)"Use up batteries local");
							base.isBeingUsed = false;
							((GrabbableObject)this).UseUpBatteries();
							base.isSendingItemRPC++;
							((GrabbableObject)this).UseUpItemBatteriesServerRpc();
						}
					}
				}
				if (!base.wasOwnerLastFrame)
				{
					base.wasOwnerLastFrame = true;
				}
			}
			else if (base.wasOwnerLastFrame)
			{
				base.wasOwnerLastFrame = false;
			}
			if (base.isHeld || !((Object)(object)base.parentObject == (Object)null))
			{
				return;
			}
			if (base.fallTime < 1f)
			{
				base.reachedFloorTarget = false;
				((GrabbableObject)this).FallWithCurve();
				if (((Component)this).transform.localPosition.y - base.targetFloorPosition.y < 0.1f && !base.hasHitGround)
				{
					((GrabbableObject)this).PlayDropSFX();
					((GrabbableObject)this).OnHitGround();
				}
				return;
			}
			if (!base.reachedFloorTarget)
			{
				base.reachedFloorTarget = true;
				if (base.floorYRot == -1)
				{
					((Component)this).transform.rotation = Quaternion.Euler(base.itemProperties.restingRotation.x, ((Component)this).transform.eulerAngles.y, base.itemProperties.restingRotation.z);
				}
				else
				{
					((Component)this).transform.rotation = Quaternion.Euler(base.itemProperties.restingRotation.x, (float)(base.floorYRot + base.itemProperties.floorYOffset) + 90f, base.itemProperties.restingRotation.z);
				}
			}
			((Component)this).transform.localPosition = base.targetFloorPosition;
		}
	}
	public class MeleeGeneric : GrabbableObject
	{
		public bool air_mCrits;

		public bool goldPlatedKill;

		public float swingSpeed = 1f;

		public float swingDelay = 0.2f;

		public int hitForce = 1;

		public int mCritHitForce = 2;

		public int CritHitForce = 5;

		public float attackDistance = 2f;

		public AudioClip swingSound;

		public AudioClip[] hitSounds;

		public AudioSource meleeAudio;

		public bool isHoldingButton;

		public bool isSwinging = false;

		public Coroutine swingCoroutine;

		public void Awake()
		{
			((GrabbableObject)this).SetScrapValue(Random.Range(base.itemProperties.minValue, base.itemProperties.maxValue));
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			isHoldingButton = buttonDown;
			if (!((Object)(object)base.playerHeldBy == (Object)null) && !isSwinging && buttonDown)
			{
				if (swingCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(swingCoroutine);
				}
				swingCoroutine = ((MonoBehaviour)this).StartCoroutine(SwingWeapon());
			}
		}

		public virtual IEnumerator SwingWeapon()
		{
			while (isHoldingButton)
			{
				isSwinging = true;
				base.playerHeldBy.activatingItem = true;
				PlayRandomSwingAnim();
				SwingWeaponServerRpc();
				yield return (object)new WaitForSeconds(swingDelay);
				ApplyHit();
				yield return (object)new WaitForSeconds(swingSpeed - swingDelay);
				isSwinging = false;
				base.playerHeldBy.activatingItem = false;
			}
		}

		public virtual void ApplyHit()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_0277: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = Physics.SphereCastAll(((Component)base.playerHeldBy.gameplayCamera).transform.position, 0.5f, ((Component)base.playerHeldBy.gameplayCamera).transform.forward, attackDistance);
			bool flag = false;
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val = array2[i];
				IHittable component = ((Component)((RaycastHit)(ref val)).collider).GetComponent<IHittable>();
				EnemyAI component2 = ((Component)((RaycastHit)(ref val)).collider).GetComponent<EnemyAI>();
				if (component != null && (Object)(object)((RaycastHit)(ref val)).transform != (Object)(object)((Component)base.playerHeldBy).transform)
				{
					component.Hit(hitForce, ((Component)base.playerHeldBy.gameplayCamera).transform.forward, base.playerHeldBy, true, 1);
					if (!flag)
					{
						flag = true;
						meleeAudio.PlayOneShot(hitSounds[Random.Range(0, hitSounds.Length)]);
						HitWeaponServerRpc();
					}
				}
				if (!((Object)(object)component2 != (Object)null) || component2.enemyHP > 0 || !goldPlatedKill)
				{
					continue;
				}
				GameObject val2 = StatueCreator.CreateRigidStatue(((Component)component2).gameObject);
				MeshRenderer component3 = val2.GetComponent<MeshRenderer>();
				Material[] materials = ((Renderer)component3).materials;
				Material val3 = ((Renderer)((Component)this).GetComponentInChildren<SkinnedMeshRenderer>()).materials[0];
				for (int j = 0; j < materials.Length; j++)
				{
					materials[j] = val3;
				}
				((Renderer)component3).materials = materials;
				HoarderBugAI val4 = (HoarderBugAI)(object)((component2 is HoarderBugAI) ? component2 : null);
				if (val4 != null && val4.heldItem != null && (Object)(object)val4.heldItem.itemGrabbableObject != (Object)null)
				{
					Material[] materials2 = ((Renderer)val4.heldItem.itemGrabbableObject.mainObjectRenderer).materials;
					for (int k = 0; k < materials2.Length; k++)
					{
						materials2[k] = val3;
					}
					((Renderer)val4.heldItem.itemGrabbableObject.mainObjectRenderer).materials = materials2;
					val4.heldItem.itemGrabbableObject.SetScrapValue(val4.heldItem.itemGrabbableObject.scrapValue + 15);
					if (val4.heldItem.itemGrabbableObject is MeleeGeneric meleeGeneric)
					{
						meleeGeneric.goldPlatedKill = true;
					}
					val4.DropItemServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val4.heldItem.itemGrabbableObject).NetworkObject), ((Component)val4).transform.position, false);
				}
				Object.Destroy((Object)(object)((Component)component2).gameObject);
			}
			if (!flag)
			{
				meleeAudio.PlayOneShot(swingSound);
			}
		}

		public override void DiscardItem()
		{
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				base.playerHeldBy.activatingItem = false;
			}
			((GrabbableObject)this).DiscardItem();
		}

		[ServerRpc]
		public void SwingWeaponServerRpc()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				SwingWeaponClientRpc();
			}
		}

		[ClientRpc]
		public void SwingWeaponClientRpc()
		{
			if (!((NetworkBehaviour)this).IsOwner)
			{
				meleeAudio.PlayOneShot(swingSound);
			}
		}

		[ServerRpc]
		public void HitWeaponServerRpc()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				HitWeaponClientRpc();
			}
		}

		[ClientRpc]
		public void HitWeaponClientRpc()
		{
			if (!((NetworkBehaviour)this).IsOwner)
			{
				meleeAudio.PlayOneShot(hitSounds[Random.Range(0, hitSounds.Length)]);
			}
		}

		public void PlayRandomSwingAnim()
		{
			if (!((Object)(object)base.playerHeldBy != (Object)(object)GameNetworkManager.Instance.localPlayerController) && !((Object)(object)WeaponViewmodelReplacer.Instance == (Object)null))
			{
				int num = Random.Range(0, 3);
				WeaponViewmodelReplacer.Instance.currentModel.viewModel.SetTrigger("Swing" + num);
			}
		}
	}
	public class ProjectileWeaponGeneric : GrabbableObject
	{
		public List<GameObject> projectiles;

		public byte maxProjectiles;

		public float fireRate;

		public AudioClip fireSound;

		public AudioSource audio;

		public bool isHoldingButton;

		private bool isFiring = false;

		private Coroutine fireCoroutine;

		private WeaponViewmodelReplacer view;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (!Object.op_Implicit((Object)(object)view) && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				view = ((Component)base.playerHeldBy).GetComponentInChildren<WeaponViewmodelReplacer>();
			}
			isHoldingButton = buttonDown;
			if (!((Object)(object)base.playerHeldBy == (Object)null) && !isFiring && buttonDown)
			{
				if (fireCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(fireCoroutine);
				}
				fireCoroutine = ((MonoBehaviour)this).StartCoroutine(FireWeapon());
			}
		}

		private IEnumerator FireWeapon()
		{
			while (isHoldingButton)
			{
				isFiring = true;
				if (base.insertedBattery.charge > 0f)
				{
					base.playerHeldBy.activatingItem = true;
					PlayFireAnim();
					audio.PlayOneShot(fireSound);
					FireProjectile();
					base.insertedBattery.charge = Mathf.Clamp(base.insertedBattery.charge - base.itemProperties.batteryUsage, 0f, 1f);
					yield return (object)new WaitForSeconds(fireRate);
				}
				else
				{
					PlayFireAnim();
					yield return (object)new WaitForSeconds(fireRate);
				}
				isFiring = false;
				base.playerHeldBy.activatingItem = false;
			}
		}

		public void PlayFireAnim()
		{
			if (!((Object)(object)view == (Object)null) && view.currentModel != null)
			{
				view.currentModel.viewModel.SetTrigger("Fire");
			}
		}

		private void FireProjectile()
		{
		}

		public override void DiscardItem()
		{
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				base.playerHeldBy.activatingItem = false;
			}
			((GrabbableObject)this).DiscardItem();
		}
	}
	public class SapperItem : GrabbableObject
	{
		public float attackDistance = 2f;

		public SapperObject sapperPrefab;

		public void Awake()
		{
			((GrabbableObject)this).SetScrapValue(Random.Range(base.itemProperties.minValue, base.itemProperties.maxValue));
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (buttonDown)
			{
				PlaceSapperServerRPC();
			}
		}

		[ServerRpc]
		private void PlaceSapperServerRPC()
		{
			PlaceSapperClientRPC();
		}

		[ClientRpc]
		private void PlaceSapperClientRPC()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = Physics.SphereCastAll(((Component)base.playerHeldBy.gameplayCamera).transform.position, 0.5f, ((Component)base.playerHeldBy.gameplayCamera).transform.forward, attackDistance);
			RaycastHit[] array2 = array;
			Turret targetTurret = default(Turret);
			Landmine targetLandmine = default(Landmine);
			RadMechAI targetMech = default(RadMechAI);
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val = array2[i];
				if (((Component)((RaycastHit)(ref val)).collider).TryGetComponent<Turret>(ref targetTurret))
				{
					SapperObject.Instantiate(sapperPrefab, targetTurret);
				}
				else if (((Component)((RaycastHit)(ref val)).collider).TryGetComponent<Landmine>(ref targetLandmine))
				{
					SapperObject.Instantiate(sapperPrefab, targetLandmine);
				}
				else if (((Component)((RaycastHit)(ref val)).collider).TryGetComponent<RadMechAI>(ref targetMech))
				{
					SapperObject.Instantiate(sapperPrefab, targetMech);
				}
			}
		}
	}
	public class SpyKnife : MeleeGeneric
	{
		public int backstabForce;

		public float backStabCooldown;

		public bool backStab;

		public override void Update()
		{
			((GrabbableObject)this).Update();
			SetBackstab();
		}

		public void SetBackstab()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (isSwinging)
			{
				return;
			}
			RaycastHit[] array = Physics.SphereCastAll(((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.position, 0.5f, ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward, attackDistance);
			backStab = false;
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val = array2[i];
				IHittable component = ((Component)((RaycastHit)(ref val)).collider).GetComponent<IHittable>();
				if (component != null && (Object)(object)((RaycastHit)(ref val)).transform != (Object)(object)((Component)((GrabbableObject)this).playerHeldBy).transform)
				{
					float y = ((RaycastHit)(ref val)).transform.eulerAngles.y;
					float y2 = ((Component)((GrabbableObject)this).playerHeldBy).transform.eulerAngles.y;
					float num = y2 - y;
					if (num > 180f)
					{
						num -= 360f;
					}
					if (num < -180f)
					{
						num += 360f;
					}
					if (!(num > 90f) && !(num < -90f))
					{
						backStab = true;
						break;
					}
				}
			}
			SetBackstabAnim(backStab);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			isHoldingButton = buttonDown;
			if (!((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null) && !isSwinging && buttonDown)
			{
				if (swingCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(swingCoroutine);
				}
				swingCoroutine = ((MonoBehaviour)this).StartCoroutine(SwingWeapon());
			}
		}

		public override IEnumerator SwingWeapon()
		{
			while (isHoldingButton)
			{
				SetBackstab();
				if (backStab)
				{
					isSwinging = true;
					((GrabbableObject)this).playerHeldBy.activatingItem = true;
					PlayRandomSwingAnim();
					SwingWeaponServerRpc();
					meleeAudio.PlayOneShot(swingSound);
					ApplyHit();
					yield return (object)new WaitForSeconds(backStabCooldown);
					isSwinging = false;
					((GrabbableObject)this).playerHeldBy.activatingItem = false;
				}
				else
				{
					isSwinging = true;
					((GrabbableObject)this).playerHeldBy.activatingItem = true;
					PlayRandomSwingAnim();
					SwingWeaponServerRpc();
					yield return (object)new WaitForSeconds(swingDelay);
					ApplyHit();
					yield return (object)new WaitForSeconds(swingSpeed - swingDelay);
					isSwinging = false;
					((GrabbableObject)this).playerHeldBy.activatingItem = false;
				}
			}
		}

		public override void ApplyHit()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: 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)
			bool flag = false;
			RaycastHit[] array = Physics.SphereCastAll(((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.position, 0.5f, ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward, attackDistance);
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val = array2[i];
				IHittable component = ((Component)((RaycastHit)(ref val)).collider).GetComponent<IHittable>();
				EnemyAI component2 = ((Component)((RaycastHit)(ref val)).collider).GetComponent<EnemyAI>();
				if (component != null && (Object)(object)((RaycastHit)(ref val)).transform != (Object)(object)((Component)((GrabbableObject)this).playerHeldBy).transform)
				{
					component.Hit(backStab ? backstabForce : hitForce, ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward, ((GrabbableObject)this).playerHeldBy, true, 1);
					if (!flag)
					{
						flag = true;
						meleeAudio.PlayOneShot(hitSounds[Random.Range(0, hitSounds.Length)]);
						HitWeaponServerRpc();
					}
				}
				if (!((Object)(object)component2 != (Object)null) || component2.enemyHP > 0 || !goldPlatedKill)
				{
					continue;
				}
				GameObject val2 = StatueCreator.CreateRigidStatue(((Component)component2).gameObject);
				MeshRenderer component3 = val2.GetComponent<MeshRenderer>();
				Material[] materials = ((Renderer)component3).materials;
				Material val3 = ((Renderer)((Component)this).GetComponentInChildren<SkinnedMeshRenderer>()).materials[0];
				for (int j = 0; j < materials.Length; j++)
				{
					materials[j] = val3;
				}
				((Renderer)component3).materials = materials;
				HoarderBugAI val4 = (HoarderBugAI)(object)((component2 is HoarderBugAI) ? component2 : null);
				if (val4 != null && val4.heldItem != null && (Object)(object)val4.heldItem.itemGrabbableObject != (Object)null)
				{
					Material[] materials2 = ((Renderer)val4.heldItem.itemGrabbableObject.mainObjectRenderer).materials;
					for (int k = 0; k < materials2.Length; k++)
					{
						materials2[k] = val3;
					}
					((Renderer)val4.heldItem.itemGrabbableObject.mainObjectRenderer).materials = materials2;
					val4.heldItem.itemGrabbableObject.SetScrapValue(val4.heldItem.itemGrabbableObject.scrapValue + 15);
					val4.DropItemServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val4.heldItem.itemGrabbableObject).NetworkObject), ((Component)val4).transform.position, false);
				}
				Object.Destroy((Object)(object)((Component)component2).gameObject);
			}
			if (!flag)
			{
				meleeAudio.PlayOneShot(swingSound);
			}
		}

		public void SetBackstabAnim(bool truefalse)
		{
			if (!((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)(object)GameNetworkManager.Instance.localPlayerController) && !((Object)(object)WeaponViewmodelReplacer.Instance == (Object)null))
			{
				WeaponViewmodelReplacer.Instance.currentModel.viewModel.SetBool("KnifeUp", truefalse);
			}
		}
	}
}
namespace ThatTF2SourceSauce.Weapons.Test
{
	public class TerminalHacker : GrabbableObject
	{
		public float playerRealSpeed = 1f;

		public bool playerInHackTerminal;

		public void Awake()
		{
			((GrabbableObject)this).SetScrapValue(Random.Range(base.itemProperties.minValue, base.itemProperties.maxValue));
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (playerInHackTerminal && !base.playerHeldBy.inTerminalMenu)
			{
				base.playerHeldBy.movementSpeed = playerRealSpeed;
				Terminal val = Object.FindObjectOfType<Terminal>();
			}
			((Behaviour)StartOfRound.Instance.mapScreen.mapCamera).enabled = true;
			((Component)StartOfRound.Instance.mapScreen.mapCamera).gameObject.SetActive(true);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (buttonDown)
			{
				ActivateTerminalServerRPC();
			}
		}

		[ServerRpc]
		private void ActivateTerminalServerRPC()
		{
			ActivateTerminalClientRPC();
		}

		[ClientRpc]
		private void ActivateTerminalClientRPC()
		{
			Terminal val = Object.FindObjectOfType<Terminal>();
			val.BeginUsingTerminal();
			val.terminalUIScreen.renderMode = (RenderMode)0;
			playerInHackTerminal = true;
			playerRealSpeed = base.playerHeldBy.movementSpeed;
			base.playerHeldBy.inTerminalMenu = true;
			base.playerHeldBy.movementSpeed = 0f;
		}
	}
}
namespace ThatTF2SourceSauce.Spawnables
{
	public class SapperObject : MonoBehaviour
	{
		public Turret turretPlacedOn;

		public Landmine landminePlacedOn;

		public RadMechAI mechPlacedOn;

		private float lifeTime = 60f;

		private float lifeTimeMech = 60f;

		private RoundManager RM;

		public static void Instantiate(SapperObject original, Turret targetTurret)
		{
			SapperObject sapperObject = Object.Instantiate<SapperObject>(original, ((Component)targetTurret).transform);
			sapperObject.turretPlacedOn = targetTurret;
			sapperObject.turretPlacedOn.ToggleTurretServerRpc(false);
			sapperObject.Initialize();
		}

		public static void Instantiate(SapperObject original, Landmine targetLandmine)
		{
			SapperObject sapperObject = Object.Instantiate<SapperObject>(original, ((Component)targetLandmine).transform);
			sapperObject.landminePlacedOn = targetLandmine;
			sapperObject.landminePlacedOn.ToggleMineServerRpc(false);
			sapperObject.Initialize();
		}

		public static void Instantiate(SapperObject original, RadMechAI targetMech)
		{
			SapperObject sapperObject = Object.Instantiate<SapperObject>(original, ((Component)targetMech).transform);
			sapperObject.mechPlacedOn = targetMech;
			((Behaviour)sapperObject.mechPlacedOn).enabled = false;
			sapperObject.Initialize();
		}

		public void Initialize()
		{
			RM = Object.FindObjectOfType<RoundManager>();
		}

		public void Update()
		{
			if ((Object)(object)RM != (Object)null)
			{
				if ((Object)(object)mechPlacedOn != (Object)null)
				{
					lifeTimeMech -= 1f * Time.deltaTime;
					if (lifeTimeMech <= 0f)
					{
						Object.Destroy((Object)(object)((Component)this).gameObject);
					}
				}
				else
				{
					lifeTime -= 1f / RM.timeScript.lengthOfHours * Time.deltaTime;
					if (lifeTime <= 0f)
					{
						Object.Destroy((Object)(object)((Component)this).gameObject);
					}
				}
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)turretPlacedOn))
			{
				turretPlacedOn.ToggleTurretServerRpc(true);
			}
			if (Object.op_Implicit((Object)(object)landminePlacedOn))
			{
				landminePlacedOn.ToggleMineServerRpc(true);
			}
			if (Object.op_Implicit((Object)(object)mechPlacedOn))
			{
				((Behaviour)mechPlacedOn).enabled = true;
			}
		}
	}
	public class Stickybomb : MonoBehaviour
	{
		public Rigidbody rb;

		public void Awake()
		{
			rb = ((Component)this).GetComponent<Rigidbody>();
		}

		public void OnCollisionEnter(Collision collision)
		{
			if (!((Object)(object)rb == (Object)null))
			{
				rb.constraints = (RigidbodyConstraints)126;
				((Component)this).transform.parent = collision.transform;
			}
		}

		public void OnDetonate()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Landmine.SpawnExplosion(((Component)this).transform.position, true, 5.7f, 6f, 50, 0f, (GameObject)null, false);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}