Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerRegisterHotbar.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3using UnityEngine.UI;
4
6{
7 public Image moldCover;
8
9 private List<WidgetHotbar> hotbars = new List<WidgetHotbar>();
10
11 private List<Image> covers = new List<Image>();
12
13 public void SetItem(SourceElement.Row act)
14 {
16 {
17 id = act.id
18 });
19 }
20
22 {
23 return SetItem(t.trait.GetHotItem());
24 }
25
26 public void SetItem(Chara c)
27 {
29 {
30 uid = c.uid
31 });
32 }
33
35 {
36 WidgetHotbar.registeringItem = item;
37 Show();
38 return this;
39 }
40
41 public void Show()
42 {
43 WidgetHotbar.registering = true;
44 foreach (Widget item in ELayer.ui.widgets.list)
45 {
46 WidgetHotbar widgetHotbar = item as WidgetHotbar;
47 if (!(widgetHotbar == null) && widgetHotbar.CanRegisterItem && !widgetHotbar.hotbar.IsLocked)
48 {
49 if (!widgetHotbar.Visible)
50 {
51 widgetHotbar.ToggleVisible();
52 }
53 widgetHotbar.transform.SetParent(base.transform, worldPositionStays: false);
54 hotbars.Add(widgetHotbar);
55 }
56 }
57 }
58
60 {
61 foreach (WidgetHotbar hotbar in hotbars)
62 {
63 foreach (ButtonHotItem button in hotbar.buttons)
64 {
65 if (InputModuleEX.IsPointerOver(button))
66 {
67 return button;
68 }
69 }
70 }
71 return null;
72 }
73
74 public bool OnEndDrag()
75 {
76 ButtonHotItem button = GetButton();
77 if ((bool)button)
78 {
79 button.onClick.Invoke();
80 return true;
81 }
82 return false;
83 }
84
85 public override void OnKill()
86 {
87 foreach (WidgetHotbar hotbar in hotbars)
88 {
89 hotbar.transform.SetParent(ELayer.ui.widgets.transform, worldPositionStays: false);
90 }
91 foreach (Image cover in covers)
92 {
93 Object.DestroyImmediate(cover.gameObject);
94 }
95 WidgetHotbar.registering = false;
96 WidgetHotbar.registeringItem = null;
97 }
98}
Trait trait
Definition: Card.cs:49
Definition: Chara.cs:10
Definition: ELayer.cs:4
static UI ui
Definition: ELayer.cs:21
bool IsLocked
Definition: Hotbar.cs:99
static bool IsPointerOver(Component c)
List< WidgetHotbar > hotbars
LayerRegisterHotbar SetItem(HotItem item)
void SetItem(SourceElement.Row act)
LayerRegisterHotbar SetItem(Thing t)
ButtonHotItem GetButton()
override void OnKill()
string uid
Definition: Layer.cs:125
Definition: Thing.cs:8
virtual HotItem GetHotItem()
Definition: Trait.cs:914
Hotbar hotbar
Definition: WidgetHotbar.cs:65
void ToggleVisible()
bool CanRegisterItem
Definition: WidgetHotbar.cs:83
List< ButtonHotItem > buttons
Definition: WidgetHotbar.cs:57
Definition: Widget.cs:7