15 return this.buttons[this.currentIndex];
21 public override bool CanCancelAI
31 public override bool RepeatAI
42 LayerDragGrid.Instance =
this;
43 InvOwner.Trader = this.owner;
44 this.wasInventoryOpen =
ELayer.ui.IsInventoryOpen;
45 if (!this.wasInventoryOpen)
47 ELayer.ui.OpenFloatInv(
true);
55 owner.owner.SetImage(this.imageOwner);
57 this.textTitle.text = owner.langTransfer.lang();
59 this.buttonOwner.SetCardGrid(owner.owner,
null);
60 owner.Container.things.RefreshGrid();
61 for (
int j = 0; j < this.buttons.Count; j++)
63 this.buttons[j].gameObject.AddComponent<CanvasGroup>();
64 if (owner.numDragGrid > j)
66 this.buttons[j].SetCardGrid(
null, owner);
67 this.buttons[j].index = j;
68 owner.buttons.Add(this.buttons[j]);
72 this.buttons[j].SetActive(
false);
75 this.textFuel.SetActive(owner.owner.trait.IsRequireFuel);
76 owner.BuildUICurrency(this.uiCurrency,
false);
77 base.InvokeRepeating(
"RefreshCost", 0f, 0.2f);
78 this.RebuildLayout(
true);
79 this.RefreshCurrentGrid();
81 this.RebuildLayout(
true);
82 this.buttonRefuel.SetActive(owner.ShowFuel);
83 this.buttonAutoRefuel.SetActive(owner.ShowFuel);
84 if (owner.CanTargetAlly &&
ELayer.pc.party.members.Count > 1)
86 BaseList baseList = this.listAlly;
87 UIList.Callback<
Chara, UIButton> callback =
new UIList.Callback<
Chara, UIButton>();
88 callback.onInstantiate = delegate(
Chara a, UIButton b)
91 b.SetTooltipLang(a.Name);
93 callback.onClick = delegate(
Chara c, UIButton i)
102 callback.onSort = delegate(
Chara a, UIList.SortMode m)
104 a.SetSortVal(m, CurrencyType.Money);
107 callback.onList = delegate(UIList.SortMode m)
113 this.listAlly.Add(chara);
117 baseList.callbacks = callback;
118 this.listAlly.List(
false);
122 this.listAlly.SetActive(
false);
125 this.buttonRefuel.SetOnClick(delegate
127 this.windows[0].SetInteractable(
false, 0f);
128 this.info.InitFuel(owner.owner);
131 if ((onKill = <>9__6) ==
null)
133 onKill = (<>9__6 = delegate()
135 if (!this.isDestroyed)
137 this.windows[0].SetInteractable(
true, 0.5f);
138 this.info.Init(owner.owner);
140 this.RefreshCurrentGrid();
142 owner.OnAfterRefuel();
146 layer.SetOnKill(onKill);
148 this.buttonAutoRefuel.SetOnClick(delegate
151 owner.owner.autoRefuel = !owner.owner.autoRefuel;
153 if (owner.owner.trait.IsFuelEnough(1,
null,
true))
155 owner.OnAfterRefuel();
162 if (refuelFromLayerDragGrid)
164 this.info.SetActive(
false);
168 Debug.Log(owner.owner);
169 this.info.InitFuel(owner.owner);
174 this.info.Init(owner.owner);
179 Debug.LogError(ex.Message);
185 public int GetPrice()
187 return this.owner.price;
191 public void RefreshCost()
193 this.buttonAutoRefuel.mainText.text = (this.owner.owner.autoRefuel ?
"On" :
"Off");
194 this.buttonAutoRefuel.icon.SetAlpha(this.owner.owner.autoRefuel ? 1f : 0.4f);
195 this.textFuel.text = ((int)((float)this.owner.owner.c_charges / (float)this.owner.owner.trait.MaxFuel * 100f)).ToString() +
"%";
196 int price = this.GetPrice();
197 this.itemCost.transform.parent.SetActive(price != 0);
202 this.itemCost.text1.SetText(Lang._currency(
this.GetPrice(),
false, 14), (
ELayer.pc.GetCurrency(
this.owner.IDCurrency) >= price) ? FontColor.Good : FontColor.Bad);
203 this.itemCost.image1.sprite = SpriteSheet.Get(
"icon_" + this.owner.IDCurrency);
207 public bool IsAllGridSet()
209 for (
int i = 0; i < this.owner.numDragGrid; i++)
211 if (this.buttons[i].card ==
null)
220 public override void ClearButtons()
222 for (
int i = 0; i < this.owner.numDragGrid; i++)
224 this.buttons[i].SetCardGrid(
null,
null);
226 this.RefreshCurrentGrid();
230 public override void RefreshCurrentGrid()
233 for (
int i = 0; i < this.buttons.Count; i++)
235 bool flag = this.buttons[i].Card !=
null;
236 if (num == -1 && (!flag || i == this.owner.numDragGrid - 1))
240 this.buttons[i].interactable = (flag || num == i);
241 this.buttons[i].GetComponent<CanvasGroup>().alpha = (this.buttons[i].interactable ? 1f : 0.5f);
243 this.currentIndex = num;
244 bool flag2 = num >= 0 && num < this.owner.numDragGrid;
247 this.transIndex.position = this.buttons[num].transform.position;
249 this.transIndex.SetActive(flag2);
254 public override List<Thing> GetTargets()
256 List<Thing> list =
new List<Thing>();
258 for (
int i = 0; i < traitCrafter.numIng; i++)
260 Card card = this.buttons[i].card;
261 list.Add(((card !=
null) ? card.Thing :
null) ??
null);
267 private void Update()
273 public void Validate()
275 Card card = this.buttonOwner.card;
276 if (card.Num !=
this.lastNum)
278 this.lastNum = card.Num;
279 this.buttonOwner.SetCardGrid(this.owner.owner,
null);
281 if (card ==
null || card.isDestroyed)
290 foreach (
ButtonGrid buttonGrid
in this.buttons)
292 if (buttonGrid.gameObject.activeSelf)
301 public override void OnKill()
304 InvOwner.Trader =
null;
305 if (!this.wasInventoryOpen &&
ELayer.ui.IsInventoryOpen)
307 ELayer.ui.ToggleInventory(
false);
317 public override void OnUpdateInput()
319 if (EInput.action == EAction.MenuInventory || Input.GetKeyDown(KeyCode.Tab))
322 EInput.WaitReleaseKey();
325 base.OnUpdateInput();
329 public override void OnRightClick()
331 if (InputModuleEX.GetComponentOf<
ButtonGrid>() ==
null)
340 return ELayer.ui.AddLayer<
LayerDragGrid>(
"LayerInventory/LayerDragGrid").SetInv(owner, refuelFromLayerDragGrid);
346 Msg.Say(
"offer_what");
358 Msg.Say(
"bills",
ELayer.player.taxBills.ToString() ??
"",
null,
null,
null);
360 Msg.Say(
"deliver_what");
388 Msg.Say(
"recycle_what");
398 Msg.Say(
"target_what");
413 int num = (owner.count == -1) ? 1 : owner.count;
415 Func<Thing, bool> <>9__0;
419 Func<Thing, bool> func;
420 if ((func = <>9__0) ==
null)
422 func = (<>9__0 = ((
Thing t) => owner.ShouldShowGuide(t)));
424 List<Thing> list = things.List(func,
false);
428 owner._OnProcess(t2);
435 cc.SayNothingHappans();
445 public static LayerDragGrid CreateIdentify(
Chara cc,
bool superior =
false, BlessedState state = BlessedState.Normal,
int price = 0,
int count = 1)
457 public static LayerDragGrid CreateEnchant(
Chara cc,
bool armor,
bool superior =
false, BlessedState state = BlessedState.Normal,
int count = 1)
483 public static LayerDragGrid CreateUncurse(
Chara cc, BlessedState state = BlessedState.Normal,
int price = 0,
int count = 1)
494 public static LayerDragGrid CreateLighten(
Chara cc, BlessedState state = BlessedState.Normal,
int price = 0,
int count = 1)
505 public static LayerDragGrid CreateReconstruction(
Chara cc, BlessedState state = BlessedState.Normal,
int price = 0,
int count = 1)
519 public UIItem itemCost;
522 public Image imageOwner;
525 public UIText textTitle;
528 public UIText textFuel;
531 public Transform transIndex;
534 public List<ButtonGrid> buttons;
540 public UIButton buttonRefuel;
543 public UIButton buttonAutoRefuel;
546 public UIButton buttonAlly;
555 public int currentIndex;
561 public UIList listAlly;
564 private bool wasInventoryOpen;