/
entity.go
384 lines (330 loc) · 9.12 KB
/
entity.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
package df2014
import (
"reflect"
"strconv"
)
type EntityType uint16
const (
Civilization EntityType = iota
SiteGovernment
VesselCrew
MigratingGroup
NomadicGroup
Religion
MilitaryUnit
Outcast
)
var entityTypes = []string{
"civilization",
"site government",
"vessel crew",
"migrating group",
"nomadic group",
"religion",
"military unit",
"outcast",
}
func (i EntityType) prettyPrint(w *WorldDat, buf, indent []byte, outerTag reflect.StructTag) []byte {
return prettyPrintIndex(int64(i), uint64(i), entityTypes, buf)
}
type EntityFlags uint32
var entityFlags = map[uint8]string{
4: "ruin",
}
func (f EntityFlags) prettyPrint(w *WorldDat, buf, indent []byte, outerTag reflect.StructTag) []byte {
return prettyPrintFlags(uint64(f), entityFlags, buf)
}
type RaceCasteList struct {
Race []uint32
Caste []uint16 `df2014_assert_same_length_as:"Race"`
}
func (rcl RaceCasteList) prettyPrint(w *WorldDat, buf, indent []byte, outerTag reflect.StructTag) []byte {
buf = append(buf, "(len = "...)
buf = strconv.AppendInt(buf, int64(len(rcl.Race)), 10)
buf = append(buf, ") {"...)
indent = append(indent, '\t')
for i, r := range rcl.Race {
c := rcl.Caste[i]
buf = append(buf, indent...)
buf = strconv.AppendInt(buf, int64(i), 10)
buf = append(buf, ": "...)
buf = CreatureIndex(r).prettyPrint(w, buf, indent, "")
buf = append(buf, ": "...)
buf = strconv.AppendUint(buf, uint64(c), 10)
buf = append(buf, " (0x"...)
buf = strconv.AppendUint(buf, uint64(c), 16)
buf = append(buf, ')')
}
buf = append(buf, indent[:len(indent)-1]...)
buf = append(buf, '}')
return buf
}
type EntityEthicResponse uint16
const (
EERNotApplicable EntityEthicResponse = iota
EERAcceptable
EERPersonalMatter
EERJustifiedIfNoRepercussions
EERJustifiedIfGoodReason
EERJustifiedIfExtremeReason
EERJustifiedIfSelfDefense
EEROnlyIfSanctioned
EERMisguided
EERShun
EERAppalling
EERPunishReprimand
EERPunishSerious
EERPunishExile
EERPunishCapital
EERUnthinkable
EERRequired
)
var entityEthicResponses = [...]string{
"not applicable",
"acceptable",
"personal matter",
"justified if no repercussions",
"justified if good reason",
"justified if extreme reason",
"justified if self defense",
"only if sanctioned",
"misguided",
"shun",
"appalling",
"punish reprimand",
"punish serious",
"punish exile",
"punish capital",
"unthinkable",
"required",
}
func (i EntityEthicResponse) prettyPrint(w *WorldDat, buf, indent []byte, outerTag reflect.StructTag) []byte {
return prettyPrintIndex(int64(i), uint64(i), entityEthicResponses[:], buf)
}
type Entity struct {
Type EntityType
ID int32
Class string
MinTemperature int16 `df2014_version_min:"1131"`
MaxTemperature int16 `df2014_version_min:"1131"`
UnitChunkID uint32
UnitChunkSubID uint16
Unused_41C []uint32 `df2014_assert_equals:"[]uint32{}"`
Name *Name
Race CreatureIndex16
Flags EntityFlags
Leather []int16
Cloth []int16
Silk []int16
Crafts MaterialList
Glass MaterialList
Wood MaterialList
Pets []int16
Cages MaterialList
Drinks MaterialList
Cheese MaterialList
Mill MaterialList
Extract MaterialList
MeatFish []int16
Plants []int16
Wagons []int16
PackAnimals []int16
WagonPullers []int16
Mounts []int16
SiegeMinions []int16
LyeWood []int16 `df2014_version_min:"1147"`
CraftMetals []int16 `df2014_version_min:"1147"`
Stone MaterialList `df2014_version_min:"1147"`
Gem MaterialList `df2014_version_min:"1147"`
Bones []int16 `df2014_version_min:"1147"`
Shells []int16 `df2014_version_min:"1147"`
Pearls []int16 `df2014_version_min:"1147"`
Ivory []int16 `df2014_version_min:"1147"`
Horn []int16 `df2014_version_min:"1147"`
Other MaterialList `df2014_version_min:"1147"`
SpecialMat0 Material
SpecialMat1 Material
SpecialMat2 Material
Diggers []int16 `df2014_version_min:"1130"`
Weapons []int16 `df2014_version_min:"1130"`
Armor []int16 `df2014_version_min:"1130"`
Ammo []int16 `df2014_version_min:"1130"`
Helms []int16 `df2014_version_min:"1130"`
Gloves []int16 `df2014_version_min:"1130"`
Shoes []int16 `df2014_version_min:"1130"`
Pants []int16 `df2014_version_min:"1130"`
Shields []int16 `df2014_version_min:"1130"`
TrapComps []int16 `df2014_version_min:"1130"`
Toys []int16 `df2014_version_min:"1130"`
Instruments []int16 `df2014_version_min:"1130"`
SiegeAmmo []int16 `df2014_version_min:"1130"`
WeaponMaterials MaterialList
ArmorMaterials MaterialList
/*
ActivityStats *struct {
Stats EntityActivityStatistics
LastCommunicateSeason int16
LastCommunicateYear int32
}
Imports, Exports, Offerings int32
OfferingsHistory [10]int32
HostileLevel, SiegeCount int32
*/
Discoveries EntityDiscoveredMatGlosses
MeatFishRecipes []EntityRecipe
OtherRecipes []EntityRecipe
OwnedItems []int32
/*
MeetingEvents []EntityMeetingEvent
*/
EntityLinks []EntityEntityLink
SiteLinks []EntitySiteLink
FigureIDs []int32
NemesisIDs []int32
ArtImageTypes []int16 `df2014_version_min:"1147"`
ArtImageIDs []int32 `df2014_version_min:"1147"`
ArtImageSubIDs []int16 `df2014_version_min:"1147"`
Uniforms []EntityUniform `df2014_version_min:"1147"`
}
type EntityMaterials struct {
Leather MaterialList
Fiber MaterialList
Silk MaterialList
Wool MaterialList
Craft MaterialList
Unk002 MaterialList
Barrel MaterialList
Flask MaterialList
Quiver MaterialList
Backpack MaterialList
Cage MaterialList
Wood MaterialList
Ore MaterialList
Drink MaterialList
Cheese MaterialList
Powder MaterialList
Extract MaterialList
Meat MaterialList
}
type EntityResources struct {
Fish RaceCasteList
Egg RaceCasteList
Plant MaterialList
Orchard PlantGrowthList
Garden PlantGrowthList
Seed MaterialList
WoodProducts ItemMaterialList
Pet RaceCasteList
Wagon RaceCasteList
PackAnimal RaceCasteList
WagonPuller RaceCasteList
Mount RaceCasteList
Minion RaceCasteList
ExoticPet RaceCasteList
Wood MaterialList
Metal []InorganicIndex
Stone []InorganicIndex
Gem []InorganicIndex
Bone MaterialList
Shell MaterialList
Pearl MaterialList
Ivory MaterialList
Horn MaterialList
Unk004 MaterialList
Sand MaterialList
Glass MaterialList
Clay MaterialList
}
type EntityEntityLinkType uint16
const (
EntityParent EntityEntityLinkType = iota
EntityChild
)
var entityEntityLinkTypes = [...]string{
"parent",
"child",
}
func (i EntityEntityLinkType) prettyPrint(w *WorldDat, buf, indent []byte, outerTag reflect.StructTag) []byte {
buf = strconv.AppendUint(buf, uint64(i), 10)
buf = append(buf, " (0x"...)
buf = strconv.AppendUint(buf, uint64(i), 16)
buf = append(buf, ')')
if int(i) < len(entityEntityLinkTypes) {
buf = append(buf, " ("...)
buf = append(buf, entityEntityLinkTypes[i]...)
buf = append(buf, ')')
}
return buf
}
type EntityEntityLink struct {
Type EntityEntityLinkType
ID uint32
Strength uint16 `df2014_assert_lte:"100"`
}
type EntitySiteLinkType uint16
type EntitySiteLink struct {
Type EntitySiteLinkType
ID uint32
Strength uint16 `df2014_assert_lte:"100"`
}
type EntityUnk143 struct {
Unk000 uint32
Unk001 uint16 // flags?
}
type EntityUnk153 struct {
Unk000 uint32 `df2014_assert_equals:"0x0"`
Unk001 uint16 `df2014_assert_equals:"0x3"`
}
type EntityUnk156 struct {
Unk000 bool `df2014_assert_equals:"true"`
Unk001 int8 `df2014_assert_equals:"-1"`
Unk002 int16 `df2014_assert_equals:"-1"`
}
type EntityUnk157 struct {
Unk000 uint16 `df2014_assert_equals:"0x108"`
Unk001 int16 `df2014_assert_equals:"-1"`
Unk002 uint16 `df2014_assert_equals:"0x4"`
Unk003 int32 `df2014_assert_equals:"-1"`
Unk004 int32 `df2014_assert_equals:"-1"`
}
type EntityUnk251 struct {
Unk000 uint32 `df2014_assert_equals:"0x4"`
Unk001 uint32
Unk002 uint32
Unk003 int32 `df2014_assert_equals:"-1"`
Unk004 uint32
Unk005 int32 `df2014_assert_equals:"-1"`
Unk006 uint32 `df2014_assert_same_as:"Unk004"`
Unk007 int32 `df2014_assert_equals:"-1"`
Unk008 uint32 `df2014_assert_equals:"0x0"`
}
type EntityDiscoveredMatGlosses struct {
CreatureFoods []bool `df2014_key_is_string:"Creature"`
Creatures []bool `df2014_key_is_string:"Creature"`
PlantFoods []bool `df2014_key_is_string:"Plant"`
Plants []bool `df2014_key_is_string:"Plant"`
Trees []bool `df2014_key_is_string:"Tree"`
}
type EntityRecipe struct {
SubType int16
ItemTypes []int16
ItemSubtypes []int16
Materials []int16
MatGlosses []int16
}
type EntityUniform struct {
ID int16
ItemTypes []int16
ItemSubtypes []int16
ItemInfo []EntityUniformItem
}
type EntityUniformItem struct {
RandomDye int8
ArmorLevel int8
ItemColor int16
ArtImageChunk int32
ArtImageID int16
ImageThreadColor int16
ImageMaterialClass int16
MakerRace int16 `df2014_version_min:"1164"`
}