private static void ItemInLevel__OnSyncStateChange(ItemInLevel __instance, ePickupItemStatus status, pPickupPlacement placement) { if (status != ePickupItemStatus.PlacedInLevel) { return; } var resourceContainer = GTFOUtils.GetParentResourceContainer(placement.position); if (resourceContainer == null) { return; } // Abort if the item was already reparented if (__instance.GetComponentInParent <LG_WeakResourceContainer>() != null) { return; } Instance.LogDebug($"Reparenting {__instance.name} {__instance.PublicName}"); __instance.gameObject.transform.SetParent(resourceContainer.gameObject.transform); __instance.gameObject.transform.SetPositionAndRotation(placement.position, placement.rotation); }
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); }