Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerCraftFloat.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
4public class LayerCraftFloat : ELayer
5{
6 public static LayerCraftFloat Instance;
7
9
10 public Recipe recipe;
11
13
14 public int maxSize;
15
16 public int paddingY;
17
18 public int paddingY2;
19
20 public string idLastRecipe;
21
22 public override void OnInit()
23 {
24 Instance = this;
25 }
26
27 public override void OnSwitchContent(Window window)
28 {
30 {
32 }
33 }
34
35 public void Update()
36 {
38 {
39 ButtonGrid componentOf = InputModuleEX.GetComponentOf<ButtonGrid>();
40 if ((bool)componentOf && componentOf.transform.IsChildOf(base.transform))
41 {
42 Recipe recipe = componentOf.recipe;
43 if (recipe != null && windows[0].idTab == 0)
44 {
46 }
47 }
48 }
49 if (Input.GetMouseButton(0))
50 {
51 ButtonGrid componentOf2 = InputModuleEX.GetComponentOf<ButtonGrid>();
52 if ((bool)componentOf2 && componentOf2.transform.IsChildOf(base.transform) && ELayer.player.waitingInput && ELayer.pc.HasNoGoal && componentOf2.recipe.id == idLastRecipe)
53 {
54 list.callbacks.OnClick(componentOf2.recipe, componentOf2);
55 }
56 }
57 else
58 {
59 idLastRecipe = null;
60 }
61 }
62
63 public void OnCompleteCraft()
64 {
65 }
66
67 public void RefreshCraft()
68 {
69 list.callbacks = new UIList.Callback<Recipe, ButtonGrid>
70 {
71 onClick = delegate(Recipe a, ButtonGrid b)
72 {
73 ELayer.ui.RemoveLayers();
75 if (!RecipeUpdater.recipes.Contains(a))
76 {
77 SE.BeepSmall();
79 }
80 else
81 {
83 recipe = a;
86 {
87 SE.BeepSmall();
88 }
89 else
90 {
91 TaskCraft taskCraft = new TaskCraft
92 {
93 recipe = recipe,
94 num = 1,
95 repeat = false,
96 floatMode = true
97 };
98 taskCraft.ResetReq();
99 if (!taskCraft.IsIngredientsValid(destoryResources: false, taskCraft.num))
100 {
101 SE.Beep();
102 }
103 else
104 {
105 ELayer.pc.SetAI(taskCraft);
107 }
108 }
109 }
110 },
111 onRedraw = delegate(Recipe a, ButtonGrid b, int i)
112 {
113 b.SetCraftRecipe(a, ButtonGrid.Mode.RecipeGrid, tooltip: true);
114 if (!ELayer.player.recipes.hoveredRecipes.Contains(a.id))
115 {
116 b.Attach("recipe_new", rightAttach: false);
117 }
118 b.onRightClick = delegate
119 {
121 };
122 },
123 onList = delegate
124 {
126 {
127 list.Add(recipe);
128 }
129 }
130 };
131 list.List();
132 RefreshSize();
133 list.dsv.OnResize();
134 }
135
136 public void ShowContextMenu(Recipe a)
137 {
138 UIContextMenu i = ELayer.ui.CreateContextMenuInteraction();
139 Point point = ELayer.pc.pos.Copy();
140 foreach (Recipe.Ingredient ing in a.ingredients)
141 {
142 UIContextMenu uIContextMenu = ((a.ingredients.Count == 1) ? i : i.AddChild(ing.GetName() + "x" + ing.req));
143 List<Thing> list = new List<Thing>();
144 foreach (Thing thing in ELayer.pc.things)
145 {
146 thing.GetIngredients(ing, list);
147 }
148 for (int j = point.x - 1; j < point.x + 2; j++)
149 {
150 if (j < 0 || j >= ELayer._map.Size)
151 {
152 continue;
153 }
154 for (int k = point.z - 1; k < point.z + 2; k++)
155 {
156 if (k < 0 || k >= ELayer._map.Size)
157 {
158 continue;
159 }
160 Cell cell = ELayer._map.cells[j, k];
161 if (cell.detail == null || cell.detail.things.Count == 0)
162 {
163 continue;
164 }
165 foreach (Thing thing2 in cell.detail.things)
166 {
167 thing2.GetIngredients(ing, list);
168 }
169 }
170 }
171 foreach (Thing t in list)
172 {
173 UIButton uIButton = Util.Instantiate(moldButtonContext);
174 uIContextMenu.AddGameObject(uIButton);
175 t.SetImage(uIButton.icon);
176 uIButton.mainText.text = t.Name + ((t.parent == ELayer.pc) ? "" : ("(" + ((t.parent == ELayer._zone) ? "ground".lang() : (t.parent as Card)?.Name) + ")"));
177 uIButton.onClick.AddListener(delegate
178 {
179 ing.thing = t;
180 SE.ClickOk();
181 this.list.List();
182 i.Hide();
183 });
184 }
185 }
186 i.Show();
187 }
188
189 public void RefreshDisassemble()
190 {
191 list.callbacks = new UIList.Callback<Thing, ButtonGrid>
192 {
193 onClick = delegate(Thing a, ButtonGrid b)
194 {
196 {
197 SE.BeepSmall();
198 }
199 else
200 {
201 a.Disassemble();
203 }
204 },
205 onRedraw = delegate(Thing a, ButtonGrid b, int i)
206 {
207 b.SetCard(a, ButtonGrid.Mode.RecipeGrid, delegate(UINote n)
208 {
209 RecipeSource recipeSource = RecipeManager.Get(a.id);
210 if (recipeSource != null)
211 {
212 n.Space();
213 Recipe.Create(recipeSource).WriteReqSkill(n);
214 }
215 });
216 b.mainText.SetActive(enable: false);
217 },
218 onList = delegate
219 {
220 foreach (Thing item in RecipeUpdater.listD)
221 {
222 list.Add(item);
223 }
224 }
225 };
226 list.List();
227 RefreshSize();
228 list.dsv.OnResize();
229 }
230
231 public void RefreshSize()
232 {
233 list.dsv.GetComponent<UIScrollView>().enabled = list.ItemCount > 0;
234 RectTransform rectTransform = windows[0].Rect();
235 float x = rectTransform.sizeDelta.x;
236 float num = list.Rect().sizeDelta.y;
237 if (num > (float)maxSize)
238 {
239 num = maxSize;
240 }
241 rectTransform.sizeDelta = new Vector2(x, num + (float)((list.ItemCount > 0) ? paddingY : paddingY2));
242 rectTransform.RebuildLayout();
243 }
244}
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
void SetTurbo(int mtp=-1)
Definition: AM_Adv.cs:1040
static AM_Adv Adv
Definition: ActionMode.cs:15
UIList.ICallback callbacks
Definition: BaseList.cs:13
void SetCraftRecipe(Recipe r, Mode mode, bool tooltip=false)
Definition: ButtonGrid.cs:585
void SetCard(Card c, Mode mode=Mode.Default, Action< UINote > onWriteNote=null)
Definition: ButtonGrid.cs:184
Transform Attach(string id, bool rightAttach=true)
Definition: ButtonGrid.cs:63
Recipe recipe
Definition: ButtonGrid.cs:20
Definition: Card.cs:11
string id
Definition: Card.cs:31
ICardParent parent
Definition: Card.cs:51
Point pos
Definition: Card.cs:55
ThingContainer things
Definition: Card.cs:34
void SetImage(Image image, int dir, int idSkin=0)
Definition: Card.cs:5355
List< Thing > things
Definition: CellDetail.cs:11
Definition: Cell.cs:7
CellDetail detail
Definition: Cell.cs:92
AIAct SetAI(AIAct g)
Definition: Chara.cs:8045
bool IsGameStarted
Definition: Core.cs:84
Definition: EInput.cs:8
static ButtonState middleMouse
Definition: EInput.cs:353
Definition: ELayer.cs:4
static Chara pc
Definition: ELayer.cs:15
static Player player
Definition: ELayer.cs:13
static Core core
Definition: ELayer.cs:7
static Game game
Definition: ELayer.cs:9
static Map _map
Definition: ELayer.cs:23
static UI ui
Definition: ELayer.cs:21
static Zone _zone
Definition: ELayer.cs:25
RecipeUpdater recipe
Definition: GameUpdater.cs:363
GameUpdater updater
Definition: Game.cs:243
override void OnInit()
static LayerCraftFloat Instance
override void OnSwitchContent(Window window)
UIDynamicList list
UIButton moldButtonContext
void ShowContextMenu(Recipe a)
List< Window > windows
Definition: Layer.cs:116
int Size
Definition: MapBounds.cs:20
Cell[,] cells
Definition: Map.cs:85
RecipeManager recipes
Definition: Player.cs:898
void EndTurn(bool consume=true)
Definition: Player.cs:1866
bool waitingInput
Definition: Player.cs:960
Definition: Point.cs:9
Point Copy()
Definition: Point.cs:467
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
static RecipeSource Get(string id)
HashSet< string > hoveredRecipes
void Build(Point _p, Mode _mode=Mode.Passive)
static HashSet< Recipe > recipes
static List< Thing > listD
Definition: Recipe.cs:7
string id
Definition: Recipe.cs:161
List< Ingredient > ingredients
Definition: Recipe.cs:164
static Recipe Create(RecipeSource _source, int idMat=-1, Thing ing=null)
Definition: Recipe.cs:308
virtual void OnChangeIngredient()
Definition: Recipe.cs:532
void ResetReq()
Definition: TaskCraft.cs:53
int num
Definition: TaskCraft.cs:13
bool IsIngredientsValid(bool destoryResources=false, int numCraft=1)
Definition: TaskCraft.cs:111
Definition: Thing.cs:8
void GetIngredients(Recipe.Ingredient ing, List< Thing > list)
Definition: Thing.cs:1654
void Disassemble()
Definition: Thing.cs:1691
Image icon
Definition: UIButton.cs:110
UIText mainText
Definition: UIButton.cs:102
void Show(UIItem i)
UIContextMenu AddChild(string idLang, TextAnchor anchor)
override void List()
override void Add(object o)
DynamicScrollView dsv
override int ItemCount
Definition: UIList.cs:9
Definition: UINote.cs:6
void Space(int sizeY=0, int sizeX=1)
Definition: UINote.cs:62
Definition: Window.cs:13