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;
using FhpSLib.BundleModCore;
using HarmonyLib;
using Landfall.TABS;
using SLMA;
using TFBGames;
using Unity.Collections;
using Unity.Jobs;
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_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Expected O, but got Unknown
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: 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_WESTERN_QUICKDRAW")
{
GameObject obj2 = UPool.MyPool.AddObject("xiufu3", (GameObject)SLMALoader.SDic["weapons"]["Quickdraw_Revolver_AgainstHip"], true, (HideFlags)52, (Sprite)null, 0, true);
obj2.GetComponentInChildren<RangeWeapon>().useSpawnDelayForEveryShot = true;
obj2.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)
{
foreach (GameObject value in HelpLibrary.m_unitBases.Values)
{
if (Object.op_Implicit((Object)(object)value.GetComponentInChildren<SkinnedMeshRenderer>()))
{
SkinnedMeshRenderer[] componentsInChildren = value.GetComponentsInChildren<SkinnedMeshRenderer>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].updateWhenOffscreen = true;
}
}
}
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);
AddTargetableEffectExplosionTeamFix.ApplyPatches();
BlockMoveOptimizationPatches.ApplyPatches();
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 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;
}
}
}
internal static class AddTargetableEffectExplosionTeamFix
{
public static void ApplyPatches()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0025: Expected O, but got Unknown
try
{
Debug.Log((object)"[AddTargetableEffectExplosionTeamFix] 正在应用 AddTargetableEffect Explosion 队伍判断修复补丁...");
Harmony val = new Harmony("Mod_Name.AddTargetableEffectExplosionTeamFix");
PatchAddTargetableEffectDoEffect(val);
PatchExplosionExplode(val);
PatchExplosionStart(val);
Debug.Log((object)"[AddTargetableEffectExplosionTeamFix] AddTargetableEffect Explosion 队伍判断修复补丁应用完成!");
}
catch (Exception ex)
{
Debug.LogError((object)("[AddTargetableEffectExplosionTeamFix] 应用补丁时发生错误: " + ex.Message + "\n" + ex.StackTrace));
}
}
private static void PatchAddTargetableEffectDoEffect(Harmony harmony)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
MethodInfo method = typeof(AddTargetableEffect).GetMethod("DoEffect", new Type[2]
{
typeof(Transform),
typeof(Transform)
});
if (method != null)
{
harmony.Patch((MethodBase)method, new HarmonyMethod(typeof(AddTargetableEffectExplosionTeamFix).GetMethod("AddTargetableEffect_DoEffect_Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Debug.Log((object)"[AddTargetableEffectExplosionTeamFix] 已补丁 AddTargetableEffect.DoEffect(Transform, Transform)");
}
else
{
Debug.LogWarning((object)"[AddTargetableEffectExplosionTeamFix] 未找到 AddTargetableEffect.DoEffect(Transform, Transform) 方法");
}
}
private static bool AddTargetableEffect_DoEffect_Prefix(AddTargetableEffect __instance, Transform startPoint, Transform target)
{
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
try
{
DataHandler componentInChildren = ((Component)((Component)target).transform.root).GetComponentInChildren<DataHandler>();
if ((Object)(object)componentInChildren == (Object)null || componentInChildren.Dead || !Object.op_Implicit((Object)(object)componentInChildren))
{
return true;
}
UnitEffectBase val = UnitEffectBase.AddEffectToTarget(((Component)target).gameObject, __instance.EffectPrefab);
if ((Object)(object)val != (Object)null)
{
val.Ping();
return false;
}
FieldInfo field = typeof(AddTargetableEffect).GetField("unit", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeof(AddTargetableEffect).GetField("rootTeamHolder", BindingFlags.Instance | BindingFlags.NonPublic);
object? obj = ((field != null) ? field.GetValue(__instance) : null);
Unit val2 = (Unit)((obj is Unit) ? obj : null);
object? obj2 = ((field2 != null) ? field2.GetValue(__instance) : null);
TeamHolder val3 = (TeamHolder)((obj2 is TeamHolder) ? obj2 : null);
if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
{
TeamHolder.GetTeamRelevantComponents(((Component)__instance).transform.root, ref val2, ref val3);
}
UnitEffectBase val4 = Object.Instantiate<UnitEffectBase>(__instance.EffectPrefab, ((Component)target).transform.root);
((Component)val4).transform.position = ((Component)target).transform.root.position;
val4.damageMultiplier = ((TargetableEffect)__instance).damageMultiplier;
TeamHolder val5 = TeamHolder.AddTeamHolder(((Component)val4).gameObject, val2, val3);
Explosion[] componentsInChildren = ((Component)val4).GetComponentsInChildren<Explosion>();
foreach (Explosion val6 in componentsInChildren)
{
if (!((Object)(object)val6 != (Object)null))
{
continue;
}
FieldInfo field3 = typeof(Explosion).GetField("teamHolder", BindingFlags.Instance | BindingFlags.NonPublic);
if (field3 != null && (Object)(object)val5 != (Object)null)
{
field3.SetValue(val6, val5);
}
if (val6.automatic && (Object)(object)val5 != (Object)null)
{
FieldInfo field4 = typeof(Explosion).GetField("team", BindingFlags.Instance | BindingFlags.NonPublic);
if (field4 != null)
{
field4.SetValue(val6, val5.team);
}
}
}
val4.DoEffect();
return false;
}
catch (Exception ex)
{
Debug.LogError((object)("[AddTargetableEffectExplosionTeamFix] AddTargetableEffect_DoEffect_Prefix 执行失败: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
private static void PatchExplosionExplode(Harmony harmony)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
MethodInfo method = typeof(Explosion).GetMethod("Explode", BindingFlags.Instance | BindingFlags.Public);
if (method != null)
{
harmony.Patch((MethodBase)method, new HarmonyMethod(typeof(AddTargetableEffectExplosionTeamFix).GetMethod("Explosion_Explode_Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Debug.Log((object)"[AddTargetableEffectExplosionTeamFix] 已补丁 Explosion.Explode()");
}
else
{
Debug.LogWarning((object)"[AddTargetableEffectExplosionTeamFix] 未找到 Explosion.Explode() 方法");
}
}
private static bool Explosion_Explode_Prefix(Explosion __instance)
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: 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_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
try
{
__instance.Start();
FieldInfo field = typeof(Explosion).GetField("teamHolder", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeof(Explosion).GetField("team", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field3 = typeof(Explosion).GetField("ownUnit", BindingFlags.Instance | BindingFlags.NonPublic);
object? obj = ((field != null) ? field.GetValue(__instance) : null);
TeamHolder val = (TeamHolder)((obj is TeamHolder) ? obj : null);
if (field2 != null && field2.GetValue(__instance) != null)
{
_ = (Team)field2.GetValue(__instance);
}
object? obj2 = ((field3 != null) ? field3.GetValue(__instance) : null);
Unit val2 = (Unit)((obj2 is Unit) ? obj2 : null);
if ((Object)(object)val == (Object)null)
{
val = ((Component)__instance).GetComponentInParent<TeamHolder>();
}
if ((Object)(object)val == (Object)null)
{
Transform parent = ((Component)__instance).transform.parent;
while ((Object)(object)parent != (Object)null && (Object)(object)val == (Object)null)
{
val = ((Component)parent).GetComponent<TeamHolder>();
if ((Object)(object)val == (Object)null)
{
parent = parent.parent;
}
}
}
if ((Object)(object)val != (Object)null)
{
Team team = val.team;
if ((Object)(object)val.spawner != (Object)null)
{
val2 = val.spawner.GetComponentInParent<Unit>();
}
if (field != null)
{
field.SetValue(__instance, val);
}
if (field2 != null)
{
field2.SetValue(__instance, team);
}
if (field3 != null && (Object)(object)val2 != (Object)null)
{
field3.SetValue(__instance, val2);
}
}
else
{
Unit component = ((Component)((Component)__instance).transform.root).GetComponent<Unit>();
if ((Object)(object)component != (Object)null)
{
TeamHolder component2 = ((Component)component).GetComponent<TeamHolder>();
Team team2;
if ((Object)(object)component2 != (Object)null && (Object)(object)component2.spawner == (Object)(object)((Component)component).gameObject)
{
team2 = component.Team;
val2 = component;
}
else
{
TeamHolder componentInChildren = ((Component)((Component)__instance).transform.root).GetComponentInChildren<TeamHolder>();
if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.spawner != (Object)null)
{
Unit componentInParent = componentInChildren.spawner.GetComponentInParent<Unit>();
if ((Object)(object)componentInParent != (Object)null)
{
team2 = componentInParent.Team;
val2 = componentInParent;
}
else
{
team2 = component.Team;
val2 = component;
}
}
else
{
team2 = component.Team;
val2 = component;
}
}
if (field2 != null)
{
field2.SetValue(__instance, team2);
}
if (field3 != null && (Object)(object)val2 != (Object)null)
{
field3.SetValue(__instance, val2);
}
}
}
return true;
}
catch (Exception ex)
{
Debug.LogError((object)("[AddTargetableEffectExplosionTeamFix] Explosion_Explode_Prefix 执行失败: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
private static void PatchExplosionStart(Harmony harmony)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
MethodInfo method = typeof(Explosion).GetMethod("Start", BindingFlags.Instance | BindingFlags.Public);
if (method != null)
{
harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(typeof(AddTargetableEffectExplosionTeamFix).GetMethod("Explosion_Start_Postfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Debug.Log((object)"[AddTargetableEffectExplosionTeamFix] 已补丁 Explosion.Start()");
}
else
{
Debug.LogWarning((object)"[AddTargetableEffectExplosionTeamFix] 未找到 Explosion.Start() 方法");
}
}
private static void Explosion_Start_Postfix(Explosion __instance)
{
try
{
FieldInfo field = typeof(Explosion).GetField("teamHolder", BindingFlags.Instance | BindingFlags.NonPublic);
object? obj = ((field != null) ? field.GetValue(__instance) : null);
TeamHolder val = (TeamHolder)((obj is TeamHolder) ? obj : null);
if (!((Object)(object)val == (Object)null))
{
return;
}
val = ((Component)__instance).GetComponentInParent<TeamHolder>();
if ((Object)(object)val == (Object)null)
{
Transform parent = ((Component)__instance).transform.parent;
while ((Object)(object)parent != (Object)null && (Object)(object)val == (Object)null)
{
val = ((Component)parent).GetComponent<TeamHolder>();
if ((Object)(object)val == (Object)null)
{
parent = parent.parent;
}
}
}
if (field != null && (Object)(object)val != (Object)null)
{
field.SetValue(__instance, val);
}
}
catch (Exception ex)
{
Debug.LogWarning((object)("[AddTargetableEffectExplosionTeamFix] Explosion_Start_Postfix 执行失败: " + ex.Message));
}
}
}
}
[HarmonyPatch(typeof(RaycastTrail), "Check")]
internal class RaycastTrailOptimizationPatch
{
[HarmonyPrefix]
public static bool Prefix(RaycastTrail __instance, ref Vector3 ___lastPos, ref Vector3 ___deltaPos, ref ProjectileHit ___projectileHit, ref NativeArray<RaycastCommand> ___raycastCommands, ref NativeArray<RaycastHit> ___raycastHits, ref JobHandle ___jobHandle, ref bool ___nativeArraysDisposed, ref int ___ignoredFrames)
{
//IL_0035: 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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: 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_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: 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_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_037a: Unknown result type (might be due to invalid IL or missing references)
//IL_037f: Unknown result type (might be due to invalid IL or missing references)
//IL_0384: Unknown result type (might be due to invalid IL or missing references)
//IL_038f: Unknown result type (might be due to invalid IL or missing references)
//IL_039d: Unknown result type (might be due to invalid IL or missing references)
//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0368: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
if (___nativeArraysDisposed)
{
return true;
}
if (___ignoredFrames > 0)
{
___ignoredFrames--;
___lastPos = ((Component)__instance).transform.position;
return true;
}
((JobHandle)(ref ___jobHandle)).Complete();
Vector3 position = ((Component)__instance).transform.position;
Vector3 val = position - ___lastPos;
float magnitude = ((Vector3)(ref val)).magnitude;
if (magnitude < 0.01f)
{
___lastPos = position;
if (!___nativeArraysDisposed)
{
___raycastCommands[0] = new RaycastCommand(___lastPos, ((Vector3)(ref val)).normalized, 0.01f, LayerMask.op_Implicit(__instance.mask), 1);
___jobHandle = RaycastCommand.ScheduleBatch(___raycastCommands, ___raycastHits, 1, default(JobHandle));
}
return true;
}
int num = Mathf.Max(1, Mathf.CeilToInt(magnitude / 0.5f));
bool flag = false;
RaycastHit val2 = default(RaycastHit);
HashSet<Collider> hashSet = new HashSet<Collider>();
RaycastHit val6 = default(RaycastHit);
for (int i = 0; i < num; i++)
{
float num2 = (float)i / (float)num;
float num3 = (float)(i + 1) / (float)num;
Vector3 val3 = Vector3.Lerp(___lastPos, position, num2);
Vector3 val4 = Vector3.Lerp(___lastPos, position, num3) - val3;
float magnitude2 = ((Vector3)(ref val4)).magnitude;
if (magnitude2 < 0.001f)
{
continue;
}
if (__instance.useSphereCastOnUnits)
{
RaycastHit[] array = Physics.SphereCastAll(val3, __instance.radius, ((Vector3)(ref val4)).normalized, magnitude2, LayerMask.op_Implicit(__instance.mask));
if (array != null && array.Length != 0)
{
RaycastHit val5 = default(RaycastHit);
float num4 = float.MaxValue;
bool flag2 = false;
for (int j = 0; j < array.Length; j++)
{
if ((!((Object)(object)((RaycastHit)(ref array[j])).collider != (Object)null) || !hashSet.Contains(((RaycastHit)(ref array[j])).collider)) && ((RaycastHit)(ref array[j])).distance < num4)
{
num4 = ((RaycastHit)(ref array[j])).distance;
val5 = array[j];
flag2 = true;
}
}
if (flag2 && (Object)(object)((RaycastHit)(ref val5)).collider != (Object)null)
{
val2 = val5;
hashSet.Add(((RaycastHit)(ref val5)).collider);
___projectileHit.Hit(val5, 1f);
flag = true;
break;
}
}
}
if (Physics.Raycast(val3, ((Vector3)(ref val4)).normalized, ref val6, magnitude2, LayerMask.op_Implicit(__instance.mask)) && (!((Object)(object)((RaycastHit)(ref val6)).collider != (Object)null) || !hashSet.Contains(((RaycastHit)(ref val6)).collider)))
{
val2 = val6;
if ((Object)(object)((RaycastHit)(ref val6)).collider != (Object)null)
{
hashSet.Add(((RaycastHit)(ref val6)).collider);
}
___projectileHit.Hit(val6, 1f);
flag = true;
break;
}
}
if (flag && (Object)(object)((RaycastHit)(ref val2)).collider != (Object)null)
{
Vector3 point = ((RaycastHit)(ref val2)).point;
___deltaPos = point - ___lastPos;
___lastPos = point;
}
else
{
___deltaPos = val;
___lastPos = position;
}
if (!___nativeArraysDisposed)
{
Vector3 val7 = ((Vector3)(ref ___deltaPos)).normalized;
float num5 = Mathf.Max(0.1f, ((Vector3)(ref ___deltaPos)).magnitude);
if (num5 < 0.01f)
{
MoveTransform component = ((Component)__instance).GetComponent<MoveTransform>();
if ((Object)(object)component != (Object)null && ((Vector3)(ref component.velocity)).magnitude > 0.1f)
{
val7 = ((Vector3)(ref component.velocity)).normalized;
num5 = ((Vector3)(ref component.velocity)).magnitude * Time.fixedDeltaTime;
}
else
{
val7 = Vector3.forward;
num5 = 0.1f;
}
}
___raycastCommands[0] = new RaycastCommand(___lastPos, val7, num5, LayerMask.op_Implicit(__instance.mask), 1);
___jobHandle = RaycastCommand.ScheduleBatch(___raycastCommands, ___raycastHits, 1, default(JobHandle));
}
return !flag;
}
}
[HarmonyPatch(typeof(BlockMove), "ProjectileBlock")]
internal class BlockMoveOptimizationPatch
{
private static Dictionary<GameObject, float> recentlyBlockedProjectiles = new Dictionary<GameObject, float>();
private const float BLOCK_COOLDOWN = 0.1f;
[HarmonyPrefix]
public static bool Prefix(BlockMove __instance, GameObject projectile, HitData hit, ref bool __result)
{
if (Random.Range(0, 100) == 0)
{
CleanupExpiredRecords();
}
if (recentlyBlockedProjectiles.TryGetValue(projectile, out var value) && Time.time - value < 0.1f)
{
__result = false;
return false;
}
return true;
}
private static void CleanupExpiredRecords()
{
float time = Time.time;
List<GameObject> list = new List<GameObject>();
foreach (KeyValuePair<GameObject, float> recentlyBlockedProjectile in recentlyBlockedProjectiles)
{
if (time - recentlyBlockedProjectile.Value > 0.2f || (Object)(object)recentlyBlockedProjectile.Key == (Object)null)
{
list.Add(recentlyBlockedProjectile.Key);
}
}
foreach (GameObject item in list)
{
recentlyBlockedProjectiles.Remove(item);
}
}
[HarmonyPostfix]
public static void Postfix(BlockMove __instance, GameObject projectile, HitData hit, ref bool __result, ref DataHandler ___data, ref bool ___reflect, ref FixedTimeStepService ___fixedTimeStepService, ref bool ___goodReflect)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: 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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: 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_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: 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)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: 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_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: 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)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Invalid comparison between Unknown and I4
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
if (__result)
{
recentlyBlockedProjectiles[projectile] = Time.time;
RaycastTrail component = projectile.GetComponent<RaycastTrail>();
if ((Object)(object)component != (Object)null && component.ignoredFrames < 3)
{
component.ignoredFrames = 3;
}
}
if (!__result || !___reflect || (Object)(object)___data == (Object)null)
{
return;
}
MoveTransform component2 = projectile.GetComponent<MoveTransform>();
if ((Object)(object)component2 == (Object)null)
{
return;
}
Vector3 val = (((Object)(object)___data.mainRig != (Object)null) ? ((Component)___data.mainRig).transform.position : ((Component)___data).transform.position);
Vector3 position = projectile.transform.position;
Vector3 val2 = (((Object)(object)___data.characterForwardObject != (Object)null) ? ___data.characterForwardObject.forward : ((Component)___data).transform.forward);
Vector3 val3 = position - val;
Vector3 normalized = ((Vector3)(ref val3)).normalized;
if (!(Vector3.Dot(val2, normalized) < 0f))
{
return;
}
Vector3 val4;
if (Vector3.Dot(((Vector3)(ref component2.velocity)).normalized, -val2) > 0.5f)
{
val3 = Vector3.Cross(val2, Vector3.up);
Vector3 normalized2 = ((Vector3)(ref val3)).normalized;
if (((Vector3)(ref normalized2)).magnitude < 0.1f)
{
val3 = Vector3.Cross(val2, Vector3.forward);
normalized2 = ((Vector3)(ref val3)).normalized;
}
val3 = val2 + normalized2 * Random.Range(-1f, 1f);
val4 = ((Vector3)(ref val3)).normalized;
}
else
{
Vector3 val5 = Vector3.Reflect(((Vector3)(ref component2.velocity)).normalized, hit.normal);
if (Vector3.Dot(val5, -val2) > 0.3f)
{
val3 = Vector3.Cross(val2, Vector3.up);
Vector3 normalized3 = ((Vector3)(ref val3)).normalized;
if (((Vector3)(ref normalized3)).magnitude < 0.1f)
{
val3 = Vector3.Cross(val2, Vector3.forward);
normalized3 = ((Vector3)(ref val3)).normalized;
}
val3 = val5 + normalized3 * Random.Range(0.5f, 1.5f);
val4 = ((Vector3)(ref val3)).normalized;
}
else
{
val4 = val5;
}
}
float magnitude = ((Vector3)(ref component2.velocity)).magnitude;
FixedTimeStep currentFixedTimeStep = ___fixedTimeStepService.CurrentFixedTimeStep;
if ((int)currentFixedTimeStep != 0)
{
if ((int)currentFixedTimeStep == 1)
{
component2.velocity = val4 * magnitude * 1.25f;
}
else
{
component2.velocity = val4 * magnitude;
}
}
else
{
component2.velocity = val4 * magnitude;
}
if (!___goodReflect)
{
component2.velocity *= Random.Range(0.3f, 0.5f);
}
}
}
public static class BlockMoveOptimizationPatches
{
private static Harmony harmonyInstance;
private static bool patchesApplied;
public static void ApplyPatches(Harmony harmony = null)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
if (patchesApplied)
{
Debug.Log((object)"[BlockMoveOptimization] 补丁已经应用,跳过重复应用");
return;
}
if (harmony == null)
{
harmony = new Harmony("com.blockmove.optimization");
}
harmonyInstance = harmony;
try
{
harmony.PatchAll(typeof(RaycastTrailOptimizationPatch));
harmony.PatchAll(typeof(BlockMoveOptimizationPatch));
patchesApplied = true;
Debug.Log((object)"[BlockMoveOptimization] 所有补丁已成功应用");
}
catch (Exception ex)
{
Debug.LogError((object)("[BlockMoveOptimization] 应用补丁时发生错误: " + ex.Message));
Debug.LogError((object)("[BlockMoveOptimization] 错误堆栈: " + ex.StackTrace));
throw;
}
}
public static void RemovePatches()
{
if (!patchesApplied || harmonyInstance == null)
{
Debug.Log((object)"[BlockMoveOptimization] 没有已应用的补丁,跳过移除");
return;
}
try
{
harmonyInstance.UnpatchAll(harmonyInstance.Id);
patchesApplied = false;
Debug.Log((object)"[BlockMoveOptimization] 所有补丁已成功移除");
}
catch (Exception ex)
{
Debug.LogError((object)("[BlockMoveOptimization] 移除补丁时发生错误: " + ex.Message));
Debug.LogError((object)("[BlockMoveOptimization] 错误堆栈: " + ex.StackTrace));
}
}
public static bool IsPatched()
{
return patchesApplied;
}
}