15 return Core.Instance.Colors;
25 if (this.card ==
null || this.card.isDestroyed)
35 public virtual float extFixY
44 public override string ToString()
46 Card card = this.card;
51 return card.ToString();
55 public T Attach<T>(
string id,
bool rightAttach =
true) where T : Component
57 return this.Attach(
id, rightAttach).GetComponent<T>();
61 public Transform Attach(
string id,
bool rightAttach =
true)
63 Transform transform = PoolManager.Spawn<Transform>(
"attach_" + id,
"UI/Element/Grid/Attach/" + id, base.transform);
64 this.listAttach.Add(transform);
67 RectTransform rectTransform = transform.Rect();
68 rectTransform.anchoredPosition =
new Vector2(rectTransform.anchoredPosition.x, (
float)(-8 - 8 *
this.rightAttachCount));
69 transform.tag =
"RightAttach";
70 this.rightAttachCount++;
77 public void Dettach(
string id)
79 this.listAttach.ForeachReverse(delegate(Transform t)
83 if (t.tag.Contains(
"RightAttach"))
85 this.rightAttachCount--;
87 this.listAttach.Remove(t);
88 PoolManager.Despawn(t);
96 base.image.color = Color.white;
97 if (this.listAttach.Count > 0)
99 foreach (Transform c
in this.listAttach)
101 PoolManager.Despawn(c);
103 this.listAttach.Clear();
107 this.icon.enabled =
true;
109 this.rightAttachCount = 0;
113 protected override void OnDestroy()
115 if (this.listAttach.Count > 0)
119 this.rightAttachCount = 0;
125 this.SetCardGrid(b.thing, owner);
126 this.imageCheck.sprite = SpriteSheet.Get(
"Media/Graphics/Icon/Element/",
"eq_" + b.element.alias);
127 this.imageCheck.SetNativeSize();
128 this.imageCheck.SetAlpha((b.thing ==
null) ? 1f : 0.4f);
134 this.SetCardGrid(this.card, this.invOwner);
142 this.invOwner = owner;
144 if (c !=
null && !c.isDestroyed)
146 base.interactable =
true;
148 this.SetCard(c,
ButtonGrid.Mode.Grid, delegate(UINote n)
151 if (invOwner ==
null)
155 invOwner.OnWriteNote(
this, n);
157 this.onRightClick = delegate()
159 if (!
EClass.ui.AllowInventoryInteractions)
163 if (this.invOwner ==
null)
167 InvOwner.clickTimer = 0f;
168 this.invOwner.OnRightClick(
this);
169 UIButton.onPressed = delegate()
171 this.invOwner.OnRightPressed(
this);
173 EInput.Consume(
false, 1);
174 UIButton.TryShowTip(
null,
true,
true);
176 this.SetOnClick(delegate
178 if (!
EClass.ui.AllowInventoryInteractions)
183 if (invOwner !=
null)
185 invOwner.OnClick(
this);
187 EInput.Consume(
false, 1);
188 UIButton.TryShowTip(
null,
true,
true);
196 CS$<>8__locals1.<>4__this =
this;
197 CS$<>8__locals1.c = c;
198 CS$<>8__locals1.onWriteNote = onWriteNote;
200 CS$<>8__locals1.refs =
EClass.core.refs.buttonAssets;
201 this.card = CS$<>8__locals1.c;
202 ButtonGrid.<>c__DisplayClass25_0 CS$<>8__locals2 = CS$<>8__locals1;
204 CS$<>8__locals2.showNew = (invOwner !=
null && invOwner.ShowNew);
205 if (CS$<>8__locals1.c !=
null && !CS$<>8__locals1.c.isDestroyed)
207 base.SetTooltip(
"note", delegate(UITooltip t)
209 if (CS$<>8__locals1.c.isNew)
211 CS$<>8__locals1.c.isNew =
false;
212 base.<SetCard>g__RefreshBG|0();
214 CS$<>8__locals1.c.WriteNote(t.note, CS$<>8__locals1.onWriteNote,
IInspect.NoteMode.Default,
null);
215 if (CS$<>8__locals1.<>4__this.ing !=
null)
218 t.note.AddText(
"mark_ing".lang() + (CS$<>8__locals1.<>4__this.ing.optional ?
"opIngredient" :
"reqIng").lang(CS$<>8__locals1.<>4__this.ing.GetName(),
null,
null,
null,
null), FontColor.DontChange);
221 CS$<>8__locals1.c.SetImage(this.icon);
222 if (CS$<>8__locals1.c ==
EClass.pc.held && CS$<>8__locals1.c.invY != 1)
224 this.Attach(
"held",
true);
228 this.Attach<Image>(
"target_self",
true).sprite = (CS$<>8__locals1.c.trait as
TraitAbility).act.TargetType.IconType;
230 if (
EClass.core.config.test.showRefIcon && CS$<>8__locals1.c.IsIdentified)
233 if (refElement !=
null)
235 if (refElement.GetSprite())
237 Image image = this.Attach<Image>(
"reficon",
false);
238 refElement.SetImage(image);
243 Sprite refSprite = CS$<>8__locals1.c.trait.GetRefSprite();
246 Image image2 = this.Attach<Image>(
"reficon",
false);
247 image2.sprite = refSprite;
248 image2.color = Color.white;
252 if (CS$<>8__locals1.c.qualityTier > 0)
254 this.Attach<Image>(
"quality",
false).sprite =
EClass.core.refs.icons.quality[Mathf.Clamp(CS$<>8__locals1.c.qualityTier - 1, 0,
EClass.core.refs.icons.quality.Count - 1)];
256 if (CS$<>8__locals1.c.c_equippedSlot != 0 &&
this.invOwner !=
null &&
this.invOwner.owner.isChara && !
this.invOwner.owner.IsPC)
258 this.Attach(
"equip",
false);
260 if (CS$<>8__locals1.c.isNPCProperty || CS$<>8__locals1.c.isGifted)
262 this.Attach(
"npcProperty",
true);
266 CS$<>8__locals1.c.trait.OnSetCardGrid(
this);
272 Color c2 = this.Colors.Skin.textUnidentified;
273 if (CS$<>8__locals1.c.IsIdentified)
275 switch (CS$<>8__locals1.c.blessedState)
277 case BlessedState.Doomed:
278 c2 = this.Colors.Skin.textDoomed;
280 case BlessedState.Cursed:
281 c2 = this.Colors.Skin.textCursed;
283 case BlessedState.Blessed:
284 c2 = this.Colors.Skin.textBlessed;
287 c2 = this.Colors.Skin.textIdentified;
290 this.mainText.SetText(CS$<>8__locals1.c.Name, c2);
293 this.subText.SetText(Lang._weight(CS$<>8__locals1.c.ChildrenAndSelfWeight,
true, 0));
299 CS$<>8__locals1.<SetCard>g__RefreshBG|0();
300 if (CS$<>8__locals1.c.IsContainer && CS$<>8__locals1.c.c_indexContainerIcon != 0)
302 this.Attach(
"icon_container",
false).GetComponent<Image>().sprite =
EClass.core.refs.spritesContainerIcon[CS$<>8__locals1.c.c_indexContainerIcon];
304 if (CS$<>8__locals1.c.IsIdentified)
306 BlessedState blessedState = CS$<>8__locals1.c.blessedState;
307 if (blessedState != BlessedState.Normal)
309 this.Attach(
"status_" + blessedState.ToString(),
true);
314 this.Attach(
"status_unidentified",
true);
316 if (CS$<>8__locals1.c.IsDecayed)
318 this.Attach(
"rotten",
true);
320 else if (CS$<>8__locals1.c.IsRotting)
322 this.Attach(
"rotting",
true);
324 CS$<>8__locals1.c.trait.SetMainText(this.mainText,
false);
327 Card rootCard = CS$<>8__locals1.c.GetRootCard();
328 if (rootCard !=
EClass.pc)
330 this.Attach((rootCard == CS$<>8__locals1.c) ?
"searched" :
"searched_container",
false);
335 if (CS$<>8__locals1.c.IsIdentified)
337 BlessedState blessedState2 = CS$<>8__locals1.c.blessedState;
338 if (blessedState2 != BlessedState.Normal)
340 this.Attach(
"status_" + blessedState2.ToString(),
true);
345 this.Attach(
"status_unidentified",
true);
347 if (CS$<>8__locals1.c.IsDecayed)
349 this.Attach(
"rotten",
true);
351 else if (CS$<>8__locals1.c.IsRotting)
353 this.Attach(
"rotting",
true);
357 if (CS$<>8__locals1.c.c_isImportant)
359 this.Attach(
"important",
true);
365 CS$<>8__locals1.<SetCard>g__RefreshBG|0();
366 this.icon.sprite =
EClass.core.refs.icons.trans;
367 this.mainText.text =
"";
370 this.subText.text =
"";
375 this.icon.sprite = Core.Instance.refs.spriteNoIng;
377 this.icon.SetNativeSize();
378 if (this.invOwner ==
null || !this.invOwner.AlwaysShowTooltip || CS$<>8__locals1.onWriteNote ==
null)
380 base.SetTooltip(
null,
false);
383 base.SetTooltip(
"note", delegate(UITooltip t)
385 CS$<>8__locals1.onWriteNote(t.note);
390 public void SetArea(
Area a)
393 this.icon.sprite = SpriteSheet.Get(
"icon_area");
394 this.icon.SetNativeSize();
395 this.mainText.SetActive(
false);
402 this.mainText.SetActive(
true);
407 public void SetObject(
object o)
411 this.SetArea(o as
Area);
421 public void SetDummy()
424 this.icon.enabled =
false;
425 this.mainText.SetActive(
false);
426 base.onClick.RemoveAllListeners();
427 base.onClick.AddListener(delegate()
431 this.tooltip.enable =
false;
432 base.image.color =
new Color(1f, 1f, 1f, 0.3f);
436 public virtual void SetDragParent(IDragParent p)
443 if (_ing.id.IsEmpty())
448 this.mainText.SetActive(
true);
449 base.image.color = Color.white;
451 if (this.ing.thing !=
null && (
this.ing.thing.isDestroyed ||
this.ing.thing.Num == 0))
453 this.ing.thing =
null;
455 Thing thing = this.ing.thing;
456 this.SetCard(thing,
ButtonGrid.Mode.Ingredient,
null);
457 if (r !=
null && r.source.colorIng != 0 && r.ingredients !=
null && r.ingredients.Count > 0 && r.ingredients.IndexOf(_ing) == r.source.colorIng)
459 this.Attach(
"ing_color",
false);
461 if (this.ing.optional)
463 UIButton componentInChildren = this.Attach(
"ing_option",
false).GetComponentInChildren<UIButton>(
true);
464 componentInChildren.SetActive(this.ing.thing !=
null);
465 componentInChildren.SetOnClick(delegate
468 this.ing.thing =
null;
469 this.SetIngredient(r, _ing);
470 r.OnChangeIngredient();
477 HitSummary summary = Core.Instance.screen.tileSelector.summary;
478 int num = (thing ==
null) ? 0 : thing.Num;
479 int num2 = summary.countValid;
484 num2 *= this.ing.req;
485 if (this.ing.optional && num == 0)
489 bool flag = num < num2 && !this.ing.optional;
490 string text = (num.ToString() ??
"").TagColor(this.Colors.colorIngPredict) + (
" -" + num2.ToString()).TagColor(flag ? this.Colors.colorIngCost :
this.Colors.colorIngReq);
491 this.mainText.text = text;
494 base.SetTooltip(
"note", delegate(UITooltip tt)
497 tt.note.Space(16, 1);
498 tt.note.AddText(
"mark_ing".lang() + (this.ing.optional ?
"opIngredient" :
"noIngredient").lang(_ing.GetName(),
null,
null,
null,
null),
this.ing.optional ? FontColor.Good : FontColor.Bad);
501 EClass.sources.cards.map[this.ing.IdThing].SetImage(this.icon,
null, 0,
true, 0, 0);
502 this.icon.SetAlpha(0.5f);
505 if (thing.GetRootCard() !=
EClass.pc)
507 this.Attach(
"pcInv",
false);
514 this.SetCard(t,
ButtonGrid.Mode.Ingredient,
null);
516 this.mainText.text = (num.ToString() ??
"");
517 this.mainText.SetActive(
true);
518 if (t.GetRootCard() !=
EClass.pc)
520 this.Attach(
"pcInv",
false);
529 if (recipe.UseStock && !recipe.VirtualBlock && recipe.ingredients[0].thing !=
null)
531 recipe.ingredients[0].thing.SetImage(this.icon, a.dir, recipe.ingredients[0].thing.idSkin);
535 recipe.renderRow.SetImage(this.icon,
null, recipe.renderRow.GetColorInt(recipe.GetColorMaterial()),
true, a.dir, recipe.idSkin);
537 this.mainText.SetActive(
false);
541 public void SetRecipe()
543 this.SetRecipe(this.recipe);
547 public void SetRecipe(
Area a)
551 this.icon.sprite = Core.Instance.refs.spriteArea;
552 this.icon.SetNativeSize();
553 this.mainText.SetActive(
false);
557 public void SetRecipe(
Recipe r)
563 this.recipe.ingredients[0].RefreshThing();
564 Thing thing = this.recipe.ingredients[0].thing;
565 this.mainText.SetText(thing.Num.ToString() ??
"", SkinManager.CurrentColors.buttonGrid);
568 r.renderRow.SetImage(this.icon,
null, r.GetDefaultColor(),
true, 0, thing.idSkin);
572 thing.SetImage(this.icon);
577 r.renderRow.SetImage(this.icon,
null, r.GetDefaultColor(),
true, 0, r.idSkin);
579 this.mainText.SetActive(r.UseStock);
582 Thing thing2 = r.ingredients[0].thing;
583 if (((thing2 !=
null) ? thing2.GetRootCard() :
null) !=
EClass.pc)
585 this.Attach(
"pcInv",
false);
591 public void RefreshCraftable()
593 ThingStack thingStack =
EClass.pc.things.GetThingStack(this.recipe.GetIdThing(),
this.recipe.GetRefVal());
594 bool flag = this.recipe.IsCraftable();
595 this.mainText.SetText(this.recipe.Name, flag ? FontColor.Good : FontColor.Bad);
596 this.subText.text = (thingStack.count.ToString() ??
"");
597 this.recipe.SetTextDifficulty(this.subText2);
601 public void SetCraftRecipe(
Recipe r,
ButtonGrid.Mode mode,
bool tooltip =
false)
607 this.RefreshCraftable();
611 this.mainText.SetActive(
false);
616 r.SetImage(this.icon);
620 r.SetImage(this.icon);
624 Action<UINote> <>9__1;
625 base.SetTooltip(
"note", delegate(UITooltip t)
627 if (r.ingredients.Count == 0)
629 r.BuildIngredientList();
631 EClass.player.recipes.hoveredRecipes.Add(r.id);
632 this.Dettach(
"recipe_new");
635 if (mode ==
ButtonGrid.Mode.RecipeGrid && rCard._mold ==
null)
638 rCard._mold =
ThingGen.Create(r.id, -1, -1);
640 Card mold = rCard.Mold;
641 UINote note = t.note;
642 Action<UINote> onWriteNote;
643 if ((onWriteNote = <>9__1) ==
null)
645 onWriteNote = (<>9__1 = delegate(UINote n)
648 this.WriteReqMat(n, r);
651 mold.WriteNote(note, onWriteNote,
IInspect.NoteMode.Product, r);
654 UINote note2 = t.note;
656 note2.AddHeaderCard(r.GetName(),
this.icon.sprite);
657 if (!r.GetDetail().IsEmpty())
659 note2.AddText(r.GetDetail(), FontColor.DontChange);
661 this.WriteReqMat(note2, r);
668 public void WriteReqMat(UINote n,
Recipe r)
670 r.WriteReqFactory(n,
true);
672 n.AddHeaderTopic(
"reqMat",
null);
675 int count =
EClass._map.Stocked.ListThingStack(ingredient, StockSearchMode.AroundPC).count;
676 Color c = (count >= ingredient.req) ? SkinManager.CurrentColors.textGood : SkinManager.CurrentColors.textBad;
677 string text =
string.Concat(
new string[]
682 ingredient.GetName(),
684 ingredient.req.ToString(),
689 if (ingredient.optional)
691 text =
"opIngredient".lang(text,
null,
null,
null,
null);
693 n.AddText(text, FontColor.DontChange).text1.SetSize(-1);
698 public bool ShowMouseHintLeft()
700 return this.invOwner !=
null && this.card !=
null && (this.invOwner.CanShiftClick(
this,
false) || this.invOwner.CanCtrlClick(
this) ||
this.invOwner.CanAltClick(
this));
704 public string GetTextMouseHintLeft()
706 if (this.invOwner.CanShiftClick(
this,
false))
708 return this.invOwner.GetTextShiftClick(
this);
710 if (this.invOwner.CanCtrlClick(
this))
712 return this.invOwner.GetTextCtrlClick(
this);
714 if (!this.invOwner.CanAltClick(
this))
718 return this.invOwner.GetTextAltClick(
this);
722 public bool ShowMouseHintRight()
724 return this.invOwner !=
null && this.card !=
null && this.invOwner.AllowAutouse;
728 public string GetTextMouseHintRight()
730 return this.invOwner.GetAutoUseLang(
this) ??
"";
740 if (this.recipe !=
null)
742 return this.recipe.renderRow;
744 if (this.card ==
null)
748 return this.card.sourceCard;
752 public void OnRefreshPref()
755 if (renderRow !=
null)
757 renderRow.SetImage(this.icon,
null, 0,
false, 0, 0);
759 if (this.recipe !=
null)
761 this.SetRecipe(this.recipe);
764 if (this.card !=
null)
766 this.SetCard(this.card,
ButtonGrid.Mode.Default,
null);
771 public override bool CanMiddleClick()
773 return this.invOwner !=
null && this.card !=
null &&
EClass.ui.AllowInventoryInteractions;
777 public override void OnMiddleClick()
779 Thing t = this.card.Thing;
781 if (EInput.middleMouse.clicked && o.AllowContext)
783 o.ShowContextMenu(
this);
785 EInput.middleMouse.pressedLongAction = delegate()
787 if (
EClass.ui.AllowInventoryInteractions &&
EClass.core.config.game.holdMiddleButtonToHold && o.TryHold(t))
791 HotItemHeld.disableTool =
true;
793 if (
EClass.ui.contextMenu.isActive)
795 EClass.ui.contextMenu.currentMenu.Hide();
797 EInput.Consume(
false, 1);
825 public List<Transform> listAttach =
new List<Transform>();
828 private int rightAttachCount;