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