Elin Modding Docs Doc
Loading...
Searching...
No Matches
Faction.2.cs
1using System;
2using System.Collections.Generic;
3using Newtonsoft.Json;
4using UnityEngine;
5
6// Token: 0x02000067 RID: 103
7public class Faction : EClass
8{
9 // Token: 0x17000080 RID: 128
10 // (get) Token: 0x060002A1 RID: 673 RVA: 0x000143AD File Offset: 0x000125AD
11 public string Name
12 {
13 get
14 {
15 return this.name;
16 }
17 }
18
19 // Token: 0x17000081 RID: 129
20 // (get) Token: 0x060002A2 RID: 674 RVA: 0x000143B8 File Offset: 0x000125B8
21 public SourceFaction.Row source
22 {
23 get
24 {
25 SourceFaction.Row result;
26 if ((result = this._source) == null)
27 {
28 result = (this._source = EClass.sources.factions.map[this.id]);
29 }
30 return result;
31 }
32 }
33
34 // Token: 0x17000082 RID: 130
35 // (get) Token: 0x060002A3 RID: 675 RVA: 0x000143F2 File Offset: 0x000125F2
36 public virtual string TextType
37 {
38 get
39 {
40 return "sub_faction".lang();
41 }
42 }
43
44 // Token: 0x060002A4 RID: 676 RVA: 0x000143FE File Offset: 0x000125FE
45 public static Faction Create(SourceFaction.Row r)
46 {
47 Faction faction = ClassCache.Create<Faction>(r.type, "Elin");
48 faction.id = r.id;
49 faction.Init();
50 return faction;
51 }
52
53 // Token: 0x060002A5 RID: 677 RVA: 0x00014424 File Offset: 0x00012624
54 public void Init()
55 {
56 EClass.game.factions.AssignUID(this);
57 this.relation.faction = this;
58 this.relation.affinity = this.source.relation;
59 this.name = this.source.GetText("name", false);
60 }
61
62 // Token: 0x060002A6 RID: 678 RVA: 0x0001447A File Offset: 0x0001267A
63 public void OnLoad()
64 {
65 this.relation.faction = this;
66 }
67
68 // Token: 0x060002A7 RID: 679 RVA: 0x00014488 File Offset: 0x00012688
69 public float GetHappiness()
70 {
71 return 50f;
72 }
73
74 // Token: 0x060002A8 RID: 680 RVA: 0x0001448F File Offset: 0x0001268F
75 public Sprite GetSprite()
76 {
77 return ResourceCache.Load<Sprite>("Media/Graphics/Image/Faction/" + this.source.id);
78 }
79
80 // Token: 0x060002A9 RID: 681 RVA: 0x000144AB File Offset: 0x000126AB
81 public int CountTax()
82 {
83 return (int)((float)this.CountWealth() * 0.1f);
84 }
85
86 // Token: 0x060002AA RID: 682 RVA: 0x000144BC File Offset: 0x000126BC
87 public List<FactionBranch> GetChildren()
88 {
89 List<FactionBranch> list = new List<FactionBranch>();
90 foreach (Spatial spatial in EClass.game.spatials.map.Values)
91 {
92 if (spatial.mainFaction == this)
93 {
94 list.Add((spatial as Zone).branch);
95 }
96 }
97 return list;
98 }
99
100 // Token: 0x060002AB RID: 683 RVA: 0x00014538 File Offset: 0x00012738
101 public int CountWealth()
102 {
103 if (EClass._zone.IsPCFaction)
104 {
105 EClass._zone.branch.resources.Refresh();
106 }
107 int num = 0;
108 foreach (FactionBranch factionBranch in this.GetChildren())
109 {
110 num += factionBranch.Worth;
111 }
112 return num;
113 }
114
115 // Token: 0x060002AC RID: 684 RVA: 0x000145B0 File Offset: 0x000127B0
116 public int CountTerritories()
117 {
118 int num = 0;
119 using (Dictionary<int, Spatial>.ValueCollection.Enumerator enumerator = EClass.game.spatials.map.Values.GetEnumerator())
120 {
121 while (enumerator.MoveNext())
122 {
123 if (enumerator.Current.mainFaction == this)
124 {
125 num++;
126 }
127 }
128 }
129 return num;
130 }
131
132 // Token: 0x060002AD RID: 685 RVA: 0x00014618 File Offset: 0x00012818
133 public int CountMembers()
134 {
135 int num = 0;
136 using (Dictionary<int, Chara>.ValueCollection.Enumerator enumerator = EClass.game.cards.globalCharas.Values.GetEnumerator())
137 {
138 while (enumerator.MoveNext())
139 {
140 if (enumerator.Current.Chara.faction == this)
141 {
142 num++;
143 }
144 }
145 }
146 return num;
147 }
148
149 // Token: 0x060002AE RID: 686 RVA: 0x00014688 File Offset: 0x00012888
150 public Hostility GetHostility()
151 {
152 if (this == EClass.Home || this.relation.affinity >= 200)
153 {
154 return Hostility.Ally;
155 }
156 if (this.relation.affinity >= 100)
157 {
158 return Hostility.Friend;
159 }
160 if (this.relation.affinity <= -100)
161 {
162 return Hostility.Enemy;
163 }
164 return Hostility.Neutral;
165 }
166
167 // Token: 0x060002AF RID: 687 RVA: 0x000146D4 File Offset: 0x000128D4
168 public void ModRelation(int a)
169 {
170 this.relation.affinity += a;
171 }
172
173 // Token: 0x060002B0 RID: 688 RVA: 0x000146EC File Offset: 0x000128EC
174 public bool HasMember(string id, bool includeReserve = true)
175 {
176 foreach (Chara chara in EClass.game.cards.globalCharas.Values)
177 {
178 if (chara.id == id && chara.IsHomeMember())
179 {
180 return true;
181 }
182 }
183 if (includeReserve)
184 {
185 using (List<HireInfo>.Enumerator enumerator2 = this.listReserve.GetEnumerator())
186 {
187 while (enumerator2.MoveNext())
188 {
189 if (enumerator2.Current.chara.id == id)
190 {
191 return true;
192 }
193 }
194 }
195 }
196 return false;
197 }
198
199 // Token: 0x060002B1 RID: 689 RVA: 0x000147B8 File Offset: 0x000129B8
200 public void AddContribution(int a)
201 {
202 if (a == 0 || this.relation.type != FactionRelation.RelationType.Member)
203 {
204 return;
205 }
206 this.relation.exp += a;
207 Msg.Say("contribute", a.ToString() ?? "", this.Name, null, null);
208 }
209
210 // Token: 0x060002B2 RID: 690 RVA: 0x00014810 File Offset: 0x00012A10
211 public void AddReserve(Chara c)
212 {
213 if (c.memberType == FactionMemberType.Livestock)
214 {
215 c.SetInt(36, EClass.world.date.GetRaw(0) + 14400);
216 }
217 if (c.IsHomeMember())
218 {
219 c.homeBranch.RemoveMemeber(c);
220 }
221 if (c.currentZone != null)
222 {
223 c.currentZone.RemoveCard(c);
224 }
225 if (EClass.Branch.uidMaid == c.uid)
226 {
227 EClass.Branch.uidMaid = 0;
228 }
229 HireInfo item = new HireInfo
230 {
231 chara = c,
232 isNew = true
233 };
234 this.listReserve.Add(item);
235 }
236
237 // Token: 0x060002B3 RID: 691 RVA: 0x000148AC File Offset: 0x00012AAC
238 public void RemoveReserve(Chara c)
239 {
240 this.listReserve.ForeachReverse(delegate(HireInfo i)
241 {
242 if (i.chara == c || i.chara.uid == c.uid)
243 {
244 this.listReserve.Remove(i);
245 }
246 });
247 }
248
249 // Token: 0x060002B4 RID: 692 RVA: 0x000148E4 File Offset: 0x00012AE4
250 public void OnAdvanceDay()
251 {
252 foreach (FactionBranch factionBranch in EClass.pc.faction.GetChildren())
253 {
254 factionBranch.OnAdvanceDay();
255 }
256 }
257
258 // Token: 0x060002B5 RID: 693 RVA: 0x00014940 File Offset: 0x00012B40
259 public void OnAdvanceMonth()
260 {
261 if (this.GetChildren().Count == 0)
262 {
263 return;
264 }
265 int num = 0;
266 num += this.GetResidentTax();
267 num += this.GetRankIncome();
268 num += this.GetFactionSalary();
269 if (num > 0)
270 {
271 Thing thing = ThingGen.Create("money", -1, -1).SetNum(num);
272 Thing p = ThingGen.CreateParcel("parcel_salary", new Thing[]
273 {
274 thing
275 });
276 EClass.world.SendPackage(p);
277 }
278 num = this.GetTotalTax(true);
279 Thing thing2 = ThingGen.CreateBill(num, true);
280 thing2.SetInt(35, EClass.player.extraTax);
281 Msg.Say("getBill", Lang._currency(num, "money"), null, null, null);
282 this.TryPayBill(thing2);
283 Msg.Say("bills", EClass.player.taxBills.ToString() ?? "", null, null, null);
284 if (EClass.player.taxBills >= 4)
285 {
286 EClass.player.ModKarma(-50);
287 }
288 }
289
290 // Token: 0x060002B6 RID: 694 RVA: 0x00014A30 File Offset: 0x00012C30
291 public void TryPayBill(Thing bill)
292 {
293 if (this.IsGlobalPolicyActive(2705) && EClass.game.cards.container_deposit.GetCurrency("money") > bill.c_bill)
294 {
295 InvOwnerDeliver.PayBill(bill, true);
296 return;
297 }
298 EClass.world.SendPackage(bill);
299 }
300
301 // Token: 0x060002B7 RID: 695 RVA: 0x00014A80 File Offset: 0x00012C80
302 public FactionBranch FindBranch(Chara c)
303 {
304 foreach (FactionBranch factionBranch in EClass.pc.faction.GetChildren())
305 {
306 if (factionBranch.members.Contains(c))
307 {
308 return factionBranch;
309 }
310 }
311 return null;
312 }
313
314 // Token: 0x060002B8 RID: 696 RVA: 0x00014AEC File Offset: 0x00012CEC
315 public void AddGlobalPolicy(int id)
316 {
317 this.globalPolicies.Add(id);
318 }
319
320 // Token: 0x060002B9 RID: 697 RVA: 0x00014AFC File Offset: 0x00012CFC
321 public bool IsGlobalPolicyActive(int id)
322 {
323 bool result = false;
324 using (List<FactionBranch>.Enumerator enumerator = EClass.pc.faction.GetChildren().GetEnumerator())
325 {
326 while (enumerator.MoveNext())
327 {
328 if (enumerator.Current.policies.IsActive(id, -1))
329 {
330 result = true;
331 }
332 }
333 }
334 return result;
335 }
336
337 // Token: 0x060002BA RID: 698 RVA: 0x00014B64 File Offset: 0x00012D64
338 public void SetGlobalPolicyActive(int id, bool active)
339 {
340 foreach (FactionBranch factionBranch in EClass.pc.faction.GetChildren())
341 {
342 factionBranch.policies.SetActive(id, active);
343 }
344 }
345
346 // Token: 0x060002BB RID: 699 RVA: 0x00014BC4 File Offset: 0x00012DC4
347 public int GetResidentTax()
348 {
349 int num = 0;
350 foreach (FactionBranch factionBranch in EClass.pc.faction.GetChildren())
351 {
352 num += factionBranch.GetResidentTax();
353 }
354 if (num > 0)
355 {
356 Msg.Say("getResidentTax", Lang._currency(num, "money"), null, null, null);
357 }
358 return num;
359 }
360
361 // Token: 0x060002BC RID: 700 RVA: 0x00014C44 File Offset: 0x00012E44
362 public int GetRankIncome()
363 {
364 int num = 0;
365 foreach (FactionBranch factionBranch in EClass.pc.faction.GetChildren())
366 {
367 num += EClass.game.spatials.ranks.GetIncome(factionBranch.owner);
368 }
369 if (num > 0)
370 {
371 Msg.Say("getRankIncome", Lang._currency(num, "money"), null, null, null);
372 }
373 return num;
374 }
375
376 // Token: 0x060002BD RID: 701 RVA: 0x00014CD8 File Offset: 0x00012ED8
377 public int GetFactionSalary()
378 {
379 int num = 0;
380 foreach (Faction faction in EClass.game.factions.dictAll.Values)
381 {
382 num += faction.relation.GetSalary();
383 }
384 if (num > 0)
385 {
386 Msg.Say("getFactionSalary", Lang._currency(num, "money"), null, null, null);
387 }
388 return num;
389 }
390
391 // Token: 0x060002BE RID: 702 RVA: 0x00014D60 File Offset: 0x00012F60
392 public int GetTotalTax(bool evasion)
393 {
394 return this.GetBaseTax(evasion) + this.GetFameTax(evasion) + EClass.player.extraTax;
395 }
396
397 // Token: 0x060002BF RID: 703 RVA: 0x00014D7C File Offset: 0x00012F7C
398 public int GetBaseTax(bool evasion)
399 {
400 int a = EClass.world.date.year - EClass.game.Prologue.year;
401 int v = 500 + Mathf.Min(a, 10) * 500;
402 return this.EvadeTax(v, evasion);
403 }
404
405 // Token: 0x060002C0 RID: 704 RVA: 0x00014DC8 File Offset: 0x00012FC8
406 public int GetFameTax(bool evasion)
407 {
408 int v = EClass.curve(EClass.player.fame * 2, 10000, 2000, 80);
409 return this.EvadeTax(v, evasion);
410 }
411
412 // Token: 0x060002C1 RID: 705 RVA: 0x00014DFC File Offset: 0x00012FFC
413 public int EvadeTax(int v, bool evasion)
414 {
415 if (!evasion)
416 {
417 return v;
418 }
419 int num = 0;
420 foreach (FactionBranch factionBranch in EClass.pc.faction.GetChildren())
421 {
422 num += factionBranch.Evalue(2119);
423 }
424 return (int)((float)(v * 100) / (100f + Mathf.Sqrt((float)(num * 5))));
425 }
426
427 // Token: 0x060002C2 RID: 706 RVA: 0x00014E7C File Offset: 0x0001307C
428 public void SetTaxTooltip(UINote n)
429 {
430 n.AddHeader("tax", null);
431 n.AddTopic("tax_base", Lang._currency(this.GetBaseTax(true), true, 14) + " (" + Lang._currency(this.GetBaseTax(false), false, 14) + ")");
432 n.AddTopic("tax_fame", Lang._currency(this.GetFameTax(true), true, 14) + " (" + Lang._currency(this.GetFameTax(false), false, 14) + ")");
433 n.AddTopic("tax_extra", Lang._currency(EClass.player.extraTax, true, 14));
434 }
435
436 // Token: 0x060002C3 RID: 707 RVA: 0x00014F28 File Offset: 0x00013128
437 public int CountTaxFreeLand()
438 {
439 int num = 0;
440 using (List<FactionBranch>.Enumerator enumerator = EClass.pc.faction.GetChildren().GetEnumerator())
441 {
442 while (enumerator.MoveNext())
443 {
444 if (enumerator.Current.policies.IsActive(2514, -1))
445 {
446 num++;
447 }
448 }
449 }
450 return num;
451 }
452
453 // Token: 0x04000530 RID: 1328
454 [JsonProperty]
455 public FactionRelation relation = new FactionRelation();
456
457 // Token: 0x04000531 RID: 1329
458 [JsonProperty]
459 public int maxReserve = 3;
460
461 // Token: 0x04000532 RID: 1330
462 [JsonProperty]
463 public string id;
464
465 // Token: 0x04000533 RID: 1331
466 [JsonProperty]
467 public string uid;
468
469 // Token: 0x04000534 RID: 1332
470 [JsonProperty]
471 public string name;
472
473 // Token: 0x04000535 RID: 1333
474 [JsonProperty]
475 public List<HireInfo> listReserve = new List<HireInfo>();
476
477 // Token: 0x04000536 RID: 1334
478 [JsonProperty]
479 public ElementContainerZone elements = new ElementContainerZone();
480
481 // Token: 0x04000537 RID: 1335
482 [JsonProperty]
483 public HashSet<int> globalPolicies = new HashSet<int>();
484
485 // Token: 0x04000538 RID: 1336
486 public ElementContainerFaction charaElements = new ElementContainerFaction();
487
488 // Token: 0x04000539 RID: 1337
489 public SourceFaction.Row _source;
490}
Definition Chara.cs:12
Definition Msg.cs:7
Definition Thing.cs:10
Definition Zone.cs:14