コード例 #1
0
        /// <summary>
        /// Refresh the display of all the slots in the currently displayed hotbar,
        /// to reflect the current component state and assignments of actions component.
        /// </summary>
        public void UpdateUI()
        {
            _menu.UpdateUI();

            foreach (var actionSlot in Slots)
            {
                var assignedActionType = _actionsComponent.Assignments[SelectedHotbar, actionSlot.SlotIndex];
                if (!assignedActionType.HasValue)
                {
                    actionSlot.Clear();
                    continue;
                }

                if (assignedActionType.Value.TryGetAction(out var actionType))
                {
                    UpdateActionSlot(actionType, actionSlot, assignedActionType);
                }
                else if (assignedActionType.Value.TryGetItemActionWithoutItem(out var itemlessActionType))
                {
                    UpdateActionSlot(itemlessActionType, actionSlot, assignedActionType);
                }
                else if (assignedActionType.Value.TryGetItemActionWithItem(out var itemActionType, out var item))
                {
                    UpdateActionSlot(item, itemActionType, actionSlot, assignedActionType);
                }
                else
                {
                    Logger.ErrorS("action", "unexpected Assignment type {0}",
                                  assignedActionType.Value.Assignment);
                    actionSlot.Clear();
                }
            }
        }
コード例 #2
0
ファイル: ActionsUI.cs プロジェクト: komunre/space-station-14
        /// <summary>
        /// Refresh the display of all the slots in the currently displayed hotbar,
        /// to reflect the current component state and assignments of actions component.
        /// </summary>
        public void UpdateUI()
        {
            _menu.UpdateUI();

            foreach (var actionSlot in Slots)
            {
                var action = System.Assignments[SelectedHotbar, actionSlot.SlotIndex];

                if (action == null)
                {
                    if (SelectingTargetFor == actionSlot)
                    {
                        StopTargeting(true);
                    }
                    actionSlot.Clear();
                    continue;
                }

                if (Component.Actions.TryGetValue(action, out var actualAction))
                {
                    UpdateActionSlot(actualAction, actionSlot);
                    continue;
                }

                // Action not in the actions component, but in the assignment list.
                // This is either an action that doesn't auto-clear from the menu, or the action menu was locked.
                // Show the old action, but make sure it is disabled;
                action.Enabled = false;
                action.Toggled = false;

                // If we enable the item-sprite, and if the item-sprite has a visual toggle, then the player will be
                // able to know whether the item is toggled, even if it is not in their LOS (but in PVS). And for things
                // like PDA sprites, the player can even see whether the action's item is currently inside of their PVS.
                // SO unless theres some way of "freezing" a sprite-view, we just have to disable it.
                action.ItemIconStyle = ItemActionIconStyle.NoItem;

                UpdateActionSlot(action, actionSlot);
            }
        }