Decompiled source of Mobility Abilities v1.2.0

JumpModTurt.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using DM;
using Landfall.TABS;
using Landfall.TABS.UnitEditor;
using Landfall.TABS.Workshop;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Tabs Poof Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Tabs Poof Mod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8aad4f38-2ad4-4206-bf0b-7d28fb6d5c2e")]
[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 TraversalJump;

public enum iliketomoveitkind
{
	launch,
	pull,
	freeze
}
public class abilitydef
{
	public string name;

	public int localid;

	public iliketomoveitkind kind;

	public float howmuchforward;

	public float howmuchup;

	public float howlongfreeze;

	public float cooldown;

	public float range;
}
public class thegenerics : Move
{
	public iliketomoveitkind kind;

	public float howmuchforward = 25f;

	public float howmuchup = 12f;

	public float howlongfreeze = 2f;

	public float range = 8f;

	public float cooldown = 3f;

	public float howlongramp = 0.15f;

	public float ppgdampeningboxreal = 6f;

	private float nextfiretimee;

	private DataHandler dadada;

	private RigidbodyHolder holddarigs;

	private void Awake()
	{
		dadada = ((Component)((Component)this).transform.root).GetComponentInChildren<DataHandler>();
		holddarigs = ((Component)((Component)this).transform.root).GetComponentInChildren<RigidbodyHolder>();
	}

	public override void DoMove(Rigidbody weapondeenemy, Rigidbody torsoofenemy, DataHandler dataofenemy)
	{
		if ((Object)(object)dadada == (Object)null)
		{
			dadada = ((Component)((Component)this).transform.root).GetComponentInChildren<DataHandler>();
		}
		if ((Object)(object)holddarigs == (Object)null)
		{
			holddarigs = ((Component)((Component)this).transform.root).GetComponentInChildren<RigidbodyHolder>();
		}
		if ((Object)(object)dadada == (Object)null || (Object)(object)dadada.torso == (Object)null)
		{
			return;
		}
		Rigidbody component = ((Component)dadada.torso).GetComponent<Rigidbody>();
		if (!((Object)(object)component == (Object)null))
		{
			if (kind == iliketomoveitkind.launch)
			{
				Rigidbody hiprig = (((Object)(object)dadada.hip != (Object)null) ? ((Component)dadada.hip).GetComponent<Rigidbody>() : null);
				((MonoBehaviour)this).StartCoroutine(dolaunch(component, hiprig, torsoofenemy));
			}
			else if (kind == iliketomoveitkind.pull)
			{
				dopull(component, torsoofenemy);
			}
			else if (kind == iliketomoveitkind.freeze)
			{
				((MonoBehaviour)this).StartCoroutine(dofreeze());
			}
		}
	}

	public void TriggerFromEvent()
	{
		if (Time.time < nextfiretimee)
		{
			return;
		}
		Rigidbody val = null;
		if (kind == iliketomoveitkind.launch || kind == iliketomoveitkind.pull)
		{
			val = nearestotorso(range);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
		}
		nextfiretimee = Time.time + cooldown;
		((Move)this).DoMove((Rigidbody)null, val, (DataHandler)null);
	}

	private Rigidbody nearestotorso(float searchradius)
	{
		//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_0034: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)dadada == (Object)null || (Object)(object)dadada.torso == (Object)null)
		{
			return null;
		}
		Vector3 position = dadada.torso.position;
		Collider[] array = Physics.OverlapSphere(position, searchradius);
		Unit component = ((Component)((Component)this).transform.root).GetComponent<Unit>();
		Rigidbody result = null;
		float num = float.MaxValue;
		for (int i = 0; i < array.Length; i++)
		{
			Unit componentInParent = ((Component)array[i]).GetComponentInParent<Unit>();
			if ((Object)(object)componentInParent == (Object)null || (Object)(object)componentInParent == (Object)(object)component)
			{
				continue;
			}
			DataHandler componentInChildren = ((Component)componentInParent).GetComponentInChildren<DataHandler>();
			if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.torso != (Object)null)
			{
				float num2 = Vector3.Distance(position, componentInChildren.torso.position);
				if (num2 < num)
				{
					num = num2;
					result = ((Component)componentInChildren.torso).GetComponent<Rigidbody>();
				}
			}
		}
		return result;
	}

	private IEnumerator dolaunch(Rigidbody torsorig, Rigidbody hiprig, Rigidbody torsoofenemy)
	{
		Vector3 val = (((Object)(object)torsoofenemy != (Object)null) ? torsoofenemy.position : (torsorig.position + ((Component)torsorig).transform.forward)) - torsorig.position;
		val.y = 0f;
		if (((Vector3)(ref val)).sqrMagnitude > 0.001f)
		{
			Quaternion rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized);
			((Component)torsorig).transform.rotation = rotation;
			if ((Object)(object)hiprig != (Object)null)
			{
				((Component)hiprig).transform.rotation = rotation;
			}
		}
		Vector3 wantvel = ((Component)torsorig).transform.forward * howmuchforward + Vector3.up * howmuchup;
		float rampclock = 0f;
		while (rampclock < howlongramp)
		{
			if ((Object)(object)torsorig == (Object)null)
			{
				yield break;
			}
			float num = Mathf.Sin(Mathf.Clamp01(rampclock / howlongramp) * (float)Math.PI * 0.5f);
			torsorig.velocity = wantvel * num;
			if ((Object)(object)hiprig != (Object)null)
			{
				hiprig.velocity = wantvel * num;
			}
			rampclock += Time.fixedDeltaTime;
			yield return (object)new WaitForFixedUpdate();
		}
		if ((Object)(object)torsorig != (Object)null)
		{
			torsorig.velocity = wantvel;
		}
		if ((Object)(object)hiprig != (Object)null)
		{
			hiprig.velocity = wantvel;
		}
		if ((Object)(object)dadada != (Object)null)
		{
			dadada.cantFallForSeconds = Mathf.Max(dadada.cantFallForSeconds, 0.4f);
		}
	}

	private void dopull(Rigidbody elrig, Rigidbody torsoofenemy)
	{
		if ((Object)(object)torsoofenemy != (Object)null)
		{
			((MonoBehaviour)this).StartCoroutine(pulltowardsgood(torsoofenemy, elrig, howmuchforward, 0.5f, 1.5f));
		}
	}

	private IEnumerator pulltowardsgood(Rigidbody target, Rigidbody anchor, float speed, float duration, float stopdist)
	{
		for (float howlongitisbe = 0f; howlongitisbe < duration; howlongitisbe += Time.fixedDeltaTime)
		{
			if ((Object)(object)target == (Object)null)
			{
				break;
			}
			if ((Object)(object)anchor == (Object)null)
			{
				break;
			}
			Vector3 val = anchor.position - target.position;
			if (((Vector3)(ref val)).magnitude <= stopdist)
			{
				target.velocity = Vector3.zero;
				break;
			}
			Vector3 val2 = ((Vector3)(ref val)).normalized * speed;
			if (howlongitisbe < howlongramp)
			{
				float num = Mathf.Clamp01(howlongitisbe / howlongramp);
				target.velocity = val2 * Mathf.Sin(num * (float)Math.PI * 0.5f);
			}
			else
			{
				target.velocity = val2;
			}
			yield return (object)new WaitForFixedUpdate();
		}
	}

	private IEnumerator dofreeze()
	{
		List<Rigidbody> list = new List<Rigidbody>();
		if ((Object)(object)holddarigs != (Object)null && holddarigs.AllRigs != null)
		{
			list.AddRange(holddarigs.AllRigs);
		}
		WeaponHandler componentInChildren = ((Component)((Component)this).transform.root).GetComponentInChildren<WeaponHandler>();
		if ((Object)(object)componentInChildren != (Object)null)
		{
			if ((Object)(object)componentInChildren.rightWeapon != (Object)null && (Object)(object)componentInChildren.rightWeapon.rigidbody != (Object)null)
			{
				list.Add(componentInChildren.rightWeapon.rigidbody);
			}
			if ((Object)(object)componentInChildren.leftWeapon != (Object)null && (Object)(object)componentInChildren.leftWeapon.rigidbody != (Object)null)
			{
				list.Add(componentInChildren.leftWeapon.rigidbody);
			}
		}
		if (list.Count == 0 && (Object)(object)dadada != (Object)null && (Object)(object)dadada.torso != (Object)null)
		{
			Rigidbody component = ((Component)dadada.torso).GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				list.Add(component);
			}
		}
		List<Rigidbody> actuallyfroze = new List<Rigidbody>();
		for (int i = 0; i < list.Count; i++)
		{
			Rigidbody val = list[i];
			if (!((Object)(object)val == (Object)null) && !val.isKinematic)
			{
				val.velocity = Vector3.zero;
				val.angularVelocity = Vector3.zero;
				val.isKinematic = true;
				actuallyfroze.Add(val);
			}
		}
		yield return (object)new WaitForSeconds(howlongfreeze);
		for (int j = 0; j < actuallyfroze.Count; j++)
		{
			if ((Object)(object)actuallyfroze[j] != (Object)null)
			{
				actuallyfroze[j].isKinematic = false;
			}
		}
	}
}
public class onlyifequip : MonoBehaviour
{
	private void Awake()
	{
		recheck();
	}

	private void OnEnable()
	{
		recheck();
	}

	private void recheck()
	{
		bool enabled = (Object)(object)((Component)((Component)this).transform.root).GetComponent<Unit>() != (Object)null;
		thegenerics component = ((Component)this).GetComponent<thegenerics>();
		ConditionalEvent component2 = ((Component)this).GetComponent<ConditionalEvent>();
		if ((Object)(object)component != (Object)null)
		{
			((Behaviour)component).enabled = enabled;
		}
		if ((Object)(object)component2 != (Object)null)
		{
			((Behaviour)component2).enabled = enabled;
		}
	}
}
[BepInPlugin("bayturtleking.traversaljump", "Mobility Abilities", "1.2.1")]
public class thejumpmod : BaseUnityPlugin
{
	private List<abilitydef> abilitydefs = new List<abilitydef>
	{
		new abilitydef
		{
			name = "Long Jump",
			localid = 738201455,
			kind = iliketomoveitkind.launch,
			howmuchforward = 60f,
			howmuchup = 30f,
			cooldown = 3f,
			range = 6f
		},
		new abilitydef
		{
			name = "Small Dash",
			localid = 738201456,
			kind = iliketomoveitkind.launch,
			howmuchforward = 40f,
			howmuchup = 5f,
			cooldown = 2f,
			range = 5f
		},
		new abilitydef
		{
			name = "Backstep",
			localid = 738201457,
			kind = iliketomoveitkind.launch,
			howmuchforward = -40f,
			howmuchup = 8f,
			cooldown = 3f,
			range = 5f
		},
		new abilitydef
		{
			name = "Updraft",
			localid = 738201458,
			kind = iliketomoveitkind.launch,
			howmuchforward = 0f,
			howmuchup = 45f,
			cooldown = 4f,
			range = 4f
		},
		new abilitydef
		{
			name = "Grapple Pull",
			localid = 738201459,
			kind = iliketomoveitkind.pull,
			howmuchforward = 40f,
			cooldown = 4f,
			range = 8f
		},
		new abilitydef
		{
			name = "Shove!!!!",
			localid = 738201460,
			kind = iliketomoveitkind.pull,
			howmuchforward = -40f,
			cooldown = 3f,
			range = 3f
		},
		new abilitydef
		{
			name = "Anchor",
			localid = 738201461,
			kind = iliketomoveitkind.freeze,
			howlongfreeze = 2f,
			cooldown = 6f,
			range = 3f
		}
	};

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

	private IEnumerator addwhenre()
	{
		while (ContentDatabase.Instance() == null)
		{
			yield return null;
		}
		foreach (abilitydef abilitydef in abilitydefs)
		{
			addability(abilitydef);
		}
	}

	private void addability(abilitydef def)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Expected O, but got Unknown
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Expected O, but got Unknown
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Expected O, but got Unknown
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Expected O, but got Unknown
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Expected O, but got Unknown
		//IL_0141: 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_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: 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_015b: 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_0174: Expected O, but got Unknown
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: 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_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Expected O, but got Unknown
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Expected O, but got Unknown
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: 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)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(def.name);
		val.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)val);
		((Object)val).hideFlags = (HideFlags)52;
		SpecialAbility obj = val.AddComponent<SpecialAbility>();
		CharacterItem component = val.GetComponent<CharacterItem>();
		if ((Object)(object)component != (Object)null)
		{
			component.tags = new List<Tag>
			{
				new Tag
				{
					tagType = (TagType)0,
					value = "Mobility Abilities"
				}
			};
		}
		DatabaseEntity val2 = new DatabaseEntity((WorkshopContentType)5)
		{
			GUID = new DatabaseID(738201400, def.localid),
			Name = def.name
		};
		doprivstuff(obj, "m_entity", val2);
		thegenerics thegenerics2 = val.AddComponent<thegenerics>();
		thegenerics2.kind = def.kind;
		thegenerics2.howmuchforward = def.howmuchforward;
		thegenerics2.howmuchup = def.howmuchup;
		thegenerics2.howlongfreeze = def.howlongfreeze;
		thegenerics2.range = def.range;
		thegenerics2.cooldown = def.cooldown;
		((Behaviour)thegenerics2).enabled = false;
		ConditionalEvent val3 = val.AddComponent<ConditionalEvent>();
		((Behaviour)val3).enabled = false;
		ConditionalEventInstance val4 = new ConditionalEventInstance();
		val4.delay = 0f;
		val4.turnOnEvent = new UnityEvent();
		val4.turnOffEvent = new UnityEvent();
		val4.continuousEvent = new UnityEvent();
		val4.conditions = (EventCondition[])(object)new EventCondition[2]
		{
			new EventCondition
			{
				conditionType = (ConditionType)0,
				startOnCD = true,
				alwaysResetCounter = true,
				value = def.cooldown,
				counter = def.cooldown
			},
			new EventCondition
			{
				conditionType = (ConditionType)1,
				whichRange = (WhichRange)0,
				valueType = (ValueType)1,
				value = def.range,
				startOnCD = true
			}
		};
		val4.turnOnEvent.AddListener(new UnityAction(thegenerics2.TriggerFromEvent));
		val3.events = (ConditionalEventInstance[])(object)new ConditionalEventInstance[1] { val4 };
		val.AddComponent<onlyifequip>();
		LandfallContentDatabase landfallContentDatabase = ContentDatabase.Instance().LandfallContentDatabase;
		Dictionary<DatabaseID, Object> dictionary = getprivatefield<Dictionary<DatabaseID, Object>>(ContentDatabase.Instance().AssetLoader, "m_nonStreamableAssets");
		Dictionary<DatabaseID, GameObject> dictionary2 = getprivatefield<Dictionary<DatabaseID, GameObject>>(landfallContentDatabase, "m_combatMoves");
		dictionary[val2.GUID] = (Object)(object)val;
		dictionary2[val2.GUID] = val;
		try
		{
			val.SetActive(true);
		}
		catch (NullReferenceException)
		{
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)(def.name + " is now an ability cuz of turtle's abilities mod"));
	}

	private static void doprivstuff(object obj, string fieldname, object value)
	{
		getanyfieldd(obj.GetType(), fieldname)?.SetValue(obj, value);
	}

	private static T getprivatefield<T>(object obj, string fieldname)
	{
		FieldInfo fieldInfo = getanyfieldd(obj.GetType(), fieldname);
		if (fieldInfo == null)
		{
			return default(T);
		}
		return (T)fieldInfo.GetValue(obj);
	}

	private static FieldInfo getanyfieldd(Type t, string fieldname)
	{
		while (t != null)
		{
			FieldInfo field = t.GetField(fieldname, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				return field;
			}
			t = t.BaseType;
		}
		return null;
	}
}