Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
Happiness.cs
Go to the documentation of this file.
1using Newtonsoft.Json;
2using UnityEngine;
3
4public class Happiness : EClass
5{
6 [JsonProperty]
7 public int value;
8
9 [JsonProperty]
10 public int lastValue;
11
12 public int modPolicy;
13
15
17
18 public string Name => ("member" + type).lang();
19
20 public void SetOwner(FactionBranch _branch, FactionMemberType _type)
21 {
22 branch = _branch;
23 type = _type;
24 }
25
26 public void OnAdvanceDay()
27 {
29 value = (int)Mathf.Lerp(value, GetTargetValue(), 0.1f);
30 }
31
32 public void OnRefreshEffect()
33 {
34 modPolicy = 0;
35 }
36
37 public int GetTargetValue()
38 {
39 int num = 50;
40 if (branch.resources.food.value < 0)
41 {
42 num -= 100;
43 }
44 num += (branch.resources.fun.value - 50) / 4;
45 num += (branch.resources.culture.value - 50) / 4;
46 num += (branch.resources.medicine.value - 50) / 4;
47 num += (branch.resources.safety.value - 50) / 4;
48 foreach (Chara member in branch.members)
49 {
50 _ = member;
51 }
53 {
54 _ = item;
55 }
56 foreach (Policy item2 in branch.policies.list)
57 {
58 _ = item2;
59 }
60 return num + modPolicy;
61 }
62
63 public string GetText()
64 {
65 if (CountMembers() == 0)
66 {
67 return " - %".TagColor(FontColor.Passive);
68 }
69 string text = value + "%";
70 int num = value - lastValue;
71 if (num != 0)
72 {
73 _ = 0;
74 }
75 if (value <= 30)
76 {
77 text = text.TagColor(FontColor.Bad);
78 }
79 else if (value >= 70)
80 {
81 text = text.TagColor(FontColor.Good);
82 }
83 string text2 = "";
84 if (num > 0)
85 {
86 text2 = "↑".TagColor(FontColor.Good);
87 }
88 else if (num < 0)
89 {
90 text2 = "↓".TagColor(FontColor.Bad);
91 }
92 return text + " " + text2;
93 }
94
95 public int CountMembers()
96 {
97 int num = 0;
98 foreach (Chara member in branch.members)
99 {
100 if (member.memberType == type)
101 {
102 num++;
103 }
104 }
105 return num;
106 }
107
108 public void WriteNote(UINote n)
109 {
110 n.Clear();
111 n.AddHeader(Name);
112 n.Space();
113 n.AddText("vTarget".lang() + GetTargetValue());
114 n.AddText("vCurrent".lang() + value);
115 n.AddText("vLast".lang() + lastValue);
116 n.Space();
117 n.AddText("policyHappiness".lang(modPolicy.ToString() ?? ""));
118 n.Build();
119 }
120}
FactionMemberType
FontColor
Definition: FontColor.cs:2
Definition: Chara.cs:10
FactionMemberType memberType
Definition: Chara.cs:46
Definition: EClass.cs:5
List< Chara > members
PolicyManager policies
HomeResourceManager resources
int modPolicy
Definition: Happiness.cs:12
void OnAdvanceDay()
Definition: Happiness.cs:26
int CountMembers()
Definition: Happiness.cs:95
void WriteNote(UINote n)
Definition: Happiness.cs:108
int value
Definition: Happiness.cs:7
FactionBranch branch
Definition: Happiness.cs:14
int GetTargetValue()
Definition: Happiness.cs:37
void OnRefreshEffect()
Definition: Happiness.cs:32
string Name
Definition: Happiness.cs:18
FactionMemberType type
Definition: Happiness.cs:16
string GetText()
Definition: Happiness.cs:63
void SetOwner(FactionBranch _branch, FactionMemberType _type)
Definition: Happiness.cs:20
int lastValue
Definition: Happiness.cs:10
List< BaseHomeResource > list
List< Policy > list
Definition: PolicyManager.cs:7
Definition: UINote.cs:6
void Clear()
Definition: UINote.cs:35
UIItem AddHeader(string text, Sprite sprite=null)
Definition: UINote.cs:79
UIItem AddText(string text, FontColor color=FontColor.DontChange)
Definition: UINote.cs:113
void Space(int sizeY=0, int sizeX=1)
Definition: UINote.cs:62
void Build()
Definition: UINote.cs:49