Decompiled source of YAPYAP Repo Like v1.0.0

ChangeMechanic.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using YAPYAP;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.5.2", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("ChangeMechanic")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ChangeMechanic in YAPYAP")]
[assembly: AssemblyTitle("ChangeMechanic")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[BepInPlugin("ChangeMechanic", "ChangeMechanic", "1.0")]
public class ChangeMechanic : BaseUnityPlugin
{
	public static ConfigEntry<int> ValueMultiplier;

	public static ConfigEntry<float> DistanceShownValue;

	public static ConfigEntry<string> HudTextValue;

	public static ConfigEntry<int> MaxHpMultiplier;

	public static ConfigEntry<float> MultiplyUpSupport;

	public static ManualLogSource Log;

	private void Awake()
	{
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Expected O, but got Unknown
		ValueMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("items", "ValueMultiplier", 3, "Multiply value item");
		DistanceShownValue = ((BaseUnityPlugin)this).Config.Bind<float>("Hud", "DistanceShownValue", 3f, "Select with what distance you see value");
		HudTextValue = ((BaseUnityPlugin)this).Config.Bind<string>("Hud", "HudText", "Value:", "What will be show when you look to valuable item");
		MaxHpMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("items", "MaxHpMultiplier", 5, "Multiply MaxHp item");
		MultiplyUpSupport = ((BaseUnityPlugin)this).Config.Bind<float>("Charcter", "MultiplyUpSupport", 2f, "Multiply added force");
		((Component)this).gameObject.AddComponent<ValueOverlay>();
		Log = ((BaseUnityPlugin)this).Logger;
		Harmony val = new Harmony("ChangeMechanic");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"ChangeMechanic by opexob10 loaded");
	}
}
[HarmonyPatch(typeof(NetworkPhysicsPropDestroy), "OnStartServer")]
internal class Patch_ChangeMaxHp
{
	private static readonly FieldInfo MaxHpField = AccessTools.Field(typeof(NetworkPhysicsPropDestroy), "maxHealth");

	private static void Prefix(NetworkPhysicsPropDestroy __instance)
	{
		MaxHpField.SetValue(__instance, (int)MaxHpField.GetValue(__instance) * ChangeMechanic.MaxHpMultiplier.Value);
	}
}
[HarmonyPatch(typeof(GameManager), "ModifyRoundScore")]
public class Patch_disableAddScore
{
	private static bool Aviable;

	private static bool Prefix(int addScore)
	{
		if (Aviable)
		{
			Aviable = false;
			return true;
		}
		return false;
	}

	public static void AddScore(int addScore)
	{
		Aviable = true;
		GameManager instance = GameManager.Instance;
		if (instance != null)
		{
			instance.ModifyRoundScore(addScore);
		}
	}
}
[HarmonyPatch(typeof(TeleportExtractionCircle), "Awake")]
internal class Patch_TeleportExtractionCircle_Awake
{
	private static readonly FieldInfo circleRadiusField = AccessTools.Field(typeof(TeleportExtractionCircle), "circleRadius");

	private static void Postfix(TeleportExtractionCircle __instance)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("ExtractionCircleTrigger");
		val.transform.SetParent(((Component)__instance).transform);
		val.transform.localPosition = Vector3.zero;
		SphereCollider val2 = val.AddComponent<SphereCollider>();
		((Collider)val2).isTrigger = true;
		float radius = (float)circleRadiusField.GetValue(__instance);
		val2.radius = radius;
		ExtractionCircleTrigger extractionCircleTrigger = val.AddComponent<ExtractionCircleTrigger>();
		extractionCircleTrigger.Initialize(__instance);
		ChangeMechanic.Log.LogInfo((object)$"ExtractionCircleTrigger created with radius {val2.radius}");
	}
}
public class ExtractionCircleTrigger : MonoBehaviour
{
	private TeleportExtractionCircle parentCircle;

	public void Initialize(TeleportExtractionCircle circle)
	{
		parentCircle = circle;
	}

	private void OnTriggerEnter(Collider other)
	{
		//IL_008c: 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)
		Pawn val = default(Pawn);
		if (((Component)other).TryGetComponent<Pawn>(ref val) && !val.IsExtracted)
		{
			ChangeMechanic.Log.LogInfo((object)("Pawn " + ((Object)val).name + " entered custom trigger"));
		}
		ValuableObject val2 = default(ValuableObject);
		NetworkPhysicsPropDestroy val3 = default(NetworkPhysicsPropDestroy);
		if (((Component)other).TryGetComponent<ValuableObject>(ref val2) && ((Component)other).TryGetComponent<NetworkPhysicsPropDestroy>(ref val3))
		{
			ChangeMechanic.Log.LogError((object)("Work Value " + val2.Value));
			Patch_disableAddScore.AddScore(val2.Value);
			val3.SvDoDestroy(default(Vector3), true);
		}
	}
}
[HarmonyPatch(typeof(ValuableObject), "Awake")]
internal class Patch_UpValue
{
	private static void Prefix(ValuableObject __instance)
	{
		__instance.SetValue(__instance.Value * ChangeMechanic.ValueMultiplier.Value);
	}
}
public class ValueOverlay : MonoBehaviour
{
	public static ValueOverlay Instance;

	private Canvas canvas;

	private TextMeshProUGUI text;

	private float targetAlpha = 0f;

	private float currentAlpha = 0f;

	private void Awake()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		GameObject val = new GameObject("ValueOverlayCanvas");
		canvas = val.AddComponent<Canvas>();
		canvas.renderMode = (RenderMode)0;
		val.AddComponent<CanvasScaler>();
		val.AddComponent<GraphicRaycaster>();
		Object.DontDestroyOnLoad((Object)(object)val);
		GameObject val2 = new GameObject("ValueText");
		val2.transform.SetParent(val.transform);
		text = val2.AddComponent<TextMeshProUGUI>();
		((TMP_Text)text).fontSize = 28f;
		((TMP_Text)text).alignment = (TextAlignmentOptions)514;
		((Graphic)text).color = new Color(1f, 1f, 1f, 0f);
		RectTransform rectTransform = ((TMP_Text)text).rectTransform;
		rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
		rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
		rectTransform.anchoredPosition = new Vector2(0f, 60f);
		rectTransform.sizeDelta = new Vector2(400f, 80f);
	}

	private void Update()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Camera.main == (Object)null)
		{
			return;
		}
		Ray val = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f));
		RaycastHit val2 = default(RaycastHit);
		if (Physics.Raycast(val, ref val2, 5f))
		{
			ValuableObject val3 = default(ValuableObject);
			if (((Component)((RaycastHit)(ref val2)).collider).TryGetComponent<ValuableObject>(ref val3) && ((RaycastHit)(ref val2)).distance < ChangeMechanic.DistanceShownValue.Value)
			{
				ShowValue(val3.Value);
			}
			else
			{
				Hide();
			}
		}
		else
		{
			Hide();
		}
		currentAlpha = Mathf.Lerp(currentAlpha, targetAlpha, Time.deltaTime * 8f);
		Color color = ((Graphic)text).color;
		color.a = currentAlpha;
		((Graphic)text).color = color;
	}

	private void ShowValue(int value)
	{
		((TMP_Text)text).text = $"{ChangeMechanic.HudTextValue.Value} {value}";
		targetAlpha = 1f;
	}

	private void Hide()
	{
		targetAlpha = 0f;
	}
}
[HarmonyPatch(typeof(PawnGrabInteractions), "DragGrabbedObject")]
internal class Patch_SoftLift
{
	private static void Postfix(PawnGrabInteractions __instance)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		object? value = AccessTools.Field(typeof(PawnGrabInteractions), "_grabbedRb").GetValue(__instance);
		Rigidbody val = (Rigidbody)((value is Rigidbody) ? value : null);
		if (!((Object)(object)val == (Object)null))
		{
			val.AddForce(Vector3.up * (val.mass * ChangeMechanic.MultiplyUpSupport.Value), (ForceMode)0);
		}
	}
}