// --------- protected override void OnShow() { base.OnShow(); for (int i = 0; i < m_GuiGadgets.Length; i++) { if (m_GuiGadgets[i] != null) { bool shouldBeVisible = i < Gadgets.Count && Gadgets[i] != E_ItemID.None ? true : false; m_GuiGadgets[i].m_Parent.Show(shouldBeVisible, true); } } PerkInfo perk = LocalPlayer.Owner.GadgetsComponent.Perk; if (m_Perk != null) { m_Perk.m_Parent.Show(!perk.IsEmpty(), true); } RegisterFloatingFireInteractions(); ShowSelection(true); }
// ----------- void UpdateGadgets() { if (!LocalPlayer) { return; } for (int i = 0; i < Gadgets.Count; i++) { if (i >= m_GuiGadgets.Length) { break; } if (Gadgets[i] == E_ItemID.None) { continue; } Item gadget = LocalPlayer.Owner.GadgetsComponent.GetGadget(Gadgets[i]); if (gadget.Settings.ItemBehaviour == E_ItemBehaviour.Booster) { if (gadget.IsAvailableForUse() || gadget.Active) { if (m_GuiGadgets[i].m_IsTransparent) { m_GuiGadgets[i].SetAllTransparent(false); } } else { if (!m_GuiGadgets[i].m_IsTransparent) { m_GuiGadgets[i].SetAllTransparent(true); } } UpdateGuiGadgetBar(m_GuiGadgets[i], gadget.Timer, m_GuiGadgets[i].m_Settings.BoostTimer, gadget.Count, gadget.OrigCount, true); } else { if (gadget.IsAvailableForUse()) { if (m_GuiGadgets[i].m_IsTransparent) { m_GuiGadgets[i].SetAllTransparent(false); } } else { if (!m_GuiGadgets[i].m_IsTransparent) { m_GuiGadgets[i].SetAllTransparent(true); } } UpdateGuiGadgetBar(m_GuiGadgets[i], gadget.Timer, m_GuiGadgets[i].m_Settings.Timer, gadget.Count, gadget.OrigCount, false); } } PerkInfo perk = LocalPlayer.Owner.GadgetsComponent.Perk; if (!perk.IsEmpty()) { UpdateGuiGadgetBar(m_Perk, perk.Timer, m_Perk.m_Settings.Timer, 0, 0, perk.IsSprint()); } }
// ----------- //create gadgets buttons public void CreateGadgetInventory(PlayerPersistantInfo ppi) { ResetGadgetsList(); // ---------- foreach (PPIItemData d in ppi.EquipList.Items) { if (d.ID == E_ItemID.None) { continue; } Gadgets[d.EquipSlotIdx] = d.ID; } for (int i = 0; i < m_GuiGadgets.Length; i++) { m_GuiGadgets[i] = new GuiGadget <ItemSettings>(); GUIBase_Widget parent = PrepareWidget(m_LayoutMain, "Gadget_" + (i + 1)); m_GuiGadgets[i].m_Parent = parent; m_GuiGadgets[i].m_Button = GuiBaseUtils.GetButton(m_LayoutMain, s_GadgetsBtnNames[i]); m_GuiGadgets[i].m_GadgetIcon = GuiBaseUtils.GetChildSprite(parent, "GadgetIcon").Widget; m_GuiGadgets[i].m_BarBck = GuiBaseUtils.GetChildSprite(parent, "Meter_Back").Widget; m_GuiGadgets[i].m_Progress = GuiBaseUtils.GetChildSprite(parent, "Meter_BAR").Widget; m_GuiGadgets[i].m_Div2 = GuiBaseUtils.GetChildSprite(parent, "Meter_Div2").Widget; m_GuiGadgets[i].m_Div3 = GuiBaseUtils.GetChildSprite(parent, "Meter_Div3").Widget; m_GuiGadgets[i].m_PrevScale = -1; if (i >= Gadgets.Count || Gadgets[i] == E_ItemID.None) { m_GuiGadgets[i].m_Parent.Show(false, true); continue; } m_GuiGadgets[i].m_Settings = ItemSettingsManager.Instance.Get(Gadgets[i]); GuiBaseUtils.RegisterButtonDelegate(m_LayoutMain, s_GadgetsBtnNames[i], s_GadgetsBtnDelegates[i], null); GUIBase_Sprite s = GuiBaseUtils.GetChildSprite(parent, "GadgetIcon"); s.Widget.CopyMaterialSettings(m_GuiGadgets[i].m_Settings.HudWidget); m_GuiGadgets[i].m_Parent.Show(true, true); m_GuiGadgets[i].SetAllTransparent(false); Item gadget = LocalPlayer.Owner.GadgetsComponent.GetGadget(Gadgets[i]); UpdateGuiGadgetBar(m_GuiGadgets[i], gadget.Timer, m_GuiGadgets[i].m_Settings.Timer, gadget.Count, gadget.OrigCount, false); } // ---------- m_Perk = new GuiGadget <PerkSettings>(); m_Perk.m_Parent = PrepareWidget(m_LayoutMain, "Perk"); m_Perk.m_Button = GuiBaseUtils.GetButton(m_LayoutMain, "GButton"); m_Perk.m_GadgetIcon = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "GadgetIcon").Widget; m_Perk.m_BarBck = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "Meter_Back").Widget; m_Perk.m_Progress = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "Meter_BAR").Widget; m_Perk.m_Div2 = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "Meter_Div2").Widget; m_Perk.m_Div3 = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "Meter_Div3").Widget; m_Perk.m_PrevScale = -1; PerkInfo perk = LocalPlayer.Owner.GadgetsComponent.Perk; m_Perk.m_Settings = PerkSettingsManager.Instance.Get(ppi.EquipList.Perk); if (!perk.IsEmpty()) { GUIBase_Sprite s = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "GadgetIcon"); s.Widget.CopyMaterialSettings(m_Perk.m_Settings.HudWidget); m_Perk.m_Parent.Show(true, true); UpdateGuiGadgetBar(m_Perk, perk.Timer, m_Perk.m_Settings.Timer, 0, 0, perk.IsSprint()); } else { m_Perk.m_Parent.Show(false, true); } //m_Perk.SetAllTransparent(false); m_SelIndex = SelectFirst(); m_SelectionWidget = m_LayoutMain.GetWidget("GadgetSelection_Sprite", true); ShowSelection(true); m_Initialised = true; UpdateControlsPosition(); RegisterFloatingFireInteractions(); }