Elin Modding Docs Doc
Loading...
Searching...
No Matches
SpawnList.cs
1using System;
2using System.Collections.Generic;
3using System.Runtime.CompilerServices;
4using UnityEngine;
5
6// Token: 0x020004F1 RID: 1265
7public class SpawnList : EClass
8{
9 // Token: 0x060021B9 RID: 8633 RVA: 0x000BA700 File Offset: 0x000B8900
10 public static SpawnList Get(string id, string parent = null, CardFilter filter = null)
11 {
12 SpawnList spawnList = SpawnList.allList.TryGetValue(id, null);
13 if (spawnList != null)
14 {
15 if (spawnList.filter != filter && filter != null)
16 {
17 spawnList.CreateMaster(filter, parent);
18 }
19 return spawnList;
20 }
21 spawnList = new SpawnList(id);
22 if (filter != null)
23 {
24 spawnList.CreateMaster(filter, parent);
25 }
26 SpawnList.allList.Add(id, spawnList);
27 return spawnList;
28 }
29
30 // Token: 0x060021BA RID: 8634 RVA: 0x000BA754 File Offset: 0x000B8954
31 public SpawnList(string id = null)
32 {
33 if (!id.IsEmpty())
34 {
35 SourceSpawnList.Row row = EClass.sources.spawnLists.map.TryGetValue(id, null);
36 if (row != null)
37 {
38 bool flag = row.type == "chara";
39 CardFilter cardFilter = flag ? new CharaFilter() : new ThingFilter();
40 cardFilter.isChara = flag;
41 cardFilter.strTag = row.tag;
42 cardFilter.strFilter = row.filter;
43 cardFilter.filterCategory = row.category;
44 cardFilter.idCard = row.idCard;
45 this.CreateMaster(cardFilter, row.parent);
46 }
47 this.id = id;
48 }
49 }
50
51 // Token: 0x060021BB RID: 8635 RVA: 0x000BA803 File Offset: 0x000B8A03
52 public void Add(CardRow row)
53 {
54 this.rows.Add(row);
55 this.totalChance += row.chance;
56 }
57
58 // Token: 0x060021BC RID: 8636 RVA: 0x000BA824 File Offset: 0x000B8A24
59 public void CreateMaster(CardFilter _filter, string parent = null)
60 {
61 this.rows.Clear();
62 this.totalChance = 0;
63 this.filter = _filter;
64 List<CardRow> list = parent.IsEmpty() ? EClass.sources.cards.rows : SpawnList.Get(parent, null, null).rows;
65 for (int i = 0; i < list.Count; i++)
66 {
67 CardRow cardRow = list[i];
68 if (cardRow.chance > 0 && this.filter.Pass(cardRow))
69 {
70 this.Add(cardRow);
71 }
72 }
73 if (!this.filter.idCard.IsEmpty())
74 {
75 foreach (string key in this.filter.idCard)
76 {
77 CardRow row = EClass.sources.cards.map[key];
78 this.Add(row);
79 }
80 }
81 }
82
83 // Token: 0x060021BD RID: 8637 RVA: 0x000BA900 File Offset: 0x000B8B00
84 public SpawnList Filter(int lv, int levelRange = -1)
85 {
86 SpawnList.tempList.rows.Clear();
87 SpawnList.tempList.totalChance = 0;
88 SpawnList.tempList.filter = this.filter;
89 int i = 0;
90 while (i < this.rows.Count)
91 {
92 CardRow cardRow = this.rows[i];
93 if (levelRange != -1)
94 {
95 if (Mathf.Abs(cardRow.LV - lv) < levelRange)
96 {
97 goto IL_5A;
98 }
99 }
100 else if (cardRow.LV <= lv)
101 {
102 goto IL_5A;
103 }
104 IL_81:
105 i++;
106 continue;
107 IL_5A:
108 SpawnList.tempList.rows.Add(cardRow);
109 SpawnList.tempList.totalChance += cardRow.chance;
110 goto IL_81;
111 }
112 if (SpawnList.tempList.rows.Count == 0)
113 {
114 Debug.Log("list contains no item: " + this.id + "/" + lv.ToString());
115 return this;
116 }
117 return SpawnList.tempList;
118 }
119
120 // Token: 0x060021BE RID: 8638 RVA: 0x000BA9DC File Offset: 0x000B8BDC
121 public CardRow Select(int lv = -1, int levelRange = -1)
122 {
123 if (lv != -1)
124 {
125 if (levelRange != -1)
126 {
127 for (int i = 0; i < 50; i++)
128 {
129 SpawnList spawnList = this.Filter(lv + i - i * i, levelRange + i * i);
130 if (spawnList.rows.Count > 5)
131 {
132 return spawnList.Select(-1, -1);
133 }
134 }
135 }
136 lv = lv + 2 + EClass.rnd(EClass.rnd(EClass.rnd(EClass.rnd(Mathf.Min(lv * 2, 20)) + 1) + 1) + 1);
137 return this.Filter(lv, -1).Select(-1, -1);
138 }
139 if (this.filter != null && this.filter.categoriesInclude.Count > 0)
140 {
141 SourceCategory.Row r = this.filter.categoriesInclude.RandomItem<SourceCategory.Row>();
142 for (int j = 0; j < 100; j++)
143 {
144 CardRow cardRow = this.<Select>g___Select|11_0();
145 if (cardRow != null && cardRow.Category.IsChildOf(r))
146 {
147 return cardRow;
148 }
149 }
150 }
151 return this.<Select>g___Select|11_0();
152 }
153
154 // Token: 0x060021BF RID: 8639 RVA: 0x000BAABF File Offset: 0x000B8CBF
155 public CardRow GetRandom()
156 {
157 return this.rows[EClass.rnd(this.rows.Count)];
158 }
159
160 // Token: 0x060021C0 RID: 8640 RVA: 0x000BAADC File Offset: 0x000B8CDC
161 public CardRow GetFirst()
162 {
163 return this.rows[0];
164 }
165
166 // Token: 0x060021C2 RID: 8642 RVA: 0x000BAB04 File Offset: 0x000B8D04
167 [CompilerGenerated]
168 private CardRow <Select>g___Select|11_0()
169 {
170 int num = EClass.rnd(this.totalChance);
171 int num2 = 0;
172 foreach (CardRow cardRow in this.rows)
173 {
174 num2 += cardRow.chance;
175 if (num < num2)
176 {
177 return cardRow;
178 }
179 }
180 if (this.rows.Count == 0)
181 {
182 Debug.Log("no item:" + this.id);
183 foreach (CardFilter.FilterItem filterItem in this.filter.tags)
184 {
185 Debug.Log(filterItem.name + "/" + filterItem.exclude.ToString());
186 }
187 return null;
188 }
189 return this.rows[EClass.rnd(this.rows.Count)];
190 }
191
192 // Token: 0x04001138 RID: 4408
193 public static Dictionary<string, SpawnList> allList = new Dictionary<string, SpawnList>();
194
195 // Token: 0x04001139 RID: 4409
196 public static SpawnList tempList = new SpawnList(null);
197
198 // Token: 0x0400113A RID: 4410
199 public string id;
200
201 // Token: 0x0400113B RID: 4411
202 public List<CardRow> rows = new List<CardRow>();
203
204 // Token: 0x0400113C RID: 4412
205 public CardFilter filter;
206
207 // Token: 0x0400113D RID: 4413
208 public int totalChance;
209}