Decompiled source of RC REPO v1.0.0

BepInEx/plugins/RCREPO/RCREPO.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RCREPO")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1d47c364b8fcbc4795e846cc30e8344fb16fc765")]
[assembly: AssemblyProduct("RCREPO")]
[assembly: AssemblyTitle("RCREPO")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RCRepo
{
	public class AssetManager
	{
		private readonly AssetBundle assetBundle;

		public Dictionary<string, Object> Assets { get; private set; } = new Dictionary<string, Object>();


		public AssetManager(AssetBundle bundle)
		{
			assetBundle = bundle ?? throw new ArgumentNullException("bundle", "AssetBundle cannot be null");
		}

		public static AssetManager CreateFromBundle(AssetBundle bundle)
		{
			if ((Object)(object)bundle == (Object)null)
			{
				throw new ArgumentNullException("bundle", "AssetBundle cannot be null");
			}
			AssetManager assetManager = new AssetManager(bundle);
			string[] allAssetNames = assetManager.assetBundle.GetAllAssetNames();
			foreach (string text in allAssetNames)
			{
				Plugin.logger.LogInfo((object)("Asset found: " + text));
				Object val = assetManager.assetBundle.LoadAsset<Object>(text);
				if (val == (Object)null)
				{
					Plugin.logger.LogWarning((object)("Failed to load asset: " + text));
					continue;
				}
				int num = text.LastIndexOf('/');
				string text2 = (text.Substring(num + 1, text.LastIndexOf('.') - num - 1) + "." + ((object)val).GetType().Name).ToLower();
				assetManager.Assets[text2] = val;
				Plugin.logger.LogInfo((object)("Loaded asset: " + text2));
			}
			return assetManager;
		}

		public bool TryGetAsset<T>(string assetName, [NotNullWhen(true)] out T? asset) where T : Object
		{
			string name = typeof(T).Name;
			string text = (assetName + "." + name).ToLower();
			if (Assets.TryGetValue(text, out Object value))
			{
				T val = (T)(object)((value is T) ? value : null);
				if (val != null)
				{
					asset = val;
					return true;
				}
			}
			Plugin.logger.LogWarning((object)("Asset '" + text + "' not found or is not of type " + name));
			asset = default(T);
			return false;
		}
	}
	[BepInPlugin("com.VELD-Dev.RCRepo", "R&C.E.P.O.", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <BundleLoadCallback>d__14 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public AssetBundle bundle;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <BundleLoadCallback>d__14(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				AM = AssetManager.CreateFromBundle(bundle);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[NotNull]
		public static string AssemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty;

		internal static ManualLogSource logger
		{
			[return: NotNull]
			get;
			private set; }

		public static Plugin Singleton
		{
			[return: NotNull]
			get;
			private set; }

		public static AssetManager AM
		{
			[return: NotNull]
			get;
			private set; }

		private void Awake()
		{
			Singleton = this;
			logger = ((BaseUnityPlugin)this).Logger;
			logger.LogInfo((object)"Loading mod R&C.E.P.O. v1.0.0");
			string text = Path.Combine(AssemblyPath, "ratchetvaluables");
			BundleLoader.LoadBundle(text, (Func<AssetBundle, IEnumerator>)BundleLoadCallback, true);
			logger.LogInfo((object)("Loaded Bundle '" + text + "'"));
		}

		[IteratorStateMachine(typeof(<BundleLoadCallback>d__14))]
		private IEnumerator BundleLoadCallback(AssetBundle bundle)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <BundleLoadCallback>d__14(0)
			{
				bundle = bundle
			};
		}
	}
	public static class PluginInfo
	{
		public const string GUID = "com.VELD-Dev.RCRepo";

		public const string Name = "R&C.E.P.O.";

		public const string Version = "1.0.0";
	}
}
namespace RCRepo.Monobehaviours
{
	internal class CrateBehaviour : MonoBehaviour
	{
		private void Start()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogInfo((object)$"Crate spawned at {((Component)this).transform.position}");
		}

		public virtual void OnCrateDestroy()
		{
		}
	}
	internal class ExplosiveCrateBehaviour : CrateBehaviour
	{
		private void Start()
		{
		}

		public override void OnCrateDestroy()
		{
			base.OnCrateDestroy();
		}
	}
	internal class OmniWrenchBehaviour : ItemMelee
	{
		private List<HurtCollider> hurtColliders = new List<HurtCollider>();

		private void Start()
		{
			Transform val = ((Component)this).transform.Find("Object");
			base.rb = ((Component)this).GetComponent<Rigidbody>();
			hurtColliders = ((Component)this).GetComponentsInChildren<HurtCollider>().ToList();
			base.hurtColliderRotation = null;
			base.physGrabObjectImpactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			foreach (HurtCollider hurtCollider in hurtColliders)
			{
				((Component)hurtCollider).gameObject.SetActive(false);
			}
			base.trailRenderer = ((Component)this).GetComponentInChildren<TrailRenderer>();
			base.swingPoint = val.Find("Swing Point");
			base.physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			base.particleSystem = ((Component)val.Find("Particles")).GetComponent<ParticleSystem>();
			base.particleSystemGroundHit = ((Component)((Component)this).transform.Find("Particles Ground Hit")).GetComponent<ParticleSystem>();
			base.photonView = ((Component)this).GetComponent<PhotonView>();
			base.itemBattery = ((Component)this).GetComponent<ItemBattery>();
			base.forceGrabPoint = val.Find("Force Grab Point");
			base.meshHealthy = val.Find("Mesh");
			base.itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
			if (!SemiFunc.RunIsArena())
			{
				return;
			}
			foreach (HurtCollider hurtCollider2 in hurtColliders)
			{
				hurtCollider2.playerDamage = hurtCollider2.enemyDamage;
			}
		}

		private void Update()
		{
			//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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			if (base.grabbedTimer > 0f)
			{
				base.grabbedTimer -= Time.deltaTime;
			}
			if (base.physGrabObject.grabbed)
			{
				base.grabbedTimer = 1f;
			}
			if (base.hitFreezeDelay > 0f)
			{
				base.hitFreezeDelay -= Time.deltaTime;
				if (base.hitFreezeDelay <= 0f)
				{
					base.physGrabObject.FreezeForces(base.hitFreeze, Vector3.zero, Vector3.zero);
				}
			}
			if (!LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (base.spawnTimer > 0f)
			{
				base.prevPosition = base.swingPoint.position;
				base.swingTimer = 0f;
				base.spawnTimer -= Time.deltaTime;
				return;
			}
			if (base.hitCooldown > 0f)
			{
				base.hitCooldown -= Time.deltaTime;
			}
			if (base.enemyOrPVPDurabilityLossCooldown > 0f)
			{
				base.enemyOrPVPDurabilityLossCooldown -= Time.deltaTime;
			}
			if (base.groundHitCooldown > 0f)
			{
				base.groundHitCooldown -= Time.deltaTime;
			}
			if (base.groundHitSoundTimer > 0f)
			{
				base.groundHitSoundTimer -= Time.deltaTime;
			}
			DisableHurtBoxWhenEquipping();
			if (base.itemEquippable.equipTimer > 0f || base.itemEquippable.unequipTimer > 0f)
			{
				return;
			}
			bool flag = hurtColliders.Any((HurtCollider hurtCollider) => ((Component)hurtCollider).gameObject.activeSelf);
			base.soundSwingLoop.PlayLoop(flag, 10f, 10f, 3f);
			if (SemiFunc.IsMultiplayer() && !SemiFunc.IsMasterClient() && base.isSwinging)
			{
				base.swingTimer = 0.5f;
			}
			if (SemiFunc.IsMasterClientOrSingleplayer() && base.itemBattery != null)
			{
				if (base.itemBattery.batteryLife <= 0f)
				{
					((ItemMelee)this).MeleeBreak();
				}
				else
				{
					((ItemMelee)this).MeleeFix();
				}
				if (base.durabilityLossCooldown > 0f)
				{
					base.durabilityLossCooldown -= Time.deltaTime;
				}
				if (!base.isBroken)
				{
					if (base.physGrabObject.grabbedLocal)
					{
						if (!base.itemBattery.batteryActive)
						{
						}
					}
					else
					{
						_ = base.itemBattery.batteryActive;
					}
				}
			}
			if (base.isBroken)
			{
				return;
			}
			if (base.hitSoundDelayTimer > 0f)
			{
				base.hitSoundDelayTimer -= Time.deltaTime;
			}
			if (base.swingPitch != base.swingPitchTarget && base.swingPitchTargetProgress >= 1f)
			{
				base.swingPitch = base.swingPitchTarget;
			}
			Vector3 val = base.prevPosition - base.swingPoint.position;
			Vector3 normalized = ((Vector3)(ref base.swingStartDirection)).normalized;
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			float num = Vector3.Dot(normalized, normalized2);
			double num2 = 0.85;
			if (!base.physGrabObject.grabbed)
			{
				num2 = 0.1;
			}
			if ((double)num > num2)
			{
				base.swingTimer = 0f;
			}
			if (base.isSwinging)
			{
				((ItemMelee)this).ActivateHitbox();
			}
			if (base.hitTimer > 0f)
			{
				base.hitTimer -= Time.deltaTime;
			}
			if (base.swingTimer <= 0f)
			{
				if (base.hitBoxTimer <= 0f)
				{
					foreach (HurtCollider hurtCollider in hurtColliders)
					{
						((Component)hurtCollider).gameObject.SetActive(false);
					}
				}
				else
				{
					base.hitBoxTimer -= Time.deltaTime;
				}
				base.trailRenderer.emitting = false;
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					base.isSwinging = false;
				}
			}
			else
			{
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					base.isSwinging = true;
				}
				if (base.hitTimer <= 0f)
				{
					base.hitBoxTimer = 0.2f;
				}
				base.swingTimer -= Time.deltaTime;
			}
		}

		private void FixedUpdate()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			DisableHurtBoxWhenEquipping();
			bool flag = false;
			foreach (PhysGrabber item in base.physGrabObject.playerGrabbing)
			{
				if (item.isRotating)
				{
					flag = true;
				}
			}
			if (!flag)
			{
				Quaternion currentYRotation = base.currentYRotation;
				Quaternion val = Quaternion.Euler(45f, 0f, 0f);
				base.physGrabObject.TurnXYZ(val, currentYRotation, Quaternion.identity);
			}
			if (base.itemEquippable.equipTimer > 0f || base.itemEquippable.unequipTimer > 0f || base.isBroken)
			{
				return;
			}
			if (base.prevPosUpdateTimer > 0.1f)
			{
				base.prevPosition = base.swingPoint.position;
				base.prevPosUpdateTimer = 0f;
			}
			else
			{
				base.prevPosUpdateTimer += Time.fixedDeltaTime;
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			if (!flag)
			{
				if (base.torqueStrength != 1f)
				{
					base.physGrabObject.OverrideTorqueStrength(base.torqueStrength, 0.1f);
				}
				if (base.physGrabObject.grabbed)
				{
					if (base.itemBattery == null || (base.itemBattery != null && base.itemBattery.batteryLife <= 0f))
					{
						base.physGrabObject.OverrideTorqueStrength(0.1f, 0.1f);
					}
					base.physGrabObject.OverrideMaterial(SemiFunc.PhysicMaterialSlippery(), 0.1f);
				}
			}
			if (flag)
			{
				base.physGrabObject.OverrideTorqueStrength(4f, 0.1f);
			}
			if (base.distanceCheckTimer > 0.1f)
			{
				base.prevPosDistance = Vector3.Distance(base.prevPosition, base.swingPoint.position) * 10f * base.rb.mass;
				base.distanceCheckTimer = 0f;
			}
			base.distanceCheckTimer += Time.fixedDeltaTime;
			((ItemMelee)this).TurnWeapon();
			Vector3 val2 = base.prevPosition - base.swingPoint.position;
			float num = 1f;
			if (!base.physGrabObject.grabbed)
			{
				num = 0.5f;
			}
			if (((Vector3)(ref val2)).magnitude > num * base.swingDetectSpeedMultiplier && base.swingPoint.position - base.prevPosition != Vector3.zero)
			{
				base.swingTimer = 0.2f;
				if (!base.isSwinging)
				{
					base.newSwing = true;
				}
				base.swingDirection = Quaternion.LookRotation(base.swingPoint.position - base.prevPosition);
			}
		}

		public void DisableHurtBoxWhenEquipping()
		{
			if (base.itemEquippable == null)
			{
				Plugin.logger.LogError((object)"OmniWrench has no ItemEquippable component!");
				base.itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
				if (base.itemEquippable == null)
				{
					Plugin.logger.LogError((object)("Failed to find ItemEquippable component on OmniWrench on GameObject " + ((Object)((Component)this).gameObject).name + "!"));
					return;
				}
			}
			if (!(base.itemEquippable.equipTimer > 0f) && !(base.itemEquippable.unequipTimer > 0f))
			{
				return;
			}
			foreach (HurtCollider hurtCollider in hurtColliders)
			{
				((Component)hurtCollider).gameObject.SetActive(false);
			}
			base.swingTimer = 0f;
			base.trailRenderer.emitting = false;
		}

		public void GroundHit()
		{
			((ItemMelee)this).GroundHit();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}