using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using H3VRUtils;
using HarmonyLib;
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 ShermanJumbo
{
public class ChamberDependentParticlesAndSounds : MonoBehaviour
{
public FVRFireArmChamber ChamberToRead;
public ParticleSystem ParticlesToEnable;
public AudioSource SoundsToEnable;
private void Update()
{
if (ChamberToRead.IsFull)
{
ParticlesToEnable.Play();
SoundsToEnable.Play();
}
else
{
ParticlesToEnable.Stop();
SoundsToEnable.Stop();
}
}
}
public class EnableDisableIfChamberFull : MonoBehaviour
{
public GameObject TurnsOnIfChamberFull;
public FVRFireArmChamber Chamber;
public bool ConsiderFullEvenIfRoundFired;
private void Update()
{
if (ConsiderFullEvenIfRoundFired)
{
if (Chamber.IsFull)
{
TurnsOnIfChamberFull.gameObject.SetActive(true);
}
}
else if (Chamber.IsFull && !Chamber.IsSpent)
{
TurnsOnIfChamberFull.gameObject.SetActive(true);
}
else
{
TurnsOnIfChamberFull.gameObject.SetActive(false);
}
}
}
}
namespace ShermanJumbo.Pixel_Gun_3D_Mega_Pack
{
[BepInPlugin("ShermanJumbo.Pixel_Gun_3D_Mega_Pack", "Pixel_Gun_3D_Mega_Pack", "1.2.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class Pixel_Gun_3D_Mega_PackPlugin : BaseUnityPlugin
{
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
internal static ManualLogSource Logger;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
LoadAssets();
}
private void LoadAssets()
{
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "ShermanJumbo.Pixel_Gun_3D_Mega_Pack");
OtherLoader.RegisterDirectLoad(BasePath, "ShermanJumbo.Pixel_Gun_3D_Mega_Pack", "", "shermanjumbo_pg3dammo", "", "");
OtherLoader.RegisterDirectLoad(BasePath, "ShermanJumbo.Pixel_Gun_3D_Mega_Pack", "", "", "shermanjumbo_pg3dattachments", "");
OtherLoader.RegisterDirectLoad(BasePath, "ShermanJumbo.Pixel_Gun_3D_Mega_Pack", "", "", "", "shermanjumbo_pg3dheavy,shermanjumbo_pg3drifles,shermanjumbo_pg3dspecial");
OtherLoader.RegisterDirectLoad(BasePath, "ShermanJumbo.Pixel_Gun_3D_Mega_Pack", "", "", "shermanjumbo_pg3dubgls,shermanjumbo_pg3dmelee", "");
OtherLoader.RegisterDirectLoad(BasePath, "ShermanJumbo.Pixel_Gun_3D_Mega_Pack", "", "", "", "shermanjumbo_pg3dpistols,shermanjumbo_pg3dsmgs,shermanjumbo_pg3dshotguns,shermanjumbo_pg3dsnipers");
OtherLoader.RegisterDirectLoad(BasePath, "ShermanJumbo.Pixel_Gun_3D_Mega_Pack", "", "", "shermanjumbo_pg3dsosig,shermanjumbo_pg3dgadgets", "");
}
}
}
namespace ShermanJumbo
{
public class GR8RecoillessRifle : FVRFireArm
{
public FVRFireArmChamber Chamber;
public GR8ShellInsertEject ShellInsertEject;
public GR8TailLatch TailLatch;
private float m_curZ;
private float m_tarZ;
public float ZThreshold = 0.01f;
public Transform Trigger;
public float TriggerFiringThreshold = 0.8f;
public float TriggerResetThreshold = 0.4f;
public float Trigger_ForwardValue;
public float Trigger_RearwardValue;
private float m_triggerFloat;
private float m_lastTriggerFloat;
private bool m_hasTriggerReset;
public AudioEvent AudEvent_BackSound;
public Transform COM;
public override void Awake()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
((FVRFireArm)this).Awake();
base.FChambers.Add(Chamber);
((FVRPhysicalObject)this).RootRigidbody.centerOfMass = COM.localPosition;
}
public void FixCOM()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
((FVRPhysicalObject)this).RootRigidbody.centerOfMass = COM.localPosition;
}
public override void FVRUpdate()
{
((FVRFireArm)this).FVRUpdate();
if (TailLatch.LState == GR8TailLatch.CGLatchState.Open)
{
Chamber.IsAccessible = true;
}
else
{
Chamber.IsAccessible = false;
}
if (Mathf.Abs(m_triggerFloat - m_lastTriggerFloat) > 0.0001f)
{
m_lastTriggerFloat = m_triggerFloat;
((FVRPhysicalObject)this).SetAnimatedComponent(Trigger, Mathf.Lerp(Trigger_ForwardValue, Trigger_RearwardValue, m_triggerFloat), (InterpStyle)1, (Axis)0);
}
}
public override void UpdateInteraction(FVRViveHand hand)
{
((FVRPhysicalObject)this).UpdateInteraction(hand);
if (((FVRPhysicalObject)this).IsAltHeld)
{
m_triggerFloat = 0f;
return;
}
if (((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin)
{
m_triggerFloat = hand.Input.TriggerFloat;
}
else
{
m_triggerFloat = 0f;
}
if (!m_hasTriggerReset && m_triggerFloat <= TriggerResetThreshold)
{
m_hasTriggerReset = true;
((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)16, 1f);
}
if (((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin && m_triggerFloat >= TriggerFiringThreshold && TailLatch.LState == GR8TailLatch.CGLatchState.Closed && m_hasTriggerReset)
{
m_hasTriggerReset = false;
TryToFire();
}
}
private void TryToFire()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 1f);
if (Chamber.Fire())
{
((FVRFireArm)this).PlayAudioGunShot(Chamber.GetRound(), GM.CurrentPlayerBody.GetCurrentSoundEnvironment(), 1f);
((FVRFireArm)this).Fire(Chamber, ((FVRFireArm)this).GetMuzzle(), true, 1f, -1f);
((FVRFireArm)this).FireMuzzleSmoke();
SM.PlayCoreSound((FVRPooledAudioType)5, AudEvent_BackSound, ((Component)TailLatch).transform.position);
bool flag = ((FVRFireArm)this).IsTwoHandStabilized();
bool flag2 = (Object)(object)((FVRPhysicalObject)this).AltGrip != (Object)null;
bool flag3 = ((FVRFireArm)this).IsShoulderStabilized();
((FVRFireArm)this).Recoil(flag, flag2, flag3, (FVRFireArmRecoilProfile)null, 1f);
}
}
}
public class GR8ShellInsertEject : FVRInteractiveObject
{
public enum ChamberSlideState
{
In,
Middle,
Out
}
public GR8RecoillessRifle CG;
public AudioEvent AudEvent_ShellInStart;
public AudioEvent AudEvent_ShellIn;
public AudioEvent AudEvent_ShellOutStart;
public AudioEvent AudEvent_ShellOut;
public Transform ChamberPoint_Back;
public Transform ChamberPoint_Forward;
public Collider Col;
public ChamberSlideState CSState = ChamberSlideState.Out;
private float m_curZ;
private float m_tarZ;
public float ZThreshold = 0.02f;
private float m_timeHeld;
public override void Awake()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).Awake();
m_curZ = ChamberPoint_Back.localPosition.z;
m_tarZ = m_curZ;
}
public override bool IsInteractable()
{
return CG.Chamber.IsFull && CG.TailLatch.LState == GR8TailLatch.CGLatchState.Open;
}
public override void UpdateInteraction(FVRViveHand hand)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).UpdateInteraction(hand);
float tarZ = Mathf.Clamp(((Component)CG).transform.InverseTransformPoint(((HandInput)(ref hand.Input)).Pos).z, ChamberPoint_Back.localPosition.z, ChamberPoint_Forward.localPosition.z);
m_tarZ = tarZ;
}
public override void EndInteraction(FVRViveHand hand)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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_0062: 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_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)
((FVRInteractiveObject)this).EndInteraction(hand);
float num = Mathf.Abs(m_curZ - ChamberPoint_Back.localPosition.z);
float num2 = Mathf.Abs(m_curZ - ChamberPoint_Forward.localPosition.z);
if (num < ZThreshold * 2f)
{
m_tarZ = ChamberPoint_Back.localPosition.z;
}
else if (num2 < ZThreshold * 2f)
{
m_tarZ = ChamberPoint_Forward.localPosition.z;
}
}
public override void BeginInteraction(FVRViveHand hand)
{
((FVRInteractiveObject)this).BeginInteraction(hand);
m_timeHeld = 0f;
}
public override void FVRUpdate()
{
//IL_0078: 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_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_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: 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_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).FVRUpdate();
m_timeHeld += Time.deltaTime;
if (!(Mathf.Abs(m_curZ - m_tarZ) > 0.001f))
{
return;
}
m_curZ = Mathf.MoveTowards(m_curZ, m_tarZ, Time.deltaTime * 1f);
((Component)CG.Chamber).transform.localPosition = new Vector3(((Component)CG.Chamber).transform.localPosition.x, ((Component)CG.Chamber).transform.localPosition.y, m_curZ);
float num = Mathf.Abs(m_curZ - ChamberPoint_Back.localPosition.z);
float num2 = Mathf.Abs(m_curZ - ChamberPoint_Forward.localPosition.z);
ChamberSlideState cSState = CSState;
if (num < ZThreshold)
{
CSState = ChamberSlideState.Out;
}
else if (num2 < ZThreshold)
{
CSState = ChamberSlideState.In;
}
else
{
CSState = ChamberSlideState.Middle;
}
if (CSState == ChamberSlideState.Out && cSState != ChamberSlideState.Out)
{
((FVRFireArm)CG).PlayAudioAsHandling(AudEvent_ShellOut, ((Component)this).transform.position);
if (m_timeHeld > 0.2f)
{
FVRFireArmRound val = CG.Chamber.EjectRound(((Component)ChamberPoint_Back).transform.position, ChamberPoint_Back.forward * 0.1f, Vector3.zero, false);
if (((FVRInteractiveObject)this).IsHeld)
{
FVRViveHand hand = base.m_hand;
hand.ForceSetInteractable((FVRInteractiveObject)(object)val);
((FVRInteractiveObject)val).BeginInteraction(hand);
}
CG.FixCOM();
}
}
else if (CSState == ChamberSlideState.In && cSState != 0)
{
((FVRFireArm)CG).PlayAudioAsHandling(AudEvent_ShellIn, ((Component)this).transform.position);
((FVRInteractiveObject)this).ForceBreakInteraction();
CG.FixCOM();
}
else if (CSState == ChamberSlideState.Middle && cSState == ChamberSlideState.In)
{
((FVRFireArm)CG).PlayAudioAsHandling(AudEvent_ShellOutStart, ((Component)this).transform.position);
}
else if (CSState == ChamberSlideState.Middle && cSState == ChamberSlideState.Out)
{
((FVRFireArm)CG).PlayAudioAsHandling(AudEvent_ShellInStart, ((Component)this).transform.position);
}
}
}
public class GR8TailLatch : FVRInteractiveObject
{
public enum CGLatchType
{
Main,
Lock
}
public enum CGLatchState
{
Closed,
Middle,
Open
}
public GR8RecoillessRifle CG;
public CGLatchType LType;
public CGLatchState LState;
public float RotMin;
public float RotMax;
public bool IsMinOpen;
public AudioEvent AudEvent_Open;
public AudioEvent AudEvent_Close;
public Transform BaseZeroDir;
private float m_curRot;
private float m_tarRot;
public bool DisablesUseWhenNotInGivenState = true;
public GR8TailLatch RestrictingLatch;
public CGLatchState RequiredState = CGLatchState.Open;
public bool DoesPartialChamberingBlock;
public bool IsOpen()
{
return LState == CGLatchState.Open;
}
public override bool IsInteractable()
{
return (!DoesPartialChamberingBlock || !CG.Chamber.IsFull || CG.ShellInsertEject.CSState == GR8ShellInsertEject.ChamberSlideState.In) && (!DisablesUseWhenNotInGivenState || RestrictingLatch.LState == RequiredState) && ((FVRInteractiveObject)this).IsInteractable();
}
public override void UpdateInteraction(FVRViveHand hand)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_0035: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).UpdateInteraction(hand);
Vector3 val = ((HandInput)(ref hand.Input)).Pos - ((Component)this).transform.position;
val = Vector3.ProjectOnPlane(val, BaseZeroDir.up);
float signedAngle = GetSignedAngle(val, BaseZeroDir.forward, BaseZeroDir.up);
signedAngle = Mathf.Clamp(signedAngle, RotMin, RotMax);
m_tarRot = signedAngle;
}
public override void EndInteraction(FVRViveHand hand)
{
((FVRInteractiveObject)this).EndInteraction(hand);
float num = Mathf.Abs(m_curRot - RotMin);
float num2 = Mathf.Abs(m_curRot - RotMax);
if (num < num2)
{
m_tarRot = RotMin;
}
else
{
m_tarRot = RotMax;
}
}
public override void FVRUpdate()
{
//IL_005c: 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_015f: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).FVRUpdate();
if (!(Mathf.Abs(m_curRot - m_tarRot) > 0.001f))
{
return;
}
m_curRot = Mathf.MoveTowards(m_curRot, m_tarRot, Time.deltaTime * 900f);
((Component)this).transform.localEulerAngles = new Vector3(0f, m_curRot, 0f);
float num = Mathf.Abs(m_curRot - RotMin);
float num2 = Mathf.Abs(m_curRot - RotMax);
CGLatchState lState = LState;
if (num < 1f)
{
if (IsMinOpen)
{
LState = CGLatchState.Open;
}
else
{
LState = CGLatchState.Closed;
}
}
else if (num2 < 1f)
{
if (IsMinOpen)
{
LState = CGLatchState.Closed;
}
else
{
LState = CGLatchState.Open;
}
}
else
{
LState = CGLatchState.Middle;
}
if (LState == CGLatchState.Closed && lState != 0)
{
((FVRFireArm)CG).PlayAudioAsHandling(AudEvent_Close, ((Component)this).transform.position);
}
else if (LState == CGLatchState.Open && lState != CGLatchState.Open)
{
((FVRFireArm)CG).PlayAudioAsHandling(AudEvent_Open, ((Component)this).transform.position);
}
}
public float GetSignedAngle(Vector3 from, Vector3 to, Vector3 axis)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//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_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = Vector3.ProjectOnPlane(from, axis);
from = ((Vector3)(ref val)).normalized;
Vector3 val2 = Vector3.Cross(axis, to);
float num = Mathf.Sign(Vector3.Dot(from, val2));
float num2 = Vector3.Angle(from, to);
return num2 * num;
}
}
public class PhysicalMagazineReleasePokeableButton : FVRInteractiveObject
{
public FVRFireArm Gun;
public void Poke(FVRViveHand hand)
{
if ((Object)(object)((FVRInteractiveObject)Gun).m_hand == (Object)null || (Object)(object)hand != (Object)(object)((FVRInteractiveObject)Gun).m_hand)
{
Gun.EjectMag(false);
}
((FVRInteractiveObject)this).Poke(hand);
}
}
public class PlayAudioEventOnAwakeConfigurableDelay : MonoBehaviour
{
public AudioEvent AudioEvent;
public bool TravelsAtSpeedOfSound;
public bool HasDelay;
public float LengthOfDelay;
public FVRPooledAudioType Type = (FVRPooledAudioType)11;
private void Start()
{
//IL_000e: 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_0089: 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_0046: 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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
if (HasDelay)
{
SM.PlayCoreSoundDelayed(Type, AudioEvent, ((Component)this).transform.position, LengthOfDelay);
}
else if (TravelsAtSpeedOfSound)
{
float num = Vector3.Distance(GM.CurrentPlayerRoot.position, ((Component)this).transform.position);
float num2 = num / 343f;
SM.PlayCoreSoundDelayed(Type, AudioEvent, ((Component)this).transform.position, num2);
}
else
{
SM.PlayCoreSound(Type, AudioEvent, ((Component)this).transform.position);
}
}
}
public class ProjectileModeSwitchWithSounds : MonoBehaviour
{
public enum ProjMode
{
FirstMode,
SecondMode
}
public FVRFireArmRound ParentRound;
[Header("Mode Control")]
public List<string> ModeName;
public List<FireArmRoundClass> ModeClass;
public List<FVRObject> AltObjWrapper;
public ProjMode CurrentMode = ProjMode.FirstMode;
public FVRPooledAudioType Type = (FVRPooledAudioType)11;
public AudioEvent AudioEvent;
[Header("UI Display")]
public GameObject Canvas;
public Text DisplayText;
public void Update()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
FVRViveHand hand = ((FVRInteractiveObject)ParentRound).m_hand;
if ((Object)(object)hand != (Object)null)
{
if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.right) < 45f)
{
SwapMode();
}
if (hand.IsInStreamlinedMode && hand.Input.BYButtonDown)
{
SwapMode();
}
Canvas.gameObject.SetActive(true);
}
else
{
Canvas.gameObject.SetActive(false);
}
}
public void SwapMode()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
SM.PlayCoreSound(Type, AudioEvent, ((Component)this).transform.position);
if (CurrentMode == ProjMode.FirstMode)
{
CurrentMode = ProjMode.SecondMode;
}
else
{
CurrentMode = ProjMode.FirstMode;
}
UpdateMenu();
}
public void UpdateMenu()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)DisplayText != (Object)null)
{
DisplayText.text = ModeName[(int)CurrentMode];
}
ParentRound.RoundClass = ModeClass[(int)CurrentMode];
((FVRPhysicalObject)ParentRound).ObjectWrapper = AltObjWrapper[(int)CurrentMode];
}
}
}
public class CuttableMesh
{
private MeshRenderer inputMeshRenderer;
private bool hasUvs;
private bool hasUv1s;
private bool hasColours;
private List<CuttableSubMesh> subMeshes;
public CuttableMesh(Mesh inputMesh)
{
Init(inputMesh, ((Object)inputMesh).name);
}
public CuttableMesh(MeshRenderer input)
{
inputMeshRenderer = input;
MeshFilter component = ((Component)input).GetComponent<MeshFilter>();
Mesh sharedMesh = component.sharedMesh;
Init(sharedMesh, ((Object)input).name);
}
public CuttableMesh(CuttableMesh inputMesh, List<CuttableSubMesh> newSubMeshes)
{
inputMeshRenderer = inputMesh.inputMeshRenderer;
hasUvs = inputMesh.hasUvs;
hasUv1s = inputMesh.hasUv1s;
hasColours = inputMesh.hasColours;
subMeshes = new List<CuttableSubMesh>();
subMeshes.AddRange(newSubMeshes);
}
private void Init(Mesh inputMesh, string debugName)
{
subMeshes = new List<CuttableSubMesh>();
if (inputMesh.isReadable)
{
Vector3[] vertices = inputMesh.vertices;
Vector3[] normals = inputMesh.normals;
Vector2[] uv = inputMesh.uv;
Vector2[] uv2 = inputMesh.uv2;
Color32[] colors = inputMesh.colors32;
hasUvs = uv != null && uv.Length > 0;
hasUv1s = uv2 != null && uv2.Length > 0;
hasColours = colors != null && colors.Length > 0;
for (int i = 0; i < inputMesh.subMeshCount; i++)
{
int[] indices = inputMesh.GetIndices(i);
CuttableSubMesh item = new CuttableSubMesh(indices, vertices, normals, colors, uv, uv2);
subMeshes.Add(item);
}
}
else
{
Debug.LogError((object)("CuttableMesh's input mesh is not readable: " + debugName), (Object)(object)inputMesh);
}
}
public void Add(CuttableMesh other)
{
if (subMeshes.Count != other.subMeshes.Count)
{
throw new Exception("Mismatched submesh count");
}
for (int i = 0; i < subMeshes.Count; i++)
{
subMeshes[i].Add(other.subMeshes[i]);
}
}
public int NumSubMeshes()
{
return subMeshes.Count;
}
public bool HasUvs()
{
return hasUvs;
}
public bool HasColours()
{
return hasColours;
}
public List<CuttableSubMesh> GetSubMeshes()
{
return subMeshes;
}
public CuttableSubMesh GetSubMesh(int index)
{
return subMeshes[index];
}
public Transform GetTransform()
{
if ((Object)(object)inputMeshRenderer != (Object)null)
{
return ((Component)inputMeshRenderer).transform;
}
return null;
}
public MeshRenderer ConvertToRenderer(string newObjectName)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_003d: 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_005d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
Mesh val = CreateMesh();
if (val.vertexCount == 0)
{
return null;
}
GameObject val2 = new GameObject(newObjectName);
val2.transform.SetParent(((Component)inputMeshRenderer).transform);
val2.transform.localPosition = Vector3.zero;
val2.transform.localRotation = Quaternion.identity;
val2.transform.localScale = Vector3.one;
MeshFilter val3 = val2.AddComponent<MeshFilter>();
val3.mesh = val;
MeshRenderer val4 = val2.AddComponent<MeshRenderer>();
((Renderer)val4).shadowCastingMode = ((Renderer)inputMeshRenderer).shadowCastingMode;
((Renderer)val4).reflectionProbeUsage = ((Renderer)inputMeshRenderer).reflectionProbeUsage;
((Renderer)val4).lightProbeUsage = ((Renderer)inputMeshRenderer).lightProbeUsage;
((Renderer)val4).sharedMaterials = ((Renderer)inputMeshRenderer).sharedMaterials;
return val4;
}
public Mesh CreateMesh()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
Mesh val = new Mesh();
int num = 0;
for (int i = 0; i < subMeshes.Count; i++)
{
num += subMeshes[i].NumIndices();
}
List<Vector3> list = new List<Vector3>();
List<Vector3> list2 = new List<Vector3>();
List<Color32> list3 = ((!hasColours) ? null : new List<Color32>());
List<Vector2> list4 = ((!hasUvs) ? null : new List<Vector2>());
List<Vector2> list5 = ((!hasUv1s) ? null : new List<Vector2>());
List<int> list6 = new List<int>();
foreach (CuttableSubMesh subMesh in subMeshes)
{
list6.Add(list.Count);
subMesh.AddTo(list, list2, list3, list4, list5);
}
val.vertices = list.ToArray();
val.normals = list2.ToArray();
val.colors32 = ((!hasColours) ? null : list3.ToArray());
val.uv = ((!hasUvs) ? null : list4.ToArray());
val.uv2 = ((!hasUv1s) ? null : list5.ToArray());
val.subMeshCount = subMeshes.Count;
for (int j = 0; j < subMeshes.Count; j++)
{
CuttableSubMesh cuttableSubMesh = subMeshes[j];
int num2 = list6[j];
int[] array = cuttableSubMesh.GenIndices();
for (int k = 0; k < array.Length; k++)
{
array[k] += num2;
}
val.SetTriangles(array, j, true);
}
return val;
}
}
public class CuttableSubMesh
{
private List<Vector3> vertices;
private List<Vector3> normals;
private List<Color32> colours;
private List<Vector2> uvs;
private List<Vector2> uv1s;
public CuttableSubMesh(bool hasNormals, bool hasColours, bool hasUvs, bool hasUv1)
{
vertices = new List<Vector3>();
if (hasNormals)
{
normals = new List<Vector3>();
}
if (hasColours)
{
colours = new List<Color32>();
}
if (hasUvs)
{
uvs = new List<Vector2>();
}
if (hasUv1)
{
uv1s = new List<Vector2>();
}
}
public CuttableSubMesh(int[] indices, Vector3[] inputVertices, Vector3[] inputNormals, Color32[] inputColours, Vector2[] inputUvs, Vector2[] inputUv1)
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: 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)
vertices = new List<Vector3>();
if (inputNormals != null && inputNormals.Length > 0)
{
normals = new List<Vector3>();
}
if (inputColours != null && inputColours.Length > 0)
{
colours = new List<Color32>();
}
if (inputUvs != null && inputUvs.Length > 0)
{
uvs = new List<Vector2>();
}
if (inputUv1 != null && inputUv1.Length > 0)
{
uv1s = new List<Vector2>();
}
foreach (int num in indices)
{
vertices.Add(inputVertices[num]);
if (normals != null)
{
normals.Add(inputNormals[num]);
}
if (colours != null)
{
colours.Add(inputColours[num]);
}
if (uvs != null)
{
uvs.Add(inputUvs[num]);
}
if (uv1s != null)
{
uv1s.Add(inputUv1[num]);
}
}
}
public void Add(CuttableSubMesh other)
{
for (int i = 0; i < other.vertices.Count; i++)
{
CopyVertex(i, other);
}
}
public int NumVertices()
{
return vertices.Count;
}
public Vector3 GetVertex(int index)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
return vertices[index];
}
public bool HasNormals()
{
return normals != null;
}
public bool HasColours()
{
return colours != null;
}
public bool HasUvs()
{
return uvs != null;
}
public bool HasUv1()
{
return uv1s != null;
}
public void CopyVertex(int srcIndex, CuttableSubMesh srcMesh)
{
//IL_000e: 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_0052: 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_0096: Unknown result type (might be due to invalid IL or missing references)
vertices.Add(srcMesh.vertices[srcIndex]);
if (normals != null)
{
normals.Add(srcMesh.normals[srcIndex]);
}
if (colours != null)
{
colours.Add(srcMesh.colours[srcIndex]);
}
if (uvs != null)
{
uvs.Add(srcMesh.uvs[srcIndex]);
}
if (uv1s != null)
{
uv1s.Add(srcMesh.uv1s[srcIndex]);
}
}
public void AddInterpolatedVertex(int i0, int i1, float weight, CuttableSubMesh srcMesh)
{
//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)
//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_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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_003f: 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_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_005a: 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_008a: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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_00e9: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
Vector3 vertex = srcMesh.GetVertex(i0);
Vector3 vertex2 = srcMesh.GetVertex(i1);
vertices.Add(Vector3.Lerp(vertex, vertex2, weight));
if (normals != null)
{
List<Vector3> list = normals;
Vector3 val = Vector3.Lerp(srcMesh.normals[i0], srcMesh.normals[i1], weight);
list.Add(((Vector3)(ref val)).normalized);
}
if (colours != null)
{
colours.Add(Color32.Lerp(srcMesh.colours[i0], srcMesh.colours[i1], weight));
}
if (uvs != null)
{
uvs.Add(Vector2.Lerp(srcMesh.uvs[i0], srcMesh.uvs[i1], weight));
}
if (uv1s != null)
{
uv1s.Add(Vector2.Lerp(srcMesh.uv1s[i0], srcMesh.uv1s[i1], weight));
}
}
public void AddTo(List<Vector3> destVertices, List<Vector3> destNormals, List<Color32> destColours, List<Vector2> destUvs, List<Vector2> destUv1s)
{
destVertices.AddRange(vertices);
if (normals != null)
{
destNormals.AddRange(normals);
}
if (colours != null)
{
destColours.AddRange(colours);
}
if (uvs != null)
{
destUvs.AddRange(uvs);
}
if (uv1s != null)
{
destUv1s.AddRange(uv1s);
}
}
public int NumIndices()
{
return vertices.Count;
}
public int[] GenIndices()
{
int[] array = new int[vertices.Count];
for (int i = 0; i < array.Length; i++)
{
array[i] = i;
}
return array;
}
}
public enum VertexClassification
{
Front = 1,
Back = 2,
OnPlane = 4
}
public class MeshCutter
{
private CuttableMesh inputMesh;
private List<CuttableSubMesh> outputFrontSubMeshes;
private List<CuttableSubMesh> outputBackSubMeshes;
public void Cut(CuttableMesh input, Plane worldCutPlane)
{
//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_0038: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
inputMesh = input;
outputFrontSubMeshes = new List<CuttableSubMesh>();
outputBackSubMeshes = new List<CuttableSubMesh>();
Transform transform = inputMesh.GetTransform();
Plane cutPlane = default(Plane);
if ((Object)(object)transform != (Object)null)
{
Vector3 val = transform.InverseTransformPoint(ClosestPointOnPlane(worldCutPlane, Vector3.zero));
Vector3 val2 = transform.InverseTransformDirection(((Plane)(ref worldCutPlane)).normal);
((Plane)(ref cutPlane))..ctor(val2, val);
}
else
{
cutPlane = worldCutPlane;
}
foreach (CuttableSubMesh subMesh in input.GetSubMeshes())
{
Cut(subMesh, cutPlane);
}
}
private static Vector3 ClosestPointOnPlane(Plane plane, Vector3 point)
{
//IL_0003: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0021: 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_004b: Unknown result type (might be due to invalid IL or missing references)
float distanceToPoint = ((Plane)(ref plane)).GetDistanceToPoint(point);
if (((Plane)(ref plane)).GetSide(point))
{
return point - ((Plane)(ref plane)).normal * distanceToPoint;
}
return point + ((Plane)(ref plane)).normal * distanceToPoint;
}
public CuttableMesh GetFrontOutput()
{
return new CuttableMesh(inputMesh, outputFrontSubMeshes);
}
public CuttableMesh GetBackOutput()
{
return new CuttableMesh(inputMesh, outputBackSubMeshes);
}
private void Cut(CuttableSubMesh inputSubMesh, Plane cutPlane)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0068: 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_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: 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_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_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_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: 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_02d8: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
bool hasNormals = inputSubMesh.HasNormals();
bool hasColours = inputSubMesh.HasColours();
bool hasUvs = inputSubMesh.HasUvs();
bool hasUv = inputSubMesh.HasUv1();
CuttableSubMesh cuttableSubMesh = new CuttableSubMesh(hasNormals, hasColours, hasUvs, hasUv);
CuttableSubMesh cuttableSubMesh2 = new CuttableSubMesh(hasNormals, hasColours, hasUvs, hasUv);
for (int i = 0; i < inputSubMesh.NumVertices(); i += 3)
{
int num = i;
int num2 = i + 1;
int num3 = i + 2;
Vector3 vertex = inputSubMesh.GetVertex(num);
Vector3 vertex2 = inputSubMesh.GetVertex(num2);
Vector3 vertex3 = inputSubMesh.GetVertex(num3);
VertexClassification vertexClassification = Classify(vertex, cutPlane);
VertexClassification vertexClassification2 = Classify(vertex2, cutPlane);
VertexClassification vertexClassification3 = Classify(vertex3, cutPlane);
int numFront = 0;
int numBehind = 0;
CountSides(vertexClassification, ref numFront, ref numBehind);
CountSides(vertexClassification2, ref numFront, ref numBehind);
CountSides(vertexClassification3, ref numFront, ref numBehind);
if (numFront > 0 && numBehind == 0)
{
KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh);
}
else if (numFront == 0 && numBehind > 0)
{
KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh2);
}
else if (numFront == 2 && numBehind == 1)
{
if (vertexClassification == VertexClassification.Back)
{
SplitA(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh);
}
else if (vertexClassification2 == VertexClassification.Back)
{
SplitA(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh);
}
else
{
SplitA(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh);
}
}
else if (numFront == 1 && numBehind == 2)
{
if (vertexClassification == VertexClassification.Front)
{
SplitA(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
}
else if (vertexClassification2 == VertexClassification.Front)
{
SplitA(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
}
else
{
SplitA(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
}
}
else if (numFront == 1 && numBehind == 1)
{
if (vertexClassification == VertexClassification.OnPlane)
{
if (vertexClassification3 == VertexClassification.Front)
{
SplitB(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
}
else
{
SplitBFlipped(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
}
continue;
}
switch (vertexClassification2)
{
case VertexClassification.OnPlane:
if (vertexClassification == VertexClassification.Front)
{
SplitB(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
}
else
{
SplitBFlipped(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
}
break;
case VertexClassification.Front:
SplitB(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
break;
default:
SplitBFlipped(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
break;
}
}
else if (numFront == 0 && numBehind == 0)
{
Vector3 val = vertex2 - vertex;
Vector3 val2 = vertex3 - vertex;
Vector3 val3 = Vector3.Cross(val, val2);
if (Vector3.Dot(val3, ((Plane)(ref cutPlane)).normal) > 0f)
{
KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh2);
}
else
{
KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh);
}
}
}
outputFrontSubMeshes.Add(cuttableSubMesh);
outputBackSubMeshes.Add(cuttableSubMesh2);
}
private VertexClassification Classify(Vector3 vertex, Plane cutPlane)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(vertex.x, vertex.y, vertex.z);
float distanceToPoint = ((Plane)(ref cutPlane)).GetDistanceToPoint(val);
double num = 9.999999747378752E-06;
if ((double)distanceToPoint > 0.0 - num && (double)distanceToPoint < num)
{
return VertexClassification.OnPlane;
}
if (distanceToPoint > 0f)
{
return VertexClassification.Front;
}
return VertexClassification.Back;
}
private void CountSides(VertexClassification c, ref int numFront, ref int numBehind)
{
switch (c)
{
case VertexClassification.Front:
numFront++;
break;
case VertexClassification.Back:
numBehind++;
break;
}
}
private void KeepTriangle(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, CuttableSubMesh destSubMesh)
{
destSubMesh.CopyVertex(i0, inputSubMesh);
destSubMesh.CopyVertex(i1, inputSubMesh);
destSubMesh.CopyVertex(i2, inputSubMesh);
}
private void SplitA(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh)
{
//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)
//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_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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: 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_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_002c: 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)
Vector3 vertex = inputSubMesh.GetVertex(i0);
Vector3 vertex2 = inputSubMesh.GetVertex(i1);
Vector3 vertex3 = inputSubMesh.GetVertex(i2);
CalcIntersection(vertex, vertex2, cutPlane, out var weight);
CalcIntersection(vertex3, vertex, cutPlane, out var weight2);
frontSubMesh.CopyVertex(i0, inputSubMesh);
frontSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
frontSubMesh.AddInterpolatedVertex(i2, i0, weight2, inputSubMesh);
backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
backSubMesh.CopyVertex(i1, inputSubMesh);
backSubMesh.CopyVertex(i2, inputSubMesh);
backSubMesh.CopyVertex(i2, inputSubMesh);
backSubMesh.AddInterpolatedVertex(i2, i0, weight2, inputSubMesh);
backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
}
private void SplitB(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh)
{
//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)
//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_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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_001a: Unknown result type (might be due to invalid IL or missing references)
Vector3 vertex = inputSubMesh.GetVertex(i0);
Vector3 vertex2 = inputSubMesh.GetVertex(i2);
CalcIntersection(vertex2, vertex, cutPlane, out var weight);
frontSubMesh.CopyVertex(i0, inputSubMesh);
frontSubMesh.CopyVertex(i1, inputSubMesh);
frontSubMesh.AddInterpolatedVertex(i2, i0, weight, inputSubMesh);
backSubMesh.CopyVertex(i1, inputSubMesh);
backSubMesh.CopyVertex(i2, inputSubMesh);
backSubMesh.AddInterpolatedVertex(i2, i0, weight, inputSubMesh);
}
private void SplitBFlipped(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh)
{
//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)
//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_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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_001a: Unknown result type (might be due to invalid IL or missing references)
Vector3 vertex = inputSubMesh.GetVertex(i0);
Vector3 vertex2 = inputSubMesh.GetVertex(i1);
CalcIntersection(vertex, vertex2, cutPlane, out var weight);
frontSubMesh.CopyVertex(i0, inputSubMesh);
frontSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
frontSubMesh.CopyVertex(i2, inputSubMesh);
backSubMesh.CopyVertex(i1, inputSubMesh);
backSubMesh.CopyVertex(i2, inputSubMesh);
backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
}
private Vector3 CalcIntersection(Vector3 v0, Vector3 v1, Plane plane, out float weight)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//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_0013: 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_0022: 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_0034: 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_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_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: 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)
Vector3 val = v1 - v0;
float magnitude = ((Vector3)(ref val)).magnitude;
Ray val2 = default(Ray);
((Ray)(ref val2))..ctor(v0, val / magnitude);
float num = default(float);
((Plane)(ref plane)).Raycast(val2, ref num);
Vector3 result = ((Ray)(ref val2)).origin + ((Ray)(ref val2)).direction * num;
weight = num / magnitude;
return result;
}
}
namespace ShermanJumbo
{
public class TubeFedShotgunFakeAutoMagSwitcher : MonoBehaviour
{
public enum MagState
{
LeftMag,
RightMag
}
[Serializable]
public class FauxMag
{
public Transform LowerPathForward;
public Transform LowerPathRearward;
public Transform TrigPoint;
}
public FVRFireArmMagazine Magazine;
public TubeFedShotgun Shotgun;
public FVRFireArmMagazineReloadTrigger Trig;
public Transform Switch;
public List<FauxMag> FauxMags;
public MagState CurState;
private void Update()
{
if ((float)Magazine.m_numRounds < 8f)
{
CurState = MagState.RightMag;
}
else
{
CurState = MagState.LeftMag;
}
UpdateState();
}
private void UpdateState()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_0099: 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_00f8: 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_0142: Unknown result type (might be due to invalid IL or missing references)
if (CurState == MagState.LeftMag)
{
Shotgun.RoundPos_LowerPath_Forward.position = FauxMags[0].LowerPathForward.position;
Shotgun.RoundPos_LowerPath_Rearward.position = FauxMags[0].LowerPathRearward.position;
((Component)Trig).transform.position = FauxMags[0].TrigPoint.position;
((Component)Switch).transform.localEulerAngles = new Vector3(0f, 0f, 16f);
}
else if (CurState == MagState.RightMag)
{
Shotgun.RoundPos_LowerPath_Forward.position = FauxMags[1].LowerPathForward.position;
Shotgun.RoundPos_LowerPath_Rearward.position = FauxMags[1].LowerPathRearward.position;
((Component)Trig).transform.position = FauxMags[1].TrigPoint.position;
((Component)Switch).transform.localEulerAngles = new Vector3(0f, 0f, -16f);
}
}
}
public class TurretSelfDestruct : MonoBehaviour
{
private float TurretTimeAlive = 0f;
public AutoMeater Turret;
public Transform SmokeParticleSystem;
public float MaxLifetime = 10f;
public float LifetimeToStartSmoking = 5f;
private void Update()
{
if (TurretTimeAlive < MaxLifetime)
{
TurretTimeAlive += Time.deltaTime;
}
if ((Object)(object)SmokeParticleSystem != (Object)null)
{
((Component)SmokeParticleSystem).gameObject.SetActive(TurretTimeAlive >= LifetimeToStartSmoking);
}
if (TurretTimeAlive >= MaxLifetime && (Object)(object)Turret != (Object)null)
{
Turret.KillMe();
}
}
}
public class TurretSpinnyBarrels : MonoBehaviour
{
public GameObject SpinnyThing;
public float SpinRate;
public float SpinRateSameAsAbove;
public dirType DirectionOfSpin;
public AutoMeater Turret;
public float FiringSpinRate;
public AudioSource SpinningSounds;
public AudioEvent StopSpinningSounds;
private AutoMeaterState previousState;
public void Start()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
previousState = Turret.m_state;
}
public void FixedUpdate()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_001a: Expected I4, but got Unknown
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Invalid comparison between Unknown and I4
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Invalid comparison between Unknown and I4
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_006d: 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_00c7: Invalid comparison between Unknown and I4
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Invalid comparison between Unknown and I4
//IL_00f7: 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_00df: Invalid comparison between Unknown and I4
Vector3 zero = Vector3.zero;
((Vector3)(ref zero))[(int)DirectionOfSpin] = SpinRate;
SpinnyThing.transform.Rotate(zero);
if ((int)Turret.m_state == 2 || (int)Turret.m_state == 3)
{
SpinRate = FiringSpinRate;
if (previousState != Turret.m_state)
{
SpinningSounds.Play();
}
}
else
{
SpinRate = SpinRateSameAsAbove;
if (previousState != Turret.m_state)
{
SpinningSounds.Stop();
}
}
if ((int)Turret.m_state == 1 && ((int)previousState == 2 || (int)previousState == 3))
{
SM.PlayCoreSound((FVRPooledAudioType)0, StopSpinningSounds, SpinnyThing.transform.position);
}
previousState = Turret.m_state;
}
}
}