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