using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using DM;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.AI.Components.Modifiers;
using Landfall.TABS.UnitEditor;
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("IceCarModaaa")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IceCarModaaa")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8e94e236-52b5-4e26-af4b-1affe5b0ac69")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace IceCarModaaa;
[BepInPlugin("org.bepinex.plugins.IceCarModaaa", "IceCarModaaa", "1.0.0")]
internal class Loader : BaseUnityPlugin
{
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
Harmony val = new Harmony("IceCarModaaa");
val.PatchAll();
GameObject val2 = new GameObject("IceCarModaaa");
Object.DontDestroyOnLoad((Object)(object)val2);
val2.AddComponent<Main>();
val2.AddComponent<TME>();
}
}
public class Main : MonoBehaviour
{
public void Awake()
{
TME.LoadAssets(reload: false);
Debug.Log((object)"Loaded 冰车模型aaa Successfully!");
}
}
public class TME : MonoBehaviour
{
private static readonly string[] assetbundles = new string[1] { "IceCarModaaa.bakaicecaraaa" };
public static void ChangeAI()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
LandfallContentDatabase landfallContentDatabase = ContentDatabase.Instance().LandfallContentDatabase;
foreach (UnitBlueprint unitBlueprint in landfallContentDatabase.GetUnitBlueprints())
{
if (unitBlueprint.Entity.Name == "单位名称")
{
unitBlueprint.MovementComponents.Clear();
unitBlueprint.MovementComponents.Add((IMovementComponent)(object)default(KeepRangedDistance));
}
}
}
public static void LoadAssets(bool reload)
{
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_0382: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_0492: Unknown result type (might be due to invalid IL or missing references)
//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
//IL_0433: Unknown result type (might be due to invalid IL or missing references)
//IL_0337: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
//IL_055e: Unknown result type (might be due to invalid IL or missing references)
//IL_0462: Unknown result type (might be due to invalid IL or missing references)
//IL_044d: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: Unknown result type (might be due to invalid IL or missing references)
//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0703: Unknown result type (might be due to invalid IL or missing references)
//IL_0689: Unknown result type (might be due to invalid IL or missing references)
//IL_058d: Unknown result type (might be due to invalid IL or missing references)
//IL_0578: Unknown result type (might be due to invalid IL or missing references)
//IL_047c: Unknown result type (might be due to invalid IL or missing references)
//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
//IL_07c9: Unknown result type (might be due to invalid IL or missing references)
//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0920: Unknown result type (might be due to invalid IL or missing references)
//IL_0936: Unknown result type (might be due to invalid IL or missing references)
//IL_08c1: Unknown result type (might be due to invalid IL or missing references)
//IL_080c: Unknown result type (might be due to invalid IL or missing references)
//IL_0818: Unknown result type (might be due to invalid IL or missing references)
//IL_07d5: Unknown result type (might be due to invalid IL or missing references)
//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0a41: Unknown result type (might be due to invalid IL or missing references)
//IL_0a57: Unknown result type (might be due to invalid IL or missing references)
//IL_09e2: Unknown result type (might be due to invalid IL or missing references)
//IL_08f0: Unknown result type (might be due to invalid IL or missing references)
//IL_08db: Unknown result type (might be due to invalid IL or missing references)
//IL_07f0: Unknown result type (might be due to invalid IL or missing references)
//IL_07e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0a11: Unknown result type (might be due to invalid IL or missing references)
//IL_09fc: Unknown result type (might be due to invalid IL or missing references)
//IL_090a: Unknown result type (might be due to invalid IL or missing references)
//IL_0800: Unknown result type (might be due to invalid IL or missing references)
//IL_0a2b: Unknown result type (might be due to invalid IL or missing references)
LandfallContentDatabase landfallContentDatabase = ContentDatabase.Instance().LandfallContentDatabase;
if (assetbundles.Length < 1)
{
Debug.LogError((object)"未找到资源!");
return;
}
Assembly executingAssembly = Assembly.GetExecutingAssembly();
if (reload)
{
AssetBundle.UnloadAllAssetBundles(true);
}
string[] array = assetbundles;
foreach (string text in array)
{
Debug.Log((object)("Loading embedded resource: " + text));
using Stream stream = executingAssembly.GetManifestResourceStream(text);
if (stream == null)
{
Debug.LogError((object)("资源:'" + text + "'未找到!"));
continue;
}
if (reload)
{
AssetBundle.UnloadAllAssetBundles(true);
}
AssetBundle val = AssetBundle.LoadFromStream(stream);
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)("资源:'" + text + "'加载失败!"));
continue;
}
List<GameObject> source = val.LoadAllAssets<GameObject>().ToList();
List<GameObject> list = source.Where((GameObject x) => (Object)(object)x.GetComponentInChildren<Unit>() != (Object)null).ToList();
List<WeaponItem> list2 = (from x in source
where (Object)(object)x.GetComponent<WeaponItem>() != (Object)null
select x.GetComponent<WeaponItem>()).ToList();
List<ProjectileEntity> list3 = (from x in source
where (Object)(object)x.GetComponent<ProjectileEntity>() != (Object)null
select x.GetComponent<ProjectileEntity>()).ToList();
List<SpecialAbility> list4 = (from x in source
where (Object)(object)x.GetComponent<SpecialAbility>() != (Object)null
select x.GetComponent<SpecialAbility>()).ToList();
List<PropItem> list5 = (from x in source
where (Object)(object)x.GetComponent<PropItem>() != (Object)null
select x.GetComponent<PropItem>()).ToList();
List<UnitBlueprint> list6 = val.LoadAllAssets<UnitBlueprint>().ToList();
List<Faction> list7 = val.LoadAllAssets<Faction>().ToList();
Dictionary<DatabaseID, Object> dictionary = (Dictionary<DatabaseID, Object>)typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ContentDatabase.Instance().AssetLoader);
if (list2.Count > 0)
{
Dictionary<DatabaseID, GameObject> dictionary2 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_weapons", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (WeaponItem item in list2)
{
if (reload)
{
if (dictionary2.ContainsKey(((CharacterItem)item).Entity.GUID))
{
dictionary2.Remove(((CharacterItem)item).Entity.GUID);
}
if (dictionary.ContainsKey(((CharacterItem)item).Entity.GUID))
{
dictionary.Remove(((CharacterItem)item).Entity.GUID);
}
}
dictionary2.Add(((CharacterItem)item).Entity.GUID, ((Component)item).gameObject);
dictionary.Add(((CharacterItem)item).Entity.GUID, (Object)(object)((Component)item).gameObject);
}
typeof(LandfallContentDatabase).GetField("m_weapons", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary2);
}
if (list3.Count > 0)
{
Dictionary<DatabaseID, GameObject> dictionary3 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_projectiles", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (ProjectileEntity item2 in list3)
{
if (reload)
{
if (dictionary3.ContainsKey(item2.Entity.GUID))
{
dictionary3.Remove(item2.Entity.GUID);
}
if (dictionary.ContainsKey(item2.Entity.GUID))
{
dictionary.Remove(item2.Entity.GUID);
}
}
dictionary3.Add(item2.Entity.GUID, ((Component)item2).gameObject);
dictionary.Add(item2.Entity.GUID, (Object)(object)((Component)item2).gameObject);
}
typeof(LandfallContentDatabase).GetField("m_projectiles", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary3);
}
if (list4.Count > 0)
{
Dictionary<DatabaseID, GameObject> dictionary4 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_combatMoves", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (SpecialAbility item3 in list4)
{
if (reload)
{
if (dictionary4.ContainsKey(((CharacterItem)item3).Entity.GUID))
{
dictionary4.Remove(((CharacterItem)item3).Entity.GUID);
}
if (dictionary.ContainsKey(((CharacterItem)item3).Entity.GUID))
{
dictionary.Remove(((CharacterItem)item3).Entity.GUID);
}
}
dictionary4.Add(((CharacterItem)item3).Entity.GUID, ((Component)item3).gameObject);
dictionary.Add(((CharacterItem)item3).Entity.GUID, (Object)(object)((Component)item3).gameObject);
}
typeof(LandfallContentDatabase).GetField("m_combatMoves", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary4);
}
if (list5.Count > 0)
{
Dictionary<DatabaseID, GameObject> dictionary5 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_characterProps", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (PropItem item4 in list5)
{
if (reload)
{
if (dictionary5.ContainsKey(((CharacterItem)item4).Entity.GUID))
{
dictionary5.Remove(((CharacterItem)item4).Entity.GUID);
}
if (dictionary.ContainsKey(((CharacterItem)item4).Entity.GUID))
{
dictionary.Remove(((CharacterItem)item4).Entity.GUID);
}
}
dictionary5.Add(((CharacterItem)item4).Entity.GUID, ((Component)item4).gameObject);
dictionary.Add(((CharacterItem)item4).Entity.GUID, (Object)(object)((Component)item4).gameObject);
}
typeof(LandfallContentDatabase).GetField("m_characterProps", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary5);
}
if (list.Count > 0)
{
Dictionary<DatabaseID, GameObject> dictionary6 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_unitBases", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (GameObject item5 in list)
{
Unit componentInChildren = item5.GetComponentInChildren<Unit>();
if ((Object)(object)componentInChildren == (Object)null)
{
continue;
}
DatabaseID gUID = componentInChildren.Entity.GUID;
if (reload)
{
if (dictionary6.ContainsKey(gUID))
{
dictionary6.Remove(gUID);
}
if (dictionary.ContainsKey(gUID))
{
dictionary.Remove(gUID);
}
}
dictionary6.Add(gUID, item5);
dictionary.Add(gUID, (Object)(object)item5);
}
typeof(LandfallContentDatabase).GetField("m_unitBases", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary6);
}
if (list6.Count > 0)
{
Dictionary<DatabaseID, UnitBlueprint> dictionary7 = (Dictionary<DatabaseID, UnitBlueprint>)typeof(LandfallContentDatabase).GetField("m_unitBlueprints", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (UnitBlueprint item6 in list6)
{
if (reload)
{
if (dictionary7.ContainsKey(item6.Entity.GUID))
{
dictionary7.Remove(item6.Entity.GUID);
}
if (dictionary.ContainsKey(item6.Entity.GUID))
{
dictionary.Remove(item6.Entity.GUID);
}
}
dictionary7.Add(item6.Entity.GUID, item6);
dictionary.Add(item6.Entity.GUID, (Object)(object)item6);
}
typeof(LandfallContentDatabase).GetField("m_unitBlueprints", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary7);
}
if (list7.Count <= 0)
{
continue;
}
Dictionary<DatabaseID, Faction> dictionary8 = (Dictionary<DatabaseID, Faction>)typeof(LandfallContentDatabase).GetField("m_factions", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (Faction item7 in list7)
{
if (reload)
{
if (dictionary8.ContainsKey(item7.Entity.GUID))
{
dictionary8.Remove(item7.Entity.GUID);
}
if (dictionary.ContainsKey(item7.Entity.GUID))
{
dictionary.Remove(item7.Entity.GUID);
}
}
dictionary8.Add(item7.Entity.GUID, item7);
dictionary.Add(item7.Entity.GUID, (Object)(object)item7);
}
typeof(LandfallContentDatabase).GetField("m_factions", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary8);
}
ChangeAI();
}
public void Update()
{
}
}
[DisallowMultipleComponent]
[AddComponentMenu("IceCarModaaa/Unit Control Immunity")]
public sealed class UnitControlImmunity : MonoBehaviour
{
[Tooltip("Prevent new vanilla ice-arrow frost stacks and their drag/freeze effects. Does not cleanse existing frost.")]
public bool immuneToIce = true;
[Tooltip("Ignore scripted push and velocity damping from vanilla ProjectileHit, CollisionWeapon and Explosion. Physical collisions still work.")]
public bool immuneToAttackKnockback = true;
private DataHandler data;
private Unit owner;
private void Awake()
{
owner = ((Component)this).GetComponent<Unit>();
data = ((Component)this).GetComponentInChildren<DataHandler>(true);
UnitControlImmunityPatches.Install();
}
private void Start()
{
if ((Object)(object)owner == (Object)null || (Object)(object)data == (Object)null)
{
Debug.LogWarning((object)("[UnitControlImmunity] Attach to the UnitBase root containing Unit and DataHandler: " + ((Object)this).name), (Object)(object)this);
}
}
internal static UnitControlImmunity Find(Component target)
{
if ((Object)(object)target == (Object)null)
{
return null;
}
Unit componentInParent = target.GetComponentInParent<Unit>();
if ((Object)(object)componentInParent == (Object)null)
{
return null;
}
UnitControlImmunity component = ((Component)componentInParent).GetComponent<UnitControlImmunity>();
if ((Object)(object)component == (Object)null || !((Behaviour)component).isActiveAndEnabled || componentInParent.dead)
{
return null;
}
if ((Object)(object)component.data == (Object)null)
{
component.data = ((Component)componentInParent).GetComponentInChildren<DataHandler>(true);
}
return ((Object)(object)component.data != (Object)null && !component.data.Dead) ? component : null;
}
}
internal static class UnitControlImmunityPatches
{
private const string HarmonyId = "icecarmodaaa.controlimmunity";
private static bool attempted;
internal static void Install()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
if (attempted || !Application.isPlaying)
{
return;
}
attempted = true;
Harmony val = new Harmony("icecarmodaaa.controlimmunity");
List<MethodBase> list = new List<MethodBase>();
try
{
MethodInfo methodInfo = Require(typeof(Effect_IceArrow), "Add", typeof(float));
list.Add(methodInfo);
val.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(UnitControlImmunityPatches), "BeforeIce", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
PatchAttack(val, list, Require(typeof(ProjectileHit), "AddForceToTarget", typeof(Vector3), typeof(Rigidbody), typeof(float)));
PatchAttack(val, list, Require(typeof(CollisionWeapon), "OnCollisionEnter", typeof(Collision)));
PatchAttack(val, list, Require(typeof(Explosion), "Explode"));
Debug.Log((object)"[UnitControlImmunity] Installed: vanilla ice, projectile, melee and explosion protection (opt-in units only).");
}
catch (Exception ex)
{
foreach (MethodBase item in list)
{
val.Unpatch(item, (HarmonyPatchType)0, "icecarmodaaa.controlimmunity");
}
Debug.LogError((object)("[UnitControlImmunity] Installation failed; protection unavailable. " + ex));
}
}
private static MethodInfo Require(Type type, string name, params Type[] arguments)
{
MethodInfo methodInfo = AccessTools.DeclaredMethod(type, name, arguments, (Type[])null);
if (methodInfo == null)
{
throw new MissingMethodException(type.FullName, name);
}
return methodInfo;
}
private static void PatchAttack(Harmony harmony, List<MethodBase> patched, MethodInfo method)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
patched.Add(method);
harmony.Patch((MethodBase)method, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(UnitControlImmunityPatches), "ProtectAttackForces", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
}
private static bool BeforeIce(Effect_IceArrow __instance)
{
UnitControlImmunity unitControlImmunity = UnitControlImmunity.Find((Component)(object)__instance);
return (Object)(object)unitControlImmunity == (Object)null || !unitControlImmunity.immuneToIce;
}
private static bool Blocks(Rigidbody target)
{
UnitControlImmunity unitControlImmunity = UnitControlImmunity.Find((Component)(object)target);
return (Object)(object)unitControlImmunity != (Object)null && unitControlImmunity.immuneToAttackKnockback;
}
internal static IEnumerable<CodeInstruction> ProtectAttackForces(IEnumerable<CodeInstruction> instructions, MethodBase __originalMethod)
{
Dictionary<MethodInfo, MethodInfo> dictionary = new Dictionary<MethodInfo, MethodInfo>();
AddReplacement(dictionary, typeof(WilhelmPhysicsFunctions), "AddForceWithMinWeight", "AttackForce", typeof(Rigidbody), typeof(Vector3), typeof(ForceMode), typeof(float));
AddReplacement(dictionary, typeof(WilhelmPhysicsFunctions), "AddForceWithMinWeight", "AttackForceAtPosition", typeof(Rigidbody), typeof(Vector3), typeof(Vector3), typeof(ForceMode), typeof(float));
AddReplacement(dictionary, typeof(WilhelmPhysicsFunctions), "AddAxplosionForceWithMinWeight", "AttackExplosionForce", typeof(Rigidbody), typeof(float), typeof(Vector3), typeof(float), typeof(ForceMode), typeof(float));
dictionary.Add(Require(typeof(Rigidbody), "set_velocity", typeof(Vector3)), Require(typeof(UnitControlImmunityPatches), "AttackVelocity", typeof(Rigidbody), typeof(Vector3)));
int num = 0;
int num2 = 0;
List<CodeInstruction> list = new List<CodeInstruction>();
foreach (CodeInstruction instruction in instructions)
{
MethodInfo methodInfo = instruction.operand as MethodInfo;
if ((instruction.opcode == OpCodes.Call || instruction.opcode == OpCodes.Callvirt) && methodInfo != null && dictionary.TryGetValue(methodInfo, out var value))
{
if (methodInfo.Name == "set_velocity")
{
num2++;
}
else
{
num++;
}
instruction.opcode = OpCodes.Call;
instruction.operand = value;
}
list.Add(instruction);
}
int num3 = ((__originalMethod.DeclaringType == typeof(ProjectileHit)) ? 1 : 2);
int num4 = ((!(__originalMethod.DeclaringType == typeof(CollisionWeapon))) ? 1 : 2);
if (num != num3 || num2 != num4)
{
throw new InvalidOperationException("Unsupported attack IL: " + __originalMethod?.ToString() + "; force calls=" + num + ", velocity writes=" + num2);
}
return list;
}
private static void AddReplacement(Dictionary<MethodInfo, MethodInfo> map, Type type, string original, string replacement, params Type[] signature)
{
map.Add(Require(type, original, signature), Require(typeof(UnitControlImmunityPatches), replacement, signature));
}
private static void AttackForce(Rigidbody rig, Vector3 force, ForceMode mode, float minWeight)
{
//IL_000f: 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)
if (!Blocks(rig))
{
WilhelmPhysicsFunctions.AddForceWithMinWeight(rig, force, mode, minWeight);
}
}
private static void AttackForceAtPosition(Rigidbody rig, Vector3 force, Vector3 position, ForceMode mode, float minWeight)
{
//IL_000f: 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)
if (!Blocks(rig))
{
WilhelmPhysicsFunctions.AddForceWithMinWeight(rig, force, position, mode, minWeight);
}
}
private static void AttackExplosionForce(Rigidbody rig, float force, Vector3 position, float radius, ForceMode mode, float minWeight)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (!Blocks(rig))
{
WilhelmPhysicsFunctions.AddAxplosionForceWithMinWeight(rig, force, position, radius, mode, minWeight);
}
}
private static void AttackVelocity(Rigidbody rig, Vector3 velocity)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
if (!Blocks(rig))
{
rig.velocity = velocity;
}
}
}