示例#1
0
        private void HandleInput()
        {
            if (this.handleInputFrame == Time.frameCount)
            {
                return;
            }
            this.handleInputFrame = Time.frameCount;
            if (!AvatarInputHandler.main.IsEnabled())
            {
                return;
            }
            bool flag = this.TryDisplayNoPowerTooltip();

            if (flag)
            {
                return;
            }
            Targeting.AddToIgnoreList(Player.main.gameObject);
            Targeting.AddToIgnoreList(thisVehicle.gameObject);
            GameObject gameObject;
            float      num;

            Targeting.GetTarget(null, 60f, out gameObject, out num);
            if (gameObject == null)
            {
                return;
            }
            bool          buttonHeld    = GameInput.GetButtonHeld(GameInput.Button.AltTool);
            bool          buttonDown    = GameInput.GetButtonDown(GameInput.Button.Deconstruct);
            bool          buttonHeld2   = GameInput.GetButtonHeld(GameInput.Button.Deconstruct);
            bool          quickbuild    = GameInput.GetButtonHeld(GameInput.Button.Sprint);
            Constructable constructable = gameObject.GetComponentInParent <Constructable>();

            if (constructable != null && num > constructable.placeMaxDistance * 4)
            {
                constructable = null;
            }
            if (constructable != null)
            {
                this.OnHover(constructable);
                string text;
                if (buttonHeld)
                {
                    this.Construct(constructable, true);
                    if (quickbuild)
                    {
                        this.Construct(constructable, true);
                        this.Construct(constructable, true);
                        this.Construct(constructable, true);
                    }
                }
                else if (constructable.DeconstructionAllowed(out text))
                {
                    if (buttonHeld2)
                    {
                        if (constructable.constructed)
                        {
                            constructable.SetState(false, false);
                        }
                        else
                        {
                            this.Construct(constructable, false);
                            if (quickbuild)
                            {
                                this.Construct(constructable, false);
                                this.Construct(constructable, false);
                                this.Construct(constructable, false);
                            }
                        }
                    }
                }
                else if (buttonDown && !string.IsNullOrEmpty(text))
                {
                    ErrorMessage.AddMessage(text);
                }
            }
            else
            {
                BaseDeconstructable baseDeconstructable = gameObject.GetComponentInParent <BaseDeconstructable>();
                if (baseDeconstructable == null)
                {
                    BaseExplicitFace componentInParent = gameObject.GetComponentInParent <BaseExplicitFace>();
                    if (componentInParent != null)
                    {
                        baseDeconstructable = componentInParent.parent;
                    }
                }
                else
                {
                    string text;
                    if (baseDeconstructable.DeconstructionAllowed(out text))
                    {
                        this.OnHover(baseDeconstructable);
                        if (buttonDown)
                        {
                            baseDeconstructable.Deconstruct();
                            if (quickbuild)
                            {
                                baseDeconstructable.Deconstruct();
                                baseDeconstructable.Deconstruct();
                                baseDeconstructable.Deconstruct();
                            }
                        }
                    }
                    else if (buttonDown && !string.IsNullOrEmpty(text))
                    {
                        ErrorMessage.AddMessage(text);
                    }
                }
            }
        }
示例#2
0
        //=====================================================================
        // HandleInput
        //
        // Called by Update. Checks for input events and operates the Builder
        // accordingly
        //=====================================================================
        private void HandleInput()
        {
            if (this.handleInputFrame == Time.frameCount)
            {
                return;
            }
            this.handleInputFrame = Time.frameCount;
            if (Builder.isPlacing || !AvatarInputHandler.main.IsEnabled())
            {
                return;
            }
            Targeting.AddToIgnoreList(Player.main.gameObject);
            GameObject gameObject;
            float      num;

            // Range increased to 40 to give the seamoth more room
            Targeting.GetTarget(hitRange, out gameObject, out num, null);
            if (gameObject == null)
            {
                return;
            }
            // Bring up the construct menu on alt tool use
            //      (because the seamoth has lights bound to right hand)
            if (GameInput.GetButtonDown(GameInput.Button.AltTool))
            {
                uGUI_BuilderMenu.Show();
                return;
            }
            bool          constructHeld   = GameInput.GetButtonHeld(GameInput.Button.LeftHand);
            bool          deconstructDown = GameInput.GetButtonDown(GameInput.Button.Deconstruct);
            bool          deconstructHeld = GameInput.GetButtonHeld(GameInput.Button.Deconstruct);
            Constructable constructable   = gameObject.GetComponentInParent <Constructable>();

            if (constructable != null && num > constructable.placeMaxDistance)
            {
                constructable = null;
            }
            if (constructable != null)
            {
                this.OnHover(constructable);
                string text;
                if (constructHeld)
                {
                    this.Construct(constructable, true);
                }
                else if (constructable.DeconstructionAllowed(out text))
                {
                    if (deconstructHeld)
                    {
                        if (constructable.constructed)
                        {
                            constructable.SetState(false, false);
                        }
                        else
                        {
                            this.Construct(constructable, false);
                        }
                    }
                }
                else if (deconstructDown && !string.IsNullOrEmpty(text))
                {
                    ErrorMessage.AddMessage(text);
                }
            }
            else
            {
                BaseDeconstructable baseDeconstructable = gameObject.GetComponentInParent <BaseDeconstructable>();
                if (baseDeconstructable == null)
                {
                    BaseExplicitFace componentInParent = gameObject.GetComponentInParent <BaseExplicitFace>();
                    if (componentInParent != null)
                    {
                        baseDeconstructable = componentInParent.parent;
                    }
                }
                if (baseDeconstructable != null)
                {
                    string text;
                    if (baseDeconstructable.DeconstructionAllowed(out text))
                    {
                        this.OnHover(baseDeconstructable);
                        if (deconstructDown)
                        {
                            baseDeconstructable.Deconstruct();
                        }
                    }
                    else if (deconstructDown && !string.IsNullOrEmpty(text))
                    {
                        ErrorMessage.AddMessage(text);
                    }
                }
            }
        }