コード例 #1
0
        public override void Update()
        {
            if (m_inventory == null || DragHostWidget == null)
            {
                return;
            }
            WidgetInput     input      = base.Input;
            ComponentPlayer viewPlayer = GetViewPlayer();
            int             slotValue  = m_inventory.GetSlotValue(m_slotIndex);
            int             num        = Terrain.ExtractContents(slotValue);
            Block           block      = BlocksManager.Blocks[num];

            if (m_componentPlayer != null)
            {
                m_blockIconWidget.DrawBlockEnvironmentData.InWorldMatrix = m_componentPlayer.ComponentBody.Matrix;
            }
            if (m_focus && !input.Press.HasValue)
            {
                m_focus = false;
            }
            else if (input.Tap.HasValue && HitTestGlobal(input.Tap.Value) == this)
            {
                m_focus = true;
            }
            if (input.SpecialClick.HasValue && HitTestGlobal(input.SpecialClick.Value.Start) == this && HitTestGlobal(input.SpecialClick.Value.End) == this)
            {
                IInventory inventory = null;
                foreach (InventorySlotWidget item in ((ContainerWidget)base.RootWidget).AllChildren.OfType <InventorySlotWidget>())
                {
                    if (item.m_inventory != null && item.m_inventory != m_inventory && item.Input == base.Input && item.IsEnabledGlobal && item.IsVisibleGlobal)
                    {
                        inventory = item.m_inventory;
                        break;
                    }
                }
                if (inventory != null)
                {
                    int num2 = ComponentInventoryBase.FindAcquireSlotForItem(inventory, slotValue);
                    if (num2 >= 0)
                    {
                        HandleMoveItem(m_inventory, m_slotIndex, inventory, num2, m_inventory.GetSlotCount(m_slotIndex));
                    }
                }
            }
            if (input.Click.HasValue && HitTestGlobal(input.Click.Value.Start) == this && HitTestGlobal(input.Click.Value.End) == this)
            {
                bool flag = false;
                if (viewPlayer != null)
                {
                    if (viewPlayer.ComponentInput.SplitSourceInventory == m_inventory && viewPlayer.ComponentInput.SplitSourceSlotIndex == m_slotIndex)
                    {
                        viewPlayer.ComponentInput.SetSplitSourceInventoryAndSlot(null, -1);
                        flag = true;
                    }
                    else if (viewPlayer.ComponentInput.SplitSourceInventory != null)
                    {
                        flag = HandleMoveItem(viewPlayer.ComponentInput.SplitSourceInventory, viewPlayer.ComponentInput.SplitSourceSlotIndex, m_inventory, m_slotIndex, 1);
                        AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                    }
                }
                if (!flag && m_inventory.ActiveSlotIndex != m_slotIndex && m_slotIndex < 10)
                {
                    m_inventory.ActiveSlotIndex = m_slotIndex;
                    if (m_inventory.ActiveSlotIndex == m_slotIndex)
                    {
                        AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                    }
                }
            }
            if (!m_focus || ProcessingOnly || viewPlayer == null)
            {
                return;
            }
            Vector2?hold = input.Hold;

            if (hold.HasValue && HitTestGlobal(hold.Value) == this && !DragHostWidget.IsDragInProgress && m_inventory.GetSlotCount(m_slotIndex) > 0 && (viewPlayer.ComponentInput.SplitSourceInventory != m_inventory || viewPlayer.ComponentInput.SplitSourceSlotIndex != m_slotIndex))
            {
                input.Clear();
                viewPlayer.ComponentInput.SetSplitSourceInventoryAndSlot(m_inventory, m_slotIndex);
                AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
            }
            Vector2?drag = input.Drag;

            if (!drag.HasValue || HitTestGlobal(drag.Value) != this || DragHostWidget.IsDragInProgress)
            {
                return;
            }
            int slotCount = m_inventory.GetSlotCount(m_slotIndex);

            if (slotCount > 0)
            {
                DragMode dragMode = input.DragMode;
                if (viewPlayer.ComponentInput.SplitSourceInventory == m_inventory && viewPlayer.ComponentInput.SplitSourceSlotIndex == m_slotIndex)
                {
                    dragMode = DragMode.SingleItem;
                }
                int num3 = (dragMode != 0) ? 1 : slotCount;
                SubsystemTerrain subsystemTerrain = m_inventory.Project.FindSubsystem <SubsystemTerrain>();
                ContainerWidget  containerWidget  = (ContainerWidget)Widget.LoadWidget(null, ContentManager.Get <XElement>("Widgets/InventoryDragWidget"), null);
                containerWidget.Children.Find <BlockIconWidget>("InventoryDragWidget.Icon").Value = Terrain.ReplaceLight(slotValue, 15);
                containerWidget.Children.Find <BlockIconWidget>("InventoryDragWidget.Icon").DrawBlockEnvironmentData.SubsystemTerrain = subsystemTerrain;
                containerWidget.Children.Find <LabelWidget>("InventoryDragWidget.Name").Text       = block.GetDisplayName(subsystemTerrain, slotValue);
                containerWidget.Children.Find <LabelWidget>("InventoryDragWidget.Count").Text      = num3.ToString();
                containerWidget.Children.Find <LabelWidget>("InventoryDragWidget.Count").IsVisible = (!(m_inventory is ComponentCreativeInventory) && !(m_inventory is ComponentFurnitureInventory));
                DragHostWidget.BeginDrag(containerWidget, new InventoryDragData
                {
                    Inventory = m_inventory,
                    SlotIndex = m_slotIndex,
                    DragMode  = dragMode
                }, delegate
                {
                    m_dragMode = null;
                });
                m_dragMode = dragMode;
            }
        }
コード例 #2
0
ファイル: ComponentNGui.cs プロジェクト: Lixue9jiu/SCIE
        public new void HandleInput()
        {
            WidgetInput    input          = m_componentPlayer.View.Input;
            PlayerInput    playerInput    = m_componentPlayer.ComponentInput.PlayerInput;
            ComponentRider componentRider = m_componentPlayer.ComponentRider;

            if (m_componentPlayer.View.ActiveCamera.IsEntityControlEnabled)
            {
                if (!m_keyboardHelpMessageShown && (m_componentPlayer.PlayerData.InputDevice & WidgetInputDevice.Keyboard) != 0 && Time.PeriodicEvent(7.0, 0.0))
                {
                    m_keyboardHelpMessageShown = true;
                    DisplaySmallMessage(Utils.Get("按 H 键查看键盘控制帮助\n(或看帮助)"), true, true);
                }
                else if (!m_gamepadHelpMessageShown && (m_componentPlayer.PlayerData.InputDevice & WidgetInputDevice.Gamepads) != 0 && Time.PeriodicEvent(7.0, 0.0))
                {
                    m_gamepadHelpMessageShown = true;
                    DisplaySmallMessage(Utils.Get("按 START/PAUSE 键查看手柄控制帮助\n(或看帮助)"), true, true);
                }
            }
            if (playerInput.KeyboardHelp)
            {
                if (m_keyboardHelpDialog == null)
                {
                    m_keyboardHelpDialog = new KeyboardHelpDialog();
                }
                if (m_keyboardHelpDialog.ParentWidget != null)
                {
                    DialogsManager.HideDialog(m_keyboardHelpDialog);
                }
                else
                {
                    DialogsManager.ShowDialog(m_componentPlayer.View.GameWidget, m_keyboardHelpDialog);
                }
            }
            if (playerInput.GamepadHelp)
            {
                if (m_gamepadHelpDialog == null)
                {
                    m_gamepadHelpDialog = new GamepadHelpDialog();
                }
                if (m_gamepadHelpDialog.ParentWidget != null)
                {
                    DialogsManager.HideDialog(m_gamepadHelpDialog);
                }
                else
                {
                    DialogsManager.ShowDialog(m_componentPlayer.View.GameWidget, m_gamepadHelpDialog);
                }
            }
            if (m_helpButtonWidget.IsClicked)
            {
                ScreensManager.SwitchScreen("Help");
            }
            IInventory inventory = m_componentPlayer.ComponentMiner.Inventory;

            if (playerInput.ToggleInventory || m_inventoryButtonWidget.IsClicked)
            {
                if (componentRider.Mount != null && ModalPanelWidget == null)
                {
                    Widget widget = OpenEntity(inventory, m_componentPlayer.ComponentRider.Mount.Entity);
                    if (widget != null)
                    {
                        ModalPanelWidget = widget;
                        AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                        return;
                    }
                }
                ModalPanelWidget = IsInventoryVisible()
                                        ? null
                                        : inventory is ComponentCreativeInventory
                                        ? new CreativeInventoryWidget(m_componentPlayer.Entity)
                                        : (Widget) new FullInventoryWidget(inventory, m_componentPlayer.Entity.FindComponent <ComponentCraftingTable>(true));
            }
            if (playerInput.ToggleClothing || m_clothingButtonWidget.IsClicked)
            {
                ModalPanelWidget = IsClothingVisible() ? null : new ClothingWidget(m_componentPlayer);
            }
            if (m_sneakButtonWidget.IsClicked || playerInput.ToggleSneak)
            {
                bool isSneaking = m_componentPlayer.ComponentBody.IsSneaking;
                m_componentPlayer.ComponentBody.IsSneaking = !isSneaking;
                if (m_componentPlayer.ComponentBody.IsSneaking != isSneaking)
                {
                    DisplaySmallMessage(Utils.Get(m_componentPlayer.ComponentBody.IsSneaking ? "潜行模式:开" : "潜行模式:关"), false, false);
                }
            }
            if (componentRider != null && (m_mountButtonWidget.IsClicked || playerInput.ToggleMount))
            {
                bool flag = componentRider.Mount != null;
                if (flag)
                {
                    componentRider.StartDismounting();
                }
                else
                {
                    ComponentMount componentMount = FindNearestMount(componentRider);
                    if (componentMount != null)
                    {
                        componentRider.StartMounting(componentMount);
                    }
                }
                if (componentRider.Mount != null != flag)
                {
                    DisplaySmallMessage(Utils.Get(componentRider.Mount != null ? "上马" : "下马"), false, false);
                }
            }
            if ((m_editItemButton.IsClicked || playerInput.EditItem) && m_nearbyEditableCell.HasValue)
            {
                int cellValue = m_subsystemTerrain.Terrain.GetCellValue(m_nearbyEditableCell.Value.X, m_nearbyEditableCell.Value.Y, m_nearbyEditableCell.Value.Z);
                int contents  = Terrain.ExtractContents(cellValue);
                SubsystemBlockBehavior[] blockBehaviors = m_subsystemBlockBehaviors.GetBlockBehaviors(contents);
                for (int i = 0; i < blockBehaviors.Length && !blockBehaviors[i].OnEditBlock(m_nearbyEditableCell.Value.X, m_nearbyEditableCell.Value.Y, m_nearbyEditableCell.Value.Z, cellValue, m_componentPlayer); i++)
                {
                }
            }
            else if ((m_editItemButton.IsClicked || playerInput.EditItem) && IsActiveSlotEditable())
            {
                if (inventory != null)
                {
                    int activeSlotIndex = inventory.ActiveSlotIndex;
                    int num             = Terrain.ExtractContents(inventory.GetSlotValue(activeSlotIndex));
                    if (BlocksManager.Blocks[num].IsEditable)
                    {
                        SubsystemBlockBehavior[] blockBehaviors2 = m_subsystemBlockBehaviors.GetBlockBehaviors(num);
                        for (int j = 0; j < blockBehaviors2.Length && !blockBehaviors2[j].OnEditInventoryItem(inventory, activeSlotIndex, m_componentPlayer); j++)
                        {
                        }
                    }
                }
            }
            bool isCreative = m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative;

            if (isCreative && (m_creativeFlyButtonWidget.IsClicked || playerInput.ToggleCreativeFly) && componentRider.Mount == null)
            {
                bool isCreativeFlyEnabled = m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled;
                m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled = !isCreativeFlyEnabled;
                if (m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled != isCreativeFlyEnabled)
                {
                    if (m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled)
                    {
                        m_componentPlayer.ComponentLocomotion.JumpOrder = 1f;
                        DisplaySmallMessage(Utils.Get("飞行模式:开"), false, false);
                    }
                    else
                    {
                        DisplaySmallMessage(Utils.Get("飞行模式:关"), false, false);
                    }
                }
            }
            if (m_cameraButtonWidget.IsClicked || playerInput.SwitchCameraMode)
            {
                View view = m_componentPlayer.View;
                if (view.ActiveCamera.GetType() == typeof(FppCamera))
                {
                    view.ActiveCamera = view.FindCamera <TppCamera>(true);
                    DisplaySmallMessage(Utils.Get("第三人称视角"), false, false);
                }
                else if (view.ActiveCamera.GetType() == typeof(TppCamera))
                {
                    view.ActiveCamera = view.FindCamera <OrbitCamera>(true);
                    DisplaySmallMessage(Utils.Get("滑轨视角"), false, false);
                }
                else if (view.ActiveCamera.GetType() == typeof(OrbitCamera))
                {
                    view.ActiveCamera = isCreative ? (Camera) new DebugCamera(view) : view.FindCamera <FixedCamera>(true);
                    DisplaySmallMessage(Utils.Get(isCreative ? "调试视角" : "固定视角"), false, false);
                }
                else if (isCreative && view.ActiveCamera.GetType() == typeof(FixedCamera))
                {
                    view.ActiveCamera = new FlyCamera(view);
                    DisplaySmallMessage(Utils.Get("飞行视角"), false, false);
                }
                else if (view.ActiveCamera.GetType() == typeof(DebugCamera))
                {
                    view.ActiveCamera = view.FindCamera <FixedCamera>(true);
                    DisplaySmallMessage(Utils.Get("固定视角"), false, false);
                }
                else if (view.ActiveCamera.GetType() == typeof(FlyCamera))
                {
                    view.ActiveCamera = new RandomJumpCamera(view);
                    DisplaySmallMessage(Utils.Get("随机跳跃视角"), false, false);
                }
                else if (view.ActiveCamera.GetType() == typeof(RandomJumpCamera))
                {
                    view.ActiveCamera = new StraightFlightCamera(view);
                    DisplaySmallMessage(Utils.Get("垂直飞行视角"), false, false);
                }
                else
                {
                    view.ActiveCamera = view.FindCamera <FppCamera>(true);
                    DisplaySmallMessage(Utils.Get("第一人称视角"), false, false);
                }
            }
            if (m_photoButtonWidget.IsClicked || playerInput.TakeScreenshot)
            {
                ScreenCaptureManager.CapturePhoto();
                Time.QueueFrameCountDelayedExecution(Time.FrameIndex + 1, delegate
                {
                    DisplaySmallMessage(Utils.Get("照片已保存到图片相册"), false, false);
                });
            }
            if (isCreative && (m_lightningButtonWidget.IsClicked || playerInput.Lighting))
            {
                Project.FindSubsystem <SubsystemWeather>(true).ManualLightingStrike(m_componentPlayer.ComponentCreatureModel.EyePosition, Matrix.CreateFromQuaternion(m_componentPlayer.ComponentCreatureModel.EyeRotation).Forward);
            }
            if (isCreative && (m_timeOfDayButtonWidget.IsClicked || playerInput.TimeOfDay))
            {
                float num2  = MathUtils.Remainder(0.25f, 1f);
                float num3  = MathUtils.Remainder(0.5f, 1f);
                float num4  = MathUtils.Remainder(0.75f, 1f);
                float num5  = MathUtils.Remainder(1f, 1f);
                float num6  = MathUtils.Remainder(num2 - m_subsystemTimeOfDay.TimeOfDay, 1f);
                float num7  = MathUtils.Remainder(num3 - m_subsystemTimeOfDay.TimeOfDay, 1f);
                float num8  = MathUtils.Remainder(num4 - m_subsystemTimeOfDay.TimeOfDay, 1f);
                float num9  = MathUtils.Remainder(num5 - m_subsystemTimeOfDay.TimeOfDay, 1f);
                float num10 = MathUtils.Min(num6, num7, num8, num9);
                if (num6 == num10)
                {
                    m_subsystemTimeOfDay.TimeOfDayOffset += num6;
                    DisplaySmallMessage(Utils.Get("黎明"), false, false);
                }
                else if (num7 == num10)
                {
                    m_subsystemTimeOfDay.TimeOfDayOffset += num7;
                    DisplaySmallMessage(Utils.Get("中午"), false, false);
                }
                else if (num8 == num10)
                {
                    m_subsystemTimeOfDay.TimeOfDayOffset += num8;
                    DisplaySmallMessage(Utils.Get("黄昏"), false, false);
                }
                else if (num9 == num10)
                {
                    m_subsystemTimeOfDay.TimeOfDayOffset += num9;
                    DisplaySmallMessage(Utils.Get("午夜"), false, false);
                }
            }
            if (ModalPanelWidget != null)
            {
                if (input.Cancel || input.Back || m_backButtonWidget.IsClicked)
                {
                    ModalPanelWidget = null;
                }
            }
            else if (input.Back || m_backButtonWidget.IsClicked)
            {
                DialogsManager.ShowDialog(m_componentPlayer.View.GameWidget, new GameMenuDialog(m_componentPlayer));
            }
            return;
        }
コード例 #3
0
        public void UpdateInputFromWidgets(WidgetInput input)
        {
            float      num        = MathUtils.Pow(1.25f, 10f * (SettingsManager.MoveSensitivity - 0.5f));
            float      num2       = MathUtils.Pow(1.25f, 10f * (SettingsManager.LookSensitivity - 0.5f));
            float      num3       = MathUtils.Clamp(m_subsystemTime.GameTimeDelta, 0f, 0.1f);
            ViewWidget viewWidget = m_componentPlayer.ViewWidget;

            m_componentGui.MoveWidget.Radius = 30f / num * m_componentGui.MoveWidget.GlobalScale;
            if (m_componentGui.ModalPanelWidget != null || !(m_subsystemTime.GameTimeFactor > 0f) || !(num3 > 0f))
            {
                return;
            }
            Vector2 v = new Vector2(SettingsManager.LeftHandedLayout ? 96 : (-96), -96f);

            v = Vector2.TransformNormal(v, input.Widget.GlobalTransform);
            if (m_componentGui.ViewWidget != null && m_componentGui.ViewWidget.TouchInput.HasValue)
            {
                IsControlledByTouch = true;
                TouchInput value         = m_componentGui.ViewWidget.TouchInput.Value;
                Camera     activeCamera  = m_componentPlayer.GameWidget.ActiveCamera;
                Vector3    viewPosition  = activeCamera.ViewPosition;
                Vector3    viewDirection = activeCamera.ViewDirection;
                Vector3    direction     = Vector3.Normalize(activeCamera.ScreenToWorld(new Vector3(value.Position, 1f), Matrix.Identity) - viewPosition);
                Vector3    direction2    = Vector3.Normalize(activeCamera.ScreenToWorld(new Vector3(value.Position + v, 1f), Matrix.Identity) - viewPosition);
                if (value.InputType == TouchInputType.Tap)
                {
                    if (SettingsManager.LookControlMode == LookControlMode.SplitTouch)
                    {
                        m_playerInput.Interact = new Ray3(viewPosition, viewDirection);
                        m_playerInput.Hit      = new Ray3(viewPosition, viewDirection);
                    }
                    else
                    {
                        m_playerInput.Interact = new Ray3(viewPosition, direction);
                        m_playerInput.Hit      = new Ray3(viewPosition, direction);
                    }
                }
                else if (value.InputType == TouchInputType.Hold && value.DurationFrames > 1 && value.Duration > 0.2f)
                {
                    if (SettingsManager.LookControlMode == LookControlMode.SplitTouch)
                    {
                        m_playerInput.Dig = new Ray3(viewPosition, viewDirection);
                        m_playerInput.Aim = new Ray3(viewPosition, direction2);
                    }
                    else
                    {
                        m_playerInput.Dig = new Ray3(viewPosition, direction);
                        m_playerInput.Aim = new Ray3(viewPosition, direction2);
                    }
                    m_isViewHoldStarted = true;
                }
                else if (value.InputType == TouchInputType.Move)
                {
                    if (SettingsManager.LookControlMode == LookControlMode.EntireScreen || SettingsManager.LookControlMode == LookControlMode.SplitTouch)
                    {
                        Vector2 v2     = Vector2.TransformNormal(value.Move, m_componentGui.ViewWidget.InvertedGlobalTransform);
                        Vector2 vector = num2 / num3 * new Vector2(0.0006f, -0.0006f) * v2 * MathUtils.Pow(v2.LengthSquared(), 0.125f);
                        m_playerInput.Look += vector;
                    }
                    if (m_isViewHoldStarted)
                    {
                        if (SettingsManager.LookControlMode == LookControlMode.SplitTouch)
                        {
                            m_playerInput.Dig = new Ray3(viewPosition, viewDirection);
                            m_playerInput.Aim = new Ray3(viewPosition, direction2);
                        }
                        else
                        {
                            m_playerInput.Dig = new Ray3(viewPosition, direction);
                            m_playerInput.Aim = new Ray3(viewPosition, direction2);
                        }
                    }
                }
            }
            else
            {
                m_isViewHoldStarted = false;
            }
            if (m_componentGui.MoveWidget != null && m_componentGui.MoveWidget.TouchInput.HasValue)
            {
                IsControlledByTouch = true;
                float      radius = m_componentGui.MoveWidget.Radius;
                TouchInput value2 = m_componentGui.MoveWidget.TouchInput.Value;
                if (value2.InputType == TouchInputType.Tap)
                {
                    m_playerInput.Jump = true;
                }
                else if (value2.InputType == TouchInputType.Move || value2.InputType == TouchInputType.Hold)
                {
                    Vector2 v3      = Vector2.TransformNormal(value2.Move, m_componentGui.ViewWidget.InvertedGlobalTransform);
                    Vector2 vector2 = num / num3 * new Vector2(0.003f, -0.003f) * v3 * MathUtils.Pow(v3.LengthSquared(), 0.175f);
                    m_playerInput.SneakMove.X += vector2.X;
                    m_playerInput.SneakMove.Z += vector2.Y;
                    Vector2 vector3 = Vector2.TransformNormal(value2.TotalMoveLimited, m_componentGui.ViewWidget.InvertedGlobalTransform);
                    m_playerInput.Move.X += ProcessInputValue(vector3.X * viewWidget.GlobalScale, 0.2f * radius, radius);
                    m_playerInput.Move.Z += ProcessInputValue((0f - vector3.Y) * viewWidget.GlobalScale, 0.2f * radius, radius);
                }
            }
            if (m_componentGui.MoveRoseWidget != null)
            {
                if (m_componentGui.MoveRoseWidget.Direction != Vector3.Zero || m_componentGui.MoveRoseWidget.Jump)
                {
                    IsControlledByTouch = true;
                }
                m_playerInput.Move      += m_componentGui.MoveRoseWidget.Direction;
                m_playerInput.SneakMove += m_componentGui.MoveRoseWidget.Direction;
                m_playerInput.Jump      |= m_componentGui.MoveRoseWidget.Jump;
            }
            if (m_componentGui.LookWidget != null && m_componentGui.LookWidget.TouchInput.HasValue)
            {
                IsControlledByTouch = true;
                TouchInput value3 = m_componentGui.LookWidget.TouchInput.Value;
                if (value3.InputType == TouchInputType.Tap)
                {
                    m_playerInput.Jump = true;
                }
                else if (value3.InputType == TouchInputType.Move)
                {
                    Vector2 v4      = Vector2.TransformNormal(value3.Move, m_componentGui.ViewWidget.InvertedGlobalTransform);
                    Vector2 vector4 = num2 / num3 * new Vector2(0.0006f, -0.0006f) * v4 * MathUtils.Pow(v4.LengthSquared(), 0.125f);
                    m_playerInput.Look += vector4;
                }
            }
        }
コード例 #4
0
 public void UpdateInputFromVrControllers(WidgetInput input)
 {
     if (!IsControlledByVr)
     {
         return;
     }
     IsControlledByTouch = false;
     if (m_componentGui.ModalPanelWidget != null || DialogsManager.HasDialogs(m_componentPlayer.GuiWidget))
     {
         if (!input.IsVrCursorVisible)
         {
             input.IsVrCursorVisible = true;
         }
     }
     else
     {
         input.IsVrCursorVisible = false;
         float   num              = MathUtils.Pow(1.25f, 10f * (SettingsManager.MoveSensitivity - 0.5f));
         float   num2             = MathUtils.Pow(1.25f, 10f * (SettingsManager.LookSensitivity - 0.5f));
         float   num3             = MathUtils.Clamp(m_subsystemTime.GameTimeDelta, 0f, 0.1f);
         Vector2 v                = Vector2.Normalize(m_componentPlayer.ComponentBody.Matrix.Right.XZ);
         Vector2 v2               = Vector2.Normalize(m_componentPlayer.ComponentBody.Matrix.Forward.XZ);
         Vector2 vrStickPosition  = input.GetVrStickPosition(VrController.Left, 0.2f);
         Vector2 vrStickPosition2 = input.GetVrStickPosition(VrController.Right, 0.2f);
         Matrix  m                = VrManager.HmdMatrixInverted.OrientationMatrix * m_componentPlayer.ComponentCreatureModel.EyeRotation.ToMatrix();
         Vector2 xZ               = Vector3.TransformNormal(new Vector3(VrManager.WalkingVelocity.X, 0f, VrManager.WalkingVelocity.Y), m).XZ;
         Vector3 value            = Vector3.TransformNormal(new Vector3(VrManager.HeadMove.X, 0f, VrManager.HeadMove.Y), m);
         Vector3 zero             = Vector3.Zero;
         zero += 0.5f * new Vector3(Vector2.Dot(xZ, v), 0f, Vector2.Dot(xZ, v2));
         zero += new Vector3(2f * vrStickPosition.X, 2f * vrStickPosition2.Y, 2f * vrStickPosition.Y);
         m_playerInput.Move      += zero;
         m_playerInput.SneakMove += zero;
         m_playerInput.VrMove     = value;
         TouchInput?touchInput = VrManager.GetTouchInput(VrController.Left);
         if (touchInput.HasValue && num3 > 0f)
         {
             if (touchInput.Value.InputType == TouchInputType.Move)
             {
                 Vector2 move   = touchInput.Value.Move;
                 Vector2 vector = 10f * num / num3 * new Vector2(0.5f) * move * MathUtils.Pow(move.LengthSquared(), 0.175f);
                 m_playerInput.SneakMove.X += vector.X;
                 m_playerInput.SneakMove.Z += vector.Y;
                 m_playerInput.Move.X      += ProcessInputValue(touchInput.Value.TotalMoveLimited.X, 0.1f, 1f);
                 m_playerInput.Move.Z      += ProcessInputValue(touchInput.Value.TotalMoveLimited.Y, 0.1f, 1f);
             }
             else if (touchInput.Value.InputType == TouchInputType.Tap)
             {
                 m_playerInput.Jump = true;
             }
         }
         m_playerInput.Look += 0.5f * vrStickPosition2 * MathUtils.Pow(vrStickPosition2.LengthSquared(), 0.25f);
         Vector3 hmdMatrixYpr     = VrManager.HmdMatrixYpr;
         Vector3 hmdLastMatrixYpr = VrManager.HmdLastMatrixYpr;
         Vector3 vector2          = hmdMatrixYpr - hmdLastMatrixYpr;
         m_playerInput.VrLook = new Vector2(vector2.X, hmdMatrixYpr.Y);
         TouchInput?touchInput2 = VrManager.GetTouchInput(VrController.Right);
         Vector2    zero2       = Vector2.Zero;
         if (touchInput2.HasValue)
         {
             if (touchInput2.Value.InputType == TouchInputType.Move)
             {
                 zero2.X = touchInput2.Value.Move.X;
                 m_playerInput.Move.Y += ProcessInputValue(touchInput2.Value.TotalMoveLimited.Y, 0.1f, 1f);
             }
             else if (touchInput2.Value.InputType == TouchInputType.Tap)
             {
                 m_playerInput.Jump = true;
             }
         }
         if (num3 > 0f)
         {
             m_vrSmoothLook      = Vector2.Lerp(m_vrSmoothLook, zero2, 14f * num3);
             m_playerInput.Look += num2 / num3 * new Vector2(0.25f) * m_vrSmoothLook * MathUtils.Pow(m_vrSmoothLook.LengthSquared(), 0.3f);
         }
         if (VrManager.IsControllerPresent(VrController.Right))
         {
             m_playerInput.Dig      = (VrManager.IsButtonDown(VrController.Right, VrControllerButton.Trigger) ? CalculateVrHandRay() : m_playerInput.Dig);
             m_playerInput.Hit      = (VrManager.IsButtonDownOnce(VrController.Right, VrControllerButton.Trigger) ? CalculateVrHandRay() : m_playerInput.Hit);
             m_playerInput.Aim      = (VrManager.IsButtonDown(VrController.Left, VrControllerButton.Trigger) ? CalculateVrHandRay() : m_playerInput.Aim);
             m_playerInput.Interact = (VrManager.IsButtonDownOnce(VrController.Left, VrControllerButton.Trigger) ? CalculateVrHandRay() : m_playerInput.Interact);
         }
         m_playerInput.ToggleMount       |= input.IsVrButtonDownOnce(VrController.Left, VrControllerButton.TouchpadUp);
         m_playerInput.ToggleSneak       |= input.IsVrButtonDownOnce(VrController.Left, VrControllerButton.TouchpadDown);
         m_playerInput.EditItem          |= input.IsVrButtonDownOnce(VrController.Left, VrControllerButton.Grip);
         m_playerInput.ToggleCreativeFly |= input.IsVrButtonDownOnce(VrController.Right, VrControllerButton.TouchpadUp);
         if (input.IsVrButtonDownOnce(VrController.Right, VrControllerButton.TouchpadLeft))
         {
             m_playerInput.ScrollInventory--;
         }
         if (input.IsVrButtonDownOnce(VrController.Right, VrControllerButton.TouchpadRight))
         {
             m_playerInput.ScrollInventory++;
         }
         m_playerInput.Drop |= input.IsVrButtonDownOnce(VrController.Right, VrControllerButton.Grip);
     }
     if (!DialogsManager.HasDialogs(m_componentPlayer.GuiWidget))
     {
         m_playerInput.ToggleInventory |= input.IsVrButtonDownOnce(VrController.Right, VrControllerButton.Menu);
     }
 }
コード例 #5
0
        public void UpdateInputFromGamepad(WidgetInput input)
        {
            Vector3 viewPosition  = m_componentPlayer.GameWidget.ActiveCamera.ViewPosition;
            Vector3 viewDirection = m_componentPlayer.GameWidget.ActiveCamera.ViewDirection;

            if (m_componentGui.ModalPanelWidget != null || DialogsManager.HasDialogs(m_componentPlayer.GuiWidget))
            {
                if (!input.IsPadCursorVisible)
                {
                    ViewWidget viewWidget        = m_componentPlayer.ViewWidget;
                    Vector2    padCursorPosition = viewWidget.WidgetToScreen(viewWidget.ActualSize / 2f);
                    input.IsPadCursorVisible = true;
                    input.PadCursorPosition  = padCursorPosition;
                }
            }
            else
            {
                input.IsPadCursorVisible = false;
                Vector3 zero                = Vector3.Zero;
                Vector2 padStickPosition    = input.GetPadStickPosition(GamePadStick.Left, SettingsManager.GamepadDeadZone);
                Vector2 padStickPosition2   = input.GetPadStickPosition(GamePadStick.Right, SettingsManager.GamepadDeadZone);
                float   padTriggerPosition  = input.GetPadTriggerPosition(GamePadTrigger.Left);
                float   padTriggerPosition2 = input.GetPadTriggerPosition(GamePadTrigger.Right);
                zero += new Vector3(2f * padStickPosition.X, 0f, 2f * padStickPosition.Y);
                zero += Vector3.UnitY * (input.IsPadButtonDown(GamePadButton.A) ? 1 : 0);
                zero += -Vector3.UnitY * (input.IsPadButtonDown(GamePadButton.RightShoulder) ? 1 : 0);
                m_playerInput.Move             += zero;
                m_playerInput.SneakMove        += zero;
                m_playerInput.Look             += 0.75f * padStickPosition2 * MathUtils.Pow(padStickPosition2.LengthSquared(), 0.25f);
                m_playerInput.Jump             |= input.IsPadButtonDownOnce(GamePadButton.A);
                m_playerInput.Dig               = ((padTriggerPosition2 >= 0.5f) ? new Ray3?(new Ray3(viewPosition, viewDirection)) : m_playerInput.Dig);
                m_playerInput.Hit               = ((padTriggerPosition2 >= 0.5f && m_lastRightTrigger < 0.5f) ? new Ray3?(new Ray3(viewPosition, viewDirection)) : m_playerInput.Hit);
                m_playerInput.Aim               = ((padTriggerPosition >= 0.5f) ? new Ray3?(new Ray3(viewPosition, viewDirection)) : m_playerInput.Aim);
                m_playerInput.Interact          = ((padTriggerPosition >= 0.5f && m_lastLeftTrigger < 0.5f) ? new Ray3?(new Ray3(viewPosition, viewDirection)) : m_playerInput.Interact);
                m_playerInput.Drop             |= input.IsPadButtonDownOnce(GamePadButton.B);
                m_playerInput.ToggleMount      |= (input.IsPadButtonDownOnce(GamePadButton.LeftThumb) || input.IsPadButtonDownOnce(GamePadButton.DPadUp));
                m_playerInput.EditItem         |= input.IsPadButtonDownOnce(GamePadButton.LeftShoulder);
                m_playerInput.ToggleSneak      |= input.IsPadButtonDownOnce(GamePadButton.RightShoulder);
                m_playerInput.SwitchCameraMode |= (input.IsPadButtonDownOnce(GamePadButton.RightThumb) || input.IsPadButtonDownOnce(GamePadButton.DPadDown));
                if (input.IsPadButtonDownRepeat(GamePadButton.DPadLeft))
                {
                    m_playerInput.ScrollInventory--;
                }
                if (input.IsPadButtonDownRepeat(GamePadButton.DPadRight))
                {
                    m_playerInput.ScrollInventory++;
                }
                if (padStickPosition != Vector2.Zero || padStickPosition2 != Vector2.Zero)
                {
                    IsControlledByTouch = false;
                }
                m_lastLeftTrigger  = padTriggerPosition;
                m_lastRightTrigger = padTriggerPosition2;
            }
            if (!DialogsManager.HasDialogs(m_componentPlayer.GuiWidget))
            {
                m_playerInput.ToggleInventory |= input.IsPadButtonDownOnce(GamePadButton.X);
                m_playerInput.ToggleClothing  |= input.IsPadButtonDownOnce(GamePadButton.Y);
                m_playerInput.GamepadHelp     |= input.IsPadButtonDownOnce(GamePadButton.Start);
            }
        }
コード例 #6
0
        public void UpdateInputFromMouseAndKeyboard(WidgetInput input)
        {
            Vector3 viewPosition  = m_componentPlayer.GameWidget.ActiveCamera.ViewPosition;
            Vector3 viewDirection = m_componentPlayer.GameWidget.ActiveCamera.ViewDirection;

            if (m_componentGui.ModalPanelWidget != null || DialogsManager.HasDialogs(m_componentPlayer.GuiWidget))
            {
                if (!input.IsMouseCursorVisible)
                {
                    ViewWidget viewWidget = m_componentPlayer.ViewWidget;
                    Vector2    value      = viewWidget.WidgetToScreen(viewWidget.ActualSize / 2f);
                    input.IsMouseCursorVisible = true;
                    input.MousePosition        = value;
                }
            }
            else
            {
                input.IsMouseCursorVisible = false;
                Vector2 zero = Vector2.Zero;
                int     num  = 0;
                if (Window.IsActive && Time.FrameDuration > 0f)
                {
                    Point2 mouseMovement      = input.MouseMovement;
                    int    mouseWheelMovement = input.MouseWheelMovement;
                    zero.X = 0.02f * (float)mouseMovement.X / Time.FrameDuration / 60f;
                    zero.Y = -0.02f * (float)mouseMovement.Y / Time.FrameDuration / 60f;
                    num    = mouseWheelMovement / 120;
                    if (mouseMovement != Point2.Zero)
                    {
                        IsControlledByTouch = false;
                    }
                }
                Vector3 vector = default(Vector3) + Vector3.UnitX * (input.IsKeyDown(Key.D) ? 1 : 0);
                vector                          += -Vector3.UnitZ * (input.IsKeyDown(Key.S) ? 1 : 0);
                vector                          += Vector3.UnitZ * (input.IsKeyDown(Key.W) ? 1 : 0);
                vector                          += -Vector3.UnitX * (input.IsKeyDown(Key.A) ? 1 : 0);
                vector                          += Vector3.UnitY * (input.IsKeyDown(Key.Space) ? 1 : 0);
                vector                          += -Vector3.UnitY * (input.IsKeyDown(Key.Shift) ? 1 : 0);
                m_playerInput.Look              += new Vector2(MathUtils.Clamp(zero.X, -15f, 15f), MathUtils.Clamp(zero.Y, -15f, 15f));
                m_playerInput.Move              += vector;
                m_playerInput.SneakMove         += vector;
                m_playerInput.Jump              |= input.IsKeyDownOnce(Key.Space);
                m_playerInput.ScrollInventory   -= num;
                m_playerInput.Dig                = (input.IsMouseButtonDown(MouseButton.Left) ? new Ray3?(new Ray3(viewPosition, viewDirection)) : m_playerInput.Dig);
                m_playerInput.Hit                = (input.IsMouseButtonDownOnce(MouseButton.Left) ? new Ray3?(new Ray3(viewPosition, viewDirection)) : m_playerInput.Hit);
                m_playerInput.Aim                = (input.IsMouseButtonDown(MouseButton.Right) ? new Ray3?(new Ray3(viewPosition, viewDirection)) : m_playerInput.Aim);
                m_playerInput.Interact           = (input.IsMouseButtonDownOnce(MouseButton.Right) ? new Ray3?(new Ray3(viewPosition, viewDirection)) : m_playerInput.Interact);
                m_playerInput.ToggleSneak       |= input.IsKeyDownOnce(Key.Shift);
                m_playerInput.ToggleMount       |= input.IsKeyDownOnce(Key.R);
                m_playerInput.ToggleCreativeFly |= input.IsKeyDownOnce(Key.F);
                m_playerInput.PickBlockType      = (input.IsMouseButtonDownOnce(MouseButton.Middle) ? new Ray3?(new Ray3(viewPosition, viewDirection)) : m_playerInput.PickBlockType);
            }
            if (!DialogsManager.HasDialogs(m_componentPlayer.GuiWidget))
            {
                m_playerInput.ToggleInventory  |= input.IsKeyDownOnce(Key.E);
                m_playerInput.ToggleClothing   |= input.IsKeyDownOnce(Key.C);
                m_playerInput.TakeScreenshot   |= input.IsKeyDownOnce(Key.P);
                m_playerInput.SwitchCameraMode |= input.IsKeyDownOnce(Key.V);
                m_playerInput.TimeOfDay        |= input.IsKeyDownOnce(Key.T);
                m_playerInput.Lighting         |= input.IsKeyDownOnce(Key.L);
                m_playerInput.Drop             |= input.IsKeyDownOnce(Key.Q);
                m_playerInput.EditItem         |= input.IsKeyDownOnce(Key.G);
                m_playerInput.KeyboardHelp     |= input.IsKeyDownOnce(Key.H);
                if (input.IsKeyDownOnce(Key.Number1))
                {
                    m_playerInput.SelectInventorySlot = 0;
                }
                if (input.IsKeyDownOnce(Key.Number2))
                {
                    m_playerInput.SelectInventorySlot = 1;
                }
                if (input.IsKeyDownOnce(Key.Number3))
                {
                    m_playerInput.SelectInventorySlot = 2;
                }
                if (input.IsKeyDownOnce(Key.Number4))
                {
                    m_playerInput.SelectInventorySlot = 3;
                }
                if (input.IsKeyDownOnce(Key.Number5))
                {
                    m_playerInput.SelectInventorySlot = 4;
                }
                if (input.IsKeyDownOnce(Key.Number6))
                {
                    m_playerInput.SelectInventorySlot = 5;
                }
                if (input.IsKeyDownOnce(Key.Number7))
                {
                    m_playerInput.SelectInventorySlot = 6;
                }
                if (input.IsKeyDownOnce(Key.Number8))
                {
                    m_playerInput.SelectInventorySlot = 7;
                }
                if (input.IsKeyDownOnce(Key.Number9))
                {
                    m_playerInput.SelectInventorySlot = 8;
                }
                if (input.IsKeyDownOnce(Key.Number0))
                {
                    m_playerInput.SelectInventorySlot = 9;
                }
            }
        }
コード例 #7
0
        public void HandleInput()
        {
            WidgetInput    input          = m_componentPlayer.GameWidget.Input;
            PlayerInput    playerInput    = m_componentPlayer.ComponentInput.PlayerInput;
            ComponentRider componentRider = m_componentPlayer.ComponentRider;

            if (m_componentPlayer.GameWidget.ActiveCamera.IsEntityControlEnabled)
            {
                if (!m_keyboardHelpMessageShown && (m_componentPlayer.PlayerData.InputDevice & WidgetInputDevice.Keyboard) != 0 && Time.PeriodicEvent(7.0, 0.0))
                {
                    m_keyboardHelpMessageShown = true;
                    DisplaySmallMessage(LanguageControl.Get(fName, 1), Color.White, blinking: true, playNotificationSound: true);
                }
                else if (!m_gamepadHelpMessageShown && (m_componentPlayer.PlayerData.InputDevice & WidgetInputDevice.Gamepads) != 0 && Time.PeriodicEvent(7.0, 0.0))
                {
                    m_gamepadHelpMessageShown = true;
                    DisplaySmallMessage(LanguageControl.Get(fName, 2), Color.White, blinking: true, playNotificationSound: true);
                }
            }
            if (playerInput.KeyboardHelp)
            {
                if (m_keyboardHelpDialog == null)
                {
                    m_keyboardHelpDialog = new KeyboardHelpDialog();
                }
                if (m_keyboardHelpDialog.ParentWidget != null)
                {
                    DialogsManager.HideDialog(m_keyboardHelpDialog);
                }
                else
                {
                    DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, m_keyboardHelpDialog);
                }
            }
            if (playerInput.GamepadHelp)
            {
                if (m_gamepadHelpDialog == null)
                {
                    m_gamepadHelpDialog = new GamepadHelpDialog();
                }
                if (m_gamepadHelpDialog.ParentWidget != null)
                {
                    DialogsManager.HideDialog(m_gamepadHelpDialog);
                }
                else
                {
                    DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, m_gamepadHelpDialog);
                }
            }
            if (m_helpButtonWidget.IsClicked)
            {
                ScreensManager.SwitchScreen("Help");
            }
            if (playerInput.ToggleInventory || m_inventoryButtonWidget.IsClicked)
            {
                if (IsInventoryVisible())
                {
                    ModalPanelWidget = null;
                }
                else if (m_componentPlayer.ComponentMiner.Inventory is ComponentCreativeInventory)
                {
                    ModalPanelWidget = new CreativeInventoryWidget(m_componentPlayer.Entity);
                }
                else
                {
                    ModalPanelWidget = new FullInventoryWidget(m_componentPlayer.ComponentMiner.Inventory, m_componentPlayer.Entity.FindComponent <ComponentCraftingTable>(throwOnError: true));
                }
            }
            if (playerInput.ToggleClothing || m_clothingButtonWidget.IsClicked)
            {
                if (IsClothingVisible())
                {
                    ModalPanelWidget = null;
                }
                else
                {
                    ModalPanelWidget = new ClothingWidget(m_componentPlayer);
                }
            }
            if (m_sneakButtonWidget.IsClicked || playerInput.ToggleSneak)
            {
                bool isSneaking = m_componentPlayer.ComponentBody.IsSneaking;
                m_componentPlayer.ComponentBody.IsSneaking = !isSneaking;
                if (m_componentPlayer.ComponentBody.IsSneaking != isSneaking)
                {
                    if (m_componentPlayer.ComponentBody.IsSneaking)
                    {
                        DisplaySmallMessage(LanguageControl.Get(fName, 3), Color.White, blinking: false, playNotificationSound: false);
                    }
                    else
                    {
                        DisplaySmallMessage(LanguageControl.Get(fName, 4), Color.White, blinking: false, playNotificationSound: false);
                    }
                }
            }
            if (componentRider != null && (m_mountButtonWidget.IsClicked || playerInput.ToggleMount))
            {
                bool flag = componentRider.Mount != null;
                if (flag)
                {
                    componentRider.StartDismounting();
                }
                else
                {
                    ComponentMount componentMount = componentRider.FindNearestMount();
                    if (componentMount != null)
                    {
                        componentRider.StartMounting(componentMount);
                    }
                }
                if (componentRider.Mount != null != flag)
                {
                    if (componentRider.Mount != null)
                    {
                        DisplaySmallMessage(LanguageControl.Get(fName, 5), Color.White, blinking: false, playNotificationSound: false);
                    }
                    else
                    {
                        DisplaySmallMessage(LanguageControl.Get(fName, 6), Color.White, blinking: false, playNotificationSound: false);
                    }
                }
            }
            if ((m_editItemButton.IsClicked || playerInput.EditItem) && m_componentPlayer.ComponentBlockHighlight.NearbyEditableCell.HasValue)
            {
                Point3 value     = m_componentPlayer.ComponentBlockHighlight.NearbyEditableCell.Value;
                int    cellValue = m_subsystemTerrain.Terrain.GetCellValue(value.X, value.Y, value.Z);
                int    contents  = Terrain.ExtractContents(cellValue);
                SubsystemBlockBehavior[] blockBehaviors = m_subsystemBlockBehaviors.GetBlockBehaviors(contents);
                for (int i = 0; i < blockBehaviors.Length && !blockBehaviors[i].OnEditBlock(value.X, value.Y, value.Z, cellValue, m_componentPlayer); i++)
                {
                }
            }
            else if ((m_editItemButton.IsClicked || playerInput.EditItem) && IsActiveSlotEditable())
            {
                IInventory inventory = m_componentPlayer.ComponentMiner.Inventory;
                if (inventory != null)
                {
                    int activeSlotIndex = inventory.ActiveSlotIndex;
                    int num             = Terrain.ExtractContents(inventory.GetSlotValue(activeSlotIndex));
                    if (BlocksManager.Blocks[num].IsEditable)
                    {
                        SubsystemBlockBehavior[] blockBehaviors = m_subsystemBlockBehaviors.GetBlockBehaviors(num);
                        for (int i = 0; i < blockBehaviors.Length && !blockBehaviors[i].OnEditInventoryItem(inventory, activeSlotIndex, m_componentPlayer); i++)
                        {
                        }
                    }
                }
            }
            if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative && (m_creativeFlyButtonWidget.IsClicked || playerInput.ToggleCreativeFly) && componentRider.Mount == null)
            {
                bool isCreativeFlyEnabled = m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled;
                m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled = !isCreativeFlyEnabled;
                if (m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled != isCreativeFlyEnabled)
                {
                    if (m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled)
                    {
                        m_componentPlayer.ComponentLocomotion.JumpOrder = 1f;
                        DisplaySmallMessage(LanguageControl.Get(fName, 7), Color.White, blinking: false, playNotificationSound: false);
                    }
                    else
                    {
                        DisplaySmallMessage(LanguageControl.Get(fName, 8), Color.White, blinking: false, playNotificationSound: false);
                    }
                }
            }
            if (!m_componentPlayer.ComponentInput.IsControlledByVr && (m_cameraButtonWidget.IsClicked || playerInput.SwitchCameraMode))
            {
                GameWidget gameWidget = m_componentPlayer.GameWidget;
                if (gameWidget.ActiveCamera.GetType() == typeof(FppCamera))
                {
                    gameWidget.ActiveCamera = gameWidget.FindCamera <TppCamera>();
                    DisplaySmallMessage(LanguageControl.Get(fName, 9), Color.White, blinking: false, playNotificationSound: false);
                }
                else if (gameWidget.ActiveCamera.GetType() == typeof(TppCamera))
                {
                    gameWidget.ActiveCamera = gameWidget.FindCamera <OrbitCamera>();
                    DisplaySmallMessage(LanguageControl.Get(fName, 10), Color.White, blinking: false, playNotificationSound: false);
                }
                else if (gameWidget.ActiveCamera.GetType() == typeof(OrbitCamera))
                {
                    gameWidget.ActiveCamera = gameWidget.FindCamera <FixedCamera>();
                    DisplaySmallMessage(LanguageControl.Get(fName, 11), Color.White, blinking: false, playNotificationSound: false);
                }
                else
                {
                    gameWidget.ActiveCamera = gameWidget.FindCamera <FppCamera>();
                    DisplaySmallMessage(LanguageControl.Get(fName, 12), Color.White, blinking: false, playNotificationSound: false);
                }
            }
            if (m_photoButtonWidget.IsClicked || playerInput.TakeScreenshot)
            {
                ScreenCaptureManager.CapturePhoto(delegate
                {
                    DisplaySmallMessage(LanguageControl.Get(fName, 13), Color.White, blinking: false, playNotificationSound: false);
                }, delegate
                {
                    DisplaySmallMessage(LanguageControl.Get(fName, 14), Color.White, blinking: false, playNotificationSound: false);
                });
            }
            if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative && (m_lightningButtonWidget.IsClicked || playerInput.Lighting))
            {
                Matrix matrix = Matrix.CreateFromQuaternion(m_componentPlayer.ComponentCreatureModel.EyeRotation);
                base.Project.FindSubsystem <SubsystemWeather>(throwOnError: true).ManualLightingStrike(m_componentPlayer.ComponentCreatureModel.EyePosition, matrix.Forward);
            }
            if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative && (m_timeOfDayButtonWidget.IsClicked || playerInput.TimeOfDay))
            {
                float num2  = MathUtils.Remainder(0.25f, 1f);
                float num3  = MathUtils.Remainder(0.5f, 1f);
                float num4  = MathUtils.Remainder(0.75f, 1f);
                float num5  = MathUtils.Remainder(1f, 1f);
                float num6  = MathUtils.Remainder(num2 - m_subsystemTimeOfDay.TimeOfDay, 1f);
                float num7  = MathUtils.Remainder(num3 - m_subsystemTimeOfDay.TimeOfDay, 1f);
                float num8  = MathUtils.Remainder(num4 - m_subsystemTimeOfDay.TimeOfDay, 1f);
                float num9  = MathUtils.Remainder(num5 - m_subsystemTimeOfDay.TimeOfDay, 1f);
                float num10 = MathUtils.Min(num6, num7, num8, num9);
                if (num6 == num10)
                {
                    m_subsystemTimeOfDay.TimeOfDayOffset += num6;
                    DisplaySmallMessage(LanguageControl.Get(fName, 15), Color.White, blinking: false, playNotificationSound: false);
                }
                else if (num7 == num10)
                {
                    m_subsystemTimeOfDay.TimeOfDayOffset += num7;
                    DisplaySmallMessage(LanguageControl.Get(fName, 16), Color.White, blinking: false, playNotificationSound: false);
                }
                else if (num8 == num10)
                {
                    m_subsystemTimeOfDay.TimeOfDayOffset += num8;
                    DisplaySmallMessage(LanguageControl.Get(fName, 17), Color.White, blinking: false, playNotificationSound: false);
                }
                else if (num9 == num10)
                {
                    m_subsystemTimeOfDay.TimeOfDayOffset += num9;
                    DisplaySmallMessage(LanguageControl.Get(fName, 18), Color.White, blinking: false, playNotificationSound: false);
                }
            }
            if (ModalPanelWidget != null)
            {
                if (input.Cancel || input.Back || m_backButtonWidget.IsClicked)
                {
                    ModalPanelWidget = null;
                }
            }
            else if (input.Back || m_backButtonWidget.IsClicked)
            {
                DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new GameMenuDialog(m_componentPlayer));
            }
        }