using System;
using System.Collections;
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 H3VRUtils.FVRInteractiveObjects;
using HarmonyLib;
using OpenScripts2;
using OtherLoader;
using UnityEngine;
using UnityEngine.UI;
[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 JerryComponent
{
public class BallisticChronograph : MonoBehaviour
{
private class BulletState
{
public Vector3 prevWorldPos;
public bool plane1Triggered;
public bool plane2Triggered;
public double plane1Time;
public double plane2Time;
public Vector3 plane1WorldPos;
public Vector3 plane2WorldPos;
}
private struct Intersection
{
public int plane;
public Vector3 localPos;
public float t;
}
[Header("UI Display")]
public Text display;
public GameObject hit1obj;
public GameObject hit2obj;
public bool is1 = false;
public bool is2 = false;
public float cd = 5f;
public float count;
public float vel;
[Header("Detection Planes (Local Coordinates)")]
private const float PLANE1_Z = -0.125f;
private const float PLANE2_Z = 0.125f;
private const float X_MIN = -0.0625f;
private const float X_MAX = 0.0625f;
private const float Y_MIN = 0.025f;
private const float Y_MAX = 0.145f;
[Header("Visualization (Optional)")]
public GameObject hit1;
public GameObject hit2;
public List<BallisticProjectile> projs = new List<BallisticProjectile>();
private Dictionary<BallisticProjectile, BulletState> bulletStates = new Dictionary<BallisticProjectile, BulletState>();
private void Awake()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
OpenScripts2_BasePlugin.ProjectileFiredEvent += new ProjectileFired(ProjectileFiredEvent);
}
private void OnDestroy()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
OpenScripts2_BasePlugin.ProjectileFiredEvent -= new ProjectileFired(ProjectileFiredEvent);
}
private void ProjectileFiredEvent(FVRFireArm fireArm, ref BallisticProjectile projectile)
{
//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)
projs.Add(projectile);
bulletStates[projectile] = new BulletState
{
prevWorldPos = ((Component)projectile).transform.position
};
}
private void FixedUpdate()
{
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: 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_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_032f: Unknown result type (might be due to invalid IL or missing references)
//IL_0331: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0347: Unknown result type (might be due to invalid IL or missing references)
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_0318: Unknown result type (might be due to invalid IL or missing references)
//IL_037c: Unknown result type (might be due to invalid IL or missing references)
//IL_037e: Unknown result type (might be due to invalid IL or missing references)
//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0420: Unknown result type (might be due to invalid IL or missing references)
//IL_0422: Unknown result type (might be due to invalid IL or missing references)
//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
//IL_047e: Unknown result type (might be due to invalid IL or missing references)
//IL_0480: Unknown result type (might be due to invalid IL or missing references)
//IL_0443: Unknown result type (might be due to invalid IL or missing references)
//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0502: Unknown result type (might be due to invalid IL or missing references)
//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
if (!is1 && is2)
{
is1 = false;
is2 = false;
}
if (is1)
{
if (!is2)
{
if (cd > 0f)
{
cd -= Time.deltaTime;
}
if (cd <= 0f)
{
is1 = false;
is2 = false;
}
vel = 0f;
count += Time.deltaTime;
}
else if (is2)
{
vel = Vector3.Distance(hit1.transform.position, hit2.transform.position) / count;
display.text = vel.ToString("F2");
Debug.Log((object)(vel + "=" + Vector3.Distance(hit1.transform.position, hit2.transform.position) + "/" + count));
is1 = false;
is2 = false;
hit1obj.transform.localPosition = new Vector3(0f, 0f, 0f);
hit2obj.transform.localPosition = new Vector3(0f, 0f, 0f);
vel = 0f;
}
}
if (!is1)
{
count = 0f;
cd = 5f;
}
float fixedDeltaTime = Time.fixedDeltaTime;
float time = Time.time;
float num = time - fixedDeltaTime;
for (int num2 = projs.Count - 1; num2 >= 0; num2--)
{
BallisticProjectile val = projs[num2];
if ((Object)(object)val == (Object)null)
{
projs.RemoveAt(num2);
bulletStates.Remove(val);
}
else
{
if (!bulletStates.TryGetValue(val, out var value))
{
BulletState bulletState = new BulletState();
bulletState.prevWorldPos = ((Component)val).transform.position;
value = bulletState;
bulletStates[val] = value;
}
Vector3 position = ((Component)val).transform.position;
Vector3 p = ((Component)this).transform.InverseTransformPoint(value.prevWorldPos);
Vector3 p2 = ((Component)this).transform.InverseTransformPoint(position);
List<Intersection> list = new List<Intersection>();
if (IntersectPlane(p, p2, -0.125f, out var intersectPoint, out var t) && IsWithinXYBounds(intersectPoint, -0.0625f, 0.0625f, 0.025f, 0.145f))
{
list.Add(new Intersection
{
plane = 1,
localPos = intersectPoint,
t = t
});
}
if (IntersectPlane(p, p2, 0.125f, out intersectPoint, out t) && IsWithinXYBounds(intersectPoint, -0.0625f, 0.0625f, 0.025f, 0.145f))
{
list.Add(new Intersection
{
plane = 2,
localPos = intersectPoint,
t = t
});
}
list.Sort((Intersection a, Intersection b) => a.t.CompareTo(b.t));
foreach (Intersection item in list)
{
float num3 = num + item.t * fixedDeltaTime;
Vector3 val2 = ((Component)this).transform.TransformPoint(item.localPos);
if (item.plane == 1 && !value.plane1Triggered)
{
value.plane1Triggered = true;
value.plane1Time = num3;
value.plane1WorldPos = val2;
if ((Object)(object)hit1 != (Object)null)
{
hit1.transform.position = val2;
}
}
else if (item.plane == 2 && !value.plane2Triggered)
{
value.plane2Triggered = true;
value.plane2Time = num3;
value.plane2WorldPos = val2;
if ((Object)(object)hit2 != (Object)null)
{
hit2.transform.position = val2;
}
}
}
if (value.plane1Triggered && value.plane2Triggered)
{
float num4 = Mathf.Abs((float)(value.plane2Time - value.plane1Time));
float num5 = Vector3.Distance(value.plane1WorldPos, value.plane2WorldPos);
float num6 = num5 / num4;
if ((Object)(object)display != (Object)null)
{
display.text = num6.ToString("F2");
}
Debug.Log((object)("Bullet speed: " + num6 + " m/s, distance " + num5 + ", time " + num4));
projs.RemoveAt(num2);
bulletStates.Remove(val);
}
else
{
value.prevWorldPos = position;
}
}
}
CleanupFarBullets();
}
private bool IntersectPlane(Vector3 p1, Vector3 p2, float planeZ, out Vector3 intersectPoint, out float t)
{
//IL_0003: 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_0079: 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_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)
intersectPoint = Vector3.zero;
t = 0f;
if (Mathf.Approximately(p2.z - p1.z, 0f))
{
return false;
}
t = (planeZ - p1.z) / (p2.z - p1.z);
if (t < 0f || t > 1f)
{
return false;
}
intersectPoint = Vector3.Lerp(p1, p2, t);
return true;
}
private bool IsWithinXYBounds(Vector3 point, float xMin, float xMax, float yMin, float yMax)
{
return point.x >= xMin && point.x <= xMax && point.y >= yMin && point.y <= yMax;
}
private void CleanupFarBullets()
{
//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_005f: Unknown result type (might be due to invalid IL or missing references)
for (int num = projs.Count - 1; num >= 0; num--)
{
if ((Object)(object)projs[num] == (Object)null)
{
projs.RemoveAt(num);
}
else
{
Vector3 val = ((Component)this).transform.InverseTransformPoint(((Component)projs[num]).transform.position);
if (val.z < -1f || val.z > 1f)
{
bulletStates.Remove(projs[num]);
projs.RemoveAt(num);
}
}
}
}
}
public class HitColBC : MonoBehaviour
{
public BallisticChronograph BC;
public bool isFront;
public GameObject pos;
private void OnTriggerEnter(Collider other)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)((Component)other).gameObject.GetComponent<Rigidbody>() != (Object)null)
{
if (isFront)
{
Debug.Log((object)"is1 Triggered");
BC.hit1obj.transform.position = ((Component)other).gameObject.transform.position;
BC.is1 = true;
}
else if (!isFront)
{
Debug.Log((object)"is2 Triggered");
BC.hit2obj.transform.position = ((Component)other).gameObject.transform.position;
BC.is2 = true;
}
}
}
private void Update()
{
//IL_0017: 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)
((Component)this).gameObject.transform.position = pos.transform.position;
((Component)this).gameObject.transform.eulerAngles = pos.transform.eulerAngles;
}
}
}
[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;
}
}
}
}
namespace JerryComponent
{
public class G11Handle : FVRInteractiveObject
{
public Transform RotPiece;
public AudioEvent HandleCrank;
[NonSerialized]
public float m_curRot;
public Transform FlapPiece;
[NonSerialized]
public Vector3 lastHandForward = Vector3.zero;
public override void BeginInteraction(FVRViveHand hand)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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)
((FVRInteractiveObject)this).BeginInteraction(hand);
SetFlapState(isOut: true);
lastHandForward = Vector3.ProjectOnPlane(((HandInput)(ref base.m_hand.Input)).Up, ((Component)this).transform.right);
}
public override void EndInteraction(FVRViveHand hand)
{
((FVRInteractiveObject)this).EndInteraction(hand);
}
public void SetFlapState(bool isOut)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (isOut)
{
FlapPiece.localEulerAngles = new Vector3(0f, 90f, -90f);
}
else
{
FlapPiece.localEulerAngles = new Vector3(0f, 90f, 0f);
}
}
public override void FVRFixedUpdate()
{
//IL_001f: 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_002f: 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_0039: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_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_005c: 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_0066: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: 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_016c: 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)
if (((FVRInteractiveObject)this).IsHeld)
{
float curRot = m_curRot;
Vector3 val = Vector3.ProjectOnPlane(((HandInput)(ref base.m_hand.Input)).Up, -((Component)this).transform.right);
Vector3 val2 = Vector3.ProjectOnPlane(lastHandForward, -((Component)this).transform.right);
float num = Mathf.Atan2(Vector3.Dot(-((Component)this).transform.right, Vector3.Cross(val, val2)), Vector3.Dot(val, val2)) * 57.29578f;
if (num > 0f)
{
m_curRot -= num;
}
if (curRot > -180f && m_curRot <= -180f)
{
SM.PlayCoreSound((FVRPooledAudioType)10, HandleCrank, ((Component)this).transform.position);
}
if (m_curRot <= -360f)
{
RotPiece.localEulerAngles = new Vector3(0f, 0f, 0f);
SM.PlayCoreSound((FVRPooledAudioType)10, HandleCrank, ((Component)this).transform.position);
m_curRot = 0f;
SetFlapState(isOut: false);
base.m_hand.EndInteractionIfHeld((FVRInteractiveObject)(object)this);
((FVRInteractiveObject)this).ForceBreakInteraction();
}
else
{
RotPiece.localEulerAngles = new Vector3(0f, 0f, m_curRot);
}
lastHandForward = val;
}
((FVRInteractiveObject)this).FVRFixedUpdate();
}
}
public class GM6Barrel : MonoBehaviour
{
public Rigidbody gunrig;
public GameObject barrelRig;
public Mac11_Stock grab;
public GameObject grabtarg;
public GameObject barreltarg;
public ClosedBoltReceiverDustCoverTrigger dustcover;
public WaggleJoint dustcoverJoint;
public AR15HandleSightFlipper barrelLatch;
public Vector2 ZbarrelLimit;
public float rear;
public float fore;
public GameObject snapbarrel;
public ClosedBolt bolt;
public GameObject boltGeo;
public ClosedBoltWeapon gun;
public GameObject boltrot;
public AudioEvent snaptorearaud;
public bool reachedtorear = false;
public bool shot = false;
public GameObject foreexp;
public GameObject rearexp;
public bool pulled = false;
public bool startrecoil = false;
public float recoverspeedbarrel;
public float recoverspeedbolt;
public bool blowback1 = false;
public bool blowback2 = false;
public float mul1 = 1f;
public float mul2 = 1f;
private void OnShotFired(FVRFireArm firearm)
{
if ((Object)(object)firearm == (Object)(object)gun)
{
if (((FVRInteractiveObject)bolt).IsHeld)
{
((FVRInteractiveObject)bolt).ForceBreakInteraction();
}
((FVRInteractiveObject)bolt).IsSimpleInteract = true;
bolt.Speed_Rearward = 0f;
shot = true;
startrecoil = true;
}
}
private void Awake()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired);
}
private void Update()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: 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_008c: 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_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_032f: Unknown result type (might be due to invalid IL or missing references)
//IL_0334: 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_0384: Unknown result type (might be due to invalid IL or missing references)
//IL_0389: Unknown result type (might be due to invalid IL or missing references)
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_0432: Unknown result type (might be due to invalid IL or missing references)
//IL_0437: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: 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_0469: Unknown result type (might be due to invalid IL or missing references)
//IL_0417: Unknown result type (might be due to invalid IL or missing references)
//IL_03df: Unknown result type (might be due to invalid IL or missing references)
//IL_0553: Unknown result type (might be due to invalid IL or missing references)
//IL_056e: Unknown result type (might be due to invalid IL or missing references)
//IL_058e: Unknown result type (might be due to invalid IL or missing references)
//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0768: Unknown result type (might be due to invalid IL or missing references)
//IL_076d: Unknown result type (might be due to invalid IL or missing references)
//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
//IL_06a1: Unknown result type (might be due to invalid IL or missing references)
//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
//IL_0618: Unknown result type (might be due to invalid IL or missing references)
//IL_061d: Unknown result type (might be due to invalid IL or missing references)
//IL_0634: Unknown result type (might be due to invalid IL or missing references)
//IL_08b7: Unknown result type (might be due to invalid IL or missing references)
//IL_08bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0798: Unknown result type (might be due to invalid IL or missing references)
//IL_079d: Unknown result type (might be due to invalid IL or missing references)
//IL_0731: Unknown result type (might be due to invalid IL or missing references)
//IL_0736: Unknown result type (might be due to invalid IL or missing references)
//IL_074c: Unknown result type (might be due to invalid IL or missing references)
//IL_09be: Unknown result type (might be due to invalid IL or missing references)
//IL_09c3: Unknown result type (might be due to invalid IL or missing references)
//IL_07f8: Unknown result type (might be due to invalid IL or missing references)
//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
//IL_07d8: Unknown result type (might be due to invalid IL or missing references)
//IL_08f8: Unknown result type (might be due to invalid IL or missing references)
//IL_08fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0838: Unknown result type (might be due to invalid IL or missing references)
//IL_0944: Unknown result type (might be due to invalid IL or missing references)
//IL_0949: Unknown result type (might be due to invalid IL or missing references)
//IL_0960: Unknown result type (might be due to invalid IL or missing references)
//IL_0878: Unknown result type (might be due to invalid IL or missing references)
if ((int)((FVRPhysicalObject)gun).Size == 3 && (Object)(object)((FVRPhysicalObject)gun).m_quickbeltSlot != (Object)null && ((FVRPhysicalObject)gun).m_isHardnessed)
{
((FVRPhysicalObject)gun).m_isHardnessed = false;
}
if (((FVRInteractiveObject)bolt).IsHeld)
{
boltGeo.gameObject.transform.localPosition = ((Component)bolt).gameObject.transform.localPosition;
if (boltrot.transform.localEulerAngles.y >= 1f && !pulled)
{
barrelRig.gameObject.transform.localPosition = ((Component)bolt).gameObject.transform.localPosition;
}
else if (boltrot.transform.localEulerAngles.y < 1f)
{
pulled = true;
blowback1 = false;
blowback2 = false;
}
}
dustcoverJoint.angleLimitRight = -1f * ((Component)dustcover).gameObject.transform.localEulerAngles.z;
barrelRig.gameObject.transform.localPosition = new Vector3(0f, 0f, barrelRig.gameObject.transform.localPosition.z);
boltGeo.gameObject.transform.localPosition = new Vector3(0f, 0f, boltGeo.gameObject.transform.localPosition.z);
barrelRig.gameObject.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
boltGeo.gameObject.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
if (barrelRig.gameObject.transform.localPosition.z < rear)
{
barrelRig.gameObject.transform.localPosition = new Vector3(0f, 0f, rear);
}
if (barrelRig.gameObject.transform.localPosition.z > fore)
{
pulled = false;
if (mul1 != 1f)
{
if (!((FVRInteractiveObject)bolt).IsHeld)
{
SM.PlayCoreSound((FVRPooledAudioType)41, snaptorearaud, barrelRig.gameObject.transform.position);
}
mul1 = 1f;
}
barrelRig.gameObject.transform.localPosition = new Vector3(0f, 0f, fore);
}
if (boltGeo.gameObject.transform.localPosition.z < rear)
{
boltGeo.gameObject.transform.localPosition = new Vector3(0f, 0f, rear);
}
if (boltGeo.gameObject.transform.localPosition.z > fore)
{
pulled = false;
if (mul2 != 1f)
{
if (!((FVRInteractiveObject)bolt).IsHeld)
{
SM.PlayCoreSound((FVRPooledAudioType)41, snaptorearaud, boltGeo.gameObject.transform.position);
}
mul2 = 1f;
}
boltGeo.gameObject.transform.localPosition = new Vector3(0f, 0f, fore);
}
if (boltGeo.gameObject.transform.localPosition.z >= fore)
{
pulled = false;
}
if (barrelRig.gameObject.transform.localPosition.z < rear + 0.01f && !barrelLatch.m_isLargeAperture)
{
snapbarrel.SetActive(true);
if (((FVRInteractiveObject)grab).IsHeld)
{
((FVRInteractiveObject)grab).ForceBreakInteraction();
((FVRInteractiveObject)grab).IsSimpleInteract = true;
}
((FVRPhysicalObject)gun).Size = (FVRPhysicalObjectSize)2;
barrelRig.gameObject.transform.localPosition = new Vector3(0f, 0f, rear);
if (!dustcover.m_isOpen)
{
dustcover.ToggleDustCoverState();
}
((FVRInteractiveObject)bolt).IsSimpleInteract = true;
}
if (barrelLatch.m_isLargeAperture && !((FVRInteractiveObject)grab).IsHeld)
{
((FVRPhysicalObject)gun).Size = (FVRPhysicalObjectSize)3;
((Component)grab).transform.position = grabtarg.transform.position;
((Component)grab).transform.eulerAngles = grabtarg.transform.eulerAngles;
((FVRInteractiveObject)grab).IsSimpleInteract = false;
((FVRInteractiveObject)bolt).IsSimpleInteract = false;
snapbarrel.SetActive(false);
if (barrelRig.gameObject.transform.localPosition.z < fore)
{
mul1 += Time.deltaTime;
barrelRig.transform.localPosition = new Vector3(0f, 0f, barrelRig.transform.localPosition.z + recoverspeedbarrel * mul1);
}
}
if (((FVRInteractiveObject)grab).IsHeld)
{
if (!dustcover.m_isOpen)
{
dustcover.ToggleDustCoverState();
}
snapbarrel.SetActive(false);
((FVRInteractiveObject)bolt).IsSimpleInteract = false;
barrelRig.gameObject.transform.eulerAngles = barreltarg.transform.eulerAngles;
barrelRig.gameObject.transform.position = barreltarg.transform.position;
}
if (startrecoil && barrelRig.gameObject.transform.localPosition.z > rear)
{
barrelRig.gameObject.transform.localPosition = new Vector3(0f, 0f, barrelRig.gameObject.transform.localPosition.z - recoverspeedbarrel * 25f);
}
if (barrelRig.gameObject.transform.localPosition.z < fore - 0.01f)
{
if (boltGeo.gameObject.transform.localPosition.z > rear + 0.01f)
{
boltGeo.gameObject.transform.localPosition = barrelRig.gameObject.transform.localPosition;
}
else if (boltGeo.gameObject.transform.localPosition.z < rear + 0.01f)
{
boltGeo.gameObject.transform.localPosition = new Vector3(0f, 0f, rear);
if (!reachedtorear && shot)
{
startrecoil = false;
SM.PlayCoreSound((FVRPooledAudioType)41, snaptorearaud, boltGeo.gameObject.transform.position);
reachedtorear = true;
shot = false;
blowback1 = false;
blowback2 = false;
}
}
}
else if (barrelRig.gameObject.transform.localPosition.z >= fore - 0.01f)
{
if (!((FVRInteractiveObject)bolt).IsHeld && boltGeo.gameObject.transform.localPosition.z < fore)
{
mul2 += Time.deltaTime;
boltGeo.transform.localPosition = new Vector3(0f, 0f, boltGeo.transform.localPosition.z + recoverspeedbolt * mul2);
}
if (reachedtorear)
{
if (!((FVRInteractiveObject)bolt).IsHeld)
{
bolt.Speed_Rearward = -100f;
bolt.SnapToRear();
}
reachedtorear = false;
}
}
if (boltGeo.gameObject.transform.localPosition.z >= fore - 0.01f)
{
((FVRInteractiveObject)bolt).IsSimpleInteract = false;
}
}
private void OnDestroy()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
GM.CurrentSceneSettings.ShotFiredEvent -= new ShotFired(OnShotFired);
}
}
public class G50Seeker : MonoBehaviour
{
public QuadcopterController QC;
public AR15HandleSightFlipper trigger;
public GameObject wingrot;
public GameObject explosion;
public GameObject audseek;
public GameObject audfly;
public FVRPhysicalObject main;
public Collider detectcol;
[NonSerialized]
public List<SosigLink> currentAI = new List<SosigLink>();
[NonSerialized]
public Transform nearestAI;
public GameObject lookdir;
public LayerMask lm;
public bool clicked = false;
public bool triggered = true;
public GameObject lookdir2;
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_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_0061: 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_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(tr_self.localEulerAngles.x, tr_self.localEulerAngles.y, 0f);
}
private void OnTriggerStay(Collider other)
{
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Invalid comparison between Unknown and I4
if (!trigger.m_isLargeAperture && !((FVRInteractiveObject)main).m_isHeld && (Object)(object)main.m_quickbeltSlot == (Object)null && ((Object)((Component)other).gameObject).name == "Sosig_Torso" && (Object)(object)((Component)other).gameObject.GetComponent<SosigLink>() != (Object)null && (Object)(object)GM.CurrentPlayerBody != (Object)null && !currentAI.Contains(((Component)other).gameObject.GetComponent<SosigLink>()) && (int)((Component)other).gameObject.GetComponent<SosigLink>().S.BodyState != 3)
{
currentAI.Add(((Component)other).gameObject.GetComponent<SosigLink>());
}
}
private void Update()
{
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_045f: 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_0345: Unknown result type (might be due to invalid IL or missing references)
//IL_034a: Unknown result type (might be due to invalid IL or missing references)
//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
//IL_05b2: Invalid comparison between Unknown and I4
//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
//IL_04dc: 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_05e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0500: Unknown result type (might be due to invalid IL or missing references)
//IL_0519: Unknown result type (might be due to invalid IL or missing references)
//IL_053f: Unknown result type (might be due to invalid IL or missing references)
//IL_054f: Unknown result type (might be due to invalid IL or missing references)
if (((FVRInteractiveObject)main).m_isHeld)
{
if (((FVRInteractiveObject)main).m_hand.Input.TriggerFloat > 0.75f)
{
if (!clicked)
{
triggered = !triggered;
clicked = true;
}
}
else
{
clicked = false;
}
}
else if (!((FVRInteractiveObject)main).m_isHeld)
{
clicked = false;
}
trigger.m_isLargeAperture = triggered;
if ((Object)(object)main == (Object)null)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
if (trigger.m_isLargeAperture || ((FVRInteractiveObject)main).m_isHeld || (Object)(object)main.m_quickbeltSlot != (Object)null)
{
detectcol.enabled = false;
audfly.SetActive(false);
audseek.SetActive(false);
nearestAI = null;
wingrot.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
((Behaviour)QC).enabled = false;
}
if (trigger.m_isLargeAperture || ((FVRInteractiveObject)main).m_isHeld || !((Object)(object)main.m_quickbeltSlot == (Object)null))
{
return;
}
detectcol.enabled = true;
audfly.SetActive(true);
wingrot.transform.localEulerAngles = new Vector3(90f, 0f, 0f);
((Behaviour)QC).enabled = true;
if (currentAI == null || (Object)(object)nearestAI == (Object)null)
{
if ((Object)(object)GM.CurrentPlayerBody != (Object)null)
{
QC.SetFollowTarget(((Component)GM.CurrentPlayerBody.Head).gameObject.transform);
QC.SetTargetHeight(((Component)GM.CurrentPlayerBody.Head).gameObject.transform.position.y + 0.25f);
}
QC.obstacleCheckDistanceY = 1f;
QC.followDistance = 1f;
audseek.SetActive(false);
}
if ((Object)(object)nearestAI != (Object)null)
{
AxisLookAt(lookdir.transform, ((Component)nearestAI).gameObject.transform.position, Vector3.forward);
RaycastHit val = default(RaycastHit);
if (Physics.Raycast(lookdir2.transform.position, lookdir2.transform.forward, ref val, 25f, LayerMask.op_Implicit(lm)))
{
if ((Object)(object)((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponentInParent<SosigLink>() != (Object)null)
{
audseek.SetActive(true);
QC.SetFollowTarget(((Component)nearestAI).gameObject.transform);
QC.SetTargetHeight(((Component)nearestAI).gameObject.transform.position.y);
QC.followDistance = 0f;
QC.obstacleCheckDistanceY = 0.1f;
}
else
{
if ((Object)(object)GM.CurrentPlayerBody != (Object)null)
{
QC.SetFollowTarget(((Component)GM.CurrentPlayerBody.Head).gameObject.transform);
QC.SetTargetHeight(((Component)GM.CurrentPlayerBody.Head).gameObject.transform.position.y + 0.25f);
}
QC.obstacleCheckDistanceY = 1f;
QC.followDistance = 1f;
audseek.SetActive(false);
}
}
else
{
if ((Object)(object)GM.CurrentPlayerBody != (Object)null)
{
QC.SetFollowTarget(((Component)GM.CurrentPlayerBody.Head).gameObject.transform);
QC.SetTargetHeight(((Component)GM.CurrentPlayerBody.Head).gameObject.transform.position.y + 0.25f);
}
QC.obstacleCheckDistanceY = 1f;
QC.followDistance = 1f;
audseek.SetActive(false);
}
if ((Object)(object)GM.CurrentPlayerBody != (Object)null && Vector3.Distance(((Component)main).gameObject.transform.position, ((Component)nearestAI).gameObject.transform.position) <= 1f && Vector3.Distance(((Component)main).gameObject.transform.position, ((Component)GM.CurrentPlayerBody.Head).gameObject.transform.position) >= 2.5f)
{
Object.Instantiate<GameObject>(explosion, ((Component)this).gameObject.transform.position, ((Component)this).gameObject.transform.rotation);
Object.Destroy((Object)(object)((Component)main).gameObject);
}
}
if (currentAI == null)
{
return;
}
for (int i = 0; i < currentAI.Count; i++)
{
if ((Object)(object)currentAI[i] == (Object)null || (int)currentAI[i].S.BodyState == 3 || Vector3.Distance(((Component)main).gameObject.transform.position, ((Component)currentAI[i]).gameObject.transform.position) > 25f)
{
currentAI.Remove(currentAI[i]);
}
}
nearestAI = GetNearestGameObject(((Component)this).gameObject.transform, currentAI);
}
public Transform GetNearestGameObject(Transform player, List<SosigLink> objects)
{
//IL_0044: 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_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)
Transform val = null;
if (objects == null || (Object)(object)val == (Object)null)
{
}
if (objects.Count > 0 && (Object)(object)objects[0] != (Object)null)
{
val = ((Component)objects[0]).transform;
float num = Vector3.Distance(player.position, ((Component)objects[0]).transform.position);
for (int i = 1; i < objects.Count; i++)
{
float num2 = Vector3.Distance(player.position, ((Component)objects[i]).transform.position);
if (num > num2)
{
num = num2;
val = ((Component)objects[i]).transform;
}
}
}
return val;
}
}
[RequireComponent(typeof(Rigidbody))]
public class QuadcopterController : MonoBehaviour
{
[Header("悬停设置")]
public float targetHeight = 1.8f;
public float heightTolerance = 0.1f;
public float maxLiftForce = 50f;
[Header("PID控制器参数")]
public float P_Gain = 5f;
public float I_Gain = 0.5f;
public float D_Gain = 2f;
[Header("避障设置")]
public LayerMask obstacleMask = LayerMask.op_Implicit(-1);
public float obstacleCheckDistance = 3f;
public float avoidanceForce = 15f;
public float obstacleCheckDistanceY = 1f;
public float sideRayOffset = 0.5f;
[Header("跟随设置")]
public Transform followTarget;
public float followDistance = 3f;
public float followForce = 10f;
public float rotationSpeed = 5f;
[Header("稳定设置")]
public float stability = 10f;
public float stabilitySpeed = 100f;
private Rigidbody rb;
private float heightErrorIntegral = 0f;
private float previousHeightError = 0f;
private Vector3 avoidanceVector = Vector3.zero;
private float horizontalErrorIntegralX = 0f;
private float horizontalErrorIntegralZ = 0f;
private Vector3 previousHorizontalError = Vector3.zero;
private void Start()
{
rb = ((Component)this).GetComponent<Rigidbody>();
rb.drag = 1f;
rb.angularDrag = 5f;
rb.useGravity = true;
if ((Object)(object)followTarget == (Object)null)
{
((MonoBehaviour)this).StartCoroutine(HoverInPlace());
}
}
private void FixedUpdate()
{
AvoidObstacles();
ControlHeight();
FollowTarget();
StabilizeRotation();
}
private void ControlHeight()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
float y = ((Component)this).transform.position.y;
float num = targetHeight - y;
heightErrorIntegral += num * Time.fixedDeltaTime;
float num2 = (num - previousHeightError) / Time.fixedDeltaTime;
previousHeightError = num;
float num3 = num * P_Gain + heightErrorIntegral * I_Gain + num2 * D_Gain;
num3 = Mathf.Clamp(num3, 0f - maxLiftForce, maxLiftForce);
Vector3 val = Vector3.up * (num3 + Mathf.Abs(Physics.gravity.y) * rb.mass);
rb.AddForce(val);
if (Mathf.Abs(num) < heightTolerance)
{
heightErrorIntegral *= 0.9f;
}
}
private void AvoidObstacles()
{
//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_001f: 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_0036: 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_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_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: 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_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: 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_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_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: 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_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
avoidanceVector = Vector3.zero;
Vector3[] array = (Vector3[])(object)new Vector3[7]
{
((Component)this).transform.forward,
-((Component)this).transform.forward,
((Component)this).transform.right,
-((Component)this).transform.right,
((Component)this).transform.forward + ((Component)this).transform.right,
((Component)this).transform.forward - ((Component)this).transform.right,
Vector3.up
};
Vector3[] array2 = array;
RaycastHit val2 = default(RaycastHit);
foreach (Vector3 val in array2)
{
if (Physics.Raycast(((Component)this).transform.position, val, ref val2, obstacleCheckDistance, LayerMask.op_Implicit(obstacleMask)))
{
Vector3 val3 = ((Component)this).transform.position - ((RaycastHit)(ref val2)).point;
Vector3 normalized = ((Vector3)(ref val3)).normalized;
float num = 1f - ((RaycastHit)(ref val2)).distance / obstacleCheckDistance;
avoidanceVector += normalized * avoidanceForce * num;
Debug.DrawLine(((Component)this).transform.position, ((RaycastHit)(ref val2)).point, Color.red);
}
else
{
Debug.DrawRay(((Component)this).transform.position, val * obstacleCheckDistance, Color.green);
}
}
RaycastHit val4 = default(RaycastHit);
if (Physics.Raycast(((Component)this).transform.position, Vector3.down, ref val4, obstacleCheckDistanceY, LayerMask.op_Implicit(obstacleMask)))
{
Vector3 val5 = ((Component)this).transform.position - ((RaycastHit)(ref val4)).point;
Vector3 normalized2 = ((Vector3)(ref val5)).normalized;
float num2 = 1f - ((RaycastHit)(ref val4)).distance / obstacleCheckDistance;
avoidanceVector += normalized2 * avoidanceForce * num2;
Debug.DrawLine(((Component)this).transform.position, ((RaycastHit)(ref val4)).point, Color.red);
}
else
{
Debug.DrawRay(((Component)this).transform.position, Vector3.down * obstacleCheckDistance, Color.green);
}
if (avoidanceVector != Vector3.zero)
{
rb.AddForce(avoidanceVector);
}
}
private v