public override void AddToGUIUpdateList(bool ignoreChildren = false, int order = 0) { base.AddToGUIUpdateList(true, order); if (!ignoreChildren) { button.AddToGUIUpdateList(false, order); } }
public void AddToGUIUpdateList() { if (GUI.DisableHUD) { return; } GameMode?.AddToGUIUpdateList(); infoFrame?.AddToGUIUpdateList(); }
public override void AddToGUIUpdateList() { base.AddToGUIUpdateList(); button.AddToGUIUpdateList(); if (Dropped) { listBox.AddToGUIUpdateList(); } }
public override void AddToGUIUpdateList() { if (!isRunning) { return; } base.AddToGUIUpdateList(); CrewManager.AddToGUIUpdateList(); endRoundButton.AddToGUIUpdateList(); }
public void AddToGUIUpdateList() { infoButton.AddToGUIUpdateList(); if (GameMode != null) { GameMode.AddToGUIUpdateList(); } if (infoFrame != null) { infoFrame.AddToGUIUpdateList(); } }
public void AddToGUIUpdateList() { if (GUI.DisableHUD) { return; } GameMode?.AddToGUIUpdateList(); infoFrame?.AddToGUIUpdateList(); if (GameMain.NetworkMember != null) { GameMain.NetLobbyScreen?.HeadSelectionList?.AddToGUIUpdateList(); GameMain.NetLobbyScreen?.JobSelectionFrame?.AddToGUIUpdateList(); } }
public override void AddToGUIUpdateList() { if (!isRunning) { return; } base.AddToGUIUpdateList(); CrewManager.AddToGUIUpdateList(); endRoundButton.AddToGUIUpdateList(); if (ContextualTutorial.Initialized) { ContextualTutorial.AddToGUIUpdateList(); } }
public static void AddToGUIUpdateList(Character character) { if (GUI.DisableHUD) { return; } if (cprButton != null && cprButton.Visible) { cprButton.AddToGUIUpdateList(); } if (grabHoldButton != null && cprButton.Visible) { grabHoldButton.AddToGUIUpdateList(); } if (suicideButton != null && suicideButton.Visible) { suicideButton.AddToGUIUpdateList(); } if (!character.IsUnconscious && character.Stun <= 0.0f) { if (character.Inventory != null) { for (int i = 0; i < character.Inventory.Items.Length - 1; i++) { var item = character.Inventory.Items[i]; if (item == null || CharacterInventory.limbSlots[i] == InvSlotType.Any) { continue; } foreach (ItemComponent ic in item.components) { if (ic.DrawHudWhenEquipped) { ic.AddToGUIUpdateList(); } } } } } }
public override void AddToGUIUpdateList() { if (ShowCampaignUI || ForceMapUI) { campaignUIContainer?.AddToGUIUpdateList(); if (CampaignUI?.UpgradeStore?.HoveredItem != null) { if (CampaignUI.SelectedTab != InteractionType.Upgrade) { return; } CampaignUI?.UpgradeStore?.ItemInfoFrame.AddToGUIUpdateList(order: 1); } } base.AddToGUIUpdateList(); CrewManager.AddToGUIUpdateList(); endRoundButton.AddToGUIUpdateList(); }
public override void Update(float deltaTime, Camera cam, bool isSubInventory = false) { if (!AccessibleWhenAlive && !character.IsDead) { syncItemsDelay = Math.Max(syncItemsDelay - deltaTime, 0.0f); return; } base.Update(deltaTime, cam); bool hoverOnInventory = GUI.MouseOn == null && ((selectedSlot != null && selectedSlot.IsSubSlot) || (draggingItem != null && (draggingSlot == null || !draggingSlot.MouseOn()))); if (CharacterHealth.OpenHealthWindow != null) { hoverOnInventory = true; } if (layout == Layout.Default && hideButton.Visible) { hideButton.AddToGUIUpdateList(); hideButton.UpdateManually(deltaTime, alsoChildren: true); hidePersonalSlotsState = hidePersonalSlots ? Math.Min(hidePersonalSlotsState + deltaTime * 5.0f, 1.0f) : Math.Max(hidePersonalSlotsState - deltaTime * 5.0f, 0.0f); for (int i = 0; i < slots.Length; i++) { if (!PersonalSlots.HasFlag(SlotTypes[i])) { continue; } if (HidePersonalSlots) { if (selectedSlot?.Slot == slots[i]) { selectedSlot = null; } highlightedSubInventorySlots.RemoveWhere(s => s.Slot == slots[i]); } slots[i].DrawOffset = Vector2.Lerp(Vector2.Zero, new Vector2(personalSlotArea.Width, 0.0f), hidePersonalSlotsState); } } if (hoverOnInventory) { HideTimer = 0.5f; } if (HideTimer > 0.0f) { HideTimer -= deltaTime; } for (int i = 0; i < capacity; i++) { if (Items[i] != null && Items[i] != draggingItem && Character.Controlled?.Inventory == this && GUI.KeyboardDispatcher.Subscriber == null && slots[i].QuickUseKey != Keys.None && PlayerInput.KeyHit(slots[i].QuickUseKey)) { QuickUseItem(Items[i], true, false, true); } } //force personal slots open if an item is running out of battery/fuel/oxygen/etc if (hidePersonalSlots) { for (int i = 0; i < slots.Length; i++) { if (Items[i]?.OwnInventory != null && Items[i].OwnInventory.Capacity == 1 && PersonalSlots.HasFlag(SlotTypes[i])) { if (Items[i].OwnInventory.Items[0] != null && Items[i].OwnInventory.Items[0].Condition > 0.0f && Items[i].OwnInventory.Items[0].Condition / Items[i].OwnInventory.Items[0].MaxCondition < 0.15f) { hidePersonalSlots = false; } } } } List <SlotReference> hideSubInventories = new List <SlotReference>(); foreach (var highlightedSubInventorySlot in highlightedSubInventorySlots) { if (highlightedSubInventorySlot.ParentInventory == this) { UpdateSubInventory(deltaTime, highlightedSubInventorySlot.SlotIndex, cam); } Rectangle hoverArea = GetSubInventoryHoverArea(highlightedSubInventorySlot); if (highlightedSubInventorySlot.Inventory?.slots == null || (!hoverArea.Contains(PlayerInput.MousePosition))) { hideSubInventories.Add(highlightedSubInventorySlot); } else { highlightedSubInventorySlot.Inventory.HideTimer = 1.0f; } } if (doubleClickedItem != null) { QuickUseItem(doubleClickedItem, true, true, true); } //activate the subinventory of the currently selected slot if (selectedSlot?.ParentInventory == this) { var subInventory = GetSubInventory(selectedSlot.SlotIndex); if (subInventory != null) { selectedSlot.Inventory = subInventory; if (!highlightedSubInventorySlots.Any(s => s.Inventory == subInventory)) { var slot = selectedSlot; highlightedSubInventorySlots.Add(selectedSlot); UpdateSubInventory(deltaTime, selectedSlot.SlotIndex, cam); //hide previously opened subinventories if this one overlaps with them Rectangle hoverArea = GetSubInventoryHoverArea(slot); foreach (SlotReference highlightedSubInventorySlot in highlightedSubInventorySlots) { if (highlightedSubInventorySlot == slot) { continue; } if (hoverArea.Intersects(GetSubInventoryHoverArea(highlightedSubInventorySlot))) { hideSubInventories.Add(highlightedSubInventorySlot); highlightedSubInventorySlot.Inventory.HideTimer = 0.0f; } } } } } foreach (var subInventorySlot in hideSubInventories) { if (subInventorySlot.Inventory == null) { continue; } subInventorySlot.Inventory.HideTimer -= deltaTime; if (subInventorySlot.Inventory.HideTimer <= 0.0f) { highlightedSubInventorySlots.Remove(subInventorySlot); } } for (int i = 0; i < capacity; i++) { if (Items[i] != null && Items[i].AllowedSlots.Any(a => a != InvSlotType.Any)) { slots[i].EquipButtonState = slots[i].EquipButtonRect.Contains(PlayerInput.MousePosition) ? GUIComponent.ComponentState.Hover : GUIComponent.ComponentState.None; if (PlayerInput.LeftButtonHeld() && PlayerInput.RightButtonHeld()) { slots[i].EquipButtonState = GUIComponent.ComponentState.None; } if (slots[i].EquipButtonState != GUIComponent.ComponentState.Hover) { slots[i].QuickUseTimer = Math.Max(0.0f, slots[i].QuickUseTimer - deltaTime * 5.0f); continue; } var quickUseAction = GetQuickUseAction(Items[i], allowEquip: true, allowInventorySwap: false, allowApplyTreatment: false); slots[i].QuickUseButtonToolTip = quickUseAction == QuickUseAction.None ? "" : TextManager.Get("QuickUseAction." + quickUseAction.ToString()); //equipped item that can't be put in the inventory, use delayed dropping if (quickUseAction == QuickUseAction.Drop) { slots[i].QuickUseButtonToolTip = TextManager.Get("QuickUseAction.HoldToUnequip", returnNull: true) ?? (GameMain.Config.Language == "English" ? "Hold to unequip" : TextManager.Get("QuickUseAction.Unequip")); if (PlayerInput.LeftButtonHeld()) { slots[i].QuickUseTimer = Math.Max(0.1f, slots[i].QuickUseTimer + deltaTime); if (slots[i].QuickUseTimer >= 1.0f) { Items[i].Drop(Character.Controlled); GUI.PlayUISound(GUISoundType.DropItem); } } else { slots[i].QuickUseTimer = Math.Max(0.0f, slots[i].QuickUseTimer - deltaTime * 5.0f); } } else { if (PlayerInput.LeftButtonDown()) { slots[i].EquipButtonState = GUIComponent.ComponentState.Pressed; } if (PlayerInput.LeftButtonClicked()) { QuickUseItem(Items[i], allowEquip: true, allowInventorySwap: false, allowApplyTreatment: false); } } } } //cancel dragging if too far away from the container of the dragged item if (draggingItem != null) { var rootContainer = draggingItem.GetRootContainer(); var rootInventory = draggingItem.ParentInventory; if (rootContainer != null) { rootInventory = rootContainer.ParentInventory ?? rootContainer.GetComponent <ItemContainer>().Inventory; } if (rootInventory != null && rootInventory.Owner != Character.Controlled && rootInventory.Owner != Character.Controlled.SelectedConstruction && rootInventory.Owner != Character.Controlled.SelectedCharacter) { //allow interacting if the container is linked to the item the character is interacting with if (!(rootContainer != null && rootContainer.DisplaySideBySideWhenLinked && Character.Controlled.SelectedConstruction != null && rootContainer.linkedTo.Contains(Character.Controlled.SelectedConstruction))) { draggingItem = null; } } } doubleClickedItem = null; }
public override void Update(float deltaTime, Camera cam, bool isSubInventory = false) { if (!AccessibleWhenAlive && !character.IsDead) { syncItemsDelay = Math.Max(syncItemsDelay - deltaTime, 0.0f); return; } base.Update(deltaTime, cam); bool hoverOnInventory = GUI.MouseOn == null && ((selectedSlot != null && selectedSlot.IsSubSlot) || (draggingItem != null && (draggingSlot == null || !draggingSlot.MouseOn()))); if (CharacterHealth.OpenHealthWindow != null) { hoverOnInventory = true; } if (layout == Layout.Default && hideButton.Visible) { hideButton.AddToGUIUpdateList(); hideButton.UpdateManually(deltaTime, alsoChildren: true); hidePersonalSlotsState = hidePersonalSlots ? Math.Min(hidePersonalSlotsState + deltaTime * 5.0f, 1.0f) : Math.Max(hidePersonalSlotsState - deltaTime * 5.0f, 0.0f); for (int i = 0; i < slots.Length; i++) { if (!PersonalSlots.HasFlag(SlotTypes[i])) { continue; } if (HidePersonalSlots) { if (selectedSlot?.Slot == slots[i]) { selectedSlot = null; } highlightedSubInventorySlots.RemoveWhere(s => s.Slot == slots[i]); } slots[i].DrawOffset = Vector2.Lerp(Vector2.Zero, new Vector2(personalSlotArea.Width, 0.0f), hidePersonalSlotsState); } } if (hoverOnInventory) { HideTimer = 0.5f; } if (HideTimer > 0.0f) { HideTimer -= deltaTime; } for (int i = 0; i < capacity; i++) { if (Items[i] != null && Items[i] != draggingItem && Character.Controlled?.Inventory == this && GUI.KeyboardDispatcher.Subscriber == null && slots[i].QuickUseKey != Keys.None && PlayerInput.KeyHit(slots[i].QuickUseKey)) { QuickUseItem(Items[i], true, false, true); } } //force personal slots open if an item is running out of battery/fuel/oxygen/etc if (hidePersonalSlots) { for (int i = 0; i < slots.Length; i++) { if (Items[i]?.OwnInventory != null && Items[i].OwnInventory.Capacity == 1 && PersonalSlots.HasFlag(SlotTypes[i])) { if (Items[i].OwnInventory.Items[0] != null && Items[i].OwnInventory.Items[0].Condition > 0.0f && Items[i].OwnInventory.Items[0].Condition / Items[i].OwnInventory.Items[0].MaxCondition < 0.15f) { hidePersonalSlots = false; } } } } List <SlotReference> hideSubInventories = new List <SlotReference>(); highlightedSubInventorySlots.RemoveWhere(s => s.ParentInventory == this && ((s.SlotIndex < 0 || s.SlotIndex >= Items.Length || Items[s.SlotIndex] == null) || (Character.Controlled != null && !Character.Controlled.CanAccessInventory(s.Inventory)))); foreach (var highlightedSubInventorySlot in highlightedSubInventorySlots) { if (highlightedSubInventorySlot.ParentInventory == this) { UpdateSubInventory(deltaTime, highlightedSubInventorySlot.SlotIndex, cam); } if (!highlightedSubInventorySlot.Inventory.IsInventoryHoverAvailable(character, null)) { continue; } Rectangle hoverArea = GetSubInventoryHoverArea(highlightedSubInventorySlot); if (highlightedSubInventorySlot.Inventory?.slots == null || (!hoverArea.Contains(PlayerInput.MousePosition))) { hideSubInventories.Add(highlightedSubInventorySlot); } else { highlightedSubInventorySlot.Inventory.HideTimer = 1.0f; } } //activate the subinventory of the currently selected slot if (selectedSlot?.ParentInventory == this) { var subInventory = GetSubInventory(selectedSlot.SlotIndex); if (subInventory != null && subInventory.IsInventoryHoverAvailable(character, null)) { selectedSlot.Inventory = subInventory; if (!highlightedSubInventorySlots.Any(s => s.Inventory == subInventory)) { ShowSubInventory(selectedSlot, deltaTime, cam, hideSubInventories, false); } } } foreach (var subInventorySlot in hideSubInventories) { if (subInventorySlot.Inventory == null) { continue; } subInventorySlot.Inventory.HideTimer -= deltaTime; if (subInventorySlot.Inventory.HideTimer < 0.25f) { highlightedSubInventorySlots.Remove(subInventorySlot); } } if (character.SelectedCharacter == null) // Permanently open subinventories only available when the default UI layout is in use -> not when grabbing characters { //remove the highlighted slots of other characters' inventories when not grabbing anyone highlightedSubInventorySlots.RemoveWhere(s => s.ParentInventory != this && s.ParentInventory?.Owner is Character); for (int i = 0; i < capacity; i++) { var item = Items[i]; if (item != null) { if (HideSlot(i)) { continue; } if (character.HasEquippedItem(item)) // Keep a subinventory display open permanently when the container is equipped { var itemContainer = item.GetComponent <ItemContainer>(); if (itemContainer != null && itemContainer.KeepOpenWhenEquipped && character.CanAccessInventory(itemContainer.Inventory) && !highlightedSubInventorySlots.Any(s => s.Inventory == itemContainer.Inventory)) { ShowSubInventory(new SlotReference(this, slots[i], i, false, itemContainer.Inventory), deltaTime, cam, hideSubInventories, true); } } } } } if (doubleClickedItem != null) { QuickUseItem(doubleClickedItem, true, true, true); } for (int i = 0; i < capacity; i++) { var item = Items[i]; if (item != null) { var slot = slots[i]; if (item.AllowedSlots.Any(a => a != InvSlotType.Any)) { HandleButtonEquipStates(item, slot, deltaTime); } } } //cancel dragging if too far away from the container of the dragged item if (draggingItem != null) { var rootContainer = draggingItem.GetRootContainer(); var rootInventory = draggingItem.ParentInventory; if (rootContainer != null) { rootInventory = rootContainer.ParentInventory ?? rootContainer.GetComponent <ItemContainer>().Inventory; } if (rootInventory != null && rootInventory.Owner != Character.Controlled && rootInventory.Owner != Character.Controlled.SelectedConstruction && rootInventory.Owner != Character.Controlled.SelectedCharacter) { //allow interacting if the container is linked to the item the character is interacting with if (!(rootContainer != null && rootContainer.DisplaySideBySideWhenLinked && Character.Controlled.SelectedConstruction != null && rootContainer.linkedTo.Contains(Character.Controlled.SelectedConstruction))) { draggingItem = null; } } } doubleClickedItem = null; }
public override void AddToGUIUpdateList() { base.AddToGUIUpdateList(); createEventButton?.AddToGUIUpdateList(); }