12 public BuildMenu.Mode mode
16 return EMono.scene.actionMode.buildMenuMode;
21 public static void Toggle()
23 EMono.player.hotbars.ResetHotbar(3);
24 EMono.player.hotbars.bars[3].dirty =
true;
25 EMono.player.hotbars.ResetHotbar(4);
26 EMono.player.hotbars.bars[4].dirty =
true;
27 if (
EMono.debug.godBuild || (
EMono.Branch !=
null &&
EMono.Branch.elements.Has(4006)))
34 ActionMode.LastBuildMode.Activate(
true,
false);
41 public static void Activate()
45 BuildMenu.Instance = Util.Instantiate<
BuildMenu>(
"UI/BuildMenu/BuildMenu",
EMono.ui);
48 if (
EMono.debug.godBuild)
50 EMono._map.RevealAll(
true);
54 EMono.screen.focusPos =
null;
58 public void OnActivate()
60 if (
EMono.debug.godBuild &&
EMono.debug.GetDebugContainer() ==
null)
62 EMono.debug.EnableDebugResource();
64 EMono.ui.HideFloats();
65 this.SetActive(this.mode !=
BuildMenu.Mode.None);
66 this.transMain.SetActive(this.mode ==
BuildMenu.Mode.Build && (
EMono.debug.godBuild ||
EMono._zone.elements.Has(4005)));
67 BuildMenu.Mode mode = this.mode;
72 this.RefreshCategoryArea();
78 string cat =
EMono.player.pref.lastBuildCategory.IsEmpty(
"wall");
79 this.SelectCategory(cat);
81 UIScrollView componentInChildren = this.cg.GetComponentInChildren<UIScrollView>();
82 if (componentInChildren !=
null)
84 componentInChildren.RebuildLayout(
true);
86 this.buttonUndo.onClick.RemoveAllListeners();
87 this.buttonUndo.onClick.AddListener(delegate()
89 EMono._map.tasks.undo.Perform();
91 this.buttonUndo.SetTooltip(
"note", delegate(UITooltip tp)
93 EMono._map.tasks.undo.WriteNote(tp.note);
96 if (
EMono.debug.enable)
98 EMono._map.ResetEditorPos();
100 EMono.screen.RefreshAll();
104 public static void Deactivate()
110 UnityEngine.Object.DestroyImmediate(
BuildMenu.Instance.gameObject);
111 if (
EMono.game.altUI)
113 EMono._zone.RefreshBGM();
115 EMono.ui.ShowFloats();
116 EMono.screen.RefreshAll();
124 this.info2.transform.position = this.info1.transform.position;
125 this.orgPos = this.info1.Rect().anchoredPosition;
126 this.orgPosOption = this.transOption.anchoredPosition;
127 for (
int i = 0; i < this.categories.Length; i++)
129 if (!this.categories[i].IsEmpty())
131 this.catDic.Add(this.categories[i], i);
134 UIButton t = this.gridTab.CreateMold(
null);
135 for (
int j = 0; j < this.categories.Length - 1; j++)
138 UIButton uibutton = Util.Instantiate<UIButton>(t, this.gridTab);
139 uibutton.onClick.AddListener(delegate()
141 this.ClearSearch(
false);
142 this.SelectCategory(this.categories[_i]);
144 uibutton.mainText.SetText((
"cat_" + this.categories[j]).lang());
145 this.tabs[this.categories[j]] = uibutton;
146 if (this.categories[j].IsEmpty())
148 uibutton.mainText.SetActive(
false);
149 uibutton.interactable =
false;
152 this.groupTab.Init(-1,
null,
false);
153 EMono.ui.hud.frame.SetActive(
EMono.game.altUI);
154 this.inputSearch.onValueChanged.AddListener(
new UnityAction<string>(this.Search));
155 this.inputSearch.onSubmit.AddListener(
new UnityAction<string>(this.Search));
156 if (
EMono.game.altUI)
158 EMono.Sound.SwitchPlaylist(
EMono.Sound.playlistBuild,
true);
163 public void Search(
string s)
166 this.buttonClearSearch.SetActive(this.inputSearch.text !=
"");
167 if (s == this.lastSearch)
171 this.timerSearch = this.intervalSearch;
176 private void _Search()
178 string s = this.lastSearch;
180 HashSet<Recipe> newRecipes =
new HashSet<Recipe>();
185 if (!recipeSource.noListing && !recipeSource.isBridgePillar && (
EMono.debug.godBuild || recipeSource.alwaysKnown ||
EMono.player.recipes.knownRecipes.ContainsKey(recipeSource.id)) && (recipeSource.row.GetSearchName(
false).Contains(s) || recipeSource.row.GetSearchName(
true).Contains(s) || recipeSource.id.Contains(s) || recipeSource.row.category.Contains(s)))
187 for (
int i = 0; i < ((recipeSource.row.skins ==
null) ? 1 : (recipeSource.row.skins.Length + 1)); i++)
193 Debug.Log(recipeSource.Name +
"/" + recipeSource.id);
197 newRecipes.Add(recipe);
202 foreach (
Thing thing
in EMono._map.Stocked.Things)
204 if (thing.source.name.Contains(s) || thing.source.name_JP.Contains(s))
209 Debug.Log(thing.Name +
"/" + thing.id);
213 newRecipes.Add(recipe2);
219 if (!t.trait.CanBeDropped || t.trait.CanOnlyCarry)
223 if (t.source.name.Contains(s) || t.source.name_JP.Contains(s))
228 Debug.Log(t.Name +
"/" + t.id);
231 newRecipes.Add(recipe3);
235 if (!newRecipes.SetEquals(
this.searchRecipes))
237 this.searchRecipes = newRecipes;
238 this.RefreshCategory(this.currentCat);
244 public void ClearSearch()
246 this.ClearSearch(
true);
250 public void ClearSearch(
bool refresh)
253 this.inputSearch.text =
"";
254 this.timerSearch = 0f;
255 this.lastSearch =
"";
258 this.RefreshCategory(this.currentCat);
263 public static void Show()
272 public static void Hide()
281 private void LateUpdate()
284 if (this.timerSearch > 0f)
286 this.timerSearch -= Core.delta;
287 if (this.timerSearch <= 0f)
295 public void Refresh()
298 if (buttonGrid && buttonGrid.recipe ==
null && buttonGrid.area ==
null)
302 bool flag = EMono.scene.actionMode.ShouldHideBuildMenu || (EMono.scene.actionMode != ActionMode.Build && EMono.scene.actionMode != ActionMode.Inspect && EMono.scene.actionMode !=
ActionMode.EditArea);
303 this.cg.SetActive(!flag, delegate(
bool enabled)
307 this.list.RefreshHighlight(
false);
308 this.groupTab.RefreshButtons();
311 this.groupTab.SetActive(
EMono.scene.actionMode !=
ActionMode.EditArea);
312 this.transOption.anchoredPosition = (this.groupTab.gameObject.activeInHierarchy ? this.orgPosOption : this.posOption);
313 if (this.info1.hideMode != flag ||
this.firstRefresh)
315 this.info1.hideMode = flag;
318 this.info1.Rect().anchoredPosition = (flag ? this.posInfo1 : this.orgPos);
321 if (buttonGrid && !flag)
323 this.info2.transform.position = buttonGrid.transform.position;
324 this.info2.Rect().anchoredPosition =
new Vector2(this.info2.Rect().anchoredPosition.x +
this.posInfo2.x,
this.posInfo2.y);
325 if (buttonGrid.area !=
null)
327 this.info2.SetArea(buttonGrid.area);
331 this.info2.SetRecipe(buttonGrid.recipe);
333 this.info2.SetActive(
true);
337 this.info2.SetActive(
false);
339 this.firstRefresh =
false;
343 public void SelectCategory(
string cat)
345 if (!
BuildMenu.dirtyCat &&
this.currentCat == cat)
349 BuildMenu.dirtyCat =
false;
350 this.groupTab.Select(this.catDic[cat]);
351 this.RefreshCategory(cat);
357 EInput.Consume(
false, 10);
358 Debug.Log(EInput.skipFrame);
359 this.ClearSearch(
false);
360 this.RefreshCategory(r.source.recipeCat);
361 foreach (
object obj
in this.list.objects)
364 if (r.source == recipe.source && (r.thing ==
null || r.thing.idSkin == recipe.idSkin))
366 int index = this.list.GetIndex(recipe);
369 this.list.dsv.scrollByItemIndex(index);
378 if (buttonGrid.recipe.source == r.source && (r.thing ==
null || r.thing.idSkin == buttonGrid.recipe.idSkin))
380 this.info1.lastMats[buttonGrid.recipe.id] = r.mat.id;
381 buttonGrid.onClick.Invoke();
388 public void Unselect()
390 this.info1.SetRecipe(
null);
391 this.list.Select(
null,
false);
395 public void RefreshCategoryArea()
397 UIDynamicList uidynamicList = this.listArea;
398 List<Area> list =
new List<Area>();
402 area.data.name =
null;
405 uidynamicList.Clear();
406 object selected =
null;
417 EMono.ui.hud.hint.Refresh();
418 this.info1.SetArea(a);
423 if (this.info1.area !=
null && a.source ==
this.info1.area.source)
429 foreach (
Area area2
in list)
431 if (area2.isListable)
433 uidynamicList.Add(area2);
436 uidynamicList.List();
440 public void RefreshCategory(
string cat)
442 cat = cat.IsEmpty(this.categories[0]);
443 EMono.player.pref.lastBuildCategory = cat;
444 this.currentCat = cat;
446 object selected =
null;
448 Action<Thing> <>9__4;
454 EMono.ui.hud.hint.Refresh();
455 EMono.player.pref.lastBuildRecipe = a.source.id;
456 if (a.UseStock && (a.ingredients[0].uid == 0 || a.ingredients[0].thing ==
null))
458 Debug.LogError(
"expection: invalid ingredient:" + a.ingredients[0].uid.ToString());
460 if (this.info1.recipe != a && !a.UseStock)
464 ingredient.SetThing(
null);
467 if (a.UseStock && (a.ingredients[0].uid == 0 || a.ingredients[0].thing ==
null))
469 Debug.LogError(
"expection: invalid ingredient:" + a.ingredients[0].uid.ToString());
471 this.info1.SetRecipe(a);
472 if (a.UseStock && (a.ingredients[0].uid == 0 || a.ingredients[0].thing ==
null))
474 Debug.LogError(
"expection: invalid ingredient:" + a.ingredients[0].uid.ToString());
476 a.OnChangeIngredient();
478 this.info1.SetRecipe(a);
479 this.list.Select(a,
false);
480 if (a.UseStock && (a.ingredients[0].uid == 0 || a.ingredients[0].thing ==
null))
482 Debug.LogError(
"expection: invalid ingredient:" + a.ingredients[0].uid.ToString());
487 b.SetActive(a !=
null);
493 if (this.info1.recipe !=
null && a.id ==
this.info1.recipe.id)
497 a.BuildIngredientList();
499 onList = delegate(UIList.SortMode m)
501 foreach (
string key
in this.categories)
503 this.counts[key] = 0;
505 if (this.inputSearch.text !=
"")
507 foreach (
Recipe recipe
in this.searchRecipes)
511 Thing thing = recipe.ingredients[0].thing;
512 if (thing ==
null || thing.isDestroyed || thing.ExistsOnMap || (thing.parentCard !=
null && thing.parentCard.c_lockLv > 0))
517 this.list.Add(recipe);
523 if (
EMono.debug.godBuild || (!recipeSource.noListing && !recipeSource.row.tileType.EditorTile &&
EMono.player.recipes.IsKnown(recipeSource.id) && (recipeSource.row.factory.Length == 0 || !(recipeSource.row.factory[0] ==
"none"))))
525 Dictionary<string, int> dictionary = this.counts;
526 string recipeCat = recipeSource.recipeCat;
527 int i = dictionary[recipeCat];
528 dictionary[recipeCat] = i + 1;
529 if (!(recipeSource.recipeCat != cat))
531 for (
int j = 0; j < ((recipeSource.row.skins ==
null) ? 0 : recipeSource.row.skins.Length) + 1; j++)
535 this.list.Add(recipe2);
540 if (!
EMono.debug.hidePCItemsInBuild)
542 foreach (
Thing thing2
in EMono._map.Stocked.Things)
547 Dictionary<string, int> dictionary2 = this.counts;
548 string recipeCat = thing2.trait.RecipeCat;
549 int i = dictionary2[recipeCat];
550 dictionary2[recipeCat] = i + 1;
551 if (thing2.trait.RecipeCat == cat)
553 Card rootCard = thing2.GetRootCard();
554 if (rootCard !=
null && rootCard.c_lockLv == 0)
556 this.list.Add(thing2.trait.GetBuildModeRecipe());
562 Action<Thing> action;
563 if ((action = <>9__4) ==
null)
565 action = (<>9__4 = delegate(
Thing t)
567 if (t.trait.CanOnlyCarry || !t.trait.CanBeDropped || t.c_isImportant)
571 Dictionary<string, int> dictionary3 = this.counts;
572 string recipeCat2 = t.trait.RecipeCat;
573 int num = dictionary3[recipeCat2];
574 dictionary3[recipeCat2] = num + 1;
575 if (t.trait.RecipeCat == cat && t.invY != 1)
577 this.list.Add(t.trait.GetBuildModeRecipe());
581 things.Foreach(action,
true);
585 this.list.objects.Sort((
object a,
object b) =>
string.Compare((a as
Recipe).
id, (b as
Recipe).
id));
587 else if (cat ==
"wall" || cat ==
"floor" || cat ==
"foundation" || cat ==
"obj")
589 this.list.objects.Sort((
object a,
object b) => (a as
Recipe).renderRow.sort - (b as
Recipe).renderRow.sort);
593 this.list.objects.Sort(delegate(
object a,
object b)
597 int num = recipe3.renderRow.sort - recipe4.renderRow.sort;
602 if (recipeCard !=
null && recipeCard2 !=
null)
604 num =
string.Compare(recipeCard.sourceCard._origin.IsEmpty(recipeCard.sourceCard.id), recipeCard2.sourceCard._origin.IsEmpty(recipeCard2.sourceCard.id));
608 num =
string.Compare(recipe3.id, recipe4.id);
612 num = (recipe3.IngAsProduct ? recipe3.ingredients[0].uid : 0) - (recipe4.IngAsProduct ? recipe4.ingredients[0].uid : 0);
618 foreach (
string text
in this.categories)
620 if (!(text ==
"area") && !(text ==
""))
622 if (this.counts[text] == 0)
624 this.tabs[text].subText.text =
"";
628 this.tabs[text].subText.text = (this.counts[text].ToString() ??
"");
635 if (this.lastCat != this.currentCat)
639 this.groupTab.Select(this.catDic[cat]);
640 if (selected !=
null)
642 this.list.Select(selected,
false);
644 this.lastCat = this.currentCat;
649 public void OnClickPicker()
655 public GridLayoutGroup gridTab;
658 public UISelectableGroup groupTab;
661 public UIDynamicList list;
664 public UIDynamicList listArea;
667 public Dictionary<string, int> catDic =
new Dictionary<string, int>();
676 public RectTransform transOption;
679 public RectTransform transMain;
682 public Vector2 posInfo2;
685 public Vector2 posInfo1;
688 public Vector2 posOption;
691 public CanvasGroup cg;
694 public float hideSpeed;
697 public float intervalSearch;
700 public bool moveInfo1;
706 public InputField inputSearch;
709 public string currentCat;
712 public string lastCat;
715 public UIButton buttonClearSearch;
719 public string[] categories =
new string[]
748 public Dictionary<string, int> counts =
new Dictionary<string, int>();
751 public Dictionary<string, UIButton> tabs =
new Dictionary<string, UIButton>();
754 private Vector2 orgPos;
757 private Vector2 orgPosOption;
763 public UIButton buttonUndo;
766 public static bool dirtyCat;
769 private float timerSearch;
772 public string lastSearch;
775 public HashSet<Recipe> searchRecipes =
new HashSet<Recipe>();
778 private bool firstRefresh =
true;