1
- using OpenTS2 . Content . DBPF ;
1
+ using OpenTS2 . Common ;
2
+ using OpenTS2 . Content ;
3
+ using OpenTS2 . Content . DBPF ;
2
4
using OpenTS2 . Files . Formats . DBPF ;
5
+ using OpenTS2 . Lua . Disassembly . OpCodes ;
3
6
using System ;
4
7
using System . Collections . Generic ;
5
8
using System . Linq ;
@@ -21,6 +24,7 @@ public class VMEntity
21
24
public VM VM ;
22
25
public ObjectDefinitionAsset ObjectDefinition ;
23
26
public short [ ] Attributes ;
27
+ public short [ ] SemiAttributes ;
24
28
public short [ ] ObjectData = new short [ 114 ] ;
25
29
public uint PrivateGroupID => ObjectDefinition . GlobalTGI . GroupID ;
26
30
public uint SemiGlobalGroupID
@@ -42,7 +46,30 @@ protected VMEntity()
42
46
public VMEntity ( ObjectDefinitionAsset objectDefinition ) : this ( )
43
47
{
44
48
ObjectDefinition = objectDefinition ;
45
- Attributes = new short [ objectDefinition . NumAttributes ] ;
49
+ Attributes = new short [ GetNumberOfAttributes ( ) ] ;
50
+ SemiAttributes = new short [ GetNumberOfSemiGlobalAttributes ( ) ] ;
51
+ }
52
+
53
+ // TODO: Verify these two methods below are right. Sometimes objdefs have 0 attributes but do have attribute labels and get/set their attributes.
54
+ private int GetNumberOfAttributes ( )
55
+ {
56
+ var objDefAttributes = ObjectDefinition . NumAttributes ;
57
+ var attrLabels = ContentManager . Instance . GetAsset < StringSetAsset > ( new ResourceKey ( 0x100 , PrivateGroupID , TypeIDs . STR ) ) ;
58
+ if ( attrLabels == null )
59
+ return objDefAttributes ;
60
+ var attrLabelsCount = attrLabels . StringData . Strings [ Languages . USEnglish ] . Count ;
61
+ return attrLabelsCount > objDefAttributes ? attrLabelsCount : objDefAttributes ;
62
+ }
63
+
64
+ private int GetNumberOfSemiGlobalAttributes ( )
65
+ {
66
+ var semiGlobal = ObjectDefinition . SemiGlobal ;
67
+ if ( semiGlobal == null )
68
+ return 0 ;
69
+ var semiAttributeLabels = ContentManager . Instance . GetAsset < StringSetAsset > ( new ResourceKey ( 0x100 , semiGlobal . SemiGlobalGroupID , TypeIDs . STR ) ) ;
70
+ if ( semiAttributeLabels == null )
71
+ return 0 ;
72
+ return semiAttributeLabels . StringData . Strings [ Languages . USEnglish ] . Count ;
46
73
}
47
74
48
75
public short GetObjectData ( VMObjectData field )
0 commit comments