Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
FACTION.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using Newtonsoft.Json;
3using UnityEngine;
4
5public class FACTION
6{
7 public const int bfBeach = 3604;
8
9 public const int bfCave = 3500;
10
11 public const int bfPlain = 3600;
12
13 public const int bfForest = 3601;
14
15 public const int bfSnow = 3602;
16
17 public const int bfHill = 3603;
18
19 public const int bfFertile = 3700;
20
21 public const int bfSea = 3605;
22
23 public const int fRation = 2207;
24
25 public const int bfGeyser = 3701;
26
27 public const int fAttraction = 2206;
28
29 public const int fEducation = 2116;
30
31 public const int fFood = 2204;
32
33 public const int fMoral = 2203;
34
35 public const int fPromo = 2202;
36
37 public const int fElec = 2201;
38
39 public const int fSoil = 2200;
40
41 public const int fHeirloom = 2120;
42
43 public const int fLoyal = 2117;
44
45 public const int fConstruction = 2003;
46
47 public const int bfRuin = 3702;
48
49 public const int fTaxEvasion = 2119;
50
51 public const int fLuck = 2118;
52
53 public const int fAdmin = 2115;
54
55 public const int fSafety = 2205;
56
57 public const int bfTranquil = 3703;
58
59 public const int bfFish = 3706;
60
61 public const int bfHunt = 3705;
62
63 public const int actBuildInspect = 4006;
64
65 public const int actBuildRecipe = 4005;
66
67 public const int actBuildCollect = 4004;
68
69 public const int actBuildAnywhere = 4003;
70
71 public const int actBuildTerrain = 4002;
72
73 public const int actBuildMine = 4001;
74
75 public const int bfVolcano = 3704;
76
77 public const int bfStart = 3900;
78
79 public const int bfChitin = 3805;
80
81 public const int bfIce = 3804;
82
83 public const int bfGum = 3803;
84
85 public const int actBuildCut = 4000;
86
87 public const int bfMushroom = 3801;
88
89 public const int bfSilica = 3802;
90
91 public const int bfFreshAir = 3708;
92
93 public const int bfBasin = 3709;
94
95 public const int bfBreed = 3710;
96
97 public const int bfLandmark1 = 3780;
98
99 public const int bfMonster = 3707;
100
101 public const int bfLandmark3 = 3782;
102
103 public const int bfLandmark4 = 3783;
104
105 public const int bfLandmark5 = 3784;
106
107 public const int bfCoal = 3800;
108
109 public const int bfLandmark2 = 3781;
110
111 public static readonly int[] IDS = new int[52]
112 {
113 3604, 3500, 3600, 3601, 3602, 3603, 3700, 3605, 2207, 3701,
114 2206, 2116, 2204, 2203, 2202, 2201, 2200, 2120, 2117, 2003,
115 3702, 2119, 2118, 2115, 2205, 3703, 3706, 3705, 4006, 4005,
116 4004, 4003, 4002, 4001, 3704, 3900, 3805, 3804, 3803, 4000,
117 3801, 3802, 3708, 3709, 3710, 3780, 3707, 3782, 3783, 3784,
118 3800, 3781
119 };
120}
121public class Faction : EClass
122{
123 [JsonProperty]
125
126 [JsonProperty]
127 public string id;
128
129 [JsonProperty]
130 public string uid;
131
132 [JsonProperty]
133 public string name;
134
135 [JsonProperty]
136 public List<HireInfo> listReserve = new List<HireInfo>();
137
138 [JsonProperty]
140
141 [JsonProperty]
142 public HashSet<int> globalPolicies = new HashSet<int>();
143
145
147
148 public string Name => name;
149
151
152 public virtual string TextType => "sub_faction".lang();
153
155 {
156 Faction faction = ClassCache.Create<Faction>(r.type, "Elin");
157 faction.id = r.id;
158 faction.Init();
159 return faction;
160 }
161
162 public void Init()
163 {
165 relation.faction = this;
166 relation.affinity = source.relation;
167 name = source.GetText();
168 }
169
170 public void OnLoad()
171 {
172 relation.faction = this;
173 }
174
175 public float GetHappiness()
176 {
177 return 50f;
178 }
179
180 public Sprite GetSprite()
181 {
182 return ResourceCache.Load<Sprite>("Media/Graphics/Image/Faction/" + source.id);
183 }
184
185 public int CountTax()
186 {
187 return (int)((float)CountWealth() * 0.1f);
188 }
189
190 public int GetMaxReserve()
191 {
192 int num = 2;
193 foreach (FactionBranch child in GetChildren())
194 {
195 num += child.lv;
196 }
197 return num;
198 }
199
200 public List<FactionBranch> GetChildren()
201 {
202 List<FactionBranch> list = new List<FactionBranch>();
203 foreach (Spatial value in EClass.game.spatials.map.Values)
204 {
205 if (value.mainFaction == this)
206 {
207 list.Add((value as Zone).branch);
208 }
209 }
210 return list;
211 }
212
213 public int CountWealth()
214 {
216 {
218 }
219 int num = 0;
220 foreach (FactionBranch child in GetChildren())
221 {
222 num += child.Worth;
223 }
224 return num;
225 }
226
227 public int CountTerritories()
228 {
229 int num = 0;
230 foreach (Spatial value in EClass.game.spatials.map.Values)
231 {
232 if (value.mainFaction == this)
233 {
234 num++;
235 }
236 }
237 return num;
238 }
239
240 public int CountMembers()
241 {
242 int num = 0;
243 foreach (Chara value in EClass.game.cards.globalCharas.Values)
244 {
245 if (value.Chara.faction == this)
246 {
247 num++;
248 }
249 }
250 return num;
251 }
252
254 {
255 if (this == EClass.Home || relation.affinity >= 200)
256 {
257 return Hostility.Ally;
258 }
259 if (relation.affinity >= 100)
260 {
261 return Hostility.Friend;
262 }
263 if (relation.affinity <= -100)
264 {
265 return Hostility.Enemy;
266 }
267 return Hostility.Neutral;
268 }
269
270 public void ModRelation(int a)
271 {
272 relation.affinity += a;
273 }
274
275 public bool HasMember(string id, bool includeReserve = true)
276 {
277 foreach (Chara value in EClass.game.cards.globalCharas.Values)
278 {
279 if (value.id == id && value.IsHomeMember())
280 {
281 return true;
282 }
283 }
284 if (includeReserve)
285 {
286 foreach (HireInfo item in listReserve)
287 {
288 if (item.chara.id == id)
289 {
290 return true;
291 }
292 }
293 }
294 return false;
295 }
296
297 public bool IsWearingPanty(Chara c)
298 {
299 if ((!c.IsUnique || c.bio.gender != 2) && (c.race.IsHuman || c.race.IsFairy) && !(c.trait is TraitMerchant))
300 {
301 return true;
302 }
303 if (IsGlobalPolicyActive(2712))
304 {
305 foreach (Chara value in EClass.game.cards.globalCharas.Values)
306 {
307 if (value.id == c.id && value.IsHomeMember())
308 {
309 return true;
310 }
311 }
312 }
313 return false;
314 }
315
316 public void AddContribution(int a)
317 {
318 if (a != 0 && relation.type == FactionRelation.RelationType.Member)
319 {
320 relation.exp += a;
321 Msg.Say("contribute", a.ToString() ?? "", Name);
322 }
323 }
324
325 public void AddReserve(Chara c)
326 {
327 if (c.memberType == FactionMemberType.Livestock)
328 {
329 c.SetInt(36, EClass.world.date.GetRaw() + 14400);
330 }
331 if (c.IsHomeMember())
332 {
334 }
335 if (c.currentZone != null)
336 {
338 }
339 if (EClass.Branch.uidMaid == c.uid)
340 {
341 EClass.Branch.uidMaid = 0;
342 }
344 {
345 chara = c,
346 isNew = true
347 };
348 listReserve.Add(item);
349 }
350
351 public void RemoveReserve(Chara c)
352 {
353 listReserve.ForeachReverse(delegate(HireInfo i)
354 {
355 if (i.chara == c || i.chara.uid == c.uid)
356 {
357 listReserve.Remove(i);
358 }
359 });
360 }
361
362 public void OnAdvanceDay()
363 {
364 foreach (FactionBranch child in GetChildren())
365 {
366 child.OnAdvanceDay();
367 }
368 }
369
370 public void OnAdvanceMonth()
371 {
372 if (GetChildren().Count == 0)
373 {
374 return;
375 }
376 int num = 0;
377 num += GetResidentTax();
378 num += GetRankIncome();
379 num += GetFactionSalary();
380 if (num > 0)
381 {
382 Thing container_deposit = EClass.game.cards.container_deposit;
383 if (EClass.pc.homeBranch.policies.IsActive(2711) && (container_deposit.GetCurrency() > 0 || !container_deposit.things.IsFull()))
384 {
385 container_deposit.ModCurrency(num);
386 Msg.Say("bankIncome", Lang._currency(num, "money"));
387 }
388 else
389 {
390 Thing thing = ThingGen.Create("money").SetNum(num);
391 Thing p = ThingGen.CreateParcel("parcel_salary", thing);
393 }
394 }
395 num = GetTotalTax(evasion: true);
396 Thing thing2 = ThingGen.CreateBill(num, tax: true);
397 thing2.SetInt(35, EClass.player.extraTax);
398 Msg.Say("getBill", Lang._currency(num, "money"));
399 TryPayBill(thing2);
400 Msg.Say("bills", EClass.player.taxBills.ToString() ?? "");
402 {
404 }
405 }
406
407 public void TryPayBill(Thing bill)
408 {
410 {
411 InvOwnerDeliver.PayBill(bill, fromBank: true);
412 }
413 else
414 {
416 }
417 }
418
420 {
421 foreach (FactionBranch child in GetChildren())
422 {
423 if (child.members.Contains(c))
424 {
425 return child;
426 }
427 }
428 return null;
429 }
430
431 public void AddGlobalPolicy(int id)
432 {
433 globalPolicies.Add(id);
434 }
435
436 public bool IsGlobalPolicyActive(int id)
437 {
438 bool result = false;
439 foreach (FactionBranch child in GetChildren())
440 {
441 if (child.policies.IsActive(id))
442 {
443 result = true;
444 }
445 }
446 return result;
447 }
448
449 public void SetGlobalPolicyActive(int id, bool active)
450 {
451 foreach (FactionBranch child in GetChildren())
452 {
453 child.policies.SetActive(id, active);
454 }
455 }
456
457 public int GetResidentTax()
458 {
459 int num = 0;
460 foreach (FactionBranch child in GetChildren())
461 {
462 num += child.GetResidentTax();
463 }
464 if (num > 0)
465 {
466 Msg.Say("getResidentTax", Lang._currency(num, "money"));
467 }
468 return num;
469 }
470
471 public int GetRankIncome()
472 {
473 int num = 0;
474 foreach (FactionBranch child in GetChildren())
475 {
476 num += EClass.game.spatials.ranks.GetIncome(child.owner);
477 }
478 if (num > 0)
479 {
480 Msg.Say("getRankIncome", Lang._currency(num, "money"));
481 }
482 return num;
483 }
484
485 public int GetFactionSalary()
486 {
487 int num = 0;
488 foreach (Faction value in EClass.game.factions.dictAll.Values)
489 {
490 num += value.relation.GetSalary();
491 }
492 if (num > 0)
493 {
494 Msg.Say("getFactionSalary", Lang._currency(num, "money"));
495 }
496 return num;
497 }
498
499 public int GetTotalTax(bool evasion)
500 {
501 return GetBaseTax(evasion) + GetFameTax(evasion) + EClass.player.extraTax;
502 }
503
504 public int GetBaseTax(bool evasion)
505 {
506 int a = EClass.world.date.year - EClass.game.Prologue.year;
507 int v = 500 + Mathf.Min(a, 10) * 500;
508 return EvadeTax(v, evasion);
509 }
510
511 public int GetFameTax(bool evasion)
512 {
513 int v = EClass.curve(EClass.player.fame * 2, 10000, 2000, 80);
514 v = EvadeTax(v, evasion);
515 if (v < 0)
516 {
517 v = 50000;
518 }
519 return v;
520 }
521
522 public int EvadeTax(int v, bool evasion)
523 {
524 if (!evasion)
525 {
526 return v;
527 }
528 int num = 0;
529 foreach (FactionBranch child in GetChildren())
530 {
531 num += child.Evalue(2119);
532 }
533 return (int)(long)((float)(v * 100) / (100f + Mathf.Sqrt(num * 5)));
534 }
535
536 public void SetTaxTooltip(UINote n)
537 {
538 n.AddHeader("tax");
539 n.AddTopic("tax_base", Lang._currency(GetBaseTax(evasion: true), showUnit: true) + " (" + Lang._currency(GetBaseTax(evasion: false)) + ")");
540 n.AddTopic("tax_fame", Lang._currency(GetFameTax(evasion: true), showUnit: true) + " (" + Lang._currency(GetFameTax(evasion: false)) + ")");
541 n.AddTopic("tax_extra", Lang._currency(EClass.player.extraTax, showUnit: true));
542 }
543
544 public int CountTaxFreeLand()
545 {
546 int num = 0;
547 foreach (FactionBranch child in GetChildren())
548 {
549 if (child.policies.IsActive(2514))
550 {
551 num++;
552 }
553 }
554 return num;
555 }
556}
FactionMemberType
Hostility
Definition: Hostility.cs:2
void SetInt(int id, int value=0)
Definition: BaseCard.cs:39
int gender
Definition: Biography.cs:29
GlobalCharaList globalCharas
Definition: CardManager.cs:46
Thing container_deposit
Definition: CardManager.cs:58
virtual Chara Chara
Definition: Card.cs:1946
string id
Definition: Card.cs:31
bool IsUnique
Definition: Card.cs:1967
Biography bio
Definition: Card.cs:40
Thing SetNum(int a)
Definition: Card.cs:3242
int GetCurrency(string id="money")
Definition: Card.cs:3652
int uid
Definition: Card.cs:118
void ModCurrency(int a, string id="money")
Definition: Card.cs:3638
ThingContainer things
Definition: Card.cs:34
Definition: Chara.cs:10
new TraitChara trait
Definition: Chara.cs:488
Faction faction
Definition: Chara.cs:412
Zone currentZone
Definition: Chara.cs:240
FactionMemberType memberType
Definition: Chara.cs:46
bool IsHomeMember()
Definition: Chara.cs:5942
FactionBranch homeBranch
Definition: Chara.cs:889
SourceRace.Row race
Definition: Chara.cs:449
bool godMode
Definition: CoreDebug.cs:172
int GetRaw(int offsetHours=0)
Definition: Date.cs:322
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Faction Home
Definition: EClass.cs:26
static int curve(int a, int start, int step, int rate=75)
Definition: EClass.cs:55
static Zone _zone
Definition: EClass.cs:20
static World world
Definition: EClass.cs:40
static SourceManager sources
Definition: EClass.cs:42
static FactionBranch Branch
Definition: EClass.cs:22
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
const int fHeirloom
Definition: FACTION.cs:41
const int bfLandmark1
Definition: FACTION.cs:97
const int bfHill
Definition: FACTION.cs:17
const int bfStart
Definition: FACTION.cs:77
const int fSafety
Definition: FACTION.cs:55
const int bfLandmark4
Definition: FACTION.cs:103
const int bfTranquil
Definition: FACTION.cs:57
const int bfChitin
Definition: FACTION.cs:79
const int fLoyal
Definition: FACTION.cs:43
const int bfBeach
Definition: FACTION.cs:7
const int bfGum
Definition: FACTION.cs:83
const int fConstruction
Definition: FACTION.cs:45
const int bfMonster
Definition: FACTION.cs:99
const int actBuildRecipe
Definition: FACTION.cs:65
const int bfLandmark2
Definition: FACTION.cs:109
const int fLuck
Definition: FACTION.cs:51
const int bfRuin
Definition: FACTION.cs:47
const int fFood
Definition: FACTION.cs:31
const int bfSea
Definition: FACTION.cs:21
const int fMoral
Definition: FACTION.cs:33
const int fElec
Definition: FACTION.cs:37
const int bfFish
Definition: FACTION.cs:59
const int bfVolcano
Definition: FACTION.cs:75
const int actBuildInspect
Definition: FACTION.cs:63
const int actBuildCollect
Definition: FACTION.cs:67
const int bfSilica
Definition: FACTION.cs:89
const int bfCoal
Definition: FACTION.cs:107
const int bfBasin
Definition: FACTION.cs:93
const int bfLandmark5
Definition: FACTION.cs:105
const int fSoil
Definition: FACTION.cs:39
const int fRation
Definition: FACTION.cs:23
const int bfHunt
Definition: FACTION.cs:61
const int fTaxEvasion
Definition: FACTION.cs:49
const int bfFertile
Definition: FACTION.cs:19
const int fEducation
Definition: FACTION.cs:29
const int fPromo
Definition: FACTION.cs:35
const int actBuildCut
Definition: FACTION.cs:85
const int bfCave
Definition: FACTION.cs:9
const int bfSnow
Definition: FACTION.cs:15
const int bfMushroom
Definition: FACTION.cs:87
const int actBuildAnywhere
Definition: FACTION.cs:69
const int bfFreshAir
Definition: FACTION.cs:91
const int fAttraction
Definition: FACTION.cs:27
const int bfPlain
Definition: FACTION.cs:11
const int bfForest
Definition: FACTION.cs:13
const int actBuildTerrain
Definition: FACTION.cs:71
const int bfGeyser
Definition: FACTION.cs:25
const int bfBreed
Definition: FACTION.cs:95
const int bfIce
Definition: FACTION.cs:81
const int bfLandmark3
Definition: FACTION.cs:101
static readonly int[] IDS
Definition: FACTION.cs:111
const int fAdmin
Definition: FACTION.cs:53
const int actBuildMine
Definition: FACTION.cs:73
int Evalue(int ele)
List< Chara > members
void RemoveMemeber(Chara c)
void OnAdvanceDay()
PolicyManager policies
HomeResourceManager resources
void AssignUID(Faction s)
Dictionary< string, Faction > dictAll
RelationType type
int GetFactionSalary()
Definition: FACTION.cs:485
Sprite GetSprite()
Definition: FACTION.cs:180
List< FactionBranch > GetChildren()
Definition: FACTION.cs:200
void AddGlobalPolicy(int id)
Definition: FACTION.cs:431
FactionBranch FindBranch(Chara c)
Definition: FACTION.cs:419
virtual string TextType
Definition: FACTION.cs:152
ElementContainerFaction charaElements
Definition: FACTION.cs:144
int CountWealth()
Definition: FACTION.cs:213
void Init()
Definition: FACTION.cs:162
void SetTaxTooltip(UINote n)
Definition: FACTION.cs:536
bool IsGlobalPolicyActive(int id)
Definition: FACTION.cs:436
int GetTotalTax(bool evasion)
Definition: FACTION.cs:499
bool IsWearingPanty(Chara c)
Definition: FACTION.cs:297
void TryPayBill(Thing bill)
Definition: FACTION.cs:407
string uid
Definition: FACTION.cs:130
int GetFameTax(bool evasion)
Definition: FACTION.cs:511
Hostility GetHostility()
Definition: FACTION.cs:253
int CountTaxFreeLand()
Definition: FACTION.cs:544
ElementContainerZone elements
Definition: FACTION.cs:139
string name
Definition: FACTION.cs:133
bool HasMember(string id, bool includeReserve=true)
Definition: FACTION.cs:275
int CountMembers()
Definition: FACTION.cs:240
HashSet< int > globalPolicies
Definition: FACTION.cs:142
void AddReserve(Chara c)
Definition: FACTION.cs:325
List< HireInfo > listReserve
Definition: FACTION.cs:136
int EvadeTax(int v, bool evasion)
Definition: FACTION.cs:522
void RemoveReserve(Chara c)
Definition: FACTION.cs:351
SourceFaction.Row _source
Definition: FACTION.cs:146
void ModRelation(int a)
Definition: FACTION.cs:270
int CountTax()
Definition: FACTION.cs:185
int GetResidentTax()
Definition: FACTION.cs:457
int GetBaseTax(bool evasion)
Definition: FACTION.cs:504
string Name
Definition: FACTION.cs:148
SourceFaction.Row source
Definition: FACTION.cs:150
float GetHappiness()
Definition: FACTION.cs:175
void OnAdvanceDay()
Definition: FACTION.cs:362
string id
Definition: FACTION.cs:127
int GetRankIncome()
Definition: FACTION.cs:471
void OnAdvanceMonth()
Definition: FACTION.cs:370
static Faction Create(SourceFaction.Row r)
Definition: FACTION.cs:154
void SetGlobalPolicyActive(int id, bool active)
Definition: FACTION.cs:449
void AddContribution(int a)
Definition: FACTION.cs:316
void OnLoad()
Definition: FACTION.cs:170
int CountTerritories()
Definition: FACTION.cs:227
int GetMaxReserve()
Definition: FACTION.cs:190
FactionRelation relation
Definition: FACTION.cs:124
GamePrincipal principal
Definition: Game.cs:221
SpatialManager spatials
Definition: Game.cs:152
Prologue Prologue
Definition: Game.cs:257
CardManager cards
Definition: Game.cs:155
FactionManager factions
Definition: Game.cs:161
Chara chara
Definition: HireInfo.cs:6
static void PayBill(Thing t, bool fromBank=false)
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
int extraTax
Definition: Player.cs:739
int fame
Definition: Player.cs:688
int taxBills
Definition: Player.cs:715
void SetActive(int id, bool active)
bool IsActive(int id, int days=-1)
int year
Definition: Prologue.cs:13
int GetIncome(Zone z)
SourceFaction factions
GlobalSpatialList map
RankedZoneManager ranks
Faction mainFaction
Definition: Spatial.cs:430
bool IsFull(int y=0)
static Thing CreateParcel(string idLang=null, params Thing[] things)
Definition: ThingGen.cs:42
static Thing CreateBill(int pay, bool tax)
Definition: ThingGen.cs:85
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
Definition: UINote.cs:6
UIItem AddHeader(string text, Sprite sprite=null)
Definition: UINote.cs:79
UIItem AddTopic(string id, string text, string value=null)
Definition: UINote.cs:144
GameDate date
Definition: World.cs:6
void SendPackage(Thing p)
Definition: World.cs:68
Definition: Zone.cs:12
FactionBranch branch
Definition: Zone.cs:34
void RemoveCard(Card t)
Definition: Zone.cs:1933
bool IsPCFaction
Definition: Zone.cs:464