Elin Decompiled Documentation EA 23.303 Nightly
Loading...
Searching...
No Matches
SourceObj.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3
4public class SourceObj : SourceDataInt<SourceObj.Row>
5{
6 [Serializable]
7 public class Row : TileRow
8 {
9 public string[] _growth;
10
11 public int costSoil;
12
13 public string objType;
14
15 public string[] vals;
16
17 public string[] reqHarvest;
18
19 public string valType;
20
21 public int[] anime;
22
23 public string matCategory;
24
25 public int idRoof;
26
27 [NonSerialized]
28 public bool HasGrowth;
29
30 [NonSerialized]
31 public bool autoTile;
32
34
36
37 [NonSerialized]
38 public string name_L;
39
40 [NonSerialized]
41 public string detail_L;
42
43 public override bool UseAlias => true;
44
45 public override string GetAlias => alias;
46
47 public override string RecipeID => "o" + id;
48
50
51 public override void OnInit()
52 {
53 objValType = ((!valType.IsEmpty()) ? valType.ToEnum<ObjValType>() : ObjValType.None);
54 autoTile = tag.Contains("autotile");
55 if (!_growth.IsEmpty())
56 {
57 growth = ClassCache.Create<GrowSystem>("GrowSystem" + _growth[0], "Elin");
58 growth.Init(this);
59 HasGrowth = true;
60 }
61 else
62 {
63 HasGrowth = false;
64 }
65 }
66 }
67
68 public class Stage
69 {
70 public int step;
71
72 public int[] tiles;
73
74 public string idThing;
75
76 public bool harvest;
77 }
78
79 public Dictionary<int, Row> _rows = new Dictionary<int, Row>();
80
82
83 public override Row CreateRow()
84 {
85 return new Row
86 {
87 id = SourceData.GetInt(0),
88 alias = SourceData.GetString(1),
89 name_JP = SourceData.GetString(2),
90 name = SourceData.GetString(3),
91 _growth = SourceData.GetStringArray(4),
92 costSoil = SourceData.GetInt(5),
93 objType = SourceData.GetString(6),
94 vals = SourceData.GetStringArray(7),
96 sort = SourceData.GetInt(9),
97 reqHarvest = SourceData.GetStringArray(10),
98 hp = SourceData.GetInt(11),
99 _tileType = SourceData.GetString(12),
100 valType = SourceData.GetString(13),
101 _idRenderData = SourceData.GetString(14),
102 tiles = SourceData.GetIntArray(15),
103 anime = SourceData.GetIntArray(16),
104 snowTile = SourceData.GetInt(17),
105 colorMod = SourceData.GetInt(18),
106 colorType = SourceData.GetString(19),
107 value = SourceData.GetInt(20),
108 LV = SourceData.GetInt(21),
109 chance = SourceData.GetInt(22),
110 recipeKey = SourceData.GetStringArray(23),
111 factory = SourceData.GetStringArray(24),
112 components = SourceData.GetStringArray(25),
113 defMat = SourceData.GetString(26),
114 matCategory = SourceData.GetString(27),
115 category = SourceData.GetString(28),
116 idRoof = SourceData.GetInt(29),
117 detail_JP = SourceData.GetString(30),
118 detail = SourceData.GetString(31)
119 };
120 }
121
122 public override void SetRow(Row r)
123 {
124 map[r.id] = r;
125 }
126
127 public override void BackupPref()
128 {
129 _rows.Clear();
130 foreach (Row row in rows)
131 {
132 _rows[row.id] = row;
133 }
134 }
135
136 public override void RestorePref()
137 {
138 foreach (Row row in rows)
139 {
140 row.pref = _rows.TryGetValue(row.id)?.pref ?? new SourcePref();
141 }
142 }
143
144 public override void ValidatePref()
145 {
146 foreach (Row row in rows)
147 {
148 row.pref.Validate();
149 }
150 }
151
152 public string GetName(int id)
153 {
154 return map[id].GetName().ToTitleCase();
155 }
156
157 public override void OnAfterImportData()
158 {
159 int num = 0;
160 foreach (Row row in rows)
161 {
162 if (row.sort != 0)
163 {
164 num = row.sort;
165 }
166 row.sort = num;
167 num++;
168 }
169 rows.Sort((Row a, Row b) => a.id - b.id);
170 }
171
172 public override void OnInit()
173 {
174 FallbackRenderData = ResourceCache.Load<RenderData>("Scene/Render/Data/obj");
175 Cell.objList = rows;
176 foreach (Row row in rows)
177 {
178 row.Init();
179 }
180 }
181}
ObjValType
Definition: ObjValType.cs:2
void Init(SourceObj.Row _row)
Definition: GrowSystem.cs:149
string[] tag
Definition: RenderRow.cs:58
int sort
Definition: RenderRow.cs:18
SourcePref pref
Definition: RenderRow.cs:68
static string[] GetStringArray(int id)
Definition: SourceData.cs:922
static string GetString(int id)
Definition: SourceData.cs:927
static int GetInt(int id)
Definition: SourceData.cs:892
static int[] GetIntArray(int id)
Definition: SourceData.cs:917
bool HasGrowth
Definition: SourceObj.cs:28
ObjValType objValType
Definition: SourceObj.cs:35
int[] anime
Definition: SourceObj.cs:21
string[] reqHarvest
Definition: SourceObj.cs:17
string detail_L
Definition: SourceObj.cs:41
override bool UseAlias
Definition: SourceObj.cs:43
string valType
Definition: SourceObj.cs:19
string[] _growth
Definition: SourceObj.cs:9
override string RecipeID
Definition: SourceObj.cs:47
override void OnInit()
Definition: SourceObj.cs:51
string objType
Definition: SourceObj.cs:13
GrowSystem growth
Definition: SourceObj.cs:33
string matCategory
Definition: SourceObj.cs:23
override RenderData defaultRenderData
Definition: SourceObj.cs:49
string name_L
Definition: SourceObj.cs:38
bool autoTile
Definition: SourceObj.cs:31
override string GetAlias
Definition: SourceObj.cs:45
string[] vals
Definition: SourceObj.cs:15
string idThing
Definition: SourceObj.cs:74
string GetName(int id)
Definition: SourceObj.cs:152
override void OnInit()
Definition: SourceObj.cs:172
override void OnAfterImportData()
Definition: SourceObj.cs:157
override void RestorePref()
Definition: SourceObj.cs:136
override void SetRow(Row r)
Definition: SourceObj.cs:122
override void BackupPref()
Definition: SourceObj.cs:127
override Row CreateRow()
Definition: SourceObj.cs:83
static RenderData FallbackRenderData
Definition: SourceObj.cs:81
override void ValidatePref()
Definition: SourceObj.cs:144
Dictionary< int, Row > _rows
Definition: SourceObj.cs:79
void Validate()
Definition: SourcePref.cs:351
string alias
Definition: TileRow.cs:12
int id
Definition: TileRow.cs:8
void Init()
Definition: TileRow.cs:16