Elin Decompiled Documentation EA 23.153 Nightly
Loading...
Searching...
No Matches
InvOwner.Transaction Class Reference

Public Member Functions

 Transaction (DragItemCard.DragInfo from, UIInventory destUIInv, int num=1)
 
 Transaction (DragItemCard.DragInfo from, DragItemCard.DragInfo to, int num=1)
 
 Transaction (ButtonGrid button, int num=1, InvOwner owner=null)
 
bool Process (bool startTransaction=false)
 
int GetPrice ()
 
bool IsValid ()
 
string GetTextDetail ()
 

Public Attributes

Thing thing
 
ButtonGrid button
 
int num = 1
 
DragItemCard.DragInfo from
 
DragItemCard.DragInfo to
 
UIInventory destUIInv
 
InvOwner inv
 

Static Public Attributes

static ErrorMessage error = new ErrorMessage()
 

Properties

InvOwner destInv [get]
 
bool sell [get]
 
string IDCurrency [get]
 
CurrencyType currency [get]
 
bool FreeTrade [get]
 

Detailed Description

Definition at line 33 of file InvOwner.cs.

Constructor & Destructor Documentation

◆ Transaction() [1/3]

InvOwner.Transaction.Transaction ( DragItemCard::DragInfo  from,
UIInventory  destUIInv,
int  num = 1 
)
inline

Definition at line 107 of file InvOwner.cs.

108 {
109 this.from = from;
111 thing = from.thing;
112 this.num = num;
113 inv = from.invOwner;
114 this.destUIInv = destUIInv;
115 }
ButtonGrid button
Definition: DragItemCard.cs:52
UIInventory destUIInv
Definition: InvOwner.cs:47
DragItemCard.DragInfo from
Definition: InvOwner.cs:43
ButtonGrid button
Definition: InvOwner.cs:39

References DragItemCard.button, InvOwner.Transaction.button, InvOwner.Transaction.destUIInv, InvOwner.Transaction.from, InvOwner.Transaction.inv, InvOwner.Transaction.num, and InvOwner.Transaction.thing.

◆ Transaction() [2/3]

InvOwner.Transaction.Transaction ( DragItemCard::DragInfo  from,
DragItemCard::DragInfo  to,
int  num = 1 
)
inline

Definition at line 117 of file InvOwner.cs.

118 {
119 this.from = from;
120 this.to = to;
122 thing = from.thing;
123 this.num = num;
124 inv = from.invOwner;
125 }
DragItemCard.DragInfo to
Definition: InvOwner.cs:45

References DragItemCard.button, InvOwner.Transaction.button, InvOwner.Transaction.from, InvOwner.Transaction.inv, InvOwner.Transaction.num, InvOwner.Transaction.thing, and InvOwner.Transaction.to.

◆ Transaction() [3/3]

InvOwner.Transaction.Transaction ( ButtonGrid  button,
int  num = 1,
InvOwner  owner = null 
)
inline

Definition at line 127 of file InvOwner.cs.

128 {
129 this.button = button;
130 thing = button.card as Thing;
131 this.num = num;
133 }
InvOwner invOwner
Definition: ButtonGrid.cs:28
Card owner
Definition: InvOwner.cs:533
Definition: Thing.cs:8

References InvOwner.Transaction.button, InvOwner.Transaction.inv, ButtonGrid.invOwner, InvOwner.Transaction.num, InvOwner.owner, and InvOwner.Transaction.thing.

Member Function Documentation

◆ GetPrice()

int InvOwner.Transaction.GetPrice ( )
inline

Definition at line 348 of file InvOwner.cs.

349 {
350 if (Trader != null)
351 {
353 }
354 return 0;
355 }
CurrencyType currency
Definition: InvOwner.cs:89
static InvOwner Trader
Definition: InvOwner.cs:519
virtual int GetPrice(Thing t, CurrencyType currency, int num, bool sell)
Definition: InvOwner.cs:1725

References InvOwner.Transaction.currency, InvOwner.GetPrice(), InvOwner.Transaction.num, InvOwner.Transaction.sell, InvOwner.Transaction.thing, and InvOwner.Trader.

Referenced by InvOwner.Transaction.IsValid(), InvOwner.OnWriteNote(), and InvOwner.Transaction.Process().

◆ GetTextDetail()

string InvOwner.Transaction.GetTextDetail ( )
inline

Definition at line 447 of file InvOwner.cs.

448 {
450 {
451 return "";
452 }
454 }
InvOwner destInv
Definition: InvOwner.cs:52
virtual string GetTextDetail(Thing t, CurrencyType currency, int num, bool sell)
Definition: InvOwner.cs:1730
virtual bool UseGuide
Definition: InvOwner.cs:571
virtual bool ShouldShowGuide(Thing t)
Definition: InvOwner.cs:681

References InvOwner.Transaction.currency, InvOwner.Transaction.destInv, InvOwner.Transaction.FreeTrade, InvOwner.GetTextDetail(), InvOwner.Transaction.num, InvOwner.Transaction.sell, InvOwner.ShouldShowGuide(), InvOwner.Transaction.thing, and InvOwner.UseGuide.

Referenced by InvOwner.ListInteractions(), and InvOwner.OnDrag().

◆ IsValid()

bool InvOwner.Transaction.IsValid ( )
inline

Definition at line 357 of file InvOwner.cs.

358 {
360 {
361 return false;
362 }
364 {
365 return false;
366 }
367 if (destInv.Container.c_lockLv != 0)
368 {
369 return false;
370 }
372 {
373 return false;
374 }
376 {
377 return false;
378 }
380 {
381 return false;
382 }
384 {
385 error.Set("errorUnemptyContainer");
386 return false;
387 }
388 if (HasTrader && Trader.currency != 0)
389 {
390 int price = GetPrice();
391 if (sell)
392 {
394 {
395 return false;
396 }
398 {
399 return false;
400 }
402 {
403 if (!Trader.AllowSell)
404 {
405 return false;
406 }
407 if (!FreeTrade && price == 0)
408 {
409 return false;
410 }
411 }
412 }
413 else if (!FreeTrade)
414 {
416 {
417 if (Trader.homeResource.value < price)
418 {
419 return false;
420 }
421 }
422 else if (EClass.pc.GetCurrency(IDCurrency) < price || price < 0 || (price == 0 && Trader.GetPrice(thing, currency, 1, sell) > 0))
423 {
424 return false;
425 }
426 }
427 }
428 if (to != null)
429 {
430 if (to.invOwner.IsMagicChest && to.container.things.IsFull())
431 {
432 return false;
433 }
434 if (to.thing != null && !to.thing.isDestroyed && !destInv.AllowHold(to.thing))
435 {
436 return false;
437 }
438 }
440 {
441 error.Set("errorOverweight");
442 return false;
443 }
444 return true;
445 }
int c_lockLv
Definition: Card.cs:936
int GetCurrency(string id="money")
Definition: Card.cs:3820
Trait trait
Definition: Card.cs:49
bool c_isImportant
Definition: Card.cs:996
ThingContainer things
Definition: Card.cs:34
virtual bool IsPC
Definition: Card.cs:2079
Definition: EClass.cs:5
static Chara pc
Definition: EClass.cs:14
void Set(string _lang, Card c=null, string _sound="beep_small")
Definition: InvOwner.cs:15
static ErrorMessage error
Definition: InvOwner.cs:35
virtual int destInvY
Definition: InvOwner.cs:589
bool UseHomeResource
Definition: InvOwner.cs:597
static bool HasTrader
Definition: InvOwner.cs:539
virtual bool AllowHold(Thing t)
Definition: InvOwner.cs:639
Card Container
Definition: InvOwner.cs:535
virtual bool AllowTransfer
Definition: InvOwner.cs:574
bool IsWeightOver(Thing t)
Definition: InvOwner.cs:721
CurrencyType currency
Definition: InvOwner.cs:527
HomeResource homeResource
Definition: InvOwner.cs:531
virtual bool CopyOnTransfer
Definition: InvOwner.cs:593
virtual bool AllowSell
Definition: InvOwner.cs:558
static LayerDragGrid Instance
bool HasBought(Thing t)
static ShopTransaction current
bool CanSellBack(Thing t, int num=-1)
bool IsFull(int y=0)
virtual bool IsContainer
Definition: Trait.cs:209

References InvOwner.AllowHold(), InvOwner.AllowSell, InvOwner.AllowTransfer, DragItemCard.button, Card.c_isImportant, Card.c_lockLv, ShopTransaction.CanSellBack(), InvOwner.Container, InvOwner.CopyOnTransfer, InvOwner.Transaction.currency, InvOwner.currency, ShopTransaction.current, LayerDragGrid.currentIndex, InvOwner.Transaction.destInv, InvOwner.destInvY, InvOwner.Transaction.error, InvOwner.Transaction.FreeTrade, Card.GetCurrency(), InvOwner.Transaction.GetPrice(), InvOwner.GetPrice(), ShopTransaction.HasBought(), InvOwner.HasTrader, InvOwner.homeResource, InvOwner.Transaction.IDCurrency, ButtonGrid.index, LayerDragGrid.Instance, Trait.IsContainer, ThingContainer.IsFull(), Card.IsPC, InvOwner.IsWeightOver(), InvOwner.owner, EClass.pc, InvOwner.Transaction.sell, InvOwner.ErrorMessage.Set(), InvOwner.ShouldShowGuide(), InvOwner.Transaction.thing, Card.things, InvOwner.Transaction.to, InvOwner.Trader, Card.trait, InvOwner.UseGuide, InvOwner.UseHomeResource, and BaseHomeResource.value.

Referenced by InvOwnerAlly.GetAutoUseLang(), InvOwner.ListInteractions(), InvOwner.OnDrag(), InvOwner.OnWriteNote(), and InvOwner.Transaction.Process().

◆ Process()

bool InvOwner.Transaction.Process ( bool  startTransaction = false)
inline

Definition at line 135 of file InvOwner.cs.

136 {
137 error = new ErrorMessage
138 {
139 card = this.thing
140 };
141 if (!IsValid())
142 {
143 SE.Play(error.sound);
144 if (!error.lang.IsEmpty())
145 {
147 }
148 return false;
149 }
150 if (inv.IsFailByCurse(this.thing))
151 {
152 return false;
153 }
155 {
156 int num = this.thing.Num;
157 if (from != null && !(from.invOwner is InvOwnerAlly))
158 {
159 this.thing = from.invOwner.PutBack(from);
160 }
161 else if (this.thing.parent != inv.Container)
162 {
163 this.thing = inv.Container.AddThing(this.thing);
164 }
165 if (num != this.thing.Num)
166 {
167 this.thing = this.thing.Split(num);
168 this.thing = EClass.pc.Pick(this.thing, msg: false, tryStack: false);
169 }
171 {
172 this.thing = this.thing.Split(1);
173 }
174 if (to != null)
175 {
177 }
178 else
179 {
180 int currentIndex = LayerDragGrid.Instance.currentIndex;
181 destInv.buttons[currentIndex].SetCardGrid(this.thing, destInv.buttons[currentIndex].invOwner);
182 }
183 destInv.OnProcess(this.thing);
184 if (GetPrice() != 0)
185 {
186 SE.Play("buy");
188 }
189 return true;
190 }
191 if (!startTransaction && to == null && (destInv.owner.IsPC ? EClass.pc : destInv.Container).things.IsFull(this.thing))
192 {
193 if (destInv.owner == EClass.pc)
194 {
195 error.Set("backpack_full");
196 }
197 SE.Beep();
198 return false;
199 }
200 Thing thing = this.thing.parent as Thing;
201 if (thing != null && thing.isNPCProperty)
202 {
203 Msg.Say("steal_container", thing, this.thing);
204 this.thing.isNPCProperty = false;
207 }
208 DragItemCard dragItemCard = new DragItemCard(button, startTransaction);
209 Thing thing2 = this.thing.Split(this.num);
210 Thing thing3 = thing2;
211 bool flag = false;
212 if (FreeTrade)
213 {
214 flag = true;
215 }
216 else
217 {
218 SE.Play(sell ? "sell" : "buy");
219 int price = GetPrice();
221 {
222 Trader.homeResource.Mod(sell ? price : (-price));
223 }
224 else
225 {
226 if (sell)
227 {
229 }
230 else
231 {
233 }
234 if (sell && !thing2.IsIdentified)
235 {
236 thing2.Identify(show: true, IDTSource.SuperiorIdentify);
237 }
238 else
239 {
240 ShopTransaction.current.Process(thing2, thing2.Num, sell);
241 }
242 Msg.Say(sell ? "sold" : "bought", thing2, Lang._currency(Mathf.Abs(price), IDCurrency));
243 if (thing2.id == "statue_weird" && sell)
244 {
245 EClass.pc.Say("statue_install");
246 }
247 }
248 }
250 {
251 destInv.owner.Chara.Talk("tooHeavy");
252 return false;
253 }
255 {
256 Msg.Say("markedImportant");
257 return false;
258 }
259 if (startTransaction)
260 {
261 dragItemCard.from.thing = thing2;
262 EClass.ui.StartDrag(dragItemCard);
263 }
264 else
265 {
266 if (to != null)
267 {
268 thing2.invY = to.invY;
269 thing3 = to.container.AddThing(thing2, tryStack: true, to.invX, to.invY);
270 if (thing3 == thing2)
271 {
272 if (to.thing != null)
273 {
275 {
276 if (!EClass.core.config.game.doubleClickToHold || !EInput.leftMouse.down || !(EClass.ui.dragDuration < 0.35f) || from == null || !(from.button == to.button) || to.button.invOwner is InvOwnerHotbar)
277 {
278 EClass.ui.nextDrag = new DragItemCard(to.button);
279 to.invOwner.Grab(to);
280 flag = false;
281 }
282 }
283 else if (destInv.Container != thing2.parent)
284 {
285 thing3 = destInv.Container.AddThing(thing2);
286 }
287 }
288 to.grid[to.invX] = thing2;
289 thing2.invX = to.invX;
290 to.button.card = thing2;
291 }
292 }
293 else
294 {
295 bool useGrid = EClass.game.UseGrid;
296 if (!EClass.game.UseGrid && (bool)destUIInv)
297 {
298 RectTransform rectTransform = new GameObject().AddComponent<RectTransform>();
299 rectTransform.SetParent(destUIInv.list.transform);
300 rectTransform.SetAnchor(0f, 0f, 0f, 0f);
301 rectTransform.localScale = Vector3.one;
302 rectTransform.sizeDelta = Vector3.one;
303 rectTransform.position = Input.mousePosition;
304 from.thing.posInvX = (int)rectTransform.anchoredPosition.x;
305 from.thing.posInvY = (int)rectTransform.anchoredPosition.y;
306 }
307 thing3 = ((!destInv.owner.IsPC) ? destInv.Container.AddThing(thing2, useGrid) : EClass.pc.Pick(thing2, msg: false));
308 }
309 destInv.OnProcess(thing3);
310 }
312 {
313 thing2.SetInt(102, EClass._zone.uid);
314 }
315 else
316 {
317 thing2.SetInt(102);
318 }
320 if (chara != null && !chara.IsPC)
321 {
322 chara.TryEquip(thing2);
323 if (thing2.id == "lovepotion" || thing2.id == "dreambug")
324 {
325 EClass.pc.GiveLovePotion(chara, thing2);
326 EClass.ui.CloseLayers();
327 return true;
328 }
329 }
330 if (thing2.id == "statue_weird")
331 {
332 if (!destInv.owner.IsPC)
333 {
334 EClass.pc.Say("statue_sell");
335 }
336 else if (thing == null || thing.GetRootCard() != EClass.pc)
337 {
338 EClass.pc.Say("statue_pick");
339 }
340 }
341 if (flag)
342 {
343 SE.Drop();
344 }
345 return true;
346 }
IDTSource
Definition: IDTSource.cs:2
void SetInt(int id, int value=0)
Definition: BaseCard.cs:39
void SetCardGrid(Card c, InvOwner owner=null)
Definition: ButtonGrid.cs:145
virtual Chara Chara
Definition: Card.cs:2006
Thing Split(int a)
Definition: Card.cs:3345
string id
Definition: Card.cs:31
bool isNPCProperty
Definition: Card.cs:538
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3020
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6326
ICardParent parent
Definition: Card.cs:51
Point pos
Definition: Card.cs:55
void ModCurrency(int a, string id="money")
Definition: Card.cs:3806
virtual bool isChara
Definition: Card.cs:2019
Card GetRootCard()
Definition: Card.cs:3287
int Num
Definition: Card.cs:154
bool IsIdentified
Definition: Card.cs:2313
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6423
Definition: Chara.cs:10
override bool IsPC
Definition: Chara.cs:608
bool CanAcceptItem(Card t, int num=-1)
Definition: Chara.cs:7582
void GiveLovePotion(Chara c, Thing t)
Definition: Chara.cs:7761
bool TryEquip(Thing t, bool useFav=false)
Definition: Chara.cs:7150
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4017
new GameConfig game
Definition: CoreConfig.cs:600
CoreConfig config
Definition: Core.cs:70
static Game game
Definition: EClass.cs:8
static Core core
Definition: EClass.cs:6
static Zone _zone
Definition: EClass.cs:20
static Player player
Definition: EClass.cs:12
static UI ui
Definition: EClass.cs:16
Definition: EInput.cs:8
static ButtonState leftMouse
Definition: EInput.cs:349
bool UseGrid
Definition: Game.cs:259
override void Mod(int a, bool popText=true)
Definition: HomeResource.cs:64
virtual bool DenyImportant
Definition: InvOwner.cs:623
virtual void OnProcess(Thing t)
Definition: InvOwner.cs:1279
virtual bool IsFailByCurse(Thing t)
Definition: InvOwner.cs:1770
virtual bool SingleTarget
Definition: InvOwner.cs:595
List< ButtonGrid > buttons
Definition: InvOwner.cs:537
bool IsMagicChest
Definition: InvOwner.cs:599
Definition: Lang.cs:6
static string _currency(object a, string IDCurrency)
Definition: Lang.cs:162
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
void ModKarma(int a)
Definition: Player.cs:2311
bool TryWitnessCrime(Chara criminal, Chara target=null, int radius=4, Func< Chara, bool > funcWitness=null)
Definition: Point.cs:857
void Process(Thing t, int n, bool sell)
int uid
Definition: Spatial.cs:70
Thing Identify(bool show=true, IDTSource idtSource=IDTSource.Identify)
Definition: Thing.cs:1980
UIList list
Definition: UIInventory.cs:79

References Lang._currency(), EClass._zone, Card.AddThing(), DragItemCard.button, InvOwner.Transaction.button, InvOwner.buttons, Card.c_isImportant, Chara.CanAcceptItem(), InvOwner.ErrorMessage.card, card, Card.Chara, Core.config, InvOwner.Container, InvOwner.CopyOnTransfer, EClass.core, ShopTransaction.current, LayerDragGrid.currentIndex, InvOwner.DenyImportant, InvOwner.Transaction.destInv, InvOwner.Transaction.destUIInv, CoreConfig.GameConfig.doubleClickToHold, ButtonState.down, InvOwner.Transaction.error, InvOwner.Transaction.FreeTrade, InvOwner.Transaction.from, CoreConfig.game, EClass.game, InvOwner.Transaction.GetPrice(), Card.GetRootCard(), Chara.GiveLovePotion(), InvOwner.homeResource, Card.id, InvOwner.Transaction.IDCurrency, Thing.Identify(), LayerDragGrid.Instance, InvOwner.Transaction.inv, ButtonGrid.invOwner, Card.isChara, InvOwner.IsFailByCurse(), Card.IsIdentified, InvOwner.IsMagicChest, Card.isNPCProperty, Card.IsPC, Chara.IsPC, InvOwner.Transaction.IsValid(), InvOwner.ErrorMessage.lang, EInput.leftMouse, UIInventory.list, HomeResource.Mod(), Card.ModCurrency(), Player.ModKarma(), Card.Num, InvOwner.Transaction.num, InvOwner.OnProcess(), InvOwner.owner, Card.parent, EClass.pc, Chara.Pick(), EClass.player, Card.pos, ShopTransaction.Process(), Msg.Say(), Card.Say(), InvOwner.Transaction.sell, InvOwner.ErrorMessage.Set(), ButtonGrid.SetCardGrid(), BaseCard.SetInt(), InvOwner.SingleTarget, InvOwner.ErrorMessage.sound, Card.Split(), Card.Talk(), InvOwner.Transaction.thing, InvOwner.Transaction.to, InvOwner.Trader, Card.trait, Chara.TryEquip(), Point.TryWitnessCrime(), EClass.ui, Spatial.uid, Game.UseGrid, and InvOwner.UseHomeResource.

Referenced by InvOwner.OnClick(), InvOwner.OnDrag(), and InvOwnerAlly.Process().

Member Data Documentation

◆ button

ButtonGrid InvOwner.Transaction.button

Definition at line 39 of file InvOwner.cs.

Referenced by InvOwner.Transaction.Process(), and InvOwner.Transaction.Transaction().

◆ destUIInv

UIInventory InvOwner.Transaction.destUIInv

Definition at line 47 of file InvOwner.cs.

Referenced by InvOwner.Transaction.Process(), and InvOwner.Transaction.Transaction().

◆ error

ErrorMessage InvOwner.Transaction.error = new ErrorMessage()
static

Definition at line 35 of file InvOwner.cs.

Referenced by InvOwner.Transaction.IsValid(), and InvOwner.Transaction.Process().

◆ from

DragItemCard.DragInfo InvOwner.Transaction.from

Definition at line 43 of file InvOwner.cs.

Referenced by InvOwner.Transaction.Process(), and InvOwner.Transaction.Transaction().

◆ inv

InvOwner InvOwner.Transaction.inv

Definition at line 49 of file InvOwner.cs.

Referenced by InvOwner.Transaction.Process(), and InvOwner.Transaction.Transaction().

◆ num

◆ thing

◆ to

Property Documentation

◆ currency

CurrencyType InvOwner.Transaction.currency
get

◆ destInv

InvOwner InvOwner.Transaction.destInv
get

Definition at line 51 of file InvOwner.cs.

52 {
53 get
54 {
55 if (to == null)
56 {
57 if (!(destUIInv != null))
58 {
59 if (!inv.owner.IsPC)
60 {
61 return Main;
62 }
63 return Trader;
64 }
65 return destUIInv.owner;
66 }
67 return to.invOwner;
68 }
69 }
static InvOwner Main
Definition: InvOwner.cs:521
InvOwner owner
Definition: UIInventory.cs:137

Referenced by InvOwner.Transaction.GetTextDetail(), InvOwner.Transaction.IsValid(), and InvOwner.Transaction.Process().

◆ FreeTrade

bool InvOwner.Transaction.FreeTrade
get

Definition at line 91 of file InvOwner.cs.

92 {
93 get
94 {
95 if (HasTrader && currency != 0 && (to == null || to.invOwner.owner != EClass.pc))
96 {
97 if ((bool)destUIInv)
98 {
99 return destUIInv.owner.owner == EClass.pc;
100 }
101 return false;
102 }
103 return true;
104 }
105 }

Referenced by InvOwner.Transaction.GetTextDetail(), InvOwner.Transaction.IsValid(), and InvOwner.Transaction.Process().

◆ IDCurrency

string InvOwner.Transaction.IDCurrency
get

Definition at line 87 of file InvOwner.cs.

Referenced by InvOwner.Transaction.IsValid(), and InvOwner.Transaction.Process().

◆ sell

bool InvOwner.Transaction.sell
get

Definition at line 71 of file InvOwner.cs.

72 {
73 get
74 {
76 {
78 {
79 return destInv.owner.IsPC;
80 }
81 return false;
82 }
83 return true;
84 }
85 }
virtual bool InvertSell
Definition: InvOwner.cs:617

Referenced by InvOwner.Transaction.GetPrice(), InvOwner.Transaction.GetTextDetail(), InvOwner.Transaction.IsValid(), and InvOwner.Transaction.Process().


The documentation for this class was generated from the following file: