Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ExtractionButtonConfirm v1.0.1
plugins\ExtractionButtonMod\ExtractionButtonMod.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ExtractionButtonMod.Configuration; using ExtractionButtonMod.Internal; using ExtractionButtonMod.Patches; using ExtractionButtonMod.Services; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ExtractionButtonMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+f32e5145b8d6b1656653255d6479ec4bde0d976d")] [assembly: AssemblyProduct("ExtractionButtonMod")] [assembly: AssemblyTitle("ExtractionButtonMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ExtractionButtonMod { [BepInPlugin("com.user.repo.extractionbutton", "Extraction Button Confirm", "1.0.1")] public sealed class ExtractionButtonPlugin : BaseUnityPlugin { private Harmony? _harmony; public static ExtractionButtonPlugin? Instance { get; private set; } public ModConfig? ModConfig { get; private set; } private void Awake() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown Instance = this; ModConfig = new ModConfig(((BaseUnityPlugin)this).Config); ExtractionPointPatches.Initialize(new ExtractionConfirmationService(ModConfig, ((BaseUnityPlugin)this).Logger)); _harmony = new Harmony("com.user.repo.extractionbutton"); _harmony.PatchAll(typeof(ExtractionPointPatches)); CheckForConflictingPlugins(); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} v{1} cargado correctamente (Modo: {2}).", "Extraction Button Confirm", "1.0.1", ModConfig.ButtonMode.Value)); } private void OnDestroy() { Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void CheckForConflictingPlugins() { foreach (PluginInfo value in Chainloader.PluginInfos.Values) { if (((value != null) ? value.Metadata : null) != null && !(value.Metadata.GUID == "com.user.repo.extractionbutton") && (value.Metadata.GUID.IndexOf("ExtractionDelayConfirm", StringComparison.OrdinalIgnoreCase) >= 0 || value.Metadata.Name.IndexOf("ExtractionDelayConfirm", StringComparison.OrdinalIgnoreCase) >= 0)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Se detectó otro mod de confirmación de extracción instalado (" + value.Metadata.Name + " [" + value.Metadata.GUID + "]). Se recomienda desactivarlo en Thunderstore Mod Manager para evitar conflictos en ExtractionPoint.")); } } } } public static class PluginInfo { public const string PluginGuid = "com.user.repo.extractionbutton"; public const string PluginName = "Extraction Button Confirm"; public const string PluginVersion = "1.0.1"; } } namespace ExtractionButtonMod.Services { public sealed class ExtractionConfirmationService { private readonly ModConfig _config; private readonly ManualLogSource _logger; private readonly ShopPedestalPlacementService _placementService; public ExtractionConfirmationService(ModConfig config, ManualLogSource logger) { _config = config ?? throw new ArgumentNullException("config"); _logger = logger ?? throw new ArgumentNullException("logger"); _placementService = new ShopPedestalPlacementService(_logger); } public bool TryOverrideShopSetup(ExtractionPoint instance) { if (!_config.Enabled.Value || !_config.UsesShopPedestalButton) { return true; } if (SemiFunc.RunIsShop()) { return true; } ExtractionPointAccess.IsShopRef.Invoke(instance) = false; if ((Object)(object)instance.shopStation != (Object)null) { ((Component)instance.shopStation).gameObject.SetActive(true); _placementService.InitializePlacement(instance); } return false; } public void PreventAutomaticExtraction(ExtractionPoint instance) { if (_config.Enabled.Value && !ExtractionPointAccess.IsShopRef.Invoke(instance)) { ExtractionPointAccess.SuccessDelayRef.Invoke(instance) = 10f; } } public bool ShouldAllowAutoActivateFromTruck(ExtractionPoint instance) { if (!_config.Enabled.Value) { return true; } return ExtractionPointAccess.StateIs(instance, (State)1); } public void UpdateMainButtonInActiveState(ExtractionPoint instance) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (!_config.Enabled.Value || ExtractionPointAccess.IsShopRef.Invoke(instance) || !ExtractionPointAccess.StateIs(instance, (State)2)) { return; } if (_config.UsesShopPedestalButton) { _placementService.RefreshPlacementOnActivation(instance); } if (!_config.UsesExtractionPointButton || ExtractionPointAccess.TubeSlamDownEvalRef.Invoke(instance) < 1f || ExtractionPointAccess.ButtonDenyCooldownRef.Invoke(instance) > 0f || ExtractionPointAccess.ButtonActiveRef.Invoke(instance)) { return; } ExtractionPointAccess.ButtonPressedRef.Invoke(instance) = false; ExtractionPointAccess.ButtonPressEvalRef.Invoke(instance) = 0f; if ((Object)(object)instance.button != (Object)null) { ((Component)instance.button).transform.localPosition = ExtractionPointAccess.ButtonOriginalPositionRef.Invoke(instance); Material val = ExtractionPointAccess.ButtonOriginalMaterialRef.Invoke(instance); if ((Object)(object)val != (Object)null) { ((Renderer)instance.button).material = val; } } if ((Object)(object)instance.buttonLight != (Object)null) { ((Behaviour)instance.buttonLight).enabled = true; } if ((Object)(object)instance.buttonGrabObject != (Object)null) { ((Behaviour)instance.buttonGrabObject).enabled = true; } ExtractionPointAccess.ButtonActiveRef.Invoke(instance) = true; } public bool TryHandleMainButtonClick(ExtractionPoint instance) { if (!_config.Enabled.Value || ExtractionPointAccess.IsShopRef.Invoke(instance) || !_config.UsesExtractionPointButton) { return true; } if (instance.isLocked || ExtractionPointAccess.StateIs(instance, (State)1)) { return true; } if (!ExtractionPointAccess.StateIs(instance, (State)2)) { return false; } ReleaseStaticGrabObjectGrabbers(instance.buttonGrabObject); if (ExtractionPointAccess.TubeSlamDownEvalRef.Invoke(instance) < 1f) { return false; } EvaluateAndTriggerConfirmation(instance); return false; } public bool TryHandleShopButtonClick(ExtractionPoint instance) { if (!_config.Enabled.Value || ExtractionPointAccess.IsShopRef.Invoke(instance)) { return true; } if ((Object)(object)instance.shopStation != (Object)null) { ReleaseStaticGrabObjectGrabbers(((Component)instance.shopStation).GetComponentInChildren<StaticGrabObject>()); } if (!ExtractionPointAccess.StateIs(instance, (State)2) || ExtractionPointAccess.TubeSlamDownEvalRef.Invoke(instance) < 1f) { return false; } EvaluateAndTriggerConfirmation(instance); return false; } public void TriggerButtonPushVisuals(ExtractionPoint instance) { //IL_00f6: 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_0114: Unknown result type (might be due to invalid IL or missing references) if (!_config.Enabled.Value || ExtractionPointAccess.IsShopRef.Invoke(instance)) { return; } if (_config.UsesExtractionPointButton && ExtractionPointAccess.ButtonActiveRef.Invoke(instance)) { ReleaseStaticGrabObjectGrabbers(instance.buttonGrabObject); ExtractionPointAccess.ButtonToggle(instance, active: false); ExtractionPointAccess.ButtonPressedRef.Invoke(instance) = true; ExtractionPointAccess.ButtonPressEvalRef.Invoke(instance) = 0f; if (instance.soundButton != null && (Object)(object)instance.button != (Object)null) { instance.soundButton.Play(((Component)instance.button).transform.position, 1f, 1f, 1f, 1f); } } if (_config.UsesShopPedestalButton && (Object)(object)instance.shopButton != (Object)null && !ExtractionPointAccess.ShopButtonAnimationRef.Invoke(instance)) { instance.shopButton.localScale = new Vector3(1f, 0.1f, 1f); if (instance.soundButton != null) { instance.soundButton.Play(instance.shopButton.position, 1f, 1f, 1f, 1f); } ExtractionPointAccess.ShopButtonAnimationEvalRef.Invoke(instance) = 0f; ExtractionPointAccess.ShopButtonAnimationRef.Invoke(instance) = true; } } public void UpdateConfirmationButtonAnimation(ExtractionPoint instance) { //IL_0099: 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_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_0103: 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) if (!_config.Enabled.Value || ExtractionPointAccess.IsShopRef.Invoke(instance)) { return; } if (_config.UsesShopPedestalButton) { _placementService.EnsurePlacementResolved(instance); } if (!ExtractionPointAccess.StateIs(instance, (State)2) && ExtractionPointAccess.ButtonPressedRef.Invoke(instance) && !((Object)(object)instance.button == (Object)null)) { ref float reference = ref ExtractionPointAccess.ButtonPressEvalRef.Invoke(instance); if (reference >= 1f) { ExtractionPointAccess.ButtonPressedRef.Invoke(instance) = false; ((Component)instance.button).transform.localPosition = ExtractionPointAccess.ButtonOriginalPositionRef.Invoke(instance); return; } reference = Mathf.Min(1f, reference + 8f * Time.deltaTime); float num = ((instance.buttonPressAnimationCurve != null) ? instance.buttonPressAnimationCurve.Evaluate(reference) : 0f); Vector3 val = ExtractionPointAccess.ButtonOriginalPositionRef.Invoke(instance); ((Component)instance.button).transform.localPosition = new Vector3(val.x, val.y, val.z - 0.1f * num); } } private void EvaluateAndTriggerConfirmation(ExtractionPoint instance) { ExtractionPointAccess.HaulInternalStatsUpdate(instance); if (SemiFunc.GameEventIsHalloween()) { ExtractionHalloweenTower val = ExtractionPointAccess.HalloweenTowerRef.Invoke(instance); if ((Object)(object)val != (Object)null && ExtractionPointAccess.IsHalloweenTowerWaiting(val)) { ExtractionPointAccess.StateSet(instance, (State)5); return; } } int num = ExtractionPointAccess.HaulCurrentRef.Invoke(instance); int haulGoal = instance.haulGoal; if (ExtractionPointAccess.HaulGoalFetchedRef.Invoke(instance) && num >= haulGoal) { _logger.LogInfo((object)$"Extraction confirmed via button! Haul: ${num} / ${haulGoal}."); ExtractionPointAccess.StateSet(instance, (State)3); } else { _logger.LogInfo((object)$"Extraction rejected (insufficient haul): ${num} / ${haulGoal}."); ExtractionPointAccess.StateSet(instance, (State)5); } } private static void ReleaseStaticGrabObjectGrabbers(StaticGrabObject? grabObject) { if ((Object)(object)grabObject == (Object)null || grabObject.playerGrabbing == null || grabObject.playerGrabbing.Count == 0) { return; } PhotonView val = ExtractionPointAccess.StaticGrabPhotonViewRef.Invoke(grabObject); if ((Object)(object)val == (Object)null) { return; } int viewID = val.ViewID; List<PhysGrabber> list = new List<PhysGrabber>(grabObject.playerGrabbing); for (int i = 0; i < list.Count; i++) { PhysGrabber val2 = list[i]; if (!((Object)(object)val2 == (Object)null)) { if (!SemiFunc.IsMultiplayer()) { val2.ReleaseObject(viewID, 0.1f); } else if (SemiFunc.IsMasterClient() && (Object)(object)val2.photonView != (Object)null && val2.photonView.Owner != null) { val2.OverrideGrabRelease(viewID, 0.25f); } } } } } public sealed class ShopPedestalPlacementService { private sealed class PlacementContext { public Vector3 OriginalPointLocalPosition { get; } public Quaternion OriginalPointLocalRotation { get; } public Vector3 ButtonOffsetInStation { get; } public HashSet<Collider> IgnoredSelfColliders { get; } public bool ResolvedAfterLevelGen { get; set; } public bool ResolvedOnActivation { get; set; } public PlacementContext(Vector3 originalPointLocalPosition, Quaternion originalPointLocalRotation, Vector3 buttonOffsetInStation, HashSet<Collider> ignoredSelfColliders) { //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) //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) OriginalPointLocalPosition = originalPointLocalPosition; OriginalPointLocalRotation = originalPointLocalRotation; ButtonOffsetInStation = buttonOffsetInStation; IgnoredSelfColliders = ignoredSelfColliders; } } private readonly struct CandidateSpot { public string Label { get; } public Vector3 PointLocalPosition { get; } public Quaternion PointLocalRotation { get; } public CandidateSpot(string label, Vector3 pointLocalPosition, Quaternion pointLocalRotation) { //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) Label = label; PointLocalPosition = pointLocalPosition; PointLocalRotation = pointLocalRotation; } } private const float CapsuleBottomHeightOffset = 0.54f; private const float CapsuleTopHeightOffset = 1.3f; private const float OverlapRadius = 0.24f; private const float ClearanceCheckRadius = 0.4f; private const float FloorIgnoreHeightThreshold = 0.25f; private readonly ManualLogSource _logger; private readonly ConditionalWeakTable<ExtractionPoint, PlacementContext> _contexts = new ConditionalWeakTable<ExtractionPoint, PlacementContext>(); private readonly Collider[] _overlapBuffer = (Collider[])(object)new Collider[32]; public ShopPedestalPlacementService(ManualLogSource logger) { _logger = logger ?? throw new ArgumentNullException("logger"); } public void InitializePlacement(ExtractionPoint instance) { if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.shopStation == (Object)null)) { PlacementContext orCreateContext = GetOrCreateContext(instance); EvaluateAndApplyBestPlacement(instance, orCreateContext, SemiFunc.LevelGenDone()); } } public void EnsurePlacementResolved(ExtractionPoint instance) { if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.shopStation == (Object)null)) { PlacementContext orCreateContext = GetOrCreateContext(instance); if (!orCreateContext.ResolvedAfterLevelGen && SemiFunc.LevelGenDone()) { EvaluateAndApplyBestPlacement(instance, orCreateContext, isPostLevelGenPass: true); } } } public void RefreshPlacementOnActivation(ExtractionPoint instance) { if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.shopStation == (Object)null)) { PlacementContext orCreateContext = GetOrCreateContext(instance); if (!orCreateContext.ResolvedOnActivation) { orCreateContext.ResolvedOnActivation = true; EvaluateAndApplyBestPlacement(instance, orCreateContext, isPostLevelGenPass: true); } } } private PlacementContext GetOrCreateContext(ExtractionPoint instance) { //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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_005f: 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_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_0083: Unknown result type (might be due to invalid IL or missing references) if (_contexts.TryGetValue(instance, out PlacementContext value)) { return value; } Transform transform = ((Component)instance).transform; Transform shopStation = instance.shopStation; Vector3 originalPointLocalPosition = transform.InverseTransformPoint(shopStation.position); Quaternion originalPointLocalRotation = Quaternion.Inverse(transform.rotation) * shopStation.rotation; Vector3 buttonOffsetInStation = (Vector3)(((Object)(object)instance.shopButton != (Object)null) ? shopStation.InverseTransformPoint(instance.shopButton.position) : new Vector3(0f, 1f, 0f)); HashSet<Collider> ignoredSelfColliders = CollectSelfColliders(instance); PlacementContext placementContext = new PlacementContext(originalPointLocalPosition, originalPointLocalRotation, buttonOffsetInStation, ignoredSelfColliders); _contexts.Add(instance, placementContext); return placementContext; } private void EvaluateAndApplyBestPlacement(ExtractionPoint instance, PlacementContext context, bool isPostLevelGenPass) { if ((Object)(object)instance.shopStation == (Object)null) { return; } if (isPostLevelGenPass) { context.ResolvedAfterLevelGen = true; } Physics.SyncTransforms(); CandidateSpot[] array = BuildCandidates(instance, context); int num = 0; float num2 = float.MaxValue; for (int i = 0; i < array.Length; i++) { float num3 = EvaluateCandidatePenalty(instance, context, array[i]); if (num3 < num2) { num2 = num3; num = i; } if (num3 <= 0.001f) { break; } } CandidateSpot candidate = array[num]; ApplyCandidate(instance, candidate); if (num > 0 && isPostLevelGenPass) { _logger.LogInfo((object)("Pedestal de confirmación reposicionado en '" + ((Object)instance).name + "' -> [" + candidate.Label + "] " + $"(penalización: {num2:F1}) para evitar superposición con objetos del nivel.")); } } private static CandidateSpot[] BuildCandidates(ExtractionPoint instance, PlacementContext context) { //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_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_0027: 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_004a: 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_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_0061: 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_00c4: 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_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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_016a: 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_0184: 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_0191: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) Vector3 originalPointLocalPosition = context.OriginalPointLocalPosition; Quaternion originalPointLocalRotation = context.OriginalPointLocalRotation; float num = ((Mathf.Abs(originalPointLocalPosition.x) >= 0.05f) ? Mathf.Sign(originalPointLocalPosition.x) : 1f); float num2 = Mathf.Max(Mathf.Abs(originalPointLocalPosition.x), 1.25f); float num3 = DetermineFrontDirectionSign(instance, originalPointLocalPosition); float num4 = DetermineFrontEdgeZ(instance, originalPointLocalPosition, num3); Quaternion val = MirrorRotationAcrossX(originalPointLocalRotation); float num5 = num * Mathf.Clamp(num2 * 0.86f, 1.05f, 1.48f); float num6 = num4 + num3 * 0.35f; float num7 = num * Mathf.Clamp(num2 * 0.72f, 0.9f, 1.25f); float num8 = num4 + num3 * 0.72f; Quaternion pointLocalRotation = originalPointLocalRotation * Quaternion.Euler(0f, (0f - num) * num3 * 25f, 0f); Quaternion pointLocalRotation2 = val * Quaternion.Euler(0f, num * num3 * 25f, 0f); return new CandidateSpot[6] { new CandidateSpot("Lado original", originalPointLocalPosition, originalPointLocalRotation), new CandidateSpot("Lado opuesto", new Vector3(0f - originalPointLocalPosition.x, originalPointLocalPosition.y, originalPointLocalPosition.z), val), new CandidateSpot("Esquina frontal (lado original)", new Vector3(num5, originalPointLocalPosition.y, num6), pointLocalRotation), new CandidateSpot("Esquina frontal (lado opuesto)", new Vector3(0f - num5, originalPointLocalPosition.y, num6), pointLocalRotation2), new CandidateSpot("Frente de esquina exterior (lado original)", new Vector3(num7, originalPointLocalPosition.y, num8), pointLocalRotation), new CandidateSpot("Frente de esquina exterior (lado opuesto)", new Vector3(0f - num7, originalPointLocalPosition.y, num8), pointLocalRotation2) }; } private float EvaluateCandidatePenalty(ExtractionPoint instance, PlacementContext context, CandidateSpot candidate) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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_0027: 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_002f: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0055: 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_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) //IL_0069: 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_00ab: 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_00f7: 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_0128: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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_016a: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01da: 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_0187: 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_0205: 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) Transform transform = ((Component)instance).transform; Vector3 val = transform.TransformPoint(candidate.PointLocalPosition); Quaternion val2 = transform.rotation * candidate.PointLocalRotation; Vector3 up = transform.up; Vector3 val3 = val + up * 0.54f; Vector3 val4 = val + up * 1.3f; Vector3 val5 = val + val2 * context.ButtonOffsetInStation; float floorMaxY = val.y + 0.25f; float num = 0f; int num2 = Physics.OverlapCapsuleNonAlloc(val3, val4, 0.24f, _overlapBuffer, -5, (QueryTriggerInteraction)1); for (int i = 0; i < num2; i++) { if (IsRelevantObstruction(_overlapBuffer[i], context.IgnoredSelfColliders, val3, floorMaxY)) { num += 100f; } } int num3 = Physics.OverlapSphereNonAlloc(val5, 0.22799999f, _overlapBuffer, -5, (QueryTriggerInteraction)1); for (int j = 0; j < num3; j++) { if (IsRelevantObstruction(_overlapBuffer[j], context.IgnoredSelfColliders, val5, floorMaxY)) { num += 120f; } } float num4 = DetermineFrontDirectionSign(instance, context.OriginalPointLocalPosition); float num5 = DetermineFrontEdgeZ(instance, context.OriginalPointLocalPosition, num4); Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(0f, context.OriginalPointLocalPosition.y + 0.9f, num5 + num4 * 0.25f); Vector3 val7 = transform.TransformPoint(val6); Vector3 val8 = val5 - val7; float magnitude = ((Vector3)(ref val8)).magnitude; if (magnitude > 0.15f) { RaycastHit[] array = Physics.RaycastAll(val7, val8 / magnitude, magnitude, -5, (QueryTriggerInteraction)1); for (int k = 0; k < array.Length; k++) { if (IsRelevantObstruction(((RaycastHit)(ref array[k])).collider, context.IgnoredSelfColliders, val5, floorMaxY)) { num += 250f; } } } int num6 = Physics.OverlapCapsuleNonAlloc(val3, val4, 0.4f, _overlapBuffer, -5, (QueryTriggerInteraction)1); for (int l = 0; l < num6; l++) { if (IsRelevantObstruction(_overlapBuffer[l], context.IgnoredSelfColliders, val3, floorMaxY)) { num += 15f; } } return num; } private static bool IsRelevantObstruction(Collider? collider, HashSet<Collider> ignoredSelfColliders, Vector3 samplePoint, float floorMaxY) { //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_004d: 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_0075: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)collider == (Object)null || !collider.enabled || collider.isTrigger) { return false; } if (ignoredSelfColliders.Contains(collider)) { return false; } if ((Object)(object)((Component)collider).GetComponentInParent<PlayerAvatar>() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent<PlayerController>() != (Object)null) { return false; } Bounds bounds = collider.bounds; if (((Bounds)(ref bounds)).max.y <= floorMaxY) { return false; } if (SupportsClosestPoint(collider) && collider.ClosestPoint(samplePoint).y <= floorMaxY && ((Bounds)(ref bounds)).size.y < 0.35f) { return false; } return true; } private static bool SupportsClosestPoint(Collider collider) { if (collider is BoxCollider || collider is SphereCollider || collider is CapsuleCollider) { return true; } MeshCollider val = (MeshCollider)(object)((collider is MeshCollider) ? collider : null); if (val != null) { return val.convex; } return false; } private static void ApplyCandidate(ExtractionPoint instance, CandidateSpot candidate) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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) if (!((Object)(object)instance.shopStation == (Object)null)) { Transform transform = ((Component)instance).transform; Transform shopStation = instance.shopStation; shopStation.position = transform.TransformPoint(candidate.PointLocalPosition); shopStation.rotation = transform.rotation * candidate.PointLocalRotation; } } private static float DetermineFrontDirectionSign(ExtractionPoint instance, Vector3 originalStationLocalPos) { //IL_0043: 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_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_0055: 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) if ((Object)(object)instance.ramp != (Object)null) { Vector3 val = ((Component)instance).transform.InverseTransformPoint(instance.ramp.position); if (Mathf.Abs(val.z) > 0.05f) { return Mathf.Sign(val.z); } } if (Mathf.Abs(originalStationLocalPos.z) > 0.05f) { return Mathf.Sign(originalStationLocalPos.z); } return 1f; } private static float DetermineFrontEdgeZ(ExtractionPoint instance, Vector3 originalStationLocalPos, float frontSignZ) { //IL_0000: 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_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_0038: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Abs(originalStationLocalPos.z) + 0.55f; if ((Object)(object)instance.ramp != (Object)null) { Vector3 val = ((Component)instance).transform.InverseTransformPoint(instance.ramp.position); num = Mathf.Max(num, Mathf.Abs(val.z)); } return frontSignZ * num; } private static Quaternion MirrorRotationAcrossX(Quaternion localRotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0027: 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_003b: 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_005e: 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_005a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = localRotation * Vector3.forward; Vector3 val2 = localRotation * Vector3.up; Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(0f - val.x, val.y, val.z); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(0f - val2.x, val2.y, val2.z); if (((Vector3)(ref val3)).sqrMagnitude < 0.001f) { return localRotation; } return Quaternion.LookRotation(((Vector3)(ref val3)).normalized, ((Vector3)(ref val4)).normalized); } private static HashSet<Collider> CollectSelfColliders(ExtractionPoint instance) { HashSet<Collider> hashSet = new HashSet<Collider>(); Collider[] componentsInChildren = ((Component)instance).GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { hashSet.Add(componentsInChildren[i]); } } return hashSet; } } } namespace ExtractionButtonMod.Patches { [HarmonyPatch(typeof(ExtractionPoint))] internal static class ExtractionPointPatches { private static ExtractionConfirmationService? s_service; internal static void Initialize(ExtractionConfirmationService service) { s_service = service; } [HarmonyPatch("ShopSetup")] [HarmonyPrefix] private static bool ShopSetupPrefix(ExtractionPoint __instance) { if (s_service != null) { return s_service.TryOverrideShopSetup(__instance); } return true; } [HarmonyPatch("HaulChecker")] [HarmonyPrefix] private static void HaulCheckerPrefix(ExtractionPoint __instance) { s_service?.PreventAutomaticExtraction(__instance); } [HarmonyPatch("ActivateTheFirstExtractionPointAutomaticallyWhenAPlayerLeaveTruck")] [HarmonyPrefix] private static bool AutoActivateFirstPointPrefix(ExtractionPoint __instance) { if (s_service != null) { return s_service.ShouldAllowAutoActivateFromTruck(__instance); } return true; } [HarmonyPatch("StateActive")] [HarmonyPostfix] private static void StateActivePostfix(ExtractionPoint __instance) { s_service?.UpdateMainButtonInActiveState(__instance); } [HarmonyPatch("OnClick")] [HarmonyPrefix] private static bool OnClickPrefix(ExtractionPoint __instance) { if (s_service != null) { return s_service.TryHandleMainButtonClick(__instance); } return true; } [HarmonyPatch("OnShopClick")] [HarmonyPrefix] private static bool OnShopClickPrefix(ExtractionPoint __instance) { if (s_service != null) { return s_service.TryHandleShopButtonClick(__instance); } return true; } [HarmonyPatch("ShopButtonPushVisualsStart")] [HarmonyPostfix] private static void ShopButtonPushVisualsStartPostfix(ExtractionPoint __instance) { s_service?.TriggerButtonPushVisuals(__instance); } [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdatePostfix(ExtractionPoint __instance) { s_service?.UpdateConfirmationButtonAnimation(__instance); } [HarmonyPatch("StateComplete")] [HarmonyPrefix] private static void StateCompletePrefix(ExtractionPoint __instance, out Transform? __state) { __state = null; if (s_service != null && !ExtractionPointAccess.IsShopRef.Invoke(__instance) && (Object)(object)__instance.shopStation != (Object)null) { __state = __instance.shopStation; __instance.shopStation = null; } } [HarmonyPatch("StateComplete")] [HarmonyPostfix] private static void StateCompletePostfix(ExtractionPoint __instance, Transform? __state) { if ((Object)(object)__state != (Object)null) { __instance.shopStation = __state; } } } } namespace ExtractionButtonMod.Internal { internal static class ExtractionPointAccess { public static readonly FieldRef<ExtractionPoint, bool> IsShopRef = AccessTools.FieldRefAccess<ExtractionPoint, bool>("isShop"); public static readonly FieldRef<ExtractionPoint, int> HaulCurrentRef = AccessTools.FieldRefAccess<ExtractionPoint, int>("haulCurrent"); public static readonly FieldRef<ExtractionPoint, bool> HaulGoalFetchedRef = AccessTools.FieldRefAccess<ExtractionPoint, bool>("haulGoalFetched"); public static readonly FieldRef<ExtractionPoint, float> SuccessDelayRef = AccessTools.FieldRefAccess<ExtractionPoint, float>("successDelay"); public static readonly FieldRef<ExtractionPoint, float> TubeSlamDownEvalRef = AccessTools.FieldRefAccess<ExtractionPoint, float>("tubeSlamDownEval"); public static readonly FieldRef<ExtractionPoint, Material> ButtonOriginalMaterialRef = AccessTools.FieldRefAccess<ExtractionPoint, Material>("buttonOriginalMaterial"); public static readonly FieldRef<ExtractionPoint, bool> ButtonActiveRef = AccessTools.FieldRefAccess<ExtractionPoint, bool>("buttonActive"); public static readonly FieldRef<ExtractionPoint, float> ButtonDenyCooldownRef = AccessTools.FieldRefAccess<ExtractionPoint, float>("buttonDenyCooldown"); public static readonly FieldRef<ExtractionPoint, bool> ButtonPressedRef = AccessTools.FieldRefAccess<ExtractionPoint, bool>("buttonPressed"); public static readonly FieldRef<ExtractionPoint, float> ButtonPressEvalRef = AccessTools.FieldRefAccess<ExtractionPoint, float>("buttonPressEval"); public static readonly FieldRef<ExtractionPoint, Vector3> ButtonOriginalPositionRef = AccessTools.FieldRefAccess<ExtractionPoint, Vector3>("buttonOriginalPosition"); public static readonly FieldRef<ExtractionPoint, bool> ShopButtonAnimationRef = AccessTools.FieldRefAccess<ExtractionPoint, bool>("shopButtonAnimation"); public static readonly FieldRef<ExtractionPoint, float> ShopButtonAnimationEvalRef = AccessTools.FieldRefAccess<ExtractionPoint, float>("shopButtonAnimationEval"); public static readonly FieldRef<ExtractionPoint, ExtractionHalloweenTower?> HalloweenTowerRef = AccessTools.FieldRefAccess<ExtractionPoint, ExtractionHalloweenTower>("halloweenTower"); public static readonly FieldRef<StaticGrabObject, PhotonView?> StaticGrabPhotonViewRef = AccessTools.FieldRefAccess<StaticGrabObject, PhotonView>("photonView"); private static readonly Action<ExtractionPoint> HaulInternalStatsUpdateDelegate = AccessTools.MethodDelegate<Action<ExtractionPoint>>(AccessTools.Method(typeof(ExtractionPoint), "HaulInternalStatsUpdate", (Type[])null, (Type[])null), (object)null, true); private static readonly Action<ExtractionPoint, State> StateSetDelegate = AccessTools.MethodDelegate<Action<ExtractionPoint, State>>(AccessTools.Method(typeof(ExtractionPoint), "StateSet", new Type[1] { typeof(State) }, (Type[])null), (object)null, true); private static readonly Func<ExtractionPoint, State, bool> StateIsDelegate = AccessTools.MethodDelegate<Func<ExtractionPoint, State, bool>>(AccessTools.Method(typeof(ExtractionPoint), "StateIs", new Type[1] { typeof(State) }, (Type[])null), (object)null, true); private static readonly Action<ExtractionPoint, bool> ButtonToggleDelegate = AccessTools.MethodDelegate<Action<ExtractionPoint, bool>>(AccessTools.Method(typeof(ExtractionPoint), "ButtonToggle", new Type[1] { typeof(bool) }, (Type[])null), (object)null, true); private static readonly Func<ExtractionHalloweenTower, bool> HalloweenTowerExtractionWaitDelegate = AccessTools.MethodDelegate<Func<ExtractionHalloweenTower, bool>>(AccessTools.Method(typeof(ExtractionHalloweenTower), "ExtractionWait", (Type[])null, (Type[])null), (object)null, true); public static void HaulInternalStatsUpdate(ExtractionPoint instance) { HaulInternalStatsUpdateDelegate(instance); } public static void StateSet(ExtractionPoint instance, State state) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) StateSetDelegate(instance, state); } public static bool StateIs(ExtractionPoint instance, State state) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return StateIsDelegate(instance, state); } public static void ButtonToggle(ExtractionPoint instance, bool active) { ButtonToggleDelegate(instance, active); } public static bool IsHalloweenTowerWaiting(ExtractionHalloweenTower tower) { return HalloweenTowerExtractionWaitDelegate(tower); } } } namespace ExtractionButtonMod.Configuration { public enum ConfirmationButtonMode { ExtractionPointButton, ShopPedestalButton, Both } public sealed class ModConfig { public ConfigEntry<bool> Enabled { get; } public ConfigEntry<ConfirmationButtonMode> ButtonMode { get; } public bool UsesExtractionPointButton { get { if (ButtonMode.Value != ConfirmationButtonMode.ExtractionPointButton) { return ButtonMode.Value == ConfirmationButtonMode.Both; } return true; } } public bool UsesShopPedestalButton { get { if (ButtonMode.Value != ConfirmationButtonMode.ShopPedestalButton) { return ButtonMode.Value == ConfirmationButtonMode.Both; } return true; } } public ModConfig(ConfigFile config) { if (config == null) { throw new ArgumentNullException("config"); } Enabled = config.Bind<bool>("General", "Enabled", true, "Activa o desactiva el mod. Cuando está activo, las extracciones no se envían automáticamente al alcanzar la cuota, sino hasta presionar el botón de confirmación."); ButtonMode = config.Bind<ConfirmationButtonMode>("General", "ButtonMode", ConfirmationButtonMode.Both, "Elige qué botón físico usar para confirmar la extracción en niveles normales:\n- Both: Habilita tanto el pedestal de la tienda (shopStation) como el botón de la máquina (Recomendado).\n- ShopPedestalButton: Conserva el pedestal con botón de la tienda (shopStation) al lado del punto de extracción.\n- ExtractionPointButton: Usa únicamente el botón propio de la máquina de extracción."); } } }