Decompiled source of fixmod v0.0.11

fixmod.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DM;
using FhpSLib.BundleModCore;
using HarmonyLib;
using Landfall.TABS;
using SLMA;
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("Custom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("made in SFT by FhpSlime")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3a45c3cf-230c-4310-952f-0887d4266a22")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace fixmod
{
	public static class UManager
	{
		public static string modname;

		public static string modder;

		private static string com;

		public static SLMABundleMod bundleMod;

		public static SLMABundleMod bundleMod1;

		static UManager()
		{
			modname = "SFT";
			modder = "FhpSlime";
		}

		public static void SetRiders(UnitBlueprint me, UnitBlueprint[] riders)
		{
			s.SetField<UnitBlueprint>(me, "Riders", (object)riders);
		}

		public static void EditBlueprint(UnitBlueprint unit, LandfallContentDatabase db)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Expected O, but got Unknown
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Expected O, but got Unknown
			if (unit.Entity.Name == "UNIT_SECRET_ULLR")
			{
				SLMATool.UnitCost(unit, 3000);
				GameObject obj = UPool.MyPool.AddObject("xiufu", (GameObject)SLMALoader.SDic["weapons"]["Thrown_UllrAxe"], true, (HideFlags)52, (Sprite)null, 0, true);
				UPool.MyPool.AddObject("霹雳2", (GameObject)SLMALoader.SDic["projectiles"]["P_AxeUllr"], true, (HideFlags)52, (Sprite)null, 0, true);
				ChineseLibrary.设置子弹(obj, UPool.MyPool.GetObject("霹雳2"));
				unit.RightWeapon = UPool.MyPool.GetObject("xiufu");
				unit.LeftWeapon = UPool.MyPool.GetObject("xiufu");
			}
			if (unit.Entity.Name == "UNIT_LEGACY_LEG_WIZARD")
			{
				GameObject obj2 = UPool.MyPool.AddObject("xiufu2", (GameObject)SLMALoader.SDic["weapons"]["Leg_WizardStaff"], true, (HideFlags)52, (Sprite)null, 0, true);
				GameObject obj3 = UPool.MyPool.AddObject("霹雳3", (GameObject)SLMALoader.SDic["projectiles"]["E_Leg_WizardThrow_Spell"], true, (HideFlags)52, (Sprite)null, 0, true);
				UPool.MyPool.AddObject("newexps", (GameObject)SLMALoader.SDic["effects"]["E_Leg_WizardThrow_Effect"], true, (HideFlags)52, (Sprite)null, 1147116, true);
				UnitEffectBase component = UPool.MyPool.GetObject("newexps").GetComponent<UnitEffectBase>();
				obj3.GetComponentInChildren<AddTargetableEffect>().EffectPrefab = component;
				((Component)component).gameObject.AddComponent<ExplosionFixer>();
				ChineseLibrary.设置子弹(obj2, UPool.MyPool.GetObject("霹雳3"));
				unit.RightWeapon = UPool.MyPool.GetObject("xiufu2");
			}
			if (unit.Entity.Name == "UNIT_WESTERN_QUICKDRAW")
			{
				GameObject obj4 = UPool.MyPool.AddObject("xiufu3", (GameObject)SLMALoader.SDic["weapons"]["Quickdraw_Revolver_AgainstHip"], true, (HideFlags)52, (Sprite)null, 0, true);
				obj4.GetComponentInChildren<RangeWeapon>().useSpawnDelayForEveryShot = true;
				obj4.AddComponent<RangeWeaponAmmoFixer>();
				unit.RightWeapon = UPool.MyPool.GetObject("xiufu3");
			}
			if (unit.Entity.Name == "UNIT_WESTERN_DEADEYE")
			{
				HoldableLookAtFixer holdableLookAtFixer = ((Component)UPool.MyPool.AddObject("xiufu6", (GameObject)SLMALoader.SDic["weapons"]["Winchester"], true, (HideFlags)52, (Sprite)null, 0, true).GetComponentInChildren<Holdable>()).gameObject.AddComponent<HoldableLookAtFixer>();
				holdableLookAtFixer.enableFix = true;
				holdableLookAtFixer.returnSmoothTime = 0.2f;
				holdableLookAtFixer.returnThreshold = 0.5f;
				unit.RightWeapon = UPool.MyPool.GetObject("xiufu6");
			}
		}

		public static void EditClothes(GameObject cloth, CharacterItem item, PropItemData data, Unit unit, int index, LandfallContentDatabase db)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			Debug.Log((object)"Hey");
			if (unit.unitBlueprint.Entity.Name == "unit name")
			{
				Renderer[] componentsInChildren = cloth.GetComponentsInChildren<Renderer>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].materials = (Material[])(object)new Material[1] { (Material)SLMALoader.SDic["materials"]["Glow_Neon_Green_143734"] };
				}
			}
		}

		public static void EditProjectiles(GameObject proj, ProjectileHit projhit, Unit unit, LandfallContentDatabase db)
		{
		}

		public static void EditCombatMoves(GameObject move, int index, Unit unit, LandfallContentDatabase db)
		{
			//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_006b: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: 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_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Expected O, but got Unknown
			if (unit.unitBlueprint.Entity.Name == "666" && Object.op_Implicit((Object)(object)move.GetComponentInChildren<DodgeMove>()) && index == 2)
			{
				move.GetComponentInChildren<DodgeMove>().moves[0].forceCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[5]
				{
					new Keyframe(0f, 0f),
					new Keyframe(1f, 1f),
					new Keyframe(2f, 1f),
					new Keyframe(0f, 0f),
					new Keyframe(0f, 0f)
				});
				move.GetComponentInChildren<DodgeMove>().forceMultiplier = -1f;
			}
			if (unit.unitBlueprint.Entity.Name == "666" && Object.op_Implicit((Object)(object)move.GetComponentInChildren<DodgeMove>()) && index == 3)
			{
				move.GetComponentInChildren<DodgeMove>().moves[0].forceCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[5]
				{
					new Keyframe(-1f, 1f),
					new Keyframe(1f, 1f),
					new Keyframe(5f, 4f),
					new Keyframe(0f, 0f),
					new Keyframe(0f, 0f)
				});
				move.GetComponentInChildren<DodgeMove>().forceMultiplier = -2f;
			}
			if (unit.unitBlueprint.Entity.Name == "666" && Object.op_Implicit((Object)(object)move.GetComponentInChildren<DodgeMove>()) && index == 4)
			{
				move.GetComponentInChildren<DodgeMove>().moves[0].forceCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[5]
				{
					new Keyframe(-1f, 1f),
					new Keyframe(1f, 1f),
					new Keyframe(5f, 4f),
					new Keyframe(0f, 0f),
					new Keyframe(0f, 0f)
				});
			}
		}

		public static void CodeAfterSpawn(Unit unit, LandfallContentDatabase db)
		{
			//IL_0028: 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)
			if (unit.unitBlueprint.Entity.Name == "unit name")
			{
				Transform head = unit.data.head;
				head.localScale *= 2f;
			}
		}

		public static void Init(LandfallContentDatabase db)
		{
			com = "Bundle Mod Init";
			com = "Bundle Mod Init";
			MyModItems.GetInstance();
			com = "——————————Fations and Units——————————";
			com = "——————————Clothes——————————";
			com = "——————————Weapons——————————";
			com = "——————————Effects——————————";
			com = "——————————Explosions——————————";
			com = "——————————UnitBases——————————";
			com = "——————————Projectiles——————————";
			com = "——————————Moves——————————";
		}

		public static void EditWeapons(GameObject weapon, Team team, Unit unit, MeleeWeapon melee, RangeWeapon range, LandfallContentDatabase db)
		{
		}

		public static void SetMoveConditionalValue(this ConditionalEventInstance gameObject, ConditionType type, ValueType valuet, float value)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0065: Expected O, but got Unknown
			bool flag = false;
			EventCondition[] conditions = gameObject.conditions;
			foreach (EventCondition val in conditions)
			{
				if (val.conditionType == type)
				{
					val.valueType = valuet;
					val.value = value;
					flag = true;
				}
			}
			if (!flag)
			{
				List<EventCondition> list = gameObject.conditions.ToList();
				list.Add(new EventCondition
				{
					conditionType = type,
					valueType = valuet,
					value = value
				});
				gameObject.conditions = list.ToArray();
			}
		}
	}
	[BepInPlugin("fixmod", "fixmod", "1.0.0")]
	internal class Loader : BaseUnityPlugin
	{
		public static bool BundleMode;

		private void Awake()
		{
			((MonoBehaviour)this).StartCoroutine("call");
		}

		private IEnumerator call()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
			yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
			yield return (object)new WaitForSecondsRealtime(0.3f);
			SLMALoader.GetInstance();
			LandfallContentDatabase landfallContentDatabase = ContentDatabase.Instance().LandfallContentDatabase;
			UManager.Init(landfallContentDatabase);
			new Harmony(UManager.modname).PatchAll();
			GOSLMA.EditWeapons = ((GOSLMA.EditWeapons == null) ? new Action<GameObject, Team, Unit, MeleeWeapon, RangeWeapon, LandfallContentDatabase>(UManager.EditWeapons) : ((Action<GameObject, Team, Unit, MeleeWeapon, RangeWeapon, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, Team, Unit, MeleeWeapon, RangeWeapon, LandfallContentDatabase>(UManager.EditWeapons), GOSLMA.EditWeapons)));
			GOSLMA.EditClothes = ((GOSLMA.EditClothes == null) ? new Action<GameObject, CharacterItem, PropItemData, Unit, int, LandfallContentDatabase>(UManager.EditClothes) : ((Action<GameObject, CharacterItem, PropItemData, Unit, int, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, CharacterItem, PropItemData, Unit, int, LandfallContentDatabase>(UManager.EditClothes), GOSLMA.EditClothes)));
			GOSLMA.EditCombatMoves = ((GOSLMA.EditCombatMoves == null) ? new Action<GameObject, int, Unit, LandfallContentDatabase>(UManager.EditCombatMoves) : ((Action<GameObject, int, Unit, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, int, Unit, LandfallContentDatabase>(UManager.EditCombatMoves), GOSLMA.EditCombatMoves)));
			GOSLMA.CodeAfterSpawn = ((GOSLMA.CodeAfterSpawn == null) ? new Action<Unit, LandfallContentDatabase>(UManager.CodeAfterSpawn) : ((Action<Unit, LandfallContentDatabase>)Delegate.Combine(new Action<Unit, LandfallContentDatabase>(UManager.CodeAfterSpawn), GOSLMA.CodeAfterSpawn)));
			GOSLMA.EditProjectiles = ((GOSLMA.EditProjectiles == null) ? new Action<GameObject, ProjectileHit, Unit, LandfallContentDatabase>(UManager.EditProjectiles) : ((Action<GameObject, ProjectileHit, Unit, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, ProjectileHit, Unit, LandfallContentDatabase>(UManager.EditProjectiles), GOSLMA.EditProjectiles)));
			UnitBlueprint[] array = Resources.FindObjectsOfTypeAll<UnitBlueprint>();
			for (int i = 0; i < array.Length; i++)
			{
				UManager.EditBlueprint(array[i], landfallContentDatabase);
			}
			Debug.Log((object)("Loaded " + UManager.modname + " Successfully"));
			Debug.Log((object)(UManager.modname + "is made in SFT by FhpSlime"));
			Debug.Log((object)(UManager.modder + "wished you a pleasant trip"));
		}

		static Loader()
		{
			BundleMode = true;
		}
	}
}
public class Item : MonoBehaviour
{
	public enum kind
	{
		Weapon,
		Cloth,
		Skill,
		Unit,
		Projectile,
		Other
	}

	public string name;

	public kind Kind;
}
namespace fixmod
{
	public class MyModItems : MonoBehaviour
	{
		private static Dictionary<string, Item> items;

		private static MyModItems instance { get; set; }

		public static MyModItems GetInstance()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)instance == (Object)null)
			{
				instance = new GameObject("MyModItems").AddComponent<MyModItems>();
				Object.DontDestroyOnLoad((Object)(object)instance);
			}
			return instance;
		}

		public void AddItem(Item item)
		{
			items.Add(item.name, item);
		}

		public Item GetItem(string name)
		{
			Item value = new Item
			{
				name = null,
				Kind = Item.kind.Other
			};
			items.TryGetValue(name, out value);
			return value;
		}
	}
	public class ExplosionFixer : MonoBehaviour
	{
		private void Update()
		{
			//IL_000b: 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_0011: 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)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			Team team = ((Component)this).GetComponentInParent<Unit>().data.team;
			if ((int)team == 0)
			{
				Explosion[] componentsInChildren = ((Component)this).GetComponentsInChildren<Explosion>();
				foreach (Explosion obj in componentsInChildren)
				{
					s.SetField<Explosion>(obj, "team", (object)team);
					obj.ignoreTeamMates = false;
					obj.onlyTeamMates = true;
				}
				componentsInChildren = ((Component)((Component)this).transform.GetChild(0)).GetComponentsInChildren<Explosion>();
				foreach (Explosion obj2 in componentsInChildren)
				{
					s.SetField<Explosion>(obj2, "team", (object)team);
					obj2.ignoreTeamMates = false;
					obj2.onlyTeamMates = true;
				}
			}
			else
			{
				Explosion[] componentsInChildren = ((Component)this).GetComponentsInChildren<Explosion>();
				foreach (Explosion obj3 in componentsInChildren)
				{
					s.SetField<Explosion>(obj3, "team", (object)team);
					obj3.ignoreTeamMates = true;
					obj3.onlyTeamMates = false;
				}
				componentsInChildren = ((Component)((Component)this).transform.GetChild(0)).GetComponentsInChildren<Explosion>();
				foreach (Explosion obj4 in componentsInChildren)
				{
					s.SetField<Explosion>(obj4, "team", (object)team);
					obj4.ignoreTeamMates = true;
					obj4.onlyTeamMates = false;
				}
			}
		}
	}
}
public class Example : MonoBehaviour
{
	public GameObject prefab;

	private void Start()
	{
		if ((Object)(object)prefab != (Object)null)
		{
			Transform[] componentsInChildren = prefab.GetComponentsInChildren<Transform>();
			if (componentsInChildren.Length > 1)
			{
				_ = componentsInChildren[1];
			}
		}
	}
}
namespace fixmod
{
	public class RangeWeaponAmmoFixer : MonoBehaviour
	{
		[Header("修复设置")]
		[Tooltip("是否启用循环修复")]
		public bool enableFix = true;

		private RangeWeapon rangeWeapon;

		private int lastAmmo;

		private float originalSpawnDelay;

		[Tooltip("弹药耗尽后的等待时间(秒)")]
		public float waitTimeAfterEmpty;

		private bool isWaiting;

		private float waitTimer;

		private bool isRecovering;

		private int originalMagSize;

		public bool IsWaiting => isWaiting;

		public float RemainingWaitTime => Mathf.Max(0f, waitTimeAfterEmpty - waitTimer);

		private void Start()
		{
			rangeWeapon = ((Component)this).GetComponent<RangeWeapon>();
			if ((Object)(object)rangeWeapon != (Object)null)
			{
				originalSpawnDelay = rangeWeapon.spawnDelay;
				originalMagSize = rangeWeapon.magSize;
				lastAmmo = rangeWeapon.GetAmmo();
			}
			else
			{
				Debug.LogWarning((object)"RangeWeaponAmmoFixer: 未找到RangeWeapon组件,组件将被禁用");
				((Behaviour)this).enabled = false;
			}
		}

		private void Update()
		{
			if (!enableFix || (Object)(object)rangeWeapon == (Object)null)
			{
				return;
			}
			int ammo = rangeWeapon.GetAmmo();
			if (ammo <= 0 && lastAmmo > 0 && !isWaiting)
			{
				StartWaiting();
			}
			if (isWaiting && !isRecovering)
			{
				waitTimer += Time.deltaTime;
				if (waitTimer >= waitTimeAfterEmpty)
				{
					StartRecovery();
				}
			}
			lastAmmo = ammo;
		}

		public void ResetFix()
		{
			if ((Object)(object)rangeWeapon != (Object)null)
			{
				RestoreWeaponToOriginalState();
				ResetWeaponData();
				rangeWeapon.allowedToFire = true;
				isWaiting = false;
				isRecovering = false;
				waitTimer = 0f;
			}
		}

		public RangeWeaponAmmoFixer()
		{
			lastAmmo = -1;
		}

		private void StartWaiting()
		{
			if ((Object)(object)rangeWeapon == (Object)null)
			{
				return;
			}
			try
			{
				isWaiting = true;
				waitTimer = 0f;
				rangeWeapon.allowedToFire = false;
				rangeWeapon.spawnDelay = 999999f;
				((MonoBehaviour)rangeWeapon).StopAllCoroutines();
				Debug.Log((object)$"RangeWeaponAmmoFixer: 弹药耗尽,开始等待 {waitTimeAfterEmpty} 秒,已清除多余发射逻辑");
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("RangeWeaponAmmoFixer: 开始等待时出现错误: " + ex.Message));
			}
		}

		private void StartRecovery()
		{
			isRecovering = true;
			((MonoBehaviour)this).StartCoroutine(RecoverShooting());
		}

		private IEnumerator RecoverShooting()
		{
			yield return null;
			if ((Object)(object)rangeWeapon == (Object)null)
			{
				yield break;
			}
			((MonoBehaviour)rangeWeapon).StopAllCoroutines();
			yield return null;
			try
			{
				RestoreWeaponToOriginalState();
				ResetWeaponData();
				rangeWeapon.allowedToFire = true;
				isWaiting = false;
				isRecovering = false;
				waitTimer = 0f;
				Debug.Log((object)"RangeWeaponAmmoFixer: 等待完成,武器已完全恢复原始状态,可以继续射击");
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("RangeWeaponAmmoFixer: 恢复射击时出现错误: " + ex.Message));
			}
		}

		private void ResetWeaponData()
		{
			if ((Object)(object)rangeWeapon == (Object)null)
			{
				return;
			}
			try
			{
				FieldInfo field = ((object)rangeWeapon).GetType().GetField("spawnDelayCounter", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field != null)
				{
					field.SetValue(rangeWeapon, 0f);
					Debug.Log((object)"RangeWeaponAmmoFixer: 已重置spawnDelayCounter");
				}
				FieldInfo field2 = ((object)rangeWeapon).GetType().GetField("internalCounter", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field2 != null)
				{
					field2.SetValue(rangeWeapon, 10000f);
					Debug.Log((object)"RangeWeaponAmmoFixer: 已重置internalCounter");
				}
				FieldInfo field3 = ((object)rangeWeapon).GetType().GetField("reloading", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field3 != null)
				{
					field3.SetValue(rangeWeapon, false);
					Debug.Log((object)"RangeWeaponAmmoFixer: 已重置reloading状态");
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("RangeWeaponAmmoFixer: 刷新武器数据时出现警告: " + ex.Message));
			}
		}

		private void RestoreWeaponToOriginalState()
		{
			if ((Object)(object)rangeWeapon == (Object)null)
			{
				return;
			}
			try
			{
				rangeWeapon.spawnDelay = originalSpawnDelay;
				rangeWeapon.magSize = originalMagSize;
				rangeWeapon.Reload();
				Debug.Log((object)$"RangeWeaponAmmoFixer: 已恢复原始spawnDelay: {originalSpawnDelay}, magSize: {originalMagSize}");
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("RangeWeaponAmmoFixer: 恢复原始状态时出现警告: " + ex.Message));
			}
		}
	}
	public class HoldableLookAtFixer : MonoBehaviour
	{
		public bool enableFix = true;

		public float returnSmoothTime = 0.3f;

		public float returnThreshold = 1f;

		private Holdable holdable;

		private DataHandler holderData;

		private Vector3 originalForwardRotation;

		private Vector3 originalUpRotation;

		private bool isLookingAtTarget;

		private bool isReturning;

		private float returnTimer;

		private Vector3 currentForwardVelocity;

		private Vector3 currentUpVelocity;

		public bool IsLookingAtTarget => isLookingAtTarget;

		public bool IsReturning => isReturning;

		public float ReturnProgress
		{
			get
			{
				if (!isReturning)
				{
					return 1f;
				}
				return Mathf.Clamp01(returnTimer / returnSmoothTime);
			}
		}

		private void Start()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			holdable = ((Component)this).GetComponent<Holdable>();
			if ((Object)(object)holdable == (Object)null)
			{
				((Behaviour)this).enabled = false;
				return;
			}
			originalForwardRotation = holdable.holdableData.forwardRotation;
			originalUpRotation = holdable.holdableData.upRotation;
		}

		private void Update()
		{
			if (!enableFix || (Object)(object)holdable == (Object)null)
			{
				return;
			}
			if ((Object)(object)holderData == (Object)null && (Object)(object)holdable.holderData != (Object)null)
			{
				holderData = holdable.holderData;
			}
			if (!((Object)(object)holderData == (Object)null))
			{
				bool flag = ShouldLookAtTarget();
				if (flag && !isLookingAtTarget)
				{
					StartLookingAtTarget();
				}
				else if (!flag && isLookingAtTarget && !isReturning)
				{
					StartReturning();
				}
				if (isReturning)
				{
					ProcessReturning();
				}
			}
		}

		private bool ShouldLookAtTarget()
		{
			if (holdable.holdableData.lookAtTargetWhenWithin > 0f && !((Object)(object)holderData.targetMainRig == (Object)null))
			{
				return holderData.distanceToTarget < holdable.holdableData.lookAtTargetWhenWithin;
			}
			return false;
		}

		private void StartLookingAtTarget()
		{
			isLookingAtTarget = true;
			isReturning = false;
			returnTimer = 0f;
		}

		private void StartReturning()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			isReturning = true;
			returnTimer = 0f;
			currentForwardVelocity = Vector3.zero;
			currentUpVelocity = Vector3.zero;
		}

		private void ProcessReturning()
		{
			//IL_0028: 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_003f: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			returnTimer += Time.deltaTime;
			holdable.holdableData.forwardRotation = Vector3.SmoothDamp(holdable.holdableData.forwardRotation, originalForwardRotation, ref currentForwardVelocity, returnSmoothTime);
			holdable.holdableData.upRotation = Vector3.SmoothDamp(holdable.holdableData.upRotation, originalUpRotation, ref currentUpVelocity, returnSmoothTime);
			float num = Vector3.Angle(holdable.holdableData.forwardRotation, originalForwardRotation);
			float num2 = Vector3.Angle(holdable.holdableData.upRotation, originalUpRotation);
			if (num < returnThreshold && num2 < returnThreshold)
			{
				CompleteReturning();
			}
		}

		private void CompleteReturning()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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)
			holdable.holdableData.forwardRotation = originalForwardRotation;
			holdable.holdableData.upRotation = originalUpRotation;
			isLookingAtTarget = false;
			isReturning = false;
			returnTimer = 0f;
		}

		public void ResetOrientation()
		{
			//IL_001a: 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)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)holdable != (Object)null)
			{
				holdable.holdableData.forwardRotation = originalForwardRotation;
				holdable.holdableData.upRotation = originalUpRotation;
				isLookingAtTarget = false;
				isReturning = false;
				returnTimer = 0f;
			}
		}
	}
}