Elin Decompiled Documentation EA 23.102 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:538
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 353 of file InvOwner.cs.

354 {
355 if (Trader != null)
356 {
358 }
359 return 0;
360 }
CurrencyType currency
Definition: InvOwner.cs:89
static InvOwner Trader
Definition: InvOwner.cs:524
virtual int GetPrice(Thing t, CurrencyType currency, int num, bool sell)
Definition: InvOwner.cs:1735

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 452 of file InvOwner.cs.

453 {
455 {
456 return "";
457 }
459 }
InvOwner destInv
Definition: InvOwner.cs:52
virtual string GetTextDetail(Thing t, CurrencyType currency, int num, bool sell)
Definition: InvOwner.cs:1740
virtual bool UseGuide
Definition: InvOwner.cs:576
virtual bool ShouldShowGuide(Thing t)
Definition: InvOwner.cs:686

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 362 of file InvOwner.cs.

363 {
365 {
366 return false;
367 }
369 {
370 return false;
371 }
372 if (destInv.Container.c_lockLv != 0)
373 {
374 return false;
375 }
377 {
378 return false;
379 }
381 {
382 return false;
383 }
385 {
386 return false;
387 }
389 {
390 error.Set("errorUnemptyContainer");
391 return false;
392 }
393 if (HasTrader && Trader.currency != 0)
394 {
395 int price = GetPrice();
396 if (sell)
397 {
399 {
400 return false;
401 }
403 {
404 return false;
405 }
407 {
408 if (!Trader.AllowSell)
409 {
410 return false;
411 }
412 if (!FreeTrade && price == 0)
413 {
414 return false;
415 }
416 }
417 }
418 else if (!FreeTrade)
419 {
421 {
422 if (Trader.homeResource.value < price)
423 {
424 return false;
425 }
426 }
427 else if (EClass.pc.GetCurrency(IDCurrency) < price || price < 0 || (price == 0 && Trader.GetPrice(thing, currency, 1, sell) > 0))
428 {
429 return false;
430 }
431 }
432 }
433 if (to != null)
434 {
435 if (to.invOwner.IsMagicChest && to.container.things.IsFull())
436 {
437 return false;
438 }
439 if (to.thing != null && !to.thing.isDestroyed && !destInv.AllowHold(to.thing))
440 {
441 return false;
442 }
443 }
445 {
446 error.Set("errorOverweight");
447 return false;
448 }
449 return true;
450 }
int c_lockLv
Definition: Card.cs:924
int GetCurrency(string id="money")
Definition: Card.cs:3652
Trait trait
Definition: Card.cs:49
bool c_isImportant
Definition: Card.cs:984
ThingContainer things
Definition: Card.cs:34
virtual bool IsPC
Definition: Card.cs:2019
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:594
bool UseHomeResource
Definition: InvOwner.cs:602
static bool HasTrader
Definition: InvOwner.cs:544
virtual bool AllowHold(Thing t)
Definition: InvOwner.cs:644
Card Container
Definition: InvOwner.cs:540
virtual bool AllowTransfer
Definition: InvOwner.cs:579
bool IsWeightOver(Thing t)
Definition: InvOwner.cs:726
CurrencyType currency
Definition: InvOwner.cs:532
HomeResource homeResource
Definition: InvOwner.cs:536
virtual bool CopyOnTransfer
Definition: InvOwner.cs:598
virtual bool AllowSell
Definition: InvOwner.cs:563
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:205

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 }
260 {
261 thing2.ammoData = null;
262 thing2.c_ammo = 0;
263 }
264 if (startTransaction)
265 {
266 dragItemCard.from.thing = thing2;
267 EClass.ui.StartDrag(dragItemCard);
268 }
269 else
270 {
271 if (to != null)
272 {
273 thing2.invY = to.invY;
274 thing3 = to.container.AddThing(thing2, tryStack: true, to.invX, to.invY);
275 if (thing3 == thing2)
276 {
277 if (to.thing != null)
278 {
280 {
281 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)
282 {
283 EClass.ui.nextDrag = new DragItemCard(to.button);
284 to.invOwner.Grab(to);
285 flag = false;
286 }
287 }
288 else if (destInv.Container != thing2.parent)
289 {
290 thing3 = destInv.Container.AddThing(thing2);
291 }
292 }
293 to.grid[to.invX] = thing2;
294 thing2.invX = to.invX;
295 to.button.card = thing2;
296 }
297 }
298 else
299 {
300 bool useGrid = EClass.game.UseGrid;
301 if (!EClass.game.UseGrid && (bool)destUIInv)
302 {
303 RectTransform rectTransform = new GameObject().AddComponent<RectTransform>();
304 rectTransform.SetParent(destUIInv.list.transform);
305 rectTransform.SetAnchor(0f, 0f, 0f, 0f);
306 rectTransform.localScale = Vector3.one;
307 rectTransform.sizeDelta = Vector3.one;
308 rectTransform.position = Input.mousePosition;
309 from.thing.posInvX = (int)rectTransform.anchoredPosition.x;
310 from.thing.posInvY = (int)rectTransform.anchoredPosition.y;
311 }
312 thing3 = ((!destInv.owner.IsPC) ? destInv.Container.AddThing(thing2, useGrid) : EClass.pc.Pick(thing2, msg: false));
313 }
314 destInv.OnProcess(thing3);
315 }
317 {
318 thing2.SetInt(102, EClass._zone.uid);
319 }
320 else
321 {
322 thing2.SetInt(102);
323 }
325 if (chara != null && !chara.IsPC)
326 {
327 chara.TryEquip(thing2);
328 if (thing2.id == "lovepotion" || thing2.id == "dreambug")
329 {
330 EClass.pc.GiveLovePotion(chara, thing2);
331 EClass.ui.CloseLayers();
332 return true;
333 }
334 }
335 if (thing2.id == "statue_weird")
336 {
337 if (!destInv.owner.IsPC)
338 {
339 EClass.pc.Say("statue_sell");
340 }
341 else if (thing == null || thing.GetRootCard() != EClass.pc)
342 {
343 EClass.pc.Say("statue_pick");
344 }
345 }
346 if (flag)
347 {
348 SE.Drop();
349 }
350 return true;
351 }
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:1946
Thing Split(int a)
Definition: Card.cs:3231
string id
Definition: Card.cs:31
bool isNPCProperty
Definition: Card.cs:526
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:2901
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:5949
bool IsRangedWeapon
Definition: Card.cs:2103
ICardParent parent
Definition: Card.cs:51
Point pos
Definition: Card.cs:55
void ModCurrency(int a, string id="money")
Definition: Card.cs:3638
virtual bool isChara
Definition: Card.cs:1959
Card GetRootCard()
Definition: Card.cs:3173
int Num
Definition: Card.cs:154
bool IsIdentified
Definition: Card.cs:2237
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6046
Definition: Chara.cs:10
override bool IsPC
Definition: Chara.cs:597
bool CanAcceptItem(Card t, int num=-1)
Definition: Chara.cs:7434
override bool IsPCFaction
Definition: Chara.cs:656
void GiveLovePotion(Chara c, Thing t)
Definition: Chara.cs:7613
bool TryEquip(Thing t, bool useFav=false)
Definition: Chara.cs:6961
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:3920
new GameConfig game
Definition: CoreConfig.cs:596
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:628
virtual void OnProcess(Thing t)
Definition: InvOwner.cs:1289
virtual bool IsFailByCurse(Thing t)
Definition: InvOwner.cs:1780
virtual bool SingleTarget
Definition: InvOwner.cs:600
List< ButtonGrid > buttons
Definition: InvOwner.cs:542
bool IsMagicChest
Definition: InvOwner.cs:604
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:2289
bool TryWitnessCrime(Chara criminal, Chara target=null, int radius=4, Func< Chara, bool > funcWitness=null)
Definition: Point.cs:845
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:1959
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, Chara.IsPCFaction, Card.IsRangedWeapon, 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:526
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:622

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: