Decompiled source of MGCarryHandle Attachment v1.0.0
MGCarryHandle_Attachment.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using FistVR; using HarmonyLib; using OpenScripts2; using OtherLoader; using UnityEditor; using UnityEngine; using UnityEngine.UI; using VolksScripts; [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 VolksScripts { public class NVGPowerSwitch : FVRInteractiveObject { public PIPScope Scope; [HideInInspector] public bool Toggle = true; public override void SimpleInteraction(FVRViveHand hand) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).SimpleInteraction(hand); SM.PlayCoreSound((FVRPooledAudioType)10, ManagerSingleton<SM>.Instance.AudioEvent_AttachmentClick_Minor, ((Component)this).transform.position); if (Toggle) { Scope.enableNightvision = (Scope.enableThermal = false); } else { Scope.enableNightvision = (Scope.enableThermal = true); } Toggle = !Toggle; } } public class ANVIS21Control : MonoBehaviour { public Transform armreal; public Transform armfake; public PIPScope scopeL; public PIPScope scopeR; public float onspeed = 0.5f; public float offspeed = 0.5f; public AudioEvent powerOn; public AudioEvent powerOff; public bool isOn; private float gainVelL; private float gainVelR; private float brightVelL; private float brightVelR; public bool IsOn => isOn; private void Start() { SetScopesImmediate(0f); } private void Update() { SyncArms(); UpdateNVG(); } public void SetPower(bool value) { //IL_006d: 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) if (isOn == value) { return; } isOn = value; if (isOn) { if (powerOn != null) { SM.PlayCoreSound((FVRPooledAudioType)10, powerOn, ((Component)this).transform.position); } } else if (powerOff != null) { SM.PlayCoreSound((FVRPooledAudioType)10, powerOff, ((Component)this).transform.position); } } private void SyncArms() { //IL_0035: 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) if (!((Object)(object)armreal == (Object)null) && !((Object)(object)armfake == (Object)null)) { armfake.localPosition = armreal.localPosition; armfake.localRotation = armreal.localRotation; } } private void UpdateNVG() { float num = ((!isOn) ? 0f : 1f); float num2 = ((!isOn) ? offspeed : onspeed); if ((Object)(object)scopeL != (Object)null) { scopeL.nvDef.nightVisionTargetBrightness = Mathf.SmoothDamp(scopeL.nvDef.nightVisionTargetBrightness, num, ref brightVelL, num2); scopeL.nightVisionManualGainFactor = Mathf.SmoothDamp(scopeL.nightVisionManualGainFactor, num, ref gainVelL, num2); ((Behaviour)scopeL).enabled = true; scopeL.UpdateParameters(); } if ((Object)(object)scopeR != (Object)null) { scopeR.nvDef.nightVisionTargetBrightness = Mathf.SmoothDamp(scopeR.nvDef.nightVisionTargetBrightness, num, ref brightVelR, num2); scopeR.nightVisionManualGainFactor = Mathf.SmoothDamp(scopeR.nightVisionManualGainFactor, num, ref gainVelR, num2); ((Behaviour)scopeR).enabled = true; scopeR.UpdateParameters(); } } private void SetScopesImmediate(float value) { if ((Object)(object)scopeL != (Object)null) { scopeL.nvDef.nightVisionTargetBrightness = value; scopeL.nightVisionManualGainFactor = value; } if ((Object)(object)scopeR != (Object)null) { scopeR.nvDef.nightVisionTargetBrightness = value; scopeR.nightVisionManualGainFactor = value; } } } public class ANVIS21PowerSwitch : FVRInteractiveObject { public ANVIS21Control control; public Transform switchTransform; public Vector3 offEulerAngles; public Vector3 onEulerAngles; public float lerpSpeed = 8f; private float m_lerp; protected void Awake() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).Awake(); if ((Object)(object)switchTransform == (Object)null) { switchTransform = ((Component)this).transform; } if ((Object)(object)control != (Object)null) { m_lerp = ((!control.IsOn) ? 0f : 1f); switchTransform.localEulerAngles = Vector3.Lerp(offEulerAngles, onEulerAngles, m_lerp); } } public override void SimpleInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).SimpleInteraction(hand); if (!((Object)(object)control == (Object)null)) { control.SetPower(!control.IsOn); } } protected void FVRUpdate() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).FVRUpdate(); if (!((Object)(object)control == (Object)null) && !((Object)(object)switchTransform == (Object)null)) { float num = ((!control.IsOn) ? 0f : 1f); m_lerp = Mathf.MoveTowards(m_lerp, num, Time.deltaTime * lerpSpeed); switchTransform.localEulerAngles = Vector3.Lerp(offEulerAngles, onEulerAngles, m_lerp); } } } } public class ForceBindToHead : MonoBehaviour { [Tooltip("The object that should follow the player's head (e.g. NVG physical root).")] public GameObject phys; [Tooltip("Optional: if true, runs even when not equipped.")] public bool alwaysFollow = true; private Transform headTransform; private void Start() { if ((Object)(object)GM.CurrentMovementManager != (Object)null && (Object)(object)GM.CurrentMovementManager.Head != (Object)null) { headTransform = ((Component)GM.CurrentMovementManager.Head).transform; } else { Debug.LogWarning((object)"[ForceBindToHead] Could not find head transform."); } } private void FixedUpdate() { //IL_00ac: 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) if (!((Object)(object)phys == (Object)null) && (alwaysFollow || !((Object)(object)headTransform == (Object)null))) { if ((Object)(object)headTransform == (Object)null && (Object)(object)GM.CurrentMovementManager != (Object)null) { headTransform = ((Component)GM.CurrentMovementManager.Head).transform; } if ((Object)(object)phys.transform.parent != (Object)(object)headTransform) { phys.transform.SetParent(headTransform); } phys.transform.localPosition = Vector3.zero; phys.transform.localEulerAngles = Vector3.zero; } } } public class BaffleSuppressor : Suppressor { public enum PerceptionMode { Automatic, ForceEnvironment, UseVolumeOnly } [Header("Baffle (wear) settings")] [Tooltip("Max integrity (brand new).")] public int MaxIntegrity = 10; [Tooltip("Current integrity (MaxIntegrity = new, 0 = broken).")] [Range(0f, 100f)] public int Integrity = 10; [Tooltip("Integrity lost per shot.")] public int WearPerShot = 1; [Tooltip("Multiplier applied to loudness at full integrity (very quiet).")] [Range(0f, 1f)] public float QuietMultiplierAtFull = 0.12f; [Tooltip("Multiplier applied to loudness when fully broken (typically 1).")] [Range(0f, 2f)] public float LoudMultiplierAtBroken = 1f; [Header("Suppressor audio (played by this suppressor)")] [Tooltip("Clip played as the primary suppressed shot. If null, suppressor will still attempt to mute nearby audio but won't play a replacement.")] public AudioClip SuppressedShotClip; [Tooltip("Optional tail/ambience clip to complement the suppressed shot.")] public AudioClip SuppressedTailClip; [Tooltip("Base volume multiplier for suppressed shot clip (before applying integrity multiplier).")] [Range(0f, 2f)] public float SuppressedShotBaseVolume = 1f; [Tooltip("Base volume multiplier for suppressed tail clip.")] [Range(0f, 2f)] public float SuppressedTailBaseVolume = 1f; [Header("Visuals")] [Tooltip("GameObject root for intact visual (enable when not broken).")] public GameObject IntactVisual; [Tooltip("GameObject root for broken visual (enable when broken).")] public GameObject BrokenVisual; [Header("Feedback")] [Tooltip("Clip played when suppressor breaks.")] public AudioClip BreakClip; [Tooltip("Local audio source used for PlayOneShot; if null PlayClipAtPoint is used.")] public AudioSource LocalAudioSource; [Tooltip("If > 0, auto-repair after this many seconds (debugging/testing). 0 = disabled.")] public float AutoRepairAfterSeconds = 0f; [Header("Audio-silencing tuning (best-effort)")] [Tooltip("Radius around muzzle within which playing AudioSources may be considered gunshot audio (meters).")] public float MuzzleSilenceRadius = 0.75f; [Tooltip("Maximum age (seconds) of a recent AudioSource play to consider it for silencing.")] public float RecentPlayMaxAge = 0.2f; [Tooltip("Time (seconds) to fade an AudioSource's volume to zero before stopping it.")] public float FadeOutTime = 0.04f; [Header("Perception / Environment")] [Tooltip("How perception is reported to the scene (affects AI hearing/travel distance).")] public PerceptionMode PerceptionBehavior = PerceptionMode.Automatic; [Tooltip("When PerceptionBehavior == ForceEnvironment, use this environment for travel multiplier lookups.")] public FVRSoundEnvironment ForcedEnvironment = (FVRSoundEnvironment)11; [Tooltip("When PerceptionBehavior == UseVolumeOnly, scale perceived primary loudness by this multiplier (independent of environment).")] [Range(0f, 10f)] public float PerceptionVolumeMultiplier = 1f; [Header("Debris & Hole visuals")] [Tooltip("Optional debris prefab spawned when the suppressor breaks.")] public GameObject DebrisPrefab; [Tooltip("Spawn debris when the suppressor breaks.")] public bool SpawnDebrisOnBreak = true; [Tooltip("Min scale applied to spawned debris.")] public Vector3 DebrisScaleMin = new Vector3(0.2f, 0.2f, 0.2f); [Tooltip("Max scale applied to spawned debris.")] public Vector3 DebrisScaleMax = new Vector3(1.5f, 1.5f, 1.5f); [Tooltip("Lifetime of spawned debris (0 = no auto-destroy).")] public float DebrisLifetime = 5f; [Tooltip("Optional transform used as an animated 'hole' visual; its scale is driven by damage.")] public Transform HoleVisual; [Tooltip("Scale when intact (usually small or 0).")] public Vector3 HoleScaleAtIntact = Vector3.zero; [Tooltip("Scale when fully broken.")] public Vector3 HoleScaleAtBroken = Vector3.one; [Tooltip("How long to animate hole scale changes.")] public float HoleScaleAnimTime = 0.15f; private bool _isBroken = false; private readonly Dictionary<AudioSource, float> _audioPlayStart = new Dictionary<AudioSource, float>(); private FVRFireArm _cachedFirearm = null; private FVRFireArm _lastShotFirearm = null; private Coroutine _holeAnimCoroutine = null; public bool IsBroken => _isBroken; public override void Awake() { ((MuzzleDevice)this).Awake(); MaxIntegrity = Mathf.Max(1, MaxIntegrity); Integrity = Mathf.Clamp(Integrity, 0, MaxIntegrity); _isBroken = Integrity <= 0; ApplyVisualState(); UpdateHoleVisualImmediate(); } public float GetSuppressionMultiplier() { if (MaxIntegrity <= 0) { return LoudMultiplierAtBroken; } if (IsBroken) { return LoudMultiplierAtBroken; } float num = 1f - (float)Integrity / (float)MaxIntegrity; return Mathf.Lerp(QuietMultiplierAtFull, LoudMultiplierAtBroken, num); } public override void OnShot(FVRFireArm firearm, FVRTailSoundClass tailClass) { //IL_0004: 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) try { ((MuzzleDevice)this).OnShot(firearm, tailClass); } catch { } _lastShotFirearm = firearm; if (!IsBroken) { AttemptSilenceRecentAudioNearMuzzle(firearm); PlaySuppressedAudio(firearm); } NotifyPerception(firearm, tailClass); ApplyWear(); } private void AttemptSilenceRecentAudioNearMuzzle(FVRFireArm firearm) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; try { if ((Object)(object)firearm != (Object)null) { Transform muzzle = firearm.GetMuzzle(); if ((Object)(object)muzzle != (Object)null) { position = muzzle.position; } } } catch { } AudioSource[] array = Object.FindObjectsOfType<AudioSource>(); float time = Time.time; foreach (AudioSource val in array) { if (!((Object)(object)val == (Object)null)) { bool isPlaying = val.isPlaying; bool flag = _audioPlayStart.ContainsKey(val); if (isPlaying && !flag) { _audioPlayStart[val] = time; } else if (!isPlaying && flag) { _audioPlayStart.Remove(val); } } } List<AudioSource> list = new List<AudioSource>(); foreach (KeyValuePair<AudioSource, float> item in _audioPlayStart) { AudioSource key = item.Key; float value = item.Value; if (!((Object)(object)key == (Object)null) && key.isPlaying && !(time - value > RecentPlayMaxAge) && (!((Object)(object)LocalAudioSource != (Object)null) || !((Object)(object)key == (Object)(object)LocalAudioSource))) { Vector3 position2 = ((Component)key).transform.position; float num = Vector3.Distance(position2, position); if (num <= MuzzleSilenceRadius && (!((Object)(object)key.clip != (Object)null) || !(key.clip.length > 5f))) { list.Add(key); } } } for (int j = 0; j < list.Count; j++) { AudioSource s = list[j]; ((MonoBehaviour)this).StartCoroutine(FadeOutAndStopAudio(s, FadeOutTime)); } } private IEnumerator FadeOutAndStopAudio(AudioSource s, float fadeTime) { if ((Object)(object)s == (Object)null) { yield break; } float startVol = s.volume; float t = 0f; while (t < fadeTime) { if ((Object)(object)s == (Object)null) { yield break; } t += Time.deltaTime; float mul = 1f - Mathf.Clamp01(t / fadeTime); try { s.volume = startVol * mul; } catch { } yield return null; } try { s.Stop(); s.volume = startVol; } catch { } if (_audioPlayStart.ContainsKey(s)) { _audioPlayStart.Remove(s); } } private void PlaySuppressedAudio(FVRFireArm firearm) { //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_0132: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) float suppressionMultiplier = GetSuppressionMultiplier(); float num = 1f; if ((Object)(object)SuppressedShotClip != (Object)null) { Vector3 val = ((Component)this).transform.position; try { if ((Object)(object)firearm != (Object)null) { Transform muzzle = firearm.GetMuzzle(); val = ((!((Object)(object)muzzle != (Object)null)) ? ((Component)firearm).transform.position : muzzle.position); } } catch { } float num2 = Mathf.Clamp01(SuppressedShotBaseVolume * suppressionMultiplier * num); if ((Object)(object)LocalAudioSource != (Object)null) { LocalAudioSource.PlayOneShot(SuppressedShotClip, num2); } else { AudioSource.PlayClipAtPoint(SuppressedShotClip, val, num2); } } if (!((Object)(object)SuppressedTailClip != (Object)null)) { return; } Vector3 position = ((Component)this).transform.position; try { if ((Object)(object)firearm != (Object)null) { Transform muzzle2 = firearm.GetMuzzle(); if ((Object)(object)muzzle2 != (Object)null) { position = muzzle2.position; } } } catch { } float num3 = Mathf.Clamp01(SuppressedTailBaseVolume * suppressionMultiplier * num); AudioSource.PlayClipAtPoint(SuppressedTailClip, position, num3); } private void NotifyPerception(FVRFireArm firearm, FVRTailSoundClass tailClass) { //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_008c: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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) try { Vector3 position = ((Component)this).transform.position; if ((Object)(object)firearm != (Object)null) { Transform muzzle = firearm.GetMuzzle(); if ((Object)(object)muzzle != (Object)null) { position = muzzle.position; } } float suppressionMultiplier = GetSuppressionMultiplier(); FVRSoundEnvironment val = (FVRSoundEnvironment)11; float num = 1f; int num2 = 0; try { num2 = GM.CurrentPlayerBody.GetPlayerIFF(); } catch { } if (PerceptionBehavior == PerceptionMode.Automatic) { try { val = GM.CurrentPlayerBody.GetCurrentSoundEnvironment(); } catch { } try { num = SM.GetSoundTravelDistanceMultByEnvironment(val); } catch { num = 1f; } } else if (PerceptionBehavior == PerceptionMode.ForceEnvironment) { val = ForcedEnvironment; try { num = SM.GetSoundTravelDistanceMultByEnvironment(val); } catch { num = 1f; } } else { num = 1f; } float num3 = 1f * suppressionMultiplier; if (PerceptionBehavior == PerceptionMode.UseVolumeOnly) { num3 *= PerceptionVolumeMultiplier; } float num4 = num3 * num * 0.5f; GM.CurrentSceneSettings.OnPerceiveableSound(num3, num4, position, num2, GM.CurrentPlayerBody.PlayerEntities[0]); } catch { } } private void ApplyWear() { if (!IsBroken) { Integrity -= WearPerShot; Integrity = Mathf.Clamp(Integrity, 0, MaxIntegrity); UpdateHoleVisual(); if (Integrity <= 0) { Integrity = 0; BreakSuppressor(); } } } private void BreakSuppressor() { //IL_0118: 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_0076: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if (_isBroken) { return; } _isBroken = true; ApplyVisualState(); if ((Object)(object)LocalAudioSource != (Object)null && (Object)(object)BreakClip != (Object)null) { LocalAudioSource.PlayOneShot(BreakClip); } else if ((Object)(object)BreakClip != (Object)null) { AudioSource.PlayClipAtPoint(BreakClip, ((Component)this).transform.position, 1f); } if (SpawnDebrisOnBreak && (Object)(object)DebrisPrefab != (Object)null) { Vector3 position = ((Component)this).transform.position; Quaternion rot = Quaternion.identity; if ((Object)(object)_lastShotFirearm != (Object)null) { try { Transform muzzle = _lastShotFirearm.GetMuzzle(); if ((Object)(object)muzzle != (Object)null) { position = muzzle.position; rot = muzzle.rotation; } else { position = ((Component)_lastShotFirearm).transform.position; } } catch { } } SpawnDebrisAt(position, rot, 1f); } if (AutoRepairAfterSeconds > 0f) { ((MonoBehaviour)this).StartCoroutine(AutoRepairCoroutine(AutoRepairAfterSeconds)); } } private IEnumerator AutoRepairCoroutine(float seconds) { yield return (object)new WaitForSeconds(seconds); RepairToFull(); } protected void ApplyVisualState() { if ((Object)(object)IntactVisual != (Object)null) { IntactVisual.SetActive(!_isBroken); } if ((Object)(object)BrokenVisual != (Object)null) { BrokenVisual.SetActive(_isBroken); } } public void RepairToFull() { Integrity = MaxIntegrity; _isBroken = false; ApplyVisualState(); UpdateHoleVisualImmediate(); } private void SpawnDebrisAt(Vector3 pos, Quaternion rot, float damageT) { //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_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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)DebrisPrefab == (Object)null) { return; } try { GameObject val = Object.Instantiate<GameObject>(DebrisPrefab, pos, rot); if ((Object)(object)val != (Object)null) { Vector3 localScale = Vector3.Lerp(DebrisScaleMin, DebrisScaleMax, Mathf.Clamp01(damageT)); val.transform.localScale = localScale; if (DebrisLifetime > 0f) { Object.Destroy((Object)(object)val, DebrisLifetime); } } } catch { } } private IEnumerator AnimateHoleScale(Transform tform, Vector3 target, float duration) { //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) if ((Object)(object)tform == (Object)null) { yield break; } Vector3 start = tform.localScale; float elapsed = 0f; while (elapsed < duration) { elapsed += Time.deltaTime; float i = Mathf.Clamp01(elapsed / duration); try { tform.localScale = Vector3.Lerp(start, target, i); } catch { } yield return null; } try { tform.localScale = target; } catch { } _holeAnimCoroutine = null; } private void UpdateHoleVisualImmediate() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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) if ((Object)(object)HoleVisual == (Object)null) { return; } float num = 1f - (float)Integrity / (float)MaxIntegrity; Vector3 localScale = Vector3.Lerp(HoleScaleAtIntact, HoleScaleAtBroken, Mathf.Clamp01(num)); try { HoleVisual.localScale = localScale; } catch { } } private void UpdateHoleVisual() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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) if (!((Object)(object)HoleVisual == (Object)null)) { float num = 1f - (float)Integrity / (float)MaxIntegrity; Vector3 target = Vector3.Lerp(HoleScaleAtIntact, HoleScaleAtBroken, Mathf.Clamp01(num)); if (_holeAnimCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_holeAnimCoroutine); } _holeAnimCoroutine = ((MonoBehaviour)this).StartCoroutine(AnimateHoleScale(HoleVisual, target, HoleScaleAnimTime)); } } public override void AttachToMount(FVRFireArmAttachmentMount m, bool playSound) { ((Suppressor)this).AttachToMount(m, playSound); _cachedFirearm = null; try { if (!((Object)(object)m != (Object)null)) { return; } FVRFireArmAttachmentMount rootMount = m.GetRootMount(); if ((Object)(object)rootMount != (Object)null && rootMount.Parent is FVRFireArm) { ref FVRFireArm cachedFirearm = ref _cachedFirearm; FVRPhysicalObject parent = rootMount.Parent; cachedFirearm = (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null); return; } Transform val = ((Component)m).transform; while ((Object)(object)val != (Object)null) { FVRFireArm component = ((Component)val).GetComponent<FVRFireArm>(); if ((Object)(object)component != (Object)null) { _cachedFirearm = component; break; } val = val.parent; } } catch { } } } namespace VolksScripts { public class Bulletholder : FVRPhysicalObject { [Header("Bullet Slots")] [Tooltip("Positions where rounds will be placed. Order defines fill order.")] public List<Transform> BulletSlots = new List<Transform>(); [Header("Visuals (optional)")] public MeshRenderer SlotHighlight; [Header("Behaviors")] public bool ClearVelocityOnPlace = true; [Header("Capacity")] public int capacity = 8; private FVRFireArmRound[] _storedRounds; public int NumRounds { get; private set; } protected void Awake() { ((FVRPhysicalObject)this).Awake(); if (BulletSlots == null) { BulletSlots = new List<Transform>(); } if (capacity <= 0 || capacity > BulletSlots.Count) { capacity = BulletSlots.Count; } _storedRounds = (FVRFireArmRound[])(object)new FVRFireArmRound[capacity]; NumRounds = 0; UpdateBulletDisplay(); } public bool TryPlace(FVRFireArmRound round) { if ((Object)(object)round == (Object)null || NumRounds >= capacity || capacity <= 0) { Debug.Log((object)"TryPlace failed: round is null or holder is full."); return false; } int num = FindFirstFreeSlot(); if (num < 0) { Debug.Log((object)"TryPlace failed: no free slot found."); return false; } Debug.Log((object)("TryPlace: placing round at slot " + num)); return PlaceAtIndex(round, num); } public bool PlaceAtIndex(FVRFireArmRound round, int index) { if ((Object)(object)round == (Object)null || index < 0 || index >= capacity || index >= BulletSlots.Count) { Debug.Log((object)("PlaceAtIndex failed: invalid round or index " + index)); return false; } if ((Object)(object)BulletSlots[index] == (Object)null) { Debug.Log((object)("PlaceAtIndex failed: slot " + index + " is null")); return false; } if ((Object)(object)_storedRounds[index] != (Object)null) { Debug.Log((object)("PlaceAtIndex failed: slot " + index + " already occupied")); return false; } PlaceAtSlot(round, BulletSlots[index]); _storedRounds[index] = round; NumRounds++; UpdateBulletDisplay(); if ((Object)(object)round != (Object)null) { ((FVRInteractiveObject)round).ForceBreakInteraction(); } Debug.Log((object)("PlaceAtIndex: round placed at slot " + index)); return true; } public FVRFireArmRound RemoveAt(int index) { if (index < 0 || index >= capacity) { return null; } FVRFireArmRound val = _storedRounds[index]; if ((Object)(object)val != (Object)null) { _storedRounds[index] = null; NumRounds--; UpdateBulletDisplay(); } return val; } public FVRFireArmRound GetAt(int index) { if (index < 0 || index >= capacity) { return null; } return _storedRounds[index]; } public void ClearAll() { for (int i = 0; i < capacity; i++) { _storedRounds[i] = null; } NumRounds = 0; UpdateBulletDisplay(); } private void PlaceAtSlot(FVRFireArmRound round, Transform slot) { //IL_0018: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_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_00b9: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_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_00fe: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_0117: 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_0065: 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) if (!((Object)(object)slot == (Object)null)) { Vector3 up = ((Component)this).transform.up; Rigidbody val = ((!((Object)(object)((FVRPhysicalObject)round).RootRigidbody != (Object)null)) ? ((Component)round).GetComponent<Rigidbody>() : ((FVRPhysicalObject)round).RootRigidbody); if ((Object)(object)val != (Object)null && ClearVelocityOnPlace) { val.velocity = Vector3.zero; val.angularVelocity = Vector3.zero; } ((Component)round).transform.rotation = Quaternion.LookRotation(((Component)this).transform.forward, up); if (TryGetBaseAndTipAlongUp(round, up, out var baseAlongUp, out var _)) { float num = Vector3.Dot(slot.position, up); float num2 = num - baseAlongUp; Transform transform = ((Component)round).transform; transform.position += up * num2; Collider componentInChildren = ((Component)round).GetComponentInChildren<Collider>(); Bounds bounds = componentInChildren.bounds; Vector3 val2 = Vector3.ProjectOnPlane(slot.position, up); Vector3 val3 = Vector3.ProjectOnPlane(((Bounds)(ref bounds)).center, up); Vector3 val4 = val2 - val3; Transform transform2 = ((Component)round).transform; transform2.position += val4; } else { ((Component)round).transform.position = slot.position; } if ((Object)(object)SlotHighlight != (Object)null) { ((Component)SlotHighlight).transform.position = slot.position; } } } private bool TryGetBaseAndTipAlongUp(FVRFireArmRound round, Vector3 up, out float baseAlongUp, out float tipAlongUp) { //IL_0029: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_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) baseAlongUp = (tipAlongUp = 0f); Collider componentInChildren = ((Component)round).GetComponentInChildren<Collider>(); if ((Object)(object)componentInChildren == (Object)null) { return false; } Bounds bounds = componentInChildren.bounds; baseAlongUp = Vector3.Dot(((Bounds)(ref bounds)).min, up); tipAlongUp = Vector3.Dot(((Bounds)(ref bounds)).max, up); return true; } private int FindFirstFreeSlot() { for (int i = 0; i < capacity; i++) { if (i < BulletSlots.Count && !((Object)(object)BulletSlots[i] == (Object)null) && (Object)(object)_storedRounds[i] == (Object)null) { return i; } } return -1; } public void UpdateBulletDisplay() { for (int i = 0; i < BulletSlots.Count; i++) { if ((Object)(object)BulletSlots[i] != (Object)null) { } } } private void OnTriggerEnter(Collider other) { FVRFireArmRound componentInParent = ((Component)other).GetComponentInParent<FVRFireArmRound>(); if (!((Object)(object)componentInParent == (Object)null)) { TryPlace(componentInParent); } } } public class BulletholderReloadTrigger : MonoBehaviour { public Bulletholder Holder; private void OnTriggerEnter(Collider other) { if ((Object)(object)Holder == (Object)null) { Debug.LogWarning((object)"BulletholderReloadTrigger: Holder not assigned."); return; } FVRFireArmRound componentInParent = ((Component)other).GetComponentInParent<FVRFireArmRound>(); if ((Object)(object)componentInParent != (Object)null) { Holder.TryPlace(componentInParent); } } } public class ShellCaddy : FVRFireArmMagazine { [Header("Caddy Configuration")] public int MaxCapacity = 8; public Transform DisplayContainer; private readonly List<FireArmRoundClass> roundClassData = new List<FireArmRoundClass>(); private int currentCapacity; private bool hasRoundType; private FireArmRoundType storedRoundType; private GameObject displayRoot; public override void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) ((FVRFireArmMagazine)this).Awake(); roundClassData.Clear(); currentCapacity = 0; hasRoundType = false; storedRoundType = (FireArmRoundType)0; } public override void Start() { ((FVRInteractiveObject)this).Start(); UpdateDisplayMag(); } public void AddShell(FVRFireArmRound shell) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0053: 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 ((Object)(object)shell == (Object)null || !((FVRPhysicalObject)shell).m_isVisible || currentCapacity >= MaxCapacity) { Debug.LogWarning((object)"Invalid shell or caddy is full."); return; } if (!hasRoundType) { hasRoundType = true; storedRoundType = shell.RoundType; } if (shell.RoundType != storedRoundType) { Debug.LogWarning((object)"Shell type mismatch."); return; } roundClassData.Add(shell.RoundClass); currentCapacity++; Object.Destroy((Object)(object)((Component)shell).gameObject); UpdateDisplayMag(); } public FVRFireArmRound RemoveShell() { //IL_002c: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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) if (currentCapacity == 0) { Debug.LogWarning((object)"No shells to remove."); return null; } FireArmRoundClass val = roundClassData[currentCapacity - 1]; roundClassData.RemoveAt(currentCapacity - 1); currentCapacity--; if (!hasRoundType || (Object)(object)DisplayContainer == (Object)null) { UpdateDisplayMag(); return null; } GameObject val2 = Object.Instantiate<GameObject>(((AnvilAsset)AM.GetRoundSelfPrefab(storedRoundType, val)).GetGameObject(), DisplayContainer.position, DisplayContainer.rotation); UpdateDisplayMag(); return val2.GetComponent<FVRFireArmRound>(); } private void UpdateDisplayMag() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0084: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00d7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)displayRoot != (Object)null) { Object.Destroy((Object)(object)displayRoot); displayRoot = null; } if (currentCapacity <= 0 || (Object)(object)DisplayContainer == (Object)null || !hasRoundType) { return; } displayRoot = new GameObject("ShellCaddyDisplay"); displayRoot.transform.SetParent(DisplayContainer, false); for (int i = 0; i < currentCapacity; i++) { GameObject val = Object.Instantiate<GameObject>(((AnvilAsset)AM.GetRoundSelfPrefab(storedRoundType, roundClassData[i])).GetGameObject(), displayRoot.transform); val.transform.localPosition = Vector3.down * (float)i * 0.02f; val.transform.localRotation = Quaternion.identity; Rigidbody component = val.GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { component.isKinematic = true; component.detectCollisions = false; } Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>(); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].enabled = false; } } } public void ResetCaddy() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) roundClassData.Clear(); currentCapacity = 0; hasRoundType = false; storedRoundType = (FireArmRoundType)0; if ((Object)(object)displayRoot != (Object)null) { Object.Destroy((Object)(object)displayRoot); displayRoot = null; } UpdateDisplayMag(); } public void HandleCollision(Collider other) { FVRFireArmRound component = ((Component)other).GetComponent<FVRFireArmRound>(); if ((Object)(object)component != (Object)null) { AddShell(component); } } } public class ShellCaddy_Reception : MonoBehaviour { public ShellCaddy caddy; private void OnTriggerStay(Collider other) { caddy.HandleCollision(other); } } } public class Compass : FVRPhysicalObject { [Header("Compass Lid")] public Transform Lid; public float openRotationX = 90f; public float openRotationY = 0f; public float openRotationZ = 0f; public float closeRotationX = 0f; public float closeRotationY = 0f; public float closeRotationZ = 0f; public float lidRotationSpeed = 5f; public AudioSource openCloseAudioSource; public AudioClip openClip; public AudioClip closeClip; [Header("Compass Needle")] public Transform Needle; [Tooltip("The direction that is considered North. Default is (0,0,1) (Z+).")] public Vector3 NorthDirection = Vector3.forward; public float needleSmoothTime = 0.5f; public float needleWobbleAmount = 2f; public float needleWobbleSpeed = 5f; private bool isOpen = false; private bool isTouching = false; private Vector2 initTouch = Vector2.zero; private Vector2 lastTouchPoint = Vector2.zero; private float currentNeedleAngle = 0f; private float needleVelocity = 0f; private void Update() { //IL_003a: 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_003f: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_0135: Unknown result type (might be due to invalid IL or missing references) Quaternion val = ((!isOpen) ? Quaternion.Euler(closeRotationX, closeRotationY, closeRotationZ) : Quaternion.Euler(openRotationX, openRotationY, openRotationZ)); if ((Object)(object)Lid != (Object)null) { Lid.localRotation = Quaternion.Lerp(Lid.localRotation, val, Time.deltaTime * lidRotationSpeed); } if ((Object)(object)Needle != (Object)null) { Vector3 normalized = ((Vector3)(ref NorthDirection)).normalized; Vector3 val2 = Vector3.ProjectOnPlane(((Component)this).transform.forward, Vector3.up); Vector3 val3 = Vector3.ProjectOnPlane(normalized, Vector3.up); float num = Mathf.Atan2(Vector3.Cross(val2, val3).y, Vector3.Dot(val2, val3)) * 57.29578f; float num2 = Mathf.Sin(Time.time * needleWobbleSpeed) * needleWobbleAmount; num += num2; currentNeedleAngle = Mathf.SmoothDampAngle(currentNeedleAngle, num, ref needleVelocity, needleSmoothTime); Needle.localRotation = Quaternion.Euler(0f, currentNeedleAngle, 0f); } } public void ToggleLid() { isOpen = !isOpen; if ((Object)(object)openCloseAudioSource != (Object)null) { openCloseAudioSource.PlayOneShot((!isOpen) ? closeClip : openClip); } } public override void UpdateInteraction(FVRViveHand hand) { //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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00bc: 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_00c8: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) ((FVRPhysicalObject)this).UpdateInteraction(hand); if (hand.IsInStreamlinedMode) { if (hand.Input.BYButtonDown || hand.Input.AXButtonDown) { ToggleLid(); } return; } if (hand.Input.TouchpadTouched && !isTouching && hand.Input.TouchpadAxes != Vector2.zero) { isTouching = true; initTouch = hand.Input.TouchpadAxes; } if (hand.Input.TouchpadTouchUp && isTouching) { isTouching = false; Vector2 val = lastTouchPoint; float y = (val - initTouch).y; if (y > 0.5f || y < -0.5f) { ToggleLid(); } initTouch = Vector2.zero; val = Vector2.zero; } lastTouchPoint = hand.Input.TouchpadAxes; } } public class SimpleDartboard : MonoBehaviour, IFVRDamageable { private class StuckRestore : MonoBehaviour { private Collider[] _colliders; private bool[] _origIsTrigger; private Rigidbody _rb; private bool _origKinematic; private Transform _boardTransform; private bool _restored; public void Initialize(Rigidbody rootRigidbody, Transform boardTransform) { _boardTransform = boardTransform; _rb = rootRigidbody; _colliders = ((Component)this).GetComponentsInChildren<Collider>(); _origIsTrigger = new bool[_colliders.Length]; for (int i = 0; i < _colliders.Length; i++) { _origIsTrigger[i] = (Object)(object)_colliders[i] != (Object)null && _colliders[i].isTrigger; } if ((Object)(object)_rb != (Object)null) { _origKinematic = _rb.isKinematic; } else { _origKinematic = false; } _restored = false; } private void Update() { if (_restored) { return; } if (!((Component)this).transform.IsChildOf(_boardTransform)) { Restore(); return; } FVRPhysicalObject componentInParent = ((Component)this).GetComponentInParent<FVRPhysicalObject>(); if ((Object)(object)componentInParent != (Object)null && ((FVRInteractiveObject)componentInParent).IsHeld) { Restore(); } } private void Restore() { if (_restored) { return; } _restored = true; if (_colliders != null && _origIsTrigger != null) { int num = Mathf.Min(_colliders.Length, _origIsTrigger.Length); for (int i = 0; i < num; i++) { if (!((Object)(object)_colliders[i] == (Object)null)) { _colliders[i].isTrigger = _origIsTrigger[i]; } } } if ((Object)(object)_rb != (Object)null) { _rb.isKinematic = _origKinematic; } Object.Destroy((Object)(object)this); } private void OnDestroy() { if (!_restored) { Restore(); } } } [Header("Dartboard Settings")] public float minSharpDamage = 10f; [Header("Damage Thresholds")] [Tooltip("Minimum blunt damage required to consider sticking (0 disables blunt threshold).")] public float MinBlunt = 0f; [Tooltip("Minimum cutting damage required to consider sticking (0 disables cutting threshold).")] public float MinCutting = 0f; [Tooltip("Minimum piercing damage required to consider sticking (0 disables piercing threshold).")] public float MinPiercing = 10f; [Tooltip("Minimum total kinetic damage required to consider sticking (0 disables total threshold).")] public float MinTotal = 0f; [Tooltip("If true, stick when ANY threshold is met. If false, require Dam_TotalKinetic >= MinTotal.")] public bool AcceptIfAnyThreshold = true; [Header("Damage Classes")] [Tooltip("If true, accept Melee damage.")] public bool AcceptMelee = true; [Tooltip("If true, accept Projectile damage.")] public bool AcceptProjectile = true; [Tooltip("If true, accept other damage classes.")] public bool AcceptOtherDamageClasses = true; [Header("Damage Type Filters")] [Tooltip("If true, include blunt damage checks when evaluating thresholds.")] public bool AcceptBluntDamage = true; [Tooltip("If true, include cutting damage checks when evaluating thresholds.")] public bool AcceptCuttingDamage = true; [Tooltip("If true, include piercing damage checks when evaluating thresholds.")] public bool AcceptPiercingDamage = true; [Tooltip("If true, include total kinetic damage checks when evaluating thresholds.")] public bool AcceptTotalDamage = true; [Header("Sticking Settings")] [Tooltip("Radius (meters) around hit point to search for candidate objects to stick.")] public float StickSearchRadius = 0.6f; [Tooltip("Preferred maximum distance from hit point to object's collider closest point for easy sticking.")] public float StickMaxClosestDist = 0.25f; [Tooltip("If true, allow sticking objects that are currently held (will force break).")] public bool AllowStickingHeldObjects = false; [Header("Audio")] public AudioEvent HitEvent; public FVRPooledAudioType PoolType = (FVRPooledAudioType)0; public float HitSoundRefire = 0.1f; private float m_refireTick; private FVRPhysicalObject _myFvrObject; private void Awake() { _myFvrObject = ((Component)this).GetComponentInParent<FVRPhysicalObject>(); } private void Update() { if (m_refireTick > 0f) { m_refireTick -= Time.deltaTime; } } void IFVRDamageable.Damage(Damage d) { //IL_0013: 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_0099: 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_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)string.Concat("Dartboard hit! Class:", d.Class, " Piercing:", d.Dam_Piercing, " Cutting:", d.Dam_Cutting, " Blunt:", d.Dam_Blunt, " Total:", d.Dam_TotalKinetic)); if (!IsDamageClassAccepted(d.Class)) { Debug.Log((object)("Damage class not accepted: " + d.Class)); return; } if (!EvaluateDamageThresholds(d)) { Debug.Log((object)("Damage below configured thresholds. Blunt=" + d.Dam_Blunt + " Cutting=" + d.Dam_Cutting + " Piercing=" + d.Dam_Piercing + " Total=" + d.Dam_TotalKinetic)); return; } Debug.Log((object)"Looking for object to stick..."); PlayHitSound(Mathf.Clamp(d.Dam_TotalKinetic / 20f, 0.05f, 1f)); Collider[] array = Physics.OverlapSphere(d.point, StickSearchRadius, -1, (QueryTriggerInteraction)2); Debug.Log((object)("Found " + array.Length + " nearby colliders (including triggers)")); FVRPhysicalObject val = null; float num = float.MaxValue; foreach (Collider val2 in array) { if ((Object)(object)val2 == (Object)null) { continue; } FVRPhysicalObject componentInParent = ((Component)val2).GetComponentInParent<FVRPhysicalObject>(); if ((Object)(object)componentInParent == (Object)null) { continue; } if ((Object)(object)componentInParent == (Object)(object)_myFvrObject || ((Component)componentInParent).transform.IsChildOf(((Component)_myFvrObject).transform) || ((Component)_myFvrObject).transform.IsChildOf(((Component)componentInParent).transform)) { Debug.LogFormat("Skipping candidate {0} (is board or in board hierarchy)", new object[1] { ((Object)componentInParent).name }); continue; } if (((FVRInteractiveObject)componentInParent).IsHeld && !AllowStickingHeldObjects) { Debug.LogFormat("Skipping physObj because it's held: {0}", new object[1] { ((Object)componentInParent).name }); continue; } Vector3 val3 = val2.ClosestPoint(d.point); float num2 = Vector3.Distance(val3, d.point); Debug.LogFormat("Candidate {0}: closestDist={1:F4}", new object[2] { ((Object)componentInParent).name, num2 }); if (num2 <= StickMaxClosestDist) { val = componentInParent; num = num2; Debug.LogFormat("Immediate accept candidate {0} at dist {1:F4}", new object[2] { ((Object)componentInParent).name, num2 }); break; } if (num2 < num) { num = num2; val = componentInParent; } } if ((Object)(object)val != (Object)null && num <= StickSearchRadius * 1.5f) { Debug.Log((object)("Sticking object: " + ((Object)val).name + " (dist=" + num.ToString("F3") + ")")); StickObject(val); } else { Debug.Log((object)("No valid external candidate found to stick. BestDist=" + ((!((Object)(object)val != (Object)null)) ? "n/a" : num.ToString("F4")))); } } private bool IsDamageClassAccepted(DamageClass cls) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 if ((int)cls != 3) { if ((int)cls == 1) { return AcceptProjectile; } return AcceptOtherDamageClasses; } return AcceptMelee; } private bool EvaluateDamageThresholds(Damage d) { if (AcceptIfAnyThreshold) { if (AcceptPiercingDamage && MinPiercing > 0f && d.Dam_Piercing >= MinPiercing) { return true; } if (AcceptCuttingDamage && MinCutting > 0f && d.Dam_Cutting >= MinCutting) { return true; } if (AcceptBluntDamage && MinBlunt > 0f && d.Dam_Blunt >= MinBlunt) { return true; } if (AcceptTotalDamage && MinTotal > 0f && d.Dam_TotalKinetic >= MinTotal) { return true; } if (MinBlunt <= 0f && MinCutting <= 0f && MinPiercing <= 0f && MinTotal <= 0f) { float num = 0f; if (AcceptPiercingDamage) { num += d.Dam_Piercing; } if (AcceptCuttingDamage) { num += d.Dam_Cutting; } if (!AcceptPiercingDamage && !AcceptCuttingDamage) { return false; } return num >= minSharpDamage; } return false; } if (MinTotal > 0f && AcceptTotalDamage) { return d.Dam_TotalKinetic >= MinTotal; } float num2 = 0f; if (AcceptPiercingDamage) { num2 += d.Dam_Piercing; } if (AcceptCuttingDamage) { num2 += d.Dam_Cutting; } if (!AcceptPiercingDamage && !AcceptCuttingDamage) { return false; } return num2 >= minSharpDamage; } private void StickObject(FVRPhysicalObject obj) { //IL_0070: 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) if ((Object)(object)obj == (Object)null) { return; } if (((FVRInteractiveObject)obj).IsHeld) { ((FVRInteractiveObject)obj).ForceBreakInteraction(); } obj.ClearQuickbeltState(); Rigidbody rootRigidbody = obj.RootRigidbody; GameObject val = ((!((Object)(object)rootRigidbody != (Object)null)) ? ((Component)obj).gameObject : ((Component)rootRigidbody).gameObject); StuckRestore stuckRestore = val.AddComponent<StuckRestore>(); stuckRestore.Initialize(rootRigidbody, ((Component)this).transform); if ((Object)(object)rootRigidbody != (Object)null) { rootRigidbody.velocity = Vector3.zero; rootRigidbody.angularVelocity = Vector3.zero; rootRigidbody.isKinematic = true; } Collider[] componentsInChildren = ((Component)obj).GetComponentsInChildren<Collider>(); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { componentsInChildren[i].isTrigger = true; } } ((Component)obj).transform.SetParent(((Component)this).transform); } private void PlayHitSound(float soundMultiplier) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00aa: 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_0069: Unknown result type (might be due to invalid IL or missing references) if (m_refireTick <= 0f && HitEvent != null) { m_refireTick = HitSoundRefire; float num = 0f; if ((Object)(object)GM.CurrentPlayerBody != (Object)null && (Object)(object)GM.CurrentPlayerBody.Head != (Object)null) { num = Vector3.Distance(((Component)this).transform.position, GM.CurrentPlayerBody.Head.position); } float num2 = num / 343f; SM.PlayCoreSoundDelayedOverrides(PoolType, HitEvent, ((Component)this).transform.position, HitEvent.VolumeRange * soundMultiplier, HitEvent.PitchRange, num2 + 0.04f); } } } public class FlamethrowerValve : FVRInteractiveObject { [Header("References")] public Transform RefFrame; public Transform Valve; [Header("Rotation Settings")] public Vector2 ValveRotRange = new Vector2(-50f, 50f); private float m_valveRot; [Header("Runtime")] public float Lerp = 0.5f; private Vector3 refDir = Vector3.one; public override void BeginInteraction(FVRViveHand hand) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_001a: 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_0022: 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) Vector3 up = ((HandInput)(ref hand.Input)).Up; Vector3 val = Vector3.ProjectOnPlane(up, RefFrame.right); refDir = ((Vector3)(ref val)).normalized; ((FVRInteractiveObject)this).BeginInteraction(hand); } public override void UpdateInteraction(FVRViveHand hand) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_001e: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) //IL_00b7: 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_00ea: Unknown result type (might be due to invalid IL or missing references) Vector3 up = ((HandInput)(ref hand.Input)).Up; Vector3 val = Vector3.ProjectOnPlane(up, RefFrame.right); Vector3 normalized = ((Vector3)(ref val)).normalized; float num = Mathf.Atan2(Vector3.Dot(RefFrame.right, Vector3.Cross(refDir, normalized)), Vector3.Dot(refDir, normalized)) * 57.29578f; num = Mathf.Clamp(num, -5f, 5f); m_valveRot += num; m_valveRot = Mathf.Clamp(m_valveRot, ValveRotRange.x, ValveRotRange.y); Valve.localEulerAngles = new Vector3(m_valveRot, 0f, 0f); Lerp = Mathf.InverseLerp(ValveRotRange.x, ValveRotRange.y, m_valveRot); refDir = normalized; ((FVRInteractiveObject)this).UpdateInteraction(hand); } } namespace VolksScripts { public class FlareBody : FVRPhysicalObject { [Header("Flare Parts")] public GameObject FlareHead; public Transform HeadAttachPoint; public Collider StrikeArea; [Header("Ignition")] public int MinStrikesToIgnite = 2; public int MaxStrikesToIgnite = 5; public float StrikeCooldown = 0.2f; [Header("Strike Force")] public float MinStrikeSpeed = 1.2f; [Header("Strike Timing")] public float StrikeArmDelay = 0.2f; [Header("Return")] public float ReturnHeadDelay = 2f; [Header("Strike Effects")] public ParticleSystem StrikeParticles; public int StrikeParticlesPerHit = 1; public AudioSource StrikeSound; [Header("Effects")] public GameObject FlareEffectsRoot; public ParticleSystem FlareParticles; public Light FlareLight; public AudioSource IgniteSound; public AudioSource BurnLoopSound; public AudioSource DieSound; [Header("Lifetime")] public float FlareLifetime = 20f; [Header("Debug")] public bool EnableDebug = false; private int m_strikeCount = 0; private int m_strikesRequired = 3; private bool m_isHeadAttached = true; private bool m_isIgnited = false; private float m_lastStrikeTime = -1f; private float m_nextStrikeAllowedTime = 0f; private Coroutine m_lifetimeCoroutine; private Coroutine m_returnCoroutine; private List<Collider> m_headColliders = new List<Collider>(); private bool[] m_headOrigIsTrigger; private Rigidbody m_headRigidbody; private Vector3 m_lastHeadPos; private float m_lastHeadTime; public override void Awake() { ((FVRPhysicalObject)this).Awake(); AttachHead(); ForceStopParticles(StrikeParticles); ForceStopParticles(FlareParticles); if ((Object)(object)FlareEffectsRoot != (Object)null) { FlareEffectsRoot.SetActive(false); } else if ((Object)(object)FlareLight != (Object)null) { ((Behaviour)FlareLight).enabled = false; } if ((Object)(object)BurnLoopSound != (Object)null) { BurnLoopSound.Stop(); } int num = Mathf.Min(MinStrikesToIgnite, MaxStrikesToIgnite); int num2 = Mathf.Max(MinStrikesToIgnite, MaxStrikesToIgnite); m_strikesRequired = Random.Range(num, num2 + 1); } public override void FVRUpdate() { //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) ((FVRPhysicalObject)this).FVRUpdate(); if (!m_isHeadAttached && (Object)(object)FlareHead != (Object)null) { m_lastHeadPos = FlareHead.transform.position; m_lastHeadTime = Time.time; } } public void DetachHead() { //IL_0073: 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) if (!m_isHeadAttached) { return; } m_isHeadAttached = false; CacheHeadComponents(); SetHeadStrikeCollision(ignore: false); if ((Object)(object)FlareHead != (Object)null) { FlareHead.transform.parent = null; if ((Object)(object)m_headRigidbody != (Object)null) { m_headRigidbody.isKinematic = false; } m_lastHeadPos = FlareHead.transform.position; m_lastHeadTime = Time.time; } m_nextStrikeAllowedTime = Time.time + StrikeArmDelay; StartReturnTimer(); } public void AttachHead() { //IL_00b8: 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_0075: 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) m_isHeadAttached = true; if (m_returnCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(m_returnCoroutine); m_returnCoroutine = null; } if ((Object)(object)FlareHead != (Object)null && (Object)(object)HeadAttachPoint != (Object)null) { CacheHeadComponents(); if ((Object)(object)m_headRigidbody != (Object)null) { m_headRigidbody.isKinematic = true; m_headRigidbody.velocity = Vector3.zero; m_headRigidbody.angularVelocity = Vector3.zero; } SetHeadStrikeCollision(ignore: true); FlareHead.transform.parent = HeadAttachPoint; FlareHead.transform.localPosition = Vector3.zero; FlareHead.transform.localRotation = Quaternion.identity; FlareHead component = FlareHead.GetComponent<FlareHead>(); if ((Object)(object)component != (Object)null) { component.Body = this; } } } private void StartReturnTimer() { if (m_returnCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(m_returnCoroutine); } m_returnCoroutine = ((MonoBehaviour)this).StartCoroutine(ReturnHeadCoroutine()); } private IEnumerator ReturnHeadCoroutine() { yield return (object)new WaitForSeconds(ReturnHeadDelay); if (m_isIgnited || (Object)(object)FlareHead == (Object)null || m_isHeadAttached) { yield break; } FlareHead head = FlareHead.GetComponent<FlareHead>(); if ((Object)(object)head == (Object)null) { yield break; } while (((FVRInteractiveObject)head).IsHeld) { if (m_isIgnited || (Object)(object)FlareHead == (Object)null || m_isHeadAttached) { yield break; } yield return null; } head.ReturnToBody(); } public void TryStrikeFromHead(Collider headStrikeCollider, Collision col) { //IL_0091: 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) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0112: Unknown result type (might be due to invalid IL or missing references) if (m_isIgnited || m_isHeadAttached) { DebugLog("Blocked: ignited/head attached."); return; } if (Time.time < m_nextStrikeAllowedTime) { DebugLog("Strike gated by arm delay."); return; } if ((Object)(object)StrikeArea == (Object)null || (Object)(object)headStrikeCollider == (Object)null || col == null) { DebugLog("Missing strike refs."); return; } for (int i = 0; i < col.contacts.Length; i++) { ContactPoint val = col.contacts[i]; bool flag = (Object)(object)((ContactPoint)(ref val)).thisCollider == (Object)(object)headStrikeCollider || (Object)(object)((ContactPoint)(ref val)).otherCollider == (Object)(object)headStrikeCollider; bool flag2 = (Object)(object)((ContactPoint)(ref val)).thisCollider == (Object)(object)StrikeArea || (Object)(object)((ContactPoint)(ref val)).otherCollider == (Object)(object)StrikeArea; if (flag && flag2) { Vector3 relativeVelocity = col.relativeVelocity; if (((Vector3)(ref relativeVelocity)).magnitude >= MinStrikeSpeed) { Strike(((ContactPoint)(ref val)).point); return; } Vector3 relativeVelocity2 = col.relativeVelocity; DebugLog("Speed too low: " + ((Vector3)(ref relativeVelocity2)).magnitude.ToString("F2")); return; } } DebugLog("No valid head/body strike in contacts."); } public void TryStrikeFromHead(Collider headStrikeCollider, Collider other) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (m_isIgnited || m_isHeadAttached) { DebugLog("Blocked: ignited/head attached."); } else if (Time.time < m_nextStrikeAllowedTime) { DebugLog("Strike gated by arm delay."); } else if ((Object)(object)StrikeArea == (Object)null || (Object)(object)headStrikeCollider == (Object)null || (Object)(object)other == (Object)null) { DebugLog("Missing strike refs."); } else if ((Object)(object)other == (Object)(object)StrikeArea) { float triggerStrikeSpeed = GetTriggerStrikeSpeed(other); if (triggerStrikeSpeed >= MinStrikeSpeed) { Vector3 impactPoint = other.ClosestPoint(((Component)headStrikeCollider).transform.position); Strike(impactPoint); } else { DebugLog("Trigger speed too low: " + triggerStrikeSpeed.ToString("F2")); } } } private float GetTriggerStrikeSpeed(Collider other) { //IL_001f: 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_0024: 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_002c: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) Rigidbody attachedRigidbody = other.attachedRigidbody; Vector3 val = ((!((Object)(object)attachedRigidbody != (Object)null)) ? Vector3.zero : attachedRigidbody.velocity); Vector3 headVelocity = GetHeadVelocity(); Vector3 val2 = headVelocity - val; return ((Vector3)(ref val2)).magnitude; } private Vector3 GetHeadVelocity() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_008a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)FlareHead == (Object)null) { return Vector3.zero; } float num = Time.time - m_lastHeadTime; if (num <= 0f) { return Vector3.zero; } Vector3 result = (FlareHead.transform.position - m_lastHeadPos) / num; m_lastHeadPos = FlareHead.transform.position; m_lastHeadTime = Time.time; return result; } private void Strike(Vector3 impactPoint) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!(Time.time - m_lastStrikeTime < StrikeCooldown)) { m_lastStrikeTime = Time.time; m_strikeCount++; PlayStrikeParticles(impactPoint); if ((Object)(object)StrikeSound != (Object)null) { ((Component)StrikeSound).gameObject.SetActive(true); StrikeSound.Play(); } if (m_strikeCount >= m_strikesRequired) { Ignite(); } } } private void PlayStrikeParticles(Vector3 impactPoint) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)StrikeParticles == (Object)null)) { ((Component)StrikeParticles).gameObject.SetActive(true); ((Component)StrikeParticles).transform.position = impactPoint; StrikeParticles.Clear(true); int num = Mathf.Max(1, StrikeParticlesPerHit); StrikeParticles.Emit(num); } } private void Ignite() { m_isIgnited = true; if ((Object)(object)FlareEffectsRoot != (Object)null) { FlareEffectsRoot.SetActive(true); } else { ForcePlayParticles(FlareParticles); if ((Object)(object)FlareLight != (Object)null) { ((Component)FlareLight).gameObject.SetActive(true); ((Behaviour)FlareLight).enabled = true; } } if ((Object)(object)IgniteSound != (Object)null) { ((Component)IgniteSound).gameObject.SetActive(true); IgniteSound.Play(); } if ((Object)(object)BurnLoopSound != (Object)null) { ((Component)BurnLoopSound).gameObject.SetActive(true); BurnLoopSound.loop = true; BurnLoopSound.Play(); } if ((Object)(object)FlareHead != (Object)null) { Object.Destroy((Object)(object)FlareHead); } if (m_lifetimeCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(m_lifetimeCoroutine); } m_lifetimeCoroutine = ((MonoBehaviour)this).StartCoroutine(FlareLifeCoroutine()); } private IEnumerator FlareLifeCoroutine() { yield return (object)new WaitForSeconds(FlareLifetime); if ((Object)(object)BurnLoopSound != (Object)null) { BurnLoopSound.Stop(); } if ((Object)(object)DieSound != (Object)null) { DieSound.Play(); } if ((Object)(object)FlareEffectsRoot != (Object)null) { FlareEffectsRoot.SetActive(false); } else { ForceStopParticles(FlareParticles); if ((Object)(object)FlareLight != (Object)null) { ((Behaviour)FlareLight).enabled = false; } } float dieSoundLength = ((!((Object)(object)DieSound != (Object)null) || !((Object)(object)DieSound.clip != (Object)null)) ? 0f : DieSound.clip.length); while (((FVRInteractiveObject)this).IsHeld) { yield return null; } float elapsed = 0f; while (elapsed < dieSoundLength) { if (((FVRInteractiveObject)this).IsHeld) { elapsed = 0f; while (((FVRInteractiveObject)this).IsHeld) { yield return null; } } elapsed += Time.deltaTime; yield return null; } Object.Destroy((Object)(object)((Component)this).gameObject); } private void ForcePlayParticles(ParticleSystem ps) { if (!((Object)(object)ps == (Object)null)) { ((Component)ps).gameObject.SetActive(true); ps.Clear(true); ps.Play(true); } } private void ForceStopParticles(ParticleSystem ps) { if (!((Object)(object)ps == (Object)null)) { ps.Stop(true, (ParticleSystemStopBehavior)0); } } private void CacheHeadComponents() { m_headColliders.Clear(); if ((Object)(object)FlareHead == (Object)null) { m_headRigidbody = null; m_headOrigIsTrigger = null; return; } m_headColliders.AddRange(FlareHead.GetComponentsInChildren<Collider>(true)); m_headRigidbody = FlareHead.GetComponent<Rigidbody>(); if (m_headOrigIsTrigger != null && m_headOrigIsTrigger.Length == m_headColliders.Count) { return; } if (m_headColliders.Count > 0) { m_headOrigIsTrigger = new bool[m_headColliders.Count]; for (int i = 0; i < m_headColliders.Count; i++) { Collider val = m_headColliders[i]; m_headOrigIsTrigger[i] = (Object)(object)val != (Object)null && val.isTrigger; } } else { m_headOrigIsTrigger = null; } } private void SetHeadStrikeCollision(bool ignore) { if (m_headColliders == null || m_headColliders.Count == 0) { return; } for (int i = 0; i < m_headColliders.Count; i++) { Collider val = m_headColliders[i]; if (!((Object)(object)val == (Object)null)) { if ((Object)(object)StrikeArea != (Object)null) { Physics.IgnoreCollision(val, StrikeArea, ignore); } if (ignore) { val.isTrigger = true; } else if (m_headOrigIsTrigger != null && i < m_headOrigIsTrigger.Length) { val.isTrigger = m_headOrigIsTrigger[i]; } } } } private void DebugLog(string msg) { if (EnableDebug) { Debug.Log((object)("[FlareBody] " + msg)); } } } public class FlareHead : FVRPhysicalObject { [Header("Owner")] public FlareBody Body; [Header("Strike Collider")] public Collider StrikeCollider; public override void Awake() { ((FVRPhysicalObject)this).Awake(); } public override void BeginInteraction(FVRViveHand hand) { ((FVRPhysicalObject)this).BeginInteraction(hand); if ((Object)(object)Body != (Object)null) { Body.DetachHead(); } } public void ReturnToBody() { if (!((Object)(object)Body == (Object)null) && !((FVRInteractiveObject)this).IsHeld) { Body.AttachHead(); } } private void OnTransformParentChanged() { if ((Object)(object)Body != (Object)null && (Object)(object)((Component)this).transform.parent == (Object)null) { Body.DetachHead(); } } public override void OnCollisionEnter(Collision col) { ((FVRPhysicalObject)this).OnCollisionEnter(col); if ((Object)(object)Body != (Object)null && (Object)(object)StrikeCollider != (Object)null) { Body.TryStrikeFromHead(StrikeCollider, col); } } private void OnTriggerEnter(Collider other) { if ((Object)(object)Body != (Object)null && (Object)(object)StrikeCollider != (Object)null) { Body.TryStrikeFromHead(StrikeCollider, other); } } } } public class FlyingHotdog : MonoBehaviour { public enum FlapAxis { X, Y, Z } [Tooltip("Seconds to wait before the hotdog starts flying.")] public float waitTime = 2f; [Header("Speed Settings")] [Tooltip("Minimum speed the hotdog can fly.")] public float minFlySpeed = 3f; [Tooltip("Maximum speed the hotdog can fly.")] public float maxFlySpeed = 7f; [Tooltip("How often the hotdog changes direction (seconds).")] public float directionChangeInterval = 1f; [Tooltip("How much the hotdog can move up or down per direction change.")] public float verticalVariance = 2f; [Tooltip("How quickly the hotdog turns toward its new direction. Higher = snappier.")] public float turnSpeed = 1.2f; [Header("Flock Settings")] [Tooltip("Prefab of the hotdog to spawn.")] public GameObject hotdogPrefab; [Tooltip("Minimum number of hotdogs in a flock.")] public int minFlockSize = 3; [Tooltip("Maximum number of hotdogs in a flock.")] public int maxFlockSize = 8; [Tooltip("Spawn radius for flock members.")] public float flockRadius = 2f; [Tooltip("Minimum flying height (Y axis).")] public float minFlyHeight = 15f; [Tooltip("Maximum flying height (Y axis).")] public float maxFlyHeight = 25f; [Tooltip("If true, this object is a flock spawner.")] public bool isSpawner = true; [Tooltip("Delay before spawning the rest of the flock (seconds).")] public float flockSpawnDelay = 1f; [Header("Wing Flapping")] [Tooltip("Left wing mesh transform.")] public Transform leftWing; [Tooltip("Right wing mesh transform.")] public Transform rightWing; [Tooltip("Axis to rotate wings around.")] public FlapAxis flapAxis = FlapAxis.Z; [Tooltip("Maximum angle (degrees) for wing flap (from center to top/bottom).")] public float flapAngle = 45f; [Tooltip("Flap speed in cycles per second.")] public float flapSpeed = 2f; private float wingFlapTime = 0f; private Quaternion leftWingBaseRot; private Quaternion rightWingBaseRot; private Rigidbody rb; private Vector3 flyDirection; private Vector3 targetDirection; private float currentFlySpeed; private float velocityLerp = 0f; private float targetFlyHeight; private bool isFlying = false; private void Start() { //IL_0084: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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) rb = ((Component)this).GetComponent<Rigidbody>(); if ((Object)(object)rb == (Object)null) { rb = ((Component)this).gameObject.AddComponent<Rigidbody>(); } rb.useGravity = false; rb.isKinematic = true; rb.collisionDetectionMode = (CollisionDetectionMode)2; rb.interpolation = (RigidbodyInterpolation)1; rb.WakeUp(); if ((Object)(object)leftWing != (Object)null) { leftWingBaseRot = leftWing.localRotation; } if ((Object)(object)rightWing != (Object)null) { rightWingBaseRot = rightWing.localRotation; } if (isSpawner && (Object)(object)hotdogPrefab != (Object)null) { ((MonoBehaviour)this).StartCoroutine(SpawnFlockWithDelay()); return; } currentFlySpeed = minFlySpeed; if (Mathf.Approximately(targetFlyHeight, 0f)) { targetFlyHeight = GetCeilingHeight(((Component)this).transform.position, minFlyHeight, maxFlyHeight); } SetInitialDirection(); flyDirection = targetDirection; ((MonoBehaviour)this).StartCoroutine(FlyRoutine()); } private void Update() { AnimateWings(); } private void AnimateWings() { //IL_0060: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)leftWing == (Object)null) || !((Object)(object)rightWing == (Object)null)) { wingFlapTime += Time.deltaTime * flapSpeed * 2f * (float)Math.PI; float num = Mathf.Sin(wingFlapTime) * flapAngle; Vector3 val = Vector3.forward; switch (flapAxis) { case FlapAxis.X: val = Vector3.right; break; case FlapAxis.Y: val = Vector3.up; break; case FlapAxis.Z: val = Vector3.forward; break; } if ((Object)(object)leftWing != (Object)null) { leftWing.localRotation = leftWingBaseRot * Quaternion.AngleAxis(num, val); } if ((Object)(object)rightWing != (Object)null) { rightWing.localRotation = rightWingBaseRot * Quaternion.AngleAxis(0f - num, val); } } } private IEnumerator SpawnFlockWithDelay() { yield return (object)new WaitForSeconds(flockSpawnDelay); int flockCount = Random.Range(minFlockSize, maxFlockSize + 1); for (int i = 0; i < flockCount; i++) { Vector3 val = Random.insideUnitSphere * flockRadius; Vector3 val2 = ((Component)this).transform.position + val; GameObject val3 = Object.Instantiate<GameObject>(hotdogPrefab, val2, Quaternion.identity); val3.SetActive(true); FlyingHotdog component = val3.GetComponent<FlyingHotdog>(); if ((Object)(object)component != (Object)null) { component.isSpawner = false; component.targetFlyHeight = GetCeilingHeight(val2, minFlyHeight, maxFlyHeight); } } Object.Destroy((Object)(object)((Component)this).gameObject); } private IEnumerator FlyRoutine() { yield return (object)new WaitForSeconds(waitTime); while (Mathf.Abs(((Component)this).transform.position.y - targetFlyHeight) > 0.1f) { yield return (object)new WaitForFixedUpdate(); float dt = Time.fixedDeltaTime; Vector3 pos = ((Component)this).transform.position; float ascendSpeed = Mathf.Lerp(minFlySpeed, maxFlySpeed, 0.5f); float nextY = Mathf.MoveTowards(pos.y, targetFlyHeight, ascendSpeed * dt); Vector3 nextPos = new Vector3(pos.x, nextY, pos.z); if ((Object)(object)rb == (Object)null) { rb = ((Component)this).GetComponent<Rigidbody>(); } if ((Object)(object)rb != (Object)null) { rb.MovePosition(nextPos); } } isFlying = true; ((MonoBehaviour)this).StartCoroutine(FlockFlyRoutine()); } private IEnumerator FlockFlyRoutine() { if ((Object)(object)rb == (Object)null) { rb = ((Component)this).GetComponent<Rigidbody>(); } if ((Object)(object)rb == (Object)null) { yield break; } RaycastHit hit = default(RaycastHit); while (true) { SetTargetDirection(); float targetSpeed = Random.Range(minFlySpeed, maxFlySpeed); float timer = 0f; float dt; for (velocityLerp = 0f; timer < directionChangeInterval; timer += dt) { yield return (object)new WaitForFixedUpdate(); dt = Time.fixedDeltaTime; velocityLerp += dt / directionChangeInterval; currentFlySpeed = Mathf.Lerp(currentFlySpeed, targetSpeed, velocityLerp); FlyingHotdog flyingHotdog = this; Vector3 val = Vector3.Slerp(flyDirection, targetDirection, dt * turnSpeed); flyingHotdog.flyDirection = ((Vector3)(ref val)).normalized; Vector3 move = flyDirection * currentFlySpeed * dt; Vector3 nextPos = ((Component)this).transform.position + move; nextPos.y = Mathf.Clamp(nextPos.y, minFlyHeight, maxFlyHeight); if (Physics.Raycast(((Component)this).transform.position, flyDirection, ref hit, ((Vector3)(ref move)).magnitude + 0.5f)) { Vector3 val2 = Vector3.Reflect(flyDirection, ((RaycastHit)(ref hit)).normal); Vector3 normalized = ((Vector3)(ref val2)).normalized; float num = Random.Range(-45f, 45f); Quaternion val3 = Quaternion.AngleAxis(num, ((RaycastHit)(ref hit)).normal); FlyingHotdog flyingHotdog2 = this; Vector3 val4 = val3 * normalized; flyingHotdog2.flyDirection = ((Vector3)(ref val4)).normalized; targetDirection = flyDirection; } if ((Object)(object)rb == (Object)null) { rb = ((Component)this).GetComponent<Rigidbody>(); } if ((Object)(object)rb != (Object)null) { rb.MovePosition(nextPos); } } } } private void SetInitialDirection() { //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_0009: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * 0.5f; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.x, 0f, val.y); targetDirection = ((Vector3)(ref val2)).normalized; } private void SetTargetDirection() { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) //IL_002d: 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_0054: 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_007d: Unknown result type (might be due to invalid IL or missing references) Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 normalized = ((Vector2)(ref insideUnitCircle)).normalized; float num = Random.Range(0f - verticalVariance, verticalVariance); float num2 = Mathf.Clamp(((Component)this).transform.position.y + num, minFlyHeight, maxFlyHeight) - ((Component)this).transform.position.y; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(normalized.x, num2, normalized.y); targetDirection = ((Vector3)(ref val)).normalized; } private float GetCeilingHeight(Vector3 pos, float min, float max) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (Physics.Raycast(pos + Vector3.up * 2f, Vector3.up, ref val, max - min + 2f)) { return Mathf.Clamp(((RaycastHit)(ref val)).point.y - 1f, min, max); } return Random.Range(min, max); } } [ExecuteInEditMode] public class HolographicSight : MonoBehaviour { public Transform VirtualQuad; public float Scale = 1f; public bool SizeCompensation = true; private MaterialPropertyBlock m_block; private void OnEnable() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown m_block = new MaterialPropertyBlock(); ((Component)this).GetComponent<Renderer>().SetPropertyBlock(m_block); } private void OnWillRenderObject() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.InverseTransformPoint(((Component)VirtualQuad).transform.position); m_block.SetVector("_Offset", Vector4.op_Implicit(val)); m_block.SetFloat("_Scale", Scale); m_block.SetFloat("_SizeCompensation", (!SizeCompensation) ? 0f : 1f); ((Component)this).GetComponent<Renderer>().SetPropertyBlock(m_block); } } public class ClosedBoltMagRelease : FVRInteractiveObject { public ClosedBoltWeapon Weapon; protected void Awake() { ((FVRInteractiveObject)this).Awake(); } public override void SimpleInteraction(FVRViveHand hand) { if ((Object)(object)Weapon != (Object)null && ((Object)(object)((FVRInteractiveObject)Weapon).m_hand == (Object)null || (Object)(object)hand != (Object)(object)((FVRInteractiveObject)Weapon).m_hand)) { ((FVRFireArm)Weapon).EjectMag(false); } ((FVRInteractiveObject)this).SimpleInteraction(hand); } } namespace VolksScripts { public class GiantSlingshot : FVRFireArm { public enum StringScaleAxis { X, Y, Z } public enum AxisDirection { X, Y, Z, NegativeX, NegativeY, NegativeZ } [Header("Slingshot")] public Transform Basket; public Transform String_Left; public Transform String_Right; public Transform Centroid; public Transform String_LeftTarget; public Transform String_RightTarget; public GameObject ColGO_Upper; public GameObject ColGO_Basket; public Collider Col_Basket; [Header("Basket Rotation")] [Tooltip("Local rotation offset applied after LookRotation (degrees).")] public Vector3 BasketRotationOffsetEuler = Vector3.zero; [Tooltip("Use the basket's initial local rotation as an offset (keeps X=90 meshes aligned).")] public bool UseBasketInitialRotationOffset = true; [Tooltip("Which local axis represents the basket's forward direction.")] public AxisDirection BasketForwardAxis = AxisDirection.Y; [Header("String Settings")] [Tooltip("Local rotation offset applied after LookRotation (degrees).")] public Vector3 StringRotationOffsetEuler = Vector3.zero; [Tooltip("Base scale for strings (use to preserve mesh width/height).")] public Vector3 StringBaseScale = Vector3.one; [Tooltip("Which axis should be scaled to match string length.")] public StringScaleAxis StringScaleAxisMode = StringScaleAxis.Z; [Tooltip("Scale relative to rest length so resting scale starts at 1.")] public bool ScaleStringsFromRestLength = true; [Tooltip("Which axis of the string mesh points along the string direction.")] public AxisDirection StringForwardAxis = AxisDirection.Z; [Header("String Behavior Options")] [Tooltip("If true, position string meshes at the midpoint between their anchor and the basket (useful when string pivot is centered).")] public bool UseMidpointForStrings = false; [Tooltip("If true, parent string transforms to the Basket so they follow basket movement/rotation directly. Use carefully.")] public bool ParentStringsToBasket = false; [Header("Debug Gizmos")] [Tooltip("Draw debug gizmos showing anchors, midpoints and string lengths.")] public bool ShowDebugGizmos = true; [Tooltip("Show length labels (editor only).")] public bool ShowGizmoLabels = true; public Color GizmoColorLeft = Color.cyan; public Color GizmoColorRight = Color.magenta; public float GizmoSphereRadius = 0.02f; [Header("Controls")] [Tooltip("Interactive controls (levers, handles, etc.) for the slingshot. Assign in Inspector.")] public List<GameObject> Controls; [Header("Mounting")] public Collider Col; public LayerMask LM_CTest; public float MountRaycastDistance = 0.2f; [Header("Audio")] public AudioEvent AudEvent_Mount; public AudioEvent AudEvent_Fire; [Header("Slingshot Settings")] public float maxSlingVel = 20f; public float maxSlingDistance = 0.5f; private FVRPhysicalObject m_slungObject; private Vector3 m_basketLocalOffset = Vector3.zero; private bool isSlungObjectBeingSlinged; private Vector3 m_basketWorldVel = Vector3.zero; public bool m_isCol; private float m_colChange; private RaycastHit m_hit; private Vector3 m_initHandPointAdjust_Horizontal = Vector3.zero; private Vector3 m_initHandPointAdjust_Vertical = Vector3.zero; private Quaternion m_basketInitialLocalRotation = Quaternion.identity; private float m_leftRestLength = 1f; private float m_rightRestLength = 1f; public bool IsMounted => m_isCol; public override void Awake() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) ((FVRFireArm)this).Awake(); if ((Object)(object)Basket != (Object)null) { m_basketInitialLocalRotation = Basket.localRotation; } if (ParentStringsToBasket) { if ((Object)(object)String_Left != (Object)null) { String_Left.SetParent(Basket, true); } if ((Object)(object)String_Right != (Object)null) { String_Right.SetParent(Basket, true); } } ResetBasketToCentroid(); CacheRestStringLengths(); NormalizeStringsAtRest(); } private void NormalizeStringsAtRest() { //IL_0024: 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_0087: 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_00aa: 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) if ((Object)(object)String_Left != (Object)null && !ParentStringsToBasket) { String_Left.localRotation = Quaternion.identity; } if ((Object)(object)String_Right != (Object)null && !ParentStringsToBasket) { String_Right.localRotation = Quaternion.identity; } if ((Object)(object)String_Left != (Object)null) { String_Left.localScale = ApplyScaleAxis(StringBaseScale, m_leftRestLength, m_leftRestLength); } if ((Object)(object)String_Right != (Object)null) { String_Right.localScale = ApplyScaleAxis(StringBaseScale, m_rightRestLength, m_rightRestLength); } } private void ResetBasketToCentr