using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using DenjiChainsaws;
using Il2Cpp;
using Il2CppHurricaneVR.Framework.Core;
using Il2CppHurricaneVR.Framework.Core.Grabbers;
using Il2CppHurricaneVR.Framework.Shared;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Reflection;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "DenjiChainsaws", "0.3.0", "coope", null)]
[assembly: MelonGame("Kubunautilus", "BrutalistickVR")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DenjiChainsaws")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DenjiChainsaws")]
[assembly: AssemblyTitle("DenjiChainsaws")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace DenjiChainsaws
{
public class Core : MelonMod
{
private sealed class Saw
{
public bool isHead;
public bool isLeft;
public Transform hand;
public GameObject go;
public Rigidbody rb;
public ChainsawManager mgr;
public List<Collider> colliders = new List<Collider>();
public Vector3 offset;
public Quaternion grip;
public float deployDistance;
public float progress;
public Vector3 pos;
public Quaternion rot;
}
private const string RigName = "Hexa4Rig26.10.23";
private const string LeftHandPath = "Physics LeftHand";
private const string RightHandPath = "Physics RightHand";
private const string SoundFolder = "DenjiChainsawSounds";
private const float DeployDistance = 0.4f;
private const float DeployDuration = 0.15f;
private const float LerpSpeed = 84f;
private const float MaxSpeed = 84f;
private const float MaxAngularSpeed = 5400f;
private const float SearchInterval = 2f;
private const int ModeOff = 0;
private const int ModeOn = 1;
private const int ModeRetract = 2;
private static readonly Vector3 OffsetRight = new Vector3(0f, 0.06f, -0.03f);
private static readonly Vector3 OffsetLeft = new Vector3(0f, -0.14f, -0.03f);
private static readonly Quaternion RotRight = Quaternion.Euler(0f, 180f, 90f);
private static readonly Quaternion RotLeft = Quaternion.Euler(0f, 180f, -90f);
private MelonPreferences_Category _cfg;
private MelonPreferences_Entry<float> _volIdle;
private MelonPreferences_Entry<float> _volRev;
private MelonPreferences_Entry<float> _volStart;
private MelonPreferences_Entry<float> _volStop;
private MelonPreferences_Entry<float> _headX;
private MelonPreferences_Entry<float> _headY;
private MelonPreferences_Entry<float> _headZ;
private MelonPreferences_Entry<float> _headPitch;
private MelonPreferences_Entry<float> _headYaw;
private MelonPreferences_Entry<float> _headRoll;
private MelonPreferences_Entry<float> _headScale;
private MelonPreferences_Entry<float> _handScale;
private MelonPreferences_Entry<bool> _movieSounds;
private MelonPreferences_Entry<float> _voiceVolume;
private MelonPreferences_Entry<bool> _starterEnabled;
private MelonPreferences_Entry<float> _starterOut;
private MelonPreferences_Entry<float> _starterDown;
private MelonPreferences_Entry<float> _starterPull;
private MelonPreferences_Entry<float> _starterScale;
private MelonPreferences_Entry<float> _starterDelay;
private MelonPreferences_Entry<bool> _tintEnabled;
private MelonPreferences_Entry<bool> _bloodEnabled;
private MelonPreferences_Entry<float> _bloodAmount;
private MelonPreferences_Entry<float> _tintIntensity;
private MelonPreferences_Entry<int> _cfgVer;
private Transform _rig;
private HVRHexaBodyInputs _inputs;
private HVRHandGrabber _leftGrabber;
private HVRHandGrabber _rightGrabber;
private Transform _leftHand;
private Transform _rightHand;
private Camera _cam;
private GameObject _prefab;
private Saw _leftSaw;
private Saw _rightSaw;
private Saw _headSaw;
private int _mode;
private bool _rev;
private bool _wasB;
private float _bindTimer;
private float _searchTimer;
private float _camTimer;
private GameObject _audioGo;
private AudioSource _idleAudio;
private AudioSource _revAudio;
private AudioSource _oneShot;
private AudioClip _startClip;
private AudioClip _stopClip;
private bool _voiceReady;
private bool _movieLoaded;
private Transform _starterAnchor;
private Transform _starterHandle;
private Transform _cableStart;
private Rigidbody _starterRb;
private HVRGrabbable _starterGrab;
private LineRenderer _starterCable;
private Transform _cableEnd;
private Transform _starterHand;
private Quaternion _starterGrip;
private bool _starterTried;
private bool _starterHeld;
private bool _pulled;
private float _pullTimer;
private Quaternion _starterBaseRot;
private Vector3 _starterBasePos;
private float _voiceDelay;
private float _engineDelay;
private GameObject _tintGo;
private MeshRenderer _tintRenderer;
private Material _tintMat;
private Material _bloodMat;
private float _tintAlpha;
private readonly List<Collider> _rigColliders = new List<Collider>();
private static bool _dumpedProbe;
private static string SoundDir
{
get
{
try
{
string location = Assembly.GetExecutingAssembly().Location;
if (!string.IsNullOrEmpty(location))
{
string directoryName = Path.GetDirectoryName(location);
if (!string.IsNullOrEmpty(directoryName))
{
return Path.Combine(directoryName, "DenjiChainsawSounds");
}
}
}
catch
{
}
return Path.Combine(Application.persistentDataPath, "DenjiChainsawSounds");
}
}
public override void OnInitializeMelon()
{
_cfg = MelonPreferences.CreateCategory("DenjiChainsaws", "Denji Chainsaws");
_volIdle = _cfg.CreateEntry<float>("IdleVolume", 1f, "Громкость холостого хода", (string)null, false, false, (ValueValidator)null, (string)null);
_volRev = _cfg.CreateEntry<float>("RevVolume", 0.6f, "Громкость газа", (string)null, false, false, (ValueValidator)null, (string)null);
_volStart = _cfg.CreateEntry<float>("StartVolume", 0.5f, "Громкость запуска пилы", (string)null, false, false, (ValueValidator)null, (string)null);
_volStop = _cfg.CreateEntry<float>("StopVolume", 0.8f, "Громкость остановки", (string)null, false, false, (ValueValidator)null, (string)null);
_headX = _cfg.CreateEntry<float>("HeadOffsetX", 0f, "Пила на голове: сдвиг вправо", (string)null, false, false, (ValueValidator)null, (string)null);
_headY = _cfg.CreateEntry<float>("HeadOffsetY", 0.05f, "Пила на голове: сдвиг вверх", (string)null, false, false, (ValueValidator)null, (string)null);
_headZ = _cfg.CreateEntry<float>("HeadOffsetZ", 0.1f, "Пила на голове: сдвиг вперёд", (string)null, false, false, (ValueValidator)null, (string)null);
_headPitch = _cfg.CreateEntry<float>("HeadPitch", -22f, "Пила на голове: наклон вверх, градусы", (string)null, false, false, (ValueValidator)null, (string)null);
_headYaw = _cfg.CreateEntry<float>("HeadYaw", 0f, "Пила на голове: поворот, градусы", (string)null, false, false, (ValueValidator)null, (string)null);
_headRoll = _cfg.CreateEntry<float>("HeadRoll", 90f, "Пила на голове: крен, градусы", (string)null, false, false, (ValueValidator)null, (string)null);
_headScale = _cfg.CreateEntry<float>("HeadScale", 1f, "Размер пилы на голове", (string)null, false, false, (ValueValidator)null, (string)null);
_handScale = _cfg.CreateEntry<float>("HandScale", 1f, "Размер пил на руках", (string)null, false, false, (ValueValidator)null, (string)null);
_movieSounds = _cfg.CreateEntry<bool>("MovieSounds", true, "Фраза Денджи", (string)null, false, false, (ValueValidator)null, (string)null);
_voiceVolume = _cfg.CreateEntry<float>("VoiceVolume", 0.95f, "Громкость фразы Денджи", (string)null, false, false, (ValueValidator)null, (string)null);
_starterEnabled = _cfg.CreateEntry<bool>("StarterEnabled", true, "Стартер на груди (B только убирает пилы)", (string)null, false, false, (ValueValidator)null, (string)null);
_starterOut = _cfg.CreateEntry<float>("StarterOut", 0.15f, "Стартер: вынос от тела", (string)null, false, false, (ValueValidator)null, (string)null);
_starterDown = _cfg.CreateEntry<float>("StarterDown", 0.3f, "Стартер: высота от таза", (string)null, false, false, (ValueValidator)null, (string)null);
_starterPull = _cfg.CreateEntry<float>("StarterPull", 0.22f, "Стартер: длина выдергивания", (string)null, false, false, (ValueValidator)null, (string)null);
_starterScale = _cfg.CreateEntry<float>("StarterScale", 1f, "Стартер: размер", (string)null, false, false, (ValueValidator)null, (string)null);
_starterDelay = _cfg.CreateEntry<float>("StarterDelay", 0.35f, "Стартер: задержка перед выпуском пил", (string)null, false, false, (ValueValidator)null, (string)null);
_tintEnabled = _cfg.CreateEntry<bool>("TintEnabled", true, "Красный экран при включении", (string)null, false, false, (ValueValidator)null, (string)null);
_bloodEnabled = _cfg.CreateEntry<bool>("BloodEnabled", true, "Кровь из рук и головы при выпуске", (string)null, false, false, (ValueValidator)null, (string)null);
_bloodAmount = _cfg.CreateEntry<float>("BloodAmount", 1f, "Количество крови (множитель)", (string)null, false, false, (ValueValidator)null, (string)null);
_tintIntensity = _cfg.CreateEntry<float>("TintIntensity", 0.2f, "Красный экран: сила 0-1", (string)null, false, false, (ValueValidator)null, (string)null);
_cfgVer = _cfg.CreateEntry<int>("ConfigVersion", 1, "Версия конфига", (string)null, false, false, (ValueValidator)null, (string)null);
if (_cfgVer.Value < 2)
{
_headX.Value = 0f;
_headY.Value = 0.05f;
_headZ.Value = 0.1f;
_headPitch.Value = -22f;
_headRoll.Value = 90f;
_volStart.Value = 0.5f;
_cfgVer.Value = 2;
}
if (_cfgVer.Value < 3)
{
_volStart.Value = 0.8f;
_cfgVer.Value = 3;
}
if (_cfgVer.Value < 4)
{
_starterDown.Value = 0.3f;
_starterOut.Value = 0.15f;
_cfgVer.Value = 4;
}
if (_cfgVer.Value < 5)
{
_starterDelay.Value = 0.35f;
_cfgVer.Value = 5;
}
((MelonBase)this).LoggerInstance.Msg("========================================");
((MelonBase)this).LoggerInstance.Msg("Denji Chainsaws v0.3.0");
((MelonBase)this).LoggerInstance.Msg("Стартер на груди - выпустить, B / Menu - убрать");
((MelonBase)this).LoggerInstance.Msg("Курок - дать газу");
((MelonBase)this).LoggerInstance.Msg("========================================");
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
CleanupAll();
if (!(sceneName == "MainMenuScene") && !(sceneName == "IntroScene"))
{
_bindTimer = 0f;
Bind();
}
}
public override void OnDeinitializeMelon()
{
CleanupAll();
Mci.Close("denji_voice");
}
public override void OnUpdate()
{
float deltaTime = Time.deltaTime;
UpdateCamera();
if ((Object)(object)_rig == (Object)null)
{
_bindTimer -= deltaTime;
if (_bindTimer <= 0f)
{
_bindTimer = 1f;
Bind();
}
}
if (!((Object)(object)_rig == (Object)null))
{
_searchTimer -= deltaTime;
if ((Object)(object)_prefab == (Object)null && _searchTimer <= 0f)
{
_searchTimer = 2f;
FindPrefab();
}
HandleToggle();
HandleRev();
UpdateAudio(deltaTime);
UpdateTint(deltaTime);
EnsureStarter();
UpdateStarter();
}
}
public override void OnFixedUpdate()
{
if (_mode != 0)
{
float fixedDeltaTime = Time.fixedDeltaTime;
UpdateSaw(_leftSaw, fixedDeltaTime);
UpdateSaw(_rightSaw, fixedDeltaTime);
UpdateSaw(_headSaw, fixedDeltaTime);
if (_mode == 2 && _leftSaw == null && _rightSaw == null && _headSaw == null)
{
_mode = 0;
_rev = false;
}
}
}
private void Bind()
{
GameObject val = GameObject.Find("Hexa4Rig26.10.23");
if ((Object)(object)val == (Object)null)
{
val = FindRigByPrefix();
}
if (!((Object)(object)val == (Object)null))
{
_rig = val.transform;
_inputs = val.GetComponentInChildren<HVRHexaBodyInputs>();
if ((Object)(object)_inputs == (Object)null)
{
_inputs = Object.FindObjectOfType<HVRHexaBodyInputs>();
}
_leftHand = FindDeep(_rig, "Physics LeftHand");
_rightHand = FindDeep(_rig, "Physics RightHand");
_leftGrabber = (((Object)(object)_leftHand != (Object)null) ? ((Component)_leftHand).GetComponent<HVRHandGrabber>() : null);
if ((Object)(object)_leftGrabber == (Object)null && (Object)(object)_leftHand != (Object)null)
{
_leftGrabber = ((Component)_leftHand).GetComponentInChildren<HVRHandGrabber>();
}
_rightGrabber = (((Object)(object)_rightHand != (Object)null) ? ((Component)_rightHand).GetComponent<HVRHandGrabber>() : null);
if ((Object)(object)_rightGrabber == (Object)null && (Object)(object)_rightHand != (Object)null)
{
_rightGrabber = ((Component)_rightHand).GetComponentInChildren<HVRHandGrabber>();
}
((MelonBase)this).LoggerInstance.Msg("rig=" + ((Object)val).name + " inputs=" + ((Object)(object)_inputs != (Object)null) + " L=" + ((Object)(object)_leftHand != (Object)null) + " R=" + ((Object)(object)_rightHand != (Object)null));
}
}
private void UpdateCamera()
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Invalid comparison between Unknown and I4
if ((Object)(object)_cam != (Object)null)
{
return;
}
_camTimer -= Time.deltaTime;
if (_camTimer > 0f)
{
return;
}
_camTimer = 1f;
_cam = Camera.main;
if ((Object)(object)_cam != (Object)null)
{
return;
}
Camera[] array = Il2CppArrayBase<Camera>.op_Implicit((Il2CppArrayBase<Camera>)(object)Camera.allCameras);
if (array == null)
{
return;
}
for (int i = 0; i < array.Length; i++)
{
if (!((Object)(object)array[i] == (Object)null) && (int)array[i].stereoTargetEye == 3)
{
_cam = array[i];
break;
}
}
if ((Object)(object)_cam == (Object)null && array.Length != 0)
{
_cam = array[0];
}
}
private void HandleToggle()
{
if ((Object)(object)_inputs == (Object)null)
{
return;
}
HVRController leftController = _inputs.LeftController;
HVRController rightController = _inputs.RightController;
bool flag = IsTogglePressed(leftController) || IsTogglePressed(rightController);
if (flag && !_wasB)
{
if (_starterEnabled.Value && (Object)(object)_starterHandle != (Object)null)
{
if (_mode == 1)
{
Toggle();
}
}
else
{
Toggle();
}
}
_wasB = flag;
}
private static bool IsTogglePressed(HVRController controller)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Invalid comparison between Unknown and I4
//IL_0034: 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_0023: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)controller == (Object)null)
{
return false;
}
try
{
if ((int)controller.ControllerType == 3)
{
return controller.TrackpadButtonState.Active || controller.MenuButtonState.Active;
}
return controller.SecondaryButtonState.Active;
}
catch
{
return false;
}
}
private void Toggle()
{
if (_mode != 2)
{
if (_mode == 1)
{
RetractAll();
}
else if ((!((Object)(object)_leftGrabber != (Object)null) || !((HVRGrabberBase)_leftGrabber).IsGrabbing) && (!((Object)(object)_rightGrabber != (Object)null) || !((HVRGrabberBase)_rightGrabber).IsGrabbing))
{
SpawnAll();
}
}
}
private void HandleRev()
{
//IL_003b: 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)
if (_mode == 1 && !((Object)(object)_inputs == (Object)null))
{
HVRController leftController = _inputs.LeftController;
HVRController rightController = _inputs.RightController;
bool flag = ((Object)(object)leftController != (Object)null && leftController.TriggerButtonState.Active) || ((Object)(object)rightController != (Object)null && rightController.TriggerButtonState.Active);
if (flag != _rev)
{
_rev = flag;
ApplyRev(flag);
}
}
}
private void ApplyRev(bool revved)
{
SetRev(_leftSaw, revved);
SetRev(_rightSaw, revved);
SetRev(_headSaw, revved);
}
private void SpawnBloodBurst(Vector3 pos)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: 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_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: 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_00d6: 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_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: 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_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: 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)
try
{
int num = Mathf.RoundToInt(Mathf.Clamp(_bloodAmount.Value, 0.2f, 3f) * 52f);
Material bloodMaterial = GetBloodMaterial();
for (int i = 0; i < num; i++)
{
GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
((Object)obj).name = "DenjiBloodDrop";
Collider component = obj.GetComponent<Collider>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
float num2 = ((i % 3 != 0) ? Random.Range(0.022f, 0.048f) : Random.Range(0.01f, 0.022f));
obj.transform.position = pos + Random.insideUnitSphere * 0.04f;
obj.transform.localScale = new Vector3(num2, num2 * Random.Range(0.85f, 1.2f), num2);
obj.transform.rotation = Random.rotation;
Renderer component2 = obj.GetComponent<Renderer>();
if ((Object)(object)component2 != (Object)null)
{
component2.sharedMaterial = bloodMaterial;
}
Rigidbody obj2 = obj.AddComponent<Rigidbody>();
obj2.mass = 0.02f;
obj2.useGravity = true;
obj2.drag = 0.7f;
obj2.angularDrag = 2f;
Vector3 val = Random.onUnitSphere;
val.y = Mathf.Abs(val.y) * 0.9f + 0.3f;
val = ((Vector3)(ref val)).normalized;
obj2.velocity = val * Random.Range(0.9f, 3.6f);
obj2.angularVelocity = Random.onUnitSphere * 8f;
Object.Destroy((Object)(object)obj, Random.Range(1.3f, 2.1f));
}
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("blood failed: " + ex.Message);
}
}
private Material GetBloodMaterial()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_bloodMat != (Object)null)
{
return _bloodMat;
}
Shader val = Shader.Find("Universal Render Pipeline/Unlit");
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Unlit/Color");
}
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Standard");
}
_bloodMat = new Material(val);
Color val2 = default(Color);
((Color)(ref val2))..ctor(0.78f, 0.05f, 0.05f, 1f);
if (_bloodMat.HasProperty("_BaseColor"))
{
_bloodMat.SetColor("_BaseColor", val2);
}
if (_bloodMat.HasProperty("_Color"))
{
_bloodMat.SetColor("_Color", val2);
}
if (_bloodMat.HasProperty("_Smoothness"))
{
_bloodMat.SetFloat("_Smoothness", 0.75f);
}
return _bloodMat;
}
private static void SetRev(Saw s, bool revved)
{
if (s == null || (Object)(object)s.mgr == (Object)null)
{
return;
}
try
{
s.mgr.isRevved = revved;
}
catch
{
}
}
private void SpawnAll()
{
//IL_00c8: 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_010e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_prefab == (Object)null)
{
FindPrefab();
}
if ((Object)(object)_prefab == (Object)null)
{
((MelonBase)this).LoggerInstance.Warning("Chainsaw prefab not found");
return;
}
CacheRigColliders();
Saw saw = SpawnSaw(left: false, head: false);
Saw saw2 = SpawnSaw(left: true, head: false);
Saw saw3 = SpawnSaw(left: false, head: true);
if (saw == null || saw2 == null || saw3 == null)
{
DestroySaw(saw);
DestroySaw(saw2);
DestroySaw(saw3);
((MelonBase)this).LoggerInstance.Warning("Failed to spawn all chainsaws");
return;
}
_leftSaw = saw;
_rightSaw = saw2;
_headSaw = saw3;
_mode = 1;
_rev = false;
if (_bloodEnabled.Value)
{
if ((Object)(object)_leftHand != (Object)null)
{
SpawnBloodBurst(_leftHand.position);
}
if ((Object)(object)_rightHand != (Object)null)
{
SpawnBloodBurst(_rightHand.position);
}
if (saw3 != null && (Object)(object)saw3.go != (Object)null)
{
SpawnBloodBurst(saw3.go.transform.position);
}
}
ChainsawManager mgr = saw.mgr;
if ((Object)(object)mgr != (Object)null)
{
_startClip = mgr.chainsawStartSound;
_stopClip = mgr.chainsawStopSound;
}
EnsureMovieSounds();
AudioClip val = (((Object)(object)mgr != (Object)null) ? mgr.chainsawIdle : null);
AudioClip val2 = (((Object)(object)mgr != (Object)null) ? mgr.chainsawRevved : null);
if ((Object)(object)val == (Object)null && (Object)(object)mgr != (Object)null && (Object)(object)mgr.audioSourceA != (Object)null)
{
val = mgr.audioSourceA.clip;
}
if ((Object)(object)val2 == (Object)null && (Object)(object)mgr != (Object)null && (Object)(object)mgr.audioSourceB != (Object)null)
{
val2 = mgr.audioSourceB.clip;
}
SetupAudio(val, val2);
ApplyRev(revved: false);
_voiceDelay = 0f;
_engineDelay = (((Object)(object)_startClip != (Object)null) ? Mathf.Clamp(_startClip.length * 0.55f, 0.25f, 2.5f) : 0f);
if ((Object)(object)_oneShot != (Object)null)
{
if ((Object)(object)_startClip != (Object)null)
{
try
{
_oneShot.PlayOneShot(_startClip, Mathf.Max(0f, _volStart.Value));
}
catch
{
}
}
if (_movieSounds.Value && _voiceReady)
{
_voiceDelay = 0.4f;
}
}
EnsureTint();
((MelonBase)this).LoggerInstance.Msg("Denji saws out");
}
private Saw SpawnSaw(bool left, bool head)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0461: Unknown result type (might be due to invalid IL or missing references)
//IL_0466: Unknown result type (might be due to invalid IL or missing references)
//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0504: Unknown result type (might be due to invalid IL or missing references)
//IL_0509: Unknown result type (might be due to invalid IL or missing references)
//IL_050d: Unknown result type (might be due to invalid IL or missing references)
//IL_0512: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_0538: Unknown result type (might be due to invalid IL or missing references)
//IL_053d: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0576: Unknown result type (might be due to invalid IL or missing references)
//IL_057b: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_0329: Unknown result type (might be due to invalid IL or missing references)
//IL_032d: Unknown result type (might be due to invalid IL or missing references)
//IL_0332: Unknown result type (might be due to invalid IL or missing references)
//IL_0337: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: Unknown result type (might be due to invalid IL or missing references)
//IL_033e: Unknown result type (might be due to invalid IL or missing references)
//IL_0342: 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_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_0352: Unknown result type (might be due to invalid IL or missing references)
//IL_0354: Unknown result type (might be due to invalid IL or missing references)
//IL_0359: Unknown result type (might be due to invalid IL or missing references)
//IL_0365: Unknown result type (might be due to invalid IL or missing references)
//IL_036a: Unknown result type (might be due to invalid IL or missing references)
//IL_036f: Unknown result type (might be due to invalid IL or missing references)
//IL_0376: Unknown result type (might be due to invalid IL or missing references)
//IL_0378: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Unknown result type (might be due to invalid IL or missing references)
//IL_038c: Unknown result type (might be due to invalid IL or missing references)
//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
//IL_049c: 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)
GameObject val;
try
{
val = Object.Instantiate<GameObject>(_prefab);
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("instantiate failed: " + ex.Message);
return null;
}
if ((Object)(object)val == (Object)null)
{
return null;
}
((Object)val).name = (head ? "DenjiHeadSaw" : (left ? "DenjiLeftSaw" : "DenjiRightSaw"));
val.transform.SetParent((Transform)null, false);
val.transform.localScale = Vector3.one * Mathf.Max(0.2f, head ? _headScale.Value : _handScale.Value);
DestroyComponentByName(val, "HVRTagSocketable");
DestroyComponentByName(val, "HVRStringSocketable");
DisableComponentByName(val, "HVRGrabbable");
DisableComponentByName(val, "HVRGrabbableImpactHaptics");
DisableComponentByName(val, "StabilizerGrabbable");
DisableComponentByName(val, "ImpactObjectRigidbody");
DisableComponentByName(val, "ImpactCollisionTrigger3D");
DisableComponentByName(val, "ImpactSlideAndRollTrigger3D");
ChainsawManager component = val.GetComponent<ChainsawManager>();
if ((Object)(object)component == (Object)null)
{
Object.Destroy((Object)(object)val);
return null;
}
try
{
ParticleSystem smokeParticleSystem = component.smokeParticleSystem;
if ((Object)(object)smokeParticleSystem != (Object)null)
{
smokeParticleSystem.Stop(true, (ParticleSystemStopBehavior)0);
((Component)smokeParticleSystem).gameObject.SetActive(false);
}
}
catch
{
}
ParticleSystem[] array = Il2CppArrayBase<ParticleSystem>.op_Implicit(val.GetComponentsInChildren<ParticleSystem>(true));
if (array != null)
{
foreach (ParticleSystem val2 in array)
{
if (!((Object)(object)val2 == (Object)null) && ((Object)((Component)val2).gameObject).name.ToLower().Contains("smoke"))
{
try
{
val2.Stop(true, (ParticleSystemStopBehavior)0);
((Component)val2).gameObject.SetActive(false);
}
catch
{
}
}
}
}
try
{
component.StartChainsaw();
}
catch
{
try
{
component.isRunning = true;
}
catch
{
}
}
Rigidbody val3 = val.GetComponent<Rigidbody>();
if ((Object)(object)val3 == (Object)null)
{
val3 = val.AddComponent<Rigidbody>();
}
val3.isKinematic = true;
val3.useGravity = false;
val3.detectCollisions = true;
val3.interpolation = (RigidbodyInterpolation)1;
val3.mass = 1.5f;
val3.collisionDetectionMode = (CollisionDetectionMode)3;
AudioSource[] array2 = Il2CppArrayBase<AudioSource>.op_Implicit(val.GetComponents<AudioSource>());
if (array2 != null)
{
for (int j = 0; j < array2.Length; j++)
{
if (!((Object)(object)array2[j] == (Object)null))
{
try
{
array2[j].Stop();
}
catch
{
}
try
{
((Behaviour)array2[j]).enabled = false;
}
catch
{
}
}
}
}
Saw saw = new Saw();
saw.isHead = head;
saw.isLeft = left;
saw.hand = (left ? _leftHand : _rightHand);
saw.go = val;
saw.rb = val3;
saw.mgr = component;
saw.offset = (Vector3)(head ? new Vector3(_headX.Value, _headY.Value, _headZ.Value) : (left ? OffsetLeft : OffsetRight));
saw.grip = (head ? RotRight : (left ? RotLeft : RotRight));
saw.deployDistance = 0.4f;
if (!GetAnchor(saw, out var pos, out var rot))
{
Object.Destroy((Object)(object)val);
return null;
}
Vector3 val4 = pos + rot * saw.offset;
Quaternion rot2 = rot * saw.grip;
saw.pos = val4 - rot * Vector3.forward * saw.deployDistance;
saw.rot = rot2;
val.transform.SetPositionAndRotation(saw.pos, saw.rot);
Collider[] array3 = Il2CppArrayBase<Collider>.op_Implicit(val.GetComponentsInChildren<Collider>(true));
if (array3 != null)
{
foreach (Collider val5 in array3)
{
if ((Object)(object)val5 == (Object)null)
{
continue;
}
if (IsCuttingPart(((Component)val5).transform))
{
if (val5.enabled)
{
saw.colliders.Add(val5);
}
}
else
{
try
{
val5.enabled = false;
}
catch
{
}
}
}
}
Renderer[] array4 = Il2CppArrayBase<Renderer>.op_Implicit(val.GetComponentsInChildren<Renderer>(true));
if (array4 != null)
{
foreach (Renderer val6 in array4)
{
if (!((Object)(object)val6 == (Object)null) && !IsCuttingPart(((Component)val6).transform))
{
try
{
val6.enabled = false;
}
catch
{
}
}
}
}
if (head)
{
Bounds bounds = default(Bounds);
((Bounds)(ref bounds))..ctor(val.transform.position, Vector3.zero);
bool flag = false;
if (array4 != null)
{
foreach (Renderer val7 in array4)
{
if (!((Object)(object)val7 == (Object)null) && val7.enabled)
{
if (!flag)
{
bounds = val7.bounds;
flag = true;
}
else
{
((Bounds)(ref bounds)).Encapsulate(val7.bounds);
}
}
}
}
Instance loggerInstance = ((MelonBase)this).LoggerInstance;
string[] obj9 = new string[8] { "head saw pos=", null, null, null, null, null, null, null };
Vector3 val8 = val.transform.position;
obj9[1] = ((Vector3)(ref val8)).ToString("F2");
obj9[2] = " rot=";
Quaternion rotation = val.transform.rotation;
val8 = ((Quaternion)(ref rotation)).eulerAngles;
obj9[3] = ((Vector3)(ref val8)).ToString("F0");
obj9[4] = " size=";
object obj10;
if (!flag)
{
obj10 = "none";
}
else
{
val8 = ((Bounds)(ref bounds)).size;
obj10 = ((Vector3)(ref val8)).ToString("F2");
}
obj9[5] = (string)obj10;
obj9[6] = " cam=";
object obj11;
if (!((Object)(object)_cam != (Object)null))
{
obj11 = "none";
}
else
{
val8 = ((Component)_cam).transform.position;
obj11 = ((Vector3)(ref val8)).ToString("F2");
}
obj9[7] = (string)obj11;
loggerInstance.Msg(string.Concat(obj9));
}
IgnoreRigCollisions(saw);
val.SetActive(true);
return saw;
}
private void UpdateSaw(Saw s, float dt)
{
//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_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: 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_00b8: 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_00c7: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: 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_0100: 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_0147: 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_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_015d: 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_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: 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_0144: 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_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: 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_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: 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_01bd: Unknown result type (might be due to invalid IL or missing references)
if (s == null)
{
return;
}
if ((Object)(object)s.go == (Object)null)
{
DestroySaw(s);
return;
}
if (!GetAnchor(s, out var pos, out var rot))
{
DestroySaw(s);
return;
}
float num = Mathf.Max(0.02f, 0.15f);
if (_mode == 2)
{
s.progress -= dt / num;
if (s.progress <= 0f)
{
DestroySaw(s);
return;
}
}
else
{
s.progress = Mathf.Min(1f, s.progress + dt / num);
}
float num2 = Mathf.Clamp01(s.progress);
float num3 = num2 * num2 * (3f - 2f * num2);
Vector3 val = pos + rot * s.offset;
Quaternion val2 = rot * s.grip;
Vector3 val3 = val - rot * Vector3.forward * (s.deployDistance * (1f - num3));
Vector3 val4 = Vector3.Lerp(s.pos, val3, 84f * dt);
float num4 = Vector3.Distance(s.pos, val4);
float num5 = 84f * dt;
if (num4 > num5)
{
Vector3 pos2 = s.pos;
Vector3 val5 = val4 - s.pos;
val4 = pos2 + ((Vector3)(ref val5)).normalized * num5;
}
s.pos = val4;
Quaternion val6 = Quaternion.Slerp(s.rot, val2, 84f * dt);
float num6 = Quaternion.Angle(s.rot, val6);
float num7 = 5400f * dt;
if (num6 > num7)
{
val6 = Quaternion.RotateTowards(s.rot, val6, num7);
}
s.rot = val6;
if ((Object)(object)s.rb != (Object)null)
{
s.rb.MovePosition(s.pos);
s.rb.MoveRotation(s.rot);
}
else
{
s.go.transform.SetPositionAndRotation(s.pos, s.rot);
}
}
private bool GetAnchor(Saw s, out Vector3 pos, out Quaternion rot)
{
//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_0041: 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_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: 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_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: 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_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//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_0071: 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_007b: 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_008c: 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_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)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
if (s.isHead)
{
UpdateCamera();
if ((Object)(object)_cam != (Object)null)
{
pos = ((Component)_cam).transform.position;
rot = ((Component)_cam).transform.rotation;
}
else
{
if (!((Object)(object)_rig != (Object)null))
{
pos = Vector3.zero;
rot = Quaternion.identity;
return false;
}
pos = _rig.position + Vector3.up * 1.55f;
rot = _rig.rotation;
}
rot *= Quaternion.Euler(_headPitch.Value, _headYaw.Value, _headRoll.Value);
return true;
}
Transform val = s.hand;
if ((Object)(object)val == (Object)null)
{
val = (s.isLeft ? _leftHand : _rightHand);
}
if ((Object)(object)val == (Object)null)
{
pos = Vector3.zero;
rot = Quaternion.identity;
return false;
}
pos = val.position;
rot = val.rotation;
return true;
}
private void RetractAll()
{
//IL_002c: 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_0081: Unknown result type (might be due to invalid IL or missing references)
if (_mode != 1)
{
return;
}
if (_bloodEnabled.Value)
{
if ((Object)(object)_leftHand != (Object)null)
{
SpawnBloodBurst(_leftHand.position);
}
if ((Object)(object)_rightHand != (Object)null)
{
SpawnBloodBurst(_rightHand.position);
}
if (_headSaw != null && (Object)(object)_headSaw.go != (Object)null)
{
SpawnBloodBurst(_headSaw.go.transform.position);
}
}
_mode = 2;
_rev = false;
_voiceDelay = 0f;
_engineDelay = 0f;
ApplyRev(revved: false);
StopAudio();
}
private void DestroySaw(Saw s)
{
if (s == null)
{
return;
}
if ((Object)(object)s.mgr != (Object)null)
{
try
{
s.mgr.isRevved = false;
}
catch
{
}
try
{
s.mgr.StopChainsaw();
}
catch
{
}
}
if ((Object)(object)s.go != (Object)null)
{
try
{
Object.Destroy((Object)(object)s.go);
}
catch
{
}
}
if (s == _leftSaw)
{
_leftSaw = null;
}
if (s == _rightSaw)
{
_rightSaw = null;
}
if (s == _headSaw)
{
_headSaw = null;
}
}
private void EnsureMovieSounds()
{
if (_movieLoaded)
{
return;
}
_movieLoaded = true;
if (_movieSounds.Value)
{
string soundDir = SoundDir;
try
{
Directory.CreateDirectory(soundDir);
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("sounds dir failed: " + ex.Message);
}
((MelonBase)this).LoggerInstance.Msg("sounds dir=" + soundDir);
string path = Path.Combine(soundDir, "denji_damn.wav");
_voiceReady = EnsureSoundFile(soundDir, "denji_damn.wav") && Mci.Open("denji_voice", path, _voiceVolume.Value);
if (!_voiceReady)
{
((MelonBase)this).LoggerInstance.Warning("voice mci failed: " + Mci.LastError);
}
((MelonBase)this).LoggerInstance.Msg("movie sounds voice=" + _voiceReady);
}
}
private bool EnsureSoundFile(string dir, string file)
{
string path = Path.Combine(dir, file);
if (File.Exists(path))
{
return true;
}
byte[] array = ReadEmbedded(file);
if (array == null || array.Length < 44)
{
((MelonBase)this).LoggerInstance.Warning("wav " + file + " missing in " + dir);
return false;
}
try
{
File.WriteAllBytes(path, array);
((MelonBase)this).LoggerInstance.Msg("wav " + file + " unpacked");
return true;
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("wav write " + file + " failed: " + ex.Message);
return false;
}
}
private static byte[] ReadEmbedded(string endsWith)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
if (manifestResourceNames == null)
{
return null;
}
foreach (string text in manifestResourceNames)
{
if (text == null || text.Length < endsWith.Length)
{
continue;
}
bool flag = true;
int num = text.Length - endsWith.Length;
for (int j = 0; j < endsWith.Length; j++)
{
char num2 = char.ToLowerInvariant(text[num + j]);
char c = char.ToLowerInvariant(endsWith[j]);
if (num2 != c)
{
flag = false;
break;
}
}
if (!flag)
{
continue;
}
Stream stream = null;
try
{
stream = executingAssembly.GetManifestResourceStream(text);
if (stream == null)
{
return null;
}
long length = stream.Length;
if (length <= 0 || length > int.MaxValue)
{
return null;
}
byte[] array = new byte[(int)length];
int k;
int num3;
for (k = 0; k < array.Length; k += num3)
{
num3 = stream.Read(array, k, array.Length - k);
if (num3 <= 0)
{
break;
}
}
if (k != array.Length)
{
return null;
}
return array;
}
finally
{
if (stream != null)
{
try
{
stream.Dispose();
}
catch
{
}
}
}
}
return null;
}
private void SetupAudio(AudioClip idleClip, AudioClip revClip)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_audioGo == (Object)null)
{
_audioGo = new GameObject("DenjiChainsawAudio");
Transform val = (((Object)(object)_cam != (Object)null) ? ((Component)_cam).transform : _rig);
if ((Object)(object)val != (Object)null)
{
_audioGo.transform.SetParent(val, false);
}
_audioGo.transform.localPosition = new Vector3(0f, -0.25f, 0f);
}
if ((Object)(object)_idleAudio == (Object)null)
{
_idleAudio = _audioGo.AddComponent<AudioSource>();
}
if ((Object)(object)_revAudio == (Object)null)
{
_revAudio = _audioGo.AddComponent<AudioSource>();
}
if ((Object)(object)_oneShot == (Object)null)
{
_oneShot = _audioGo.AddComponent<AudioSource>();
}
ConfigureSource(_idleAudio, idleClip, loop: true);
ConfigureSource(_revAudio, revClip, loop: true);
ConfigureSource(_oneShot, null, loop: false);
_idleAudio.volume = 0f;
_revAudio.volume = 0f;
if ((Object)(object)idleClip != (Object)null)
{
try
{
_idleAudio.Play();
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("idle play failed: " + ex.Message);
}
}
if ((Object)(object)revClip != (Object)null)
{
try
{
_revAudio.Play();
}
catch (Exception ex2)
{
((MelonBase)this).LoggerInstance.Warning("rev play failed: " + ex2.Message);
}
}
((MelonBase)this).LoggerInstance.Msg("audio idle=" + ((Object)(object)idleClip != (Object)null) + " rev=" + ((Object)(object)revClip != (Object)null) + " start=" + ((Object)(object)_startClip != (Object)null) + " stop=" + ((Object)(object)_stopClip != (Object)null) + " idlePlaying=" + ((Object)(object)_idleAudio != (Object)null && _idleAudio.isPlaying) + " revPlaying=" + ((Object)(object)_revAudio != (Object)null && _revAudio.isPlaying) + " cam=" + ((Object)(object)_cam != (Object)null) + " parent=" + ((Object)(object)_audioGo != (Object)null && (Object)(object)_audioGo.transform.parent != (Object)null));
}
private static void ConfigureSource(AudioSource src, AudioClip clip, bool loop)
{
if (!((Object)(object)src == (Object)null))
{
src.clip = clip;
src.loop = loop;
src.playOnAwake = false;
src.spatialBlend = 0.25f;
src.minDistance = 0.3f;
src.maxDistance = 25f;
src.rolloffMode = (AudioRolloffMode)1;
src.pitch = 1f;
}
}
private void UpdateAudio(float dt)
{
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
if (_voiceDelay > 0f)
{
_voiceDelay -= dt;
if (_voiceDelay <= 0f && _mode == 1 && _voiceReady)
{
if (Mci.Play("denji_voice"))
{
((MelonBase)this).LoggerInstance.Msg("voice play");
}
else
{
((MelonBase)this).LoggerInstance.Warning("voice play failed: " + Mci.LastError);
}
}
}
if (_engineDelay > 0f)
{
_engineDelay = Mathf.Max(0f, _engineDelay - dt);
}
if ((Object)(object)_idleAudio == (Object)null || (Object)(object)_revAudio == (Object)null)
{
return;
}
float num = 0f;
float num2 = 0f;
if (_mode == 1 && _engineDelay <= 0f)
{
if (_rev)
{
num2 = Mathf.Max(0f, _volRev.Value);
}
else
{
num = Mathf.Max(0f, _volIdle.Value);
}
}
_idleAudio.volume = Mathf.MoveTowards(_idleAudio.volume, num, dt * 3f);
_revAudio.volume = Mathf.MoveTowards(_revAudio.volume, num2, dt * 3f);
if ((Object)(object)_audioGo != (Object)null && (Object)(object)_audioGo.transform.parent == (Object)null && (Object)(object)_rig != (Object)null)
{
_audioGo.transform.SetParent(_rig, false);
_audioGo.transform.localPosition = new Vector3(0f, 1.35f, 0f);
}
}
private void EnsureTint()
{
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_tintGo != (Object)null || (Object)(object)_cam == (Object)null)
{
return;
}
try
{
Shader val = Shader.Find("Sprites/Default");
if ((Object)(object)val == (Object)null)
{
throw new Exception("Sprites/Default not found");
}
_tintGo = GameObject.CreatePrimitive((PrimitiveType)5);
((Object)_tintGo).name = "DenjiChainsawTint";
Collider component = _tintGo.GetComponent<Collider>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
_tintRenderer = _tintGo.GetComponent<MeshRenderer>();
if ((Object)(object)_tintRenderer == (Object)null)
{
throw new Exception("quad renderer missing");
}
_tintMat = new Material(val);
_tintMat.color = new Color(0.7f, 0.02f, 0.04f, 0f);
((Renderer)_tintRenderer).material = _tintMat;
((Renderer)_tintRenderer).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)_tintRenderer).receiveShadows = false;
_tintGo.transform.SetParent(((Component)_cam).transform, false);
_tintGo.transform.localPosition = new Vector3(0f, 0f, 0.35f);
_tintGo.transform.localRotation = Quaternion.identity;
_tintGo.transform.localScale = new Vector3(1.4f, 1.4f, 1f);
_tintGo.SetActive(false);
((MelonBase)this).LoggerInstance.Msg("tint created cam=" + ((Object)_cam).name + " shader=" + ((Object)val).name);
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("tint failed: " + ex);
if ((Object)(object)_tintGo != (Object)null)
{
try
{
Object.Destroy((Object)(object)_tintGo);
}
catch
{
}
}
_tintGo = null;
_tintRenderer = null;
_tintMat = null;
}
}
private void UpdateTint(float dt)
{
//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_00be: Unknown result type (might be due to invalid IL or missing references)
if (_mode != 0)
{
EnsureTint();
}
if ((Object)(object)_tintGo == (Object)null || (Object)(object)_tintRenderer == (Object)null || (Object)(object)_tintMat == (Object)null)
{
_tintAlpha = 0f;
return;
}
float num = 0f;
if (_mode == 1 && _tintEnabled.Value)
{
num = Mathf.Clamp01(_tintIntensity.Value);
if (_rev)
{
num = Mathf.Clamp01(num * 1.35f);
}
}
_tintAlpha = Mathf.MoveTowards(_tintAlpha, num, dt * 1.2f);
Color color = _tintMat.color;
color.a = _tintAlpha;
_tintMat.color = color;
bool flag = _tintAlpha > 0.002f;
if (_tintGo.activeSelf != flag)
{
_tintGo.SetActive(flag);
}
}
private void StopAudio()
{
if ((Object)(object)_idleAudio != (Object)null)
{
try
{
_idleAudio.Stop();
}
catch
{
}
}
if ((Object)(object)_revAudio != (Object)null)
{
try
{
_revAudio.Stop();
}
catch
{
}
}
if ((Object)(object)_oneShot != (Object)null)
{
try
{
_oneShot.Stop();
}
catch
{
}
}
if ((Object)(object)_oneShot != (Object)null && (Object)(object)_stopClip != (Object)null)
{
try
{
_oneShot.PlayOneShot(_stopClip, Mathf.Max(0f, _volStop.Value));
}
catch
{
}
}
}
private void CacheRigColliders()
{
_rigColliders.Clear();
if ((Object)(object)_rig == (Object)null)
{
return;
}
Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(((Component)_rig).GetComponentsInChildren<Collider>(true));
if (array == null)
{
return;
}
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)null)
{
_rigColliders.Add(array[i]);
}
}
}
private void IgnoreRigCollisions(Saw s)
{
if (s == null || s.colliders.Count == 0)
{
return;
}
for (int i = 0; i < s.colliders.Count; i++)
{
Collider val = s.colliders[i];
if ((Object)(object)val == (Object)null)
{
continue;
}
for (int j = 0; j < _rigColliders.Count; j++)
{
Collider val2 = _rigColliders[j];
if (!((Object)(object)val2 == (Object)null))
{
try
{
Physics.IgnoreCollision(val, val2, true);
}
catch
{
}
}
}
}
}
private void EnsureStarter()
{
if (!_starterEnabled.Value || (Object)(object)_starterHandle != (Object)null || _starterTried || (Object)(object)_rig == (Object)null)
{
return;
}
if ((Object)(object)_prefab == (Object)null)
{
FindPrefab();
}
if ((Object)(object)_prefab == (Object)null)
{
return;
}
Transform val = _prefab.transform.Find("PullStartHandle");
if ((Object)(object)val == (Object)null)
{
return;
}
Transform val2 = _rig.Find("HexaBody/PlayerHexaPelvis");
if ((Object)(object)val2 == (Object)null)
{
val2 = _rig.Find("PhysicalUpperBody2/Body/Pelvis");
}
if ((Object)(object)val2 == (Object)null)
{
return;
}
_starterTried = true;
try
{
BuildStarter(val, val2);
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("starter build failed: " + ex);
}
}
private void BuildStarter(Transform handleSrc, Transform chest)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_003f: 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_00a7: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: 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_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_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Expected O, but got Unknown
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
CacheRigColliders();
GameObject val = new GameObject("DenjiStarterAnchor");
val.transform.SetParent(chest, false);
val.transform.localPosition = new Vector3(0f, _starterDown.Value, _starterOut.Value);
val.transform.localRotation = Quaternion.identity;
_starterAnchor = val.transform;
Rigidbody obj = val.AddComponent<Rigidbody>();
obj.isKinematic = true;
obj.useGravity = false;
GameObject val2 = Object.Instantiate<GameObject>(((Component)handleSrc).gameObject);
((Object)val2).name = "DenjiStarterHandle";
val2.transform.SetParent(_starterAnchor, false);
val2.transform.localPosition = Vector3.zero;
val2.transform.localRotation = Quaternion.Euler(10.7f, 0f, 0f);
val2.transform.localScale = Vector3.one * _starterScale.Value;
_starterBaseRot = val2.transform.localRotation;
_starterBasePos = val2.transform.localPosition;
_starterHandle = val2.transform;
_starterGrab = val2.GetComponent<HVRGrabbable>();
_starterRb = val2.GetComponent<Rigidbody>();
if ((Object)(object)_starterRb == (Object)null)
{
_starterRb = val2.AddComponent<Rigidbody>();
_starterRb.mass = 0.3f;
}
if ((Object)(object)_starterGrab != (Object)null)
{
((Behaviour)_starterGrab).enabled = false;
}
Transform val3 = val2.transform.Find("CableEndPoint");
_cableEnd = (((Object)(object)val3 != (Object)null) ? val3 : val2.transform);
GameObject val4 = new GameObject("DenjiStarterCableStart");
val4.transform.SetParent(_starterAnchor.parent, false);
val4.transform.localPosition = new Vector3(0f, _starterDown.Value + 0.06f, _starterOut.Value * 0.5f);
_cableStart = val4.transform;
PullStartHandleManager component = val2.GetComponent<PullStartHandleManager>();
if ((Object)(object)component != (Object)null)
{
((Behaviour)component).enabled = false;
}
if ((Object)(object)_starterRb != (Object)null)
{
_starterRb.useGravity = false;
_starterRb.drag = 2f;
_starterRb.angularDrag = 8f;
_starterRb.interpolation = (RigidbodyInterpolation)1;
_starterRb.isKinematic = true;
}
ConfigurableJoint component2 = val2.GetComponent<ConfigurableJoint>();
if ((Object)(object)component2 != (Object)null)
{
Object.Destroy((Object)(object)component2);
}
Transform val5 = _prefab.transform.Find("PullStartCable");
if ((Object)(object)val5 != (Object)null)
{
GameObject val6 = Object.Instantiate<GameObject>(((Component)val5).gameObject);
((Object)val6).name = "DenjiStarterCable";
val6.transform.SetParent(_starterAnchor, false);
val6.transform.localPosition = Vector3.zero;
val6.transform.localRotation = Quaternion.identity;
_starterCable = val6.GetComponent<LineRenderer>();
if ((Object)(object)_starterCable != (Object)null)
{
_starterCable.useWorldSpace = true;
_starterCable.positionCount = 2;
}
}
if ((Object)(object)_starterRb != (Object)null)
{
Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(val2.GetComponentsInChildren<Collider>(true));
foreach (Collider val7 in array)
{
if ((Object)(object)val7 == (Object)null)
{
continue;
}
for (int j = 0; j < _rigColliders.Count; j++)
{
Collider val8 = _rigColliders[j];
if (!((Object)(object)val8 == (Object)null))
{
try
{
Physics.IgnoreCollision(val7, val8, true);
}
catch
{
}
}
}
}
}
Instance loggerInstance = ((MelonBase)this).LoggerInstance;
string[] obj3 = new string[12]
{
"starter built at ",
PathOf(_starterAnchor),
" world=",
null,
null,
null,
null,
null,
null,
null,
null,
null
};
Vector3 position = _starterAnchor.position;
obj3[3] = ((Vector3)(ref position)).ToString("F3");
obj3[4] = " rb=";
obj3[5] = ((Object)(object)_starterRb != (Object)null).ToString();
obj3[6] = " grab=";
obj3[7] = ((Object)(object)_starterGrab != (Object)null).ToString();
obj3[8] = " joint=";
obj3[9] = ((Object)(object)component2 != (Object)null).ToString();
obj3[10] = " cable=";
obj3[11] = ((Object)(object)_starterCable != (Object)null).ToString();
loggerInstance.Msg(string.Concat(obj3));
}
private void UpdateStarter()
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: 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_0288: 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_0298: 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_0124: 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_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_starterAnchor == (Object)null || (Object)(object)_starterHandle == (Object)null)
{
return;
}
float deltaTime = Time.deltaTime;
if ((Object)(object)_starterCable != (Object)null && (Object)(object)_cableStart != (Object)null && (Object)(object)_cableEnd != (Object)null)
{
_starterCable.SetPosition(0, _cableStart.position);
_starterCable.SetPosition(1, _cableEnd.position);
}
HVRController c = (((Object)(object)_inputs != (Object)null) ? _inputs.LeftController : null);
HVRController c2 = (((Object)(object)_inputs != (Object)null) ? _inputs.RightController : null);
bool flag = IsTrigger(c);
bool flag2 = IsTrigger(c2);
if (!_starterHeld)
{
float num = (((Object)(object)_leftHand != (Object)null) ? Vector3.Distance(_leftHand.position, _starterHandle.position) : 99f);
float num2 = (((Object)(object)_rightHand != (Object)null) ? Vector3.Distance(_rightHand.position, _starterHandle.position) : 99f);
if (_mode == 0)
{
if (flag && (Object)(object)_leftHand != (Object)null && !IsGrabbing(_leftGrabber) && num < 0.2f)
{
BeginHold(_leftHand);
}
else if (flag2 && (Object)(object)_rightHand != (Object)null && !IsGrabbing(_rightGrabber) && num2 < 0.2f)
{
BeginHold(_rightHand);
}
}
_starterHandle.localPosition = Vector3.Lerp(_starterHandle.localPosition, _starterBasePos, deltaTime * 14f);
_starterHandle.localRotation = Quaternion.Slerp(_starterHandle.localRotation, _starterBaseRot, deltaTime * 14f);
}
else if (_mode != 0)
{
EndHold();
}
else
{
if ((Object)(object)_starterHand != (Object)null)
{
_starterHandle.localPosition = _starterAnchor.InverseTransformPoint(_starterHand.position);
_starterHandle.rotation = _starterHand.rotation * _starterGrip;
}
if (!(((Object)(object)_starterHand == (Object)(object)_leftHand) ? flag : flag2) || (Object)(object)_starterHand == (Object)null)
{
EndHold();
}
}
Vector3 val = _starterHandle.localPosition - _starterBasePos;
float magnitude = ((Vector3)(ref val)).magnitude;
if (_starterHeld && !_pulled && magnitude >= _starterPull.Value && _mode == 0)
{
_pulled = true;
_pullTimer = _starterDelay.Value;
}
if (_pullTimer > 0f)
{
_pullTimer -= deltaTime;
if (_pullTimer <= 0f && _mode == 0)
{
Toggle();
}
}
if (!_starterHeld && magnitude < 0.05f)
{
_pulled = false;
}
}
private bool IsHandCollider(Collider c)
{
Transform val = ((Component)c).transform;
while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)_rig)
{
string name = ((Object)val).name;
if (name == "Physics LeftHand" || name == "Physics RightHand")
{
return true;
}
val = val.parent;
}
return false;
}
private static bool IsTrigger(HVRController c)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)c == (Object)null)
{
return false;
}
try
{
return c.TriggerButtonState.Active;
}
catch
{
return false;
}
}
private static bool IsGrabbing(HVRHandGrabber g)
{
try
{
return (Object)(object)g != (Object)null && ((HVRGrabberBase)g).IsGrabbing;
}
catch
{
return false;
}
}
private void BeginHold(Transform hand)
{
//IL_0010: 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_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: 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)
_starterHeld = true;
_starterHand = hand;
_starterGrip = Quaternion.Inverse(hand.rotation) * _starterHandle.rotation;
_pulled = false;
_pullTimer = 0f;
SetHandCollision(hand, ignore: true);
((MelonBase)this).LoggerInstance.Msg("hold start " + ((Object)hand).name);
}
private void EndHold()
{
_starterHeld = false;
_starterHand = null;
((MelonBase)this).LoggerInstance.Msg("hold end");
}
private void SetHandCollision(Transform hand, bool ignore)
{
if ((Object)(object)hand == (Object)null || (Object)(object)_starterHandle == (Object)null)
{
return;
}
Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(((Component)_starterHandle).GetComponentsInChildren<Collider>(true));
Collider[] array2 = Il2CppArrayBase<Collider>.op_Implicit(((Component)hand).GetComponentsInChildren<Collider>(true));
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] == (Object)null)
{
continue;
}
for (int j = 0; j < array2.Length; j++)
{
if (!((Object)(object)array2[j] == (Object)null))
{
try
{
Physics.IgnoreCollision(array[i], array2[j], ignore);
}
catch
{
}
}
}
}
}
private void FindPrefab()
{
//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)
try
{
GameObject[] array = Il2CppArrayBase<GameObject>.op_Implicit(Resources.FindObjectsOfTypeAll<GameObject>());
if (array == null)
{
return;
}
GameObject val = null;
GameObject val2 = null;
foreach (GameObject val3 in array)
{
if ((Object)(object)val3 == (Object)null)
{
continue;
}
string name = ((Object)val3).name;
if (name != "Chainsaw" && name != "Chainsaw(Clone)")
{
continue;
}
string value = "";
try
{
Scene scene = val3.scene;
value = ((Scene)(ref scene)).name ?? "";
}
catch
{
}
string text = (((Object)(object)val3.transform.parent != (Object)null) ? ((Object)val3.transform.parent).name : "ROOT");
string text2 = (((Object)(object)val3.transform.root != (Object)null) ? ((Object)val3.transform.root).name : "?");
if (!((Object)(object)val3.GetComponent<ChainsawManager>() == (Object)null) && !IsChildOfShopStand(val3.transform) && !text.Contains("Variant") && !text.Contains("itemTab"))
{
if (string.IsNullOrEmpty(value) && text == "ROOT")
{
val = val3;
break;
}
if ((Object)(object)val2 == (Object)null && text == "ROOT" && text2 == name)
{
val2 = val3;
}
}
}
if ((Object)(object)val != (Object)null)
{
_prefab = val;
}
else if ((Object)(object)val2 != (Object)null)
{
_prefab = val2;
}
if ((Object)(object)_prefab != (Object)null)
{
((MelonBase)this).LoggerInstance.Msg("chainsaw prefab=" + ((Object)_prefab).name);
}
DumpProbe();
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("prefab search failed: " + ex.Message);
}
}
private void DumpRigNames(Transform t, int depth)
{
//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)
for (int i = 0; i < t.childCount; i++)
{
Transform child = t.GetChild(i);
string text = ((Object)child).name.ToLower();
if (text.Contains("chest") || text.Contains("spine") || text.Contains("torso") || text.Contains("neck") || text.Contains("hip") || text.Contains("pelvis"))
{
Instance loggerInstance = ((MelonBase)this).LoggerInstance;
string text2 = PathOf(child);
Vector3 position = child.position;
loggerInstance.Msg("rigbone " + text2 + " pos=" + ((Vector3)(ref position)).ToString("F3"));
}
if (depth < 2)
{
DumpRigNames(child, depth + 1);
}
}
}
private void DumpProbe()
{
if (_dumpedProbe)
{
return;
}
_dumpedProbe = true;
if (!((Object)(object)_prefab == (Object)null))
{
((MelonBase)this).LoggerInstance.Msg("chainsaw prefab=" + ((Object)_prefab).name);
if ((Object)(object)_prefab.transform.Find("PullStartHandle") == (Object)null)
{
((MelonBase)this).LoggerInstance.Warning("PullStartHandle missing in prefab");
}
}
}
private static string PathOf(Transform t)
{
string text = ((Object)t).name;
Transform parent = t.parent;
while ((Object)(object)parent != (Object)null)
{
text = ((Object)parent).name + "/" + text;
parent = parent.parent;
}
return text;
}
private void DumpT(Transform t, int depth)
{
}
private static bool IsCuttingPart(Transform t)
{
Transform val = t;
int num = 0;
while ((Object)(object)val != (Object)null && num < 20)
{
string text = ((Object)val).name.ToLower();
if (text == "bar" || text.Contains("chainsawchain"))
{
return true;
}
val = val.parent;
num++;
}
return false;
}
private static bool IsChildOfShopStand(Transform t)
{
Transform val = t;
int num = 0;
while ((Object)(object)val != (Object)null && num < 20)
{
string name = ((Object)val).name;
if (name.Contains("ShopStand") || name.Contains("WallSocket") || name.Contains("WeaponWall") || name.Contains("MeleeWall") || name.Contains("itemTab") || name.Contains("modItemTab"))
{
return true;
}
val = val.parent;
num++;
}
return false;
}
private void CleanupAll()
{
DestroySaw(_leftSaw);
DestroySaw(_rightSaw);
DestroySaw(_headSaw);
_leftSaw = null;
_rightSaw = null;
_headSaw = null;
if ((Object)(object)_audioGo != (Object)null)
{
try
{
Object.Destroy((Object)(object)_audioGo);
}
catch
{
}
}
if ((Object)(object)_tintGo != (Object)null)
{
try
{
Object.Destroy((Object)(object)_tintGo);
}
catch
{
}
}
if ((Object)(object)_starterAnchor != (Object)null)
{
try
{
Object.Destroy((Object)(object)((Component)_starterAnchor).gameObject);
}
catch
{
}
}
if ((Object)(object)_cableStart != (Object)null)
{
try
{
Object.Destroy((Object)(object)((Component)_cableStart).gameObject);
}
catch
{
}
}
_starterAnchor = null;
_starterHandle = null;
_cableStart = null;
_cableEnd = null;
_starterHand = null;
_starterHeld = false;
_starterRb = null;
_starterGrab = null;
_starterCable = null;
_starterTried = false;
_pulled = false;
_audioGo = null;
_idleAudio = null;
_revAudio = null;
_oneShot = null;
_startClip = null;
_stopClip = null;
_tintGo = null;
_tintRenderer = null;
_tintMat = null;
_tintAlpha = 0f;
_mode = 0;
_rev = false;
_wasB = false;
_voiceDelay = 0f;
_engineDelay = 0f;
_prefab = null;
_rig = null;
_inputs = null;
_leftGrabber = null;
_rightGrabber = null;
_leftHand = null;
_rightHand = null;
_cam = null;
_camTimer = 0f;
_searchTimer = 0f;
_bindTimer = 0f;
_rigColliders.Clear();
}
private static void DestroyComponentByName(GameObject obj, string componentName)
{
try
{
Component[] array = Il2CppArrayBase<Component>.op_Implicit(obj.GetComponents<Component>());
if (array == null)
{
return;
}
foreach (Component val in array)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
string text = "";
try
{
Type il2CppType = ((Object)val).GetIl2CppType();
text = ((il2CppType != null) ? ((MemberInfo)il2CppType).Name : null) ?? ((object)val).GetType().Name;
}
catch
{
}
if (!(text != componentName))
{
try
{
Object.Destroy((Object)(object)val);
}
catch
{
}
}
}
}
catch
{
}
}
private static void DisableComponentByName(GameObject obj, string componentName)
{
try
{
Component[] array = Il2CppArrayBase<Component>.op_Implicit(obj.GetComponents<Component>());
if (array == null)
{
return;
}
foreach (Component val in array)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
string text = "";
try
{
Type il2CppType = ((Object)val).GetIl2CppType();
text = ((il2CppType != null) ? ((MemberInfo)il2CppType).Name : null) ?? ((object)val).GetType().Name;
}
catch
{
}
if (text != componentName)
{
continue;
}
try
{
Behaviour val2 = ((Il2CppObjectBase)val).TryCast<Behaviour>();
if ((Object)(object)val2 != (Object)null)
{
val2.enabled = false;
}
}
catch
{
}
}
}
catch
{
}
}
private static GameObject FindRigByPrefix()
{
Transform[] array = Il2CppArrayBase<Transform>.op_Implicit(Object.FindObjectsOfType<Transform>(true));
if (array == null)
{
return null;
}
for (int i = 0; i < array.Length; i++)
{
if (!((Object)(object)array[i] == (Object)null) && ((Object)array[i]).name.StartsWith("Hexa4Rig", StringComparison.OrdinalIgnoreCase))
{
return ((Component)array[i]).gameObject;
}
}
return null;
}
private static Transform FindDeep(Transform root, string name)
{
if ((Object)(object)root == (Object)null)
{
return null;
}
if (((Object)root).name == name)
{
return root;
}
Transform[] array = Il2CppArrayBase<Transform>.op_Implicit(((Component)root).GetComponentsInChildren<Transform>(true));
if (array == null)
{
return null;
}
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)null && ((Object)array[i]).name == name)
{
return array[i];
}
}
return null;
}
}
internal static class Mci
{
public static string LastError;
[DllImport("winmm.dll", CharSet = CharSet.Ansi, EntryPoint = "mciSendStringA")]
private static extern int mciSendString(string cmd, StringBuilder buf, int bufSize, IntPtr cb);
private static int Send(string cmd)
{
try
{
StringBuilder stringBuilder = new StringBuilder(256);
int num = mciSendString(cmd, stringBuilder, stringBuilder.Capacity, IntPtr.Zero);
if (num != 0)
{
LastError = cmd + " -> " + num;
}
return num;
}
catch (Exception ex)
{
LastError = ex.Message;
return -1;
}
}
public static bool Open(string alias, string path, float volume)
{
Send("close " + alias);
if (Send("open \"" + path + "\" type waveaudio alias " + alias) != 0)
{
return false;
}
Send("set " + alias + " time format milliseconds");
float num = volume;
if (num < 0f)
{
num = 0f;
}
if (num > 1f)
{
num = 1f;
}
Send("setaudio " + alias + " volume to " + (int)Math.Round(num * 1000f));
return true;
}
public static bool Play(string alias)
{
if (Send("seek " + alias + " to start") != 0)
{
return false;
}
return Send("play " + alias) == 0;
}
public static void Close(string alias)
{
Send("close " + alias);
}
}
}