Elin Decompiled Documentation EA 23.306 Nightly
Loading...
Searching...
No Matches
InvOwnerDeliver.cs
Go to the documentation of this file.
2{
3 public enum Mode
4 {
6 Tax,
7 Bank,
8 Crop
9 }
10
11 public Mode mode;
12
13 public override bool ShowButtonDeliver => mode == Mode.Crop;
14
15 public override bool SingleTarget => mode == Mode.Tax;
16
17 public override string langTransfer
18 {
19 get
20 {
21 if (mode != Mode.Bank)
22 {
23 return "invDeliver";
24 }
25 return "invBank";
26 }
27 }
28
29 public override ProcessType processType => ProcessType.Consume;
30
31 public InvOwnerDeliver(Card owner = null, Card container = null, CurrencyType _currency = CurrencyType.Money)
32 : base(owner, container, _currency)
33 {
34 }
35
36 public override bool ShouldShowGuide(Thing t)
37 {
38 switch (mode)
39 {
40 case Mode.Tax:
41 return t.c_bill != 0;
42 case Mode.Bank:
43 return t.id == "money";
44 case Mode.Crop:
45 if (!t.GetBool(115))
46 {
47 return false;
48 }
49 if (!(t.category.id == "vegi") && !(t.category.id == "fruit"))
50 {
51 return t.category.id == "mushroom";
52 }
53 return true;
54 default:
55 return false;
56 }
57 }
58
59 public static void PayBill(Thing t, bool fromBank = false)
60 {
61 bool flag = t.id == "bill_tax";
62 bool flag2 = t.id == "bill_debt";
63 QuestDebt questDebt = EClass.game.quests.Get<QuestDebt>();
64 bool flag3 = flag2 && questDebt != null && !questDebt.paid && questDebt.IsValidBill(t);
65 if ((flag && EClass.player.taxBills <= 0) || (flag2 && !flag3))
66 {
67 SE.Beep();
68 Msg.Say("badidea");
69 EClass.pc.Pick(t, msg: false);
70 return;
71 }
72 if (fromBank)
73 {
75 }
76 else if (!EClass.pc.TryPay(t.c_bill))
77 {
78 return;
79 }
80 if (flag2)
81 {
82 EClass.player.debt -= t.c_bill;
83 if (EClass.player.debt < 0)
84 {
85 EClass.player.debt = 0;
86 }
87 questDebt.paid = true;
88 questDebt.UpdateJournal();
89 }
90 else if (flag)
91 {
92 EClass.player.stats.taxBillsPaid += t.c_bill;
94 if (EClass.player.taxBills < 0)
95 {
96 EClass.player.taxBills = 0;
97 }
98 int num = t.GetInt(35) / 1000;
99 if (num > 0)
100 {
101 Thing thing = ThingGen.Create("money2", "copper").SetNum(num);
102 Thing p = ThingGen.CreateParcel("parcel_mysiliaGift", thing);
103 Msg.Say("getSalary", thing);
105 }
106 }
107 else
108 {
109 EClass.player.unpaidBill -= t.c_bill;
110 }
111 Msg.Say("payBill", t);
112 t.Destroy();
113 }
114
115 public override void _OnProcess(Thing t)
116 {
117 switch (mode)
118 {
119 case Mode.Tax:
120 PayBill(t);
121 break;
122 case Mode.Bank:
123 SE.Pay();
124 Msg.Say("depositMoney", t, owner);
125 owner.AddThing(t);
126 break;
127 case Mode.Crop:
128 {
129 Msg.Say("farm_chest", t, Lang._weight(t.SelfWeight * t.Num));
130 QuestHarvest questHarvest = EClass.game.quests.Get<QuestHarvest>();
131 if (questHarvest != null)
132 {
133 questHarvest.weightDelivered += t.SelfWeight * t.Num;
134 }
135 SE.Pick();
136 t.Destroy();
137 break;
138 }
139 }
140 }
141}
CurrencyType
Definition: CurrencyType.cs:2
int GetInt(int id, int? defaultInt=null)
Definition: BaseCard.cs:25
bool GetBool(int id)
Definition: BaseCard.cs:15
Thing container_deposit
Definition: CardManager.cs:58
Definition: Card.cs:11
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3182
Thing SetNum(int a)
Definition: Card.cs:3579
void ModCurrency(int a, string id="money")
Definition: Card.cs:4045
bool TryPay(int a, string id="money")
Definition: Card.cs:4009
void Destroy()
Definition: Card.cs:5198
int c_bill
Definition: Card.cs:1309
int Num
Definition: Card.cs:161
SourceCategory.Row category
Definition: Card.cs:2089
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4392
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static World world
Definition: EClass.cs:41
static Player player
Definition: EClass.cs:13
static Chara pc
Definition: EClass.cs:15
CardManager cards
Definition: Game.cs:156
QuestManager quests
Definition: Game.cs:183
override void _OnProcess(Thing t)
override bool ShouldShowGuide(Thing t)
override string langTransfer
InvOwnerDeliver(Card owner=null, Card container=null, CurrencyType _currency=CurrencyType.Money)
override bool ShowButtonDeliver
override bool SingleTarget
static void PayBill(Thing t, bool fromBank=false)
override ProcessType processType
Card owner
Definition: InvOwner.cs:533
Definition: Lang.cs:6
static string _weight(int a, int b, bool showUnit=true, int unitSize=0)
Definition: Lang.cs:174
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
int debt
Definition: Player.cs:1014
int taxBills
Definition: Player.cs:975
bool IsValidBill(Thing t)
Definition: QuestDebt.cs:52
Quest Get(string id)
void UpdateJournal()
Definition: Quest.cs:690
static Thing CreateParcel(string idLang=null, params Thing[] things)
Definition: ThingGen.cs:42
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
override int SelfWeight
Definition: Thing.cs:64
void SendPackage(Thing p)
Definition: World.cs:68