Elin Decompiled Documentation EA 23.102 Nightly
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
SpawnList Class Reference
Inheritance diagram for SpawnList:
EClass

Public Member Functions

 SpawnList (string id=null)
 
void Add (CardRow row)
 
void CreateMaster (CardFilter _filter, string parent=null)
 
SpawnList Filter (int lv, int levelRange=-1)
 
CardRow Select (int lv=-1, int levelRange=-1)
 
CardRow GetRandom ()
 
CardRow GetFirst ()
 

Static Public Member Functions

static SpawnList Get (string id, string parent=null, CardFilter filter=null)
 
- Static Public Member Functions inherited from EClass
static int rnd (int a)
 
static int curve (int a, int start, int step, int rate=75)
 
static int rndHalf (int a)
 
static float rndf (float a)
 
static int rndSqrt (int a)
 
static void Wait (float a, Card c)
 
static void Wait (float a, Point p)
 
static int Bigger (int a, int b)
 
static int Smaller (int a, int b)
 

Public Attributes

string id
 
List< CardRowrows = new List<CardRow>()
 
CardFilter filter
 
int totalChance
 

Static Public Attributes

static Dictionary< string, SpawnListallList = new Dictionary<string, SpawnList>()
 
static SpawnList tempList = new SpawnList()
 
- Static Public Attributes inherited from EClass
static Core core
 

Additional Inherited Members

- Properties inherited from EClass
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Faction Wilds [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static SoundManager Sound [get]
 
static CoreDebug debug [get]
 

Detailed Description

Definition at line 4 of file SpawnList.cs.

Constructor & Destructor Documentation

◆ SpawnList()

SpawnList.SpawnList ( string  id = null)
inline

Definition at line 38 of file SpawnList.cs.

39 {
40 if (!id.IsEmpty())
41 {
42 SourceSpawnList.Row row = EClass.sources.spawnLists.map.TryGetValue(id);
43 if (row != null)
44 {
45 bool flag = row.type == "chara";
46 CardFilter cardFilter = (flag ? ((CardFilter)new CharaFilter()) : ((CardFilter)new ThingFilter()));
47 cardFilter.isChara = flag;
48 cardFilter.strTag = row.tag;
49 cardFilter.strFilter = row.filter;
50 cardFilter.filterCategory = row.category;
51 cardFilter.idCard = row.idCard;
52 CreateMaster(cardFilter, row.parent);
53 }
54 this.id = id;
55 }
56 }
Definition: EClass.cs:5
static SourceManager sources
Definition: EClass.cs:42
SourceSpawnList spawnLists
void CreateMaster(CardFilter _filter, string parent=null)
Definition: SpawnList.cs:64
string id
Definition: SpawnList.cs:10

References SourceSpawnList.Row.category, CreateMaster(), SourceSpawnList.Row.filter, id, SourceSpawnList.Row.idCard, SourceSpawnList.Row.parent, EClass.sources, SourceManager.spawnLists, and SourceSpawnList.Row.tag.

Member Function Documentation

◆ Add()

void SpawnList.Add ( CardRow  row)
inline

Definition at line 58 of file SpawnList.cs.

59 {
60 rows.Add(row);
61 totalChance += row.chance;
62 }
int chance
Definition: RenderRow.cs:24
int totalChance
Definition: SpawnList.cs:16
List< CardRow > rows
Definition: SpawnList.cs:12

References RenderRow.chance, rows, and totalChance.

Referenced by CreateMaster().

◆ CreateMaster()

void SpawnList.CreateMaster ( CardFilter  _filter,
string  parent = null 
)
inline

Definition at line 64 of file SpawnList.cs.

65 {
66 rows.Clear();
67 totalChance = 0;
68 filter = _filter;
69 List<CardRow> list = (parent.IsEmpty() ? EClass.sources.cards.rows : Get(parent).rows);
70 for (int i = 0; i < list.Count; i++)
71 {
72 CardRow cardRow = list[i];
73 if (cardRow.chance > 0 && filter.Pass(cardRow))
74 {
75 Add(cardRow);
76 }
77 }
78 if (!filter.idCard.IsEmpty())
79 {
80 string[] idCard = filter.idCard;
81 foreach (string key in idCard)
82 {
83 CardRow row = EClass.sources.cards.map[key];
84 Add(row);
85 }
86 }
87 }
string[] idCard
Definition: CardFilter.cs:37
bool Pass(CardRow source)
Definition: CardFilter.cs:91
Dictionary< string, CardRow > map
Definition: SourceCard.cs:8
SourceCard cards
static SpawnList Get(string id, string parent=null, CardFilter filter=null)
Definition: SpawnList.cs:18
void Add(CardRow row)
Definition: SpawnList.cs:58
CardFilter filter
Definition: SpawnList.cs:14

References Add(), SourceManager.cards, RenderRow.chance, filter, Get(), CardFilter.idCard, SourceCard.map, CardFilter.Pass(), rows, EClass.sources, and totalChance.

Referenced by Get(), and SpawnList().

◆ Filter()

SpawnList SpawnList.Filter ( int  lv,
int  levelRange = -1 
)
inline

Definition at line 89 of file SpawnList.cs.

90 {
91 tempList.rows.Clear();
92 tempList.totalChance = 0;
93 tempList.filter = filter;
94 for (int i = 0; i < rows.Count; i++)
95 {
96 CardRow cardRow = rows[i];
97 if (levelRange != -1)
98 {
99 if (cardRow.isChara && (cardRow as SourceChara.Row).mainElement.Length >= 2)
100 {
101 SourceChara.Row obj = cardRow as SourceChara.Row;
102 bool flag = false;
103 string[] mainElement = obj.mainElement;
104 for (int j = 0; j < mainElement.Length; j++)
105 {
106 string[] array = mainElement[j].Split('/');
107 SourceElement.Row row = EClass.sources.elements.alias["ele" + array[0]];
108 if (Mathf.Abs(cardRow.LV * row.eleP / 100 - lv) < levelRange)
109 {
110 flag = true;
111 break;
112 }
113 }
114 if (!flag)
115 {
116 continue;
117 }
118 }
119 else if (Mathf.Abs(cardRow.LV - lv) >= levelRange)
120 {
121 continue;
122 }
123 }
124 else if (cardRow.LV > lv)
125 {
126 continue;
127 }
128 tempList.rows.Add(cardRow);
129 tempList.totalChance += cardRow.chance;
130 }
131 if (tempList.rows.Count == 0)
132 {
133 Debug.Log("list contains no item: " + id + "/" + lv);
134 return this;
135 }
136 return tempList;
137 }
bool isChara
Definition: CardRow.cs:55
int LV
Definition: RenderRow.cs:22
string[] mainElement
Definition: SourceChara.cs:33
SourceElement elements
static SpawnList tempList
Definition: SpawnList.cs:8

References RenderRow.chance, Debug, SourceManager.elements, SourceElement.Row.eleP, filter, CardRow.isChara, RenderRow.LV, SourceChara.Row.mainElement, rows, EClass.sources, and tempList.

Referenced by Select().

◆ Get()

static SpawnList SpawnList.Get ( string  id,
string  parent = null,
CardFilter  filter = null 
)
inlinestatic

Definition at line 18 of file SpawnList.cs.

19 {
20 SpawnList spawnList = allList.TryGetValue(id);
21 if (spawnList != null)
22 {
23 if (spawnList.filter != filter && filter != null)
24 {
25 spawnList.CreateMaster(filter, parent);
26 }
27 return spawnList;
28 }
29 spawnList = new SpawnList(id);
30 if (filter != null)
31 {
32 spawnList.CreateMaster(filter, parent);
33 }
34 allList.Add(id, spawnList);
35 return spawnList;
36 }
static Dictionary< string, SpawnList > allList
Definition: SpawnList.cs:6

References allList, CreateMaster(), and filter.

Referenced by ThingGen.CreateFromFilter(), CharaGen.CreateFromFilter(), CreateMaster(), Trait.CreateStock(), DNA.GenerateManiGene(), DNA.GenerateRandomGene(), SpawnListChara.Get(), SpawnListThing.Get(), Region.OnAdvanceHour(), GameDate.ShipRandomPackages(), Zone.SpawnMob(), ThingGen.TestCreate(), and Card.TryMakeRandomItem().

◆ GetFirst()

CardRow SpawnList.GetFirst ( )
inline

Definition at line 200 of file SpawnList.cs.

201 {
202 return rows[0];
203 }

References rows.

◆ GetRandom()

CardRow SpawnList.GetRandom ( )
inline

Definition at line 195 of file SpawnList.cs.

196 {
197 return rows[EClass.rnd(rows.Count)];
198 }
static int rnd(int a)
Definition: EClass.cs:50

References EClass.rnd(), and rows.

◆ Select()

CardRow SpawnList.Select ( int  lv = -1,
int  levelRange = -1 
)
inline

Definition at line 139 of file SpawnList.cs.

140 {
141 if (lv != -1)
142 {
143 if (levelRange != -1)
144 {
145 for (int i = 0; i < 50; i++)
146 {
147 SpawnList spawnList = Filter(lv + i - i * i, levelRange + i * i);
148 if (spawnList.rows.Count > 5)
149 {
150 return spawnList.Select();
151 }
152 }
153 }
154 lv = lv + 2 + EClass.rnd(EClass.rnd(EClass.rnd(EClass.rnd(Mathf.Min(lv * 2, 20)) + 1) + 1) + 1);
155 return Filter(lv).Select();
156 }
157 if (filter != null && filter.categoriesInclude.Count > 0)
158 {
160 for (int j = 0; j < 100; j++)
161 {
162 CardRow cardRow = _Select();
163 if (cardRow != null && cardRow.Category.IsChildOf(r))
164 {
165 return cardRow;
166 }
167 }
168 }
169 return _Select();
170 CardRow _Select()
171 {
172 int num = EClass.rnd(totalChance);
173 int num2 = 0;
174 foreach (CardRow row in rows)
175 {
176 num2 += row.chance;
177 if (num < num2)
178 {
179 return row;
180 }
181 }
182 if (rows.Count == 0)
183 {
184 Debug.Log("no item:" + id);
185 foreach (CardFilter.FilterItem tag in filter.tags)
186 {
187 Debug.Log(tag.name + "/" + tag.exclude);
188 }
189 return null;
190 }
191 return rows[EClass.rnd(rows.Count)];
192 }
193 }
List< FilterItem > tags
Definition: CardFilter.cs:39
List< SourceCategory.Row > categoriesInclude
Definition: CardFilter.cs:45
SourceCategory.Row Category
Definition: RenderRow.cs:119
SpawnList Filter(int lv, int levelRange=-1)
Definition: SpawnList.cs:89
CardRow Select(int lv=-1, int levelRange=-1)
Definition: SpawnList.cs:139

References CardFilter.categoriesInclude, RenderRow.Category, RenderRow.chance, Debug, filter, Filter(), EClass.rnd(), rows, Select(), CardFilter.tags, and totalChance.

Referenced by ThingGen._Create(), ThingGen.CreateFromCategory(), CharaGen.CreateFromFilter(), ThingGen.CreateFromFilter(), ThingGen.CreateFromTag(), Trait.CreateStock(), DNA.GenerateManiGene(), DNA.GenerateRandomGene(), Select(), QuestDeliver.SetIdThing(), GameDate.ShipRandomPackages(), ThingGen.TestCreate(), Card.TryMakeRandomItem(), and SlaverData.TryRefresh().

Member Data Documentation

◆ allList

Dictionary<string, SpawnList> SpawnList.allList = new Dictionary<string, SpawnList>()
static

Definition at line 6 of file SpawnList.cs.

Referenced by Get(), and Core.ResetRuntime().

◆ filter

CardFilter SpawnList.filter

Definition at line 14 of file SpawnList.cs.

Referenced by CreateMaster(), Filter(), Get(), and Select().

◆ id

string SpawnList.id

Definition at line 10 of file SpawnList.cs.

Referenced by TraitCrafter.Craft(), SerializedCards.Restore(), and SpawnList().

◆ rows

List<CardRow> SpawnList.rows = new List<CardRow>()

Definition at line 12 of file SpawnList.cs.

Referenced by Add(), CreateMaster(), Filter(), GetFirst(), GetRandom(), and Select().

◆ tempList

SpawnList SpawnList.tempList = new SpawnList()
static

Definition at line 8 of file SpawnList.cs.

Referenced by Filter().

◆ totalChance

int SpawnList.totalChance

Definition at line 16 of file SpawnList.cs.

Referenced by Add(), CreateMaster(), and Select().


The documentation for this class was generated from the following file: