@@ -54,6 +54,147 @@ func TestGenerate(t *testing.T) {
5454 "DecalPallet" : nil ,
5555 },
5656 },
57+ {
58+ name : "Object State recursive" ,
59+ inputRoot : map [string ]interface {}{
60+ "SaveName" : "cool mod" ,
61+ "ObjectStates_order" : []interface {}{"parent" },
62+ },
63+ inputLuaSrc : map [string ]string {
64+ "parent/eda22b/childstate2.ttslua" : "var foo = 42\n var foo = 42\n var foo = 42\n var foo = 42\n var foo = 42\n var foo = 42\n var foo = 42\n var foo = 42\n " ,
65+ },
66+ inputOjbs : map [string ]types.J {
67+ "parent.json" : map [string ]interface {}{
68+ "GUID" : "parent" ,
69+ "States_path" : map [string ]interface {}{
70+ "2" : "eda22b" ,
71+ },
72+ "ContainedObjects_path" : "parent" ,
73+ },
74+ "parent/eda22b.json" : map [string ]interface {}{
75+ "GUID" : "eda22b" ,
76+ "Autoraise" : true ,
77+ "ContainedObjects_path" : "eda22b" ,
78+ "ContainedObjects_order" : []string {"childstate2" },
79+ },
80+ "parent/eda22b/childstate2.json" : map [string ]interface {}{
81+ "Description" : "child of state 2" ,
82+ "GUID" : "childstate2" ,
83+ "LuaScript_path" : "parent/eda22b/childstate2.ttslua" ,
84+ },
85+ },
86+ want : map [string ]interface {}{
87+ "SaveName" : "cool mod" ,
88+ "ObjectStates" : []any {
89+ map [string ]any {
90+ "GUID" : "parent" ,
91+ "States" : map [string ]interface {}{
92+ "2" : map [string ]interface {}{
93+ "Autoraise" : true ,
94+ "GUID" : "eda22b" ,
95+ "ContainedObjects" : []any {
96+ map [string ]any {
97+ "Description" : "child of state 2" ,
98+ "GUID" : "childstate2" ,
99+ "LuaScript" : "var foo = 42\n var foo = 42\n var foo = 42\n var foo = 42\n var foo = 42\n var foo = 42\n var foo = 42\n var foo = 42\n " ,
100+ },
101+ },
102+ },
103+ },
104+ },
105+ },
106+ "CameraStates" : nil ,
107+ "ComponentTags" : nil ,
108+ "MusicPlayer" : nil ,
109+ "Sky" : "" ,
110+ "TabStates" : nil ,
111+ "Note" : "" ,
112+ "Table" : "" ,
113+ "LuaScript" : "" ,
114+ "LuaScriptState" : "" ,
115+ "SnapPoints" : nil ,
116+ "XmlUI" : "" ,
117+ "Turns" : nil ,
118+ "VersionNumber" : "" ,
119+ "GameMode" : "" ,
120+ "GameType" : "" ,
121+ "Hands" : nil ,
122+ "Grid" : nil ,
123+ "Lighting" : nil ,
124+ "GameComplexity" : "" ,
125+ "Decals" : nil ,
126+ "CustomUIAssets" : nil ,
127+ "DecalPallet" : nil ,
128+ },
129+ },
130+ {
131+ name : "Object State and contained object generation" ,
132+ inputRoot : map [string ]interface {}{
133+ "SaveName" : "cool mod" ,
134+ "ObjectStates_order" : []interface {}{"parent" },
135+ },
136+ inputLuaSrc : map [string ]string {},
137+ inputOjbs : map [string ]types.J {
138+ "parent.json" : map [string ]interface {}{
139+ "GUID" : "parent" ,
140+ "States_path" : map [string ]interface {}{
141+ "2" : "state2" ,
142+ },
143+ "ContainedObjects_path" : "parent" ,
144+ "ContainedObjects_order" : []string {"co123" },
145+ },
146+ "parent/state2.json" : map [string ]interface {}{
147+ "GUID" : "state2" ,
148+ "Autoraise" : true ,
149+ },
150+ "parent/co123.json" : map [string ]interface {}{
151+ "Description" : "contained object" ,
152+ "GUID" : "co123" ,
153+ },
154+ },
155+ want : map [string ]interface {}{
156+ "SaveName" : "cool mod" ,
157+ "ObjectStates" : []any {
158+ map [string ]any {
159+ "GUID" : "parent" ,
160+ "States" : map [string ]interface {}{
161+ "2" : map [string ]interface {}{
162+ "Autoraise" : true ,
163+ "GUID" : "state2" ,
164+ },
165+ },
166+ "ContainedObjects" : []any {
167+ map [string ]any {
168+ "GUID" : "co123" ,
169+ "Description" : "contained object" ,
170+ },
171+ },
172+ },
173+ },
174+ "CameraStates" : nil ,
175+ "ComponentTags" : nil ,
176+ "MusicPlayer" : nil ,
177+ "Sky" : "" ,
178+ "TabStates" : nil ,
179+ "Note" : "" ,
180+ "Table" : "" ,
181+ "LuaScript" : "" ,
182+ "LuaScriptState" : "" ,
183+ "SnapPoints" : nil ,
184+ "XmlUI" : "" ,
185+ "Turns" : nil ,
186+ "VersionNumber" : "" ,
187+ "GameMode" : "" ,
188+ "GameType" : "" ,
189+ "Hands" : nil ,
190+ "Grid" : nil ,
191+ "Lighting" : nil ,
192+ "GameComplexity" : "" ,
193+ "Decals" : nil ,
194+ "CustomUIAssets" : nil ,
195+ "DecalPallet" : nil ,
196+ },
197+ },
57198 } {
58199 t .Run (tc .name , func (t * testing.T ) {
59200 rootff := & tests.FakeFiles {
0 commit comments