using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using Atlas; using BepInEx; using BepInEx.Logging; using FistVR; using GunGame.Scripts; using GunGame.Scripts.Options; using GunGame.Scripts.Weapons; using HarmonyLib; using Sodalite.Api; using Sodalite.Utilities; using Technie.PhysicsCreator.QHull; using UnityEditor; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.UI; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] public class CustomDebug : MonoBehaviourSingleton { public Text DebugWeaponText; public Text DebugAmmoText; } namespace GunGame.Scripts { public class CustomSosigSpawner : MonoBehaviour { public SosigOrder SpawnState; public int IFF; public SpawnedSosigInfo Spawn(SosigEnemyID SosigType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0089: 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) SpawnOptions val = new SpawnOptions(); val.SpawnActivated = true; val.SpawnState = SpawnState; val.IFF = IFF; val.SpawnWithFullAmmo = true; val.EquipmentMode = (EquipmentSlots)7; val.SosigTargetPosition = ((Component)this).transform.position; val.SosigTargetRotation = ((Component)this).transform.eulerAngles; SpawnOptions val2 = val; SosigEnemyTemplate val3 = ManagerSingleton.Instance.odicSosigObjsByID[SosigType]; Sosig spawnedSosig = SosigAPI.Spawn(val3, val2, ((Component)this).transform.position, ((Component)this).transform.rotation); SpawnedSosigInfo result = default(SpawnedSosigInfo); result.SosigType = SosigType; result.SpawnedSosig = spawnedSosig; return result; } private void OnDrawGizmos() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Gizmos.color = new Color(0.8f, 0.2f, 0.2f, 0.5f); Gizmos.DrawSphere(((Component)this).transform.position, 0.1f); Gizmos.DrawLine(((Component)this).transform.position, ((Component)this).transform.position + ((Component)this).transform.forward * 0.25f); } } public struct SpawnedSosigInfo { public SosigEnemyID SosigType; public Sosig SpawnedSosig; } public class EndArea : MonoBehaviour { public Text TimeText; public Text KillsText; public Text DeathsText; public Transform EndPos; public void EndGame() { //IL_000c: 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_0023: 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_005e: Unknown result type (might be due to invalid IL or missing references) GM.CurrentMovementManager.TeleportToPoint(EndPos.position, true, ((Component)this).transform.position + ((Component)this).transform.forward); foreach (Transform playerSpawner in MonoBehaviourSingleton.Instance.PlayerSpawners) { ((Component)playerSpawner).transform.position = EndPos.position; } KillsText.text = "Kills: " + MonoBehaviourSingleton.Instance.Kills; DeathsText.text = "Deaths: " + MonoBehaviourSingleton.Instance.Deaths; TimeSpan timeSpan = TimeSpan.FromSeconds(MonoBehaviourSingleton.Instance.GameTime); TimeText.text = "Time: " + timeSpan.Hours.ToString("00") + ":" + timeSpan.Minutes.ToString("00") + ":" + timeSpan.Seconds.ToString("00"); } } public class GameManager : MonoBehaviourSingleton { [HideInInspector] public int Kills; [HideInInspector] public int Deaths; [HideInInspector] public bool GameEnded; public EndArea EndArea; public static Action BeforeGameStartedEvent; public static Action GameStartedEvent; public PlayerSpawner PlayerSpawner; public List PlayerSpawners; private Progression _progression; private Harmony _harmony; private float _timer; public float GameTime => Time.time - _timer; public override void Awake() { base.Awake(); _progression = ((Component)this).GetComponent(); _harmony = Harmony.CreateAndPatchAll(typeof(PlayerSpawner), (string)null); _harmony.PatchAll(typeof(SosigBehavior)); _harmony.PatchAll(typeof(Progression)); } public void StartGame() { GameEnded = false; if (BeforeGameStartedEvent != null) { BeforeGameStartedEvent(); } _progression.SpawnAndEquip(); PlayerSpawner.MovePlayerToRandomSpawn(); if (GameStartedEvent != null) { GameStartedEvent(); } _timer = Time.time; } public void RemovePausedTime(float timePaused) { _timer += timePaused; } public void EndGame() { EndArea.EndGame(); GameEnded = true; } public void DebugAdvanceWeapon() { _progression.Promote(); } public void DebugPreviousWeapon() { _progression.Demote(); } public void DebugTeleport() { PlayerSpawner.MovePlayerToRandomSpawn(); } public void DebugStart() { if (BeforeGameStartedEvent != null) { BeforeGameStartedEvent(); } _progression.SpawnAndEquip(); if (GameStartedEvent != null) { GameStartedEvent(); } _timer = Time.time; } private void OnDestroy() { _harmony.UnpatchSelf(); } } } public class GunsLeftUI : MonoBehaviour { private Text _gunsLeftText; private void Awake() { _gunsLeftText = ((Component)this).GetComponent(); Progression.WeaponChangedEvent = (Action)Delegate.Combine(Progression.WeaponChangedEvent, new Action(UpdateUI)); } private void UpdateUI() { int num = Mathf.Min(GameSettings.CurrentPool.GetWeaponCount(), WeaponCountOption.WeaponCount); int num2 = MonoBehaviourSingleton.Instance.CurrentWeaponId + 1; int num3 = num - num2; _gunsLeftText.text = "Guns left: " + num3; } private void OnDestroy() { Progression.WeaponChangedEvent = (Action)Delegate.Remove(Progression.WeaponChangedEvent, new Action(UpdateUI)); } } namespace CustomScripts { public class LeverWrapper : MonoBehaviour { public UnityEvent LeverToggleEvent; public UnityEvent LeverOnEvent; public UnityEvent LeverOffEvent; public UnityEvent LeverHoldStartEvent; public UnityEvent LeverHoldEndEvent; private TrapLever _lever; private bool _isOn; private bool _isHeld; private void Awake() { _lever = ((Component)this).GetComponentInChildren(); _lever.MessageTargets.Add(((Component)this).gameObject); } private void Update() { if (!_isHeld && ((FVRInteractiveObject)_lever).IsHeld) { OnHoldStart(); } else if (_isHeld && !((FVRInteractiveObject)_lever).IsHeld) { OnHoldEnd(); } } private void OnHoldStart() { _isHeld = true; if (LeverHoldStartEvent != null) { LeverHoldStartEvent.Invoke(); } } private void OnHoldEnd() { _isHeld = false; if (LeverHoldEndEvent != null) { LeverHoldEndEvent.Invoke(); } } public void ON() { if (!_isOn) { _isOn = true; if (LeverToggleEvent != null) { LeverToggleEvent.Invoke(); } if (LeverOnEvent != null) { LeverOnEvent.Invoke(); } } } public void OFF() { if (_isOn) { _isOn = false; if (LeverToggleEvent != null) { LeverToggleEvent.Invoke(); } if (LeverOffEvent != null) { LeverOffEvent.Invoke(); } } } } } namespace GunGame.Scripts { public class MonoBehaviourSingleton : MonoBehaviour where T : Component { public static T Instance { get; private set; } public virtual void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = (T)(object)((this is T) ? this : null); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } } } namespace GunGame.Scripts.Options { public class GameSettings : MonoBehaviourSingleton { public static Action SettingsChanged; public static Action WeaponPoolChanged; public static bool DisabledAutoLoading; public static bool AlwaysChamberRounds; public static bool HealOnPromotion; public static bool AlwaysResetSosigs; [SerializeField] private Image DisabledAutoLoadingImage; [SerializeField] private Image AlwaysChamberRoundsImage; [SerializeField] private Image HealOnPromotionImage; [SerializeField] private Text MaxSosigCountText; public static int MaxSosigCount; public static WeaponPoolInterface CurrentPool { get; private set; } private void Start() { DisabledAutoLoading = false; AlwaysChamberRounds = false; HealOnPromotion = false; AlwaysResetSosigs = false; ResetMaxSosigCount(); } public void IncreaseMaxSosigCount() { MaxSosigCount++; MaxSosigCountText.text = MaxSosigCount.ToString(); if (SettingsChanged != null) { SettingsChanged(); } } public void DecreaseMaxSosigCount() { MaxSosigCount--; if (MaxSosigCount < 1) { MaxSosigCount = 1; } MaxSosigCountText.text = MaxSosigCount.ToString(); if (SettingsChanged != null) { SettingsChanged(); } } public void ResetMaxSosigCount() { MaxSosigCount = MonoBehaviourSingleton.Instance.MaxSosigCount; MaxSosigCountText.text = MaxSosigCount.ToString(); if (SettingsChanged != null) { SettingsChanged(); } } public void ToggleAutoLoading() { DisabledAutoLoading = !DisabledAutoLoading; ((Behaviour)DisabledAutoLoadingImage).enabled = DisabledAutoLoading; if (SettingsChanged != null) { SettingsChanged(); } } public void ToggleAlwaysChamberRounds() { AlwaysChamberRounds = !AlwaysChamberRounds; ((Behaviour)AlwaysChamberRoundsImage).enabled = AlwaysChamberRounds; if (SettingsChanged != null) { SettingsChanged(); } } public void ToggleHealOnPromotion() { HealOnPromotion = !HealOnPromotion; ((Behaviour)HealOnPromotionImage).enabled = HealOnPromotion; if (SettingsChanged != null) { SettingsChanged(); } } public static void ChangeCurrentPool(WeaponPoolInterface newPool) { CurrentPool = newPool; CurrentPool.Initialize(); MonoBehaviourSingleton.Instance.ProgressionType = CurrentPool.GetProgressionType(); if (WeaponPoolChanged != null) { WeaponPoolChanged(); } if (SettingsChanged != null) { SettingsChanged(); } } } public class KillsPerWeaponOption : MonoBehaviour { public Action OptionChanged; public int DefaultCount; public static int KillsPerWeaponCount; public static string Description; [SerializeField] private Text _counterText; [SerializeField] private Text _descriptionText; private void Awake() { OptionChanged = (Action)Delegate.Combine(OptionChanged, new Action(UpdateUI)); GameSettings.WeaponPoolChanged = (Action)Delegate.Combine(GameSettings.WeaponPoolChanged, new Action(ResetClicked)); } private void Start() { ResetClicked(); } public void ArrowLeftClicked() { KillsPerWeaponCount--; KillProgressionType progressionType = MonoBehaviourSingleton.Instance.ProgressionType; if (KillsPerWeaponCount <= 1 && progressionType != KillProgressionType.Tiers) { KillsPerWeaponCount = 1; } else if (KillsPerWeaponCount <= 0) { KillsPerWeaponCount = 0; } if (OptionChanged != null) { OptionChanged(); } } public void ArrowRightClicked() { KillsPerWeaponCount++; if (OptionChanged != null) { OptionChanged(); } } public void ResetClicked() { UIData progressionTypeUIDefaults = MonoBehaviourSingleton.Instance.GetProgressionTypeUIDefaults(); KillsPerWeaponCount = progressionTypeUIDefaults.Value; Description = progressionTypeUIDefaults.Text; if (OptionChanged != null) { OptionChanged(); } } private void UpdateUI() { _counterText.text = KillsPerWeaponCount.ToString(); _descriptionText.text = Description; } private void OnDestroy() { OptionChanged = (Action)Delegate.Remove(OptionChanged, new Action(UpdateUI)); GameSettings.WeaponPoolChanged = (Action)Delegate.Remove(GameSettings.WeaponPoolChanged, new Action(ResetClicked)); } } public class LeftHandOption : MonoBehaviour { public Action OptionChanged; public static bool LeftHandModeEnabled; [SerializeField] private Image EnabledImage; private void Awake() { OptionChanged = (Action)Delegate.Combine(OptionChanged, new Action(UpdateUI)); LeftHandModeEnabled = false; ((Behaviour)EnabledImage).enabled = false; } public void ToggleClicked() { LeftHandModeEnabled = !LeftHandModeEnabled; if (OptionChanged != null) { OptionChanged(); } } private void UpdateUI() { ((Behaviour)EnabledImage).enabled = LeftHandModeEnabled; } private void OnDestroy() { OptionChanged = (Action)Delegate.Remove(OptionChanged, new Action(UpdateUI)); } } public class MusicToggleOption : MonoBehaviour { public Action OptionChanged; public static bool MusicEnabled; public AudioSource MusicAudioSource; public bool MusicEnabledAtStart = false; [SerializeField] private Image EnabledImage; private void Awake() { OptionChanged = (Action)Delegate.Combine(OptionChanged, new Action(OnToggleMusic)); MusicEnabled = MusicEnabledAtStart; ((Behaviour)EnabledImage).enabled = MusicEnabled; OnToggleMusic(); } public void ToggleClicked() { MusicEnabled = !MusicEnabled; if (OptionChanged != null) { OptionChanged(); } } private void OnToggleMusic() { if (MusicEnabled) { MusicAudioSource.Play(); } else { MusicAudioSource.Stop(); } ((Behaviour)EnabledImage).enabled = MusicEnabled; } private void OnDestroy() { OptionChanged = (Action)Delegate.Remove(OptionChanged, new Action(OnToggleMusic)); } } public class QuickbeltOption : MonoBehaviour { public static FVRQuickBeltSlot AmmoQuickbeltSlot; public static FVRQuickBeltSlot ExtraQuickbeltSlot; private FVRPhysicalObject MagObject; private FVRPhysicalObject ExtraObject; public Transform MagSpawnPos; private string _magName = "MagazineStanag5rnd"; private string _extraName = "ReflexGamepointRDS"; private void Awake() { GameManager.BeforeGameStartedEvent = (Action)Delegate.Combine(GameManager.BeforeGameStartedEvent, new Action(OnGameStart)); } private IEnumerator Start() { yield return (object)new WaitForSeconds(0.2f); SpawnMag(); SpawnExtra(); } private void OnGameStart() { AmmoQuickbeltSlot = GM.CurrentPlayerBody.QBSlots_Internal[0]; ExtraQuickbeltSlot = GM.CurrentPlayerBody.QBSlots_Internal[1]; if (Object.op_Implicit((Object)(object)MagObject.QuickbeltSlot)) { Debug.Log((object)"Found mag slot item"); AmmoQuickbeltSlot = MagObject.QuickbeltSlot; } else if ((Object)(object)ExtraObject.QuickbeltSlot == (Object)(object)GM.CurrentPlayerBody.QBSlots_Internal[0]) { Debug.Log((object)"Default mag slot"); AmmoQuickbeltSlot = GM.CurrentPlayerBody.QBSlots_Internal[1]; } if (Object.op_Implicit((Object)(object)ExtraObject.QuickbeltSlot)) { Debug.Log((object)"Found extra slot item"); ExtraQuickbeltSlot = ExtraObject.QuickbeltSlot; } else if ((Object)(object)MagObject.QuickbeltSlot == (Object)(object)GM.CurrentPlayerBody.QBSlots_Internal[1]) { Debug.Log((object)"Default extra slot"); ExtraQuickbeltSlot = GM.CurrentPlayerBody.QBSlots_Internal[0]; } if (Object.op_Implicit((Object)(object)AmmoQuickbeltSlot.CurObject)) { AmmoQuickbeltSlot.CurObject.ClearQuickbeltState(); } if (Object.op_Implicit((Object)(object)ExtraQuickbeltSlot.CurObject)) { ExtraQuickbeltSlot.CurObject.ClearQuickbeltState(); } } private void SpawnMag() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) FVRObject value = null; if (!IM.OD.TryGetValue(_magName, out value)) { Debug.LogError((object)("No object found with id: " + _magName)); return; } GameObject gameObject = ((AnvilAsset)value).GetGameObject(); Vector3 position = ((Component)MagSpawnPos).transform.position; position.z -= 0.2f; GameObject val = Object.Instantiate(gameObject, position, ((Component)this).transform.rotation); val.SetActive(true); MagObject = val.GetComponent(); } private void SpawnExtra() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) FVRObject value = null; if (!IM.OD.TryGetValue(_extraName, out value)) { Debug.LogError((object)("No object found with id: " + _extraName)); return; } GameObject gameObject = ((AnvilAsset)value).GetGameObject(); Vector3 position = ((Component)MagSpawnPos).transform.position; position.z += 0.2f; GameObject val = Object.Instantiate(gameObject, position, ((Component)this).transform.rotation); val.SetActive(true); ExtraObject = val.GetComponent(); } private void OnDestroy() { GameManager.BeforeGameStartedEvent = (Action)Delegate.Remove(GameManager.BeforeGameStartedEvent, new Action(OnGameStart)); } } public class SelectedPoolUI : MonoBehaviour { public Text TitleText; public Text DescriptionText; private void Awake() { GameSettings.SettingsChanged = (Action)Delegate.Combine(GameSettings.SettingsChanged, new Action(OnSettingsChanged)); } private void OnSettingsChanged() { TitleText.text = GameSettings.CurrentPool.GetName(); DescriptionText.text = GameSettings.CurrentPool.GetDescription(); } private void OnDestroy() { GameSettings.SettingsChanged = (Action)Delegate.Remove(GameSettings.SettingsChanged, new Action(OnSettingsChanged)); } } public class StartingHealthOption : MonoBehaviour { public Action OptionChanged; public int[] PossibleHealth; private int _optionIndex = 1; public static int CurrentHealth = 1000; [SerializeField] private Text _healthText; private void Awake() { PossibleHealth = new int[5] { 100, 1000, 2000, 5000, 10000 }; OptionChanged = (Action)Delegate.Combine(OptionChanged, new Action(UpdateUI)); OptionChanged = (Action)Delegate.Combine(OptionChanged, new Action(UpdateHealth)); } private IEnumerator Start() { yield return (object)new WaitForSeconds(0.1f); ResetClicked(); } public void ArrowLeftClicked() { _optionIndex--; if (_optionIndex < 0) { _optionIndex = 0; } CurrentHealth = PossibleHealth[_optionIndex]; if (OptionChanged != null) { OptionChanged(); } } public void ArrowRightClicked() { _optionIndex++; if (_optionIndex >= PossibleHealth.Length) { _optionIndex = PossibleHealth.Length - 1; } CurrentHealth = PossibleHealth[_optionIndex]; if (OptionChanged != null) { OptionChanged(); } } public void ResetClicked() { _optionIndex = 1; CurrentHealth = PossibleHealth[_optionIndex]; if (OptionChanged != null) { OptionChanged(); } } private void UpdateHealth() { GM.CurrentPlayerBody.SetHealthThreshold((float)CurrentHealth); GM.CurrentPlayerBody.ResetHealth(); } private void UpdateUI() { _healthText.text = CurrentHealth.ToString(); } private void OnDestroy() { OptionChanged = (Action)Delegate.Remove(OptionChanged, new Action(UpdateUI)); OptionChanged = (Action)Delegate.Remove(OptionChanged, new Action(UpdateHealth)); } } public class WeaponCountOption : MonoBehaviour { public Action OptionChanged; public static int WeaponCount; [SerializeField] private Text _counterText; private void Awake() { OptionChanged = (Action)Delegate.Combine(OptionChanged, new Action(UpdateUI)); GameSettings.WeaponPoolChanged = (Action)Delegate.Combine(GameSettings.WeaponPoolChanged, new Action(ResetClicked)); } public void ArrowLeftClicked() { WeaponCount--; if (WeaponCount <= 1) { WeaponCount = 1; } if (OptionChanged != null) { OptionChanged(); } } public void ArrowRightClicked() { WeaponCount++; if (WeaponCount > GameSettings.CurrentPool.GetWeaponCount()) { WeaponCount = GameSettings.CurrentPool.GetWeaponCount(); } if (OptionChanged != null) { OptionChanged(); } } public void ArrowRight10Clicked() { WeaponCount += 20; if (WeaponCount > GameSettings.CurrentPool.GetWeaponCount()) { WeaponCount = GameSettings.CurrentPool.GetWeaponCount(); } if (OptionChanged != null) { OptionChanged(); } } public void ArrowLeft10Clicked() { WeaponCount -= 20; if (WeaponCount <= 1) { WeaponCount = 1; } if (OptionChanged != null) { OptionChanged(); } } public void ResetClicked() { WeaponCount = GameSettings.CurrentPool.GetWeaponCount(); if (OptionChanged != null) { OptionChanged(); } } private void UpdateUI() { _counterText.text = WeaponCount.ToString(); } private void OnDestroy() { OptionChanged = (Action)Delegate.Remove(OptionChanged, new Action(UpdateUI)); GameSettings.WeaponPoolChanged = (Action)Delegate.Remove(GameSettings.WeaponPoolChanged, new Action(ResetClicked)); } } } public class Pause : MonoBehaviour { [SerializeField] private Transform PauseWaypoint; [SerializeField] private Transform UnPauseWaypoint; [SerializeField] private Text TimeText; [SerializeField] private Text KillsText; [SerializeField] private Text DeathsText; private float _pauseTimer; public void PauseTheGame() { //IL_000c: 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_0023: 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) GM.CurrentMovementManager.TeleportToPoint(PauseWaypoint.position, true, ((Component)this).transform.position + ((Component)this).transform.forward); KillsText.text = "Kills: " + MonoBehaviourSingleton.Instance.Kills; DeathsText.text = "Deaths: " + MonoBehaviourSingleton.Instance.Deaths; TimeSpan timeSpan = TimeSpan.FromSeconds(MonoBehaviourSingleton.Instance.GameTime); TimeText.text = "Time: " + timeSpan.Hours.ToString("00") + ":" + timeSpan.Minutes.ToString("00") + ":" + timeSpan.Seconds.ToString("00"); _pauseTimer = Time.time; } public void UnpauseTheGame() { //IL_000c: 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_0023: 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) GM.CurrentMovementManager.TeleportToPoint(UnPauseWaypoint.position, true, ((Component)this).transform.position + ((Component)this).transform.forward); float timePaused = Time.time - _pauseTimer; MonoBehaviourSingleton.Instance.RemovePausedTime(timePaused); } } public class PlayerFollower : MonoBehaviour { private bool _isActive; private Transform _transform; private Transform _playerHeadTransform; private void Awake() { _transform = ((Component)this).GetComponent(); } private IEnumerator Start() { yield return (object)new WaitForSeconds(0.1f); _playerHeadTransform = ((Component)GM.CurrentPlayerBody.Head).transform; _isActive = true; } private void Update() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_0049: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (_isActive) { _transform.position = _playerHeadTransform.position; Quaternion rotation = _playerHeadTransform.rotation; float y = ((Quaternion)(ref rotation)).eulerAngles.y; Quaternion rotation2 = _transform.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation2)).eulerAngles; eulerAngles.y = y; _transform.rotation = Quaternion.Euler(eulerAngles); } } } namespace GunGame.Scripts { public class PlayerSpawner : MonoBehaviourSingleton { public static Action BeingRevivedEvent; public Progression Progression; private IEnumerator Start() { yield return null; GM.CurrentSceneSettings.DeathResetPoint = ((Component)this).transform; GM.CurrentMovementManager.TeleportToPoint(((Component)this).transform.position, true, ((Component)this).transform.position + ((Component)this).transform.forward); } private IEnumerator DelayedRespawn() { MonoBehaviourSingleton.Instance.Deaths++; MonoBehaviourSingleton.Instance.KillsWithCurrentWeapon = 0; MonoBehaviourSingleton.Instance.CurrentTier = 0; yield return (object)new WaitForSeconds(3f); if (MonoBehaviourSingleton.Instance.ProgressionType == KillProgressionType.Tiers || GameSettings.AlwaysResetSosigs) { ((MonoBehaviour)this).StartCoroutine(MonoBehaviourSingleton.Instance.ClearSosigs()); } MonoBehaviourSingleton.Instance.Demote(); GM.CurrentPlayerBody.ActivatePower((PowerupType)3, (PowerUpIntensity)0, (PowerUpDuration)2, false, false, -1f); GM.CurrentPlayerBody.HealPercent(100f); MovePlayerToRandomSpawn(); if (BeingRevivedEvent != null) { BeingRevivedEvent(); } } [HarmonyPatch(typeof(GM), "KillPlayer", new Type[] { typeof(bool) })] [HarmonyPatch(typeof(GM), "KillPlayer", new Type[] { typeof(bool), typeof(int) })] [HarmonyPostfix] private static void Postfix() { MonoBehaviourSingleton.Instance.OnPlayerDeath(); } private void OnPlayerDeath() { ((MonoBehaviour)this).StartCoroutine(DelayedRespawn()); } public void MovePlayerToRandomSpawn() { //IL_002d: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) int index = Random.Range(0, MonoBehaviourSingleton.Instance.PlayerSpawners.Count); ((Component)this).transform.position = MonoBehaviourSingleton.Instance.PlayerSpawners[index].position; GM.CurrentMovementManager.TeleportToPoint(((Component)this).transform.position, true, ((Component)this).transform.position + ((Component)this).transform.forward); } private void OnDrawGizmos() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Gizmos.color = new Color(0.2f, 0.8f, 0.2f, 0.5f); Gizmos.DrawSphere(((Component)this).transform.position, 0.1f); Gizmos.DrawLine(((Component)this).transform.position, ((Component)this).transform.position + ((Component)this).transform.forward * 0.25f); } } public class Progression : MonoBehaviourSingleton { public static Action SosigDespawnedEvent; public static Action WeaponChangedEvent; public AudioSource EquipSound; [HideInInspector] public int KillsWithCurrentWeapon = 0; public static List DeadSosigs = new List(); private List _currentEquipment = new List(); private WeaponBuffer _weaponBuffer; [HideInInspector] public KillProgressionType ProgressionType = KillProgressionType.Count; [HideInInspector] private List Enemies = new List(); [HideInInspector] public int CurrentTier = 0; [HideInInspector] private int ProbabilityTotal = 0; [HideInInspector] private int InverseProbabilityTotal = 0; public int CurrentWeaponId { get; private set; } public override void Awake() { base.Awake(); _weaponBuffer = ((Component)this).GetComponent(); } public void Demote() { if (!MonoBehaviourSingleton.Instance.GameEnded) { CurrentWeaponId--; if (CurrentWeaponId < 0) { CurrentWeaponId = 0; } SpawnAndEquip(demotion: true); } } public void Promote() { if (!MonoBehaviourSingleton.Instance.GameEnded) { if (GameSettings.HealOnPromotion) { GM.CurrentPlayerBody.HealPercent(100f); } CurrentWeaponId++; KillsWithCurrentWeapon = 0; if (CurrentWeaponId >= GameSettings.CurrentPool.GetWeaponCount() || CurrentWeaponId >= WeaponCountOption.WeaponCount) { CurrentWeaponId = GameSettings.CurrentPool.GetWeaponCount() - 1; MonoBehaviourSingleton.Instance.EndGame(); } else { EquipSound.Play(); SpawnAndEquip(); } } } public void SpawnAndEquip(bool demotion = false) { DestroyOldEq(); if (((Component)MonoBehaviourSingleton.Instance.DebugWeaponText).gameObject.activeInHierarchy) { MonoBehaviourSingleton.Instance.DebugWeaponText.text = "Weapon " + GameSettings.CurrentPool.GetWeapon(CurrentWeaponId).GunName; MonoBehaviourSingleton.Instance.DebugAmmoText.text = "Ammo " + GameSettings.CurrentPool.GetWeapon(CurrentWeaponId).MagName; } FVRPhysicalObject fromBuffer = _weaponBuffer.GetFromBuffer(ObjectType.Gun, CurrentWeaponId, demotion); if ((Object)(object)fromBuffer == (Object)null) { Debug.LogError((object)"Trying to equip null gun! Probably the ObjectId is invalid. Attempting a fix by promoting the player"); Promote(); return; } _currentEquipment.Add(((Component)fromBuffer).gameObject); if (Utility.IsNullOrWhiteSpace(GameSettings.CurrentPool.GetWeapon(CurrentWeaponId).MagName)) { EquipWeapon(fromBuffer); _weaponBuffer.DestroyMagBuffer(); } else { FVRPhysicalObject fromBuffer2 = _weaponBuffer.GetFromBuffer(ObjectType.MagazineToLoad, CurrentWeaponId, demotion); if ((Object)(object)fromBuffer2 == (Object)null) { Debug.LogError((object)"Trying to equip null magazine! Probably the ObjectId is invalid. Attempting a fix by promoting the player"); Promote(); return; } fromBuffer2.UsesGravity = false; fromBuffer2.RootRigidbody.isKinematic = true; FVRPhysicalObject fromBuffer3 = _weaponBuffer.GetFromBuffer(ObjectType.MagazineForQuickbelt, CurrentWeaponId, demotion); _currentEquipment.Add(((Component)fromBuffer2).gameObject); _currentEquipment.Add(((Component)fromBuffer3).gameObject); if (!GameSettings.DisabledAutoLoading) { LoadTheGun(fromBuffer, fromBuffer2); } EquipWeapon(fromBuffer); FixAmmoRotation(); MoveMagazineToSlot(fromBuffer3); } if (!Utility.IsNullOrWhiteSpace(GameSettings.CurrentPool.GetWeapon(CurrentWeaponId).Extra)) { FVRPhysicalObject fromBuffer4 = _weaponBuffer.GetFromBuffer(ObjectType.Extra, CurrentWeaponId, demotion); _currentEquipment.Add(((Component)fromBuffer4).gameObject); MoveExtraToSlot(fromBuffer4); } _weaponBuffer.ClearBuffer(); _weaponBuffer.GenerateBuffer(CurrentWeaponId); if (WeaponChangedEvent != null) { WeaponChangedEvent(); } } private void DestroyOldEq() { for (int i = 0; i < _currentEquipment.Count; i++) { if (Object.op_Implicit((Object)(object)_currentEquipment[i]) && Object.op_Implicit((Object)(object)_currentEquipment[i].GetComponent())) { ((FVRInteractiveObject)_currentEquipment[i].GetComponent()).ForceBreakInteraction(); } Object.Destroy((Object)(object)_currentEquipment[i]); } _currentEquipment.Clear(); } private void MoveMagazineToSlot(FVRPhysicalObject magazine) { if (Object.op_Implicit((Object)(object)QuickbeltOption.AmmoQuickbeltSlot.CurObject)) { QuickbeltOption.AmmoQuickbeltSlot.CurObject.ClearQuickbeltState(); } magazine.ForceObjectIntoInventorySlot(QuickbeltOption.AmmoQuickbeltSlot); magazine.m_isSpawnLock = true; } private void MoveExtraToSlot(FVRPhysicalObject extra) { if (Object.op_Implicit((Object)(object)QuickbeltOption.ExtraQuickbeltSlot.CurObject)) { QuickbeltOption.ExtraQuickbeltSlot.CurObject.ClearQuickbeltState(); } extra.ForceObjectIntoInventorySlot(QuickbeltOption.ExtraQuickbeltSlot); } private void LoadTheGun(FVRPhysicalObject weapon, FVRPhysicalObject ammo) { //IL_0015: 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_0096: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((ammo is FVRFireArmMagazine) ? ammo : null) != (Object)null) { try { ((FVRFireArmMagazine)ammo).Load((FVRFireArm)(object)((weapon is FVRFireArm) ? weapon : null)); } catch (Exception) { Debug.LogWarning((object)("Weapon failed to load magazine for gun " + weapon.ObjectWrapper.DisplayName + " with magazine " + ammo.ObjectWrapper.DisplayName)); } } else if (Object.op_Implicit((Object)(object)((Component)weapon).GetComponentInChildren()) && (Object)(object)((ammo is Speedloader) ? ammo : null) != (Object)null) { ((Component)weapon).GetComponentInChildren().LoadFromSpeedLoader((Speedloader)ammo); } else if (GameSettings.AlwaysChamberRounds || ((Object)(object)((ammo is FVRFireArmMagazine) ? ammo : null) == (Object)null && (Object)(object)((Component)weapon).GetComponentInChildren() == (Object)null && (Object)(object)((weapon is FVRFireArm) ? weapon : null) != (Object)null)) { try { List chambers = ((Component)weapon).GetComponent().GetChambers(); foreach (FVRFireArmChamber item in chambers) { FVRFireArmRound component = ((Component)_weaponBuffer.SpawnImmediate(ObjectType.MagazineToLoad, GameSettings.CurrentPool.GetWeapon(CurrentWeaponId))).GetComponent(); item.SetRound(component, false); } BreakActionWeapon componentInChildren = ((Component)weapon).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.CockAllHammers(); } } catch (Exception) { Debug.LogWarning((object)("Error while trying to load gun chambers manually for a gun: " + ((Object)weapon).name + " and ammo: " + ((Object)ammo).name)); } } FVRFireArmMagazine componentInChildren2 = ((Component)weapon).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren2)) { FireArmRoundClass @class = AM.SRoundDisplayDataDic[componentInChildren2.RoundType].Classes[0].Class; componentInChildren2.ReloadMagWithType(@class); } } public void FixAmmoRotation() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_currentEquipment[0]) && Object.op_Implicit((Object)(object)_currentEquipment[1]) && Object.op_Implicit((Object)(object)_currentEquipment[0].GetComponent()) && Object.op_Implicit((Object)(object)_currentEquipment[0].GetComponent().MagazineMountPos)) { _currentEquipment[1].transform.rotation = ((Component)_currentEquipment[0].GetComponent().MagazineMountPos).transform.rotation; } } private void EquipWeapon(FVRPhysicalObject weapon) { FVRViveHand val = GM.CurrentMovementManager.Hands[1]; if (LeftHandOption.LeftHandModeEnabled) { val = GM.CurrentMovementManager.Hands[0]; } val.RetrieveObject(weapon); } private static void OnSosigKilledByPlayer(Sosig killedSosig) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) MonoBehaviourSingleton.Instance.Kills++; SosigEnemyID val = MonoBehaviourSingleton.Instance.Sosigs[killedSosig]; if (MonoBehaviourSingleton.Instance.ProgressionType == KillProgressionType.Points) { int num = 1; foreach (EnemyData enemy in MonoBehaviourSingleton.Instance.Enemies) { if (enemy.EnemyName == val) { num = enemy.Value; break; } } MonoBehaviourSingleton.Instance.KillsWithCurrentWeapon += num; if (MonoBehaviourSingleton.Instance.KillsWithCurrentWeapon >= KillsPerWeaponOption.KillsPerWeaponCount) { MonoBehaviourSingleton.Instance.Promote(); } } else if (MonoBehaviourSingleton.Instance.ProgressionType == KillProgressionType.Tiers) { int num2 = -1; int num3 = -1; foreach (EnemyData enemy2 in MonoBehaviourSingleton.Instance.Enemies) { num3++; if (enemy2.EnemyName == val) { num2 = num3; break; } } if (num2 == -1) { MonoBehaviourSingleton.Instance.KillsWithCurrentWeapon = 0; MonoBehaviourSingleton.Instance.CurrentTier = 0; MonoBehaviourSingleton.Instance.Promote(); } else { if (num2 != MonoBehaviourSingleton.Instance.CurrentTier) { return; } MonoBehaviourSingleton.Instance.KillsWithCurrentWeapon++; if (MonoBehaviourSingleton.Instance.KillsWithCurrentWeapon >= MonoBehaviourSingleton.Instance.Enemies[MonoBehaviourSingleton.Instance.CurrentTier].Value + KillsPerWeaponOption.KillsPerWeaponCount) { MonoBehaviourSingleton.Instance.CurrentTier++; MonoBehaviourSingleton.Instance.KillsWithCurrentWeapon = 0; if (MonoBehaviourSingleton.Instance.CurrentTier == MonoBehaviourSingleton.Instance.Enemies.Count) { MonoBehaviourSingleton.Instance.CurrentTier = 0; MonoBehaviourSingleton.Instance.Promote(); } } } } else { MonoBehaviourSingleton.Instance.KillsWithCurrentWeapon++; if (MonoBehaviourSingleton.Instance.KillsWithCurrentWeapon >= KillsPerWeaponOption.KillsPerWeaponCount) { MonoBehaviourSingleton.Instance.Promote(); } } } [HarmonyPatch(typeof(Sosig), "SosigDies")] [HarmonyPostfix] private static void OnSosigDied(Sosig __instance, DamageClass damClass, SosigDeathType deathType) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if (!DeadSosigs.Contains(((Object)__instance).GetInstanceID())) { DeadSosigs.Add(((Object)__instance).GetInstanceID()); if (__instance.GetDiedFromIFF() == GM.CurrentPlayerBody.GetPlayerIFF()) { OnSosigKilledByPlayer(__instance); } __instance.DeSpawnSosig(); MonoBehaviourSingleton.Instance.OnSosigKilled(__instance); SosigEnemyID nextSosigType = GetNextSosigType(); MonoBehaviourSingleton.Instance.SpawnSosigRandomPlace(nextSosigType); } } public void InitEnemyProgression() { ProbabilityTotal = 0; InverseProbabilityTotal = 0; ProgressionType = GameSettings.CurrentPool.GetProgressionType(); Enemies = GameSettings.CurrentPool.GetEnemies(); foreach (EnemyData enemy in MonoBehaviourSingleton.Instance.Enemies) { if (enemy.Value == 0) { enemy.Value = 1; } } if (MonoBehaviourSingleton.Instance.ProgressionType == KillProgressionType.Points) { foreach (EnemyData enemy2 in MonoBehaviourSingleton.Instance.Enemies) { InverseProbabilityTotal += Math.Max(1, (int)(1f / (float)enemy2.Value * 100f)); } } foreach (EnemyData enemy3 in MonoBehaviourSingleton.Instance.Enemies) { ProbabilityTotal += enemy3.Value; } } public static SosigEnemyID GetNextSosigType() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) if (MonoBehaviourSingleton.Instance.Enemies.Count == 0) { Debug.Log((object)"No enemies loaded, make sure that your weaponpool is formatted correctly!"); return (SosigEnemyID)1200; } if (MonoBehaviourSingleton.Instance.ProgressionType == KillProgressionType.Count) { if (MonoBehaviourSingleton.Instance.ProbabilityTotal == 0) { Debug.Log((object)"All probabilities set to 0!"); return MonoBehaviourSingleton.Instance.Enemies[Random.Range(0, MonoBehaviourSingleton.Instance.Enemies.Count - 1)].EnemyName; } int num = Random.Range(0, MonoBehaviourSingleton.Instance.ProbabilityTotal); int num2 = 0; foreach (EnemyData enemy in MonoBehaviourSingleton.Instance.Enemies) { num2 += enemy.Value; if (num < num2) { return enemy.EnemyName; } } Debug.Log((object)"Default enemy selected"); return MonoBehaviourSingleton.Instance.Enemies[MonoBehaviourSingleton.Instance.Enemies.Count - 1].EnemyName; } if (MonoBehaviourSingleton.Instance.ProgressionType == KillProgressionType.Points) { if (MonoBehaviourSingleton.Instance.ProbabilityTotal == 0) { Debug.Log((object)"All probabilities set to 0!"); return MonoBehaviourSingleton.Instance.Enemies[Random.Range(0, MonoBehaviourSingleton.Instance.Enemies.Count - 1)].EnemyName; } int num3 = Random.Range(0, MonoBehaviourSingleton.Instance.InverseProbabilityTotal); int num4 = 0; foreach (EnemyData enemy2 in MonoBehaviourSingleton.Instance.Enemies) { num4 += Math.Max(1, (int)(1f / (float)enemy2.Value * 100f)); if (num3 < num4) { return enemy2.EnemyName; } } Debug.Log((object)"Default enemy selection"); return MonoBehaviourSingleton.Instance.Enemies[MonoBehaviourSingleton.Instance.Enemies.Count - 1].EnemyName; } if (MonoBehaviourSingleton.Instance.ProgressionType == KillProgressionType.Tiers) { return MonoBehaviourSingleton.Instance.Enemies[MonoBehaviourSingleton.Instance.CurrentTier].EnemyName; } Debug.Log((object)"Progression type isn't handled correctly somehow, check that your weaponpool file is formatted correctly!"); return (SosigEnemyID)1210; } public UIData GetProgressionTypeUIDefaults() { UIData result = default(UIData); switch (GameSettings.CurrentPool.GetProgressionType()) { case KillProgressionType.Points: { result.Text = "Points to advance"; int num = 0; foreach (EnemyData enemy in GameSettings.CurrentPool.GetEnemies()) { num += enemy.Value; } result.Value = num; break; } case KillProgressionType.Tiers: result.Text = "Extra kills per tier"; result.Value = 0; break; default: result.Text = "Kills to advance"; result.Value = 3; break; } return result; } } public enum KillProgressionType { Count, Points, Tiers } public struct UIData { public string Text; public int Value; } public class SosigBehavior : MonoBehaviourSingleton { public int MaxSosigCount = 8; [HideInInspector] public int RealSosigCount; [Header("Don't spawn sosigs too close or too far from the player")] public int IgnoredSpawnersCloseToPlayer = 2; public int IgnoredSpawnersFarFromPlayer = 0; public bool DespawnDistantSosigs = false; public float MaxSosigDistanceFromPlayer = 0f; public float HearRangeMultiplier = 1f; public float SightRangeMultiplier = 1f; public List Waypoints; public List SosigSpawners; [HideInInspector] public Dictionary Sosigs; public override void Awake() { base.Awake(); Sosigs = new Dictionary(); GameManager.GameStartedEvent = (Action)Delegate.Combine(GameManager.GameStartedEvent, new Action(OnGameStarted)); } private void OnGameStarted() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) MonoBehaviourSingleton.Instance.InitEnemyProgression(); RealSosigCount = GameSettings.MaxSosigCount; for (int i = 0; i < RealSosigCount; i++) { SpawnSosigRandomPlace(Progression.GetNextSosigType()); } ((MonoBehaviour)this).StartCoroutine(UpdateWaypoints()); } [HarmonyPatch(typeof(Sosig), "Start")] [HarmonyPostfix] private static void SosigSpawned(Sosig __instance) { __instance.CanBeKnockedOut = false; __instance.m_maxUnconsciousTime = 0f; __instance.BleedRateMult = 0.1f; for (int i = 0; i < __instance.Links.Count; i++) { __instance.Links[i].SetIntegrity(__instance.Links[i].m_integrity * 0.65f); } __instance.Links[0].DamMult = 13.5f; __instance.Links[1].DamMult = 6f; __instance.Links[2].DamMult = 5f; __instance.Links[3].DamMult = 4f; __instance.MaxHearingRange *= MonoBehaviourSingleton.Instance.HearRangeMultiplier; __instance.MaxSightRange *= MonoBehaviourSingleton.Instance.SightRangeMultiplier; if (MonoBehaviourSingleton.Instance.DespawnDistantSosigs) { ((MonoBehaviour)MonoBehaviourSingleton.Instance).StartCoroutine(MonoBehaviourSingleton.Instance.CheckSosigDistance(__instance)); } } private IEnumerator UpdateWaypoints() { while (true) { for (int i = 0; i < Sosigs.Count; i++) { if (i >= 0 && i < Sosigs.Count) { Sosig key = Sosigs.ElementAt(i).Key; if (!((Object)(object)key == (Object)null)) { key.SetCurrentOrder((SosigOrder)7); key.CommandAssaultPoint(Waypoints[Random.Range(0, Waypoints.Count)].position); } } } yield return (object)new WaitForSeconds((float)Random.Range(12, 25)); } } private IEnumerator CheckSosigDistance(Sosig sosig) { WaitForSeconds delay = new WaitForSeconds(6f); while ((Object)(object)sosig != (Object)null) { yield return delay; if (Vector3.Distance(((Component)GM.CurrentPlayerBody).transform.position, ((Component)sosig).transform.position) > MaxSosigDistanceFromPlayer) { if (!Progression.DeadSosigs.Contains(((Object)sosig).GetInstanceID())) { SosigEnemyID sosigtype = Sosigs[sosig]; Sosigs.Remove(sosig); sosig.DeSpawnSosig(); MonoBehaviourSingleton.Instance.SpawnSosigRandomPlace(sosigtype); } break; } } } public void SpawnSosigRandomPlace(SosigEnemyID sosigtype) { //IL_0095: 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) List list = SosigSpawners.OrderBy((CustomSosigSpawner spawner) => Vector3.Distance(((Component)spawner).transform.position, ((Component)GM.CurrentPlayerBody).transform.position)).ToList(); if (IgnoredSpawnersCloseToPlayer > list.Count || IgnoredSpawnersFarFromPlayer > list.Count || IgnoredSpawnersCloseToPlayer + IgnoredSpawnersFarFromPlayer > list.Count) { Debug.LogError((object)"Ignoring more spawners than available, aborting"); } int index = Random.Range(IgnoredSpawnersCloseToPlayer, list.Count - IgnoredSpawnersFarFromPlayer); SpawnedSosigInfo spawnedSosigInfo = list[index].Spawn(sosigtype); Sosigs.Add(spawnedSosigInfo.SpawnedSosig, spawnedSosigInfo.SosigType); } public void OnSosigKilled(Sosig sosig) { Sosigs.Remove(sosig); } public IEnumerator ClearSosigs() { List TempSosigsList = new List(); foreach (Sosig key in Sosigs.Keys) { TempSosigsList.Add(key); } foreach (Sosig sosig in TempSosigsList) { Sosigs.Remove(sosig); sosig.DeSpawnSosig(); SosigEnemyID sosigType = Progression.GetNextSosigType(); yield return (object)new WaitForSeconds(1f); MonoBehaviourSingleton.Instance.SpawnSosigRandomPlace(sosigType); } } private void OnDestroy() { GameManager.GameStartedEvent = (Action)Delegate.Remove(GameManager.GameStartedEvent, new Action(OnGameStarted)); } } } namespace GunGame.Scripts.Weapons { [Serializable] public class EnemyData { public SosigEnemyID EnemyName = (SosigEnemyID)1; public string EnemyNameString = ""; public int Value = 0; public EnemyData(SosigEnemyID InputEnum, int InputValue) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) EnemyName = InputEnum; Value = InputValue; } public EnemyData(string InputNameString, int InputValue) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) EnemyName = StringToSosigID(InputNameString); Value = InputValue; } private SosigEnemyID StringToSosigID(string InputString) { //IL_0032: 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_0039: 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_0040: Unknown result type (might be due to invalid IL or missing references) try { return (SosigEnemyID)Enum.Parse(typeof(SosigEnemyID), InputString, ignoreCase: true); } catch (Exception) { Debug.LogError((object)(InputString + " is not a valid SosigEnemyID, please check your weapon pool format")); return (SosigEnemyID)1; } } } [Serializable] public class GunData { public string GunName; public string MagName; public List MagNames; public string Extra; public int CategoryID; public override string ToString() { return "Name: " + GunName + ", MagName: " + MagName + ", Extra: " + Extra; } } public class PoolChoice : MonoBehaviour { public Text TitleText; public Button Button; private WeaponPoolInterface _weaponPool; public void Initialize(WeaponPoolInterface weaponPool) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown _weaponPool = weaponPool; TitleText.text = _weaponPool.GetName(); ((UnityEvent)Button.onClick).AddListener(new UnityAction(OnClick)); } public void OnClick() { GameSettings.ChangeCurrentPool(_weaponPool); } } public class WeaponBuffer : MonoBehaviour { public Transform BufferSpawnPos; private FVRPhysicalObject _gun; private FVRPhysicalObject _magazineToLoad; private FVRPhysicalObject _magazineForQuickbelt; private FVRPhysicalObject GetBufferObject(ObjectType type) { return (FVRPhysicalObject)(type switch { ObjectType.Gun => _gun, ObjectType.MagazineToLoad => _magazineToLoad, ObjectType.MagazineForQuickbelt => _magazineForQuickbelt, _ => null, }); } public FVRPhysicalObject GetFromBuffer(ObjectType type, int index, bool demoted) { FVRPhysicalObject bufferObject = GetBufferObject(type); if (demoted) { if (Object.op_Implicit((Object)(object)bufferObject)) { Object.Destroy((Object)(object)((Component)bufferObject).gameObject); } return SpawnImmediate(type, GameSettings.CurrentPool.GetWeapon(index)); } FVRPhysicalObject val = bufferObject; if ((Object)(object)val == (Object)null) { val = SpawnImmediate(type, GameSettings.CurrentPool.GetWeapon(index)); } return val; } public void ClearBuffer() { _gun = null; _magazineToLoad = null; _magazineForQuickbelt = null; } public void DestroyMagBuffer() { if (Object.op_Implicit((Object)(object)_magazineToLoad)) { Object.Destroy((Object)(object)((Component)_magazineToLoad).gameObject); } if (Object.op_Implicit((Object)(object)_magazineForQuickbelt)) { Object.Destroy((Object)(object)((Component)_magazineForQuickbelt).gameObject); } } public void GenerateBuffer(int currentIndex) { if (currentIndex + 1 < GameSettings.CurrentPool.GetWeaponCount()) { ((MonoBehaviour)this).StartCoroutine(SpawnAsync(ObjectType.Gun, GameSettings.CurrentPool.GetWeapon(currentIndex + 1))); ((MonoBehaviour)this).StartCoroutine(SpawnAsync(ObjectType.MagazineToLoad, GameSettings.CurrentPool.GetWeapon(currentIndex + 1))); ((MonoBehaviour)this).StartCoroutine(SpawnAsync(ObjectType.MagazineForQuickbelt, GameSettings.CurrentPool.GetWeapon(currentIndex + 1))); } } private IEnumerator SpawnAsync(ObjectType type, GunData gunData) { string weaponString = ""; if (type == ObjectType.Gun) { weaponString = gunData.GunName; } if (type == ObjectType.MagazineToLoad || type == ObjectType.MagazineForQuickbelt) { weaponString = gunData.MagName; } FVRObject newObj = null; if (!IM.OD.TryGetValue(weaponString, out newObj)) { Debug.LogError((object)("No object found with id: " + weaponString)); yield break; } AnvilCallback callback = ((AnvilAsset)newObj).GetGameObjectAsync(); yield return callback; Vector3 spawnOffset = Vector3.left * (float)type; switch (type) { case ObjectType.Gun: _gun = Object.Instantiate(callback.Result, BufferSpawnPos.position + spawnOffset, BufferSpawnPos.rotation).GetComponent(); ((Component)_gun).gameObject.SetActive(true); break; case ObjectType.MagazineToLoad: _magazineToLoad = Object.Instantiate(callback.Result, BufferSpawnPos.position + spawnOffset, BufferSpawnPos.rotation).GetComponent(); ((Component)_magazineToLoad).gameObject.SetActive(true); _magazineToLoad.UsesGravity = false; _magazineToLoad.RootRigidbody.isKinematic = true; break; case ObjectType.MagazineForQuickbelt: _magazineForQuickbelt = Object.Instantiate(callback.Result, BufferSpawnPos.position + spawnOffset, BufferSpawnPos.rotation).GetComponent(); ((Component)_magazineForQuickbelt).gameObject.SetActive(true); break; } } public FVRPhysicalObject SpawnImmediate(ObjectType objectType, GunData gunData) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) string text = ""; if (objectType == ObjectType.Gun) { text = gunData.GunName; } if (objectType == ObjectType.MagazineToLoad || objectType == ObjectType.MagazineForQuickbelt) { text = gunData.MagName; } if (objectType == ObjectType.Extra) { text = gunData.Extra; } FVRObject value = null; if (!IM.OD.TryGetValue(text, out value)) { Debug.LogError((object)("No object found with id: " + text)); return null; } GameObject gameObject = ((AnvilAsset)value).GetGameObject(); GameObject val = Object.Instantiate(gameObject, ((Component)this).transform.position + Vector3.up, ((Component)this).transform.rotation); val.SetActive(true); return val.GetComponent(); } } public enum ObjectType { Gun, MagazineToLoad, MagazineForQuickbelt, Extra } [Serializable] public class WeaponPool : WeaponPoolInterface { public string Name; public string Description; public OrderType OrderType; public string EnemyType = "M_Swat_Scout"; public int CurrentIndex; public List Guns = new List(); [NonSerialized] public List Enemies = new List(); [HideInInspector] public List GunNames = new List(); [HideInInspector] public List MagNames = new List(); [HideInInspector] public List CategoryIDs = new List(); public string GetName() { return Name; } public string GetDescription() { return Description; } public GunData GetNextWeapon() { if (CurrentIndex + 1 >= GunNames.Count) { return null; } return Guns[CurrentIndex + 1]; } public GunData GetWeapon(int index) { return Guns[index]; } public int GetWeaponCount() { return Guns.Count; } public int GetCurrentWeaponIndex() { return CurrentIndex; } public GunData GetCurrentWeapon() { return Guns[CurrentIndex]; } public KillProgressionType GetProgressionType() { return KillProgressionType.Count; } public List GetEnemies() { return Enemies; } public bool IncrementProgress() { CurrentIndex++; if (CurrentIndex == Guns.Count) { return true; } return false; } public void DecrementProgress() { if (CurrentIndex > 0) { CurrentIndex--; } } public void Initialize() { SetGunOrder(); SeedEnemyList(); CurrentIndex = 0; } private void SetGunOrder() { if (OrderType == OrderType.Random) { IListExtensions.Shuffle((IList)Guns); } if (OrderType == OrderType.RandomWithinCategory) { IListExtensions.Shuffle((IList)Guns); Guns = Guns.OrderBy((GunData x) => x.CategoryID).ToList(); } } private void SeedEnemyList() { Enemies.Add(new EnemyData(EnemyType, 1)); } private void SetSpawners() { } } [Serializable] public class WeaponPoolAdvanced : WeaponPoolInterface { public string Name = ""; public string Description = ""; public OrderType OrderType = OrderType.Fixed; public string EnemyType = "M_Swat_Scout"; public int CurrentIndex = 0; public string WeaponPoolType = ""; public KillProgressionType EnemyProgressionType = KillProgressionType.Count; public List Guns = new List(); public List Enemies = new List(); [HideInInspector] public List GunNames = new List(); [HideInInspector] public List MagNames = new List(); [HideInInspector] public List CategoryIDs = new List(); public string GetName() { return Name; } public string GetDescription() { return Description; } public GunData GetNextWeapon() { return Guns[CurrentIndex]; } public GunData GetWeapon(int index) { return Guns[index]; } public int GetWeaponCount() { return Guns.Count; } public int GetCurrentWeaponIndex() { return CurrentIndex; } public GunData GetCurrentWeapon() { return Guns[CurrentIndex]; } public KillProgressionType GetProgressionType() { return EnemyProgressionType; } public List GetEnemies() { return Enemies; } public bool IncrementProgress() { CurrentIndex++; if (CurrentIndex == Guns.Count) { return true; } return false; } public void DecrementProgress() { if (CurrentIndex > 0) { CurrentIndex--; } } public void Initialize() { SetGunOrder(); SeedRandomMagazines(); CurrentIndex = 0; AutofillEnemyData(); } private void SetGunOrder() { if (OrderType == OrderType.Random) { IListExtensions.Shuffle((IList)Guns); } if (OrderType == OrderType.RandomWithinCategory) { IListExtensions.Shuffle((IList)Guns); Guns = Guns.OrderBy((GunData x) => x.CategoryID).ToList(); } } private void AutofillEnemyData() { //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) foreach (EnemyData enemy in Enemies) { if (!Utility.IsNullOrWhiteSpace(enemy.EnemyNameString)) { enemy.EnemyName = (SosigEnemyID)Enum.Parse(typeof(SosigEnemyID), enemy.EnemyNameString, ignoreCase: true); } } } private void SeedRandomMagazines() { Random.InitState((int)Convert.ToInt16(Time.time)); int num = Random.Range(0, 10); foreach (GunData gun in Guns) { if (gun.MagNames.Count > 0) { gun.MagName = gun.MagNames[num % gun.MagNames.Count]; } num++; } } } public interface WeaponPoolInterface { string GetName(); string GetDescription(); int GetWeaponCount(); int GetCurrentWeaponIndex(); GunData GetWeapon(int index); GunData GetCurrentWeapon(); GunData GetNextWeapon(); KillProgressionType GetProgressionType(); List GetEnemies(); bool IncrementProgress(); void DecrementProgress(); void Initialize(); } public enum OrderType { Fixed, Random, RandomWithinCategory } public class WeaponPoolLoader : MonoBehaviourSingleton { public static Action WeaponLoadedEvent; public Transform ChoicesListParent; public PoolChoice ChoicePrefab; public List DebugWeaponPools; private List _loadedWeaponPoolsLocations = new List(); private List _weaponPools = new List(); private List _choices = new List(); public void SaveDebugWeaponPools() { for (int i = 0; i < DebugWeaponPools.Count; i++) { DebugWeaponPools[i].GunNames.Clear(); DebugWeaponPools[i].MagNames.Clear(); DebugWeaponPools[i].CategoryIDs.Clear(); for (int j = 0; j < DebugWeaponPools[i].Guns.Count; j++) { DebugWeaponPools[i].GunNames.Add(DebugWeaponPools[i].Guns[j].GunName); DebugWeaponPools[i].MagNames.Add(DebugWeaponPools[i].Guns[j].MagName); DebugWeaponPools[i].CategoryIDs.Add(DebugWeaponPools[i].Guns[j].CategoryID); } DebugWeaponPools[i].Guns.Clear(); } foreach (WeaponPool debugWeaponPool in DebugWeaponPools) { WriteWeaponPool(Application.dataPath + "/GunGame//GunGameWeaponPool_" + debugWeaponPool.Name + ".json", debugWeaponPool); } } public override void Awake() { base.Awake(); _loadedWeaponPoolsLocations = GetWeaponPoolLocations(); _weaponPools = new List(); if (_loadedWeaponPoolsLocations.Count == 0) { Debug.LogError((object)"No weapon pools found!"); return; } for (int i = 0; i < _loadedWeaponPoolsLocations.Count; i++) { WeaponPoolInterface weaponPoolInterface = LoadWeaponPool(_loadedWeaponPoolsLocations[i]); if (weaponPoolInterface != null) { _weaponPools.Add(weaponPoolInterface); Debug.Log((object)("Weapon pool loaded with name: " + weaponPoolInterface.GetName() + " and count: " + weaponPoolInterface.GetWeaponCount())); } else { Debug.Log((object)("Failed to load Weapon pool at location: " + _loadedWeaponPoolsLocations[i])); } } for (int j = 0; j < _weaponPools.Count; j++) { PoolChoice poolChoice = Object.Instantiate(ChoicePrefab, ChoicesListParent); poolChoice.Initialize(_weaponPools[j]); _choices.Add(poolChoice); } WeaponPoolInterface newPool = _weaponPools[0]; GameSettings.ChangeCurrentPool(newPool); if (WeaponLoadedEvent != null) { WeaponLoadedEvent(); } } public WeaponPoolInterface LoadWeaponPool(string path) { using StreamReader streamReader = new StreamReader(path); string text = streamReader.ReadToEnd(); WeaponPoolAdvanced newWeaponPoolAdvanced = null; try { newWeaponPoolAdvanced = JsonUtility.FromJson(text); } catch (Exception ex) { Debug.Log((object)ex.Message); return null; } if (newWeaponPoolAdvanced.WeaponPoolType == "Advanced") { if (_weaponPools.FirstOrDefault((WeaponPoolInterface x) => x.GetName() == newWeaponPoolAdvanced.GetName()) != null) { return null; } Debug.Log((object)("Loaded advanced weapon pool: " + newWeaponPoolAdvanced.GetName())); return newWeaponPoolAdvanced; } WeaponPool newWeaponPool = JsonUtility.FromJson(text); if (_weaponPools.FirstOrDefault((WeaponPoolInterface x) => x.GetName() == newWeaponPool.GetName()) != null) { return null; } newWeaponPool.Guns.Clear(); for (int i = 0; i < newWeaponPool.GunNames.Count; i++) { GunData gunData = new GunData(); gunData.GunName = newWeaponPool.GunNames[i]; gunData.MagName = newWeaponPool.MagNames[i]; gunData.CategoryID = newWeaponPool.CategoryIDs[i]; GunData item = gunData; newWeaponPool.Guns.Add(item); } Debug.Log((object)("Loaded basic weapon pool: " + newWeaponPoolAdvanced.GetName())); return newWeaponPool; } public void WriteWeaponPool(string path, WeaponPool weaponPool) { using StreamWriter streamWriter = new StreamWriter(path); string value = JsonUtility.ToJson((object)weaponPool, true); streamWriter.Write(value); } private List GetWeaponPoolLocations() { string pluginPath = Paths.PluginPath; List list = Directory.GetFiles(pluginPath, "GunGameWeaponPool*.json", SearchOption.AllDirectories).ToList(); List collection = Directory.GetFiles(pluginPath, "AdvancedGunGameWeaponPool*.json", SearchOption.AllDirectories).ToList(); list.AddRange(collection); return list; } } } namespace ShermanJumbo { public class SimpleMusicToggleButton : FVRInteractiveObject { public Transform Flipsight; public Vector3 m_flipsightStartPosition; public Vector3 m_flipsightEndPosition = new Vector3(0f, 0f, -0.1f); public AudioSource audioSource; private bool m_isOpen = true; private float m_curFlipLerp; private float m_tarFlipLerp; private float m_lastFlipLerp; public override void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).Awake(); if ((Object)(object)Flipsight != (Object)null) { m_flipsightStartPosition = Flipsight.localPosition; } if ((Object)(object)audioSource == (Object)null) { audioSource = ((Component)this).GetComponent(); } } public override void SimpleInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).SimpleInteraction(hand); m_isOpen = !m_isOpen; ToggleAudio(); } public override void FVRUpdate() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).FVRUpdate(); m_tarFlipLerp = ((!m_isOpen) ? 1f : 0f); m_curFlipLerp = Mathf.MoveTowards(m_curFlipLerp, m_tarFlipLerp, Time.deltaTime * 4f); if (Mathf.Abs(m_curFlipLerp - m_lastFlipLerp) > 0.01f) { Vector3 localPosition = Vector3.Lerp(m_flipsightStartPosition, m_flipsightEndPosition, m_curFlipLerp); Flipsight.localPosition = localPosition; } m_lastFlipLerp = m_curFlipLerp; } private void ToggleAudio() { if ((Object)(object)audioSource != (Object)null) { if (m_isOpen) { audioSource.Stop(); } else { audioSource.Play(); } } } } } namespace MeatKit { public class HideInNormalInspectorAttribute : PropertyAttribute { } } namespace ShermanJumbo.Soul_Silo_GunGame { [BepInPlugin("ShermanJumbo.Soul_Silo_GunGame", "Soul_Silo_GunGame", "1.0.0")] [BepInProcess("h3vr.exe")] [Description("Built with MeatKit")] [BepInDependency("nrgill28.Atlas", "1.0.1")] public class Soul_Silo_GunGamePlugin : BaseUnityPlugin { private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); internal static ManualLogSource Logger; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; LoadAssets(); } private void LoadAssets() { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "ShermanJumbo.Soul_Silo_GunGame"); AtlasPlugin.RegisterScene(Path.Combine(BasePath, "soulsilo")); } } } public class NavMeshCleaner2 : MonoBehaviour { private class Tri { public int i1; public int i2; public int i3; public int min; public int max; public Tri(int i1, int i2, int i3) { this.i1 = i1; this.i2 = i2; this.i3 = i3; min = Mathf.Min(new int[3] { i1, i2, i3 }); max = Mathf.Max(new int[3] { i1, i2, i3 }); } } private class Edge { public int i1; public int i2; public Edge(int i1, int i2) { this.i1 = i1; this.i2 = i2; } } [CustomEditor(typeof(NavMeshCleaner2))] public class NavMeshCleanerEditor : Editor { private static class Styles { private static Dictionary texture = new Dictionary(); public static GUIStyle Get(string id) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (!texture.TryGetValue(id, out var value)) { value = new GUIStyle(GUIStyle.op_Implicit(id)); texture.Add(id, value); } return value; } } private NavMeshCleaner2 m_Target; private int m_OverPoint = -1; private static float kEpsilon = 1E-06f; private void OnEnable() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown m_Target = (NavMeshCleaner2)(object)((Editor)this).target; Undo.undoRedoPerformed = (UndoRedoCallback)Delegate.Combine((Delegate?)(object)Undo.undoRedoPerformed, (Delegate?)new UndoRedoCallback(OnUndoOrRedo)); } private void OnDisable() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown Undo.undoRedoPerformed = (UndoRedoCallback)Delegate.Remove((Delegate?)(object)Undo.undoRedoPerformed, (Delegate?)new UndoRedoCallback(OnUndoOrRedo)); } private void OnUndoOrRedo() { ((Editor)this).Repaint(); } public override void OnInspectorGUI() { //IL_007c: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) EditorGUILayout.HelpBox((m_OverPoint == -1) ? "Press Control and click to add a walkable point." : "Press Control and click to remove the point.", (MessageType)((m_Target.m_WalkablePoint.Count != 0) ? 1 : 2)); ((Editor)this).OnInspectorGUI(); NavMeshCleaner2 navMeshCleaner = (NavMeshCleaner2)(object)((Editor)this).target; if (navMeshCleaner.m_Child.Count > 0) { EditorGUI.BeginChangeCheck(); bool flag = EditorGUILayout.Toggle("Hide Temp Mesh Object In Hierarchy", ((((Object)navMeshCleaner.m_Child[0].gameObject).hideFlags & 1) != 0) ? true : false, (GUILayoutOption[])(object)new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < navMeshCleaner.m_Child.Count; i++) { ((Object)navMeshCleaner.m_Child[i].gameObject).hideFlags = (HideFlags)((!flag) ? (((Object)navMeshCleaner.m_Child[i].gameObject).hideFlags & -2) : (((Object)navMeshCleaner.m_Child[i].gameObject).hideFlags | 1)); } try { EditorApplication.RepaintHierarchyWindow(); EditorApplication.DirtyHierarchyWindowSorting(); } catch { } } } if (GUILayout.Button((!navMeshCleaner.HasMesh()) ? "Calculate" : "Recalculate", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { navMeshCleaner.Build(); navMeshCleaner.SetMeshVisible(visible: true); SceneView.RepaintAll(); } if (navMeshCleaner.HasMesh() && GUILayout.Button((!navMeshCleaner.MeshVisible()) ? "Show Mesh" : "Hide Mesh", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { bool meshVisible = !navMeshCleaner.MeshVisible(); navMeshCleaner.SetMeshVisible(meshVisible); SceneView.RepaintAll(); } if (navMeshCleaner.HasMesh() && GUILayout.Button("Reset Mesh", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { navMeshCleaner.Reset(); SceneView.RepaintAll(); } if (navMeshCleaner.HasMesh() && GUILayout.Button("Reset WalkablePoints", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { Undo.RecordObject(((Editor)this).target, "reset"); m_Target.m_WalkablePoint.Clear(); SceneView.RepaintAll(); } } private void DrawDisc(Vector3 p, Vector3 n, float radius) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[20]; Matrix4x4 val = Matrix4x4.TRS(p, Quaternion.LookRotation(n), Vector3.one * radius); for (int i = 0; i < 20; i++) { ref Vector3 reference = ref array[i]; reference = ((Matrix4x4)(ref val)).MultiplyPoint3x4(new Vector3(Mathf.Cos((float)Math.PI * 2f * (float)i / 19f), Mathf.Sin((float)Math.PI * 2f * (float)i / 19f), 0f)); } Handles.DrawAAPolyLine(array); } private void OnSceneGUI() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Invalid comparison between Unknown and I4 //IL_0149: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Invalid comparison between Unknown and I4 //IL_008b: 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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Invalid comparison between Unknown and I4 //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Invalid comparison between Unknown and I4 //IL_0095: 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_00a8: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Invalid comparison between Unknown and I4 SceneView currentDrawingSceneView = SceneView.currentDrawingSceneView; Event current = Event.current; if ((int)current.type == 7) { for (int i = 0; i < m_Target.m_WalkablePoint.Count; i++) { Vector3 val = ((Component)m_Target).transform.TransformPoint(m_Target.m_WalkablePoint[i]); float num = WorldSize(1f, currentDrawingSceneView.camera, val); Handles.color = Color.black; DrawDisc(val, Vector3.up, num * 15f); Handles.color = ((i != m_OverPoint) ? Color.green : Color.red); Handles.DrawSolidDisc(val, Vector3.up, num * 10f); Handles.DrawLine(val, val + Vector3.up * (num * 200f)); } } if ((int)current.type == 8 && current.control) { HandleUtility.AddDefaultControl(GUIUtility.GetControlID((FocusType)2)); } if (current.control) { EditorGUIUtility.AddCursorRect(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (MouseCursor)((m_OverPoint != -1) ? 12 : 11)); } if (((int)current.type == 0 || (int)current.type == 3 || (int)current.type == 2 || (int)current.type == 1) && current.button == 0) { MouseEvent(current.type, current.mousePosition, (int)current.modifiers == 2); } } private void MouseEvent(EventType type, Vector2 mouseposition, bool controldown) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0010: Invalid comparison between Unknown and I4 //IL_00aa: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) SceneView currentDrawingSceneView = SceneView.currentDrawingSceneView; Ray val = HandleUtility.GUIPointToWorldRay(mouseposition); if ((int)type == 2) { int num = -1; for (int i = 0; i < m_Target.m_WalkablePoint.Count; i++) { Vector3 val2 = ((Component)m_Target).transform.TransformPoint(m_Target.m_WalkablePoint[i]); float num2 = WorldSize(10f, currentDrawingSceneView.camera, val2) * 1.5f; if (DistanceRayVsPoint(val, val2) < num2) { num = i; break; } } if (num != m_OverPoint) { m_OverPoint = num; HandleUtility.Repaint(); } } if ((int)type != 0 || !controldown) { return; } if (m_OverPoint != -1) { Undo.RecordObject((Object)(object)m_Target, "Remove Point"); m_Target.m_WalkablePoint.RemoveAt(m_OverPoint); m_OverPoint = -1; } else { float num3 = 1000f; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val, ref val3, num3)) { Undo.RecordObject((Object)(object)m_Target, "Add Point"); m_Target.m_WalkablePoint.Add(((Component)m_Target).transform.InverseTransformPoint(((RaycastHit)(ref val3)).point)); } else { NavMeshTriangulation val4 = NavMesh.CalculateTriangulation(); Vector3[] vertices = val4.vertices; int[] indices = val4.indices; Vector3 outNormal = Vector3.up; for (int j = 0; j < indices.Length; j += 3) { num3 = IntersectTest(val, vertices[indices[j]], vertices[indices[j + 1]], vertices[indices[j + 2]], num3, ref outNormal); } if (num3 < 1000f) { Undo.RecordObject((Object)(object)m_Target, "Add Point"); Vector3 val5 = ((Ray)(ref val)).origin + ((Ray)(ref val)).direction * num3; m_Target.m_WalkablePoint.Add(((Component)m_Target).transform.InverseTransformPoint(val5)); } } } HandleUtility.Repaint(); } private static float IntersectTest(Ray ray, Vector3 v0, Vector3 v1, Vector3 v2, float mint, ref Vector3 outNormal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_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_010b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = v1 - v0; Vector3 val2 = v2 - v0; Vector3 val3 = Vector3.Cross(((Ray)(ref ray)).direction, val2); float num = Vector3.Dot(val, val3); if (num > 0f - kEpsilon && num < kEpsilon) { return mint; } float num2 = 1f / num; Vector3 val4 = ((Ray)(ref ray)).origin - v0; float num3 = num2 * Vector3.Dot(val4, val3); if (num3 < 0f || num3 > 1f) { return mint; } Vector3 val5 = Vector3.Cross(val4, val); float num4 = num2 * Vector3.Dot(((Ray)(ref ray)).direction, val5); if (num4 < 0f || num3 + num4 > 1f) { return mint; } float num5 = num2 * Vector3.Dot(val2, val5); if (num5 > kEpsilon && num5 < mint) { outNormal = Vector3.Normalize(Vector3.Cross(((Vector3)(ref val)).normalized, ((Vector3)(ref val2)).normalized)); return num5; } return mint; } private static float WorldSize(float screensize, Camera camera, Vector3 p) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!camera.orthographic) { Vector3 val = ((Component)camera).transform.InverseTransformPoint(p); float num = Mathf.Tan(camera.fieldOfView * ((float)Math.PI / 180f) * 0.5f) * val.z; return num * screensize / (float)camera.pixelHeight; } return camera.orthographicSize * screensize / (float)camera.pixelHeight; } private static float DistanceRayVsPoint(Ray mouseRay, Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pos - ((Ray)(ref mouseRay)).origin; return Mathf.Sqrt(Vector3.Dot(val, val) - Vector3.Dot(((Ray)(ref mouseRay)).direction, val) * Vector3.Dot(((Ray)(ref mouseRay)).direction, val)); } private static Vector3 IntersectPlane(Vector3 inNormal, Vector3 inPoint, Ray mouseRay) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_001b: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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) Plane val = default(Plane); ((Plane)(ref val))..ctor(inNormal, inPoint); float distanceToPoint = ((Plane)(ref val)).GetDistanceToPoint(((Ray)(ref mouseRay)).origin); return ((Ray)(ref mouseRay)).origin + ((Ray)(ref mouseRay)).direction * (distanceToPoint / Vector3.Dot(-((Plane)(ref val)).normal, ((Ray)(ref mouseRay)).direction)); } } public List m_WalkablePoint = new List(); public float m_Height = 1f; public float m_Offset = 0f; public int m_MidLayerCount = 3; private List m_Child = new List(); private void Awake() { SetMeshVisible(visible: false); } private void Reset() { Undo.RecordObject((Object)(object)this, "Reset"); for (int i = 0; i < m_Child.Count; i++) { Undo.DestroyObjectImmediate((Object)(object)m_Child[i]); } m_Child.Clear(); } private void SetMeshVisible(bool visible) { for (int i = 0; i < m_Child.Count; i++) { m_Child[i].SetActive(visible); } } public bool HasMesh() { return (m_Child.Count != 0) ? true : false; } public bool MeshVisible() { if (m_Child.Count > 0) { return m_Child[0].activeSelf; } return false; } private void Build() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00ba: 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_011c->IL011c: Incompatible stack types: O vs I4 //IL_0106->IL011c: Incompatible stack types: I4 vs O //IL_0106->IL011c: Incompatible stack types: O vs I4 Mesh[] array = CreateMesh(); Undo.RegisterCreatedObjectUndo((Object)(object)this, "build"); for (int i = 0; i < array.Length || i == 0; i++) { GameObject val; if (i >= m_Child.Count) { val = new GameObject(); ((Object)val).name = ((Object)((Component)this).gameObject).name + "_Mesh(DontSave)"; val.AddComponent(); MeshRenderer val2 = val.AddComponent(); ((Renderer)val2).sharedMaterial = AssetDatabase.GetBuiltinExtraResource("Default-Diffuse.mat"); val.transform.parent = ((Component)this).transform; val.transform.localScale = Vector3.one; val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; GameObjectUtility.SetStaticEditorFlags(val, (StaticEditorFlags)(GameObjectUtility.GetStaticEditorFlags(((Component)this).gameObject) | 8)); GameObjectUtility.SetNavMeshArea(val, 1); m_Child.Add(val); Undo.RegisterCreatedObjectUndo((Object)(object)val, ""); } else { val = m_Child[i].gameObject; } object obj = val; int num; if (i == 0) { num = 53; obj = num; num = (int)obj; } else { obj = ((Object)m_Child[0].gameObject).hideFlags; num = (int)obj; } ((Object)num).hideFlags = (HideFlags)obj; MeshFilter component = m_Child[i].GetComponent(); Undo.RecordObject((Object)(object)component, "MeshUpdate"); component.sharedMesh = ((array.Length != 0) ? array[i] : null); } while (m_Child.Count > array.Length) { Undo.DestroyObjectImmediate((Object)(object)m_Child[m_Child.Count - 1]); m_Child.RemoveAt(m_Child.Count - 1); } } private static int Find(Vector3[] vtx, int left, int right, Vector3 v, float key) { //IL_0094: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) int num = (left + right) / 2; if (num == left) { for (int i = left; i < vtx.Length && vtx[i].x <= key + 0.002f; i++) { if (Vector3.Magnitude(vtx[i] - v) <= 0.01f) { return i; } } return -1; } if (key <= vtx[num].x) { return Find(vtx, left, num, v, key); } return Find(vtx, num, right, v, key); } private static bool Find(Edge[] edge, int left, int right, int i1, int i2) { int num = (left + right) / 2; if (num == left) { for (int j = left; j < edge.Length && edge[j].i1 <= i1; j++) { if (edge[j].i1 == i1 && edge[j].i2 == i2) { return true; } } return false; } if (i1 <= edge[num].i1) { return Find(edge, left, num, i1, i2); } return Find(edge, num, right, i1, i2); } private Mesh[] CreateMesh() { //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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0716: Unknown result type (might be due to invalid IL or missing references) //IL_0721: Unknown result type (might be due to invalid IL or missing references) //IL_0726: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_0618: Unknown result type (might be due to invalid IL or missing references) //IL_061d: Unknown result type (might be due to invalid IL or missing references) //IL_0628: Unknown result type (might be due to invalid IL or missing references) //IL_062d: Unknown result type (might be due to invalid IL or missing references) //IL_0632: Unknown result type (might be due to invalid IL or missing references) //IL_0757: Unknown result type (might be due to invalid IL or missing references) //IL_075c: Unknown result type (might be due to invalid IL or missing references) //IL_0767: Unknown result type (might be due to invalid IL or missing references) //IL_076c: Unknown result type (might be due to invalid IL or missing references) //IL_0a2d: Unknown result type (might be due to invalid IL or missing references) //IL_0a32: Unknown result type (might be due to invalid IL or missing references) //IL_0a42: Unknown result type (might be due to invalid IL or missing references) //IL_0a47: Unknown result type (might be due to invalid IL or missing references) //IL_0a57: Unknown result type (might be due to invalid IL or missing references) //IL_0a5c: Unknown result type (might be due to invalid IL or missing references) //IL_0a5e: Unknown result type (might be due to invalid IL or missing references) //IL_0a63: Unknown result type (might be due to invalid IL or missing references) //IL_0a73: Unknown result type (might be due to invalid IL or missing references) //IL_0a78: Unknown result type (might be due to invalid IL or missing references) //IL_0a7a: Unknown result type (might be due to invalid IL or missing references) //IL_0a7f: Unknown result type (might be due to invalid IL or missing references) NavMeshTriangulation val = NavMesh.CalculateTriangulation(); Vector3[] vertices = val.vertices; List list = new List(); list.AddRange(vertices); list.Sort((Vector3 v1, Vector3 v2) => (v1.x == v2.x) ? ((v1.z != v2.z) ? ((!(v1.z < v2.z)) ? 1 : (-1)) : 0) : ((!(v1.x < v2.x)) ? 1 : (-1))); Vector3[] vtx = list.ToArray(); int[] array = new int[val.vertices.Length]; for (int i = 0; i < array.Length; i++) { array[i] = Find(vtx, 0, list.Count, vertices[i], vertices[i].x - 0.001f); if (i % 100 == 0) { EditorUtility.DisplayProgressBar($"Export Nav-Mesh (Phase #1/3) {i}/{array.Length}", "Weld Vertex", Mathf.InverseLerp(0f, (float)array.Length, (float)i)); } } int[] indices = val.indices; List list2 = new List(); for (int j = 0; j < indices.Length; j += 3) { list2.Add(new Tri(array[indices[j]], array[indices[j + 1]], array[indices[j + 2]])); } list2.Sort((Tri t1, Tri t2) => (t1.min != t2.min) ? ((t1.min >= t2.min) ? 1 : (-1)) : 0); int[] array2 = new int[(list2.Count + 127) / 128]; int[] array3 = new int[array2.Length]; int num = 0; int num2 = 0; while (num < list2.Count) { int num3 = list2[num].min; int num4 = list2[num].max; for (int k = 1; k < 128 && num + k < list2.Count; k++) { num3 = Mathf.Min(list2[num + k].min, num3); num4 = Mathf.Max(list2[num + k].max, num4); } array2[num2] = num3; array3[num2] = num4; num += 128; num2++; } int[] array4 = new int[indices.Length]; for (int l = 0; l < array4.Length; l += 3) { array4[l] = list2[l / 3].i1; array4[l + 1] = list2[l / 3].i2; array4[l + 2] = list2[l / 3].i3; } List list3 = new List(); List list4 = new List(); int[] array5 = new int[array4.Length / 3]; for (int m = 0; m < array4.Length; m += 3) { int num5 = -1; int num6 = Mathf.Max(new int[3] { array4[m], array4[m + 1], array4[m + 2] }); int num7 = Mathf.Min(new int[3] { array4[m], array4[m + 1], array4[m + 2] }); int num8 = 0; int num9 = 0; while (num8 < m) { if (array2[num9] <= num6 && array3[num9] >= num7) { for (int n = num8; n < m && n < num8 + 384 && list2[n / 3].min <= num6; n += 3) { if (list2[n / 3].max < num7 || list3[array5[n / 3]] == num5) { continue; } for (int num10 = 0; num10 < 3; num10++) { int num11 = array4[n + num10]; if (array4[m] != num11 && array4[m + 1] != num11 && array4[m + 2] != num11) { continue; } if (num5 == -1) { num5 = list3[array5[n / 3]]; array5[m / 3] = num5; break; } int num12 = list3[array5[n / 3]]; for (int num13 = 0; num13 < list3.Count; num13++) { if (list3[num13] == num12) { list3[num13] = num5; } } break; } } } num8 += 384; num9++; } if (num5 == -1) { num5 = list3.Count; array5[m / 3] = num5; list3.Add(num5); list4.Add(0); } if (m / 3 % 100 == 0) { EditorUtility.DisplayProgressBar("Collect (Phase #2/3)", "Classification Group", Mathf.InverseLerp(0f, (float)array4.Length, (float)m)); } } for (int num14 = 0; num14 < array4.Length; num14 += 3) { array5[num14 / 3] = list3[array5[num14 / 3]]; list4[array5[num14 / 3]]++; } List list5 = new List(); List list6 = new List(); List list7 = new List(); int[] array6 = new int[list.Count]; for (int num15 = 0; num15 < array6.Length; num15++) { array6[num15] = -1; } Vector3[] points = m_WalkablePoint.ToArray(); for (int num16 = 0; num16 < list4.Count; num16++) { if (list4[num16] == 0) { continue; } List list8 = new List(); List list9 = new List(); for (int num17 = 0; num17 < array4.Length; num17 += 3) { if (array5[num17 / 3] != num16) { continue; } for (int num18 = 0; num18 < 3; num18++) { int num19 = array4[num17 + num18]; if (array6[num19] == -1) { array6[num19] = list8.Count; list8.Add(((Component)this).transform.InverseTransformPoint(list[num19] + Vector3.up * m_Offset)); } } list9.Add(array6[array4[num17]]); list9.Add(array6[array4[num17 + 1]]); list9.Add(array6[array4[num17 + 2]]); } if (Contains(list8.ToArray(), list9.ToArray(), points)) { continue; } int num20 = 32768; if (list6.Count > num20 || list6.Count + list8.Count * (2 + m_MidLayerCount) >= 65536) { list5.Add(CreateMesh(list6.ToArray(), list7.ToArray())); list6.Clear(); list7.Clear(); } Vector3 val2 = ((Component)this).transform.InverseTransformVector(Vector3.up * m_Height); int count = list6.Count; int num21 = 2 + m_MidLayerCount; for (int num22 = 0; num22 < list8.Count; num22++) { for (int num23 = 0; num23 < num21; num23++) { list6.Add(list8[num22] + val2 * ((float)num23 / (float)(num21 - 1))); } } for (int num24 = 0; num24 < list9.Count; num24 += 3) { for (int num25 = 0; num25 < num21; num25++) { if (num25 == 0) { list7.AddRange(new int[3] { count + list9[num24] * num21 + num25, count + list9[num24 + 2] * num21 + num25, count + list9[num24 + 1] * num21 + num25 }); } else { list7.AddRange(new int[3] { count + list9[num24] * num21 + num25, count + list9[num24 + 1] * num21 + num25, count + list9[num24 + 2] * num21 + num25 }); } } } if (m_Height > 0f) { List list10 = new List(); for (int num26 = 0; num26 < list9.Count; num26 += 3) { list10.Add(new Edge(list9[num26], list9[num26 + 1])); list10.Add(new Edge(list9[num26 + 1], list9[num26 + 2])); list10.Add(new Edge(list9[num26 + 2], list9[num26])); } list10.Sort((Edge e1, Edge e2) => (e1.i1 != e2.i1) ? ((e1.i1 >= e2.i1) ? 1 : (-1)) : 0); Edge[] edge = list10.ToArray(); for (int num27 = 0; num27 < list9.Count; num27 += 3) { int num28 = 2; int num29 = 0; while (num29 < 3) { int num30 = list9[num27 + num28]; int num31 = list9[num27 + num29]; if (!Find(edge, 0, list10.Count, num31, num30)) { if (list6.Count + 4 >= 65536) { list5.Add(CreateMesh(list6.ToArray(), list7.ToArray())); list6.Clear(); list7.Clear(); } list7.AddRange(new int[6] { list6.Count, list6.Count + 1, list6.Count + 3, list6.Count, list6.Count + 3, list6.Count + 2 }); list6.AddRange((IEnumerable)(object)new Vector3[4] { list8[num30], list8[num31], list8[num30] + val2, list8[num31] + val2 }); } num28 = num29++; } if (num27 % 600 == 0) { EditorUtility.DisplayProgressBar("Collect (Phase #3/3)", "Create Mesh", Mathf.InverseLerp(0f, (float)(list4.Count * 100), (float)(num16 * 100 + num27 * 100 / (num27 - list9.Count)))); } } } EditorUtility.DisplayProgressBar("Collect (Phase #3/3)", "Create Mesh", Mathf.InverseLerp(0f, (float)list4.Count, (float)num16)); } if (list6.Count > 0) { list5.Add(CreateMesh(list6.ToArray(), list7.ToArray())); } EditorUtility.ClearProgressBar(); return list5.ToArray(); } private static Mesh CreateMesh(Vector3[] vtx, int[] indices) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Mesh val = new Mesh(); ((Object)val).hideFlags = (HideFlags)52; val.vertices = vtx; val.SetIndices(indices, (MeshTopology)0, 0); val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static bool Contains(Vector3[] vtx, int[] indices, Vector3[] points) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0075: 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) foreach (Vector3 p in points) { for (int j = 0; j < indices.Length; j += 3) { if (indices[j] != indices[j + 1] && indices[j] != indices[j + 2] && indices[j + 1] != indices[j + 2] && PointInTriangle(vtx[indices[j]], vtx[indices[j + 2]], vtx[indices[j + 1]], p)) { return true; } } } return false; } private static bool PointInTriangle(Vector3 v1, Vector3 v2, Vector3 v3, Vector3 p) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_006e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(v3 - v1, v2 - v1); if (Vector3.Dot(Vector3.Cross(p - v1, v2 - v1), val) > 0f && Vector3.Dot(Vector3.Cross(p - v2, v3 - v2), val) > 0f && Vector3.Dot(Vector3.Cross(p - v3, v1 - v3), val) > 0f) { return true; } return false; } } namespace SimpleLightProbePlacer { [RequireComponent(typeof(LightProbeGroup))] [AddComponentMenu("Rendering/Light Probe Group Control")] public class LightProbeGroupControl : MonoBehaviour { [SerializeField] private float m_mergeDistance = 0.5f; [SerializeField] private bool m_usePointLights = true; [SerializeField] private float m_pointLightRange = 1f; private int m_mergedProbes; private LightProbeGroup m_lightProbeGroup; public float MergeDistance { get { return m_mergeDistance; } set { m_mergeDistance = value; } } public int MergedProbes => m_mergedProbes; public bool UsePointLights { get { return m_usePointLights; } set { m_usePointLights = value; } } public float PointLightRange { get { return m_pointLightRange; } set { m_pointLightRange = value; } } public LightProbeGroup LightProbeGroup { get { if ((Object)(object)m_lightProbeGroup != (Object)null) { return m_lightProbeGroup; } return m_lightProbeGroup = ((Component)this).GetComponent(); } } public void DeleteAll() { LightProbeGroup.probePositions = null; m_mergedProbes = 0; } public void Create() { DeleteAll(); List list = CreatePositions(); list.AddRange(CreateAroundPointLights(m_pointLightRange)); list = MergeClosestPositions(list, m_mergeDistance, out m_mergedProbes); ApplyPositions(list); } public void Merge() { if (LightProbeGroup.probePositions != null) { List source = MergeClosestPositions(LightProbeGroup.probePositions.ToList(), m_mergeDistance, out m_mergedProbes); source = source.Select((Vector3 x) => ((Component)this).transform.TransformPoint(x)).ToList(); ApplyPositions(source); } } private void ApplyPositions(List positions) { LightProbeGroup.probePositions = positions.Select((Vector3 x) => ((Component)this).transform.InverseTransformPoint(x)).ToArray(); } private static List CreatePositions() { LightProbeVolume[] array = Object.FindObjectsOfType(); if (array.Length == 0) { return new List(); } List list = new List(); for (int i = 0; i < array.Length; i++) { list.AddRange(array[i].CreatePositions()); } return list; } private static List CreateAroundPointLights(float range) { List list = (from x in Object.FindObjectsOfType() where (int)x.type == 2 select x).ToList(); if (list.Count == 0) { return new List(); } List list2 = new List(); for (int i = 0; i < list.Count; i++) { list2.AddRange(CreatePositionsAround(((Component)list[i]).transform, range)); } return list2; } private static List MergeClosestPositions(List positions, float distance, out int mergedCount) { //IL_00a2: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) if (positions == null) { mergedCount = 0; return new List(); } int count = positions.Count; bool flag = false; while (!flag) { Dictionary> dictionary = new Dictionary>(); for (int i = 0; i < positions.Count; i++) { List list = positions.Where(delegate(Vector3 x) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 val2 = x - positions[i]; return ((Vector3)(ref val2)).magnitude < distance; }).ToList(); if (list.Count > 0 && !dictionary.ContainsKey(positions[i])) { dictionary.Add(positions[i], list); } } positions.Clear(); List list2 = dictionary.Keys.ToList(); for (int j = 0; j < list2.Count; j++) { Vector3 center = dictionary[list2[j]].Aggregate(Vector3.zero, (Vector3 result, Vector3 target) => result + target) / (float)dictionary[list2[j]].Count; if (!positions.Exists((Vector3 x) => x == center)) { positions.Add(center); } } flag = positions.Select((Vector3 x) => positions.Where(delegate(Vector3 y) { //IL_0000: 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_0011: 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_001d: Unknown result type (might be due to invalid IL or missing references) int result2; if (y != x) { Vector3 val = y - x; result2 = ((((Vector3)(ref val)).magnitude < distance) ? 1 : 0); } else { result2 = 0; } return (byte)result2 != 0; })).All((IEnumerable x) => !x.Any()); } mergedCount = count - positions.Count; return positions; } public static List CreatePositionsAround(Transform transform, float range) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) Vector3[] source = (Vector3[])(object)new Vector3[8] { new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, -0.5f) }; return source.Select((Vector3 x) => transform.TransformPoint(x * range)).ToList(); } } public enum LightProbeVolumeType { Fixed, Float } [AddComponentMenu("Rendering/Light Probe Volume")] public class LightProbeVolume : TransformVolume { [SerializeField] private LightProbeVolumeType m_type = LightProbeVolumeType.Fixed; [SerializeField] private Vector3 m_densityFixed = Vector3.one; [SerializeField] private Vector3 m_densityFloat = Vector3.one; public LightProbeVolumeType Type { get { return m_type; } set { m_type = value; } } public Vector3 Density { get { //IL_0018: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) return (m_type != 0) ? m_densityFloat : m_densityFixed; } set { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) if (m_type == LightProbeVolumeType.Fixed) { m_densityFixed = value; } else { m_densityFloat = value; } } } public static Color EditorColor => new Color(1f, 0.9f, 0.25f); public List CreatePositions() { return CreatePositions(m_type); } public List CreatePositions(LightProbeVolumeType type) { //IL_0030: 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_003c: 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_0014: 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) return (type != 0) ? CreatePositionsFloat(((Component)this).transform, base.Origin, base.Size, Density) : CreatePositionsFixed(((Component)this).transform, base.Origin, base.Size, Density); } public static List CreatePositionsFixed(Transform volumeTransform, Vector3 origin, Vector3 size, Vector3 density) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Vector3 val = origin; float num = size.x / (float)Mathf.FloorToInt(density.x); float num2 = size.y / (float)Mathf.FloorToInt(density.y); float num3 = size.z / (float)Mathf.FloorToInt(density.z); val -= size * 0.5f; for (int i = 0; (float)i <= density.x; i++) { for (int j = 0; (float)j <= density.y; j++) { for (int k = 0; (float)k <= density.z; k++) { Vector3 val2 = val + new Vector3((float)i * num, (float)j * num2, (float)k * num3); val2 = volumeTransform.TransformPoint(val2); list.Add(val2); } } } return list; } public static List CreatePositionsFloat(Transform volumeTransform, Vector3 origin, Vector3 size, Vector3 density) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Vector3 val = origin; int num = Mathf.FloorToInt(size.x / density.x); int num2 = Mathf.FloorToInt(size.y / density.y); int num3 = Mathf.FloorToInt(size.z / density.z); val -= size * 0.5f; val.x += (size.x - (float)num * density.x) * 0.5f; val.y += (size.y - (float)num2 * density.y) * 0.5f; val.z += (size.z - (float)num3 * density.z) * 0.5f; for (int i = 0; i <= num; i++) { for (int j = 0; j <= num2; j++) { for (int k = 0; k <= num3; k++) { Vector3 val2 = val + new Vector3((float)i * density.x, (float)j * density.y, (float)k * density.z); val2 = volumeTransform.TransformPoint(val2); list.Add(val2); } } } return list; } } [AddComponentMenu("")] public class TransformVolume : MonoBehaviour { [SerializeField] private Volume m_volume = new Volume(Vector3.zero, Vector3.one); public Volume Volume { get { return m_volume; } set { m_volume = value; } } public Vector3 Origin => m_volume.Origin; public Vector3 Size => m_volume.Size; public bool IsInBounds(Vector3[] points) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = GetBounds(); return ((Bounds)(ref bounds)).Intersects(GetBounds(points)); } public bool IsOnBorder(Vector3[] points) { if (points.All((Vector3 x) => !IsInVolume(x))) { return false; } return !points.All(IsInVolume); } public bool IsInVolume(Vector3[] points) { return points.All(IsInVolume); } public bool IsInVolume(Vector3 position) { //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_0020: Unknown result type (might be due to invalid IL or missing references) Plane val = default(Plane); for (int i = 0; i < 6; i++) { ((Plane)(ref val))..ctor(GetSideDirection(i), GetSidePosition(i)); if (((Plane)(ref val)).GetSide(position)) { return false; } } return true; } public Vector3[] GetCorners() { //IL_001d: 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_003d: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0123: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[8] { new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, -0.5f) }; for (int i = 0; i < array.Length; i++) { ref Vector3 reference = ref array[i]; reference.x *= m_volume.Size.x; ref Vector3 reference2 = ref array[i]; reference2.y *= m_volume.Size.y; ref Vector3 reference3 = ref array[i]; reference3.z *= m_volume.Size.z; ref Vector3 reference4 = ref array[i]; reference4 = ((Component)this).transform.TransformPoint(m_volume.Origin + array[i]); } return array; } public Bounds GetBounds() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) return GetBounds(GetCorners()); } public Bounds GetBounds(Vector3[] points) { //IL_0002: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0051: 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_006a: 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) Vector3 val = points.Aggregate(Vector3.zero, (Vector3 result, Vector3 point) => result + point) / (float)points.Length; Bounds result2 = default(Bounds); ((Bounds)(ref result2))..ctor(val, Vector3.zero); for (int i = 0; i < points.Length; i++) { ((Bounds)(ref result2)).Encapsulate(points[i]); } return result2; } public GameObject[] GetGameObjectsInBounds(LayerMask layerMask) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) MeshRenderer[] array = Object.FindObjectsOfType(); List list = new List(); Bounds bounds = GetBounds(); for (int i = 0; i < array.Length; i++) { if (!((Object)(object)((Component)array[i]).gameObject == (Object)(object)((Component)((Component)this).transform).gameObject) && !((Object)(object)((Component)array[i]).GetComponent() != (Object)null) && ((1 << ((Component)array[i]).gameObject.layer) & ((LayerMask)(ref layerMask)).value) != 0 && ((Bounds)(ref bounds)).Intersects(((Renderer)array[i]).bounds)) { list.Add(((Component)array[i]).gameObject); } } return list.ToArray(); } public Vector3 GetSideDirection(int side) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_005f: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0089: 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_0095: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[6]; Vector3 right = Vector3.right; Vector3 up = Vector3.up; Vector3 forward = Vector3.forward; array[0] = right; ref Vector3 reference = ref array[1]; reference = -right; array[2] = up; ref Vector3 reference2 = ref array[3]; reference2 = -up; array[4] = forward; ref Vector3 reference3 = ref array[5]; reference3 = -forward; return ((Component)this).transform.TransformDirection(array[side]); } public Vector3 GetSidePosition(int side) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_005f: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[6]; Vector3 right = Vector3.right; Vector3 up = Vector3.up; Vector3 forward = Vector3.forward; array[0] = right; ref Vector3 reference = ref array[1]; reference = -right; array[2] = up; ref Vector3 reference2 = ref array[3]; reference2 = -up; array[4] = forward; ref Vector3 reference3 = ref array[5]; reference3 = -forward; return ((Component)this).transform.TransformPoint(array[side] * GetSizeAxis(side) + m_volume.Origin); } public float GetSizeAxis(int side) { //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) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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) switch (side) { case 0: case 1: return m_volume.Size.x * 0.5f; case 2: case 3: return m_volume.Size.y * 0.5f; default: return m_volume.Size.z * 0.5f; } } public static Volume EditorVolumeControl(TransformVolume transformVolume, float handleSize, Color color) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown Vector3[] array = (Vector3[])(object)new Vector3[6]; Transform transform = ((Component)transformVolume).transform; Handles.color = color; for (int i = 0; i < array.Length; i++) { ref Vector3 reference = ref array[i]; reference = transformVolume.GetSidePosition(i); } ref Vector3 reference2 = ref array[0]; reference2 = Handles.Slider(array[0], transform.right, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference3 = ref array[1]; reference3 = Handles.Slider(array[1], transform.right, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference4 = ref array[2]; reference4 = Handles.Slider(array[2], transform.up, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference5 = ref array[3]; reference5 = Handles.Slider(array[3], transform.up, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference6 = ref array[4]; reference6 = Handles.Slider(array[4], transform.forward, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference7 = ref array[5]; reference7 = Handles.Slider(array[5], transform.forward, handleSize, new CapFunction(Handles.DotHandleCap), 1f); Vector3 origin = default(Vector3); origin.x = transform.InverseTransformPoint((array[0] + array[1]) * 0.5f).x; origin.y = transform.InverseTransformPoint((array[2] + array[3]) * 0.5f).y; origin.z = transform.InverseTransformPoint((array[4] + array[5]) * 0.5f).z; Vector3 size = default(Vector3); size.x = transform.InverseTransformPoint(array[0]).x - transform.InverseTransformPoint(array[1]).x; size.y = transform.InverseTransformPoint(array[2]).y - transform.InverseTransformPoint(array[3]).y; size.z = transform.InverseTransformPoint(array[4]).z - transform.InverseTransformPoint(array[5]).z; return new Volume(origin, size); } } [Serializable] public struct Volume { [SerializeField] private Vector3 m_origin; [SerializeField] private Vector3 m_size; public Vector3 Origin => m_origin; public Vector3 Size => m_size; public Volume(Vector3 origin, Vector3 size) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) m_origin = origin; m_size = size; } public static bool operator ==(Volume left, Volume right) { return left.Equals(right); } public static bool operator !=(Volume left, Volume right) { return !left.Equals(right); } public bool Equals(Volume other) { //IL_0002: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) return Origin == other.Origin && Size == other.Size; } public override bool Equals(object obj) { if (object.ReferenceEquals(null, obj)) { return false; } return obj is Volume && Equals((Volume)obj); } public override int GetHashCode() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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) Vector3 origin = Origin; int num = ((object)(Vector3)(ref origin)).GetHashCode() * 397; Vector3 size = Size; return num ^ ((object)(Vector3)(ref size)).GetHashCode(); } public override string ToString() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return $"Origin: {Origin}, Size: {Size}"; } } } namespace nrgill28.AtlasSampleScene { public class CTF_CaptureZone : MonoBehaviour { public CTF_Manager Manager; public CTF_Team Team; public void OnTriggerEnter(Collider other) { CTF_Flag component = ((Component)other).GetComponent(); if (Object.op_Implicit((Object)(object)component) && component.Team != Team) { Manager.FlagCaptured(component); } } } public class CTF_Flag : FVRPhysicalObject { [Header("Flag stuffs")] public CTF_Team Team; public float RespawnDelay = 10f; public Vector3 FloorOffset = new Vector3(0f, 0.25f, 0f); private Vector3 _resetPosition; private Quaternion _resetRotation; private Transform _followTransform; private bool _isHeld; private bool _isTaken; private float _timer; private CTF_Sosig _heldBy; public override void Awake() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //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) ((FVRPhysicalObject)this).Awake(); _resetPosition = ((Component)this).transform.position; _resetRotation = ((Component)this).transform.rotation; } private void Update() { if (_isTaken && !_isHeld) { _timer -= Time.deltaTime; if (_timer < 0f) { ReturnFlag(); } } } public void Take() { _isHeld = true; _isTaken = true; } public void Drop() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).IsHeld = false; _timer = RespawnDelay; NavMeshHit val = default(NavMeshHit); NavMesh.SamplePosition(((Component)this).transform.position, ref val, 100f, -1); ((Component)this).transform.position = ((NavMeshHit)(ref val)).position + FloorOffset; ((Component)this).transform.rotation = Quaternion.identity; } public void ReturnFlag() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (((FVRInteractiveObject)this).IsHeld) { ((FVRInteractiveObject)this).ForceBreakInteraction(); } if (Object.op_Implicit((Object)(object)_heldBy)) { _heldBy.HeldFlag = null; } ((Component)this).transform.SetPositionAndRotation(_resetPosition, _resetRotation); _isTaken = false; } private void OnTriggerEnter(Collider other) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (_isHeld) { return; } CTF_Sosig componentInParent = ((Component)other).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent) && (int)componentInParent.Sosig.BodyState == 0) { if (componentInParent.Team == Team) { ReturnFlag(); return; } _heldBy = componentInParent; componentInParent.HeldFlag = this; Take(); } } public override void BeginInteraction(FVRViveHand hand) { ((FVRPhysicalObject)this).BeginInteraction(hand); Take(); } public override void EndInteraction(FVRViveHand hand) { ((FVRPhysicalObject)this).EndInteraction(hand); Drop(); } } public class CTF_Manager : MonoBehaviour { [Header("References")] public Text[] ScoreTexts; public Transform[] AttackPoints; public Text StartButtonText; [Header("Red Team")] public CTF_Flag RedFlag; public int RedTeamSize; public Transform[] RedSpawns; public SosigEnemyID[] RedTeam; [Header("Blue Team")] public CTF_Flag BlueFlag; public int BlueTeamSize; public Transform[] BlueSpawns; public SosigEnemyID[] BlueTeam; private int _blueScore; private int _redScore; private bool _running; private readonly List _sosigs = new List(); private readonly SpawnOptions _spawnOptions; public CTF_Manager() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown SpawnOptions val = new SpawnOptions(); val.SpawnState = (SosigOrder)7; val.SpawnActivated = true; val.EquipmentMode = (EquipmentSlots)7; val.SpawnWithFullAmmo = true; _spawnOptions = val; ((MonoBehaviour)this)..ctor(); } private void Start() { UpdateScoreText(); } public void ToggleGame() { if (_running) { EndGame(); StartButtonText.text = "Start Game"; } else { StartGame(); StartButtonText.text = "Stop Game"; } } private void StartGame() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown ResetGame(); _running = true; GM.CurrentSceneSettings.SosigKillEvent += new SosigKill(CurrentSceneSettingsOnSosigKillEvent); ((MonoBehaviour)this).StartCoroutine(DoInitialSpawns()); } private void EndGame() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown GM.CurrentSceneSettings.SosigKillEvent -= new SosigKill(CurrentSceneSettingsOnSosigKillEvent); foreach (CTF_Sosig sosig in _sosigs) { sosig.Sosig.ClearSosig(); } _running = false; } private void CurrentSceneSettingsOnSosigKillEvent(Sosig s) { CTF_Sosig cTF_Sosig = _sosigs.FirstOrDefault((CTF_Sosig x) => (Object)(object)x.Sosig == (Object)(object)s); if (Object.op_Implicit((Object)(object)cTF_Sosig)) { ((MonoBehaviour)this).StartCoroutine(RespawnSosig(cTF_Sosig)); } } private void SpawnSosig(CTF_Team team) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) _spawnOptions.IFF = (int)team; _spawnOptions.SosigTargetPosition = SodaliteUtils.GetRandom((IList)AttackPoints).position; Transform transform; SosigEnemyID random; if (team == CTF_Team.Red) { transform = ((Component)SodaliteUtils.GetRandom((IList)RedSpawns)).transform; random = SodaliteUtils.GetRandom((IList)RedTeam); } else { transform = ((Component)SodaliteUtils.GetRandom((IList)BlueSpawns)).transform; random = SodaliteUtils.GetRandom((IList)BlueTeam); } Sosig val = SosigAPI.Spawn(ManagerSingleton.Instance.odicSosigObjsByID[random], _spawnOptions, transform.position, transform.rotation); CTF_Sosig cTF_Sosig = ((Component)val).gameObject.AddComponent(); _sosigs.Add(cTF_Sosig); cTF_Sosig.Sosig = val; cTF_Sosig.Team = team; } private IEnumerator DoInitialSpawns() { int i = 0; while (i < Mathf.Max(RedTeamSize, BlueTeamSize)) { if (i < RedTeamSize) { SpawnSosig(CTF_Team.Red); } if (i < BlueTeamSize) { SpawnSosig(CTF_Team.Blue); } i++; yield return (object)new WaitForSeconds(2.5f); } } private IEnumerator RespawnSosig(CTF_Sosig sosig) { yield return (object)new WaitForSeconds(5f); sosig.Sosig.ClearSosig(); _sosigs.Remove(sosig); yield return (object)new WaitForSeconds(5f); if (_running) { int sosigsLeft = _sosigs.Count((CTF_Sosig x) => x.Team == sosig.Team); int teamSize = ((sosig.Team != 0) ? BlueTeamSize : RedTeamSize); if (sosigsLeft < teamSize) { SpawnSosig(sosig.Team); } } } public void ResetGame() { _blueScore = 0; _redScore = 0; UpdateScoreText(); if (Object.op_Implicit((Object)(object)RedFlag)) { RedFlag.ReturnFlag(); } if (Object.op_Implicit((Object)(object)BlueFlag)) { BlueFlag.ReturnFlag(); } } public void FlagCaptured(CTF_Flag flag) { if (flag.Team == CTF_Team.Red) { _blueScore++; } else { _redScore++; } UpdateScoreText(); flag.ReturnFlag(); } public void UpdateScoreText() { Text[] scoreTexts = ScoreTexts; foreach (Text val in scoreTexts) { val.text = "" + _redScore + " - " + _blueScore + ""; } } private void OnDrawGizmos() { //IL_0001: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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) Gizmos.color = Color.red; Transform[] redSpawns = RedSpawns; foreach (Transform val in redSpawns) { Gizmos.DrawSphere(val.position, 0.15f); } Gizmos.color = Color.blue; Transform[] blueSpawns = BlueSpawns; foreach (Transform val2 in blueSpawns) { Gizmos.DrawSphere(val2.position, 0.15f); } Gizmos.color = Color.green; Transform[] attackPoints = AttackPoints; foreach (Transform val3 in attackPoints) { Gizmos.DrawSphere(val3.position, 0.15f); } } } public class CTF_Sosig : MonoBehaviour { public CTF_Team Team; public CTF_Flag HeldFlag; public Sosig Sosig; private void Awake() { Sosig = ((Component)this).GetComponent(); } private void Update() { //IL_001d: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)HeldFlag)) { Vector3 val = ((Component)Sosig).transform.position - ((Component)Sosig).transform.forward * 0.1f; ((Component)HeldFlag).transform.SetPositionAndRotation(val, ((Component)Sosig).transform.rotation); } } } public enum CTF_Team { Red, Blue } public class PopupTarget : MonoBehaviour, IFVRDamageable { [Flags] public enum TargetRange { Near = 1, Mid = 2, Far = 4, All = 7 } public PopupTargetManager Manager; public TargetRange Range; public Transform Pivot; public Vector3 SetRotation; private Quaternion _startRotation; private Quaternion _endRotation; private bool _set; public bool Set { get { return _set; } set { //IL_003e: 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_0027: 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) if (_set != value) { _set = value; ((MonoBehaviour)this).StartCoroutine((!_set) ? RotateTo(_endRotation, _startRotation) : RotateTo(_startRotation, _endRotation)); } } } private void Awake() { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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) _startRotation = Pivot.rotation; _endRotation = Quaternion.Euler(SetRotation + ((Quaternion)(ref _startRotation)).eulerAngles); } void IFVRDamageable.Damage(Damage dam) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 if (Set && (int)dam.Class == 1) { Set = false; Manager.TargetHit(this); } } private IEnumerator RotateTo(Quaternion from, Quaternion to) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) float elapsed = 0f; while (elapsed < 0.25f) { yield return null; elapsed += Time.deltaTime; Pivot.localRotation = Quaternion.Slerp(from, to, elapsed / 0.25f); } Pivot.rotation = to; } } public class PopupTargetManager : MonoBehaviour { public List Targets; private readonly List _setTargets = new List(); private void Awake() { ((MonoBehaviour)this).StartCoroutine(StartSetAsync(3f, 8f, 5, PopupTarget.TargetRange.All)); } private IEnumerator StartSetAsync(float minDelay, float maxDelay, int numTargets, PopupTarget.TargetRange ranges) { yield return (object)new WaitForSeconds(Random.Range(minDelay, maxDelay)); IListExtensions.Shuffle((IList)Targets); _setTargets.Clear(); foreach (PopupTarget target in Targets) { if ((target.Range & ranges) != 0) { target.Set = true; _setTargets.Add(target); numTargets--; } if (numTargets == 0) { break; } } } public void TargetHit(PopupTarget target) { if (_setTargets.Contains(target)) { _setTargets.Remove(target); if (_setTargets.Count == 0) { ((MonoBehaviour)this).StartCoroutine(StartSetAsync(3f, 8f, 5, PopupTarget.TargetRange.All)); } } } } } namespace ShermanJumbo { public class PlayerDamageVolume : MonoBehaviour { private bool IsActive = false; public float DamageDelay = 0.5f; private float CurCooldown = 0.5f; public float DamagePercent = 0.25f; public AudioEvent DamageSound; private void Update() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) CurCooldown -= Time.deltaTime; if (!(CurCooldown <= 0f)) { return; } CurCooldown = DamageDelay; if (IsActive) { GM.CurrentPlayerBody.HarmPercent(DamagePercent); if (!GM.IsDead()) { SM.PlayCoreSound((FVRPooledAudioType)0, DamageSound, ((Component)GM.CurrentPlayerBody).transform.position); } } } private void OnTriggerEnter(Collider other) { if (((Component)other).gameObject.layer == 15) { IsActive = true; } } private void OnTriggerExit(Collider other) { if (((Component)other).gameObject.layer == 15) { IsActive = false; } } } } namespace Technie.PhysicsCreator { public class AlignedCapsuleFitter { public CapsuleDef Fit(Hull hull, Vector3[] meshVertices, int[] meshIndices) { //IL_003c: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) QHullUtil.FindConvexHull(hull.name, hull.selectedFaces.ToArray(), meshVertices, meshIndices, out var hullVertices, out var _, showErrorInLog: false); if (hullVertices == null || hullVertices.Length == 0) { return default(CapsuleDef); } ConstructionPlane plane = new ConstructionPlane(Vector3.zero); RotatedBox rotatedBox = RotatedBoxFitter.FindTightestBox(plane, hullVertices); ConstructionPlane constructionPlane; CapsuleAxis capsuleDirection; if (rotatedBox.size.x > rotatedBox.size.y && rotatedBox.size.x > rotatedBox.size.z) { constructionPlane = new ConstructionPlane(rotatedBox.center, Vector3.right, Vector3.forward); capsuleDirection = CapsuleAxis.X; } else if (rotatedBox.size.y > rotatedBox.size.z) { constructionPlane = new ConstructionPlane(rotatedBox.center, Vector3.up, Vector3.right); capsuleDirection = CapsuleAxis.Y; } else { constructionPlane = new ConstructionPlane(rotatedBox.center, Vector3.forward, Vector3.right); capsuleDirection = CapsuleAxis.Z; } RotatedCapsule inputCapule = RotatedCapsuleFitter.FitCapsule(constructionPlane, hullVertices); RotatedCapsuleFitter.Refine(inputCapule, constructionPlane, hullVertices, out var bestCapsule, out var _); CapsuleDef result = default(CapsuleDef); result.capsuleDirection = capsuleDirection; result.capsuleRadius = bestCapsule.radius; result.capsuleHeight = bestCapsule.height; result.capsuleCenter = bestCapsule.center; result.capsulePosition = Vector3.zero; result.capsuleRotation = Quaternion.identity; return result; } } public class AxisAlignedBoxFitter { public void Fit(Hull hull, Vector3[] meshVertices, int[] meshIndices) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Vector3[] selectedVertices = FaceAlignmentBoxFitter.GetSelectedVertices(hull, meshVertices, meshIndices); ConstructionPlane plane = new ConstructionPlane(Vector3.zero, Vector3.up, Vector3.right); RotatedBox computedBox = RotatedBoxFitter.FindTightestBox(plane, selectedVertices); RotatedBoxFitter.ApplyToHull(computedBox, hull); } } public class Pose { public Vector3 forward; public Vector3 up; public Vector3 right; } public class Triangle { public Vector3 normal; public float area; public Vector3 center; public Triangle(Vector3 p0, Vector3 p1, Vector3 p2) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_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_0017: 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_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_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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) Vector3 val = p1 - p0; Vector3 val2 = p2 - p0; Vector3 val3 = Vector3.Cross(val, val2); area = ((Vector3)(ref val3)).magnitude * 0.5f; normal = ((Vector3)(ref val3)).normalized; center = (p0 + p1 + p2) / 3f; } } public class TriangleBucket { private List triangles; private Vector3 averagedNormal; private Vector3 averagedCenter; private float totalArea; public float Area => totalArea; public TriangleBucket(Triangle initialTriangle) { triangles = new List(); triangles.Add(initialTriangle); CalculateNormal(); CalcTotalArea(); } public void Add(Triangle t) { triangles.Add(t); CalculateNormal(); CalcTotalArea(); } public void Add(TriangleBucket otherBucket) { foreach (Triangle triangle in otherBucket.triangles) { triangles.Add(triangle); } CalculateNormal(); CalcTotalArea(); } private void CalculateNormal() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_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) averagedNormal = Vector3.zero; foreach (Triangle triangle in triangles) { averagedNormal += triangle.normal * triangle.area; } ((Vector3)(ref averagedNormal)).Normalize(); } public Vector3 GetAverageNormal() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return averagedNormal; } public Vector3 GetAverageCenter() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) return triangles[0].center; } private void CalcTotalArea() { totalArea = 0f; foreach (Triangle triangle in triangles) { totalArea += triangle.area; } } } public class TriangleAreaSorter : IComparer { public int Compare(Triangle lhs, Triangle rhs) { if (lhs.area < rhs.area) { return 1; } if (lhs.area > rhs.area) { return -1; } return 0; } } public class TriangleBucketSorter : IComparer { public int Compare(TriangleBucket lhs, TriangleBucket rhs) { if (lhs.Area < rhs.Area) { return 1; } if (lhs.Area > rhs.Area) { return -1; } return 0; } } public class FaceAlignmentBoxFitter { public void Fit(Hull hull, Vector3[] meshVertices, int[] meshIndices) { if (meshIndices.Length < 3) { return; } List list = FindTriangles(meshVertices, meshIndices, hull.selectedFaces); list.Sort(new TriangleAreaSorter()); List list2 = new List(); foreach (Triangle item in list) { TriangleBucket triangleBucket = FindBestBucket(item, 30f, list2); if (triangleBucket != null) { triangleBucket.Add(item); continue; } triangleBucket = new TriangleBucket(item); list2.Add(triangleBucket); } while (list2.Count > 3) { MergeClosestBuckets(list2); } list2.Sort(new TriangleBucketSorter()); Vector3[] selectedVertices = GetSelectedVertices(hull, meshVertices, meshIndices); ConstructionPlane plane = CreateConstructionPlane(list2[0], (list2.Count <= 1) ? null : list2[1], (list2.Count <= 2) ? null : list2[2]); RotatedBox computedBox = RotatedBoxFitter.FindTightestBox(plane, selectedVertices); RotatedBoxFitter.ApplyToHull(computedBox, hull); } public static List FindTriangles(Vector3[] meshVertices, int[] meshIndices, List selectedFaces) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0065: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (int selectedFace in selectedFaces) { int num = meshIndices[selectedFace * 3]; int num2 = meshIndices[selectedFace * 3 + 1]; int num3 = meshIndices[selectedFace * 3 + 2]; Vector3 p = meshVertices[num]; Vector3 p2 = meshVertices[num2]; Vector3 p3 = meshVertices[num3]; Triangle item = new Triangle(p, p2, p3); list.Add(item); } return list; } public static void FindTriangles(Hull hull, Vector3[] meshVertices, int[] meshIndices, out Vector3[] hullVertices, out int[] hullIndices) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (int selectedFace in hull.selectedFaces) { int num = meshIndices[selectedFace * 3]; int num2 = meshIndices[selectedFace * 3 + 1]; int num3 = meshIndices[selectedFace * 3 + 2]; Vector3 item = meshVertices[num]; Vector3 item2 = meshVertices[num2]; Vector3 item3 = meshVertices[num3]; list.Add(item); list.Add(item2); list.Add(item3); } hullVertices = list.ToArray(); hullIndices = new int[hullVertices.Length]; for (int i = 0; i < hullIndices.Length; i++) { hullIndices[i] = i; } } public static Vector3[] GetSelectedVertices(Hull hull, Vector3[] meshVertices, int[] meshIndices) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); foreach (int selectedFace in hull.selectedFaces) { int num = meshIndices[selectedFace * 3]; int num2 = meshIndices[selectedFace * 3 + 1]; int num3 = meshIndices[selectedFace * 3 + 2]; dictionary[num] = num; dictionary[num2] = num2; dictionary[num3] = num3; } List list = new List(); foreach (int key in dictionary.Keys) { list.Add(meshVertices[key]); } return list.ToArray(); } private TriangleBucket FindBestBucket(Triangle tri, float thresholdAngleDeg, List buckets) { //IL_0020: 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_0050: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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) TriangleBucket result = null; float num = float.PositiveInfinity; foreach (TriangleBucket bucket in buckets) { float num2 = Vector3.Angle(tri.normal, bucket.GetAverageNormal()); if (num2 < thresholdAngleDeg && num2 < num) { num = num2; result = bucket; continue; } float num3 = Vector3.Angle(tri.normal * -1f, bucket.GetAverageNormal()); if (num3 < thresholdAngleDeg && num3 < num) { tri.normal *= -1f; num = num3; result = bucket; } } return result; } private void MergeClosestBuckets(List buckets) { //IL_0033: 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) TriangleBucket triangleBucket = null; TriangleBucket triangleBucket2 = null; float num = float.PositiveInfinity; for (int i = 0; i < buckets.Count; i++) { for (int j = i + 1; j < buckets.Count; j++) { TriangleBucket triangleBucket3 = buckets[i]; TriangleBucket triangleBucket4 = buckets[j]; float num2 = Vector3.Angle(triangleBucket3.GetAverageNormal(), triangleBucket4.GetAverageNormal()); if (num2 < num) { num = num2; triangleBucket = triangleBucket3; triangleBucket2 = triangleBucket4; } } } if (triangleBucket != null && triangleBucket2 != null) { buckets.Remove(triangleBucket2); triangleBucket.Add(triangleBucket2); } } private ConstructionPlane CreateConstructionPlane(TriangleBucket primaryBucket, TriangleBucket secondaryBucket, TriangleBucket tertiaryBucket) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0050: 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_0054: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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) if (primaryBucket != null && secondaryBucket != null) { Vector3 averageNormal = primaryBucket.GetAverageNormal(); Vector3 t = Vector3.Cross(averageNormal, secondaryBucket.GetAverageNormal()); Vector3 averageCenter = primaryBucket.GetAverageCenter(); return new ConstructionPlane(averageCenter, averageNormal, t); } if (primaryBucket != null) { Vector3 averageNormal2 = primaryBucket.GetAverageNormal(); Vector3 averageCenter2 = primaryBucket.GetAverageCenter(); Vector3 t2 = Vector3.Cross(averageNormal2, (!(Vector3.Dot(averageNormal2, Vector3.up) > 0.5f)) ? Vector3.up : Vector3.right); return new ConstructionPlane(averageCenter2, averageNormal2, t2); } return null; } } public class GizmoUtils { public static void ToggleGizmos(bool gizmosOn) { int num = (gizmosOn ? 1 : 0); Assembly assembly = Assembly.GetAssembly(typeof(Editor)); Type type = assembly.GetType("UnityEditor.AnnotationUtility"); if ((object)type == null) { return; } MethodInfo method = type.GetMethod("GetAnnotations", BindingFlags.Static | BindingFlags.NonPublic); MethodInfo method2 = type.GetMethod("SetGizmoEnabled", BindingFlags.Static | BindingFlags.NonPublic); MethodInfo method3 = type.GetMethod("SetIconEnabled", BindingFlags.Static | BindingFlags.NonPublic); object obj = method.Invoke(null, null); foreach (object item in (IEnumerable)obj) { Type type2 = item.GetType(); FieldInfo field = type2.GetField("classID", BindingFlags.Instance | BindingFlags.Public); FieldInfo field2 = type2.GetField("scriptClass", BindingFlags.Instance | BindingFlags.Public); if ((object)field == null || (object)field2 == null) { continue; } int num2 = (int)field.GetValue(item); string text = (string)field2.GetValue(item); if (text == "HullPainter") { switch (method2.GetParameters().Length) { case 3: method2.Invoke(null, new object[3] { num2, text, num }); break; case 4: method2.Invoke(null, new object[4] { num2, text, num, true }); break; } int num3 = method3.GetParameters().Length; if (num3 == 3) { method3.Invoke(null, new object[3] { num2, text, num }); } } } } } public class HullData : ScriptableObject { } public class HullMapping { public Hull sourceHull; public Collider generatedCollider; public MeshCollider[] autoGeneratedColliders; public HullPainterChild targetChild; public HullPainterChild[] targetAutoGeneratedChilds; public void AddAutoChild(HullPainterChild newChild, MeshCollider newCollider) { if ((Object)(object)newChild != (Object)null) { List list = new List(); if (targetAutoGeneratedChilds != null) { list.AddRange(targetAutoGeneratedChilds); } if (!list.Contains(newChild)) { list.Add(newChild); targetAutoGeneratedChilds = list.ToArray(); } } if ((Object)(object)newCollider != (Object)null) { List list2 = new List(); if (autoGeneratedColliders != null) { list2.AddRange(autoGeneratedColliders); } if (!list2.Contains(newCollider)) { list2.Add(newCollider); autoGeneratedColliders = list2.ToArray(); } } } } public class HullPainter : MonoBehaviour { public PaintingData paintingData; public HullData hullData; private List hullMapping; private Mesh debugMesh; private void OnDestroy() { SceneView.RepaintAll(); } public void CreateColliderComponents(Mesh[] autoHulls) { CreateHullMapping(); foreach (Hull hull in paintingData.hulls) { UpdateCollider(hull); } foreach (Hull hull2 in paintingData.hulls) { CreateAutoHulls(hull2, autoHulls); } } public void RemoveAllColliders() { if (hullMapping == null) { return; } foreach (HullMapping item in hullMapping) { DestroyImmediateWithUndo((Object)(object)item.generatedCollider); if (item.autoGeneratedColliders != null) { MeshCollider[] autoGeneratedColliders = item.autoGeneratedColliders; foreach (MeshCollider obj in autoGeneratedColliders) { DestroyImmediateWithUndo((Object)(object)obj); } } } for (int num = hullMapping.Count - 1; num >= 0; num--) { if ((Object)(object)hullMapping[num].targetChild != (Object)null) { hullMapping.RemoveAt(num); } } } public void RemoveAllGenerated() { CreateHullMapping(); foreach (HullMapping item in hullMapping) { DestroyImmediateWithUndo((Object)(object)item.generatedCollider); if ((Object)(object)item.targetChild != (Object)null) { DestroyImmediateWithUndo((Object)(object)((Component)item.targetChild).gameObject); } if (item.autoGeneratedColliders != null) { MeshCollider[] autoGeneratedColliders = item.autoGeneratedColliders; foreach (MeshCollider obj in autoGeneratedColliders) { DestroyImmediateWithUndo((Object)(object)obj); } } if (item.targetAutoGeneratedChilds == null) { continue; } HullPainterChild[] targetAutoGeneratedChilds = item.targetAutoGeneratedChilds; foreach (HullPainterChild hullPainterChild in targetAutoGeneratedChilds) { GameObject gameObject = ((Component)hullPainterChild).gameObject; DestroyImmediateWithUndo((Object)(object)hullPainterChild); if (gameObject.transform.childCount == 0 && gameObject.GetComponents().Length == 1) { DestroyImmediateWithUndo((Object)(object)gameObject); } } } } private static bool IsDeletable(GameObject obj) { Component[] components = obj.GetComponents(); int num = 0; Component[] array = components; foreach (Component val in array) { if (val is Transform || val is Collider || val is HullPainter || val is HullPainterChild) { num++; } } return components.Length == num; } private static void DestroyImmediateWithUndo(Object obj) { if (!(obj == (Object)null)) { Undo.DestroyObjectImmediate(obj); } } private void CreateHullMapping() { //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_05ae: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_0693: Unknown result type (might be due to invalid IL or missing references) //IL_069a: Unknown result type (might be due to invalid IL or missing references) //IL_06ab: Unknown result type (might be due to invalid IL or missing references) //IL_06b2: Unknown result type (might be due to invalid IL or missing references) if (this.hullMapping == null) { this.hullMapping = new List(); } for (int num = this.hullMapping.Count - 1; num >= 0; num--) { HullMapping hullMapping = this.hullMapping[num]; if (hullMapping == null || hullMapping.sourceHull == null || ((Object)(object)hullMapping.generatedCollider == (Object)null && (Object)(object)hullMapping.targetChild == (Object)null)) { this.hullMapping.RemoveAt(num); } } foreach (Hull hull4 in paintingData.hulls) { if (IsMapped(hull4)) { Collider val = FindExistingCollider(this.hullMapping, hull4); bool flag = hull4.type == HullType.ConvexHull && val is MeshCollider; bool flag2 = hull4.type == HullType.Box && val is BoxCollider; bool flag3 = hull4.type == HullType.Capsule && val is CapsuleCollider; bool flag4 = hull4.type == HullType.Sphere && val is SphereCollider; bool flag5 = hull4.type == HullType.Face && val is MeshCollider; bool flag6 = hull4.type == HullType.FaceAsBox && val is BoxCollider; bool flag7 = hull4.type == HullType.Auto && val is MeshCollider && hull4.autoMeshes != null && hull4.autoMeshes.Length > 0; bool flag8 = flag || flag2 || flag3 || flag4 || flag5 || flag6 || flag7; bool flag9 = (Object)(object)val == (Object)null || hull4.isChildCollider == ((Object)(object)((Component)val).transform.parent == (Object)(object)((Component)this).transform) || hull4.type == HullType.Auto; if (!flag8 || !flag9) { DestroyImmediateWithUndo((Object)(object)val); RemoveMapping(hull4); } } } List list = new List(); List list2 = new List(); List list3 = new List(); foreach (Hull hull5 in paintingData.hulls) { if (!IsMapped(hull5)) { list.Add(hull5); } } foreach (Collider item in FindLocal()) { if (!IsMapped(item)) { list2.Add(item); } } foreach (HullPainterChild item2 in FindLocal()) { if (!IsMapped(item2)) { list3.Add(item2); } } for (int num2 = list.Count - 1; num2 >= 0; num2--) { Hull hull = list[num2]; bool flag10 = false; for (int num3 = list2.Count - 1; num3 >= 0; num3--) { Collider val2 = list2[num3]; MeshCollider val3 = (MeshCollider)(object)((val2 is MeshCollider) ? val2 : null); BoxCollider val4 = (BoxCollider)(object)((val2 is BoxCollider) ? val2 : null); CapsuleCollider val5 = (CapsuleCollider)(object)((val2 is CapsuleCollider) ? val2 : null); SphereCollider val6 = (SphereCollider)(object)((val2 is SphereCollider) ? val2 : null); HullPainterChild hullPainterChild = null; if ((Object)(object)((Component)val2).transform.parent == (Object)(object)((Component)this).transform) { hullPainterChild = ((Component)val2).gameObject.GetComponent(); } bool flag11 = hull.isChildCollider && (Object)(object)((Component)val2).transform.parent == (Object)(object)((Component)this).transform; if ((Object)(object)hullPainterChild != (Object)null && hullPainterChild.isAutoHull && hull.type == HullType.Auto && (Object)(object)val3 != (Object)null && hull.ContainsAutoMesh(val3.sharedMesh)) { HullMapping hullMapping2 = FindMapping(hull); if (hullMapping2 == null) { hullMapping2 = new HullMapping(); hullMapping2.sourceHull = hull; this.hullMapping.Add(hullMapping2); } hullMapping2.AddAutoChild(hullPainterChild, (MeshCollider)(object)((val2 is MeshCollider) ? val2 : null)); hullPainterChild.parent = this; list2.RemoveAt(num3); list3.Remove(hullPainterChild); flag10 = true; } else if (flag11) { bool flag12 = hull.type == HullType.Box && val2 is BoxCollider && Approximately(((Bounds)(ref hull.collisionBox.collisionBox)).center, val4.center) && Approximately(((Bounds)(ref hull.collisionBox.collisionBox)).size, val4.size); bool flag13 = hull.type == HullType.Sphere && val2 is SphereCollider && hull.collisionSphere != null && Approximately(hull.collisionSphere.center, val6.center) && Approximately(hull.collisionSphere.radius, val6.radius); bool flag14 = hull.type == HullType.Capsule && val2 is CapsuleCollider && Approximately(hull.collisionCapsule.capsuleCenter, val5.center) && hull.collisionCapsule.capsuleDirection == (CapsuleAxis)val5.direction && Approximately(hull.collisionCapsule.capsuleRadius, val5.radius) && Approximately(hull.collisionCapsule.capsuleHeight, val5.radius); bool flag15 = hull.type == HullType.ConvexHull && val2 is MeshCollider && (Object)(object)val3.sharedMesh == (Object)(object)hull.collisionMesh; bool flag16 = hull.type == HullType.Face && val2 is MeshCollider && (Object)(object)val3.sharedMesh == (Object)(object)hull.faceCollisionMesh; bool flag17 = hull.type == HullType.FaceAsBox && val2 is BoxCollider && Approximately(hull.faceBoxCenter, val4.center) && Approximately(hull.faceBoxSize, val4.size); if (flag12 || flag13 || flag14 || flag15 || flag16 || flag17) { AddMapping(hull, val2, hullPainterChild); list.RemoveAt(num2); list2.RemoveAt(num3); for (int i = 0; i < list3.Count; i++) { if ((Object)(object)list3[i] == (Object)(object)hullPainterChild) { list3.RemoveAt(i); break; } } break; } } } if (flag10) { list.RemoveAt(num2); } } for (int num4 = list.Count - 1; num4 >= 0; num4--) { Hull hull2 = list[num4]; if (hull2.isChildCollider) { for (int num5 = list3.Count - 1; num5 >= 0; num5--) { HullPainterChild child = list3[num5]; HullMapping hullMapping3 = FindMapping(child); if (hullMapping3 != null && hullMapping3.sourceHull != null) { if ((Object)(object)hullMapping3.generatedCollider == (Object)null) { RecreateChildCollider(hullMapping3); } list.RemoveAt(num4); list3.RemoveAt(num5); break; } } } } for (int num6 = list.Count - 1; num6 >= 0; num6--) { Hull hull3 = list[num6]; if (hull3.isChildCollider && hull3.type == HullType.Auto) { bool flag18 = false; for (int num7 = list3.Count - 1; num7 >= 0; num7--) { HullPainterChild hullPainterChild2 = list3[num7]; if (hullPainterChild2.isAutoHull && ((Object)((Component)hullPainterChild2).gameObject).name.StartsWith(hull3.name)) { HullMapping hullMapping4 = FindMapping(hull3); if (hullMapping4 == null) { hullMapping4 = new HullMapping(); hullMapping4.sourceHull = hull3; this.hullMapping.Add(hullMapping4); } hullMapping4.AddAutoChild(hullPainterChild2, null); list3.RemoveAt(num7); flag18 = true; } } if (flag18) { list.RemoveAt(num6); } } } foreach (HullMapping item3 in this.hullMapping) { if ((Object)(object)item3.targetChild != (Object)null && (Object)(object)item3.generatedCollider == (Object)null) { RecreateChildCollider(item3); } } foreach (HullMapping item4 in this.hullMapping) { if ((Object)(object)item4.targetChild == (Object)null && (Object)(object)item4.generatedCollider != (Object)null && (Object)(object)((Component)item4.generatedCollider).transform.parent == (Object)(object)((Component)this).transform) { HullPainterChild hullPainterChild3 = AddComponent(((Component)item4.generatedCollider).gameObject); hullPainterChild3.parent = this; item4.targetChild = hullPainterChild3; } } foreach (Hull item5 in list) { if (item5.type == HullType.Box) { CreateCollider(item5); } else if (item5.type == HullType.Sphere) { CreateCollider(item5); } else if (item5.type == HullType.ConvexHull) { CreateCollider(item5); } else if (item5.type == HullType.Face) { CreateCollider(item5); } else if (item5.type == HullType.FaceAsBox) { CreateCollider(item5); } else if (item5.type == HullType.Capsule) { CreateCollider(item5); } } foreach (Collider item6 in list2) { if ((Object)(object)item6 == (Object)null) { continue; } if ((Object)(object)((Component)item6).gameObject == (Object)(object)((Component)this).gameObject) { DestroyImmediateWithUndo((Object)(object)item6); continue; } GameObject gameObject = ((Component)item6).gameObject; DestroyImmediateWithUndo((Object)(object)item6); DestroyImmediateWithUndo((Object)(object)gameObject.GetComponent()); if (IsDeletable(gameObject)) { DestroyImmediateWithUndo((Object)(object)gameObject); } } foreach (HullPainterChild item7 in list3) { if (!((Object)(object)item7 == (Object)null)) { GameObject gameObject2 = ((Component)item7).gameObject; DestroyImmediateWithUndo((Object)(object)item7); DestroyImmediateWithUndo((Object)(object)gameObject2.GetComponent()); if (IsDeletable(gameObject2)) { DestroyImmediateWithUndo((Object)(object)gameObject2); } } } } private static bool Approximately(Vector3 lhs, Vector3 rhs) { return Mathf.Approximately(lhs.x, rhs.x) && Mathf.Approximately(lhs.y, rhs.y) && Mathf.Approximately(lhs.z, rhs.z); } private static bool Approximately(float lhs, float rhs) { return Mathf.Approximately(lhs, rhs); } private void CreateCollider(Hull sourceHull) where T : Collider { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (sourceHull.isChildCollider) { GameObject val = CreateGameObject(sourceHull.name); val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; HullPainterChild hullPainterChild = AddComponent(val); hullPainterChild.parent = this; T val2 = AddComponent(val); AddMapping(sourceHull, (Collider)(object)val2, hullPainterChild); } else { T val3 = AddComponent(((Component)this).gameObject); AddMapping(sourceHull, (Collider)(object)val3, null); } } private void RecreateChildCollider(HullMapping mapping) { if (mapping != null && mapping.sourceHull != null && mapping.sourceHull.isChildCollider) { if (mapping.sourceHull.type == HullType.Box) { RecreateChildCollider(mapping); } else if (mapping.sourceHull.type == HullType.Sphere) { RecreateChildCollider(mapping); } else if (mapping.sourceHull.type == HullType.ConvexHull) { RecreateChildCollider(mapping); } else if (mapping.sourceHull.type == HullType.Face) { RecreateChildCollider(mapping); } else if (mapping.sourceHull.type == HullType.FaceAsBox) { RecreateChildCollider(mapping); } else if (mapping.sourceHull.type == HullType.Capsule) { RecreateChildCollider(mapping); } } } private void RecreateChildCollider(HullMapping mapping) where T : Collider { if (mapping.sourceHull != null && mapping.sourceHull.isChildCollider) { T val = AddComponent(((Component)mapping.targetChild).gameObject); mapping.generatedCollider = (Collider)(object)val; } } private void UpdateCollider(Hull hull) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) Collider val = null; if (hull.type == HullType.Box) { Collider obj = FindExistingCollider(hullMapping, hull); BoxCollider val2 = (BoxCollider)(object)((obj is BoxCollider) ? obj : null); val2.center = ((Bounds)(ref hull.collisionBox.collisionBox)).center; val2.size = ((Bounds)(ref hull.collisionBox.collisionBox)).size + ((!hull.enableInflation) ? Vector3.zero : (Vector3.one * hull.inflationAmount)); if (hull.isChildCollider) { ((Component)val2).transform.localPosition = hull.collisionBox.boxPosition; ((Component)val2).transform.localRotation = hull.collisionBox.boxRotation; } val = (Collider)(object)val2; } else if (hull.type == HullType.Sphere) { Collider obj2 = FindExistingCollider(hullMapping, hull); SphereCollider val3 = (SphereCollider)(object)((obj2 is SphereCollider) ? obj2 : null); val3.center = hull.collisionSphere.center; val3.radius = hull.collisionSphere.radius + ((!hull.enableInflation) ? 0f : hull.inflationAmount); val = (Collider)(object)val3; } else if (hull.type == HullType.Capsule) { Collider obj3 = FindExistingCollider(hullMapping, hull); CapsuleCollider val4 = (CapsuleCollider)(object)((obj3 is CapsuleCollider) ? obj3 : null); val4.center = hull.collisionCapsule.capsuleCenter; val4.direction = (int)hull.collisionCapsule.capsuleDirection; val4.radius = hull.collisionCapsule.capsuleRadius; val4.height = hull.collisionCapsule.capsuleHeight; if (hull.isChildCollider) { ((Component)val4).transform.localPosition = hull.collisionCapsule.capsulePosition; ((Component)val4).transform.localRotation = hull.collisionCapsule.capsuleRotation; } val = (Collider)(object)val4; } else if (hull.type == HullType.ConvexHull) { Collider obj4 = FindExistingCollider(hullMapping, hull); MeshCollider val5 = (MeshCollider)(object)((obj4 is MeshCollider) ? obj4 : null); val5.sharedMesh = hull.collisionMesh; val5.convex = true; val5.inflateMesh = hull.enableInflation; val5.skinWidth = hull.inflationAmount; val = (Collider)(object)val5; } else if (hull.type == HullType.Face) { Collider obj5 = FindExistingCollider(hullMapping, hull); MeshCollider val6 = (MeshCollider)(object)((obj5 is MeshCollider) ? obj5 : null); val6.sharedMesh = hull.faceCollisionMesh; val6.convex = true; val6.inflateMesh = hull.enableInflation; val6.skinWidth = hull.inflationAmount; val = (Collider)(object)val6; } else if (hull.type == HullType.FaceAsBox) { Collider obj6 = FindExistingCollider(hullMapping, hull); BoxCollider val7 = (BoxCollider)(object)((obj6 is BoxCollider) ? obj6 : null); val7.center = hull.faceBoxCenter; val7.size = hull.faceBoxSize + ((!hull.enableInflation) ? Vector3.zero : (Vector3.one * hull.inflationAmount)); if (hull.isChildCollider) { ((Component)val7).transform.localRotation = hull.faceAsBoxRotation; } val = (Collider)(object)val7; } else if (hull.type != HullType.Auto) { } if ((Object)(object)val != (Object)null) { val.material = hull.material; val.isTrigger = hull.isTrigger; if (hull.isChildCollider) { ((Object)((Component)val).gameObject).name = hull.name; } } } public void SetAllTypes(HullType newType) { foreach (Hull hull in paintingData.hulls) { hull.type = newType; } } public void SetAllMaterials(PhysicMaterial newMaterial) { foreach (Hull hull in paintingData.hulls) { hull.material = newMaterial; } } public void SetAllAsChild(bool isChild) { foreach (Hull hull in paintingData.hulls) { hull.isChildCollider = isChild; } } public void SetAllAsTrigger(bool isTrigger) { foreach (Hull hull in paintingData.hulls) { hull.isTrigger = isTrigger; } } private List FindLocal() where T : Component { List list = new List(); list.AddRange(((Component)this).gameObject.GetComponents()); for (int i = 0; i < ((Component)this).transform.childCount; i++) { list.AddRange(((Component)((Component)this).transform.GetChild(i)).GetComponents()); } return list; } private bool IsMapped(Hull hull) { if (hullMapping == null) { return false; } foreach (HullMapping item in hullMapping) { if (item.sourceHull == hull) { return true; } } return false; } private bool IsMapped(Collider col) { if (hullMapping == null) { return false; } foreach (HullMapping item in hullMapping) { if ((Object)(object)item.generatedCollider == (Object)(object)col) { return true; } } return false; } private bool IsMapped(HullPainterChild child) { if (hullMapping == null) { return false; } foreach (HullMapping item in hullMapping) { if ((Object)(object)item.targetChild == (Object)(object)child) { return true; } } return false; } private void AddMapping(Hull hull, Collider col, HullPainterChild painterChild) { HullMapping hullMapping = new HullMapping(); hullMapping.sourceHull = hull; hullMapping.generatedCollider = col; hullMapping.targetChild = painterChild; HullMapping item = hullMapping; this.hullMapping.Add(item); } private void RemoveMapping(Hull hull) { for (int i = 0; i < hullMapping.Count; i++) { if (hullMapping[i].sourceHull == hull) { hullMapping.RemoveAt(i); break; } } } private HullMapping FindMapping(HullPainterChild child) { if (hullMapping == null) { return null; } foreach (HullMapping item in hullMapping) { if ((Object)(object)item.targetChild == (Object)(object)child) { return item; } } return null; } private HullMapping FindMapping(Hull hull) { if (hullMapping == null) { return null; } foreach (HullMapping item in hullMapping) { if (item.sourceHull == hull) { return item; } } return null; } public Hull FindSourceHull(HullPainterChild child) { if (hullMapping == null) { return null; } foreach (HullMapping item in hullMapping) { if ((Object)(object)item.targetChild == (Object)(object)child) { return item.sourceHull; } if (item.targetAutoGeneratedChilds == null) { continue; } HullPainterChild[] targetAutoGeneratedChilds = item.targetAutoGeneratedChilds; foreach (HullPainterChild hullPainterChild in targetAutoGeneratedChilds) { if ((Object)(object)hullPainterChild == (Object)(object)child) { return item.sourceHull; } } } return null; } private static Collider FindExistingCollider(List mappings, Hull hull) { foreach (HullMapping mapping in mappings) { if (mapping.sourceHull == hull) { return mapping.generatedCollider; } } return null; } private void CreateAutoHulls(Hull hull, Mesh[] autoHulls) { if (hull.type != HullType.Auto) { return; } HullMapping hullMapping = FindMapping(hull); if (hullMapping == null) { hullMapping = new HullMapping(); hullMapping.sourceHull = hull; this.hullMapping.Add(hullMapping); } Mesh[] autoMeshes = hull.autoMeshes; List list = new List(); if (hullMapping.targetAutoGeneratedChilds != null) { for (int i = 0; i < hullMapping.targetAutoGeneratedChilds.Length; i++) { if (hullMapping.autoGeneratedColliders != null && i < hullMapping.autoGeneratedColliders.Length) { list.Add(hullMapping.autoGeneratedColliders[i]); continue; } MeshCollider val = ((Component)hullMapping.targetAutoGeneratedChilds[i]).gameObject.AddComponent(); val.convex = true; list.Add(val); } } for (int num = list.Count - 1; num >= 0; num--) { bool flag = (Object)(object)((Component)list[num]).transform != (Object)(object)((Component)this).transform; if (flag != Object.op_Implicit((Object)(object)((Component)this).transform) && hull.isChildCollider) { if (flag) { Object.DestroyImmediate((Object)(object)((Component)list[num]).gameObject); } else { Object.DestroyImmediate((Object)(object)list[num]); } list.RemoveAt(num); } } for (int j = 0; j < autoMeshes.Length; j++) { Mesh sharedMesh = autoMeshes[j]; MeshCollider val2; if (j < list.Count) { val2 = list[j]; } else if (hull.isChildCollider) { GameObject val3 = CreateGameObject("New child"); val3.transform.SetParent(((Component)this).transform, false); HullPainterChild hullPainterChild = val3.AddComponent(); hullPainterChild.parent = this; hullPainterChild.isAutoHull = true; val2 = val3.AddComponent(); list.Add(val2); } else { val2 = ((Component)this).gameObject.AddComponent(); list.Add(val2); } val2.sharedMesh = sharedMesh; val2.convex = true; ((Collider)val2).isTrigger = hull.isTrigger; ((Collider)val2).material = hull.material; } if (hull.isChildCollider) { for (int k = 0; k < list.Count; k++) { ((Object)((Component)list[k]).gameObject).name = $"{hull.name}.{k + 1}"; } } List list2 = new List(); foreach (MeshCollider item in list) { list2.Add(((Component)item).GetComponent()); } hullMapping.autoGeneratedColliders = list.ToArray(); hullMapping.targetAutoGeneratedChilds = list2.ToArray(); } private static GameObject CreateGameObject(string goName) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown GameObject val = new GameObject(goName); Undo.RegisterCreatedObjectUndo((Object)(object)val, "Created " + goName); return val; } private static T AddComponent(GameObject targetObj) where T : Component { return (T)(object)Undo.AddComponent(targetObj, typeof(T)); } private void OnDrawGizmos() { } } public class HullPainterChild : MonoBehaviour { public HullPainter parent; public bool isAutoHull; } } public class CuttableMesh { private MeshRenderer inputMeshRenderer; private bool hasUvs; private bool hasUv1s; private bool hasColours; private List subMeshes; public CuttableMesh(Mesh inputMesh) { Init(inputMesh, ((Object)inputMesh).name); } public CuttableMesh(MeshRenderer input) { inputMeshRenderer = input; MeshFilter component = ((Component)input).GetComponent(); Mesh sharedMesh = component.sharedMesh; Init(sharedMesh, ((Object)input).name); } public CuttableMesh(CuttableMesh inputMesh, List newSubMeshes) { inputMeshRenderer = inputMesh.inputMeshRenderer; hasUvs = inputMesh.hasUvs; hasUv1s = inputMesh.hasUv1s; hasColours = inputMesh.hasColours; subMeshes = new List(); subMeshes.AddRange(newSubMeshes); } private void Init(Mesh inputMesh, string debugName) { subMeshes = new List(); if (inputMesh.isReadable) { Vector3[] vertices = inputMesh.vertices; Vector3[] normals = inputMesh.normals; Vector2[] uv = inputMesh.uv; Vector2[] uv2 = inputMesh.uv2; Color32[] colors = inputMesh.colors32; hasUvs = uv != null && uv.Length > 0; hasUv1s = uv2 != null && uv2.Length > 0; hasColours = colors != null && colors.Length > 0; for (int i = 0; i < inputMesh.subMeshCount; i++) { int[] indices = inputMesh.GetIndices(i); CuttableSubMesh item = new CuttableSubMesh(indices, vertices, normals, colors, uv, uv2); subMeshes.Add(item); } } else { Debug.LogError((object)("CuttableMesh's input mesh is not readable: " + debugName), (Object)(object)inputMesh); } } public void Add(CuttableMesh other) { if (subMeshes.Count != other.subMeshes.Count) { throw new Exception("Mismatched submesh count"); } for (int i = 0; i < subMeshes.Count; i++) { subMeshes[i].Add(other.subMeshes[i]); } } public int NumSubMeshes() { return subMeshes.Count; } public bool HasUvs() { return hasUvs; } public bool HasColours() { return hasColours; } public List GetSubMeshes() { return subMeshes; } public CuttableSubMesh GetSubMesh(int index) { return subMeshes[index]; } public Transform GetTransform() { if ((Object)(object)inputMeshRenderer != (Object)null) { return ((Component)inputMeshRenderer).transform; } return null; } public MeshRenderer ConvertToRenderer(string newObjectName) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) Mesh val = CreateMesh(); if (val.vertexCount == 0) { return null; } GameObject val2 = new GameObject(newObjectName); val2.transform.SetParent(((Component)inputMeshRenderer).transform); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; MeshFilter val3 = val2.AddComponent(); val3.mesh = val; MeshRenderer val4 = val2.AddComponent(); ((Renderer)val4).shadowCastingMode = ((Renderer)inputMeshRenderer).shadowCastingMode; ((Renderer)val4).reflectionProbeUsage = ((Renderer)inputMeshRenderer).reflectionProbeUsage; ((Renderer)val4).lightProbeUsage = ((Renderer)inputMeshRenderer).lightProbeUsage; ((Renderer)val4).sharedMaterials = ((Renderer)inputMeshRenderer).sharedMaterials; return val4; } public Mesh CreateMesh() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Mesh val = new Mesh(); int num = 0; for (int i = 0; i < subMeshes.Count; i++) { num += subMeshes[i].NumIndices(); } List list = new List(); List list2 = new List(); List list3 = ((!hasColours) ? null : new List()); List list4 = ((!hasUvs) ? null : new List()); List list5 = ((!hasUv1s) ? null : new List()); List list6 = new List(); foreach (CuttableSubMesh subMesh in subMeshes) { list6.Add(list.Count); subMesh.AddTo(list, list2, list3, list4, list5); } val.vertices = list.ToArray(); val.normals = list2.ToArray(); val.colors32 = ((!hasColours) ? null : list3.ToArray()); val.uv = ((!hasUvs) ? null : list4.ToArray()); val.uv2 = ((!hasUv1s) ? null : list5.ToArray()); val.subMeshCount = subMeshes.Count; for (int j = 0; j < subMeshes.Count; j++) { CuttableSubMesh cuttableSubMesh = subMeshes[j]; int num2 = list6[j]; int[] array = cuttableSubMesh.GenIndices(); for (int k = 0; k < array.Length; k++) { array[k] += num2; } val.SetTriangles(array, j, true); } return val; } } public class CuttableSubMesh { private List vertices; private List normals; private List colours; private List uvs; private List uv1s; public CuttableSubMesh(bool hasNormals, bool hasColours, bool hasUvs, bool hasUv1) { vertices = new List(); if (hasNormals) { normals = new List(); } if (hasColours) { colours = new List(); } if (hasUvs) { uvs = new List(); } if (hasUv1) { uv1s = new List(); } } public CuttableSubMesh(int[] indices, Vector3[] inputVertices, Vector3[] inputNormals, Color32[] inputColours, Vector2[] inputUvs, Vector2[] inputUv1) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) vertices = new List(); if (inputNormals != null && inputNormals.Length > 0) { normals = new List(); } if (inputColours != null && inputColours.Length > 0) { colours = new List(); } if (inputUvs != null && inputUvs.Length > 0) { uvs = new List(); } if (inputUv1 != null && inputUv1.Length > 0) { uv1s = new List(); } foreach (int num in indices) { vertices.Add(inputVertices[num]); if (normals != null) { normals.Add(inputNormals[num]); } if (colours != null) { colours.Add(inputColours[num]); } if (uvs != null) { uvs.Add(inputUvs[num]); } if (uv1s != null) { uv1s.Add(inputUv1[num]); } } } public void Add(CuttableSubMesh other) { for (int i = 0; i < other.vertices.Count; i++) { CopyVertex(i, other); } } public int NumVertices() { return vertices.Count; } public Vector3 GetVertex(int index) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) return vertices[index]; } public bool HasNormals() { return normals != null; } public bool HasColours() { return colours != null; } public bool HasUvs() { return uvs != null; } public bool HasUv1() { return uv1s != null; } public void CopyVertex(int srcIndex, CuttableSubMesh srcMesh) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) vertices.Add(srcMesh.vertices[srcIndex]); if (normals != null) { normals.Add(srcMesh.normals[srcIndex]); } if (colours != null) { colours.Add(srcMesh.colours[srcIndex]); } if (uvs != null) { uvs.Add(srcMesh.uvs[srcIndex]); } if (uv1s != null) { uv1s.Add(srcMesh.uv1s[srcIndex]); } } public void AddInterpolatedVertex(int i0, int i1, float weight, CuttableSubMesh srcMesh) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) Vector3 vertex = srcMesh.GetVertex(i0); Vector3 vertex2 = srcMesh.GetVertex(i1); vertices.Add(Vector3.Lerp(vertex, vertex2, weight)); if (normals != null) { List list = normals; Vector3 val = Vector3.Lerp(srcMesh.normals[i0], srcMesh.normals[i1], weight); list.Add(((Vector3)(ref val)).normalized); } if (colours != null) { colours.Add(Color32.Lerp(srcMesh.colours[i0], srcMesh.colours[i1], weight)); } if (uvs != null) { uvs.Add(Vector2.Lerp(srcMesh.uvs[i0], srcMesh.uvs[i1], weight)); } if (uv1s != null) { uv1s.Add(Vector2.Lerp(srcMesh.uv1s[i0], srcMesh.uv1s[i1], weight)); } } public void AddTo(List destVertices, List destNormals, List destColours, List destUvs, List destUv1s) { destVertices.AddRange(vertices); if (normals != null) { destNormals.AddRange(normals); } if (colours != null) { destColours.AddRange(colours); } if (uvs != null) { destUvs.AddRange(uvs); } if (uv1s != null) { destUv1s.AddRange(uv1s); } } public int NumIndices() { return vertices.Count; } public int[] GenIndices() { int[] array = new int[vertices.Count]; for (int i = 0; i < array.Length; i++) { array[i] = i; } return array; } } public enum VertexClassification { Front = 1, Back = 2, OnPlane = 4 } public class MeshCutter { private CuttableMesh inputMesh; private List outputFrontSubMeshes; private List outputBackSubMeshes; public void Cut(CuttableMesh input, Plane worldCutPlane) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) inputMesh = input; outputFrontSubMeshes = new List(); outputBackSubMeshes = new List(); Transform transform = inputMesh.GetTransform(); Plane cutPlane = default(Plane); if ((Object)(object)transform != (Object)null) { Vector3 val = transform.InverseTransformPoint(ClosestPointOnPlane(worldCutPlane, Vector3.zero)); Vector3 val2 = transform.InverseTransformDirection(((Plane)(ref worldCutPlane)).normal); ((Plane)(ref cutPlane))..ctor(val2, val); } else { cutPlane = worldCutPlane; } foreach (CuttableSubMesh subMesh in input.GetSubMeshes()) { Cut(subMesh, cutPlane); } } private static Vector3 ClosestPointOnPlane(Plane plane, Vector3 point) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) float distanceToPoint = ((Plane)(ref plane)).GetDistanceToPoint(point); if (((Plane)(ref plane)).GetSide(point)) { return point - ((Plane)(ref plane)).normal * distanceToPoint; } return point + ((Plane)(ref plane)).normal * distanceToPoint; } public CuttableMesh GetFrontOutput() { return new CuttableMesh(inputMesh, outputFrontSubMeshes); } public CuttableMesh GetBackOutput() { return new CuttableMesh(inputMesh, outputBackSubMeshes); } private void Cut(CuttableSubMesh inputSubMesh, Plane cutPlane) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) bool hasNormals = inputSubMesh.HasNormals(); bool hasColours = inputSubMesh.HasColours(); bool hasUvs = inputSubMesh.HasUvs(); bool hasUv = inputSubMesh.HasUv1(); CuttableSubMesh cuttableSubMesh = new CuttableSubMesh(hasNormals, hasColours, hasUvs, hasUv); CuttableSubMesh cuttableSubMesh2 = new CuttableSubMesh(hasNormals, hasColours, hasUvs, hasUv); for (int i = 0; i < inputSubMesh.NumVertices(); i += 3) { int num = i; int num2 = i + 1; int num3 = i + 2; Vector3 vertex = inputSubMesh.GetVertex(num); Vector3 vertex2 = inputSubMesh.GetVertex(num2); Vector3 vertex3 = inputSubMesh.GetVertex(num3); VertexClassification vertexClassification = Classify(vertex, cutPlane); VertexClassification vertexClassification2 = Classify(vertex2, cutPlane); VertexClassification vertexClassification3 = Classify(vertex3, cutPlane); int numFront = 0; int numBehind = 0; CountSides(vertexClassification, ref numFront, ref numBehind); CountSides(vertexClassification2, ref numFront, ref numBehind); CountSides(vertexClassification3, ref numFront, ref numBehind); if (numFront > 0 && numBehind == 0) { KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh); } else if (numFront == 0 && numBehind > 0) { KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh2); } else if (numFront == 2 && numBehind == 1) { if (vertexClassification == VertexClassification.Back) { SplitA(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh); } else if (vertexClassification2 == VertexClassification.Back) { SplitA(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh); } else { SplitA(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh); } } else if (numFront == 1 && numBehind == 2) { if (vertexClassification == VertexClassification.Front) { SplitA(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } else if (vertexClassification2 == VertexClassification.Front) { SplitA(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } else { SplitA(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } } else if (numFront == 1 && numBehind == 1) { if (vertexClassification == VertexClassification.OnPlane) { if (vertexClassification3 == VertexClassification.Front) { SplitB(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } else { SplitBFlipped(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } continue; } switch (vertexClassification2) { case VertexClassification.OnPlane: if (vertexClassification == VertexClassification.Front) { SplitB(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } else { SplitBFlipped(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } break; case VertexClassification.Front: SplitB(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); break; default: SplitBFlipped(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); break; } } else if (numFront == 0 && numBehind == 0) { Vector3 val = vertex2 - vertex; Vector3 val2 = vertex3 - vertex; Vector3 val3 = Vector3.Cross(val, val2); if (Vector3.Dot(val3, ((Plane)(ref cutPlane)).normal) > 0f) { KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh2); } else { KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh); } } } outputFrontSubMeshes.Add(cuttableSubMesh); outputBackSubMeshes.Add(cuttableSubMesh2); } private VertexClassification Classify(Vector3 vertex, Plane cutPlane) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(vertex.x, vertex.y, vertex.z); float distanceToPoint = ((Plane)(ref cutPlane)).GetDistanceToPoint(val); double num = 9.999999747378752E-06; if ((double)distanceToPoint > 0.0 - num && (double)distanceToPoint < num) { return VertexClassification.OnPlane; } if (distanceToPoint > 0f) { return VertexClassification.Front; } return VertexClassification.Back; } private void CountSides(VertexClassification c, ref int numFront, ref int numBehind) { switch (c) { case VertexClassification.Front: numFront++; break; case VertexClassification.Back: numBehind++; break; } } private void KeepTriangle(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, CuttableSubMesh destSubMesh) { destSubMesh.CopyVertex(i0, inputSubMesh); destSubMesh.CopyVertex(i1, inputSubMesh); destSubMesh.CopyVertex(i2, inputSubMesh); } private void SplitA(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Vector3 vertex = inputSubMesh.GetVertex(i0); Vector3 vertex2 = inputSubMesh.GetVertex(i1); Vector3 vertex3 = inputSubMesh.GetVertex(i2); CalcIntersection(vertex, vertex2, cutPlane, out var weight); CalcIntersection(vertex3, vertex, cutPlane, out var weight2); frontSubMesh.CopyVertex(i0, inputSubMesh); frontSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); frontSubMesh.AddInterpolatedVertex(i2, i0, weight2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); backSubMesh.CopyVertex(i1, inputSubMesh); backSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i2, i0, weight2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); } private void SplitB(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Vector3 vertex = inputSubMesh.GetVertex(i0); Vector3 vertex2 = inputSubMesh.GetVertex(i2); CalcIntersection(vertex2, vertex, cutPlane, out var weight); frontSubMesh.CopyVertex(i0, inputSubMesh); frontSubMesh.CopyVertex(i1, inputSubMesh); frontSubMesh.AddInterpolatedVertex(i2, i0, weight, inputSubMesh); backSubMesh.CopyVertex(i1, inputSubMesh); backSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i2, i0, weight, inputSubMesh); } private void SplitBFlipped(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Vector3 vertex = inputSubMesh.GetVertex(i0); Vector3 vertex2 = inputSubMesh.GetVertex(i1); CalcIntersection(vertex, vertex2, cutPlane, out var weight); frontSubMesh.CopyVertex(i0, inputSubMesh); frontSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); frontSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.CopyVertex(i1, inputSubMesh); backSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); } private Vector3 CalcIntersection(Vector3 v0, Vector3 v1, Plane plane, out float weight) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) Vector3 val = v1 - v0; float magnitude = ((Vector3)(ref val)).magnitude; Ray val2 = default(Ray); ((Ray)(ref val2))..ctor(v0, val / magnitude); float num = default(float); ((Plane)(ref plane)).Raycast(val2, ref num); Vector3 result = ((Ray)(ref val2)).origin + ((Ray)(ref val2)).direction * num; weight = num / magnitude; return result; } } namespace Technie.PhysicsCreator { public enum HullType { Box, ConvexHull, Sphere, Face, FaceAsBox, Auto, Capsule } public enum AutoHullPreset { Low, Medium, High, Placebo, Custom } public enum CapsuleAxis { X, Y, Z } public struct BoxDef { public Bounds collisionBox; public Vector3 boxPosition; public Quaternion boxRotation; } public struct CapsuleDef { public Vector3 capsuleCenter; public CapsuleAxis capsuleDirection; public float capsuleRadius; public float capsuleHeight; public Vector3 capsulePosition; public Quaternion capsuleRotation; } [Serializable] public class Hull { public string name = ""; public bool isVisible = true; public HullType type = HullType.ConvexHull; public Color colour = Color.white; public PhysicMaterial material; public bool enableInflation = false; public float inflationAmount = 0.01f; public BoxFitMethod boxFitMethod = BoxFitMethod.MinimumVolume; public bool isTrigger = false; public bool isChildCollider = false; public List selectedFaces = new List(); public Mesh collisionMesh; public BoxDef collisionBox; public Sphere collisionSphere; public Mesh faceCollisionMesh; public Vector3 faceBoxCenter; public Vector3 faceBoxSize; public Quaternion faceAsBoxRotation; public CapsuleDef collisionCapsule; public Mesh[] autoMeshes = (Mesh[])(object)new Mesh[0]; public bool hasColliderError; public int numColliderFaces; public bool noInputError; public void Destroy() { } public bool ContainsAutoMesh(Mesh m) { if (autoMeshes != null) { Mesh[] array = autoMeshes; foreach (Mesh val in array) { if ((Object)(object)val == (Object)(object)m) { return true; } } } return false; } } public class PaintingData : ScriptableObject { public readonly Color[] hullColours = (Color[])(object)new Color[13] { new Color(0f, 1f, 1f, 0.7f), new Color(1f, 0f, 1f, 0.7f), new Color(1f, 1f, 0f, 0.7f), new Color(1f, 0f, 0f, 0.7f), new Color(0f, 1f, 0f, 0.7f), new Color(0f, 0f, 1f, 0.7f), new Color(1f, 1f, 1f, 0.7f), new Color(1f, 0.5f, 0f, 0.7f), new Color(1f, 0f, 0.5f, 0.7f), new Color(0.5f, 1f, 0f, 0.7f), new Color(0f, 1f, 0.5f, 0.7f), new Color(0.5f, 0f, 1f, 0.7f), new Color(0f, 0.5f, 1f, 0.7f) }; public HullData hullData; public Mesh sourceMesh; public int activeHull = -1; public float faceThickness = 0.1f; public List hulls = new List(); public AutoHullPreset autoHullPreset = AutoHullPreset.Medium; public VhacdParameters vhacdParams = new VhacdParameters(); public bool hasLastVhacdTimings = false; public AutoHullPreset lastVhacdPreset = AutoHullPreset.Medium; public float lastVhacdDurationSecs = 0f; public int TotalOutputColliders { get { int num = 0; foreach (Hull hull in hulls) { num = ((hull.type != HullType.Auto) ? (num + 1) : (num + ((hull.autoMeshes != null) ? hull.autoMeshes.Length : 0))); } return num; } } public void AddHull(HullType type, PhysicMaterial material, bool isChild, bool isTrigger) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) hulls.Add(new Hull()); hulls[hulls.Count - 1].name = "Hull " + hulls.Count; activeHull = hulls.Count - 1; hulls[hulls.Count - 1].colour = hullColours[activeHull % hullColours.Length]; hulls[hulls.Count - 1].type = type; hulls[hulls.Count - 1].material = material; hulls[hulls.Count - 1].isTrigger = isTrigger; hulls[hulls.Count - 1].isChildCollider = isChild; } public void RemoveHull(int index) { if (index >= 0 && index < hulls.Count) { hulls[index].Destroy(); hulls.RemoveAt(index); } } public void RemoveAllHulls() { for (int i = 0; i < hulls.Count; i++) { hulls[i].Destroy(); } hulls.Clear(); } public bool HasActiveHull() { return activeHull >= 0 && activeHull < hulls.Count; } public Hull GetActiveHull() { if (activeHull < 0 || activeHull >= hulls.Count) { return null; } return hulls[activeHull]; } public void GenerateCollisionMesh(Hull hull, Vector3[] meshVertices, int[] meshIndices, Mesh[] autoHulls) { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Expected O, but got Unknown //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Expected O, but got Unknown //IL_077d: Unknown result type (might be due to invalid IL or missing references) //IL_0787: Expected O, but got Unknown //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05d1: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_05e0: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_073b: Unknown result type (might be due to invalid IL or missing references) //IL_073d: Unknown result type (might be due to invalid IL or missing references) //IL_0743: Unknown result type (might be due to invalid IL or missing references) //IL_0745: Unknown result type (might be due to invalid IL or missing references) //IL_074b: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_04fa: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0546: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_08ee: Unknown result type (might be due to invalid IL or missing references) //IL_08f8: Expected O, but got Unknown hull.hasColliderError = false; hull.noInputError = false; if (hull.selectedFaces.Count == 0) { hull.noInputError = true; } if (hull.type == HullType.Box) { if (hull.selectedFaces.Count <= 0) { return; } if (hull.isChildCollider) { if (hull.boxFitMethod == BoxFitMethod.MinimumVolume) { RotatedBoxFitter rotatedBoxFitter = new RotatedBoxFitter(); hull.collisionBox = rotatedBoxFitter.Fit(hull, meshVertices, meshIndices); } else if (hull.boxFitMethod == BoxFitMethod.AlignFaces) { FaceAlignmentBoxFitter faceAlignmentBoxFitter = new FaceAlignmentBoxFitter(); faceAlignmentBoxFitter.Fit(hull, meshVertices, meshIndices); } else if (hull.boxFitMethod == BoxFitMethod.AxisAligned) { AxisAlignedBoxFitter axisAlignedBoxFitter = new AxisAlignedBoxFitter(); axisAlignedBoxFitter.Fit(hull, meshVertices, meshIndices); } return; } Vector3 val = meshVertices[meshIndices[hull.selectedFaces[0] * 3]]; Vector3 min = val; Vector3 max = val; for (int i = 0; i < hull.selectedFaces.Count; i++) { int num = hull.selectedFaces[i]; Vector3 point = meshVertices[meshIndices[num * 3]]; Vector3 point2 = meshVertices[meshIndices[num * 3 + 1]]; Vector3 point3 = meshVertices[meshIndices[num * 3 + 2]]; Inflate(point, ref min, ref max); Inflate(point2, ref min, ref max); Inflate(point3, ref min, ref max); } ((Bounds)(ref hull.collisionBox.collisionBox)).center = (min + max) * 0.5f; ((Bounds)(ref hull.collisionBox.collisionBox)).size = max - min; hull.collisionBox.boxRotation = Quaternion.identity; } else if (hull.type == HullType.Capsule) { if (hull.isChildCollider) { RotatedCapsuleFitter rotatedCapsuleFitter = new RotatedCapsuleFitter(); hull.collisionCapsule = rotatedCapsuleFitter.Fit(hull, meshVertices, meshIndices); } else { AlignedCapsuleFitter alignedCapsuleFitter = new AlignedCapsuleFitter(); hull.collisionCapsule = alignedCapsuleFitter.Fit(hull, meshVertices, meshIndices); } } else if (hull.type == HullType.Sphere) { if (hull.collisionSphere == null) { hull.collisionSphere = new Sphere(); } if (CalculateBoundingSphere(hull, meshVertices, meshIndices, out var sphereCenter, out var sphereRadius)) { hull.collisionSphere.center = sphereCenter; hull.collisionSphere.radius = sphereRadius; } else { hull.collisionSphere.center = Vector3.zero; hull.collisionSphere.radius = 0f; } } else if (hull.type == HullType.ConvexHull) { if ((Object)(object)hull.collisionMesh == (Object)null) { hull.collisionMesh = new Mesh(); } ((Object)hull.collisionMesh).name = hull.name; hull.collisionMesh.triangles = new int[0]; hull.collisionMesh.vertices = (Vector3[])(object)new Vector3[0]; GenerateConvexHull(hull, meshVertices, meshIndices, hull.collisionMesh); } else if (hull.type == HullType.Face) { if ((Object)(object)hull.faceCollisionMesh == (Object)null) { hull.faceCollisionMesh = new Mesh(); } ((Object)hull.faceCollisionMesh).name = hull.name; hull.faceCollisionMesh.triangles = new int[0]; hull.faceCollisionMesh.vertices = (Vector3[])(object)new Vector3[0]; GenerateFace(hull, meshVertices, meshIndices, faceThickness); } else if (hull.type == HullType.FaceAsBox) { if (hull.selectedFaces.Count <= 0) { return; } if (hull.isChildCollider) { Vector3[] vertices = ExtractUniqueVertices(hull, meshVertices, meshIndices); Vector3 val2 = CalcPrimaryAxis(hull, meshVertices, meshIndices, !hull.isChildCollider); Vector3 val3 = ((!(Vector3.Dot(val2, Vector3.up) > 0.8f)) ? Vector3.up : Vector3.right); Vector3 val4 = Vector3.Cross(val2, val3); Vector3 primaryUp = Vector3.Cross(val2, val4); float num2 = 0f; float num3 = float.MaxValue; Vector3 val5 = Vector3.zero; Vector3 val6 = Vector3.zero; Quaternion faceAsBoxRotation = Quaternion.identity; float num4 = 5f; float num5 = 0.05f; for (float num6 = 0f; num6 <= 360f; num6 += num4) { Vector3 min2; Vector3 max2; Quaternion outBasis; float num7 = CalcRequiredArea(num6, val2, primaryUp, vertices, out min2, out max2, out outBasis); if (num7 < num3) { num2 = num6; num3 = num7; val5 = min2; val6 = max2; faceAsBoxRotation = outBasis; } } float num8 = num2 - num4; float num9 = num2 + num4; for (float num10 = num8; num10 <= num9; num10 += num5) { Vector3 min3; Vector3 max3; Quaternion outBasis2; float num11 = CalcRequiredArea(num10, val2, primaryUp, vertices, out min3, out max3, out outBasis2); if (num11 < num3) { num2 = num10; num3 = num11; val5 = min3; val6 = max3; faceAsBoxRotation = outBasis2; } } Vector3 faceBoxCenter = (val5 + val6) / 2f; Vector3 faceBoxSize = val6 - val5; float num12 = faceBoxSize.z - faceThickness; faceBoxCenter.z += num12 * 0.5f; faceBoxSize.z += num12; hull.faceBoxCenter = faceBoxCenter; hull.faceBoxSize = faceBoxSize; hull.faceAsBoxRotation = faceAsBoxRotation; } else { Vector3[] array = ExtractUniqueVertices(hull, meshVertices, meshIndices); Vector3 val7 = CalcPrimaryAxis(hull, meshVertices, meshIndices, !hull.isChildCollider); Vector3 val8 = array[0]; Vector3 min4 = val8; Vector3 max4 = val8; Vector3[] array2 = array; foreach (Vector3 point4 in array2) { Inflate(point4, ref min4, ref max4); } Vector3 faceBoxCenter2 = (min4 + max4) / 2f; Vector3 faceBoxSize2 = max4 - min4; if (Mathf.Abs(val7.x) > 0f) { float num13 = ((!(val7.x > 0f)) ? (-1f) : 1f); float num14 = faceBoxSize2.x - faceThickness; faceBoxCenter2.x += num14 * 0.5f * num13; faceBoxSize2.x += num14; } else if (Mathf.Abs(val7.y) > 0f) { float num15 = ((!(val7.y > 0f)) ? (-1f) : 1f); float num16 = faceBoxSize2.y - faceThickness; faceBoxCenter2.y += num16 * 0.5f * num15; faceBoxSize2.y += num16; } else { float num17 = ((!(val7.z > 0f)) ? (-1f) : 1f); float num18 = faceBoxSize2.z - faceThickness; faceBoxCenter2.z += num18 * 0.5f * num17; faceBoxSize2.z += num18; } hull.faceBoxCenter = faceBoxCenter2; hull.faceBoxSize = faceBoxSize2; hull.faceAsBoxRotation = Quaternion.identity; } } else { if (hull.type != HullType.Auto) { return; } if ((Object)(object)hull.collisionMesh == (Object)null) { hull.collisionMesh = new Mesh(); } ((Object)hull.collisionMesh).name = $"{hull.name} bounds"; hull.collisionMesh.triangles = new int[0]; hull.collisionMesh.vertices = (Vector3[])(object)new Vector3[0]; GenerateConvexHull(hull, meshVertices, meshIndices, hull.collisionMesh); List list = new List(); if (hull.selectedFaces.Count == sourceMesh.triangles.Length / 3) { list.AddRange(autoHulls); } else { foreach (Mesh inputMesh in autoHulls) { Mesh val9 = Clip(hull.collisionMesh, inputMesh); if ((Object)(object)val9 != (Object)null) { list.Add(val9); } } } for (int l = 0; l < list.Count; l++) { ((Object)list[l]).name = $"{hull.name}.{l + 1}"; } List list2 = new List(); if (hull.autoMeshes != null) { list2.AddRange(hull.autoMeshes); } while (list2.Count > list.Count) { list2.RemoveAt(list2.Count - 1); } while (list2.Count < list.Count) { list2.Add(new Mesh()); } for (int m = 0; m < list.Count; m++) { list2[m].Clear(); ((Object)list2[m]).name = ((Object)list[m]).name; list2[m].vertices = list[m].vertices; list2[m].triangles = list[m].triangles; } hull.autoMeshes = list2.ToArray(); } } private Mesh Clip(Mesh boundingMesh, Mesh inputMesh) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)boundingMesh == (Object)null || boundingMesh.triangles.Length == 0) { return null; } if ((Object)(object)inputMesh == (Object)null || inputMesh.triangles.Length == 0) { return null; } CuttableMesh cuttableMesh = new CuttableMesh(inputMesh); MeshCutter meshCutter = new MeshCutter(); Plane[] array = ConvertToPlanes(boundingMesh, show: false); foreach (Plane worldCutPlane in array) { meshCutter.Cut(cuttableMesh, worldCutPlane); Mesh inputMesh2 = meshCutter.GetBackOutput().CreateMesh(); Mesh inputMesh3 = QHullUtil.FindConvexHull("", inputMesh2, showErrorInLog: false); cuttableMesh = new CuttableMesh(inputMesh3); } Mesh val = cuttableMesh.CreateMesh(); if (val.triangles.Length > 0) { return val; } return null; } private Plane[] ConvertToPlanes(Mesh convexMesh, bool show) { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0051: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Vector3[] vertices = convexMesh.vertices; int[] triangles = convexMesh.triangles; Plane val7 = default(Plane); for (int i = 0; i < triangles.Length; i += 3) { Vector3 val = vertices[triangles[i]]; Vector3 val2 = vertices[triangles[i + 1]]; Vector3 val3 = vertices[triangles[i + 2]]; Vector3 val4 = val2 - val; Vector3 normalized = ((Vector3)(ref val4)).normalized; Vector3 val5 = val3 - val; Vector3 normalized2 = ((Vector3)(ref val5)).normalized; Vector3 val6 = Vector3.Cross(normalized, normalized2); Vector3 normalized3 = ((Vector3)(ref val6)).normalized; if (!(((Vector3)(ref normalized3)).magnitude > 0.01f)) { continue; } ((Plane)(ref val7))..ctor(normalized3, val); if (!Contains(val7, list)) { list.Add(val7); if (show) { GameObject val8 = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val8).name = $"{i} : {triangles[i]} / {triangles[i + 1]} / {triangles[i + 2]}"; val8.transform.SetPositionAndRotation(val, Quaternion.LookRotation(normalized3)); } } } return list.ToArray(); } private static bool Contains(Plane toTest, List planes) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) foreach (Plane plane in planes) { Plane current = plane; if (Mathf.Abs(((Plane)(ref toTest)).distance - ((Plane)(ref current)).distance) < 0.01f && Vector3.Angle(((Plane)(ref toTest)).normal, ((Plane)(ref current)).normal) < 0.01f) { return true; } } return false; } private Vector3 CalcPrimaryAxis(Hull hull, Vector3[] meshVertices, int[] meshIndices, bool snapToAxies) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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_003d: 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_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_0058: 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_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_0065: 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_006c: 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_0070: 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_0079: 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_0080: 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_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_008b: 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_008e: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) int num = 0; Vector3 val = Vector3.zero; for (int i = 0; i < hull.selectedFaces.Count; i++) { int num2 = hull.selectedFaces[i]; Vector3 val2 = meshVertices[meshIndices[num2 * 3]]; Vector3 val3 = meshVertices[meshIndices[num2 * 3 + 1]]; Vector3 val4 = meshVertices[meshIndices[num2 * 3 + 2]]; Vector3 val5 = val3 - val2; Vector3 normalized = ((Vector3)(ref val5)).normalized; Vector3 val6 = val4 - val2; Vector3 normalized2 = ((Vector3)(ref val6)).normalized; Vector3 val7 = Vector3.Cross(normalized, normalized2); val += val7; num++; } Vector3 val8 = val / (float)num; if (((Vector3)(ref val8)).magnitude < 0.0001f) { return Vector3.up; } if (snapToAxies) { float num3 = Mathf.Abs(val8.x); float num4 = Mathf.Abs(val8.y); float num5 = Mathf.Abs(val8.z); if (num3 > num4 && num3 > num5) { return new Vector3((!((double)val8.x > 0.0)) ? (-1f) : 1f, 0f, 0f); } if (num4 > num5) { return new Vector3(0f, (!((double)val8.y > 0.0)) ? (-1f) : 1f, 0f); } return new Vector3(0f, 0f, (!((double)val8.z > 0.0)) ? (-1f) : 1f); } return ((Vector3)(ref val8)).normalized; } private Vector3[] ExtractUniqueVertices(Hull hull, Vector3[] meshVertices, int[] meshIndices) { //IL_0027: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0056: 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_0062: 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_0076: 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) List list = new List(); for (int i = 0; i < hull.selectedFaces.Count; i++) { int num = hull.selectedFaces[i]; Vector3 val = meshVertices[meshIndices[num * 3]]; Vector3 val2 = meshVertices[meshIndices[num * 3 + 1]]; Vector3 val3 = meshVertices[meshIndices[num * 3 + 2]]; if (!Contains(list, val)) { list.Add(val); } if (!Contains(list, val2)) { list.Add(val2); } if (!Contains(list, val3)) { list.Add(val3); } } return list.ToArray(); } private static bool Contains(List list, Vector3 p) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) foreach (Vector3 item in list) { float num = Vector3.Distance(item, p); if (num < 0.0001f) { return true; } } return false; } private static float CalcRequiredArea(float angleDeg, Vector3 primaryAxis, Vector3 primaryUp, Vector3[] vertices, out Vector3 min, out Vector3 max, out Quaternion outBasis) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) if (vertices.Length == 0) { min = Vector3.zero; max = Vector3.zero; outBasis = Quaternion.identity; return 0f; } Quaternion val = Quaternion.AngleAxis(angleDeg, primaryAxis); Vector3 val2 = val * primaryUp; Quaternion val3 = Quaternion.LookRotation(primaryAxis, val2); Quaternion val4 = Quaternion.Inverse(val3); max = (min = val4 * vertices[0]); foreach (Vector3 val5 in vertices) { Vector3 point = val4 * val5; Inflate(point, ref min, ref max); } outBasis = val3; Vector3 val6 = max - min; return val6.x * val6.y; } private bool CalculateBoundingSphere(Hull hull, Vector3[] meshVertices, int[] meshIndices, out Vector3 sphereCenter, out float sphereRadius) { //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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_008b: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if (hull.selectedFaces.Count == 0) { sphereCenter = Vector3.zero; sphereRadius = 0f; return false; } List list = new List(); for (int i = 0; i < hull.selectedFaces.Count; i++) { int num = hull.selectedFaces[i]; Vector3 item = meshVertices[meshIndices[num * 3]]; Vector3 item2 = meshVertices[meshIndices[num * 3 + 1]]; Vector3 item3 = meshVertices[meshIndices[num * 3 + 2]]; list.Add(item); list.Add(item2); list.Add(item3); } Sphere sphere = SphereUtils.MinSphere(list); sphereCenter = sphere.center; sphereRadius = sphere.radius; return true; } private void GenerateConvexHull(Hull hull, Vector3[] meshVertices, int[] meshIndices, Mesh destMesh) { QHullUtil.FindConvexHull(hull.name, hull.selectedFaces.ToArray(), meshVertices, meshIndices, out var hullVertices, out var hullIndices, showErrorInLog: true); hull.numColliderFaces = hullIndices.Length / 3; Debug.Log((object)("Calculated collider for '" + hull.name + "' has " + hull.numColliderFaces + " faces")); if (hull.numColliderFaces >= 256) { hull.hasColliderError = true; hull.enableInflation = true; } hull.collisionMesh.vertices = hullVertices; hull.collisionMesh.triangles = hullIndices; hull.collisionMesh.RecalculateBounds(); hull.faceCollisionMesh = null; } private void GenerateFace(Hull hull, Vector3[] meshVertices, int[] meshIndices, float thickness) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_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_0067: 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_006b: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00ab: 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_00bc: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) int count = hull.selectedFaces.Count; Vector3[] array = (Vector3[])(object)new Vector3[count * 3 * 2]; for (int i = 0; i < hull.selectedFaces.Count; i++) { int num = hull.selectedFaces[i]; Vector3 val = meshVertices[meshIndices[num * 3]]; Vector3 val2 = meshVertices[meshIndices[num * 3 + 1]]; Vector3 val3 = meshVertices[meshIndices[num * 3 + 2]]; Vector3 val4 = val2 - val; Vector3 normalized = ((Vector3)(ref val4)).normalized; Vector3 val5 = val3 - val; Vector3 normalized2 = ((Vector3)(ref val5)).normalized; Vector3 val6 = Vector3.Cross(normalized2, normalized); int num2 = i * 3 * 2; array[num2] = val; array[num2 + 1] = val2; array[num2 + 2] = val3; ref Vector3 reference = ref array[num2 + 3]; reference = val + val6 * faceThickness; ref Vector3 reference2 = ref array[num2 + 4]; reference2 = val2 + val6 * faceThickness; ref Vector3 reference3 = ref array[num2 + 5]; reference3 = val3 + val6 * faceThickness; } int[] array2 = new int[count * 3 * 2]; for (int j = 0; j < array2.Length; j++) { array2[j] = j; } hull.faceCollisionMesh.vertices = array; hull.faceCollisionMesh.triangles = array2; hull.faceCollisionMesh.RecalculateBounds(); hull.collisionMesh = null; } public bool ContainsMesh(Mesh m) { foreach (Hull hull in hulls) { if ((Object)(object)hull.collisionMesh == (Object)(object)m) { return true; } if ((Object)(object)hull.faceCollisionMesh == (Object)(object)m) { return true; } if (hull.autoMeshes == null) { continue; } Mesh[] autoMeshes = hull.autoMeshes; foreach (Mesh val in autoMeshes) { if ((Object)(object)val == (Object)(object)m) { return true; } } } return false; } private static void Inflate(Vector3 point, ref Vector3 min, ref Vector3 max) { min.x = Mathf.Min(min.x, point.x); min.y = Mathf.Min(min.y, point.y); min.z = Mathf.Min(min.z, point.z); max.x = Mathf.Max(max.x, point.x); max.y = Mathf.Max(max.y, point.y); max.z = Mathf.Max(max.z, point.z); } public bool HasAutoHulls() { foreach (Hull hull in hulls) { if (hull.type == HullType.Auto) { return true; } } return false; } } [CreateAssetMenu] public class PhysicsCreatorHullFolder : ScriptableObject { } public class PhysicsCreatorInstallRoot : ScriptableObject { } } namespace Technie.PhysicsCreator.QHull { public class Face { public HalfEdge he0; private Vector3d normal; public double area; private Point3d centroid; public double planeOffset; public int index; public int numVerts; public Face next; public const int VISIBLE = 1; public const int NON_CONVEX = 2; public const int DELETED = 3; public int mark = 1; public Vertex outside; public Face() { normal = new Vector3d(); centroid = new Point3d(); mark = 1; } public void computeCentroid(Point3d centroid) { centroid.setZero(); HalfEdge halfEdge = he0; do { centroid.add(halfEdge.head().pnt); halfEdge = halfEdge.next; } while (halfEdge != he0); centroid.scale(1.0 / (double)numVerts); } public void computeNormal(Vector3d normal, double minArea) { computeNormal(normal); if (!(area < minArea)) { return; } HalfEdge halfEdge = null; double num = 0.0; HalfEdge halfEdge2 = he0; do { double num2 = halfEdge2.lengthSquared(); if (num2 > num) { halfEdge = halfEdge2; num = num2; } halfEdge2 = halfEdge2.next; } while (halfEdge2 != he0); Point3d pnt = halfEdge.head().pnt; Point3d pnt2 = halfEdge.tail().pnt; double num3 = Math.Sqrt(num); double num4 = (pnt.x - pnt2.x) / num3; double num5 = (pnt.y - pnt2.y) / num3; double num6 = (pnt.z - pnt2.z) / num3; double num7 = normal.x * num4 + normal.y * num5 + normal.z * num6; normal.x -= num7 * num4; normal.y -= num7 * num5; normal.z -= num7 * num6; normal.normalize(); } public void computeNormal(Vector3d normal) { HalfEdge halfEdge = he0.next; HalfEdge halfEdge2 = halfEdge.next; Point3d pnt = he0.head().pnt; Point3d pnt2 = halfEdge.head().pnt; double num = pnt2.x - pnt.x; double num2 = pnt2.y - pnt.y; double num3 = pnt2.z - pnt.z; normal.setZero(); numVerts = 2; while (halfEdge2 != he0) { double num4 = num; double num5 = num2; double num6 = num3; pnt2 = halfEdge2.head().pnt; num = pnt2.x - pnt.x; num2 = pnt2.y - pnt.y; num3 = pnt2.z - pnt.z; normal.x += num5 * num3 - num6 * num2; normal.y += num6 * num - num4 * num3; normal.z += num4 * num2 - num5 * num; halfEdge = halfEdge2; halfEdge2 = halfEdge2.next; numVerts++; } area = normal.norm(); normal.scale(1.0 / area); } private void computeNormalAndCentroid() { computeNormal(normal); computeCentroid(centroid); planeOffset = normal.dot(centroid); int num = 0; HalfEdge halfEdge = he0; do { num++; halfEdge = halfEdge.next; } while (halfEdge != he0); if (num != numVerts) { throw new InternalErrorException("face " + getVertexString() + " numVerts=" + numVerts + " should be " + num); } } private void computeNormalAndCentroid(double minArea) { computeNormal(normal, minArea); computeCentroid(centroid); planeOffset = normal.dot(centroid); } public static Face createTriangle(Vertex v0, Vertex v1, Vertex v2) { return createTriangle(v0, v1, v2, 0.0); } public static Face createTriangle(Vertex v0, Vertex v1, Vertex v2, double minArea) { Face face = new Face(); HalfEdge halfEdge = new HalfEdge(v0, face); HalfEdge halfEdge2 = new HalfEdge(v1, face); HalfEdge halfEdge3 = (halfEdge.prev = new HalfEdge(v2, face)); halfEdge.next = halfEdge2; halfEdge2.prev = halfEdge; halfEdge2.next = halfEdge3; halfEdge3.prev = halfEdge2; halfEdge3.next = halfEdge; face.he0 = halfEdge; face.computeNormalAndCentroid(minArea); return face; } public static Face create(Vertex[] vtxArray, int[] indices) { Face face = new Face(); HalfEdge halfEdge = null; for (int i = 0; i < indices.Length; i++) { HalfEdge halfEdge2 = new HalfEdge(vtxArray[indices[i]], face); if (halfEdge != null) { halfEdge2.setPrev(halfEdge); halfEdge.setNext(halfEdge2); } else { face.he0 = halfEdge2; } halfEdge = halfEdge2; } face.he0.setPrev(halfEdge); halfEdge.setNext(face.he0); face.computeNormalAndCentroid(); return face; } public HalfEdge getEdge(int i) { HalfEdge prev = he0; while (i > 0) { prev = prev.next; i--; } while (i < 0) { prev = prev.prev; i++; } return prev; } public HalfEdge getFirstEdge() { return he0; } public HalfEdge findEdge(Vertex vt, Vertex vh) { HalfEdge halfEdge = he0; do { if (halfEdge.head() == vh && halfEdge.tail() == vt) { return halfEdge; } halfEdge = halfEdge.next; } while (halfEdge != he0); return null; } public double distanceToPlane(Point3d p) { return normal.x * p.x + normal.y * p.y + normal.z * p.z - planeOffset; } public Vector3d getNormal() { return normal; } public Point3d getCentroid() { return centroid; } public int numVertices() { return numVerts; } public string getVertexString() { string text = null; HalfEdge halfEdge = he0; do { text = ((text != null) ? (text + " " + halfEdge.head().index) : ("" + halfEdge.head().index)); halfEdge = halfEdge.next; } while (halfEdge != he0); return text; } public void getVertexIndices(int[] idxs) { HalfEdge halfEdge = he0; int num = 0; do { idxs[num++] = halfEdge.head().index; halfEdge = halfEdge.next; } while (halfEdge != he0); } private Face connectHalfEdges(HalfEdge hedgePrev, HalfEdge hedge) { Face result = null; if (hedgePrev.oppositeFace() == hedge.oppositeFace()) { Face face = hedge.oppositeFace(); if (hedgePrev == he0) { he0 = hedge; } HalfEdge opposite; if (face.numVertices() == 3) { opposite = hedge.getOpposite().prev.getOpposite(); face.mark = 3; result = face; } else { opposite = hedge.getOpposite().next; if (face.he0 == opposite.prev) { face.he0 = opposite; } opposite.prev = opposite.prev.prev; opposite.prev.next = opposite; } hedge.prev = hedgePrev.prev; hedge.prev.next = hedge; hedge.opposite = opposite; opposite.opposite = hedge; face.computeNormalAndCentroid(); } else { hedgePrev.next = hedge; hedge.prev = hedgePrev; } return result; } public void checkConsistency() { HalfEdge halfEdge = he0; double num = 0.0; int num2 = 0; if (numVerts < 3) { throw new InternalErrorException("degenerate face: " + getVertexString()); } do { HalfEdge opposite = halfEdge.getOpposite(); if (opposite == null) { throw new InternalErrorException("face " + getVertexString() + ": unreflected half edge " + halfEdge.getVertexString()); } if (opposite.getOpposite() != halfEdge) { throw new InternalErrorException("face " + getVertexString() + ": opposite half edge " + opposite.getVertexString() + " has opposite " + opposite.getOpposite().getVertexString()); } if (opposite.head() != halfEdge.tail() || halfEdge.head() != opposite.tail()) { throw new InternalErrorException("face " + getVertexString() + ": half edge " + halfEdge.getVertexString() + " reflected by " + opposite.getVertexString()); } Face face = opposite.face; if (face == null) { throw new InternalErrorException("face " + getVertexString() + ": no face on half edge " + opposite.getVertexString()); } if (face.mark == 3) { throw new InternalErrorException("face " + getVertexString() + ": opposite face " + face.getVertexString() + " not on hull"); } double num3 = Math.Abs(distanceToPlane(halfEdge.head().pnt)); if (num3 > num) { num = num3; } num2++; halfEdge = halfEdge.next; } while (halfEdge != he0); if (num2 != numVerts) { throw new InternalErrorException("face " + getVertexString() + " numVerts=" + numVerts + " should be " + num2); } } public int mergeAdjacentFace(HalfEdge hedgeAdj, Face[] discarded) { Face face = hedgeAdj.oppositeFace(); int result = 0; discarded[result++] = face; face.mark = 3; HalfEdge opposite = hedgeAdj.getOpposite(); HalfEdge prev = hedgeAdj.prev; HalfEdge halfEdge = hedgeAdj.next; HalfEdge prev2 = opposite.prev; HalfEdge halfEdge2 = opposite.next; while (prev.oppositeFace() == face) { prev = prev.prev; halfEdge2 = halfEdge2.next; } while (halfEdge.oppositeFace() == face) { prev2 = prev2.prev; halfEdge = halfEdge.next; } for (HalfEdge halfEdge3 = halfEdge2; halfEdge3 != prev2.next; halfEdge3 = halfEdge3.next) { halfEdge3.face = this; } if (hedgeAdj == he0) { he0 = halfEdge; } Face face2 = connectHalfEdges(prev2, halfEdge); if (face2 != null) { discarded[result++] = face2; } face2 = connectHalfEdges(prev, halfEdge2); if (face2 != null) { discarded[result++] = face2; } computeNormalAndCentroid(); checkConsistency(); return result; } private double areaSquared(HalfEdge hedge0, HalfEdge hedge1) { Point3d pnt = hedge0.tail().pnt; Point3d pnt2 = hedge0.head().pnt; Point3d pnt3 = hedge1.head().pnt; double num = pnt2.x - pnt.x; double num2 = pnt2.y - pnt.y; double num3 = pnt2.z - pnt.z; double num4 = pnt3.x - pnt.x; double num5 = pnt3.y - pnt.y; double num6 = pnt3.z - pnt.z; double num7 = num2 * num6 - num3 * num5; double num8 = num3 * num4 - num * num6; double num9 = num * num5 - num2 * num4; return num7 * num7 + num8 * num8 + num9 * num9; } public void triangulate(FaceList newFaces, double minArea) { if (numVertices() < 4) { return; } Vertex v = he0.head(); HalfEdge halfEdge = he0.next; HalfEdge opposite = halfEdge.opposite; Face face = null; for (halfEdge = halfEdge.next; halfEdge != he0.prev; halfEdge = halfEdge.next) { Face face2 = createTriangle(v, halfEdge.prev.head(), halfEdge.head(), minArea); face2.he0.next.setOpposite(opposite); face2.he0.prev.setOpposite(halfEdge.opposite); opposite = face2.he0; newFaces.add(face2); if (face == null) { face = face2; } } halfEdge = new HalfEdge(he0.prev.prev.head(), this); halfEdge.setOpposite(opposite); halfEdge.prev = he0; halfEdge.prev.next = halfEdge; halfEdge.next = he0.prev; halfEdge.next.prev = halfEdge; computeNormalAndCentroid(minArea); checkConsistency(); for (Face face3 = face; face3 != null; face3 = face3.next) { face3.checkConsistency(); } } } public class FaceList { private Face head; private Face tail; public void clear() { head = (tail = null); } public void add(Face vtx) { if (head == null) { head = vtx; } else { tail.next = vtx; } vtx.next = null; tail = vtx; } public Face first() { return head; } public bool isEmpty() { return head == null; } } public class HalfEdge { public Vertex vertex; public Face face; public HalfEdge next; public HalfEdge prev; public HalfEdge opposite; public HalfEdge(Vertex v, Face f) { vertex = v; face = f; } public HalfEdge() { } public void setNext(HalfEdge edge) { next = edge; } public HalfEdge getNext() { return next; } public void setPrev(HalfEdge edge) { prev = edge; } public HalfEdge getPrev() { return prev; } public Face getFace() { return face; } public HalfEdge getOpposite() { return opposite; } public void setOpposite(HalfEdge edge) { opposite = edge; edge.opposite = this; } public Vertex head() { return vertex; } public Vertex tail() { return (prev == null) ? null : prev.vertex; } public Face oppositeFace() { return (opposite == null) ? null : opposite.face; } public string getVertexString() { if (tail() != null) { return "" + tail().index + "-" + head().index; } return "?-" + head().index; } public double length() { if (tail() != null) { return head().pnt.distance(tail().pnt); } return -1.0; } public double lengthSquared() { if (tail() != null) { return head().pnt.distanceSquared(tail().pnt); } return -1.0; } } public class InternalErrorException : SystemException { public InternalErrorException(string msg) : base(msg) { } } public class Point3d : Vector3d { public Point3d() { } public Point3d(Vector3d v) { set(v); } public Point3d(double x, double y, double z) { set(x, y, z); } } } namespace Technie.PhysicsCreator { public class QHullUtil { public static Mesh FindConvexHull(string debugName, Mesh inputMesh, bool showErrorInLog) { //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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown Vector3[] vertices = inputMesh.vertices; int[] triangles = inputMesh.triangles; Point3d[] array = new Point3d[triangles.Length]; for (int i = 0; i < triangles.Length; i += 3) { Vector3 val = vertices[triangles[i]]; Vector3 val2 = vertices[triangles[i + 1]]; Vector3 val3 = vertices[triangles[i + 2]]; array[i] = new Point3d(val.x, val.y, val.z); array[i + 1] = new Point3d(val2.x, val2.y, val2.z); array[i + 2] = new Point3d(val3.x, val3.y, val3.z); } QuickHull3D quickHull3D = new QuickHull3D(); try { quickHull3D.build(array); } catch (Exception) { if (showErrorInLog) { Debug.LogError((object)("Could not generate convex hull for " + debugName)); } } Point3d[] vertices2 = quickHull3D.getVertices(); int[][] faces = quickHull3D.getFaces(); Vector3[] array2 = (Vector3[])(object)new Vector3[vertices2.Length]; for (int j = 0; j < array2.Length; j++) { ref Vector3 reference = ref array2[j]; reference = new Vector3((float)vertices2[j].x, (float)vertices2[j].y, (float)vertices2[j].z); } List list = new List(); for (int k = 0; k < faces.Length; k++) { int num = faces[k].Length; for (int l = 1; l < num - 1; l++) { list.Add(faces[k][0]); list.Add(faces[k][l]); list.Add(faces[k][l + 1]); } } int[] triangles2 = list.ToArray(); Mesh val4 = new Mesh(); val4.vertices = array2; val4.triangles = triangles2; return val4; } public static void FindConvexHull(string debugName, int[] selectedFaces, Vector3[] meshVertices, int[] meshIndices, out Vector3[] hullVertices, out int[] hullIndices, bool showErrorInLog) { //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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) if (selectedFaces.Length == 0) { hullVertices = (Vector3[])(object)new Vector3[0]; hullIndices = new int[0]; return; } int num = selectedFaces.Length; Point3d[] array = new Point3d[num * 3]; for (int i = 0; i < selectedFaces.Length; i++) { int num2 = selectedFaces[i]; Vector3 val = meshVertices[meshIndices[num2 * 3]]; Vector3 val2 = meshVertices[meshIndices[num2 * 3 + 1]]; Vector3 val3 = meshVertices[meshIndices[num2 * 3 + 2]]; array[i * 3] = new Point3d(val.x, val.y, val.z); array[i * 3 + 1] = new Point3d(val2.x, val2.y, val2.z); array[i * 3 + 2] = new Point3d(val3.x, val3.y, val3.z); } QuickHull3D quickHull3D = new QuickHull3D(); try { quickHull3D.build(array); } catch (Exception) { if (showErrorInLog) { Debug.LogError((object)("Could not generate convex hull for " + debugName)); } } Point3d[] vertices = quickHull3D.getVertices(); int[][] faces = quickHull3D.getFaces(); hullVertices = (Vector3[])(object)new Vector3[vertices.Length]; for (int j = 0; j < hullVertices.Length; j++) { ref Vector3 reference = ref hullVertices[j]; reference = new Vector3((float)vertices[j].x, (float)vertices[j].y, (float)vertices[j].z); } List list = new List(); for (int k = 0; k < faces.Length; k++) { int num3 = faces[k].Length; for (int l = 1; l < num3 - 1; l++) { list.Add(faces[k][0]); list.Add(faces[k][l]); list.Add(faces[k][l + 1]); } } hullIndices = list.ToArray(); } } } namespace Technie.PhysicsCreator.QHull { public class QuickHull3D { public const int CLOCKWISE = 1; public const int INDEXED_FROM_ONE = 2; public const int INDEXED_FROM_ZERO = 4; public const int POINT_RELATIVE = 8; public const double AUTOMATIC_TOLERANCE = -1.0; protected int findIndex = -1; protected double charLength; protected bool debug = false; protected Vertex[] pointBuffer = new Vertex[0]; protected int[] vertexPointIndices = new int[0]; private Face[] discardedFaces = new Face[3]; private Vertex[] maxVtxs = new Vertex[3]; private Vertex[] minVtxs = new Vertex[3]; protected List faces = new List(16); protected List horizon = new List(16); private FaceList newFaces = new FaceList(); private VertexList unclaimed = new VertexList(); private VertexList claimed = new VertexList(); protected int numVertices; protected int numFaces; protected int numPoints; protected double explicitTolerance = -1.0; protected double tolerance; private const double DOUBLE_PREC = 2.220446049250313E-16; private const int NONCONVEX_WRT_LARGER_FACE = 1; private const int NONCONVEX = 2; public QuickHull3D() { } public QuickHull3D(double[] coords) { build(coords, coords.Length / 3); } public QuickHull3D(Point3d[] points) { build(points, points.Length); } public bool getDebug() { return debug; } public void setDebug(bool enable) { debug = enable; } public double getDistanceTolerance() { return tolerance; } public void setExplicitDistanceTolerance(double tol) { explicitTolerance = tol; } public double getExplicitDistanceTolerance() { return explicitTolerance; } private void addPointToFace(Vertex vtx, Face face) { vtx.face = face; if (face.outside == null) { claimed.add(vtx); } else { claimed.insertBefore(vtx, face.outside); } face.outside = vtx; } private void removePointFromFace(Vertex vtx, Face face) { if (vtx == face.outside) { if (vtx.next != null && vtx.next.face == face) { face.outside = vtx.next; } else { face.outside = null; } } claimed.delete(vtx); } private Vertex removeAllPointsFromFace(Face face) { if (face.outside != null) { Vertex vertex = face.outside; while (vertex.next != null && vertex.next.face == face) { vertex = vertex.next; } claimed.delete(face.outside, vertex); vertex.next = null; return face.outside; } return null; } private HalfEdge findHalfEdge(Vertex tail, Vertex head) { foreach (Face face in faces) { HalfEdge halfEdge = face.findEdge(tail, head); if (halfEdge != null) { return halfEdge; } } return null; } protected void setHull(double[] coords, int nump, int[][] faceIndices, int numf) { initBuffers(nump); setPoints(coords, nump); computeMaxAndMin(); for (int i = 0; i < numf; i++) { Face face = Face.create(pointBuffer, faceIndices[i]); HalfEdge halfEdge = face.he0; do { HalfEdge halfEdge2 = findHalfEdge(halfEdge.head(), halfEdge.tail()); if (halfEdge2 != null) { halfEdge.setOpposite(halfEdge2); } halfEdge = halfEdge.next; } while (halfEdge != face.he0); faces.Add(face); } } public void build(double[] coords) { build(coords, coords.Length / 3); } public void build(double[] coords, int nump) { if (nump < 4) { throw new SystemException("Less than four input points specified"); } if (coords.Length / 3 < nump) { throw new SystemException("Coordinate array too small for specified number of points"); } initBuffers(nump); setPoints(coords, nump); buildHull(); } public void build(Point3d[] points) { build(points, points.Length); } public void build(Point3d[] points, int nump) { if (nump < 4) { throw new SystemException("Less than four input points specified"); } if (points.Length < nump) { throw new SystemException("Point array too small for specified number of points"); } initBuffers(nump); setPoints(points, nump); buildHull(); } public void triangulate() { double minArea = 1000.0 * charLength * 2.220446049250313E-16; newFaces.clear(); foreach (Face face2 in faces) { if (face2.mark == 1) { face2.triangulate(newFaces, minArea); } } for (Face face = newFaces.first(); face != null; face = face.next) { faces.Add(face); } } protected void initBuffers(int nump) { if (pointBuffer.Length < nump) { Vertex[] array = new Vertex[nump]; vertexPointIndices = new int[nump]; for (int i = 0; i < pointBuffer.Length; i++) { array[i] = pointBuffer[i]; } for (int j = pointBuffer.Length; j < nump; j++) { array[j] = new Vertex(); } pointBuffer = array; } faces.Clear(); claimed.clear(); numFaces = 0; numPoints = nump; } protected void setPoints(double[] coords, int nump) { for (int i = 0; i < nump; i++) { Vertex vertex = pointBuffer[i]; vertex.pnt.set(coords[i * 3], coords[i * 3 + 1], coords[i * 3 + 2]); vertex.index = i; } } protected void setPoints(Point3d[] pnts, int nump) { for (int i = 0; i < nump; i++) { Vertex vertex = pointBuffer[i]; vertex.pnt.set(pnts[i]); vertex.index = i; } } protected void computeMaxAndMin() { Vector3d vector3d = new Vector3d(); Vector3d vector3d2 = new Vector3d(); for (int i = 0; i < 3; i++) { maxVtxs[i] = (minVtxs[i] = pointBuffer[0]); } vector3d.set(pointBuffer[0].pnt); vector3d2.set(pointBuffer[0].pnt); for (int j = 1; j < numPoints; j++) { Point3d pnt = pointBuffer[j].pnt; if (pnt.x > vector3d.x) { vector3d.x = pnt.x; maxVtxs[0] = pointBuffer[j]; } else if (pnt.x < vector3d2.x) { vector3d2.x = pnt.x; minVtxs[0] = pointBuffer[j]; } if (pnt.y > vector3d.y) { vector3d.y = pnt.y; maxVtxs[1] = pointBuffer[j]; } else if (pnt.y < vector3d2.y) { vector3d2.y = pnt.y; minVtxs[1] = pointBuffer[j]; } if (pnt.z > vector3d.z) { vector3d.z = pnt.z; maxVtxs[2] = pointBuffer[j]; } else if (pnt.z < vector3d2.z) { vector3d2.z = pnt.z; minVtxs[2] = pointBuffer[j]; } } charLength = Math.Max(vector3d.x - vector3d2.x, vector3d.y - vector3d2.y); charLength = Math.Max(vector3d.z - vector3d2.z, charLength); if (explicitTolerance == -1.0) { tolerance = 6.661338147750939E-16 * (Math.Max(Math.Abs(vector3d.x), Math.Abs(vector3d2.x)) + Math.Max(Math.Abs(vector3d.y), Math.Abs(vector3d2.y)) + Math.Max(Math.Abs(vector3d.z), Math.Abs(vector3d2.z))); } else { tolerance = explicitTolerance; } } protected void createInitialSimplex() { double num = 0.0; int num2 = 0; for (int i = 0; i < 3; i++) { double num3 = maxVtxs[i].pnt.get(i) - minVtxs[i].pnt.get(i); if (num3 > num) { num = num3; num2 = i; } } if (num <= tolerance) { throw new SystemException("Input points appear to be coincident"); } Vertex[] array = new Vertex[4] { maxVtxs[num2], minVtxs[num2], null, null }; Vector3d vector3d = new Vector3d(); Vector3d vector3d2 = new Vector3d(); Vector3d vector3d3 = new Vector3d(); Vector3d vector3d4 = new Vector3d(); double num4 = 0.0; vector3d.sub(array[1].pnt, array[0].pnt); vector3d.normalize(); for (int j = 0; j < numPoints; j++) { vector3d2.sub(pointBuffer[j].pnt, array[0].pnt); vector3d4.cross(vector3d, vector3d2); double num5 = vector3d4.normSquared(); if (num5 > num4 && pointBuffer[j] != array[0] && pointBuffer[j] != array[1]) { num4 = num5; array[2] = pointBuffer[j]; vector3d3.set(vector3d4); } } if (Math.Sqrt(num4) <= 100.0 * tolerance) { throw new SystemException("Input points appear to be colinear"); } vector3d3.normalize(); double num6 = 0.0; double num7 = array[2].pnt.dot(vector3d3); for (int k = 0; k < numPoints; k++) { double num8 = Math.Abs(pointBuffer[k].pnt.dot(vector3d3) - num7); if (num8 > num6 && pointBuffer[k] != array[0] && pointBuffer[k] != array[1] && pointBuffer[k] != array[2]) { num6 = num8; array[3] = pointBuffer[k]; } } if (Math.Abs(num6) <= 100.0 * tolerance) { throw new SystemException("Input points appear to be coplanar"); } Face[] array2 = new Face[4]; if (array[3].pnt.dot(vector3d3) - num7 < 0.0) { array2[0] = Face.createTriangle(array[0], array[1], array[2]); array2[1] = Face.createTriangle(array[3], array[1], array[0]); array2[2] = Face.createTriangle(array[3], array[2], array[1]); array2[3] = Face.createTriangle(array[3], array[0], array[2]); for (int l = 0; l < 3; l++) { int num9 = (l + 1) % 3; array2[l + 1].getEdge(1).setOpposite(array2[num9 + 1].getEdge(0)); array2[l + 1].getEdge(2).setOpposite(array2[0].getEdge(num9)); } } else { array2[0] = Face.createTriangle(array[0], array[2], array[1]); array2[1] = Face.createTriangle(array[3], array[0], array[1]); array2[2] = Face.createTriangle(array[3], array[1], array[2]); array2[3] = Face.createTriangle(array[3], array[2], array[0]); for (int m = 0; m < 3; m++) { int num10 = (m + 1) % 3; array2[m + 1].getEdge(0).setOpposite(array2[num10 + 1].getEdge(1)); array2[m + 1].getEdge(2).setOpposite(array2[0].getEdge((3 - m) % 3)); } } for (int n = 0; n < 4; n++) { faces.Add(array2[n]); } for (int num11 = 0; num11 < numPoints; num11++) { Vertex vertex = pointBuffer[num11]; if (vertex == array[0] || vertex == array[1] || vertex == array[2] || vertex == array[3]) { continue; } num6 = tolerance; Face face = null; for (int num12 = 0; num12 < 4; num12++) { double num13 = array2[num12].distanceToPlane(vertex.pnt); if (num13 > num6) { face = array2[num12]; num6 = num13; } } if (face != null) { addPointToFace(vertex, face); } } } public int getNumVertices() { return numVertices; } public Point3d[] getVertices() { Point3d[] array = new Point3d[numVertices]; for (int i = 0; i < numVertices; i++) { array[i] = pointBuffer[vertexPointIndices[i]].pnt; } return array; } public int getVertices(double[] coords) { for (int i = 0; i < numVertices; i++) { Point3d pnt = pointBuffer[vertexPointIndices[i]].pnt; coords[i * 3] = pnt.x; coords[i * 3 + 1] = pnt.y; coords[i * 3 + 2] = pnt.z; } return numVertices; } public int[] getVertexPointIndices() { int[] array = new int[numVertices]; for (int i = 0; i < numVertices; i++) { array[i] = vertexPointIndices[i]; } return array; } public int getNumFaces() { return faces.Count; } public int[][] getFaces() { return getFaces(0); } public int[][] getFaces(int indexFlags) { int[][] array = new int[faces.Count][]; int num = 0; foreach (Face face in faces) { array[num] = new int[face.numVertices()]; getFaceIndices(array[num], face, indexFlags); num++; } return array; } private void getFaceIndices(int[] indices, Face face, int flags) { bool flag = (flags & 1) == 0; bool flag2 = (flags & 2) != 0; bool flag3 = (flags & 8) != 0; HalfEdge halfEdge = face.he0; int num = 0; do { int num2 = halfEdge.head().index; if (flag3) { num2 = vertexPointIndices[num2]; } if (flag2) { num2++; } indices[num++] = num2; halfEdge = ((!flag) ? halfEdge.prev : halfEdge.next); } while (halfEdge != face.he0); } protected void resolveUnclaimedPoints(FaceList newFaces) { Vertex vertex = unclaimed.first(); for (Vertex vertex2 = vertex; vertex2 != null; vertex2 = vertex) { vertex = vertex2.next; double num = tolerance; Face face = null; for (Face face2 = newFaces.first(); face2 != null; face2 = face2.next) { if (face2.mark == 1) { double num2 = face2.distanceToPlane(vertex2.pnt); if (num2 > num) { num = num2; face = face2; } if (num > 1000.0 * tolerance) { break; } } } if (face != null) { addPointToFace(vertex2, face); } } } protected void deleteFacePoints(Face face, Face absorbingFace) { Vertex vertex = removeAllPointsFromFace(face); if (vertex == null) { return; } if (absorbingFace == null) { unclaimed.addAll(vertex); return; } Vertex vertex2 = vertex; for (Vertex vertex3 = vertex2; vertex3 != null; vertex3 = vertex2) { vertex2 = vertex3.next; double num = absorbingFace.distanceToPlane(vertex3.pnt); if (num > tolerance) { addPointToFace(vertex3, absorbingFace); } else { unclaimed.add(vertex3); } } } protected double oppFaceDistance(HalfEdge he) { return he.face.distanceToPlane(he.opposite.face.getCentroid()); } private bool doAdjacentMerge(Face face, int mergeType) { HalfEdge halfEdge = face.he0; bool flag = true; do { Face face2 = halfEdge.oppositeFace(); bool flag2 = false; if (mergeType == 2) { if (oppFaceDistance(halfEdge) > 0.0 - tolerance || oppFaceDistance(halfEdge.opposite) > 0.0 - tolerance) { flag2 = true; } } else if (face.area > face2.area) { double num = oppFaceDistance(halfEdge); if (num > 0.0 - tolerance) { flag2 = true; } else if (oppFaceDistance(halfEdge.opposite) > 0.0 - tolerance) { flag = false; } } else if (oppFaceDistance(halfEdge.opposite) > 0.0 - tolerance) { flag2 = true; } else if (oppFaceDistance(halfEdge) > 0.0 - tolerance) { flag = false; } if (flag2) { int num2 = face.mergeAdjacentFace(halfEdge, discardedFaces); for (int i = 0; i < num2; i++) { deleteFacePoints(discardedFaces[i], face); } return true; } halfEdge = halfEdge.next; } while (halfEdge != face.he0); if (!flag) { face.mark = 2; } return false; } protected void calculateHorizon(Point3d eyePnt, HalfEdge edge0, Face face, List horizon) { deleteFacePoints(face, null); face.mark = 3; HalfEdge halfEdge; if (edge0 == null) { edge0 = face.getEdge(0); halfEdge = edge0; } else { halfEdge = edge0.getNext(); } do { Face face2 = halfEdge.oppositeFace(); if (face2.mark == 1) { if (face2.distanceToPlane(eyePnt) > tolerance) { calculateHorizon(eyePnt, halfEdge.getOpposite(), face2, horizon); } else { horizon.Add(halfEdge); } } halfEdge = halfEdge.getNext(); } while (halfEdge != edge0); } private HalfEdge addAdjoiningFace(Vertex eyeVtx, HalfEdge he) { Face face = Face.createTriangle(eyeVtx, he.tail(), he.head()); faces.Add(face); face.getEdge(-1).setOpposite(he.getOpposite()); return face.getEdge(0); } protected void addNewFaces(FaceList newFaces, Vertex eyeVtx, List horizon) { newFaces.clear(); HalfEdge halfEdge = null; HalfEdge halfEdge2 = null; foreach (HalfEdge item in horizon) { HalfEdge halfEdge3 = addAdjoiningFace(eyeVtx, item); if (halfEdge != null) { halfEdge3.next.setOpposite(halfEdge); } else { halfEdge2 = halfEdge3; } newFaces.add(halfEdge3.getFace()); halfEdge = halfEdge3; } halfEdge2.next.setOpposite(halfEdge); } protected Vertex nextPointToAdd() { if (!claimed.isEmpty()) { Face face = claimed.first().face; Vertex result = null; double num = 0.0; Vertex vertex = face.outside; while (vertex != null && vertex.face == face) { double num2 = face.distanceToPlane(vertex.pnt); if (num2 > num) { num = num2; result = vertex; } vertex = vertex.next; } return result; } return null; } protected void addPointToHull(Vertex eyeVtx) { horizon.Clear(); unclaimed.clear(); removePointFromFace(eyeVtx, eyeVtx.face); calculateHorizon(eyeVtx.pnt, null, eyeVtx.face, horizon); newFaces.clear(); addNewFaces(newFaces, eyeVtx, horizon); for (Face face = newFaces.first(); face != null; face = face.next) { if (face.mark == 1) { while (doAdjacentMerge(face, 1)) { } } } for (Face face2 = newFaces.first(); face2 != null; face2 = face2.next) { if (face2.mark == 2) { face2.mark = 1; while (doAdjacentMerge(face2, 2)) { } } } resolveUnclaimedPoints(newFaces); } protected void buildHull() { int num = 0; computeMaxAndMin(); createInitialSimplex(); Vertex eyeVtx; while ((eyeVtx = nextPointToAdd()) != null) { addPointToHull(eyeVtx); num++; } reindexFacesAndVertices(); } private void markFaceVertices(Face face, int mark) { HalfEdge firstEdge = face.getFirstEdge(); HalfEdge halfEdge = firstEdge; do { halfEdge.head().index = mark; halfEdge = halfEdge.next; } while (halfEdge != firstEdge); } protected void reindexFacesAndVertices() { for (int i = 0; i < numPoints; i++) { pointBuffer[i].index = -1; } numFaces = 0; for (int j = 0; j < faces.Count; j++) { Face face = faces[j]; if (face.mark != 1) { faces.RemoveAt(j); j--; } else { markFaceVertices(face, 0); numFaces++; } } numVertices = 0; for (int k = 0; k < numPoints; k++) { Vertex vertex = pointBuffer[k]; if (vertex.index == 0) { vertexPointIndices[numVertices] = k; vertex.index = numVertices++; } } } protected bool checkFaceConvexity(Face face, double tol) { HalfEdge halfEdge = face.he0; do { face.checkConsistency(); double num = oppFaceDistance(halfEdge); if (num > tol) { return false; } num = oppFaceDistance(halfEdge.opposite); if (num > tol) { return false; } if (halfEdge.next.oppositeFace() == halfEdge.oppositeFace()) { return false; } halfEdge = halfEdge.next; } while (halfEdge != face.he0); return true; } protected bool checkFaces(double tol) { bool result = true; foreach (Face face in faces) { if (face.mark == 1 && !checkFaceConvexity(face, tol)) { result = false; } } return result; } public bool check() { return check(getDistanceTolerance()); } public bool check(double tol) { double num = 10.0 * tol; if (!checkFaces(tolerance)) { return false; } for (int i = 0; i < numPoints; i++) { Point3d pnt = pointBuffer[i].pnt; foreach (Face face in faces) { if (face.mark == 1) { double num2 = face.distanceToPlane(pnt); if (num2 > num) { return false; } } } } return true; } } public class Vector3d { private const double DOUBLE_PREC = 2.220446049250313E-16; public double x; public double y; public double z; public Vector3d() { } public Vector3d(Vector3d v) { set(v); } public Vector3d(double x, double y, double z) { set(x, y, z); } public double get(int i) { return i switch { 0 => x, 1 => y, 2 => z, _ => throw new IndexOutOfRangeException("" + i), }; } public void set(int i, double value) { switch (i) { case 0: x = value; break; case 1: y = value; break; case 2: z = value; break; default: throw new IndexOutOfRangeException("" + i); } } public void set(Vector3d v1) { x = v1.x; y = v1.y; z = v1.z; } public void add(Vector3d v1, Vector3d v2) { x = v1.x + v2.x; y = v1.y + v2.y; z = v1.z + v2.z; } public void add(Vector3d v1) { x += v1.x; y += v1.y; z += v1.z; } public void sub(Vector3d v1, Vector3d v2) { x = v1.x - v2.x; y = v1.y - v2.y; z = v1.z - v2.z; } public void sub(Vector3d v1) { x -= v1.x; y -= v1.y; z -= v1.z; } public void scale(double s) { x = s * x; y = s * y; z = s * z; } public void scale(double s, Vector3d v1) { x = s * v1.x; y = s * v1.y; z = s * v1.z; } public double norm() { return Math.Sqrt(x * x + y * y + z * z); } public double normSquared() { return x * x + y * y + z * z; } public double distance(Vector3d v) { double num = x - v.x; double num2 = y - v.y; double num3 = z - v.z; return Math.Sqrt(num * num + num2 * num2 + num3 * num3); } public double distanceSquared(Vector3d v) { double num = x - v.x; double num2 = y - v.y; double num3 = z - v.z; return num * num + num2 * num2 + num3 * num3; } public double dot(Vector3d v1) { return x * v1.x + y * v1.y + z * v1.z; } public void normalize() { double num = x * x + y * y + z * z; double num2 = num - 1.0; if (num2 > 4.440892098500626E-16 || num2 < -4.440892098500626E-16) { double num3 = Math.Sqrt(num); x /= num3; y /= num3; z /= num3; } } public void setZero() { x = 0.0; y = 0.0; z = 0.0; } public void set(double x, double y, double z) { this.x = x; this.y = y; this.z = z; } public void cross(Vector3d v1, Vector3d v2) { double num = v1.y * v2.z - v1.z * v2.y; double num2 = v1.z * v2.x - v1.x * v2.z; double num3 = v1.x * v2.y - v1.y * v2.x; x = num; y = num2; z = num3; } protected void setRandom(double lower, double upper, Random generator) { double num = upper - lower; x = generator.NextDouble() * num + lower; y = generator.NextDouble() * num + lower; z = generator.NextDouble() * num + lower; } public string toString() { return x + " " + y + " " + z; } } public class Vertex { public Point3d pnt; public int index; public Vertex prev; public Vertex next; public Face face; public Vertex() { pnt = new Point3d(); } public Vertex(double x, double y, double z, int idx) { pnt = new Point3d(x, y, z); index = idx; } } internal class VertexList { private Vertex head; private Vertex tail; public void clear() { head = (tail = null); } public void add(Vertex vtx) { if (head == null) { head = vtx; } else { tail.next = vtx; } vtx.prev = tail; vtx.next = null; tail = vtx; } public void addAll(Vertex vtx) { if (head == null) { head = vtx; } else { tail.next = vtx; } vtx.prev = tail; while (vtx.next != null) { vtx = vtx.next; } tail = vtx; } public void delete(Vertex vtx) { if (vtx.prev == null) { head = vtx.next; } else { vtx.prev.next = vtx.next; } if (vtx.next == null) { tail = vtx.prev; } else { vtx.next.prev = vtx.prev; } } public void delete(Vertex vtx1, Vertex vtx2) { if (vtx1.prev == null) { head = vtx2.next; } else { vtx1.prev.next = vtx2.next; } if (vtx2.next == null) { tail = vtx1.prev; } else { vtx2.next.prev = vtx1.prev; } } public void insertBefore(Vertex vtx, Vertex next) { vtx.prev = next.prev; if (next.prev == null) { head = vtx; } else { next.prev.next = vtx; } vtx.next = next; next.prev = vtx; } public Vertex first() { return head; } public bool isEmpty() { return head == null; } } } namespace Technie.PhysicsCreator { public enum BoxFitMethod { AxisAligned, MinimumVolume, AlignFaces } public class ConstructionPlane { public Vector3 center; public Vector3 normal; public Vector3 tangent; public Quaternion rotation; public Matrix4x4 planeToWorld; public Matrix4x4 worldToPlane; public ConstructionPlane(Vector3 c) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_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) center = c; normal = Vector3.forward; tangent = Vector3.up; Init(); } public ConstructionPlane(Vector3 c, Vector3 n, Vector3 t) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) center = c; normal = n; tangent = t; Init(); } public ConstructionPlane(ConstructionPlane basePlane, float angle) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_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_003a: 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) Quaternion val = Quaternion.AngleAxis(angle, basePlane.normal); Vector3 val2 = val * basePlane.tangent; center = basePlane.center; normal = basePlane.normal; tangent = val2; Init(); } public ConstructionPlane(ConstructionPlane basePlane, Vector3 positionOffset) { //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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) center = basePlane.center + positionOffset; normal = basePlane.normal; tangent = basePlane.tangent; Init(); } private void Init() { //IL_0022: 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_0032: 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_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_0049: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref normal)).magnitude < 0.01f) { Debug.LogError((object)"!"); } rotation = Quaternion.LookRotation(normal, tangent); planeToWorld = Matrix4x4.TRS(center, rotation, Vector3.one); worldToPlane = ((Matrix4x4)(ref planeToWorld)).inverse; } } public class RotatedBox { public ConstructionPlane plane; public Vector3 localCenter; public Vector3 center; public Vector3 size; public float volume; public float VolumeCm3 => volume * 1000000f; public RotatedBox(ConstructionPlane p, Vector3 localCenter, Vector3 c, Vector3 s) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_001d: 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) plane = p; this.localCenter = localCenter; center = c; size = s; volume = size.x * size.y * size.z; } public void DrawWireframe() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0027: 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) Gizmos.matrix = Matrix4x4.TRS(center, plane.rotation, Vector3.one); Gizmos.DrawWireCube(Vector3.zero, size); Gizmos.matrix = Matrix4x4.identity; } } public class VolumeSorter : IComparer { public int Compare(RotatedBox lhs, RotatedBox rhs) { if (Mathf.Approximately(lhs.volume, rhs.volume)) { return 0; } if (lhs.volume > rhs.volume) { return 1; } return -1; } } public class RotatedBoxFitter { public BoxDef Fit(Hull hull, Vector3[] meshVertices, int[] meshIndices) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00c0: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_010c: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_011c: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) QHullUtil.FindConvexHull(hull.name, hull.selectedFaces.ToArray(), meshVertices, meshIndices, out var hullVertices, out var hullIndices, showErrorInLog: false); if (hullVertices == null || hullVertices.Length == 0) { FaceAlignmentBoxFitter.FindTriangles(hull, meshVertices, meshIndices, out hullVertices, out hullIndices); } List list = new List(); int num = 64; int numVariants = 128; float angleRange = 360f / (float)num; for (int i = 0; i < hullIndices.Length; i += 3) { int num2 = hullIndices[i]; int num3 = hullIndices[i + 1]; int num4 = hullIndices[i + 2]; Vector3 val = hullVertices[num2]; Vector3 val2 = hullVertices[num3]; Vector3 val3 = hullVertices[num4]; Vector3 c = (val + val2 + val3) / 3f; Vector3 val4 = val2 - val; Vector3 normalized = ((Vector3)(ref val4)).normalized; Vector3 val5 = val3 - val; Vector3 val6 = Vector3.Cross(normalized, ((Vector3)(ref val5)).normalized); Vector3 val7 = ((!(Mathf.Abs(Vector3.Dot(val6, Vector3.up)) > 0.9f)) ? Vector3.up : Vector3.right); Vector3 t = Vector3.Cross(val6, val7); if (((Vector3)(ref val6)).magnitude > 0.0001f) { ConstructionPlane basePlane = new ConstructionPlane(c, val6, t); for (int j = 0; j < num; j++) { float angle = (float)j / (float)(num - 1) * 360f; ConstructionPlane item = new ConstructionPlane(basePlane, angle); list.Add(item); } } } List list2 = FindTightestBoxes(list, hullVertices); if (list2.Count > 0) { list2.Sort(new VolumeSorter()); RotatedBox rotatedBox = list2[0]; List list3 = new List(); GeneratePlaneVariants(list2[0].plane, numVariants, angleRange, list3); List list4 = FindTightestBoxes(list3, hullVertices); list4.Sort(new VolumeSorter()); RotatedBox computedBox = list4[0]; ApplyToHull(computedBox, hull); return ToBoxDef(computedBox); } Debug.LogError((object)("Couldn't fit box rotation to hull for " + hull.name)); return default(BoxDef); } private static void GeneratePlaneVariants(ConstructionPlane basePlane, int numVariants, float angleRange, List variantPlanes) { variantPlanes.Add(basePlane); for (int i = 0; i < numVariants; i++) { float num = (float)i / (float)(numVariants - 1); float angle = Mathf.Lerp(0f - angleRange, angleRange, num); variantPlanes.Add(new ConstructionPlane(basePlane, angle)); } } public static BoxDef ToBoxDef(RotatedBox computedBox) { //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_0023: 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_0035: 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) BoxDef result = default(BoxDef); result.boxPosition = computedBox.plane.center; result.boxRotation = computedBox.plane.rotation; ((Bounds)(ref result.collisionBox)).center = computedBox.localCenter; ((Bounds)(ref result.collisionBox)).size = computedBox.size; return result; } public static void ApplyToHull(RotatedBox computedBox, Hull targetHull) { targetHull.collisionBox = ToBoxDef(computedBox); } private static List FindTightestBoxes(List planes, Vector3[] inputVertices) { if (inputVertices == null || inputVertices.Length == 0) { return new List(); } List list = new List(); foreach (ConstructionPlane plane in planes) { RotatedBox item = FindTightestBox(plane, inputVertices); list.Add(item); } return list; } public static RotatedBox FindTightestBox(ConstructionPlane plane, Vector3[] inputVertices) { //IL_0023: 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_002e: 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_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_0052: 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_0058: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if (inputVertices == null || inputVertices.Length == 0) { return null; } Vector3 val; Vector3 val2 = (val = ((Matrix4x4)(ref plane.worldToPlane)).MultiplyPoint(inputVertices[0])); foreach (Vector3 val3 in inputVertices) { Vector3 val4 = ((Matrix4x4)(ref plane.worldToPlane)).MultiplyPoint(val3); val2 = Vector3.Min(val4, val2); val = Vector3.Max(val4, val); } Vector3 val5 = Vector3.Lerp(val2, val, 0.5f); Vector3 c = ((Matrix4x4)(ref plane.planeToWorld)).MultiplyPoint(val5); Vector3 s = val - val2; return new RotatedBox(plane, val5, c, s); } } public struct RotatedCapsule { public Vector3 center; public Vector3 dir; public float radius; public float height; public float CalcVolume() { float num = Mathf.Max(height - radius * 2f, 0f); return (float)Math.PI * (radius * radius) * (1.3333334f * radius * num); } public void DrawWireframe() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_006b: 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_0083: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = center - dir * Mathf.Max(height * 0.5f - radius, 0f); Vector3 val2 = center + dir * Mathf.Max(height * 0.5f - radius, 0f); Vector3 val3 = val2 - val; float magnitude = ((Vector3)(ref val3)).magnitude; float num = magnitude * 0.5f; Vector3 val4 = Vector3.Cross(dir, (!(Mathf.Abs(Vector3.Dot(dir, Vector3.up)) > 0.9f)) ? Vector3.up : Vector3.right); Vector3 val5 = Vector3.Cross(dir, val4); Gizmos.DrawWireSphere(val, radius); Gizmos.DrawWireSphere(val2, radius); Gizmos.DrawLine(center + val4 * radius - dir * num, center + val4 * radius + dir * num); Gizmos.DrawLine(center - val4 * radius - dir * num, center - val4 * radius + dir * num); Gizmos.DrawLine(center + val5 * radius - dir * num, center + val5 * radius + dir * num); Gizmos.DrawLine(center - val5 * radius - dir * num, center - val5 * radius + dir * num); } } public class RotatedCapsuleFitter { public CapsuleDef Fit(Hull hull, Vector3[] meshVertices, int[] meshIndices) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_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_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_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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) QHullUtil.FindConvexHull(hull.name, hull.selectedFaces.ToArray(), meshVertices, meshIndices, out var hullVertices, out var _, showErrorInLog: false); if (hullVertices == null || hullVertices.Length == 0) { return default(CapsuleDef); } RotatedBoxFitter rotatedBoxFitter = new RotatedBoxFitter(); BoxDef boxDef = rotatedBoxFitter.Fit(hull, meshVertices, meshIndices); Vector3 c = boxDef.boxPosition + boxDef.boxRotation * ((Bounds)(ref boxDef.collisionBox)).center; ConstructionPlane constructionPlane = ((((Bounds)(ref boxDef.collisionBox)).size.x > ((Bounds)(ref boxDef.collisionBox)).size.y && ((Bounds)(ref boxDef.collisionBox)).size.x > ((Bounds)(ref boxDef.collisionBox)).size.z) ? new ConstructionPlane(c, boxDef.boxRotation * Vector3.right, boxDef.boxRotation * Vector3.forward) : ((!(((Bounds)(ref boxDef.collisionBox)).size.y > ((Bounds)(ref boxDef.collisionBox)).size.z)) ? new ConstructionPlane(c, boxDef.boxRotation * Vector3.forward, boxDef.boxRotation * Vector3.right) : new ConstructionPlane(c, boxDef.boxRotation * Vector3.up, boxDef.boxRotation * Vector3.right))); RotatedCapsule inputCapule = FitCapsule(constructionPlane, hullVertices); Refine(inputCapule, constructionPlane, hullVertices, out var bestCapsule, out var bestPlane); CapsuleDef result = default(CapsuleDef); result.capsuleCenter = Vector3.zero; result.capsuleDirection = CapsuleAxis.Z; result.capsuleRadius = bestCapsule.radius; result.capsuleHeight = bestCapsule.height; result.capsulePosition = bestPlane.center; result.capsuleRotation = bestPlane.rotation; return result; } public static void Refine(RotatedCapsule inputCapule, ConstructionPlane inputPlane, Vector3[] hullVertices, out RotatedCapsule bestCapsule, out ConstructionPlane bestPlane) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) bestPlane = inputPlane; bestCapsule = inputCapule; Random random = new Random(1234); int num = 1024; for (int i = 0; i < num; i++) { float magnitude = Mathf.Min(bestCapsule.height, bestCapsule.radius) * 0.01f; ConstructionPlane constructionPlane = new ConstructionPlane(bestPlane, new Vector3(Jitter(magnitude, random), Jitter(magnitude, random), Jitter(magnitude, random))); RotatedCapsule rotatedCapsule = FitCapsule(constructionPlane, hullVertices); if (rotatedCapsule.CalcVolume() < bestCapsule.CalcVolume()) { bestCapsule = rotatedCapsule; bestPlane = constructionPlane; } } } private static float Jitter(float magnitude, Random random) { double num = random.NextDouble() * (double)(magnitude * 2f) - (double)magnitude; return (float)num; } public static RotatedCapsule FitCapsule(ConstructionPlane plane, Vector3[] points) { //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_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_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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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) RotatedCapsule result = default(RotatedCapsule); result.center = plane.center; result.dir = plane.normal; foreach (Vector3 val in points) { Vector3 val2 = ProjectOntoAxis(plane, val); float num = Vector3.Distance(val2, val); float num2 = Vector3.Distance(plane.center, val2); result.radius = Mathf.Max(result.radius, num); result.height = Mathf.Max(result.height, num2 * 2f); } return result; } private static Vector3 ProjectOntoAxis(ConstructionPlane plane, Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = point - plane.center; float num = Vector3.Dot(plane.normal, val); return plane.center + plane.normal * num; } public static Vector3 FindCenter(Vector3[] vertices) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (vertices == null || vertices.Length == 0) { return Vector3.zero; } Vector3 val = Vector3.zero; for (int i = 0; i < vertices.Length; i++) { val += vertices[i]; } return val / (float)vertices.Length; } } public class Sphere { public Vector3 center; public float radius = 1f; } public class SphereUtils { public class Support { public int m_iQuantity; public int[] m_aiIndex = new int[4]; public bool Contains(int iIndex, List points) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_iQuantity; i++) { Vector3 val = points[iIndex] - points[m_aiIndex[i]]; if (((Vector3)(ref val)).sqrMagnitude < 0.001f) { return true; } } return false; } } private const float kEpsilon = 0.001f; private const float kOnePlusEpsilon = 1.001f; private static bool PointInsideSphere(Vector3 rkP, Sphere rkS) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = rkP - rkS.center; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; return sqrMagnitude <= 1.001f * rkS.radius; } private static Sphere ExactSphere1(Vector3 rkP) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Sphere sphere = new Sphere(); sphere.center = rkP; sphere.radius = 0f; return sphere; } private static Sphere ExactSphere2(Vector3 rkP0, Vector3 rkP1) { //IL_000d: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Sphere sphere = new Sphere(); sphere.center = 0.5f * (rkP0 + rkP1); Vector3 val = rkP1 - rkP0; sphere.radius = 0.25f * ((Vector3)(ref val)).sqrMagnitude; return sphere; } private static Sphere ExactSphere3(Vector3 rkP0, Vector3 rkP1, Vector3 rkP2) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a6: Unknown result type (might be due to invalid IL or missing references) Vector3 val = rkP0 - rkP2; Vector3 val2 = rkP1 - rkP2; float num = Vector3.Dot(val, val); float num2 = Vector3.Dot(val, val2); float num3 = Vector3.Dot(val2, val2); float num4 = num * num3 - num2 * num2; Sphere sphere = new Sphere(); float num5 = 0.5f / num4; float num6 = num5 * num3 * (num - num2); float num7 = num5 * num * (num3 - num2); float num8 = 1f - num6 - num7; sphere.center = num6 * rkP0 + num7 * rkP1 + num8 * rkP2; Vector3 val3 = num6 * val + num7 * val2; sphere.radius = ((Vector3)(ref val3)).sqrMagnitude; return sphere; } private static Sphere ExactSphere4(Vector3 rkP0, Vector3 rkP1, Vector3 rkP2, Vector3 rkP3) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) Vector3 val = rkP0 - rkP3; Vector3 val2 = rkP1 - rkP3; Vector3 val3 = rkP2 - rkP3; float[,] array = new float[3, 3]; array[0, 0] = Vector3.Dot(val, val); array[0, 1] = Vector3.Dot(val, val2); array[0, 2] = Vector3.Dot(val, val3); array[1, 0] = array[0, 1]; array[1, 1] = Vector3.Dot(val2, val2); array[1, 2] = Vector3.Dot(val2, val3); array[2, 0] = array[0, 2]; array[2, 1] = array[1, 2]; array[2, 2] = Vector3.Dot(val3, val3); float[] array2 = new float[3] { 0.5f * array[0, 0], 0.5f * array[1, 1], 0.5f * array[2, 2] }; float[,] array3 = new float[3, 3] { { array[1, 1] * array[2, 2] - array[1, 2] * array[2, 1], array[0, 2] * array[2, 1] - array[0, 1] * array[2, 2], array[0, 1] * array[1, 2] - array[0, 2] * array[1, 1] }, { array[1, 2] * array[2, 0] - array[1, 0] * array[2, 2], array[0, 0] * array[2, 2] - array[0, 2] * array[2, 0], array[0, 2] * array[1, 0] - array[0, 0] * array[1, 2] }, { array[1, 0] * array[2, 1] - array[1, 1] * array[2, 0], array[0, 1] * array[2, 0] - array[0, 0] * array[2, 1], array[0, 0] * array[1, 1] - array[0, 1] * array[1, 0] } }; float num = array[0, 0] * array3[0, 0] + array[0, 1] * array3[1, 0] + array[0, 2] * array3[2, 0]; Sphere sphere = new Sphere(); float num2 = 1f / num; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { array3[i, j] *= num2; } } float[] array4 = new float[4]; for (int i = 0; i < 3; i++) { array4[i] = 0f; for (int j = 0; j < 3; j++) { array4[i] += array3[i, j] * array2[j]; } } array4[3] = 1f - array4[0] - array4[1] - array4[2]; sphere.center = array4[0] * rkP0 + array4[1] * rkP1 + array4[2] * rkP2 + array4[3] * rkP3; Vector3 val4 = array4[0] * val + array4[1] * val2 + array4[2] * val3; sphere.radius = ((Vector3)(ref val4)).sqrMagnitude; return sphere; } private static Sphere UpdateSupport1(int i, List apkPerm, Support rkSupp) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0018: 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) Vector3 rkP = apkPerm[rkSupp.m_aiIndex[0]]; Vector3 rkP2 = apkPerm[i]; Sphere result = ExactSphere2(rkP, rkP2); rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[1] = i; return result; } private static Sphere UpdateSupport2(int i, List apkPerm, Support rkSupp) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_00b9: 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) Vector3 val = apkPerm[rkSupp.m_aiIndex[0]]; Vector3 val2 = apkPerm[rkSupp.m_aiIndex[1]]; Vector3 val3 = apkPerm[i]; Sphere[] array = new Sphere[3]; float num = float.PositiveInfinity; int num2 = -1; array[0] = ExactSphere2(val, val3); if (PointInsideSphere(val2, array[0])) { num = array[0].radius; num2 = 0; } array[1] = ExactSphere2(val2, val3); if (PointInsideSphere(val, array[1]) && array[1].radius < num) { num = array[1].radius; num2 = 1; } Sphere result; if (num2 != -1) { result = array[num2]; rkSupp.m_aiIndex[1 - num2] = i; } else { result = ExactSphere3(val, val2, val3); rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[2] = i; } return result; } private static Sphere UpdateSupport3(int i, List apkPerm, Support rkSupp) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0085: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) Vector3 val = apkPerm[rkSupp.m_aiIndex[0]]; Vector3 val2 = apkPerm[rkSupp.m_aiIndex[1]]; Vector3 val3 = apkPerm[rkSupp.m_aiIndex[2]]; Vector3 val4 = apkPerm[i]; Sphere[] array = new Sphere[6]; float num = float.PositiveInfinity; int num2 = -1; array[0] = ExactSphere2(val, val4); if (PointInsideSphere(val2, array[0]) && PointInsideSphere(val3, array[0])) { num = array[0].radius; num2 = 0; } array[1] = ExactSphere2(val2, val4); if (PointInsideSphere(val, array[1]) && PointInsideSphere(val3, array[1]) && array[1].radius < num) { num = array[1].radius; num2 = 1; } array[2] = ExactSphere2(val3, val4); if (PointInsideSphere(val, array[2]) && PointInsideSphere(val2, array[2]) && array[2].radius < num) { num = array[2].radius; num2 = 2; } array[3] = ExactSphere3(val, val2, val4); if (PointInsideSphere(val3, array[3]) && array[3].radius < num) { num = array[3].radius; num2 = 3; } array[4] = ExactSphere3(val, val3, val4); if (PointInsideSphere(val2, array[4]) && array[4].radius < num) { num = array[4].radius; num2 = 4; } array[5] = ExactSphere3(val2, val3, val4); if (PointInsideSphere(val, array[5]) && array[5].radius < num) { num = array[5].radius; num2 = 5; } Sphere result; switch (num2) { case 0: result = array[0]; rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[1] = i; break; case 1: result = array[1]; rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[0] = i; break; case 2: result = array[2]; rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[0] = rkSupp.m_aiIndex[2]; rkSupp.m_aiIndex[1] = i; break; case 3: result = array[3]; rkSupp.m_aiIndex[2] = i; break; case 4: result = array[4]; rkSupp.m_aiIndex[1] = i; break; case 5: result = array[5]; rkSupp.m_aiIndex[0] = i; break; default: result = ExactSphere4(val, val2, val3, val4); rkSupp.m_iQuantity = 4; rkSupp.m_aiIndex[3] = i; break; } return result; } public static Sphere UpdateSupport4(int i, List apkPerm, Support rkSupp) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_0074: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) Vector3 val = apkPerm[rkSupp.m_aiIndex[0]]; Vector3 val2 = apkPerm[rkSupp.m_aiIndex[1]]; Vector3 val3 = apkPerm[rkSupp.m_aiIndex[2]]; Vector3 val4 = apkPerm[rkSupp.m_aiIndex[3]]; Vector3 val5 = apkPerm[i]; Sphere[] array = new Sphere[14]; float num = float.PositiveInfinity; int num2 = -1; array[0] = ExactSphere2(val, val5); if (PointInsideSphere(val2, array[0]) && PointInsideSphere(val3, array[0]) && PointInsideSphere(val4, array[0])) { num = array[0].radius; num2 = 0; } array[1] = ExactSphere2(val2, val5); if (PointInsideSphere(val, array[1]) && PointInsideSphere(val3, array[1]) && PointInsideSphere(val4, array[1]) && array[1].radius < num) { num = array[1].radius; num2 = 1; } array[2] = ExactSphere2(val3, val5); if (PointInsideSphere(val, array[2]) && PointInsideSphere(val2, array[2]) && PointInsideSphere(val4, array[2]) && array[2].radius < num) { num = array[2].radius; num2 = 2; } array[3] = ExactSphere2(val4, val5); if (PointInsideSphere(val, array[3]) && PointInsideSphere(val2, array[3]) && PointInsideSphere(val3, array[3]) && array[3].radius < num) { num = array[3].radius; num2 = 3; } array[4] = ExactSphere3(val, val2, val5); if (PointInsideSphere(val3, array[4]) && PointInsideSphere(val4, array[4]) && array[4].radius < num) { num = array[4].radius; num2 = 4; } array[5] = ExactSphere3(val, val3, val5); if (PointInsideSphere(val2, array[5]) && PointInsideSphere(val4, array[5]) && array[5].radius < num) { num = array[5].radius; num2 = 5; } array[6] = ExactSphere3(val, val4, val5); if (PointInsideSphere(val2, array[6]) && PointInsideSphere(val3, array[6]) && array[6].radius < num) { num = array[6].radius; num2 = 6; } array[7] = ExactSphere3(val2, val3, val5); if (PointInsideSphere(val, array[7]) && PointInsideSphere(val4, array[7]) && array[7].radius < num) { num = array[7].radius; num2 = 7; } array[8] = ExactSphere3(val2, val4, val5); if (PointInsideSphere(val, array[8]) && PointInsideSphere(val3, array[8]) && array[8].radius < num) { num = array[8].radius; num2 = 8; } array[9] = ExactSphere3(val3, val4, val5); if (PointInsideSphere(val, array[9]) && PointInsideSphere(val2, array[9]) && array[9].radius < num) { num = array[9].radius; num2 = 9; } array[10] = ExactSphere4(val, val2, val3, val5); if (PointInsideSphere(val4, array[10]) && array[10].radius < num) { num = array[10].radius; num2 = 10; } array[11] = ExactSphere4(val, val2, val4, val5); if (PointInsideSphere(val3, array[11]) && array[11].radius < num) { num = array[11].radius; num2 = 11; } array[12] = ExactSphere4(val, val3, val4, val5); if (PointInsideSphere(val2, array[12]) && array[12].radius < num) { num = array[12].radius; num2 = 12; } array[13] = ExactSphere4(val2, val3, val4, val5); if (PointInsideSphere(val, array[13]) && array[13].radius < num) { num = array[13].radius; num2 = 13; } Sphere result = array[num2]; switch (num2) { case 0: rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[1] = i; break; case 1: rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[0] = i; break; case 2: rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[0] = rkSupp.m_aiIndex[2]; rkSupp.m_aiIndex[1] = i; break; case 3: rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[0] = rkSupp.m_aiIndex[3]; rkSupp.m_aiIndex[1] = i; break; case 4: rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[2] = i; break; case 5: rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[1] = i; break; case 6: rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[1] = rkSupp.m_aiIndex[3]; rkSupp.m_aiIndex[2] = i; break; case 7: rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[0] = i; break; case 8: rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[0] = rkSupp.m_aiIndex[3]; rkSupp.m_aiIndex[2] = i; break; case 9: rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[0] = rkSupp.m_aiIndex[3]; rkSupp.m_aiIndex[1] = i; break; case 10: rkSupp.m_aiIndex[3] = i; break; case 11: rkSupp.m_aiIndex[2] = i; break; case 12: rkSupp.m_aiIndex[1] = i; break; case 13: rkSupp.m_aiIndex[0] = i; break; } return result; } private static Sphere Update(int funcIndex, int numPoints, List points, Support support) { return funcIndex switch { 0 => null, 1 => UpdateSupport1(numPoints, points, support), 2 => UpdateSupport2(numPoints, points, support), 3 => UpdateSupport3(numPoints, points, support), 4 => UpdateSupport4(numPoints, points, support), _ => null, }; } public static Sphere MinSphere(List inputPoints) { //IL_0029: 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) Sphere sphere = new Sphere(); Support support = new Support(); if (inputPoints.Count >= 1) { List list = new List(inputPoints); Shuffle(list); sphere = ExactSphere1(list[0]); support.m_iQuantity = 1; support.m_aiIndex[0] = 0; int num = 1; while (num < inputPoints.Count) { if (!support.Contains(num, list) && !PointInsideSphere(list[num], sphere)) { sphere = Update(support.m_iQuantity, num, list, support); num = 0; } else { num++; } } } sphere.radius = Mathf.Sqrt(sphere.radius); return sphere; } public static void Shuffle(List list) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) for (int i = 0; i < list.Count; i++) { int index = i + Random.Range(0, list.Count - i); Vector3 value = list[index]; list[index] = list[i]; list[i] = value; } } } [Serializable] public class VhacdParameters { [Tooltip("maximum concavity")] [Range(0f, 1f)] public float concavity; [Tooltip("controls the bias toward clipping along symmetry planes")] [Range(0f, 1f)] public float alpha; [Tooltip("controls the bias toward clipping along revolution axes")] [Range(0f, 1f)] public float beta; [Tooltip("controls the adaptive sampling of the generated convex-hulls")] [Range(0f, 0.01f)] public float minVolumePerCH; [Tooltip("maximum number of voxels generated during the voxelization stage")] [Range(10000f, 64000000f)] public uint resolution; [Tooltip("controls the maximum number of triangles per convex-hull")] [Range(4f, 1024f)] public uint maxNumVerticesPerCH; [Tooltip("controls the granularity of the search for the \"best\" clipping plane")] [Range(1f, 16f)] public uint planeDownsampling; [Tooltip("controls the precision of the convex-hull generation process during the clipping plane selection stage")] [Range(1f, 16f)] public uint convexhullDownsampling; [Tooltip("enable/disable normalizing the mesh before applying the convex decomposition")] [Range(0f, 1f)] public uint pca; [Tooltip("0: voxel-based (recommended), 1: tetrahedron-based")] [Range(0f, 1f)] public uint mode; [Range(0f, 1f)] public uint convexhullApproximation; [Tooltip("Enable OpenCL acceleration")] [Range(0f, 1f)] public uint oclAcceleration; public uint maxConvexHulls; [Tooltip("This will project the output convex hull vertices onto the original source mesh to increase the floating point accuracy of the results")] public bool projectHullVertices; public VhacdParameters() { resolution = 100000u; concavity = 0.001f; planeDownsampling = 4u; convexhullDownsampling = 4u; alpha = 0.05f; beta = 0.05f; pca = 0u; mode = 0u; maxNumVerticesPerCH = 64u; minVolumePerCH = 0.0001f; convexhullApproximation = 1u; oclAcceleration = 0u; maxConvexHulls = 1024u; projectHullVertices = true; } } } namespace ShermanJumbo { public class YAxisRotate : MonoBehaviour { public float DegreesPerSecond = 90f; public string AxisToRotate = "Y"; public Transform ObjectToRotate; private void Update() { if (AxisToRotate == "X") { ObjectToRotate.Rotate(DegreesPerSecond * Time.deltaTime, 0f, 0f); } if (AxisToRotate == "Y") { ObjectToRotate.Rotate(0f, DegreesPerSecond * Time.deltaTime, 0f); } if (AxisToRotate == "Z") { ObjectToRotate.Rotate(0f, 0f, DegreesPerSecond * Time.deltaTime); } } } }