Elin Modding Docs Doc
Loading...
Searching...
No Matches
PolicyManager.cs
1using System;
2using System.Collections.Generic;
3using Newtonsoft.Json;
4
5// Token: 0x02000076 RID: 118
6public class PolicyManager : EClass
7{
8 // Token: 0x0600035F RID: 863 RVA: 0x000193D8 File Offset: 0x000175D8
9 public void SetOwner(FactionBranch _owner)
10 {
11 this.owner = _owner;
12 foreach (Policy policy in this.list)
13 {
14 policy.SetOwner(this.owner);
15 }
16 this.RefreshEffects();
17 }
18
19 // Token: 0x06000360 RID: 864 RVA: 0x0001943C File Offset: 0x0001763C
20 public void AddPolicy(string id)
21 {
22 this.AddPolicy(EClass.sources.elements.alias[id].id, true);
23 }
24
25 // Token: 0x06000361 RID: 865 RVA: 0x00019460 File Offset: 0x00017660
26 public Policy AddPolicy(int id, bool show = true)
27 {
28 if (this.owner.elements.GetElement(id) == null)
29 {
30 this.owner.elements.SetBase(id, 1, 0);
31 }
32 Policy policy = new Policy
33 {
34 id = id
35 };
36 policy.SetOwner(this.owner);
37 this.list.Add(policy);
38 if (show)
39 {
40 WidgetPopText.Say("rewardPolicy".lang(EClass.sources.elements.map[id].GetName(), null, null, null, null), FontColor.Default, null);
41 }
42 if (policy.source.tag.Contains("globalPolicy"))
43 {
44 EClass.pc.faction.AddGlobalPolicy(policy.id);
45 }
46 return policy;
47 }
48
49 // Token: 0x06000362 RID: 866 RVA: 0x00019518 File Offset: 0x00017718
50 public void Activate(int id)
51 {
52 foreach (Policy policy in this.list)
53 {
54 if (policy.id == id)
55 {
56 policy.active = true;
57 }
58 }
59 }
60
61 // Token: 0x06000363 RID: 867 RVA: 0x00019574 File Offset: 0x00017774
62 public void SetActive(int id, bool active)
63 {
64 foreach (Policy policy in this.list)
65 {
66 if (policy.id == id)
67 {
68 policy.active = active;
69 }
70 }
71 }
72
73 // Token: 0x06000364 RID: 868 RVA: 0x000195D0 File Offset: 0x000177D0
74 public bool IsActive(int id, int days = -1)
75 {
76 foreach (Policy policy in this.list)
77 {
78 if (policy.active && policy.id == id && (days == -1 || policy.days >= days))
79 {
80 return true;
81 }
82 }
83 return false;
84 }
85
86 // Token: 0x06000365 RID: 869 RVA: 0x00019644 File Offset: 0x00017844
87 public bool HasPolicy(int id)
88 {
89 using (List<Policy>.Enumerator enumerator = this.list.GetEnumerator())
90 {
91 while (enumerator.MoveNext())
92 {
93 if (enumerator.Current.id == id)
94 {
95 return true;
96 }
97 }
98 }
99 return false;
100 }
101
102 // Token: 0x06000366 RID: 870 RVA: 0x000196A0 File Offset: 0x000178A0
103 public void OnSimulateHour(VirtualDate date)
104 {
105 foreach (Policy policy in this.list)
106 {
107 if (policy.active)
108 {
109 policy.OnAdvanceHour(date);
110 if (date.hour == 0)
111 {
112 policy.days++;
113 }
114 }
115 else
116 {
117 policy.days = 0;
118 }
119 }
120 }
121
122 // Token: 0x06000367 RID: 871 RVA: 0x0001971C File Offset: 0x0001791C
123 public int GetValue(int id)
124 {
125 foreach (Policy policy in this.list)
126 {
127 if (policy.id == id && policy.active)
128 {
129 return policy.Ele.Value;
130 }
131 }
132 return 0;
133 }
134
135 // Token: 0x06000368 RID: 872 RVA: 0x0001978C File Offset: 0x0001798C
136 public int CurrentAP()
137 {
138 int num = 0;
139 foreach (Policy policy in this.list)
140 {
141 if (policy.active)
142 {
143 num += policy.Cost;
144 }
145 }
146 return num;
147 }
148
149 // Token: 0x06000369 RID: 873 RVA: 0x000197EC File Offset: 0x000179EC
150 public void RefreshEffects()
151 {
152 foreach (Happiness happiness in this.owner.happiness.list)
153 {
154 happiness.OnRefreshEffect();
155 }
156 foreach (BaseHomeResource baseHomeResource in this.owner.resources.list)
157 {
158 baseHomeResource.OnRefreshEffect();
159 }
160 foreach (Policy policy in this.list)
161 {
162 if (policy.active)
163 {
164 policy.RefreshEffect(null);
165 }
166 }
167 this.owner.resources.SetDirty();
168 }
169
170 // Token: 0x0600036A RID: 874 RVA: 0x000198EC File Offset: 0x00017AEC
171 public void Validate()
172 {
173 }
174
175 // Token: 0x04000575 RID: 1397
176 [JsonProperty]
177 public List<Policy> list = new List<Policy>();
178
179 // Token: 0x04000576 RID: 1398
180 public FactionBranch owner;
181}