Elin Modding Docs Doc
Loading...
Searching...
No Matches
ResearchManager.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using Newtonsoft.Json;
5
6// Token: 0x02000088 RID: 136
7public class ResearchManager : EClass
8{
9 // Token: 0x060003B8 RID: 952 RVA: 0x0001A810 File Offset: 0x00018A10
10 public void SetOwner(FactionBranch _branch)
11 {
12 this.branch = _branch;
13 foreach (ResearchPlan researchPlan in this.plans)
14 {
15 researchPlan.SetOwner(_branch);
16 }
17 foreach (ResearchPlan researchPlan2 in this.finished)
18 {
19 researchPlan2.SetOwner(_branch);
20 }
21 }
22
23 // Token: 0x060003B9 RID: 953 RVA: 0x0001A8A8 File Offset: 0x00018AA8
24 public void OnSimulateDay()
25 {
26 this.newPlans.Clear();
27 }
28
29 // Token: 0x060003BA RID: 954 RVA: 0x0001A8B8 File Offset: 0x00018AB8
30 public void TryAddPlans(string idResource, int lv)
31 {
32 IEnumerable<SourceResearch.Row> rows = EClass.sources.researches.rows;
33 Func<SourceResearch.Row, bool> <>9__0;
34 Func<SourceResearch.Row, bool> predicate;
35 if ((predicate = <>9__0) == null)
36 {
37 predicate = (<>9__0 = ((SourceResearch.Row r) => r.resource.Length > 1 && r.resource[0] == idResource && r.resource[1].ToInt() == lv));
38 }
39 foreach (SourceResearch.Row row in rows.Where(predicate))
40 {
41 this.AddPlan(row.id);
42 }
43 }
44
45 // Token: 0x060003BB RID: 955 RVA: 0x0001A94C File Offset: 0x00018B4C
46 public bool IsListBarter(string idPlan)
47 {
48 SourceResearch.Row row = EClass.sources.researches.map[idPlan];
49 return row.money > 0 && !this.branch.researches.HasPlan(row.id);
50 }
51
52 // Token: 0x060003BC RID: 956 RVA: 0x0001A994 File Offset: 0x00018B94
53 public bool HasPlan(string idPlan)
54 {
55 using (IEnumerator<ResearchPlan> enumerator = this.plans.Concat(this.finished).GetEnumerator())
56 {
57 while (enumerator.MoveNext())
58 {
59 if (enumerator.Current.id == idPlan)
60 {
61 return true;
62 }
63 }
64 }
65 return false;
66 }
67
68 // Token: 0x060003BD RID: 957 RVA: 0x0001A9F8 File Offset: 0x00018BF8
69 public bool IsComplete(string id, int rank = -1)
70 {
71 using (List<ResearchPlan>.Enumerator enumerator = this.finished.GetEnumerator())
72 {
73 while (enumerator.MoveNext())
74 {
75 if (enumerator.Current.source.id == id)
76 {
77 return true;
78 }
79 }
80 }
81 if (rank != -1)
82 {
83 foreach (ResearchPlan researchPlan in this.plans)
84 {
85 if (researchPlan.source.id == id && researchPlan.rank >= rank)
86 {
87 return true;
88 }
89 }
90 }
91 return false;
92 }
93
94 // Token: 0x060003BE RID: 958 RVA: 0x0001AABC File Offset: 0x00018CBC
95 public void AddPlan(string id)
96 {
97 this.AddPlan(ResearchPlan.Create(id));
98 }
99
100 // Token: 0x060003BF RID: 959 RVA: 0x0001AACC File Offset: 0x00018CCC
101 public void AddPlan(ResearchPlan p)
102 {
103 p.SetOwner(this.branch);
104 this.plans.Add(p);
105 this.newPlans.Add(p);
106 WidgetPopText.Say("rewardPlan".lang(p.Name, null, null, null, null), FontColor.Default, null);
107 }
108
109 // Token: 0x060003C0 RID: 960 RVA: 0x0001AB18 File Offset: 0x00018D18
110 public bool CanCompletePlan(ResearchPlan p)
111 {
112 return this.branch.resources.knowledge.value >= p.source.tech;
113 }
114
115 // Token: 0x060003C1 RID: 961 RVA: 0x0001AB40 File Offset: 0x00018D40
116 public void CompletePlan(ResearchPlan p)
117 {
118 if (this.focused == p)
119 {
120 this.focused = null;
121 }
122 p.OnComplete();
123 WidgetPopText.Say("completePlan".lang(p.Name, null, null, null, null), FontColor.Great, null);
124 if (p.source.maxLv > p.rank)
125 {
126 p.rank++;
127 p.exp = (p.lastExp = 0);
128 SE.Play("good");
129 return;
130 }
131 this.plans.Remove(p);
132 this.finished.Add(p);
133 SE.Play("good");
134 }
135
136 // Token: 0x060003C2 RID: 962 RVA: 0x0001ABE0 File Offset: 0x00018DE0
137 public void ShowNewPlans(Action onComplete = null)
138 {
139 Rand.SetSeed(EClass.game.seed + this.branch.seedPlan);
140 List<ResearchPlan> list = new List<ResearchPlan>();
141 foreach (SourceResearch.Row row in EClass.sources.researches.rows)
142 {
143 list.Add(ResearchPlan.Create(row.id));
144 }
145 Rand.SetSeed(-1);
146 foreach (ResearchPlan researchPlan in list)
147 {
148 }
149 EClass.core.ui.AddLayer<LayerList>().SetSize(450f, -1f).SetList2<ResearchPlan>(list, (ResearchPlan p) => p.Name, delegate(ResearchPlan p, ItemGeneral b)
150 {
151 this.branch.seedPlan++;
152 this.branch.researches.AddPlan(p);
153 Action onComplete2 = onComplete;
154 if (onComplete2 == null)
155 {
156 return;
157 }
158 onComplete2();
159 }, delegate(ResearchPlan p, ItemGeneral b)
160 {
161 }, true);
162 }
163
164 // Token: 0x040005A6 RID: 1446
165 [JsonProperty]
166 public List<ResearchPlan> plans = new List<ResearchPlan>();
167
168 // Token: 0x040005A7 RID: 1447
169 [JsonProperty]
170 public List<ResearchPlan> finished = new List<ResearchPlan>();
171
172 // Token: 0x040005A8 RID: 1448
173 [JsonProperty]
174 public List<ResearchPlan> newPlans = new List<ResearchPlan>();
175
176 // Token: 0x040005A9 RID: 1449
177 [JsonProperty]
178 public ResearchPlan focused;
179
180 // Token: 0x040005AA RID: 1450
181 public FactionBranch branch;
182}