Ejemplo n.º 1
0
    public static NetworkInterfaceResponse HandleNetworkCommand(Player player, NetworkInterfaceCommand nic)
    {
        Mk2Excavator machine = nic.target as Mk2Excavator;
        string       key     = nic.command;

        if (key != null)
        {
            int data;
            if (key == "AlterHeight")
            {
                int.TryParse(nic.payload ?? "1", out data);
                Mk2ExcavatorWindow.AlterHeight(machine, data);
            }
            else if (key == "AlterRadius")
            {
                int.TryParse(nic.payload ?? "1", out data);
                Mk2ExcavatorWindow.AlterRadius(machine, data);
            }
            else if (key == "AlterDigState")
            {
                Mk2ExcavatorWindow.AlterDigState(machine, nic.payload);
            }
            else if (key == "AlterDropState")
            {
                Mk2ExcavatorWindow.AlterDropState(machine, nic.payload);
            }
            else if (key == "SuperOPMode")
            {
                int.TryParse(nic.payload ?? "1", out data);
                Mk2ExcavatorWindow.SuperOPMode(machine, data);
            }
            else if (key == "MutePews")
            {
                int.TryParse(nic.payload ?? "1", out data);
                Mk2ExcavatorWindow.MutePews(machine, data);
            }
        }
        return(new NetworkInterfaceResponse()
        {
            entity = (SegmentEntity)machine,
            inventory = player.mInventory
        });
    }
Ejemplo n.º 2
0
    public override string GetPopupText()
    {
        ushort selectBlockType = WorldScript.instance.localPlayerInstance.mPlayerBlockPicker.selectBlockType;
        bool   flag            = (int)selectBlockType == this.GetCubeType("FlexibleGames.Mk2Excavator");

        if (flag)
        {
            Mk2Excavator lmk2Excavator =
                (Mk2Excavator)WorldScript.instance.localPlayerInstance.mPlayerBlockPicker.selectedEntity;
            bool flag2 = lmk2Excavator != null;
            if (flag2)
            {
                bool allowMovement = Mk2Excavator.AllowMovement;
                if (allowMovement)
                {
                    bool flag18 = Input.GetKeyDown(KeyCode.Q); //.GetButton("Extract");
                    if (flag18)
                    {
                        this.mfCommandDebounce += LowFrequencyThread.mrPreviousUpdateTimeStep;
                        //Debug.LogWarning("Q pressed, Debounce = " + mfCommandDebounce);
                        if (mfCommandDebounce >= 0.2f)
                        {
                            AudioHUDManager.instance.HUDOut();
                            //Mk2Excavator.ForceNGUIUpdate = 0.1f;
                            ChangeFireMode();
                            if (!WorldScript.mbIsServer)
                            {
                                string digstate;
                                switch (this.eExcavateState)
                                {
                                case ExcavateState.ClearAll:
                                    digstate = "ClearAll";
                                    break;

                                case ExcavateState.ClearGarbage:
                                    digstate = "ClearGarbage";
                                    break;

                                case ExcavateState.ClearOre:
                                    digstate = "ClearOre";
                                    break;

                                default:
                                    digstate = "Error";
                                    break;
                                }

                                Mk2ExcavatorWindow.AlterDigState(this, digstate);
                                //NetworkManager.instance.SendInterfaceCommand("FlexibleGames.Mk2ExcavatorWindow", "AlterDigState", digstate, null, this, 0.0f);
                            }

                            UIManager.ForceNGUIUpdate = 0.1f;
                            mfCommandDebounce         = 0f;
                        }
                    }

                    bool interactkey = Input.GetKeyDown(KeyCode.T); //.GetButton("Extract");
                    if (interactkey)
                    {
                        this.mfCommandDebounce += LowFrequencyThread.mrPreviousUpdateTimeStep;
                        // Debug.LogWarning("T pressed, Debounce = " + mfCommandDebounce);
                        if (this.mfCommandDebounce >= 0.2f)
                        {
                            AudioHUDManager.instance.HUDOut();
                            //this.mbDoDropBlocks = !this.mbDoDropBlocks;
                            ChangeDropMode();
                            if (!WorldScript.mbIsServer)
                            {
                                string dropstate;
                                switch (this.eDropState)
                                {
                                case DropState.DropAll:
                                    dropstate = "DropAll";
                                    break;

                                case DropState.DropNone:
                                    dropstate = "DropNone";
                                    break;

                                case DropState.DropOre:
                                    dropstate = "DropOre";
                                    break;

                                case DropState.DropSome:
                                    dropstate = "DropSome";
                                    break;

                                default:
                                    dropstate = "Error";
                                    break;
                                }

                                Mk2ExcavatorWindow.AlterDropState(this, dropstate);
                                //NetworkManager.instance.SendInterfaceCommand("FlexibleGames.Mk2ExcavatorWindow", "AlterDropState", dropstate, null, this, 0.0f);
                            }

                            UIManager.ForceNGUIUpdate = 0.1f;
                            mfCommandDebounce         = 0f;
                        }
                    }

                    bool lshiftkey = Input.GetKey(KeyCode.LeftShift);
                    bool rshiftkey = Input.GetKey(KeyCode.RightShift);

                    bool radiusupkey = Input.GetKeyDown(KeyCode.Home);
                    bool superOPkey  = Input.GetKeyDown(KeyCode.O);
                    if ((lshiftkey || rshiftkey) && superOPkey)
                    {
                        this.mfCommandDebounce += LowFrequencyThread.mrPreviousUpdateTimeStep;
                        if (this.mfCommandDebounce >= 0.2f)
                        {
                            superOPflag = !superOPflag;
                            AudioHUDManager.instance.HUDOut();
                            Mk2ExcavatorWindow.SuperOPMode(this, superOPflag ? 1 : 0);
                            UIManager.ForceNGUIUpdate = 0.1f;
                            mfCommandDebounce         = 0f;
                        }
                    }

                    if (radiusupkey)
                    {
                        this.mfCommandDebounce += LowFrequencyThread.mrPreviousUpdateTimeStep;
                        //GameManager.DoLocalChat("HomeKey Pressed: mnDigSizeX was " + this.mnDigSizeX);
                        if (this.mfCommandDebounce >= 0.2f)
                        {
                            AudioHUDManager.instance.HUDOut();
                            if (this.mnDigSizeX < 1024)
                            {
                                if (lshiftkey || rshiftkey)
                                {
                                    this.mnDigSizeX += 10;
                                    this.mnDigSizeZ += 10;
                                }
                                else
                                {
                                    this.mnDigSizeX++;
                                    this.mnDigSizeZ++;
                                }

                                Mk2ExcavatorWindow.AlterRadius(this, mnDigSizeX);
                                //if (!WorldScript.mbIsServer)
                                //    NetworkManager.instance.SendInterfaceCommand("FlexibleGames.Mk2ExcavatorWindow", "AlterRadius", mnDigSizeX.ToString(), null, this, 0.0f);
                                //GameManager.DoLocalChat("HomeKey Pressed: mnDigSizeX now " + this.mnDigSizeX);
                            }

                            UIManager.ForceNGUIUpdate = 0.1f;
                            mfCommandDebounce         = 0f;
                        }
                    }

                    bool radiusdownkey = Input.GetKeyDown(KeyCode.End);
                    if (radiusdownkey)
                    {
                        this.mfCommandDebounce += LowFrequencyThread.mrPreviousUpdateTimeStep;
                        if (this.mfCommandDebounce >= 0.2f)
                        {
                            AudioHUDManager.instance.HUDOut();
                            if (this.mnDigSizeX > 1)
                            {
                                if ((lshiftkey || rshiftkey) && mnDigSizeX > 10)
                                {
                                    this.mnDigSizeX -= 10;
                                    this.mnDigSizeZ -= 10;
                                }
                                else
                                {
                                    this.mnDigSizeX--;
                                    this.mnDigSizeZ--;
                                }

                                Mk2ExcavatorWindow.AlterRadius(this, mnDigSizeX);
                                //if (!WorldScript.mbIsServer)
                                //    NetworkManager.instance.SendInterfaceCommand("FlexibleGames.Mk2ExcavatorWindow", "AlterRadius", mnDigSizeX.ToString(), null, this, 0.0f);
                            }

                            UIManager.ForceNGUIUpdate = 0.1f;
                            mfCommandDebounce         = 0f;
                        }
                    }

                    bool heightupkey = Input.GetKey(KeyCode.KeypadPlus);
                    if (heightupkey)
                    {
                        this.mfCommandDebounce += LowFrequencyThread.mrPreviousUpdateTimeStep;
                        if (this.mfCommandDebounce >= 2.0f)
                        {
                            AudioHUDManager.instance.HUDOut();
                            if (this.mnDigSizeY < 2048)
                            {
                                if ((lshiftkey || rshiftkey) && mnDigSizeY < 2038)
                                {
                                    this.mnDigSizeY += 10;
                                }
                                else
                                {
                                    this.mnDigSizeY++;
                                }

                                Mk2ExcavatorWindow.AlterHeight(this, mnDigSizeY);
                                //if (!WorldScript.mbIsServer)
                                //    NetworkManager.instance.SendInterfaceCommand("FlexibleGames.Mk2ExcavatorWindow", "AlterHeight", mnDigSizeY.ToString(), null, this, 0.0f);
                            }

                            UIManager.ForceNGUIUpdate = 0.1f;
                            mfCommandDebounce         = 0f;
                        }
                    }

                    bool heightdownkey = Input.GetKey(KeyCode.KeypadMinus);
                    if (heightdownkey)
                    {
                        this.mfCommandDebounce += LowFrequencyThread.mrPreviousUpdateTimeStep;
                        if (this.mfCommandDebounce >= 2.0f)
                        {
                            AudioHUDManager.instance.HUDOut();
                            if (this.mnDigSizeY > 4)
                            {
                                if ((lshiftkey || rshiftkey) && mnDigSizeY > 14)
                                {
                                    this.mnDigSizeY -= 10;
                                }
                                else
                                {
                                    this.mnDigSizeY--;
                                }

                                Mk2ExcavatorWindow.AlterHeight(this, mnDigSizeY);
                                //if (!WorldScript.mbIsServer)
                                //    NetworkManager.instance.SendInterfaceCommand("FlexibleGames.Mk2ExcavatorWindow", "AlterHeight", mnDigSizeY.ToString(), null, this, 0.0f);
                            }

                            UIManager.ForceNGUIUpdate = 0.1f;
                            mfCommandDebounce         = 0f;
                        }
                    }

                    bool mutekey = Input.GetKeyDown(KeyCode.J);
                    if (mutekey)
                    {
                        this.mfCommandDebounce += LowFrequencyThread.mrPreviousUpdateTimeStep;
                        if (this.mfCommandDebounce >= 0.3f)
                        {
                            mutePews = mutePews == 0 ? 1 : 0;
                            Mk2ExcavatorWindow.MutePews(this, mutePews);
                            AudioHUDManager.instance.HUDOut();
                            UIManager.ForceNGUIUpdate = 0.1f;
                            mfCommandDebounce         = 0f;
                        }
                    }

                    if (flag18 || interactkey)
                    {
                        MarkDirtyDelayed();
                    }

                    if (radiusupkey || radiusdownkey || heightdownkey || heightupkey || superOPkey || mutekey)
                    {
                        this.RequestImmediateNetworkUpdate();
                        UpdateDigSettings();
                        MarkDirtyDelayed();
                    }
                }
                UIManager.ForceNGUIUpdate = 0.1f;

                var response = new StringBuilder();
                response.AppendLine("Mk2 Excavator v" + mModVersion + (mutePews == 1 ? " muted" : ""));
                response.AppendLine(mnTotalBlocksScanned + " Blocks Scanned");
                response.AppendLine((PercentScanned * 100) + "% complete " + (superOPflag ? "@.@" : ""));
                response.AppendLine(mrCurrentPower + "/" + mrMaxPower + " power");
                response.AppendLine("(Q)Clear mode: Currently: " + eExcavateState);
                response.AppendLine("(T)Drop mode: Currently: " + eDropState);
                response.AppendLine("(Shift) (Home/End) Radius: " + mnDigSizeX);
                response.AppendLine("(Shift) Numpad (+/-) Height: " + mnDigSizeY);
                PopUpText = response.ToString();
            }
        }

        return(PopUpText);
    }