using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using UnityEngine;
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace JerryAKMagEject
{
[BepInPlugin("JerryAKMagEject", "JAKME", "1.0.0")]
[BepInProcess("h3vr.exe")]
public class AKMagFingerEject : BaseUnityPlugin
{
public FVRFireArmMagazine mag;
public FVRFireArmMagazine mag2;
public FVRFireArmMagazine mag3;
public FVRFireArmMagazine mag4;
public float cd = 0.5f;
public float cd2 = 0.5f;
public bool has;
public bool isC;
public bool check;
public bool has2;
public bool isC2;
public bool check2;
public FVRInteractiveObject obj;
public FVRInteractiveObject obj2;
private void Update()
{
//IL_016f: 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_0683: Unknown result type (might be due to invalid IL or missing references)
//IL_0688: Unknown result type (might be due to invalid IL or missing references)
//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
//IL_0ab7: Unknown result type (might be due to invalid IL or missing references)
//IL_0ac7: Unknown result type (might be due to invalid IL or missing references)
//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0adb: Unknown result type (might be due to invalid IL or missing references)
//IL_0ae7: 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_085f: 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_08c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0467: Unknown result type (might be due to invalid IL or missing references)
//IL_0471: Unknown result type (might be due to invalid IL or missing references)
//IL_097b: Unknown result type (might be due to invalid IL or missing references)
//IL_0985: Unknown result type (might be due to invalid IL or missing references)
//IL_053b: Unknown result type (might be due to invalid IL or missing references)
//IL_0545: Unknown result type (might be due to invalid IL or missing references)
//IL_0a4f: Unknown result type (might be due to invalid IL or missing references)
//IL_0a59: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)mag2 != (Object)null)
{
if (cd > 0f)
{
cd -= Time.deltaTime;
}
else if (cd <= 0f)
{
cd = 0.5f;
((Component)((Component)mag2).gameObject.GetComponentInChildren<FVRFireArmReloadTriggerMag>(true)).gameObject.SetActive(true);
mag2 = null;
}
}
if ((Object)(object)mag4 != (Object)null)
{
if (cd2 > 0f)
{
cd2 -= Time.deltaTime;
}
else if (cd2 <= 0f)
{
cd2 = 0.5f;
((Component)((Component)mag4).gameObject.GetComponentInChildren<FVRFireArmReloadTriggerMag>(true)).gameObject.SetActive(true);
mag4 = null;
}
}
if ((Object)(object)GM.CurrentMovementManager.Hands[0].m_currentInteractable != (Object)null && (Object)(object)((Component)GM.CurrentMovementManager.Hands[0].m_currentInteractable).gameObject.GetComponentInChildren<PhysicalMagazineReleaseLatch>() != (Object)null)
{
PhysicalMagazineReleaseLatch componentInChildren = ((Component)GM.CurrentMovementManager.Hands[0].m_currentInteractable).gameObject.GetComponentInChildren<PhysicalMagazineReleaseLatch>();
Vector3 velLinearWorld = GM.CurrentMovementManager.Hands[0].OtherHand.Input.VelLinearWorld;
if ((Object)(object)mag != (Object)null)
{
if (!check)
{
if ((Object)(object)GM.CurrentMovementManager.Hands[0].OtherHand.m_currentInteractable != (Object)null)
{
if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[0]).gameObject.GetComponent<HingeJoint>() != (Object)null)
{
isC = true;
}
else if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[0]).gameObject.GetComponent<HingeJoint>() == (Object)null)
{
isC = false;
}
has = true;
check = true;
}
if ((Object)(object)GM.CurrentMovementManager.Hands[0].OtherHand.m_currentInteractable == (Object)null)
{
if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[0]).gameObject.GetComponent<HingeJoint>() != (Object)null)
{
isC = true;
}
else if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[0]).gameObject.GetComponent<HingeJoint>() == (Object)null)
{
isC = false;
}
has = false;
check = true;
}
}
if (check)
{
if ((Object)(object)mag.FireArm != (Object)null)
{
if (has)
{
obj = GM.CurrentMovementManager.Hands[0].OtherHand.m_currentInteractable;
obj.ForceBreakInteraction();
GM.CurrentMovementManager.Hands[0].OtherHand.ForceSetInteractable((FVRInteractiveObject)(object)mag);
((FVRInteractiveObject)mag).BeginInteraction(GM.CurrentMovementManager.Hands[0].OtherHand);
((Component)componentInChildren).transform.localEulerAngles = new Vector3(320f, 0f, 0f);
}
else if (!has)
{
GM.CurrentMovementManager.Hands[0].OtherHand.ForceSetInteractable((FVRInteractiveObject)(object)mag);
((FVRInteractiveObject)mag).BeginInteraction(GM.CurrentMovementManager.Hands[0].OtherHand);
((Component)componentInChildren).transform.localEulerAngles = new Vector3(320f, 0f, 0f);
}
if (isC)
{
((Component)((Component)mag).gameObject.GetComponentInChildren<FVRFireArmReloadTriggerMag>(true)).gameObject.SetActive(false);
cd = 0.5f;
}
if (!isC)
{
componentInChildren.FireArm.EjectMag(false);
}
}
if ((Object)(object)mag.FireArm == (Object)null)
{
if (has)
{
((FVRInteractiveObject)mag).ForceBreakInteraction();
if ((Object)(object)((Component)mag).gameObject.GetComponent<Rigidbody>() != (Object)null)
{
((Component)mag).gameObject.GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * 3f, (ForceMode)2);
}
mag2 = mag;
mag = null;
GM.CurrentMovementManager.Hands[0].OtherHand.ForceSetInteractable(obj);
obj.BeginInteraction(GM.CurrentMovementManager.Hands[0].OtherHand);
obj = null;
check = false;
}
else if (!has && (Object)(object)((Component)componentInChildren.FireArm).gameObject.GetComponent<Joint>() == (Object)null)
{
((FVRInteractiveObject)mag).ForceBreakInteraction();
if ((Object)(object)((Component)mag).gameObject.GetComponent<Rigidbody>() != (Object)null)
{
((Component)mag).gameObject.GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * 3f, (ForceMode)2);
}
mag2 = mag;
mag = null;
obj = null;
check = false;
}
}
}
}
if ((Object)(object)componentInChildren.FireArm.Magazine != (Object)null && Vector3.Distance(GM.CurrentMovementManager.Hands[0].OtherHand.PointingTransform.position, ((Component)componentInChildren).gameObject.transform.position) < 0.1f && Vector3.Angle(velLinearWorld, ((Component)componentInChildren).gameObject.transform.forward) < 50f && ((Vector3)(ref velLinearWorld)).magnitude > 1f)
{
mag = componentInChildren.FireArm.Magazine;
}
}
if (!((Object)(object)GM.CurrentMovementManager.Hands[1].m_currentInteractable != (Object)null) || !((Object)(object)((Component)GM.CurrentMovementManager.Hands[1].m_currentInteractable).gameObject.GetComponentInChildren<PhysicalMagazineReleaseLatch>() != (Object)null))
{
return;
}
PhysicalMagazineReleaseLatch componentInChildren2 = ((Component)GM.CurrentMovementManager.Hands[1].m_currentInteractable).gameObject.GetComponentInChildren<PhysicalMagazineReleaseLatch>();
Vector3 velLinearWorld2 = GM.CurrentMovementManager.Hands[1].OtherHand.Input.VelLinearWorld;
if ((Object)(object)mag3 != (Object)null)
{
if (!check2)
{
if ((Object)(object)GM.CurrentMovementManager.Hands[1].OtherHand.m_currentInteractable != (Object)null)
{
if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[1]).gameObject.GetComponent<HingeJoint>() != (Object)null)
{
isC2 = true;
}
else if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[1]).gameObject.GetComponent<HingeJoint>() == (Object)null)
{
isC2 = false;
}
has2 = true;
check2 = true;
}
if ((Object)(object)GM.CurrentMovementManager.Hands[1].OtherHand.m_currentInteractable == (Object)null)
{
if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[1]).gameObject.GetComponent<HingeJoint>() != (Object)null)
{
isC2 = true;
}
else if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[1]).gameObject.GetComponent<HingeJoint>() == (Object)null)
{
isC2 = false;
}
has2 = false;
check2 = true;
}
}
if (check2)
{
if ((Object)(object)mag3.FireArm != (Object)null)
{
if (has2)
{
obj2 = GM.CurrentMovementManager.Hands[1].OtherHand.m_currentInteractable;
obj2.ForceBreakInteraction();
GM.CurrentMovementManager.Hands[1].OtherHand.ForceSetInteractable((FVRInteractiveObject)(object)mag3);
((FVRInteractiveObject)mag3).BeginInteraction(GM.CurrentMovementManager.Hands[1].OtherHand);
((Component)componentInChildren2).transform.localEulerAngles = new Vector3(320f, 0f, 0f);
}
else if (!has2)
{
GM.CurrentMovementManager.Hands[1].OtherHand.ForceSetInteractable((FVRInteractiveObject)(object)mag3);
((FVRInteractiveObject)mag3).BeginInteraction(GM.CurrentMovementManager.Hands[1].OtherHand);
((Component)componentInChildren2).transform.localEulerAngles = new Vector3(320f, 0f, 0f);
}
if (isC2)
{
((Component)((Component)mag3).gameObject.GetComponentInChildren<FVRFireArmReloadTriggerMag>(true)).gameObject.SetActive(false);
cd2 = 0.5f;
}
if (!isC2)
{
componentInChildren2.FireArm.EjectMag(false);
}
}
if ((Object)(object)mag3.FireArm == (Object)null)
{
if (has2)
{
((FVRInteractiveObject)mag3).ForceBreakInteraction();
if ((Object)(object)((Component)mag3).gameObject.GetComponent<Rigidbody>() != (Object)null)
{
((Component)mag3).gameObject.GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * 3f, (ForceMode)2);
}
mag4 = mag3;
mag3 = null;
GM.CurrentMovementManager.Hands[1].OtherHand.ForceSetInteractable(obj2);
obj2.BeginInteraction(GM.CurrentMovementManager.Hands[1].OtherHand);
obj2 = null;
check2 = false;
}
else if (!has2 && (Object)(object)((Component)componentInChildren2.FireArm).gameObject.GetComponent<Joint>() == (Object)null)
{
((FVRInteractiveObject)mag3).ForceBreakInteraction();
if ((Object)(object)((Component)mag3).gameObject.GetComponent<Rigidbody>() != (Object)null)
{
((Component)mag3).gameObject.GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * 3f, (ForceMode)2);
}
mag4 = mag3;
mag3 = null;
obj2 = null;
check2 = false;
}
}
}
}
if ((Object)(object)componentInChildren2.FireArm.Magazine != (Object)null && Vector3.Distance(GM.CurrentMovementManager.Hands[1].OtherHand.PointingTransform.position, ((Component)componentInChildren2).gameObject.transform.position) < 0.1f && Vector3.Angle(velLinearWorld2, ((Component)componentInChildren2).gameObject.transform.forward) < 50f && ((Vector3)(ref velLinearWorld2)).magnitude > 1f)
{
mag3 = componentInChildren2.FireArm.Magazine;
}
}
}
}
public class RollAndLock : MonoBehaviour
{
public FVRFireArmRecoilProfile hold;
public FVRFireArmRecoilProfile unhold;
public Transform MagazinePoint;
public Transform MagazinePivot;
public float lowerlimit;
public float upperlimit;
private HingeJoint Joint;
public float eject;
public float lockangle;
public bool magejectonmag;
private bool locked = false;
private bool isPhysRel = false;
public Collider[] colliders;
public ClosedBoltWeapon Gun;
public GameObject GunRig;
[NonSerialized]
public FVRFireArmMagazine Magazine;
public GameObject maglatch;
public Collider col;
private void Update()
{
//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_001c: 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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: 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_056b: Unknown result type (might be due to invalid IL or missing references)
//IL_0590: Unknown result type (might be due to invalid IL or missing references)
//IL_041f: Unknown result type (might be due to invalid IL or missing references)
//IL_0424: Unknown result type (might be due to invalid IL or missing references)
//IL_0442: Unknown result type (might be due to invalid IL or missing references)
//IL_0447: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_0464: Unknown result type (might be due to invalid IL or missing references)
//IL_046a: Unknown result type (might be due to invalid IL or missing references)
//IL_046b: Unknown result type (might be due to invalid IL or missing references)
//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_049f: Unknown result type (might be due to invalid IL or missing references)
//IL_030e: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((Component)Gun).transform.InverseTransformPoint(MagazinePoint.position);
Vector3 val2 = ((Component)Gun).transform.InverseTransformPoint(MagazinePivot.position);
if ((Object)(object)Magazine != (Object)null)
{
if (((FVRInteractiveObject)Magazine).IsHeld)
{
((FVRFireArm)Gun).RecoilProfile = hold;
}
else if (!((FVRInteractiveObject)Magazine).IsHeld)
{
((FVRFireArm)Gun).RecoilProfile = unhold;
}
if (Quaternion.Angle(MagazinePoint.rotation, ((Component)Magazine).transform.rotation) < lockangle && !locked)
{
JointLimits limits = default(JointLimits);
((JointLimits)(ref limits)).max = lowerlimit;
((JointLimits)(ref limits)).min = lowerlimit;
Joint.limits = limits;
locked = true;
if ((Object)(object)((FVRFireArm)Gun).Magazine == (Object)null)
{
((FVRFireArm)Gun).LoadMag(Magazine);
Magazine.FireArm = (FVRFireArm)(object)Gun;
}
}
if ((Object)(object)((FVRInteractiveObject)Gun).m_hand != (Object)null && (Object)(object)((FVRInteractiveObject)Magazine).m_hand != (Object)null)
{
if (locked && !((FVRInteractiveObject)Magazine).m_hand.IsInStreamlinedMode && ((FVRInteractiveObject)Magazine).m_hand.Input.TouchpadSouthPressed)
{
locked = false;
JointLimits limits2 = default(JointLimits);
((JointLimits)(ref limits2)).max = upperlimit;
((JointLimits)(ref limits2)).min = lowerlimit;
if ((Object)(object)Joint != (Object)null)
{
Joint.limits = limits2;
Object.Destroy((Object)(object)Joint);
}
Collider[] array = ((FVRInteractiveObject)Magazine).m_colliders;
foreach (Collider val3 in array)
{
Collider[] array2 = colliders;
foreach (Collider val4 in array2)
{
Physics.IgnoreCollision(val4, val3, false);
}
}
if ((Object)(object)((FVRFireArm)Gun).Magazine != (Object)null)
{
((FVRFireArm)Gun).EjectMag(false);
Magazine = null;
}
}
if (locked && ((FVRInteractiveObject)Magazine).m_hand.IsInStreamlinedMode && ((FVRInteractiveObject)Magazine).m_hand.Input.AXButtonPressed)
{
locked = false;
JointLimits limits3 = default(JointLimits);
((JointLimits)(ref limits3)).max = upperlimit;
((JointLimits)(ref limits3)).min = lowerlimit;
if ((Object)(object)Joint != (Object)null)
{
Joint.limits = limits3;
Object.Destroy((Object)(object)Joint);
}
Collider[] array3 = ((FVRInteractiveObject)Magazine).m_colliders;
foreach (Collider val5 in array3)
{
Collider[] array4 = colliders;
foreach (Collider val6 in array4)
{
Physics.IgnoreCollision(val6, val5, false);
}
}
if ((Object)(object)((FVRFireArm)Gun).Magazine != (Object)null)
{
((FVRFireArm)Gun).EjectMag(false);
Magazine = null;
}
}
}
if ((Object)(object)((FVRInteractiveObject)Gun).m_hand != (Object)null && (Object)(object)((FVRInteractiveObject)Gun).m_hand.OtherHand.m_currentInteractable != (Object)null && (Object)(object)((Component)((FVRInteractiveObject)Gun).m_hand.OtherHand.m_currentInteractable).gameObject.GetComponent<FVRFireArmMagazine>() != (Object)null && maglatch.transform.localEulerAngles.x > 180f && maglatch.transform.localEulerAngles.x < 335f)
{
locked = false;
JointLimits limits4 = default(JointLimits);
((JointLimits)(ref limits4)).max = upperlimit;
((JointLimits)(ref limits4)).min = lowerlimit;
if ((Object)(object)Joint != (Object)null)
{
Joint.limits = limits4;
Object.Destroy((Object)(object)Joint);
}
Collider[] array5 = ((FVRInteractiveObject)Magazine).m_colliders;
foreach (Collider val7 in array5)
{
Collider[] array6 = colliders;
foreach (Collider val8 in array6)
{
Physics.IgnoreCollision(val8, val7, false);
}
}
if ((Object)(object)((FVRFireArm)Gun).Magazine != (Object)null)
{
((FVRFireArm)Gun).EjectMag(false);
Magazine = null;
}
}
if (locked)
{
((Component)Magazine).gameObject.transform.position = ((Component)MagazinePoint).transform.position;
((Component)Magazine).gameObject.transform.rotation = ((Component)MagazinePoint).transform.rotation;
}
}
else if ((Object)(object)Magazine == (Object)null)
{
((FVRFireArm)Gun).RecoilProfile = unhold;
}
}
public void OnTriggerStay(Collider other)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: 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_0093: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: 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_00eb: 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_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: 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_019e: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)((Component)other).GetComponent<FVRFireArmReloadTriggerMag>() != (Object)null) || !((Object)(object)((FVRInteractiveObject)((Component)other).GetComponent<FVRFireArmReloadTriggerMag>().Magazine).m_hand != (Object)null))
{
return;
}
Transform transform = new GameObject().transform;
transform.rotation = ((Component)((Component)other).GetComponent<FVRFireArmReloadTriggerMag>().Magazine).gameObject.transform.rotation;
transform.parent = MagazinePoint;
Vector3 val = ((Component)Gun).transform.InverseTransformPoint(MagazinePoint.position);
Vector3 val2 = ((Component)Gun).transform.InverseTransformPoint(MagazinePivot.position);
Joint = ((Component)Gun).gameObject.AddComponent<HingeJoint>();
((Joint)Joint).autoConfigureConnectedAnchor = false;
JointLimits limits = default(JointLimits);
((JointLimits)(ref limits)).max = upperlimit;
((JointLimits)(ref limits)).min = lowerlimit;
Joint.limits = limits;
((Joint)Joint).anchor = val2;
Joint.useLimits = true;
((Joint)Joint).connectedAnchor = val2 - val;
((Component)((Component)other).GetComponent<FVRFireArmReloadTriggerMag>().Magazine).transform.rotation = MagazinePoint.rotation;
((Joint)Joint).axis = ((Component)Gun).transform.InverseTransformDirection(MagazinePoint.right);
((Joint)Joint).connectedBody = ((Component)((Component)other).GetComponent<FVRFireArmReloadTriggerMag>().Magazine).GetComponent<Rigidbody>();
Magazine = ((Component)other).GetComponent<FVRFireArmReloadTriggerMag>().Magazine;
((Component)((Component)other).GetComponent<FVRFireArmReloadTriggerMag>().Magazine).transform.rotation = transform.rotation;
Object.Destroy((Object)(object)((Component)transform).gameObject);
Collider[] array = ((FVRInteractiveObject)Magazine).m_colliders;
foreach (Collider val3 in array)
{
Collider[] array2 = colliders;
foreach (Collider val4 in array2)
{
Physics.IgnoreCollision(val4, val3, true);
}
}
}
}
[Serializable]
public class BlurCircle
{
[Range(0f, 1f)]
public float positionX = 0.5f;
[Range(0f, 1f)]
public float positionY = 0.5f;
[Range(0.01f, 0.5f)]
public float radius = 0.1f;
[Range(0.1f, 5f)]
public float transitionSharpness = 1f;
[Range(0f, 1f)]
public float intensity = 1f;
public bool isActive = true;
[HideInInspector]
public float pulseTimer = 0f;
[HideInInspector]
public float pulseSpeed = 1f;
[HideInInspector]
public float minRadius = 0.05f;
[HideInInspector]
public float maxRadius = 0.2f;
public Vector2 Position
{
get
{
//IL_000d: 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)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
return new Vector2(positionX, positionY);
}
set
{
positionX = Mathf.Clamp01(value.x);
positionY = Mathf.Clamp01(value.y);
}
}
}
public class EnhancedCircleBlur : MonoBehaviour
{
[Header("Blur Settings")]
[Range(0f, 10f)]
public float blurStrength = 5f;
[Range(0.1f, 10f)]
public float globalTransitionSharpness = 3f;
[Range(0f, 1f)]
public float globalIntensity = 1f;
public bool invertEffect = false;
[Header("Circle Management")]
public List<BlurCircle> circles = new List<BlurCircle>();
public int maxCircles = 60;
[Header("Animation")]
public bool animateCircles = false;
public float animationSpeed = 1f;
public bool pulseRadius = false;
public float pulseMin = 0.05f;
public float pulseMax = 0.2f;
[Header("Performance")]
public int updateRate = 30;
public bool useFastBlur = true;
[Header("References")]
public Material targetMaterial;
public Renderer targetRenderer;
private Texture2D circleDataTexture;
private float updateTimer = 0f;
private bool materialAssigned = false;
private static readonly int CircleDataTexID = Shader.PropertyToID("_CircleDataTex");
private static readonly int CircleCountID = Shader.PropertyToID("_CircleCount");
private static readonly int BlurStrengthID = Shader.PropertyToID("_BlurStrength");
private static readonly int TransitionSharpnessID = Shader.PropertyToID("_TransitionSharpness");
private static readonly int InvertEffectID = Shader.PropertyToID("_InvertEffect");
private static readonly int GlobalIntensityID = Shader.PropertyToID("_GlobalIntensity");
private void Start()
{
if ((Object)(object)targetRenderer == (Object)null)
{
targetRenderer = ((Component)this).GetComponent<Renderer>();
}
if ((Object)(object)targetMaterial == (Object)null && (Object)(object)targetRenderer != (Object)null)
{
targetMaterial = targetRenderer.sharedMaterial;
}
if (circles.Count == 0)
{
circles.Add(new BlurCircle());
}
if (circles.Count > maxCircles)
{
circles.RemoveRange(maxCircles, circles.Count - maxCircles);
}
CreateCircleDataTexture();
if ((Object)(object)targetMaterial != (Object)null)
{
targetMaterial.SetTexture(CircleDataTexID, (Texture)(object)circleDataTexture);
UpdateMaterialProperties();
materialAssigned = true;
}
InitializeAnimation();
}
private void Update()
{
updateTimer += Time.deltaTime;
float num = 1f / (float)updateRate;
if (updateTimer >= num)
{
if (animateCircles)
{
UpdateAnimations();
}
UpdateCircleDataTexture();
if (materialAssigned)
{
UpdateMaterialProperties();
}
updateTimer = 0f;
}
}
private void CreateCircleDataTexture()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
circleDataTexture = new Texture2D(maxCircles, 1, (TextureFormat)20, false);
((Texture)circleDataTexture).wrapMode = (TextureWrapMode)1;
((Texture)circleDataTexture).filterMode = (FilterMode)0;
((Object)circleDataTexture).name = "CircleDataTexture";
UpdateCircleDataTexture();
}
private void UpdateCircleDataTexture()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)circleDataTexture == (Object)null)
{
return;
}
Color[] array = (Color[])(object)new Color[maxCircles];
for (int i = 0; i < maxCircles; i++)
{
ref Color reference = ref array[i];
reference = Color.black;
}
int num = 0;
for (int j = 0; j < circles.Count && j < maxCircles; j++)
{
if (circles[j].isActive)
{
BlurCircle blurCircle = circles[j];
float num2 = Mathf.Clamp01(blurCircle.radius / 0.5f);
float num3 = Mathf.Clamp01(blurCircle.transitionSharpness / 5f);
ref Color reference2 = ref array[num];
reference2 = new Color(blurCircle.positionX, blurCircle.positionY, num2, num3);
num++;
}
}
circleDataTexture.SetPixels(array);
circleDataTexture.Apply();
if ((Object)(object)targetMaterial != (Object)null)
{
targetMaterial.SetTexture(CircleDataTexID, (Texture)(object)circleDataTexture);
targetMaterial.SetInt(CircleCountID, num);
}
}
private void UpdateMaterialProperties()
{
if (!((Object)(object)targetMaterial == (Object)null))
{
targetMaterial.SetFloat(BlurStrengthID, blurStrength);
targetMaterial.SetFloat(TransitionSharpnessID, globalTransitionSharpness);
targetMaterial.SetFloat(GlobalIntensityID, globalIntensity);
targetMaterial.SetFloat(InvertEffectID, (!invertEffect) ? 0f : 1f);
}
}
private void InitializeAnimation()
{
foreach (BlurCircle circle in circles)
{
circle.pulseTimer = Random.Range(0f, (float)Math.PI * 2f);
circle.pulseSpeed = Random.Range(0.5f, 2f);
circle.minRadius = pulseMin;
circle.maxRadius = pulseMax;
}
}
private void UpdateAnimations()
{
if (!animateCircles)
{
return;
}
foreach (BlurCircle circle in circles)
{
if (circle.isActive)
{
circle.pulseTimer += Time.deltaTime * animationSpeed * circle.pulseSpeed;
if (pulseRadius)
{
float num = (Mathf.Sin(circle.pulseTimer) + 1f) * 0.5f;
circle.radius = Mathf.Lerp(circle.minRadius, circle.maxRadius, num);
}
circle.positionX = Mathf.Clamp01(circle.positionX);
circle.positionY = Mathf.Clamp01(circle.positionY);
circle.radius = Mathf.Clamp(circle.radius, 0.01f, 0.5f);
}
}
}
public void AddCircle(Vector2 position, float radius, float transitionSharpness)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
if (circles.Count >= maxCircles)
{
Debug.LogWarning((object)("Maximum number of circles reached:" + maxCircles));
return;
}
BlurCircle blurCircle = new BlurCircle();
blurCircle.Position = position;
blurCircle.radius = Mathf.Clamp(radius, 0.01f, 0.5f);
blurCircle.transitionSharpness = Mathf.Clamp(transitionSharpness, 0.1f, 5f);
blurCircle.isActive = true;
BlurCircle item = blurCircle;
circles.Add(item);
}
public void RemoveCircle(int index)
{
if (index >= 0 && index < circles.Count)
{
circles.RemoveAt(index);
}
}
public void SetCircleActive(int index, bool active)
{
if (index >= 0 && index < circles.Count)
{
circles[index].isActive = active;
}
}
public void ClearCircles()
{
circles.Clear();
}
public void RandomizeCircles(int count)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
circles.Clear();
for (int i = 0; i < count && i < maxCircles; i++)
{
AddCircle(new Vector2(Random.value, Random.value), Random.Range(0.05f, 0.2f), Random.Range(0.5f, 3f));
}
}
private void OnValidate()
{
blurStrength = Mathf.Clamp(blurStrength, 0f, 10f);
globalTransitionSharpness = Mathf.Clamp(globalTransitionSharpness, 0.1f, 10f);
globalIntensity = Mathf.Clamp01(globalIntensity);
foreach (BlurCircle circle in circles)
{
circle.positionX = Mathf.Clamp01(circle.positionX);
circle.positionY = Mathf.Clamp01(circle.positionY);
circle.radius = Mathf.Clamp(circle.radius, 0.01f, 0.5f);
circle.transitionSharpness = Mathf.Clamp(circle.transitionSharpness, 0.1f, 5f);
circle.intensity = Mathf.Clamp01(circle.intensity);
}
if (Application.isPlaying && (Object)(object)circleDataTexture != (Object)null)
{
UpdateCircleDataTexture();
UpdateMaterialProperties();
}
}
private void OnDrawGizmosSelected()
{
//IL_006a: 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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: 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)
//IL_00b2: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
if (circles == null || !((Behaviour)this).enabled)
{
return;
}
Color color = default(Color);
foreach (BlurCircle circle in circles)
{
if (circle.isActive)
{
Vector3 val = ((Component)this).transform.TransformPoint(new Vector3(circle.positionX - 0.5f, 0f, circle.positionY - 0.5f));
Gizmos.color = Color.green;
Gizmos.DrawWireSphere(val, circle.radius * 0.5f);
((Color)(ref color))..ctor(0f, 1f, 0f, 0.2f);
Gizmos.color = color;
Gizmos.DrawSphere(val, circle.radius * 0.5f);
Gizmos.color = Color.red;
Gizmos.DrawSphere(val, 0.01f);
}
}
}
private void OnDestroy()
{
if ((Object)(object)circleDataTexture != (Object)null)
{
Object.DestroyImmediate((Object)(object)circleDataTexture);
}
}
}
public class CircleDataMul
{
public Vector2 position;
public float radius;
public float transitionSpeed;
public CircleDataMul(Vector2 pos, float rad, float speed)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
position = pos;
radius = rad;
transitionSpeed = speed;
}
}
public class MultiCircleBlurController : MonoBehaviour
{
[Header("Shader Properties")]
public Material targetMaterial;
[Range(0f, 1f)]
public float blurStrength = 0.5f;
public float defaultRadius = 0.1f;
public float transitionSmoothness = 2f;
[Header("Circle Settings")]
public List<Vector2> circlePositions = new List<Vector2>();
public List<float> circleRadii = new List<float>();
public List<float> circleTransitions = new List<float>();
[Header("Animation Settings")]
public bool animateTransitions = true;
public float transitionDuration = 2f;
private List<float> currentTransitionValues = new List<float>();
private List<float> targetTransitionValues = new List<float>();
private float transitionTimer = 0f;
private const int MAX_CIRCLES = 8;
private void Start()
{
InitializeCircles();
UpdateShaderProperties();
for (int i = 0; i < circleTransitions.Count; i++)
{
currentTransitionValues.Add(circleTransitions[i]);
targetTransitionValues.Add(circleTransitions[i]);
}
}
private void Update()
{
if (animateTransitions)
{
UpdateTransitions();
}
UpdateShaderProperties();
}
private void InitializeCircles()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
if (circlePositions.Count == 0)
{
circlePositions.Add(new Vector2(0.5f, 0.5f));
circleRadii.Add(defaultRadius);
circleTransitions.Add(1f);
}
while (circleRadii.Count < circlePositions.Count)
{
circleRadii.Add(defaultRadius);
}
while (circleTransitions.Count < circlePositions.Count)
{
circleTransitions.Add(1f);
}
}
private void UpdateTransitions()
{
transitionTimer += Time.deltaTime;
if (transitionTimer >= transitionDuration)
{
transitionTimer = 0f;
for (int i = 0; i < targetTransitionValues.Count; i++)
{
targetTransitionValues[i] = Random.Range(0.1f, 3f);
}
}
float num = transitionTimer / transitionDuration;
float num2 = Mathf.SmoothStep(0f, 1f, num);
for (int j = 0; j < currentTransitionValues.Count; j++)
{
currentTransitionValues[j] = Mathf.Lerp(circleTransitions[j], targetTransitionValues[j], num2);
}
}
private void UpdateShaderProperties()
{
//IL_007c: 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_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: 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_00a8: 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_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: 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_040b: Unknown result type (might be due to invalid IL or missing references)
//IL_041d: Unknown result type (might be due to invalid IL or missing references)
//IL_042f: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)targetMaterial == (Object)null)
{
return;
}
targetMaterial.SetFloat("_BlurStrength", blurStrength);
targetMaterial.SetFloat("_CircleRadius", defaultRadius);
targetMaterial.SetFloat("_TransitionSmoothness", transitionSmoothness);
int num = Mathf.Min(circlePositions.Count, 8);
targetMaterial.SetInt("_CircleCount", num);
Vector4 zero = Vector4.zero;
Vector4 zero2 = Vector4.zero;
Vector4 zero3 = Vector4.zero;
for (int i = 0; i < Mathf.Min(num, 4); i++)
{
if (i == 0)
{
zero.x = circlePositions[i].x;
}
if (i == 0)
{
zero.y = circlePositions[i].y;
}
if (i == 1)
{
zero.z = circlePositions[i].x;
}
if (i == 1)
{
zero.w = circlePositions[i].y;
}
if (i == 0)
{
zero2.x = circleRadii[i];
}
if (i == 1)
{
zero2.y = circleRadii[i];
}
if (i == 2)
{
zero2.z = circleRadii[i];
}
if (i == 3)
{
zero2.w = circleRadii[i];
}
float num2 = ((!animateTransitions) ? circleTransitions[i] : currentTransitionValues[i]);
if (i == 0)
{
zero3.x = num2;
}
if (i == 1)
{
zero3.y = num2;
}
if (i == 2)
{
zero3.z = num2;
}
if (i == 3)
{
zero3.w = num2;
}
}
targetMaterial.SetVector("_CirclePositions", zero);
targetMaterial.SetVector("_CircleRadii", zero2);
targetMaterial.SetVector("_CircleTransitions", zero3);
if (num <= 4)
{
return;
}
Vector4 zero4 = Vector4.zero;
Vector4 zero5 = Vector4.zero;
Vector4 zero6 = Vector4.zero;
for (int j = 4; j < Mathf.Min(num, 8); j++)
{
int num3 = j - 4;
if (num3 == 0)
{
zero4.x = circlePositions[j].x;
}
if (num3 == 0)
{
zero4.y = circlePositions[j].y;
}
if (num3 == 1)
{
zero4.z = circlePositions[j].x;
}
if (num3 == 1)
{
zero4.w = circlePositions[j].y;
}
if (num3 == 0)
{
zero5.x = circleRadii[j];
}
if (num3 == 1)
{
zero5.y = circleRadii[j];
}
if (num3 == 2)
{
zero5.z = circleRadii[j];
}
if (num3 == 3)
{
zero5.w = circleRadii[j];
}
float num4 = ((!animateTransitions) ? circleTransitions[j] : currentTransitionValues[j]);
if (num3 == 0)
{
zero6.x = num4;
}
if (num3 == 1)
{
zero6.y = num4;
}
if (num3 == 2)
{
zero6.z = num4;
}
if (num3 == 3)
{
zero6.w = num4;
}
}
targetMaterial.SetVector("_CirclePositions2", zero4);
targetMaterial.SetVector("_CircleRadii2", zero5);
targetMaterial.SetVector("_CircleTransitions2", zero6);
}
public void AddCircle(Vector2 position, float radius, float transitionSpeed)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
if (circlePositions.Count >= 8)
{
Debug.LogWarning((object)("已达到最大圆数量限制 (" + 8 + ")"));
return;
}
circlePositions.Add(position);
circleRadii.Add(radius);
circleTransitions.Add(transitionSpeed);
currentTransitionValues.Add(transitionSpeed);
targetTransitionValues.Add(transitionSpeed);
}
public void RemoveCircle(int index)
{
if (index >= 0 && index < circlePositions.Count)
{
circlePositions.RemoveAt(index);
circleRadii.RemoveAt(index);
circleTransitions.RemoveAt(index);
currentTransitionValues.RemoveAt(index);
targetTransitionValues.RemoveAt(index);
}
}
public void UpdateCircle(int index, Vector2 position, float radius, float transitionSpeed)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if (index >= 0 && index < circlePositions.Count)
{
circlePositions[index] = position;
circleRadii[index] = radius;
circleTransitions[index] = transitionSpeed;
}
}
public void SetCircleTransition(int index, float transitionValue)
{
if (index >= 0 && index < circleTransitions.Count)
{
circleTransitions[index] = transitionValue;
if (index < currentTransitionValues.Count)
{
currentTransitionValues[index] = transitionValue;
}
}
}
private void OnDrawGizmosSelected()
{
//IL_0038: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: 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)
if (circlePositions == null)
{
return;
}
for (int i = 0; i < circlePositions.Count; i++)
{
if (i < circleRadii.Count)
{
Vector3 val = ((Component)this).transform.TransformPoint(new Vector3(circlePositions[i].x - 0.5f, 0f, circlePositions[i].y - 0.5f));
Gizmos.color = Color.green;
Gizmos.DrawWireSphere(val, circleRadii[i] * 0.5f);
Gizmos.color = new Color(0f, 1f, 0f, 0.3f);
Gizmos.DrawSphere(val, circleRadii[i] * 0.5f);
}
}
}
}
public class BezierMover : MonoBehaviour
{
[Header("控制点")]
public Transform p0;
public Transform p1;
public Transform p2;
public Transform p3;
public GameObject hook;
[Header("运动设置")]
public LineRenderer wire;
public Transform wp0;
public Transform wp1;
public Transform wp2;
public Transform wp3;
public GameObject[] joints;
private void Update()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: 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)
for (int i = 0; i < joints.Length; i++)
{
joints[i].transform.position = GetCubicBezierPoint((float)i * 0.1f, p0.position, p1.position, p2.position, p3.position);
if (i == joints.Length - 1)
{
AxisLookAt(joints[i].transform, hook.transform.position, -Vector3.right);
}
if (i != joints.Length - 1)
{
AxisLookAt(joints[i].transform, joints[i + 1].transform.position, -Vector3.right);
}
}
}
private void AxisLookAt(Transform tr_self, Vector3 lookPos, Vector3 directionAxis)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//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_0016: 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_0021: 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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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)
//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_003f: 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_0045: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_0074: Unknown result type (might be due to invalid IL or missing references)
Quaternion rotation = tr_self.rotation;
Vector3 val = lookPos - tr_self.position;
Vector3 val2 = tr_self.rotation * directionAxis;
Vector3 val3 = Vector3.Cross(val2, val);
Vector3 normalized = ((Vector3)(ref val3)).normalized;
float num = Vector3.Angle(val2, val);
tr_self.rotation = Quaternion.AngleAxis(num, normalized) * rotation;
tr_self.localEulerAngles = new Vector3(0f, tr_self.localEulerAngles.y, tr_self.localEulerAngles.z);
}
public static Vector3 GetCubicBezierPoint(float t, Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3)
{
//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_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: 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_003e: 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_004b: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
float num = 1f - t;
float num2 = t * t;
float num3 = num * num;
float num4 = num3 * num;
float num5 = num2 * t;
return num4 * p0 + 3f * num3 * t * p1 + 3f * num * num2 * p2 + num5 * p3;
}
private void OnDrawGizmos()
{
//IL_0001: 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_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
Gizmos.color = Color.white;
Vector3 val = p0.position;
for (int i = 1; i <= 30; i++)
{
float t = (float)i / 30f;
Vector3 cubicBezierPoint = GetCubicBezierPoint(t, wp0.position, wp1.position, wp2.position, wp3.position);
Gizmos.DrawLine(val, cubicBezierPoint);
val = cubicBezierPoint;
}
}
}
public class FishingRodPhysics : MonoBehaviour
{
[Serializable]
public class RodBone
{
public Transform boneTransform;
public Vector3 restPosition;
public Quaternion restRotation;
public float flexibility = 1f;
}
public GameObject hook;
public GameObject top;
public GameObject topref;
[Header("骨骼设置")]
public RodBone[] rodBones = new RodBone[9];
[Header("物理参数")]
[SerializeField]
private float pullForce = 0f;
[SerializeField]
private Vector3 pullDirection = Vector3.right;
[SerializeField]
private float maxBendAngle = 60f;
[SerializeField]
private float springStiffness = 100f;
[SerializeField]
private float damping = 10f;
[SerializeField]
private float rodLength = 2f;
[Header("弯曲曲线")]
public AnimationCurve bendCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
private Vector3[] bonePositions;
private Vector3[] boneVelocities;
private Vector3 pullPointWorld;
public float PullForce
{
get
{
return pullForce;
}
set
{
pullForce = Mathf.Clamp01(value);
}
}
public Vector3 PullDirection
{
get
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
return pullDirection;
}
set
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
pullDirection = ((Vector3)(ref value)).normalized;
}
}
private void Start()
{
//IL_00a7: 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)
//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_007d: 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)
InitializeBones();
bonePositions = (Vector3[])(object)new Vector3[rodBones.Length];
boneVelocities = (Vector3[])(object)new Vector3[rodBones.Length];
for (int i = 0; i < rodBones.Length; i++)
{
if ((Object)(object)rodBones[i].boneTransform != (Object)null)
{
ref Vector3 reference = ref bonePositions[i];
reference = rodBones[i].boneTransform.position;
ref Vector3 reference2 = ref boneVelocities[i];
reference2 = Vector3.zero;
}
}
pullPointWorld = top.transform.position;
}
private void InitializeBones()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: 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_00cf: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)rodBones[0].boneTransform == (Object)null)
{
Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>();
int num = Mathf.Min(9, componentsInChildren.Length - 1);
for (int i = 0; i < num; i++)
{
rodBones[i].boneTransform = componentsInChildren[i + 1];
rodBones[i].restPosition = rodBones[i].boneTransform.localPosition;
rodBones[i].restRotation = rodBones[i].boneTransform.localRotation;
}
return;
}
for (int j = 0; j < rodBones.Length; j++)
{
if ((Object)(object)rodBones[j].boneTransform != (Object)null)
{
rodBones[j].restPosition = rodBones[j].boneTransform.localPosition;
rodBones[j].restRotation = rodBones[j].boneTransform.localRotation;
}
}
}
private void Update()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: 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_0108: Unknown result type (might be due to invalid IL or missing references)
SimulateRodPhysics(Time.deltaTime);
for (int i = 0; i < rodBones.Length; i++)
{
rodBones[i].boneTransform.localEulerAngles = new Vector3(0f, rodBones[i].boneTransform.localEulerAngles.y, rodBones[i].boneTransform.localEulerAngles.z);
}
pullForce = Vector3.Distance(top.transform.position, hook.transform.position);
top.transform.position = topref.transform.position;
top.transform.eulerAngles = topref.transform.eulerAngles;
pullDirection = hook.transform.position - top.transform.position;
ApplyBendToBones();
}
private void SimulateRodPhysics(float deltaTime)
{
//IL_003b: 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_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: 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_00c6: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: 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_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: 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_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: 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_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: 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_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_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: 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_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)
if (rodBones.Length == 0)
{
return;
}
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(pullDirection.x, pullDirection.y, pullDirection.z);
Vector3 val2 = val * pullForce * 10f;
for (int i = 1; i < rodBones.Length; i++)
{
if (!((Object)(object)rodBones[i].boneTransform == (Object)null))
{
float num = bendCurve.Evaluate((float)i / (float)(rodBones.Length - 1));
Vector3 val3 = val2 * num * rodBones[i].flexibility;
Vector3 val4 = ((Component)this).transform.TransformPoint(rodBones[i].restPosition);
Vector3 val5 = (val4 - bonePositions[i]) * springStiffness;
Vector3 val6 = -boneVelocities[i] * damping;
Vector3 val7 = val3 + val5 + val6;
ref Vector3 reference = ref boneVelocities[i];
reference += val7 * deltaTime;
ref Vector3 reference2 = ref bonePositions[i];
reference2 += boneVelocities[i] * deltaTime;
}
}
if ((Object)(object)rodBones[0].boneTransform != (Object)null)
{
ref Vector3 reference3 = ref bonePositions[0];
reference3 = ((Component)this).transform.TransformPoint(rodBones[0].restPosition);
ref Vector3 reference4 = ref boneVelocities[0];
reference4 = Vector3.zero;
}
ApplyDistanceConstraints();
}
private void ApplyDistanceConstraints()
{
//IL_0069: 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_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
float num = rodLength / (float)(rodBones.Length - 1);
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < rodBones.Length - 1; j++)
{
if ((Object)(object)rodBones[j].boneTransform == (Object)null || (Object)(object)rodBones[j + 1].boneTransform == (Object)null)
{
continue;
}
Vector3 val = bonePositions[j + 1] - bonePositions[j];
float magnitude = ((Vector3)(ref val)).magnitude;
float num2 = magnitude - num;
if (magnitude > 0f)
{
Vector3 val2 = val * (num2 / magnitude) * 0.5f;
if (j > 0)
{
ref Vector3 reference = ref bonePositions[j];
reference += val2;
}
ref Vector3 reference2 = ref bonePositions[j + 1];
reference2 -= val2;
}
}
}
}
private void ApplyBendToBones()
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: 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_00a7: 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_003b: 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_0045: 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_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: 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_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_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: 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_0103: 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_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: 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_0160: 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_0195: Unknown result type (might be due to invalid IL or missing references)
Vector3 val4 = default(Vector3);
for (int i = 0; i < rodBones.Length; i++)
{
if ((Object)(object)rodBones[i].boneTransform == (Object)null)
{
continue;
}
Vector3 val;
Quaternion val2;
if (i == 0)
{
val = ((Component)this).transform.TransformPoint(rodBones[i].restPosition);
val2 = ((Component)this).transform.rotation * rodBones[i].restRotation;
}
else
{
Vector3 val3 = bonePositions[i - 1] - bonePositions[i];
val = bonePositions[i];
if (val3 != Vector3.zero)
{
((Vector3)(ref val4))..ctor(val3.x, val3.y, 0f);
Vector3 normalized = ((Vector3)(ref val4)).normalized;
Quaternion val5 = Quaternion.FromToRotation(Vector3.right, normalized);
val2 = ((Component)this).transform.rotation * val5 * rodBones[i].restRotation;
}
else
{
val2 = ((Component)this).transform.rotation * rodBones[i].restRotation;
}
}
rodBones[i].boneTransform.position = Vector3.Lerp(rodBones[i].boneTransform.position, val, Time.deltaTime * 20f);
rodBones[i].boneTransform.rotation = Quaternion.Slerp(rodBones[i].boneTransform.rotation, val2, Time.deltaTime * 20f);
}
}
private void OnDrawGizmosSelected()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: 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_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: 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_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: 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_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: 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_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
if (rodBones == null || rodBones.Length == 0)
{
return;
}
Gizmos.color = Color.green;
for (int i = 0; i < rodBones.Length; i++)
{
if ((Object)(object)rodBones[i].boneTransform != (Object)null)
{
Gizmos.DrawSphere(rodBones[i].boneTransform.position, 0.02f);
if (i < rodBones.Length - 1 && (Object)(object)rodBones[i + 1].boneTransform != (Object)null)
{
Gizmos.DrawLine(rodBones[i].boneTransform.position, rodBones[i + 1].boneTransform.position);
}
}
}
if (pullForce > 0.01f)
{
Gizmos.color = Color.red;
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(0f - pullDirection.x, pullDirection.y, 0f);
Vector3 val2 = val * pullForce * 0.5f;
Vector3 val3 = ((Component)this).transform.TransformPoint(new Vector3(0f - rodLength, 0f, 0f));
Gizmos.DrawLine(val3, val3 + val2);
Gizmos.DrawSphere(val3 + val2, 0.03f);
}
}
public void TestPull(float force, Vector2 direction)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
PullForce = force;
PullDirection = Vector2.op_Implicit(direction);
}
public void ResetRod()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
PullForce = 0f;
for (int i = 0; i < rodBones.Length; i++)
{
if ((Object)(object)rodBones[i].boneTransform != (Object)null)
{
rodBones[i].boneTransform.localPosition = rodBones[i].restPosition;
rodBones[i].boneTransform.localRotation = rodBones[i].restRotation;
ref Vector3 reference = ref boneVelocities[i];
reference = Vector3.zero;
}
}
}
}
internal class TronTrailSection
{
public Vector3 point;
public Vector3 upDir;
public float time;
public TronTrailSection()
{
}
public TronTrailSection(Vector3 p, float t)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
point = p;
time = t;
}
}
[RequireComponent(typeof(MeshFilter))]
public class LightsaberTrail : MonoBehaviour
{
public float height = 2f;
public float time = 2f;
public bool alwaysUp = false;
public float minDistance = 0.1f;
public float timeTransitionSpeed = 1f;
public float desiredTime = 2f;
public Color startColor = Color.white;
public Color endColor = new Color(1f, 1f, 1f, 0f);
private Vector3 position;
private float now = 0f;
private TronTrailSection currentSection;
private Matrix4x4 localSpaceTransform;
private Mesh mesh;
private Vector3[] vertices;
private Color[] colors;
private Vector2[] uv;
private MeshRenderer meshRenderer;
private Material trailMaterial;
private List<TronTrailSection> sections = new List<TronTrailSection>();
private void Awake()
{
Component component = ((Component)this).GetComponent(typeof(MeshFilter));
MeshFilter val = (MeshFilter)(object)((component is MeshFilter) ? component : null);
mesh = val.mesh;
ref MeshRenderer reference = ref meshRenderer;
Component component2 = ((Component)this).GetComponent(typeof(MeshRenderer));
reference = (MeshRenderer)(object)((component2 is MeshRenderer) ? component2 : null);
trailMaterial = ((Renderer)meshRenderer).material;
}
public void StartTrail(float timeToTweenTo, float fadeInTime)
{
desiredTime = timeToTweenTo;
if (time != desiredTime)
{
timeTransitionSpeed = Mathf.Abs(desiredTime - time) / fadeInTime;
}
if (time <= 0f)
{
time = 0.01f;
}
}
public void SetTime(float trailTime, float timeToTweenTo, float tweenSpeed)
{
time = trailTime;
desiredTime = timeToTweenTo;
timeTransitionSpeed = tweenSpeed;
if (time <= 0f)
{
ClearTrail();
}
}
public void FadeOut(float fadeTime)
{
desiredTime = 0f;
if (time > 0f)
{
timeTransitionSpeed = time / fadeTime;
}
}
public void SetTrailColor(Color color)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
trailMaterial.SetColor("_TintColor", color);
}
public void Iterate(float itterateTime)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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_006d: 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)
//IL_003b: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
position = ((Component)this).transform.position;
now = itterateTime;
if (sections.Count != 0)
{
Vector3 val = sections[0].point - position;
if (!(((Vector3)(ref val)).sqrMagnitude > minDistance * minDistance))
{
return;
}
}
TronTrailSection tronTrailSection = new TronTrailSection();
tronTrailSection.point = position;
if (alwaysUp)
{
tronTrailSection.upDir = Vector3.up;
}
else
{
tronTrailSection.upDir = ((Component)this).transform.TransformDirection(Vector3.up);
}
tronTrailSection.time = now;
sections.Insert(0, tronTrailSection);
}
public void UpdateTrail(float currentTime, float deltaTime)
{
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: 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_014d: 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_0178: 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_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_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: 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_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: 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_020e: Unknown result type (might be due to invalid IL or missing references)
mesh.Clear();
while (sections.Count > 0 && currentTime > sections[sections.Count - 1].time + time)
{
sections.RemoveAt(sections.Count - 1);
}
if (sections.Count < 2)
{
return;
}
vertices = (Vector3[])(object)new Vector3[sections.Count * 2];
colors = (Color[])(object)new Color[sections.Count * 2];
uv = (Vector2[])(object)new Vector2[sections.Count * 2];
currentSection = sections[0];
localSpaceTransform = ((Component)this).transform.worldToLocalMatrix;
for (int i = 0; i < sections.Count; i++)
{
currentSection = sections[i];
float num = 0f;
if (i != 0)
{
num = Mathf.Clamp01((currentTime - currentSection.time) / time);
}
Vector3 upDir = currentSection.upDir;
ref Vector3 reference = ref vertices[i * 2];
reference = ((Matrix4x4)(ref localSpaceTransform)).MultiplyPoint(currentSection.point);
ref Vector3 reference2 = ref vertices[i * 2 + 1];
reference2 = ((Matrix4x4)(ref localSpaceTransform)).MultiplyPoint(currentSection.point + upDir * height);
ref Vector2 reference3 = ref uv[i * 2];
reference3 = new Vector2(num, 0f);
ref Vector2 reference4 = ref uv[i * 2 + 1];
reference4 = new Vector2(num, 1f);
Color val = Color.Lerp(startColor, endColor, num);
colors[i * 2] = val;
colors[i * 2 + 1] = val;
}
int[] array = new int[(sections.Count - 1) * 2 * 3];
for (int j = 0; j < array.Length / 6; j++)
{
array[j * 6] = j * 2;
array[j * 6 + 1] = j * 2 + 1;
array[j * 6 + 2] = j * 2 + 2;
array[j * 6 + 3] = j * 2 + 2;
array[j * 6 + 4] = j * 2 + 1;
array[j * 6 + 5] = j * 2 + 3;
}
mesh.vertices = vertices;
mesh.colors = colors;
mesh.uv = uv;
mesh.triangles = array;
if (time > desiredTime)
{
time -= deltaTime * timeTransitionSpeed;
if (time <= desiredTime)
{
time = desiredTime;
}
}
else if (time < desiredTime)
{
time += deltaTime * timeTransitionSpeed;
if (time >= desiredTime)
{
time = desiredTime;
}
}
}
public void ClearTrail()
{
desiredTime = 0f;
time = 0f;
if ((Object)(object)mesh != (Object)null)
{
mesh.Clear();
sections.Clear();
}
}
}
[RequireComponent(typeof(LightsaberTrail))]
public class LightsaberTrailController : MonoBehaviour
{
private LightsaberTrail lightsaberTrail;
private void Start()
{
lightsaberTrail = ((Component)this).GetComponent<LightsaberTrail>();
}
private void Update()
{
lightsaberTrail.Iterate(Time.time);
lightsaberTrail.UpdateTrail(Time.time, 0f);
}
}
namespace JerryAr.AK_MagRelease_Flipper
{
[BepInPlugin("JerryAr.AK_MagRelease_Flipper", "AK_MagRelease_Flipper", "1.0.1")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
public class AK_MagRelease_FlipperPlugin : BaseUnityPlugin
{
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
internal static ManualLogSource Logger;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
LoadAssets();
}
private void LoadAssets()
{
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "JerryAr.AK_MagRelease_Flipper");
}
}
}