Elin Modding Docs Doc
Loading...
Searching...
No Matches
InvOwner.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5// Token: 0x02000560 RID: 1376
6public class InvOwner : EClass
7{
8 // Token: 0x17000B25 RID: 2853
9 // (get) Token: 0x06002561 RID: 9569 RVA: 0x000D4FF6 File Offset: 0x000D31F6
10 public static bool HasTrader
11 {
12 get
13 {
14 return InvOwner.Trader != null;
15 }
16 }
17
18 // Token: 0x17000B26 RID: 2854
19 // (get) Token: 0x06002562 RID: 9570 RVA: 0x000D5000 File Offset: 0x000D3200
20 public static bool FreeTransfer
21 {
22 get
23 {
24 return !InvOwner.HasTrader || InvOwner.Trader.currency == CurrencyType.None;
25 }
26 }
27
28 // Token: 0x17000B27 RID: 2855
29 // (get) Token: 0x06002563 RID: 9571 RVA: 0x000D5018 File Offset: 0x000D3218
30 public virtual bool AllowAutouse
31 {
32 get
33 {
34 return true;
35 }
36 }
37
38 // Token: 0x17000B28 RID: 2856
39 // (get) Token: 0x06002564 RID: 9572 RVA: 0x000D501B File Offset: 0x000D321B
40 public virtual bool AllowContext
41 {
42 get
43 {
44 return true;
45 }
46 }
47
48 // Token: 0x17000B29 RID: 2857
49 // (get) Token: 0x06002565 RID: 9573 RVA: 0x000D501E File Offset: 0x000D321E
50 public virtual bool AllowSell
51 {
52 get
53 {
54 return this.currency == CurrencyType.None || this.owner.trait.AllowSell;
55 }
56 }
57
58 // Token: 0x06002566 RID: 9574 RVA: 0x000D503C File Offset: 0x000D323C
59 public virtual bool AllowHold(Thing t)
60 {
61 if (!t.trait.CanBeDropped)
62 {
63 return false;
64 }
65 if (t.isEquipped && t.IsCursed)
66 {
67 return false;
68 }
69 if (this.Container.isChara && !this.Container.IsPC)
70 {
71 return !(t.id == "money") && (!t.isEquipped && !t.isGifted) && !t.isNPCProperty;
72 }
73 return !t.trait.CanOnlyCarry && (!this.Container.isNPCProperty || !InvOwner.FreeTransfer);
74 }
75
76 // Token: 0x06002567 RID: 9575 RVA: 0x000D50DA File Offset: 0x000D32DA
77 public virtual bool AllowMoved(Thing t)
78 {
79 return true;
80 }
81
82 // Token: 0x17000B2A RID: 2858
83 // (get) Token: 0x06002568 RID: 9576 RVA: 0x000D50DD File Offset: 0x000D32DD
84 public virtual bool AlwaysShowTooltip
85 {
86 get
87 {
88 return false;
89 }
90 }
91
92 // Token: 0x17000B2B RID: 2859
93 // (get) Token: 0x06002569 RID: 9577 RVA: 0x000D50E0 File Offset: 0x000D32E0
94 public virtual bool UseGuide
95 {
96 get
97 {
98 return false;
99 }
100 }
101
102 // Token: 0x0600256A RID: 9578 RVA: 0x000D50E3 File Offset: 0x000D32E3
103 public virtual bool ShouldShowGuide(Thing t)
104 {
105 return false;
106 }
107
108 // Token: 0x17000B2C RID: 2860
109 // (get) Token: 0x0600256B RID: 9579 RVA: 0x000D50E6 File Offset: 0x000D32E6
110 public virtual bool AllowTransfer
111 {
112 get
113 {
114 return this.Container.isChara || !this.Container.isNPCProperty;
115 }
116 }
117
118 // Token: 0x17000B2D RID: 2861
119 // (get) Token: 0x0600256C RID: 9580 RVA: 0x000D5105 File Offset: 0x000D3305
120 public virtual bool AllowDropOnDrag
121 {
122 get
123 {
124 return true;
125 }
126 }
127
128 // Token: 0x0600256D RID: 9581 RVA: 0x000D5108 File Offset: 0x000D3308
129 public virtual bool AllowDrop(Thing t)
130 {
131 return !EClass._zone.IsRegion || t.trait is TraitAbility;
132 }
133
134 // Token: 0x17000B2E RID: 2862
135 // (get) Token: 0x0600256E RID: 9582 RVA: 0x000D5126 File Offset: 0x000D3326
136 public virtual string langTransfer
137 {
138 get
139 {
140 return "actTransfer";
141 }
142 }
143
144 // Token: 0x17000B2F RID: 2863
145 // (get) Token: 0x0600256F RID: 9583 RVA: 0x000D512D File Offset: 0x000D332D
146 public virtual int destInvY
147 {
148 get
149 {
150 return 0;
151 }
152 }
153
154 // Token: 0x06002570 RID: 9584 RVA: 0x000D5130 File Offset: 0x000D3330
155 public virtual Thing CreateDefaultContainer()
156 {
157 return ThingGen.Create("chest3", -1, -1);
158 }
159
160 // Token: 0x17000B30 RID: 2864
161 // (get) Token: 0x06002571 RID: 9585 RVA: 0x000D513E File Offset: 0x000D333E
162 public virtual bool HasTransaction
163 {
164 get
165 {
166 return false;
167 }
168 }
169
170 // Token: 0x17000B31 RID: 2865
171 // (get) Token: 0x06002572 RID: 9586 RVA: 0x000D5141 File Offset: 0x000D3341
172 public virtual bool CopyOnTransfer
173 {
174 get
175 {
176 return false;
177 }
178 }
179
180 // Token: 0x17000B32 RID: 2866
181 // (get) Token: 0x06002573 RID: 9587 RVA: 0x000D5144 File Offset: 0x000D3344
182 public virtual bool SingleTarget
183 {
184 get
185 {
186 return false;
187 }
188 }
189
190 // Token: 0x06002574 RID: 9588 RVA: 0x000D5148 File Offset: 0x000D3348
191 public virtual void BuildUICurrency(UICurrency uiCurrency, bool canReroll = false)
192 {
193 bool flag = this.Container.isChara && !this.Container.IsPC;
194 uiCurrency.SetActive(this.currency > CurrencyType.None || flag);
195 uiCurrency.target = this.owner;
196 if (this.currency > CurrencyType.None || flag)
197 {
198 uiCurrency.Build(new UICurrency.Options
199 {
200 weight = flag,
201 money = (this.currency == CurrencyType.Money),
202 plat = (this.currency == CurrencyType.Plat),
203 medal = (this.currency == CurrencyType.Medal),
204 money2 = (this.currency == CurrencyType.Money2),
205 influence = (this.currency == CurrencyType.Influence),
206 casino = (this.currency == CurrencyType.Casino_coin),
207 ecopo = (this.currency == CurrencyType.Ecopo)
208 });
209 }
210 }
211
212 // Token: 0x17000B33 RID: 2867
213 // (get) Token: 0x06002575 RID: 9589 RVA: 0x000D5219 File Offset: 0x000D3419
214 public bool UseHomeResource
215 {
216 get
217 {
218 return this.homeResource != null;
219 }
220 }
221
222 // Token: 0x17000B34 RID: 2868
223 // (get) Token: 0x06002576 RID: 9590 RVA: 0x000D5224 File Offset: 0x000D3424
224 public bool IsMagicChest
225 {
226 get
227 {
228 return this.Container.trait is TraitMagicChest;
229 }
230 }
231
232 // Token: 0x17000B35 RID: 2869
233 // (get) Token: 0x06002577 RID: 9591 RVA: 0x000D5239 File Offset: 0x000D3439
234 public List<Thing> Things
235 {
236 get
237 {
238 if (!this.Container.things.HasGrid)
239 {
240 return this.Container.things;
241 }
242 return this.Container.things.grid;
243 }
244 }
245
246 // Token: 0x17000B36 RID: 2870
247 // (get) Token: 0x06002578 RID: 9592 RVA: 0x000D5269 File Offset: 0x000D3469
248 public Chara Chara
249 {
250 get
251 {
252 return this.owner as Chara;
253 }
254 }
255
256 // Token: 0x17000B37 RID: 2871
257 // (get) Token: 0x06002579 RID: 9593 RVA: 0x000D5276 File Offset: 0x000D3476
258 public ContainerType ContainerType
259 {
260 get
261 {
262 return this.Container.trait.ContainerType;
263 }
264 }
265
266 // Token: 0x17000B38 RID: 2872
267 // (get) Token: 0x0600257A RID: 9594 RVA: 0x000D5288 File Offset: 0x000D3488
268 public virtual bool InvertSell
269 {
270 get
271 {
272 return false;
273 }
274 }
275
276 // Token: 0x17000B39 RID: 2873
277 // (get) Token: 0x0600257B RID: 9595 RVA: 0x000D528B File Offset: 0x000D348B
278 public virtual int numDragGrid
279 {
280 get
281 {
282 return 1;
283 }
284 }
285
286 // Token: 0x17000B3A RID: 2874
287 // (get) Token: 0x0600257C RID: 9596 RVA: 0x000D528E File Offset: 0x000D348E
288 public virtual bool ShowNew
289 {
290 get
291 {
292 return this.owner.IsPC;
293 }
294 }
295
296 // Token: 0x17000B3B RID: 2875
297 // (get) Token: 0x0600257D RID: 9597 RVA: 0x000D529B File Offset: 0x000D349B
298 public virtual bool DenyImportant
299 {
300 get
301 {
302 return true;
303 }
304 }
305
306 // Token: 0x0600257E RID: 9598 RVA: 0x000D529E File Offset: 0x000D349E
307 public bool IsWeightOver(Thing t)
308 {
309 return false;
310 }
311
312 // Token: 0x17000B3C RID: 2876
313 // (get) Token: 0x0600257F RID: 9599 RVA: 0x000D52A1 File Offset: 0x000D34A1
314 public InvOwner destInvOwner
315 {
316 get
317 {
318 if (!this.owner.IsPC)
319 {
320 return InvOwner.Main;
321 }
322 return InvOwner.Trader;
323 }
324 }
325
326 // Token: 0x06002580 RID: 9600 RVA: 0x000D52BC File Offset: 0x000D34BC
327 public InvOwner(Card owner, Card container = null, CurrencyType _currency = CurrencyType.None, PriceType _price = PriceType.Default)
328 {
329 this.currency = _currency;
330 this.priceType = _price;
331 this.owner = owner;
332 this.Container = (container ?? owner);
333 if (this.currency == CurrencyType.BranchMoney)
334 {
335 this.homeResource = EClass.BranchOrHomeBranch.resources.money;
336 }
337 }
338
339 // Token: 0x06002581 RID: 9601 RVA: 0x000D531C File Offset: 0x000D351C
340 public void Init()
341 {
342 if (this.owner == null)
343 {
344 CardBlueprint.SetNormalRarity(false);
345 this.owner = this.CreateDefaultContainer();
346 this.owner.c_lockLv = 0;
347 this.owner.c_IDTState = 0;
348 this.Container = (this.Container ?? this.owner);
349 }
350 this.OnInit();
351 InvOwner.forceGive = new InvOwner.ForceGiveData();
352 }
353
354 // Token: 0x06002582 RID: 9602 RVA: 0x000D5381 File Offset: 0x000D3581
355 public virtual void OnInit()
356 {
357 }
358
359 // Token: 0x06002583 RID: 9603 RVA: 0x000D5384 File Offset: 0x000D3584
360 public virtual void OnClick(ButtonGrid button)
361 {
362 Card card = button.card;
363 Card card2 = button.invOwner.owner;
364 if (card != null && EClass.ui.currentDrag == null)
365 {
366 bool flag = false;
367 if (card.Thing.isEquipped && card.Thing.IsEquipmentOrRanged && card.Thing.IsCursed)
368 {
369 SE.Play("curse3");
370 }
371 else if (!this.AllowHold(card.Thing) && card2.isChara && !card2.IsPC && card2.IsPCFaction)
372 {
373 if (InvOwner.forceGive.card != card)
374 {
375 InvOwner.forceGive.card = card;
376 InvOwner.forceGive.tries = 0;
377 }
378 else
379 {
380 if (!EInput.isShiftDown)
381 {
382 InvOwner.forceGive.tries++;
383 }
384 if (InvOwner.forceGive.tries >= 2)
385 {
386 if (card.HasTag(CTAG.gift) && card.isGifted)
387 {
388 EClass.ui.CloseLayers();
389 card2.Say("angry", card2, null, null);
390 card2.ShowEmo(Emo.angry, 0f, true);
391 card2.Talk("noGiveRing", null, null, false);
392 card2.Chara.ModAffinity(EClass.pc, -30, true);
393 card2.Chara.InstantEat(card.Thing, true);
394 return;
395 }
396 InvOwner.forceGive.card = null;
397 bool flag2 = card.trait is TraitCurrency;
398 card.isGifted = false;
399 card.isNPCProperty = false;
400 card2.Talk(flag2 ? "forceGiveCurrency" : "forceGive", null, null, false);
401 int num = flag2 ? 3 : 1;
402 if (card.id == "money")
403 {
404 num += card.Num / 1000;
405 }
406 if (num >= 5)
407 {
408 num = 5;
409 }
410 EClass.player.ModKarma(-num);
411 EClass.pc.Pick(card.Thing, true, true);
412 return;
413 }
414 }
415 }
416 if (this.AllowHold(card.Thing) || flag)
417 {
418 if (EInput.isAltDown)
419 {
420 if (this.CanAltClick(button))
421 {
422 this.OnAltClick(button);
423 return;
424 }
425 SE.BeepSmall();
426 return;
427 }
428 else if (EInput.isCtrlDown)
429 {
430 if (this.CanCtrlClick(button))
431 {
432 this.OnCtrlClick(button);
433 return;
434 }
435 SE.BeepSmall();
436 return;
437 }
438 else if (EInput.isShiftDown)
439 {
440 if (this.CanShiftClick(button, false))
441 {
442 this.OnShiftClick(button, false);
443 return;
444 }
445 SE.BeepSmall();
446 return;
447 }
448 else
449 {
450 if (!this.owner.IsPC)
451 {
452 new InvOwner.Transaction(button, (InvOwner.HasTrader && !InvOwner.FreeTransfer) ? 1 : card.Num, null).Process(true);
453 return;
454 }
455 if (button.card != null && this.IsFailByCurse(button.card.Thing))
456 {
457 return;
458 }
459 EClass.ui.StartDrag(new DragItemCard(button, true));
460 return;
461 }
462 }
463 else
464 {
465 SE.BeepSmall();
466 if (card2.isChara && !card2.IsPC)
467 {
468 card2.Talk("noGive", null, null, false);
469 }
470 }
471 }
472 }
473
474 // Token: 0x06002584 RID: 9604 RVA: 0x000D5669 File Offset: 0x000D3869
475 public virtual void OnRightClick(ButtonGrid button)
476 {
477 if (!this.AllowAutouse)
478 {
479 this.OnClick(button);
480 }
481 if (button.card == null)
482 {
483 return;
484 }
485 this.AutoUse(button, false);
486 }
487
488 // Token: 0x06002585 RID: 9605 RVA: 0x000D568C File Offset: 0x000D388C
489 public virtual void OnRightPressed(ButtonGrid button)
490 {
491 if (!EInput.rightMouse.pressedLong)
492 {
493 return;
494 }
495 float num = 1f;
496 float pressedTimer = EInput.rightMouse.pressedTimer;
497 if (pressedTimer > 2f)
498 {
499 num = 2f;
500 }
501 else if (pressedTimer > 4f)
502 {
503 num = 5f;
504 }
505 else if (pressedTimer > 6f)
506 {
507 num = 50f;
508 }
509 InvOwner.clickTimer -= Core.delta * num;
510 if (InvOwner.clickTimer < 0f)
511 {
512 InvOwner.clickTimer = 0.1f;
513 if (button.card != null)
514 {
515 this.AutoUse(button, true);
516 }
517 }
518 }
519
520 // Token: 0x06002586 RID: 9606 RVA: 0x000D5720 File Offset: 0x000D3920
521 public InvOwner GetShitDestOwner(ButtonGrid b, bool rightMouse = false)
522 {
523 Thing thing = b.card.Thing;
524 if (rightMouse && !b.invOwner.owner.IsPC)
525 {
526 LayerInventory pclayer = LayerInventory.GetPCLayer();
527 if (pclayer == null)
528 {
529 return null;
530 }
531 return pclayer.Inv;
532 }
533 else if (InvOwner.Trader != null)
534 {
535 if (b.invOwner.owner.IsPC)
536 {
537 if (!InvOwner.Trader.Container.things.IsFull(thing, true, true))
538 {
539 return InvOwner.Trader;
540 }
541 return null;
542 }
543 else
544 {
545 LayerInventory topLayer = LayerInventory.GetTopLayer(thing, true, InvOwner.Trader);
546 if (topLayer == null)
547 {
548 return null;
549 }
550 return topLayer.Inv;
551 }
552 }
553 else
554 {
555 LayerInventory topLayer2 = LayerInventory.GetTopLayer(thing, true, this);
556 if (topLayer2 == null)
557 {
558 return null;
559 }
560 return topLayer2.Inv;
561 }
562 }
563
564 // Token: 0x06002587 RID: 9607 RVA: 0x000D57CC File Offset: 0x000D39CC
565 public virtual void OnShiftClick(ButtonGrid b, bool rightMouse = false)
566 {
567 InvOwner shitDestOwner = this.GetShitDestOwner(b, rightMouse);
568 Thing thing = b.card.Thing;
569 Card container = shitDestOwner.Container;
570 if (rightMouse && !this.owner.IsPC)
571 {
572 EClass.pc.Pick(thing, false, true);
573 return;
574 }
575 if ((thing.parent == container || thing == container) && !thing.IsHotItem)
576 {
577 if (EInput.isShiftDown)
578 {
579 SE.BeepSmall();
580 }
581 return;
582 }
583 thing.PlaySoundDrop(false);
584 if (thing.IsHotItem && thing.parent == container)
585 {
586 container.RemoveCard(thing);
587 }
588 if (container.things.CanStack(thing, -1, -1) != thing)
589 {
590 container.things.TryStack(thing, -1, -1);
591 return;
592 }
593 container.AddThing(thing, true, -1, -1);
594 }
595
596 // Token: 0x06002588 RID: 9608 RVA: 0x000D5880 File Offset: 0x000D3A80
597 public virtual bool CanShiftClick(ButtonGrid b, bool rightMouse = false)
598 {
599 if (!EInput.isShiftDown && !rightMouse)
600 {
601 return false;
602 }
603 if (!EClass.pc.HasNoGoal || this.Container.isNPCProperty || this.currency != CurrencyType.None)
604 {
605 return false;
606 }
607 if (rightMouse && !InvOwner.HasTrader)
608 {
609 return false;
610 }
611 if (InvOwner.HasTrader)
612 {
613 if (InvOwner.Trader is InvOwnerDraglet || InvOwner.Trader.Container.isNPCProperty || InvOwner.Trader.currency != CurrencyType.None)
614 {
615 return false;
616 }
617 if (InvOwner.Trader.Container.isChara)
618 {
619 return false;
620 }
621 Card card = b.card;
622 if (card != null && card.c_isImportant)
623 {
624 return false;
625 }
626 }
627 InvOwner shitDestOwner = this.GetShitDestOwner(b, rightMouse);
628 if (shitDestOwner == null)
629 {
630 return false;
631 }
632 Thing thing = b.card.Thing;
633 if (thing.trait.IsContainer && thing.things.Count > 0)
634 {
635 return false;
636 }
637 if (!this.AllowHold(thing))
638 {
639 return false;
640 }
641 if (InvOwner.HasTrader)
642 {
643 if (!InvOwner.Trader.Container.GetRootCard().IsPC && thing.trait is TraitCatalyst)
644 {
645 return false;
646 }
647 if (!InvOwner.Trader.AllowMoved(thing))
648 {
649 return false;
650 }
651 }
652 if (shitDestOwner.Container.isChara && !shitDestOwner.owner.IsPC && !shitDestOwner.owner.Chara.CanAcceptItem(thing, -1))
653 {
654 return false;
655 }
656 if (b.invOwner.owner.isChara && b.invOwner.owner.Chara.IsPCFaction && !b.invOwner.owner.IsPC && thing.IsRangedWeapon)
657 {
658 thing.ammoData = null;
659 thing.c_ammo = 0;
660 }
661 if (EInput.isShiftDown)
662 {
663 LayerInventory.highlightInv = shitDestOwner;
664 }
665 return true;
666 }
667
668 // Token: 0x06002589 RID: 9609 RVA: 0x000D5A2F File Offset: 0x000D3C2F
669 public virtual string GetTextShiftClick(ButtonGrid b)
670 {
671 return "actTransfer".lang();
672 }
673
674 // Token: 0x0600258A RID: 9610 RVA: 0x000D5A3B File Offset: 0x000D3C3B
675 public virtual void OnCtrlClick(ButtonGrid button)
676 {
677 button.card.Thing.ShowSplitMenu(button, this.HasTransaction ? new InvOwner.Transaction(button, 1, null) : null);
678 }
679
680 // Token: 0x0600258B RID: 9611 RVA: 0x000D5A61 File Offset: 0x000D3C61
681 public virtual bool CanCtrlClick(ButtonGrid b)
682 {
683 return EInput.isCtrlDown && EClass.pc.HasNoGoal && !this.Container.isNPCProperty && b.card.Num > 1;
684 }
685
686 // Token: 0x0600258C RID: 9612 RVA: 0x000D5A96 File Offset: 0x000D3C96
687 public virtual string GetTextCtrlClick(ButtonGrid b)
688 {
689 return "actSplit".lang();
690 }
691
692 // Token: 0x0600258D RID: 9613 RVA: 0x000D5AA2 File Offset: 0x000D3CA2
693 public virtual void OnAltClick(ButtonGrid button)
694 {
695 EClass.pc.DropThing(button.card.Thing, -1);
696 }
697
698 // Token: 0x0600258E RID: 9614 RVA: 0x000D5ABC File Offset: 0x000D3CBC
699 public virtual bool CanAltClick(ButtonGrid b)
700 {
701 return EInput.isAltDown && EClass.pc.HasNoGoal && !this.Container.isNPCProperty && this.currency == CurrencyType.None && this.AllowDrop(b.card.Thing);
702 }
703
704 // Token: 0x0600258F RID: 9615 RVA: 0x000D5B0B File Offset: 0x000D3D0B
705 public virtual string GetTextAltClick(ButtonGrid b)
706 {
707 return "actDrop".lang();
708 }
709
710 // Token: 0x06002590 RID: 9616 RVA: 0x000D5B18 File Offset: 0x000D3D18
711 public void Grab(DragItemCard.DragInfo from)
712 {
713 bool isEquipped = from.thing.isEquipped;
714 if (isEquipped)
715 {
716 from.invOwner.owner.Chara.body.Unequip(from.thing, true);
717 }
718 from.invOwner.Container.RemoveCard(from.thing);
719 if (isEquipped)
720 {
721 from.list.Redraw();
722 }
723 LayerInventory.SetDirty(from.thing);
724 }
725
726 // Token: 0x06002591 RID: 9617 RVA: 0x000D5B84 File Offset: 0x000D3D84
727 public Thing PutBack(DragItemCard.DragInfo from)
728 {
729 Thing thing = from.thing;
730 if (from.invY == 1 && from.container.things.IsOccupied(from.invX, from.invY))
731 {
732 return EClass.pc.Pick(thing, false, true);
733 }
734 if (from.container.things.IsFull(thing, false, false))
735 {
736 return EClass.pc.Pick(thing, false, true);
737 }
738 thing.invY = from.invY;
739 thing = from.container.AddThing(thing, true, from.invX, from.invY);
740 if (from.equippedSlot != null)
741 {
742 from.invOwner.owner.Chara.body.Equip(thing, from.equippedSlot, true);
743 from.list.Redraw();
744 }
745 else
746 {
747 thing.invX = from.invX;
748 }
749 if (from.invY == 1)
750 {
751 WidgetCurrentTool.dirty = true;
752 }
753 return thing;
754 }
755
756 // Token: 0x06002592 RID: 9618 RVA: 0x000D5C6A File Offset: 0x000D3E6A
757 public void OnStartDrag(DragItemCard.DragInfo from)
758 {
759 from.thing.PlaySoundDrop(false);
760 if (from.thing.parent != null)
761 {
762 this.Grab(from);
763 }
764 if (from.thing.IsEquipment)
765 {
766 WidgetEquip.dragEquip = from.thing;
767 WidgetEquip.Redraw();
768 }
769 }
770
771 // Token: 0x06002593 RID: 9619 RVA: 0x000D5CA9 File Offset: 0x000D3EA9
772 public virtual bool OnCancelDrag(DragItemCard.DragInfo from)
773 {
774 if (this.Container.isNPCProperty)
775 {
776 return false;
777 }
778 this.PutBack(from);
779 return true;
780 }
781
782 // Token: 0x06002594 RID: 9620 RVA: 0x000D5CC4 File Offset: 0x000D3EC4
783 public bool OnDrag(DragItemCard.DragInfo from, DragItemCard.DragInfo to, bool execute, bool cancel = false)
784 {
785 if (cancel)
786 {
787 return this.OnCancelDrag(from);
788 }
789 bool flag = false;
790 string text = "";
791 if (EClass.ui.GetLayer<LayerRegisterHotbar>(false) == null)
792 {
793 EClass.ui.AddLayer<LayerRegisterHotbar>().SetItem(from.thing);
794 }
795 LayerInventory componentOf = InputModuleEX.GetComponentOf<LayerInventory>();
796 if (!EClass.ui.isPointerOverUI && !EClass._zone.IsRegion)
797 {
798 flag = this.AllowDropOnDrag;
799 text = ((!this.AllowDropOnDrag) ? "" : ((from.thing.trait is TraitAbility) ? "dragForget" : "dragDropThing"));
800 if (execute)
801 {
802 if (!this.AllowDropOnDrag || from.thing.c_isImportant)
803 {
804 return this.OnCancelDrag(from);
805 }
806 EClass.pc.DropThing(from.thing, -1);
807 return true;
808 }
809 }
810 else if (!EClass.core.config.game.useGrid && componentOf)
811 {
812 if (to.button && to.invOwner != null && to.thing != null && to.thing.CanStackTo(from.thing))
813 {
814 InvOwner.Transaction transaction = new InvOwner.Transaction(from, to, from.thing.Num);
815 flag = transaction.IsValid();
816 text = transaction.GetTextDetail();
817 if (execute)
818 {
819 return transaction.Process(false);
820 }
821 }
822 else
823 {
824 InvOwner.Transaction transaction2 = new InvOwner.Transaction(from, componentOf.invs[0], from.thing.Num);
825 flag = transaction2.IsValid();
826 text = transaction2.GetTextDetail();
827 if (execute)
828 {
829 return transaction2.Process(false);
830 }
831 }
832 }
833 else if (to.button && to.invOwner != null && to.button.interactable)
834 {
835 if (to.invOwner is InvOwnerEquip)
836 {
837 InvOwnerEquip invOwnerEquip = to.invOwner as InvOwnerEquip;
838 Chara chara = invOwnerEquip.owner.Chara;
839 BodySlot slot = invOwnerEquip.slot;
840 if (execute && to.thing != null && to.thing.blessedState <= BlessedState.Cursed)
841 {
842 Msg.Say("unequipCursed", to.thing, null, null, null);
843 return false;
844 }
845 if (from.thing.category.slot == slot.elementId)
846 {
847 flag = true;
848 text = "dragEquip";
849 if (execute)
850 {
851 if (!chara.body.IsEquippable(from.thing, slot, true))
852 {
853 return false;
854 }
855 chara.AddCard(from.thing);
856 if (to.thing != null)
857 {
858 EClass.ui.nextDrag = new DragItemCard(to.button, true);
859 this.Grab(to);
860 }
861 chara.body.Equip(from.thing, invOwnerEquip.slot, true);
862 EClass.Sound.Play("equip");
863 if (EClass.game.UseGrid)
864 {
865 from.list.Redraw();
866 }
867 to.list.Redraw();
868 to.invOwner.OnProcess(from.thing);
869 return true;
870 }
871 }
872 }
873 else
874 {
875 if (to.invOwner is InvOwnerCopyShop && !to.invOwner.owner.trait.CanCopy(from.thing))
876 {
877 return false;
878 }
879 if (!to.invOwner.AllowTransfer)
880 {
881 return false;
882 }
883 InvOwner.Transaction transaction3 = new InvOwner.Transaction(from, to, from.thing.Num);
884 flag = transaction3.IsValid();
885 text = transaction3.GetTextDetail();
886 if (execute)
887 {
888 return transaction3.Process(false);
889 }
890 }
891 }
892 EClass.ui.hud.SetDragText(flag ? text : "", (from.thing.Num > 1) ? (from.thing.Num.ToString() ?? "") : null);
893 CursorSystem.SetCursor(flag ? null : CursorSystem.Invalid, 100);
894 return false;
895 }
896
897 // Token: 0x06002595 RID: 9621 RVA: 0x000D607C File Offset: 0x000D427C
898 public virtual void OnProcess(Thing t)
899 {
900 }
901
902 // Token: 0x06002596 RID: 9622 RVA: 0x000D607E File Offset: 0x000D427E
903 public bool CanOpenContainer(Thing t)
904 {
905 if (!t.trait.CanOpenContainer)
906 {
907 return false;
908 }
909 if (t.parent != EClass.pc)
910 {
911 Thing thing = t.parent as Thing;
912 return ((thing != null) ? thing.trait : null) is TraitToolBelt;
913 }
914 return true;
915 }
916
917 // Token: 0x06002597 RID: 9623 RVA: 0x000D60C0 File Offset: 0x000D42C0
918 public InvOwner.ListInteraction ListInteractions(ButtonGrid b, bool context)
919 {
920 InvOwner.ListInteraction listInteraction = new InvOwner.ListInteraction();
921 if (b == null || b.card == null || this is InvOwnerAlly)
922 {
923 return listInteraction;
924 }
925 Thing t = b.card.Thing;
926 if (t == null)
927 {
928 return listInteraction;
929 }
930 Trait trait = t.trait;
931 bool flag = trait is TraitAbility;
932 if (InvOwner.HasTrader)
933 {
934 if (InvOwner.Trader == null || this.destInvOwner == null)
935 {
936 return listInteraction;
937 }
938 if (this.CanOpenContainer(t))
939 {
940 listInteraction.Add("actContainer", 10, delegate()
941 {
942 (t.trait as TraitContainer).TryOpen();
943 });
944 }
945 bool flag2 = !flag && !trait.CanOnlyCarry && (!this.destInvOwner.UseGuide || this.destInvOwner.ShouldShowGuide(t));
946 bool flag3 = ShopTransaction.current != null && ShopTransaction.current.CanSellBack(t, -1);
947 if (this.destInvOwner == InvOwner.Trader && !InvOwner.Trader.AllowSell && !flag3)
948 {
949 flag2 = false;
950 }
951 if (!this.AllowHold(t))
952 {
953 flag2 = false;
954 }
955 if (!InvOwner.Trader.AllowMoved(t))
956 {
957 flag2 = false;
958 }
959 if (flag2 && (!t.c_isImportant || !this.destInvOwner.DenyImportant))
960 {
961 if (!flag3 && (InvOwner.Trader.currency == CurrencyType.None || t.GetPrice(CurrencyType.Money, false, PriceType.Default, null) == 0))
962 {
963 InvOwner.Transaction trans = new InvOwner.Transaction(b, t.Num, null);
964 if (trans.IsValid())
965 {
966 Action <>9__5;
967 listInteraction.Add(this.Container.isNPCProperty ? "actSteal".lang().TagColor(FontColor.Bad, SkinManager.DarkColors) : this.destInvOwner.langTransfer, 0, delegate()
968 {
969 if (this.Container.isNPCProperty)
970 {
971 Action action;
972 if ((action = <>9__5) == null)
973 {
974 action = (<>9__5 = delegate()
975 {
976 trans.Process(false);
977 });
978 }
979 Dialog.TryWarnCrime(action);
980 return;
981 }
982 trans.Process(false);
983 });
984 }
985 }
986 else
987 {
988 bool isShiftDown = EInput.isShiftDown;
989 InvOwner.Transaction trans = new InvOwner.Transaction(b, 1, null);
990 listInteraction.Add(trans.GetTextDetail(), 0, delegate()
991 {
992 trans.Process(false);
993 }).repeatable = true;
994 if (t.Num > 1)
995 {
996 InvOwner.Transaction trans2 = new InvOwner.Transaction(b, t.Num, null);
997 listInteraction.Add(trans2.GetTextDetail(), 10, delegate()
998 {
999 trans2.Process(false);
1000 });
1001 if (isShiftDown)
1002 {
1003 listInteraction.Add(listInteraction[0]);
1004 listInteraction.RemoveAt(0);
1005 }
1006 }
1007 }
1008 }
1009 }
1010 this.ListInteractions(listInteraction, t, trait, b, context);
1011 if (this.AllowHold(t) && !t.isEquipped && !InvOwner.HasTrader)
1012 {
1013 InvOwner.Interaction item = listInteraction.Add((EClass.pc.held == t) ? "actPick" : "actHold", 60, delegate()
1014 {
1015 this.TryHold(t);
1016 });
1017 if (t.trait.HoldAsDefaultInteraction)
1018 {
1019 listInteraction.Remove(item);
1020 listInteraction.Insert(0, item);
1021 }
1022 if (t.trait.CanBeHeldAsFurniture)
1023 {
1024 listInteraction.Add("actHoldTool", 70, delegate()
1025 {
1026 if (t != EClass.pc.held)
1027 {
1028 if (this.TryHold(t))
1029 {
1030 HotItemHeld.disableTool = true;
1031 return;
1032 }
1033 }
1034 else
1035 {
1036 HotItemHeld.disableTool = true;
1037 }
1038 });
1039 }
1040 }
1041 if (context && this.AllowHold(t) && !this.Container.isNPCProperty)
1042 {
1043 if (t.Num > 1)
1044 {
1045 listInteraction.Add("actSplit", 50, delegate()
1046 {
1047 t.ShowSplitMenu(b, (InvOwner.HasTrader && this.currency != CurrencyType.None && !this.owner.IsPC) ? new InvOwner.Transaction(b, 1, null) : null);
1048 });
1049 }
1050 if (this.owner.IsPC && this.AllowDrop(t))
1051 {
1052 if (EClass.core.config.game.advancedMenu)
1053 {
1054 listInteraction.Add(t.c_isImportant ? "important_off" : "important_on", 299, delegate()
1055 {
1056 t.c_isImportant = !t.c_isImportant;
1057 LayerInventory.SetDirty(t);
1058 SE.ClickOk();
1059 });
1060 }
1061 if (!EClass._zone.IsRegion)
1062 {
1063 listInteraction.Add(flag ? "dragForget" : "actDrop", 300, delegate()
1064 {
1065 EClass.pc.DropThing(t, -1);
1066 });
1067 }
1068 }
1069 }
1070 return listInteraction;
1071 }
1072
1073 // Token: 0x06002598 RID: 9624 RVA: 0x000D6558 File Offset: 0x000D4758
1074 public bool TryHold(Thing t)
1075 {
1076 if (!this.AllowHold(t) || t.isEquipped || InvOwner.HasTrader)
1077 {
1078 return false;
1079 }
1080 if (EClass.pc.held == t)
1081 {
1082 if (t.trait.CanOnlyCarry)
1083 {
1084 SE.Beep();
1085 return true;
1086 }
1087 EClass.pc.PickHeld(false);
1088 }
1089 else
1090 {
1091 EClass.pc.HoldCard(t, -1);
1092 }
1093 EClass.player.RefreshCurrentHotItem();
1094 SE.SelectHotitem();
1095 return true;
1096 }
1097
1098 // Token: 0x06002599 RID: 9625 RVA: 0x000D65CC File Offset: 0x000D47CC
1099 public virtual void ListInteractions(InvOwner.ListInteraction list, Thing t, Trait trait, ButtonGrid b, bool context)
1100 {
1101 if (this.owner.IsPC)
1102 {
1103 if (this.CanOpenContainer(t) && !list.Contains("actContainer"))
1104 {
1105 list.Add(LayerInventory.IsOpen(t) ? "close" : "actContainer", 100, delegate()
1106 {
1107 (t.trait as TraitContainer).TryOpen();
1108 });
1109 }
1110 if (!InvOwner.HasTrader)
1111 {
1112 CharaBody body = this.owner.Chara.body;
1113 BodySlot slot = body.GetSlot(t, false, EInput.isShiftDown);
1114 if (slot != null)
1115 {
1116 Card tParent = t.parentCard;
1117 int tInvX = t.invX;
1118 int tInvY = t.invY;
1119 if (tInvY != 1)
1120 {
1121 list.Add("invEquip", 90, delegate()
1122 {
1123 if (slot.thing != null && slot.thing.blessedState <= BlessedState.Cursed)
1124 {
1125 Msg.Say("unequipCursed", slot.thing, null, null, null);
1126 SE.Play("curse3");
1127 return;
1128 }
1129 if (EClass.pc.held == t)
1130 {
1131 EClass.pc.PickHeld(false);
1132 }
1133 Thing thing = slot.thing;
1134 body.Equip(t, slot, true);
1135 EClass.Sound.Play("equip");
1136 if (thing != null)
1137 {
1138 if (tParent != null)
1139 {
1140 tParent.AddThing(thing, true, -1, -1);
1141 thing.invX = tInvX;
1142 thing.invY = tInvY;
1143 return;
1144 }
1145 if (thing.parent is Card && (thing.parent as Card).things.IsOverflowing())
1146 {
1147 thing.parent.RemoveCard(thing);
1148 EClass.pc.Pick(thing, true, true);
1149 }
1150 }
1151 });
1152 }
1153 }
1154 if (trait.CanRead(EClass.pc))
1155 {
1156 list.Add("invRead", 110, delegate()
1157 {
1158 t.DoAct(new AI_Read
1159 {
1160 target = t
1161 });
1162 });
1163 }
1164 if (trait.CanUse(EClass.pc))
1165 {
1166 list.Add(trait.LangUse, 120, delegate()
1167 {
1168 if (trait.OnUse(EClass.pc))
1169 {
1170 EClass.player.EndTurn(true);
1171 }
1172 });
1173 }
1174 if (trait.CanDrink(EClass.pc))
1175 {
1176 list.Add("invDrink", 130, delegate()
1177 {
1178 t.DoAct(new AI_Drink
1179 {
1180 target = t
1181 });
1182 });
1183 }
1184 if (trait.CanEat(EClass.pc))
1185 {
1186 list.Add("invFood", 140, delegate()
1187 {
1188 t.DoAct(new AI_Eat
1189 {
1190 cook = false,
1191 target = t
1192 });
1193 });
1194 }
1195 if (context)
1196 {
1197 if (trait.IsBlendBase)
1198 {
1199 list.Add("invBlend", 150, delegate()
1200 {
1201 LayerDragGrid.Create(new InvOwnerBlend(t, null, CurrencyType.None), false);
1202 });
1203 }
1204 if (trait is TraitCard)
1205 {
1206 list.Add("invCollect", 150, delegate()
1207 {
1208 ContentCodex.Collect(t);
1209 });
1210 }
1211 if (trait.CanName)
1212 {
1213 Action<bool, string> <>9__9;
1214 list.Add("changeName", 200, delegate()
1215 {
1216 string langDetail = "dialogChangeName";
1217 string text2 = t.c_refText.IsEmpty("");
1218 Action<bool, string> onClose;
1219 if ((onClose = <>9__9) == null)
1220 {
1221 onClose = (<>9__9 = delegate(bool cancel, string text)
1222 {
1223 if (!cancel)
1224 {
1225 t.c_refText = text;
1226 }
1227 });
1228 }
1229 Dialog.InputName(langDetail, text2, onClose, Dialog.InputType.Default);
1230 });
1231 }
1232 }
1233 }
1234 }
1235 }
1236
1237 // Token: 0x0600259A RID: 9626 RVA: 0x000D6890 File Offset: 0x000D4A90
1238 public virtual string GetAutoUseLang(ButtonGrid button)
1239 {
1240 if (button == null || button.gameObject == null)
1241 {
1242 return "";
1243 }
1244 InvOwner.ListInteraction list = this.ListInteractions(button, false);
1245 if (button.card.trait.HoldAsDefaultInteraction && list.Count > 0)
1246 {
1247 InvOwner.Interaction interaction = list[0];
1248 if (interaction.name == "actPick" || interaction.name == "actHold" || interaction.name == "actHoldTool")
1249 {
1250 return null;
1251 }
1252 }
1253 list.ForeachReverse(delegate(InvOwner.Interaction a)
1254 {
1255 if (a.name == "actPick" || a.name == "actHold" || a.name == "actHoldTool")
1256 {
1257 list.Remove(a);
1258 }
1259 });
1260 if (list.Count == 0)
1261 {
1262 return null;
1263 }
1264 if (list[0].name == "actTransfer")
1265 {
1266 return null;
1267 }
1268 return list[0].name.lang();
1269 }
1270
1271 // Token: 0x0600259B RID: 9627 RVA: 0x000D6990 File Offset: 0x000D4B90
1272 public void AutoUse(ButtonGrid button, bool repeat = false)
1273 {
1274 Card card = button.card;
1275 if (!ActionMode.Adv.IsActive && !ActionMode.Region.IsActive)
1276 {
1277 return;
1278 }
1279 if (!EClass.pc.HasNoGoal)
1280 {
1281 SE.Beep();
1282 return;
1283 }
1284 InvOwner.ListInteraction listInteraction = this.ListInteractions(button, false);
1285 if (listInteraction.Count == 0)
1286 {
1287 SE.Beep();
1288 return;
1289 }
1290 if (repeat && !listInteraction[0].repeatable)
1291 {
1292 return;
1293 }
1294 listInteraction[0].action();
1295 }
1296
1297 // Token: 0x0600259C RID: 9628 RVA: 0x000D6A0C File Offset: 0x000D4C0C
1298 public void ShowContextMenu(ButtonGrid button)
1299 {
1300 if (!EClass.pc.HasNoGoal)
1301 {
1302 SE.Beep();
1303 return;
1304 }
1305 InvOwner.ListInteraction listInteraction = this.ListInteractions(button, true);
1306 if (listInteraction.Count == 0)
1307 {
1308 SE.BeepSmall();
1309 return;
1310 }
1311 UIContextMenu uicontextMenu = EClass.ui.CreateContextMenuInteraction();
1312 listInteraction.Sort((InvOwner.Interaction a, InvOwner.Interaction b) => a.priority - b.priority);
1313 foreach (InvOwner.Interaction interaction in listInteraction)
1314 {
1315 uicontextMenu.AddButton(interaction.name, interaction.action, true);
1316 }
1317 uicontextMenu.Show();
1318 }
1319
1320 // Token: 0x0600259D RID: 9629 RVA: 0x000D6AC8 File Offset: 0x000D4CC8
1321 public virtual int GetPrice(Thing t, CurrencyType currency, int num, bool sell)
1322 {
1323 return ShopTransaction.current.GetPrice(t, num, sell);
1324 }
1325
1326 // Token: 0x0600259E RID: 9630 RVA: 0x000D6AD8 File Offset: 0x000D4CD8
1327 public virtual string GetTextDetail(Thing t, CurrencyType currency, int num, bool sell)
1328 {
1329 int price = this.GetPrice(t, currency, num, sell);
1330 string @ref = InvOwner.Trader.UseHomeResource ? InvOwner.Trader.homeResource.Name : ((currency == CurrencyType.Influence) ? "influence".lang() : EClass.sources.things.map[this.IDCurrency].GetName());
1331 string ref2 = (price == 0) ? "" : "invInteraction3".lang(price.ToString() ?? "", @ref, null, null, null);
1332 string text = "invInteraction1".lang(num.ToString() ?? "", ref2, (sell ? "invSell" : "invBuy").lang(), null, null);
1333 if (!sell && EClass.pc.GetCurrency(Currency.ToID(currency)) < price)
1334 {
1335 text = text.TagColor(FontColor.Bad, SkinManager.DarkColors);
1336 }
1337 return text;
1338 }
1339
1340 // Token: 0x0600259F RID: 9631 RVA: 0x000D6BC0 File Offset: 0x000D4DC0
1341 public virtual void OnWriteNote(ButtonGrid button, UINote n)
1342 {
1343 Thing thing = button.card as Thing;
1344 if (thing == null)
1345 {
1346 return;
1347 }
1348 bool flag;
1349 if (InvOwner.HasTrader && InvOwner.Trader.currency != CurrencyType.None)
1350 {
1351 if (this.destInvOwner == InvOwner.Trader)
1352 {
1353 if (!InvOwner.Trader.AllowSell)
1354 {
1355 ShopTransaction current = ShopTransaction.current;
1356 flag = (current != null && current.CanSellBack(thing, -1));
1357 }
1358 else
1359 {
1360 flag = true;
1361 }
1362 }
1363 else
1364 {
1365 flag = true;
1366 }
1367 }
1368 else
1369 {
1370 flag = false;
1371 }
1372 bool flag2 = flag;
1373 if (flag2 && InvOwner.Trader.UseGuide && !InvOwner.Trader.ShouldShowGuide(thing))
1374 {
1375 flag2 = false;
1376 }
1377 if (flag2)
1378 {
1379 InvOwner.Transaction transaction = new InvOwner.Transaction(button, 1, null);
1380 n.Space(8, 1);
1381 UIItem uiitem = n.AddExtra<UIItem>("costPrice");
1382 string id = this.IDCostIcon(thing);
1383 int price = transaction.GetPrice();
1384 uiitem.text1.SetText(Lang._currency(price, false, 14), transaction.IsValid() ? FontColor.Good : FontColor.Bad);
1385 uiitem.image1.sprite = (InvOwner.Trader.UseHomeResource ? InvOwner.Trader.homeResource.Sprite : SpriteSheet.Get(id));
1386 }
1387 }
1388
1389 // Token: 0x060025A0 RID: 9632 RVA: 0x000D6CC1 File Offset: 0x000D4EC1
1390 public virtual string IDCostIcon(Thing t)
1391 {
1392 return "icon_" + this.IDCurrency;
1393 }
1394
1395 // Token: 0x17000B3D RID: 2877
1396 // (get) Token: 0x060025A1 RID: 9633 RVA: 0x000D6CD3 File Offset: 0x000D4ED3
1397 public string IDCurrency
1398 {
1399 get
1400 {
1401 return Currency.ToID(InvOwner.Trader.currency);
1402 }
1403 }
1404
1405 // Token: 0x060025A2 RID: 9634 RVA: 0x000D6CE4 File Offset: 0x000D4EE4
1406 public virtual bool IsFailByCurse(Thing t)
1407 {
1408 return false;
1409 }
1410
1411 // Token: 0x040014EA RID: 5354
1412 public static InvOwner.ForceGiveData forceGive = new InvOwner.ForceGiveData();
1413
1414 // Token: 0x040014EB RID: 5355
1415 public static InvOwner Trader;
1416
1417 // Token: 0x040014EC RID: 5356
1418 public static InvOwner Main;
1419
1420 // Token: 0x040014ED RID: 5357
1421 public static float clickTimer;
1422
1423 // Token: 0x040014EE RID: 5358
1424 public bool includeChildren;
1425
1426 // Token: 0x040014EF RID: 5359
1427 public CurrencyType currency;
1428
1429 // Token: 0x040014F0 RID: 5360
1430 public PriceType priceType;
1431
1432 // Token: 0x040014F1 RID: 5361
1433 public HomeResource homeResource;
1434
1435 // Token: 0x040014F2 RID: 5362
1436 public Card owner;
1437
1438 // Token: 0x040014F3 RID: 5363
1439 public Card Container;
1440
1441 // Token: 0x040014F4 RID: 5364
1442 public List<ButtonGrid> buttons = new List<ButtonGrid>();
1443
1444 // Token: 0x02000A95 RID: 2709
1445 public class ErrorMessage
1446 {
1447 // Token: 0x06004162 RID: 16738 RVA: 0x00151104 File Offset: 0x0014F304
1448 public void Set(string _lang, Card c = null, string _sound = "beep_small")
1449 {
1450 this.lang = _lang;
1451 if (c != null)
1452 {
1453 this.card = c;
1454 }
1455 this.sound = _sound;
1456 }
1457
1458 // Token: 0x04002B32 RID: 11058
1459 public string sound = "beep_small";
1460
1461 // Token: 0x04002B33 RID: 11059
1462 public string lang = "";
1463
1464 // Token: 0x04002B34 RID: 11060
1465 public Card card;
1466 }
1467
1468 // Token: 0x02000A96 RID: 2710
1469 public class ForceGiveData
1470 {
1471 // Token: 0x04002B35 RID: 11061
1472 public Card card;
1473
1474 // Token: 0x04002B36 RID: 11062
1475 public int tries;
1476 }
1477
1478 // Token: 0x02000A97 RID: 2711
1479 public class Transaction
1480 {
1481 // Token: 0x170011E1 RID: 4577
1482 // (get) Token: 0x06004165 RID: 16741 RVA: 0x00151144 File Offset: 0x0014F344
1483 public InvOwner destInv
1484 {
1485 get
1486 {
1487 if (this.to != null)
1488 {
1489 return this.to.invOwner;
1490 }
1491 if (this.destUIInv != null)
1492 {
1493 return this.destUIInv.owner;
1494 }
1495 if (!this.inv.owner.IsPC)
1496 {
1497 return InvOwner.Main;
1498 }
1499 return InvOwner.Trader;
1500 }
1501 }
1502
1503 // Token: 0x170011E2 RID: 4578
1504 // (get) Token: 0x06004166 RID: 16742 RVA: 0x0015119C File Offset: 0x0014F39C
1505 public bool sell
1506 {
1507 get
1508 {
1509 return (!this.destInv.InvertSell && !this.destInv.owner.IsPC) || (this.destInv.InvertSell && this.destInv.owner.IsPC);
1510 }
1511 }
1512
1513 // Token: 0x170011E3 RID: 4579
1514 // (get) Token: 0x06004167 RID: 16743 RVA: 0x001511EC File Offset: 0x0014F3EC
1515 public string IDCurrency
1516 {
1517 get
1518 {
1519 return this.currency.ToString().ToLower();
1520 }
1521 }
1522
1523 // Token: 0x170011E4 RID: 4580
1524 // (get) Token: 0x06004168 RID: 16744 RVA: 0x00151212 File Offset: 0x0014F412
1525 public CurrencyType currency
1526 {
1527 get
1528 {
1529 return InvOwner.Trader.currency;
1530 }
1531 }
1532
1533 // Token: 0x170011E5 RID: 4581
1534 // (get) Token: 0x06004169 RID: 16745 RVA: 0x00151220 File Offset: 0x0014F420
1535 public bool FreeTrade
1536 {
1537 get
1538 {
1539 return !InvOwner.HasTrader || this.currency == CurrencyType.None || (this.to != null && this.to.invOwner.owner == EClass.pc) || (this.destUIInv && this.destUIInv.owner.owner == EClass.pc);
1540 }
1541 }
1542
1543 // Token: 0x0600416A RID: 16746 RVA: 0x00151284 File Offset: 0x0014F484
1544 public Transaction(DragItemCard.DragInfo from, UIInventory destUIInv, int num = 1)
1545 {
1546 this.from = from;
1547 this.button = from.button;
1548 this.thing = from.thing;
1549 this.num = num;
1550 this.inv = from.invOwner;
1551 this.destUIInv = destUIInv;
1552 }
1553
1554 // Token: 0x0600416B RID: 16747 RVA: 0x001512D8 File Offset: 0x0014F4D8
1555 public Transaction(DragItemCard.DragInfo from, DragItemCard.DragInfo to, int num = 1)
1556 {
1557 this.from = from;
1558 this.to = to;
1559 this.button = from.button;
1560 this.thing = from.thing;
1561 this.num = num;
1562 this.inv = from.invOwner;
1563 }
1564
1565 // Token: 0x0600416C RID: 16748 RVA: 0x0015132B File Offset: 0x0014F52B
1566 public Transaction(ButtonGrid button, int num = 1, InvOwner owner = null)
1567 {
1568 this.button = button;
1569 this.thing = (button.card as Thing);
1570 this.num = num;
1571 this.inv = (owner ?? button.invOwner);
1572 }
1573
1574 // Token: 0x0600416D RID: 16749 RVA: 0x0015136C File Offset: 0x0014F56C
1575 public bool Process(bool startTransaction = false)
1576 {
1577 InvOwner.Transaction.error = new InvOwner.ErrorMessage
1578 {
1579 card = this.thing
1580 };
1581 if (!this.IsValid())
1582 {
1583 SE.Play(InvOwner.Transaction.error.sound);
1584 if (!InvOwner.Transaction.error.lang.IsEmpty())
1585 {
1586 Msg.Say(InvOwner.Transaction.error.lang, InvOwner.Transaction.error.card, null, null, null);
1587 }
1588 return false;
1589 }
1590 if (this.inv.IsFailByCurse(this.thing))
1591 {
1592 return false;
1593 }
1594 if (this.destInv.CopyOnTransfer)
1595 {
1596 int num = this.thing.Num;
1597 if (this.from != null && !(this.from.invOwner is InvOwnerAlly))
1598 {
1599 this.thing = this.from.invOwner.PutBack(this.from);
1600 }
1601 else if (this.thing.parent != this.inv.Container)
1602 {
1603 this.thing = this.inv.Container.AddThing(this.thing, true, -1, -1);
1604 }
1605 if (num != this.thing.Num)
1606 {
1607 this.thing = this.thing.Split(num);
1608 this.thing = EClass.pc.Pick(this.thing, false, false);
1609 }
1610 if (this.destInv.SingleTarget)
1611 {
1612 this.thing = this.thing.Split(1);
1613 }
1614 if (this.to != null)
1615 {
1616 this.to.button.SetCardGrid(this.thing, this.to.button.invOwner);
1617 }
1618 else
1619 {
1620 int currentIndex = LayerDragGrid.Instance.currentIndex;
1621 this.destInv.buttons[currentIndex].SetCardGrid(this.thing, this.destInv.buttons[currentIndex].invOwner);
1622 }
1623 this.destInv.OnProcess(this.thing);
1624 if (this.GetPrice() != 0)
1625 {
1626 SE.Play("buy");
1627 EClass.pc.ModCurrency(this.GetPrice() * -1, this.IDCurrency);
1628 }
1629 return true;
1630 }
1631 if (!startTransaction && this.to == null && (this.destInv.owner.IsPC ? EClass.pc : this.destInv.Container).things.IsFull(this.thing, true, true))
1632 {
1633 if (this.destInv.owner == EClass.pc)
1634 {
1635 InvOwner.Transaction.error.Set("backpack_full", null, "beep_small");
1636 }
1637 SE.Beep();
1638 return false;
1639 }
1640 Thing thing = this.thing.parent as Thing;
1641 if (thing != null && thing.isNPCProperty)
1642 {
1643 Msg.Say("steal_container", thing, this.thing, null, null);
1644 this.thing.isNPCProperty = false;
1645 EClass.player.ModKarma(-1);
1646 EClass.pc.pos.TryWitnessCrime(EClass.pc, null, 4, null);
1647 }
1648 DragItemCard dragItemCard = new DragItemCard(this.button, startTransaction);
1649 Thing thing2 = this.thing.Split(this.num);
1650 bool flag = false;
1651 if (this.FreeTrade)
1652 {
1653 flag = true;
1654 }
1655 else
1656 {
1657 SE.Play(this.sell ? "sell" : "buy");
1658 int price = this.GetPrice();
1659 if (InvOwner.Trader.UseHomeResource)
1660 {
1661 InvOwner.Trader.homeResource.Mod(this.sell ? price : (-price), true);
1662 }
1663 else
1664 {
1665 if (this.sell)
1666 {
1667 EClass.pc.ModCurrency(price, this.IDCurrency);
1668 }
1669 else
1670 {
1671 EClass.pc.ModCurrency(-price, this.IDCurrency);
1672 }
1673 ShopTransaction.current.Process(thing2, thing2.Num, this.sell);
1674 Msg.Say(this.sell ? "sold" : "bought", thing2, Lang._currency(Mathf.Abs(price), this.IDCurrency), null, null);
1675 if (thing2.id == "statue_weird" && this.sell)
1676 {
1677 EClass.pc.Say("statue_install", null, null);
1678 }
1679 }
1680 }
1681 if (this.destInv.Container.isChara && !this.destInv.owner.IsPC && !this.destInv.owner.Chara.CanAcceptItem(thing2, -1))
1682 {
1683 this.destInv.owner.Chara.Talk("tooHeavy", null, null, false);
1684 return false;
1685 }
1686 if (thing2.c_isImportant && !this.destInv.owner.IsPC && this.destInv.DenyImportant)
1687 {
1688 Msg.Say("markedImportant");
1689 return false;
1690 }
1691 if (this.inv.owner.isChara && this.inv.owner.Chara.IsPCFaction && !this.inv.owner.IsPC && thing2.IsRangedWeapon)
1692 {
1693 thing2.ammoData = null;
1694 thing2.c_ammo = 0;
1695 }
1696 if (startTransaction)
1697 {
1698 dragItemCard.from.thing = thing2;
1699 EClass.ui.StartDrag(dragItemCard);
1700 }
1701 else
1702 {
1703 Thing thing3;
1704 if (this.to != null)
1705 {
1706 thing2.invY = this.to.invY;
1707 thing3 = this.to.container.AddThing(thing2, true, this.to.invX, this.to.invY);
1708 if (thing3 == thing2)
1709 {
1710 if (this.to.thing != null)
1711 {
1712 if (this.FreeTrade && !this.destInv.IsMagicChest)
1713 {
1714 EClass.ui.nextDrag = new DragItemCard(this.to.button, true);
1715 this.to.invOwner.Grab(this.to);
1716 flag = false;
1717 }
1718 else if (this.destInv.Container != thing2.parent)
1719 {
1720 thing3 = this.destInv.Container.AddThing(thing2, true, -1, -1);
1721 }
1722 }
1723 this.to.grid[this.to.invX] = thing2;
1724 thing2.invX = this.to.invX;
1725 this.to.button.card = thing2;
1726 }
1727 }
1728 else
1729 {
1730 bool useGrid = EClass.game.UseGrid;
1731 if (!EClass.game.UseGrid && this.destUIInv)
1732 {
1733 RectTransform rectTransform = new GameObject().AddComponent<RectTransform>();
1734 rectTransform.SetParent(this.destUIInv.list.transform);
1735 rectTransform.SetAnchor(0f, 0f, 0f, 0f);
1736 rectTransform.localScale = Vector3.one;
1737 rectTransform.sizeDelta = Vector3.one;
1738 rectTransform.position = Input.mousePosition;
1739 this.from.thing.posInvX = (int)rectTransform.anchoredPosition.x;
1740 this.from.thing.posInvY = (int)rectTransform.anchoredPosition.y;
1741 }
1742 if (this.destInv.owner.IsPC)
1743 {
1744 thing3 = EClass.pc.Pick(thing2, false, true);
1745 }
1746 else
1747 {
1748 thing3 = this.destInv.Container.AddThing(thing2, useGrid, -1, -1);
1749 }
1750 }
1751 this.destInv.OnProcess(thing3);
1752 }
1753 if (this.destInv.Container.trait is TraitDeliveryChest)
1754 {
1755 thing2.SetInt(102, EClass._zone.uid);
1756 }
1757 else
1758 {
1759 thing2.SetInt(102, 0);
1760 }
1761 Chara chara = this.destInv.Container.Chara;
1762 if (chara != null && !chara.IsPC)
1763 {
1764 chara.TryEquip(thing2, false);
1765 if (thing2.id == "lovepotion" || thing2.id == "dreambug")
1766 {
1767 EClass.pc.GiveLovePotion(chara, thing2);
1768 EClass.ui.CloseLayers();
1769 return true;
1770 }
1771 }
1772 if (thing2.id == "statue_weird")
1773 {
1774 if (!this.destInv.owner.IsPC)
1775 {
1776 EClass.pc.Say("statue_sell", null, null);
1777 }
1778 else if (thing == null || thing.GetRootCard() != EClass.pc)
1779 {
1780 EClass.pc.Say("statue_pick", null, null);
1781 }
1782 }
1783 if (flag)
1784 {
1785 SE.Drop();
1786 }
1787 return true;
1788 }
1789
1790 // Token: 0x0600416E RID: 16750 RVA: 0x00151B8D File Offset: 0x0014FD8D
1791 public int GetPrice()
1792 {
1793 if (InvOwner.Trader != null)
1794 {
1795 return InvOwner.Trader.GetPrice(this.thing, this.currency, this.num, this.sell);
1796 }
1797 return 0;
1798 }
1799
1800 // Token: 0x0600416F RID: 16751 RVA: 0x00151BBC File Offset: 0x0014FDBC
1801 public bool IsValid()
1802 {
1803 if (this.destInv is InvOwnerToolbelt)
1804 {
1805 return false;
1806 }
1807 if (this.destInv.UseGuide && !this.destInv.ShouldShowGuide(this.thing))
1808 {
1809 return false;
1810 }
1811 if (this.destInv.Container.c_lockLv != 0)
1812 {
1813 return false;
1814 }
1815 if (this.thing.trait is TraitAbility && this.destInv.owner != EClass.pc)
1816 {
1817 return false;
1818 }
1819 if (this.destInv.CopyOnTransfer && this.to != null && this.to.button.index != LayerDragGrid.Instance.currentIndex)
1820 {
1821 return false;
1822 }
1823 if (!this.destInv.AllowTransfer)
1824 {
1825 return false;
1826 }
1827 if (this.thing.trait.IsContainer && this.destInv.Container != EClass.pc && !(this.destInv.Container.trait is TraitToolBelt) && this.thing.things.Count > 0 && (!this.destInv.CopyOnTransfer || !this.destInv.ShouldShowGuide(this.thing)) && (this.destInv != InvOwner.Trader || ShopTransaction.current == null || !ShopTransaction.current.HasBought(this.thing)))
1828 {
1829 InvOwner.Transaction.error.Set("errorUnemptyContainer", null, "beep_small");
1830 return false;
1831 }
1832 if (InvOwner.HasTrader && InvOwner.Trader.currency != CurrencyType.None)
1833 {
1834 int price = this.GetPrice();
1835 if (this.sell)
1836 {
1837 if (this.destInv.destInvY == 0 && this.destInv.Container.things.IsFull(this.thing, true, true))
1838 {
1839 return false;
1840 }
1841 if (this.thing.c_isImportant)
1842 {
1843 return false;
1844 }
1845 if (ShopTransaction.current == null || !ShopTransaction.current.CanSellBack(this.thing, -1))
1846 {
1847 if (!InvOwner.Trader.AllowSell)
1848 {
1849 return false;
1850 }
1851 if (!this.FreeTrade && price == 0)
1852 {
1853 return false;
1854 }
1855 }
1856 }
1857 else if (!this.FreeTrade)
1858 {
1859 if (InvOwner.Trader.UseHomeResource)
1860 {
1861 if (InvOwner.Trader.homeResource.value < price)
1862 {
1863 return false;
1864 }
1865 }
1866 else if (EClass.pc.GetCurrency(this.IDCurrency) < price)
1867 {
1868 return false;
1869 }
1870 }
1871 }
1872 if (this.to != null)
1873 {
1874 if (this.to.invOwner.IsMagicChest && this.to.container.things.IsFull(0))
1875 {
1876 return false;
1877 }
1878 if (this.to.thing != null && !this.to.thing.isDestroyed && !this.destInv.AllowHold(this.to.thing))
1879 {
1880 return false;
1881 }
1882 }
1883 if (this.destInv.owner.IsPC && !this.destInv.Container.IsPC && this.destInv.IsWeightOver(this.thing))
1884 {
1885 InvOwner.Transaction.error.Set("errorOverweight", null, "beep_small");
1886 return false;
1887 }
1888 return true;
1889 }
1890
1891 // Token: 0x06004170 RID: 16752 RVA: 0x00151EBC File Offset: 0x001500BC
1892 public string GetTextDetail()
1893 {
1894 if (this.FreeTrade || (this.destInv.UseGuide && !this.destInv.ShouldShowGuide(this.thing)))
1895 {
1896 return "";
1897 }
1898 return this.destInv.GetTextDetail(this.thing, this.currency, this.num, this.sell);
1899 }
1900
1901 // Token: 0x04002B37 RID: 11063
1902 public static InvOwner.ErrorMessage error = new InvOwner.ErrorMessage();
1903
1904 // Token: 0x04002B38 RID: 11064
1905 public Thing thing;
1906
1907 // Token: 0x04002B39 RID: 11065
1908 public ButtonGrid button;
1909
1910 // Token: 0x04002B3A RID: 11066
1911 public int num = 1;
1912
1913 // Token: 0x04002B3B RID: 11067
1914 public DragItemCard.DragInfo from;
1915
1916 // Token: 0x04002B3C RID: 11068
1917 public DragItemCard.DragInfo to;
1918
1919 // Token: 0x04002B3D RID: 11069
1920 public UIInventory destUIInv;
1921
1922 // Token: 0x04002B3E RID: 11070
1923 public InvOwner inv;
1924 }
1925
1926 // Token: 0x02000A98 RID: 2712
1927 public class Interaction
1928 {
1929 // Token: 0x04002B3F RID: 11071
1930 public string name;
1931
1932 // Token: 0x04002B40 RID: 11072
1933 public Action action;
1934
1935 // Token: 0x04002B41 RID: 11073
1936 public int priority;
1937
1938 // Token: 0x04002B42 RID: 11074
1939 public bool repeatable;
1940 }
1941
1942 // Token: 0x02000A99 RID: 2713
1943 public class ListInteraction : List<InvOwner.Interaction>
1944 {
1945 // Token: 0x06004173 RID: 16755 RVA: 0x00151F30 File Offset: 0x00150130
1946 public InvOwner.Interaction Add(string s, int priority, Action action)
1947 {
1949 {
1950 name = s,
1951 priority = priority,
1952 action = action
1953 };
1954 base.Add(interaction);
1955 return interaction;
1956 }
1957
1958 // Token: 0x06004174 RID: 16756 RVA: 0x00151F60 File Offset: 0x00150160
1959 public bool Contains(string s)
1960 {
1961 using (List<InvOwner.Interaction>.Enumerator enumerator = base.GetEnumerator())
1962 {
1963 while (enumerator.MoveNext())
1964 {
1965 if (enumerator.Current.name == s)
1966 {
1967 return true;
1968 }
1969 }
1970 }
1971 return false;
1972 }
1973 }
1974}
Definition Card.cs:13
Definition Chara.cs:12
Definition Msg.cs:7
Definition Thing.cs:10
Definition Trait.cs:9