private static void MineDeployerFirstPerson__OnStickyMineSpawned__Postfix(MineDeployerFirstPerson __instance, PlayerAgent sourceAgent) { if (!sourceAgent.IsLocallyOwned) { return; } IsMineCooldownActive = true; __instance.m_lastCanPlace = false; __instance.m_lastShowIndicator = false; // FIXME: for some reason the placement indicator is incredibly // stubborn and won't disappear... __instance.m_placementIndicator?.SetVisible(false); __instance.m_placementIndicator?.SetPlacementEnabled(false); if (__instance.FPItemHolder == null) { return; } __instance.FPItemHolder.ItemHiddenTrigger = false; // Don't trigger the cooldown for consumables if (__instance.m_isConsumable) { IsMineCooldownActive = false; Instance.LogDebug("Exiting OnStickyMineSpawned early"); return; } // Put FPItemHolder in a down state instead of hidden state __instance.FPItemHolder.ItemDownTrigger = true; Instance.LogDebug("Disabling mine deployer"); }
private static bool MineDeployerFirstPerson__ShowItem__Prefix(MineDeployerFirstPerson __instance) { // Don't trigger the cooldown for consumables if (__instance.m_isConsumable) { Instance.LogDebug("Cancelling ShowItem callback"); return(HarmonyControlFlow.DontExecute); } Instance.LogDebug("Enabling mine deployer"); IsMineCooldownActive = false; if (__instance.FPItemHolder == null) { return(HarmonyControlFlow.Execute); } __instance.FPItemHolder.ItemDownTrigger = false; // Set this to true so that the game doesn't fudge the counter // when attempting to get out of the Hidden state. __instance.FPItemHolder.ItemHiddenTrigger = true; return(HarmonyControlFlow.Execute); }
private static void MineDeployerFirstPerson__Setup__Postfix(MineDeployerFirstPerson __instance) { // Same thing as the SentryGunFirstPerson::Setup patch // Not very useful but at least it stays consistent with the // sentry behavior. __instance.m_interactPlaceItem.m_maxMoveDisAllowed = float.MaxValue; }
private static void MineDeployerFirstPerson__OnWield__Postfix(MineDeployerFirstPerson __instance) { // We have to resume the Down effect here since it was paused // when we unwielded. if (IsMineCooldownActive) { Instance.LogDebug("Reapplying ItemDownTrigger due to paused mine deployer cooldown"); __instance.FPItemHolder.ItemDownTrigger = true; } }
private static void MineDeployerFirstPerson__OnUnWield__Prefix(MineDeployerFirstPerson __instance) { // We have to undo the Down effect since swapping weapons will // cause the execution of ShowItem() to pause. if (IsMineCooldownActive) { Instance.LogDebug("Removing ItemDownTrigger due to paused mine deployer cooldown"); __instance.FPItemHolder.ItemDownTrigger = false; } }
private static void MineDeployerFirstPerson__Update__Postfix(MineDeployerFirstPerson __instance) { CanPlaceMine = __instance.CanWield && __instance.CheckCanPlace(); //Instance.LogDebug($"CanPlaceMine: {CanPlaceMine}; ShowPlacementIndicator: {__instance.ShowPlacementIndicator()}"); IgnoreWorldInteractions = false; }
private static bool MineDeployerFirstPerson__Update__Prefix(MineDeployerFirstPerson __instance) { // This is so that HasWorldInteraction can return false (to // ignore world interactions) unless the player is looking // directly at a mine. HasWorldInteraction is used the vanilla // CheckCanPlace method, which causes world interactions to // suppress the mine deployer interaction. IgnoreWorldInteractions = !UseWorldInteraction; // Disables the placement indicator if we're looking at a ladder var playerInteraction = __instance.Owner.Interaction; WorldInteractionOverride.oldState = WorldInteractionOverride.state; WorldInteractionOverride.state = playerInteraction.m_enterLadderVisible || PlayerInteraction.LadderInteractionEnabled && playerInteraction.WantToEnterLadder // Prioritize interacting with certain things if looked at directly || GTFOUtils.GetComponentInSight <Component>( playerAgent: __instance.Owner, comp: out var comp, hitPos: out var _, maxDistance: 2.5f, layerMask: LayerManager.MASK_PLAYER_INTERACT_SPHERE, predicate: comp => { if (comp.Is <iLG_WeakLockHolder>()) { return(true); } if (comp.Is <LG_BulkheadDoorController_Core>()) { return(true); } if (comp.Is <iWardenObjectiveItem>()) { return(true); } if (comp.Is <iPickupItemSync>()) { return(true); } if (comp.Is <DropResourcesPatch.StorageSlotPlaceholder>()) { return(true); } return(false); }) && comp != null; // For some reason, patching CheckCanPlace and // ShowPlacementIndicator isn't sufficient to hide the indicator. var stateChanged = WorldInteractionOverride.oldState != WorldInteractionOverride.state; if (stateChanged && WorldInteractionOverride.state) { Instance.LogDebug("Disabling placement indicator"); __instance.m_lastCanPlace = false; __instance.m_lastShowIndicator = false; __instance.m_placementIndicator?.SetVisible(false); __instance.m_placementIndicator?.SetPlacementEnabled(false); playerInteraction.UnSelectCurrentBestInteraction(); return(HarmonyControlFlow.DontExecute); } return(HarmonyControlFlow.Execute); }