private void Update() { if (over != null && MyInput.GetButtonDown("Interact")) { over.Interact(player); } }
public override void Update(GunController gun) { // To fire state. if (MyInput.GetButtonDown("Fire1")) { if (gun.NBullets > 0) { gun.AddSecondaryState(new GunStateFire()); } else { GameStats._MessageNotifier.PushFloatMessage("Out of bullet"); GameStats._GunsManager.GetComponent <AudioSource>().PlayOneShot(gun.m_emptyFireSound); } } // End aim. if (MyInput.GetButtonUp("Fire2")) { if (gun.IsSecondaryState(this)) { gun.RemoveSecondaryState(); } else { gun.ChangeState(new GunStateIdle()); } } }
private Vector2 GetRawMoveVector() { Vector2 move = Vector2.zero; move.x = MyInput.GetAxisRaw(m_HorizontalAxis); move.y = MyInput.GetAxisRaw(m_VerticalAxis); if (MyInput.GetButtonDown(m_HorizontalAxis)) { if (move.x < 0) { move.x = -1f; } if (move.x > 0) { move.x = 1f; } } if (MyInput.GetButtonDown(m_VerticalAxis)) { if (move.y < 0) { move.y = -1f; } if (move.y > 0) { move.y = 1f; } } return(move); }
void HandleYInput(float y_input) { if (y_input <= -.5f && drop_routine == null && cont.OverPlatform() && MyInput.GetButtonDown("Jump", jump_buffer)) { if (cont.OverPlatform()) { drop_routine = StartCoroutine(DropRoutine()); } MyInput.ClearBuffer("Jump"); } else if (drop_routine == null && player.can_move && MyInput.GetButtonDown("Drop")) { drop_routine = StartCoroutine(DropRoutine()); } else if (player.can_move && MyInput.GetButtonDown("Jump", jump_buffer)) { if (cont.collisions.below) { Jump(true); } else if (jumps_used < (player.jump_count - (grounded_jump_used ? 0 : 1))) { Jump(false); } } }
public override void Update(GunController gun) { m_currPlayingFire = gun.m_gunAnimator.GetCurrentAnimatorStateInfo(0).IsName("fire"); // To aim state. if (MyInput.GetButtonDown("Fire2")) { if (gun.IsSecondaryState(this)) { gun.ChangeState(new GunStateAim()); } else { gun.AddSecondaryState(new GunStateAim()); } } // End fire. if ( ((gun.m_fireMode != FireMode.Launcher) && MyInput.GetButtonUp("Fire1")) || ((gun.m_fireMode == FireMode.Launcher) && m_prevPlayingFire && !m_currPlayingFire) ) { if (gun.IsSecondaryState(this)) { gun.RemoveSecondaryState(); } else { gun.ChangeState(new GunStateIdle()); } } m_prevPlayingFire = m_currPlayingFire; }
public void Update() { if (ExtraSettingsAPI_Loaded && camera != null) { if (persistence.zoomMinimapIn != null && MyInput.GetButton(persistence.zoomMinimapIn)) { ZoomMinimapIn(); } if (persistence.zoomMinimapOut != null && MyInput.GetButton(persistence.zoomMinimapOut)) { ZoomMinimapOut(); } if (persistence.minimapDrag != null && MyInput.GetButtonDown(persistence.minimapDrag)) { InitMinimapDrag(true); } if (persistence.minimapDrag != null && MyInput.GetButton(persistence.minimapDrag)) { OnMinimapDrag(); } if (persistence.minimapDrag != null && MyInput.GetButtonUp(persistence.minimapDrag)) { InitMinimapDrag(false); } if (persistence.caveMode && camera != null) { var playerY = camera.transform.parent.position.y; camera.nearClipPlane = 300 - (playerY + CAVE_MODE_CLIP_TOP); camera.farClipPlane = 300 + (-playerY + CAVE_MODE_CLIP_BOTTOM); } } }
void CalculateMoveDirection() { MoveDirection = new Vector3(0.0f, MoveDirection.y, 0.0f); // Walk. Vector3 dir = new Vector3(MyInput.GetAxis("Horizontal"), 0.0f, MyInput.GetAxis("Vertical")); dir = m_target.transform.TransformDirection(dir); dir.y = 0.0f; if (MyInput.GetButton("Sprint")) { dir *= m_runSpeed; } else { dir *= m_walkSpeed; } MoveDirection += dir; // Jump. if (m_target.isGrounded && MyInput.GetButtonDown("Jump")) { ChangeState(new FPSCharacterStateJump()); } // Character controller don't have gravity support, so apply it here. MoveDirection = new Vector3( MoveDirection.x, MoveDirection.y - m_jumpSpeed * Time.deltaTime, MoveDirection.z ); }
private void Update() { if (MyInput.GetButtonDown("AdjustMiniMap")) { small_mini_map.gameObject.SetActive(!small_mini_map.gameObject.activeSelf); big_mini_map.gameObject.SetActive(!big_mini_map.gameObject.activeSelf); } }
/// <summary> /// Process keyboard events. /// </summary> protected bool SendMoveEventToSelectedObject() { float time = Time.unscaledTime; Vector2 movement = GetRawMoveVector(); if (Mathf.Approximately(movement.x, 0f) && Mathf.Approximately(movement.y, 0f)) { m_ConsecutiveMoveCount = 0; return(false); } // If user pressed key again, always allow event bool allow = MyInput.GetButtonDown(m_HorizontalAxis) || MyInput.GetButtonDown(m_VerticalAxis); bool similarDir = (Vector2.Dot(movement, m_LastMoveVector) > 0); if (!allow) { // Otherwise, user held down key or axis. // If direction didn't change at least 90 degrees, wait for delay before allowing consequtive event. if (similarDir && m_ConsecutiveMoveCount == 1) { allow = (time > m_PrevActionTime + m_RepeatDelay); } // If direction changed at least 90 degree, or we already had the delay, repeat at repeat rate. else { allow = (time > m_PrevActionTime + 1f / m_InputActionsPerSecond); } } if (!allow) { return(false); } // Debug.Log(m_ProcessingEvent.rawType + " axis:" + m_AllowAxisEvents + " value:" + "(" + x + "," + y + ")"); var axisEventData = GetAxisEventData(movement.x, movement.y, 0.6f); if (axisEventData.moveDir != MoveDirection.None) { ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisEventData, ExecuteEvents.moveHandler); if (!similarDir) { m_ConsecutiveMoveCount = 0; } m_ConsecutiveMoveCount++; m_PrevActionTime = time; m_LastMoveVector = movement; } else { m_ConsecutiveMoveCount = 0; } return(axisEventData.used); }
public void Update() { if (Semih_Network.InLobbyScene) { return; } if (MyInput.GetButtonDown("Sprint")) { sprinted = !sprinted; if (sprinted) { if (RAPI.GetLocalPlayer().PersonController.controllerType != ControllerType.Water) { return; } float sS = 1f; sS *= (RAPI.GetLocalPlayer().PlayerEquipment.GetEquipedIndexes().Contains(63) ? 1.4f : 1f); if (sS == 1f) { sS = 0f; } theSpeed = RAPI.GetLocalPlayer().PersonController.swimSpeed; if (RAPI.GetLocalPlayer().PersonController.swimSpeed > 10) { FindObjectOfType <HNotify>().AddNotification(HNotify.NotificationType.normal, "Swim Sprint : You can't actually Sprint when your swimming speed is more than the sprint itself ;-;", 2, HNotify.ErrorSprite).SetCloseDelay(2).SetTextColor(Color.red); return; } else if (RAPI.GetLocalPlayer().PersonController.swimSpeed > 2 && RAPI.GetLocalPlayer().PersonController.swimSpeed < 10) { RAPI.GetLocalPlayer().PersonController.swimSpeed = 10 + sS; RAPI.GetLocalPlayer().PersonController.swimSpeed = (2 * 5) + sS; GameModeValueManager.GetCurrentGameModeValue().nourishmentVariables.foodDecrementRateMultiplier = 1.2f; GameModeValueManager.GetCurrentGameModeValue().nourishmentVariables.thirstDecrementRateMultiplier = 1.2f; RAPI.GetLocalPlayer().Stats.stat_oxygen.SetOxygenLostPerSecond(1.25f); return; } RAPI.GetLocalPlayer().PersonController.swimSpeed = 10 + sS; GameModeValueManager.GetCurrentGameModeValue().nourishmentVariables.foodDecrementRateMultiplier = 1.3f; GameModeValueManager.GetCurrentGameModeValue().nourishmentVariables.thirstDecrementRateMultiplier = 1.3f; RAPI.GetLocalPlayer().Stats.stat_oxygen.SetOxygenLostPerSecond(1.5f); } } else if (MyInput.GetButtonUp("Sprint")) { sprinted = !sprinted; if (theSpeed < 2) { theSpeed = 2; } RAPI.GetLocalPlayer().PersonController.swimSpeed = theSpeed; GameModeValueManager.GetCurrentGameModeValue().nourishmentVariables.foodDecrementRateMultiplier = 1f; GameModeValueManager.GetCurrentGameModeValue().nourishmentVariables.thirstDecrementRateMultiplier = 1f; RAPI.GetLocalPlayer().Stats.stat_oxygen.SetOxygenLostPerSecond(1f); } }
private static bool Prefix ( SteeringWheel __instance, ref bool ___hasBeenPlaced, ref bool ___isDisplayingText, DisplayTextManager ___displayText, ref Network_Player ___localPlayer, ref Semih_Network ___network ) { if (!___hasBeenPlaced) { return(true); } if (MyInput.GetButton("Sprint")) { ___isDisplayingText = true; ___displayText.ShowText("Toggle Engines", MyInput.Keybinds["Interact"].MainKey, 1, "Toggle Engine Direction", MyInput.Keybinds["Rotate"].MainKey, 2); if (MyInput.GetButtonDown("Interact")) { MoreSailsMoreSpeed.ToggleAllEngines(); } if (MyInput.GetButtonDown("Rotate")) { MoreSailsMoreSpeed.ToggleAllEnginesDir(); } } else { ___isDisplayingText = true; ___displayText.ShowText("Hold for more options", MyInput.Keybinds["Sprint"].MainKey, 1, Helper.GetTerm("Game/RotateSmooth2", false), MyInput.Keybinds["Rotate"].MainKey, 2); if (MyInput.GetButtonDown("Rotate")) { ___localPlayer.PlayerScript.SetMouseLookScripts(false); } if (MyInput.GetButtonUp("Rotate")) { ___localPlayer.PlayerScript.SetMouseLookScripts(true); } if (MyInput.GetButton("Rotate")) { float axis = Input.GetAxis("Mouse X"); Message_SteeringWheel_Rotate message = new Message_SteeringWheel_Rotate(Messages.SteeringWheelRotate, ___network.NetworkIDManager, __instance.ObjectIndex, axis); if (Semih_Network.IsHost) { AccessTools.Method("SteeringWheel:Rotate").Invoke(__instance, new object[] { axis }); return(false); } ___network.SendP2P(___network.HostID, message, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game); } } return(false); }
private void Update() { if (GameManager.instance.input_active && player.can_input) { if (MyInput.GetButton("Attack")) { bool skill_used = ProcessSkillButton(MyInput.GetAxis("Attack"), 0); if (skill_used) { MyInput.ClearBuffer("Attack"); } } if (MyInput.GetButtonDown("Skill1", skill_buffer)) { bool skill_used = ProcessSkillButton(MyInput.GetAxis("Skill1"), 1); if (skill_used) { MyInput.ClearBuffer("Skill1"); } } if (MyInput.GetButtonDown("Skill2", skill_buffer)) { bool skill_used = ProcessSkillButton(MyInput.GetAxis("Skill2"), 2); if (skill_used) { MyInput.ClearBuffer("Skill2"); } } if (MyInput.GetButtonDown("Skill3")) { bool skill_used = ProcessSkillButton(MyInput.GetAxis("Skill3"), 3); if (skill_used) { MyInput.ClearBuffer("Skill3"); } } if (MyInput.GetButtonDown("ActiveSkill")) { if (player.inventory.active_item != null) { player.inventory.active_item.active_ability.TryUse(); } } if (MyInput.GetButtonDown("UseConsumable")) { player.inventory.TryUseConsumable(); } } input = new Vector2(MyInput.GetAxis("Horizontal"), MyInput.GetAxis("Vertical")); Move(); }
public void Update(FPSMovement movement) { // Change to idle state. if (movement.GetVelocity() < FPSConstants.BEGIN_WALK_VELOCITY) { movement.ChangeState(new FPSCharacterStateIdle()); } // Change to run state. if (MyInput.GetButtonDown("Sprint")) { movement.ChangeState(new FPSCharacterStateRun()); } }
void Update() { if (MyInput.GetButtonDown("Pause")) { TogglePause(); } if (MyInput.GetButtonDown("Select") && !is_paused) { ToggleShowInfoScreen(); } if (!is_paused && !is_select_screen_up) { game_time += GetDeltaTime(Character.Team.enemy); } }
// Update is called once per frame void Update() { if (!isLocalPlayer) { return; } if (MyInput.GetButtonDown("Fire1")) { CmdBeginShoot(); } if (MyInput.GetButtonUp("Fire1")) { CmdEndShoot(); } }
private static bool Prefix ( // ReSharper disable InconsistentNaming ItemNet __instance, CanvasHelper ___canvas, ref bool ___displayText) // ReSharper restore InconsistentNaming { // This overrides the original logic. // If the internal logic is changed in the future, this has to change aswell. if (!Helper.LocalPlayerIsWithinDistance( __instance.transform.position, Player.UseDistance)) { // Not within use distance, run old logic return(true); } if (MyInput.GetButtonDown("Rotate")) { ToggleFilterModeForNet(__instance); } ___displayText = true; var toggleFilterText = string.Format("Toggle net filter ({0})", GetCurrentFilter(__instance)); if (__instance.itemCollector.collectedItems.Count > 0) { ___canvas.displayTextManager.HideDisplayTexts(); LocalizationParameters.itemCount = __instance.itemCollector.collectedItems.Count; ___canvas.displayTextManager.ShowText( toggleFilterText, MyInput.Keybinds["Rotate"].MainKey, 1, Helper.GetTerm("Game/CollectItemCount", true), MyInput.Keybinds["Interact"].MainKey, 2); } else { ___canvas.displayTextManager.ShowText( toggleFilterText, MyInput.Keybinds["Rotate"].MainKey, 1); } // skip original logic return(false); }
static bool Prefix(Sail __instance, ref CanvasHelper ___canvas, ref Network_Player ___localPlayer) { if (!MyInput.GetButton("Sprint")) { return(true); } if (Helper.LocalPlayerIsWithinDistance(__instance.transform.position, Player.UseDistance) && CanvasHelper.ActiveMenu == MenuType.None) { if (MyInput.GetButtonDown("Interact")) { if (Semih_Network.IsHost) { if (__instance.open) { MoreSailsMoreSpeedMod.SailsClose(); } else { MoreSailsMoreSpeedMod.SailsOpen(); } } } if (MyInput.GetButton("Rotate")) { if (___localPlayer.PlayerScript.MouseLookIsActive()) { ___localPlayer.PlayerScript.SetMouseLookScripts(false); } MoreSailsMoreSpeedMod.SailsRotate(Input.GetAxis("Mouse X"), __instance); } else if (MyInput.GetButtonUp("Rotate")) { ___localPlayer.PlayerScript.SetMouseLookScripts(true); } return(false); } else { ___canvas.displayTextManager.HideDisplayTexts(); } return(false); }
/// <summary> /// Process submit keys. /// </summary> protected bool SendSubmitEventToSelectedObject() { if (eventSystem.currentSelectedGameObject == null) { return(false); } var data = GetBaseEventData(); if (MyInput.GetButtonDown(m_SubmitButton)) { ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.submitHandler); } if (MyInput.GetButtonDown(m_CancelButton)) { ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.cancelHandler); } return(data.used); }
public override bool ShouldActivateModule() { if (!base.ShouldActivateModule()) { return(false); } var shouldActivate = m_ForceModuleActive; shouldActivate |= MyInput.GetButtonDown(m_SubmitButton); shouldActivate |= MyInput.GetButtonDown(m_CancelButton); shouldActivate |= !Mathf.Approximately(MyInput.GetAxisRaw(m_HorizontalAxis), 0.0f); shouldActivate |= !Mathf.Approximately(MyInput.GetAxisRaw(m_VerticalAxis), 0.0f); shouldActivate |= (m_MousePosition - m_LastMousePosition).sqrMagnitude > 0.0f; shouldActivate |= MyInput.GetMouseButtonDown(0); if (MyInput.touchCount > 0) { shouldActivate = true; } return(shouldActivate); }
// Update is called once per frame void Update() { Camera camera = Camera.main; Vector3 pos = camera.transform.position; Vector3 dir = camera.transform.TransformDirection(Vector3.forward); RaycastHit hit; if (Physics.Raycast(pos, dir, out hit, m_maxDistance, m_objectToUse)) { UsableObject usableObj = hit.collider.gameObject.GetComponent <UsableObject> (); m_messageNotifier.PushFixedMessage(usableObj.GetUseMessage()); if (MyInput.GetButtonDown("Use")) { usableObj.UseObject(); } } else { m_messageNotifier.PopFixedMessage(); } }
private void Update() { // 一時停止画面がアニメーション中は反応させない if (isAnim) { return; } // 一時停止ボタンを押した時 if (MyInput.GetButtonDown("Pause")) { // 一時停止を切り替え isPause = !isPause; // 一時停止中 if (isPause) { PauseOpen(); } // 一時停止解除 else { PauseClose(); } } }
public override void Update(GunController gun) { // To fire state. if (MyInput.GetButtonDown("Fire1") && (gun.m_fireMode != FireMode.Launcher)) { if (gun.NBullets > 0) { gun.ChangeState(new GunStateFire()); } else { GameStats._MessageNotifier.PushFloatMessage("Out of bullet"); GameStats._GunsManager.GetComponent <AudioSource>().PlayOneShot(gun.m_emptyFireSound); } } // To aim state. if (MyInput.GetButtonDown("Fire2")) { gun.ChangeState(new GunStateAim()); } // To reload state. if (MyInput.GetButtonDown("Reload") && (gun.m_fireMode != FireMode.Launcher)) { if (gun.NMagazines > 0) { gun.ChangeState(new GunStateReload()); } else { GameStats._MessageNotifier.PushFloatMessage("Out of magazine"); GameStats._GunsManager.GetComponent <AudioSource>().PlayOneShot(gun.m_emptyFireSound); } } }
public void OnIsRayed() { if (!mi_loaded) { return; } if (!mi_canvas) { mi_canvas = ComponentManager <CanvasHelper> .Value; return; } if (CanvasHelper.ActiveMenu == MenuType.None && !PlayerItemManager.IsBusy && mi_canvas.CanOpenMenu && Helper.LocalPlayerIsWithinDistance(transform.position, Player.UseDistance + 0.5f)) { mi_canvas.displayTextManager.ShowText(IsOn ? "Extinguish" : "Light", MyInput.Keybinds["Interact"].MainKey, 0, 0, true); if (MyInput.GetButtonDown("Interact")) { UserControlsState = true; SetLightOn(!IsOn); var netMsg = new Message_Battery_OnOff( Messages.Battery_OnOff, RAPI.GetLocalPlayer().Network.NetworkIDManager, RAPI.GetLocalPlayer().steamID, ObjectIndex, (int)ELanternRequestType.TOGGLE, IsOn); if (Semih_Network.IsHost) { mi_network.RPC(netMsg, Target.Other, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game); return; } mi_network.SendP2P(mi_network.HostID, netMsg, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game); return; } if (UserControlsState && Input.GetKeyDown(KeyCode.F)) { var notifier = ComponentManager <HNotify> .Value; var notification = notifier.AddNotification(HNotify.NotificationType.normal, "Automatic light behaviour restored.", 5); notification.Show(); UserControlsState = false; CheckLightState(true); var netMsg = new Message_Battery_OnOff( Messages.Battery_OnOff, RAPI.GetLocalPlayer().Network.NetworkIDManager, RAPI.GetLocalPlayer().steamID, ObjectIndex, (int)ELanternRequestType.RELEASE_AUTO, //indicate to receiving side that we want to switch back to auto control IsOn); if (Semih_Network.IsHost) { mi_network.RPC(netMsg, Target.Other, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game); return; } mi_network.SendP2P(mi_network.HostID, netMsg, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game); } } else { mi_canvas.displayTextManager.HideDisplayTexts(); } }
public void OnIsRayed() { if (IsKill) { return; } wasRayed = true; if (displayText == null) { displayText = ComponentManager <DisplayTextManager> .Value; if (displayText == null) { return; } } if (CanvasHelper.ActiveMenu != MenuType.None || PlayerItemManager.IsBusy || !Helper.LocalPlayerIsWithinDistance(transform.position, Player.UseDistance)) { displayText.HideDisplayTexts(); return; } var recipeName = recipeUI.Recipe.Result.settings_Inventory.DisplayName; if (cookingPot == null) { displayText.ShowText($"{recipeName}\nNo cookingpot in proximity", 0, true, 0); return; } if (!preparationCalculated) { CalculatePreparation(); } var missingItems = originalTMPLabelColors.Count + originalLabelColors.Count; if (missingItems > 0) { displayText.ShowText($"{recipeName}\nMissing {missingItems} ingredients", 0, true, 0); return; } if (wrongOrFreeSlots.Count != unpreparedIngredients.Count) { Debug.Log($"{recipeName}: There are {wrongOrFreeSlots.Count} slots that should be replaced, but there is actually {unpreparedIngredients.Count} items that needs to be placed"); displayText.ShowText($"{recipeName}\nUnable to auto-prepare, check logs", 0, true, 0); return; } if (unpreparedIngredients.Count == 0) { if (cookingPot.CurrentRecipe != null) { displayText.ShowText($"{recipeName}\nPrepared, but cookingpot is busy", 0, true, 0); } else if (cookingPot.Fuel.GetFuelCount() == 0) { displayText.ShowText($"{recipeName}\nNo fuel in cookingpot", 0, true, 0); } else { displayText.ShowText($"{recipeName}\nStart cooking", MyInput.Keybinds["Interact"].MainKey, 0, 0, true); if (MyInput.GetButtonDown("Interact")) { Traverse.Create(cookingPot).Method("HandleStartCooking").GetValue(); ClearPreparation(); } } return; } displayText.ShowText($"{recipeName}\nPrepare", MyInput.Keybinds["Interact"].MainKey, 0, 0, true); if (MyInput.GetButtonDown("Interact")) { // ToList() because our SetItem()/ClearItem() hooks will trigger // OrderBy() because it's fun to have the ingredients shuffled :) foreach ((var slot, var item) in wrongOrFreeSlots.Zip(unpreparedIngredients.OrderBy(_ => Guid.NewGuid()), (slot, item) => (slot, item)).ToList()) { if (slot.HasItem) { slot.OnPickupItem(cookingPot.localPlayer, slot, slot.CurrentItem); } if (!Traverse.Create(slot).Field <ItemObjectEnabler>("objectEnabler").Value.DoesAcceptItem(item)) { Debug.Log($"{recipeName}: The item \"{item.UniqueName}\" can not be placed in cooking pot slot"); } else { var itemInstance = new ItemInstance(item, 1, item.MaxUses); slot.OnInsertItem(cookingPot.localPlayer, slot, itemInstance); } } ClearPreparation(); } }
public void Update() { if (!(Semih_Network.InLobbyScene)) { if (loaded) { currentItem = " "; if (!player.Inventory.GetSelectedHotbarSlot().IsEmpty) { currentItem = player.Inventory.GetSelectedHotbarItem().settings_Inventory.DisplayName; } if (currentItem == "Fertilizer") { RaycastHit hit; if (Physics.Raycast(player.CameraTransform.position, player.CameraTransform.forward, out hit, Player.UseDistance, layerMask)) { if (hit.transform.gameObject.name == "Placeable_Cropplot_Small_Floor(Clone)" || hit.transform.gameObject.name == "Placeable_Cropplot_Medium_Floor(Clone)" || hit.transform.gameObject.name == "Placeable_Cropplot_Large(Clone)" || hit.transform.gameObject.name == "Placeable_Cropplot_Small_Wall(Clone)") { Plant clsPlant = null; float minDist = Mathf.Infinity; foreach (var plants in hit.transform.gameObject.GetComponent <Cropplot>().plantationSlots) { if (hit.transform.gameObject.GetComponent <fertilzing>() != null) { if (plants.hasWater && plants.busy && !(hit.transform.gameObject.GetComponent <fertilzing>().toFertilize.Contains(plants.plant))) { float dist = Vector3.Distance(plants.transform.position, hit.point); if (dist < minDist) { if (plants.plant.FullyGrown()) { clsPlant = plants.plant; } minDist = dist; } } } if (plants.hasWater && plants.busy) { float dist = Vector3.Distance(plants.transform.position, hit.point); if (dist < minDist) { if (!plants.plant.FullyGrown()) { clsPlant = plants.plant; } minDist = dist; } } } if (clsPlant != null) { if (player.Inventory.GetSelectedHotbarItem().settings_Inventory.DisplayName == "Fertilizer") { canvas.displayTextManager.ShowText("Use the fertlizer", MyInput.Keybinds["Interact"].MainKey, 0, 0, true); } else { canvas.displayTextManager.HideDisplayTexts(); } if (MyInput.GetButtonDown("Interact")) { RAPI.GetLocalPlayer().Inventory.GetSelectedHotbarSlot().RemoveItem(1); if (hit.transform.gameObject.GetComponent <fertilzing>() != null) { addPlant(hit); } else { addFertilizeFirstTime(hit); } } } } } } } MessageHandler.ReadP2P_Channel_Fertilizer(); } }
private static bool Prefix ( Sail __instance, ref bool ___blockPlaced, ref Network_Player ___localPlayer, ref CanvasHelper ___canvas, ref bool ___isRotating, ref GameObject ___paintCollider, ref Semih_Network ___network ) { if (!___blockPlaced) { return(false); } if (___canvas == null || ___canvas.displayTextManager == null || ___localPlayer == null) { return(false); } if (Helper.LocalPlayerIsWithinDistance(__instance.transform.position, Player.UseDistance) && CanvasHelper.ActiveMenu == MenuType.None) { bool mod = MyInput.GetButton("Sprint"); if (!__instance.open) { if (mod) { ___canvas.displayTextManager.ShowText("Open Sails", MyInput.Keybinds["Interact"].MainKey, 1, "Rotate Sails", MyInput.Keybinds["Rotate"].MainKey, 2); } else { ___canvas.displayTextManager.ShowText("Hold for more options", MyInput.Keybinds["Sprint"].MainKey, 1, "Open", MyInput.Keybinds["Interact"].MainKey, 2, 0, true); ___canvas.displayTextManager.ShowText("Rotate", MyInput.Keybinds["Rotate"].MainKey, 3, 0, false); } } else { if (mod) { ___canvas.displayTextManager.ShowText("Close Sails", MyInput.Keybinds["Interact"].MainKey, 1, "Rotate Sails", MyInput.Keybinds["Rotate"].MainKey, 2); } else { ___canvas.displayTextManager.ShowText("Hold for more options", MyInput.Keybinds["Sprint"].MainKey, 1, "Close", MyInput.Keybinds["Interact"].MainKey, 2, 0, true); ___canvas.displayTextManager.ShowText("Rotate", MyInput.Keybinds["Rotate"].MainKey, 3, 0, false); } } if (MyInput.GetButtonDown("Interact")) { Message_NetworkBehaviour message = new Message_NetworkBehaviour(__instance.open ? Messages.Sail_Close : Messages.Sail_Open, __instance); if (Semih_Network.IsHost) { if (__instance.open) { if (mod) { MoreSailsMoreSpeed.SailsClose(); } else { AccessTools.Method("Sail:Close").Invoke(__instance, null); } } else { if (mod) { MoreSailsMoreSpeed.SailsOpen(); } else { AccessTools.Method("Sail:Open").Invoke(__instance, null); } } ___network.RPC(message, Target.Other, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game); } else { ___network.SendP2P(___network.HostID, message, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game); } } if (MyInput.GetButton("Rotate")) { ___localPlayer.PlayerScript.SetMouseLookScripts(false); ___isRotating = true; } else if (MyInput.GetButtonUp("Rotate")) { if (mod) { MoreSailsMoreSpeed.RotateSailsTo(__instance); } ___localPlayer.PlayerScript.SetMouseLookScripts(true); ___isRotating = false; } if (MyInput.GetButtonUp("Sprint") && ___isRotating) { MoreSailsMoreSpeed.RotateSailsTo(__instance); ___localPlayer.PlayerScript.SetMouseLookScripts(true); ___isRotating = false; return(false); } bool button = MyInput.GetButton("Rotate"); if (button) { float axis = Input.GetAxis("Mouse X"); if (Semih_Network.IsHost) { AccessTools.Method("Sail:Rotate").Invoke(__instance, new object[] { axis }); } else { Message_Sail_Rotate message2 = new Message_Sail_Rotate(Messages.Sail_Rotate, __instance, axis); ___network.SendP2P(___network.HostID, message2, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game); } } ___paintCollider.SetActiveSafe(!button); return(false); } if (___isRotating) { ___isRotating = false; ___localPlayer.PlayerScript.SetMouseLookScripts(true); } ___canvas.displayTextManager.HideDisplayTexts(); return(false); }