Ejemplo n.º 1
0
 /// <summary>
 /// Mouse left button down event handler
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void MouseLeftButtonDownEventHandler(object sender, MouseButtonEventArgs e)
 {
     _rectangleManager.MouseLeftButtonDownEventHandler(e);
     _overlayManager.UpdateOverlay();
     if (_rectangleManager.RectangleWidth == 0 && _rectangleManager.RectangleHeight == 0)
     {
         _thumbManager.ShowThumbs(false);
         _displayTextManager.ShowText(false);
     }
     _isMouseLeftButtonDown = true;
 }
Ejemplo n.º 2
0
    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);
    }
Ejemplo n.º 3
0
        /// <summary>
        ///     Mouse left button down event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void MouseLeftButtonDownEventHandler(object sender, MouseButtonEventArgs e)
        {
            _rectangleManager.MouseLeftButtonDownEventHandler(e);
            _overlayManager.UpdateOverlay();

            const double tolerance = 0.00001;

            if (Math.Abs(_rectangleManager.RectangleWidth) < tolerance && Math.Abs(_rectangleManager.RectangleHeight) < tolerance)
            {
                _thumbManager.ShowThumbs(false);
                _displayTextManager.ShowText(false);
            }

            _isMouseLeftButtonDown = true;
        }
Ejemplo n.º 4
0
        public void Update()
        {
            Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            if (unixTimestamp < stopShowTextOn)
            {
                textManager.ShowText(textToShow);
                textShown = true;
            }
            else if (textShown)
            {
                textShown = false;
                textManager.HideDisplayTexts();
            }
            if (GameManager.GameMode != GameMode.None)
            {
                if (Input.GetKeyDown(KeyCode.B))
                {
                    GameManager.UseCheats = !GameManager.UseCheats;
                    stopShowTextOn        = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds + 5;
                    if (GameManager.UseCheats)
                    {
                        textToShow = "Cheatmode enabled";
                    }
                    else
                    {
                        textToShow = "Cheatmode disabled";
                    }

                    GameManager gm    = FindObjectOfType <GameManager>();
                    Cheat       cheat = gm.GetPrivateField <Cheat>("cheat");

                    if (!cheatsInited)
                    {
                        cheat.Initialize();
                        cheatsInited = true;
                    }

                    //if(cheatsActivated)
                    //{
                    //    GameManager.UseCheats = true;
                    //    cheatsActivated = false;
                    //}
                    //else
                    //{
                    //    GameManager.UseCheats = true;
                    //    cheatsActivated = true;
                    //}
                }
            }
        }
    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();
        }
    }