1
1
using Distance . CustomCar . Data . Materials ;
2
- using Reactor . API ;
3
- using Reactor . API . Storage ;
4
2
using System ;
5
3
using System . Collections . Generic ;
6
4
using System . IO ;
@@ -24,7 +22,7 @@ public void CreateCars(CarInfos infos)
24
22
{
25
23
try
26
24
{
27
- Mod . Instance . Logger . Info ( $ "Creating car prefab for { car . Key } ...") ;
25
+ Mod . Log . LogInfo ( $ "Creating car prefab for { car . Key } ...") ;
28
26
CreateCarReturnInfos data = CreateCar ( car . Value ) ;
29
27
30
28
string fileName = Path . GetFileNameWithoutExtension ( car . Key . Substring ( 0 , car . Key . LastIndexOf ( '(' ) - 1 ) ) ;
@@ -34,6 +32,7 @@ public void CreateCars(CarInfos infos)
34
32
}
35
33
catch ( Exception ex )
36
34
{
35
+ Mod . Log . LogInfo ( $ "Could not load car prefab: { car . Key } ") ;
37
36
Mod . Instance . Errors . Add ( $ "Could not load car prefab: { car . Key } ") ;
38
37
Mod . Instance . Errors . Add ( ex ) ;
39
38
}
@@ -44,7 +43,7 @@ public void CreateCars(CarInfos infos)
44
43
45
44
private void RegisterCars ( List < CreateCarReturnInfos > carsInfos )
46
45
{
47
- Mod . Instance . Logger . Info ( $ "Registering { carsInfos . Count } car(s)...") ;
46
+ Mod . Log . LogInfo ( $ "Registering { carsInfos . Count } car(s)...") ;
48
47
49
48
ProfileManager profileManager = G . Sys . ProfileManager_ ;
50
49
CarInfo [ ] oldCars = profileManager . carInfos_ . ToArray ( ) ;
@@ -81,10 +80,10 @@ private void RegisterCars(List<CreateCarReturnInfos> carsInfos)
81
80
else
82
81
{
83
82
Mod . Instance . Errors . Add ( $ "A car with the name { car . name_ } is already registered, rename the car file if they're the same.") ;
84
- Mod . Instance . Logger . Warning ( $ "Generating unique name for car { car . name_ } ") ;
83
+ Mod . Log . LogInfo ( $ "Generating unique name for car { car . name_ } ") ;
85
84
86
85
string uniqueID = $ "#{ Guid . NewGuid ( ) : B} ";
87
- Mod . Instance . Logger . Info ( $ "Using GUID: { uniqueID } ") ;
86
+ Mod . Log . LogInfo ( $ "Using GUID: { uniqueID } ") ;
88
87
89
88
car . name_ = $ "[FFFF00]![-] { car . name_ } { uniqueID } ";
90
89
@@ -118,7 +117,7 @@ private void RegisterCars(List<CreateCarReturnInfos> carsInfos)
118
117
private Dictionary < string , GameObject > LoadAssetsBundles ( )
119
118
{
120
119
Dictionary < string , GameObject > assetsList = new Dictionary < string , GameObject > ( ) ;
121
- DirectoryInfo assetsDirectory = GetLocalFolder ( Defaults . PrivateAssetsDirectory ) ;
120
+ DirectoryInfo assetsDirectory = GetLocalFolder ( "Assets" ) ;
122
121
DirectoryInfo globalCarsDirectory = new DirectoryInfo ( Path . Combine ( Resource . personalDistanceDirPath_ , "CustomCars" ) ) ;
123
122
124
123
if ( ! globalCarsDirectory . Exists )
@@ -130,7 +129,9 @@ private Dictionary<string, GameObject> LoadAssetsBundles()
130
129
catch ( Exception ex )
131
130
{
132
131
Mod . Instance . Errors . Add ( $ "Could not create the following folder: { globalCarsDirectory . FullName } ") ;
132
+ Mod . Log . LogInfo ( $ "Could not create the following folder: { globalCarsDirectory . FullName } ") ;
133
133
Mod . Instance . Errors . Add ( ex ) ;
134
+ Mod . Log . LogInfo ( ex ) ;
134
135
}
135
136
}
136
137
@@ -140,6 +141,7 @@ private Dictionary<string, GameObject> LoadAssetsBundles()
140
141
{
141
142
Assets assets = Assets . FromUnsafePath ( assetsFile . FullName ) ;
142
143
AssetBundle bundle = assets . Bundle as AssetBundle ;
144
+
143
145
144
146
int foundPrefabCount = 0 ;
145
147
@@ -159,12 +161,15 @@ private Dictionary<string, GameObject> LoadAssetsBundles()
159
161
if ( foundPrefabCount == 0 )
160
162
{
161
163
Mod . Instance . Errors . Add ( $ "Can't find a prefab in the asset bundle: { assetsFile . FullName } ") ;
164
+ Mod . Log . LogInfo ( $ "Can't find a prefab in the asset bundle: { assetsFile . FullName } ") ;
162
165
}
163
166
}
164
167
catch ( Exception ex )
165
168
{
166
169
Mod . Instance . Errors . Add ( $ "Could not load assets file: { assetsFile . FullName } ") ;
170
+ Mod . Log . LogInfo ( $ "Could not load assets file: { assetsFile . FullName } ") ;
167
171
Mod . Instance . Errors . Add ( ex ) ;
172
+ Mod . Log . LogInfo ( ex ) ;
168
173
}
169
174
}
170
175
@@ -211,12 +216,14 @@ private void RemoveOldCar(GameObject obj)
211
216
if ( wheelsToRemove . Count != 4 )
212
217
{
213
218
Mod . Instance . Errors . Add ( $ "Found { wheelsToRemove . Count } wheels on base prefabs, expected 4") ;
219
+ Mod . Log . LogInfo ( $ "Found { wheelsToRemove . Count } wheels on base prefabs, expected 4") ;
214
220
}
215
221
216
222
Transform refractor = obj . transform . Find ( "Refractor" ) ;
217
223
if ( refractor == null )
218
224
{
219
225
Mod . Instance . Errors . Add ( "Can't find the Refractor object on the base car prefab" ) ;
226
+ Mod . Log . LogInfo ( "Can't find the Refractor object on the base car prefab" ) ;
220
227
return ;
221
228
}
222
229
@@ -243,6 +250,7 @@ private void SetColorChanger(ColorChanger colorChanger, GameObject car)
243
250
if ( colorChanger == null )
244
251
{
245
252
Mod . Instance . Errors . Add ( "Can't find the ColorChanger component on the base car" ) ;
253
+ Mod . Log . LogInfo ( "Can't find the ColorChanger component on the base car" ) ;
246
254
return ;
247
255
}
248
256
@@ -280,6 +288,7 @@ private void ReplaceMaterials(Renderer renderer)
280
288
if ( ! infos_ . materials . TryGetValue ( materialNames [ materialIndex ] , out MaterialInfos materialInfo ) )
281
289
{
282
290
Mod . Instance . Errors . Add ( $ "Can't find the material { materialNames [ materialIndex ] } on { renderer . gameObject . FullName ( ) } ") ;
291
+ Mod . Log . LogInfo ( $ "Can't find the material { materialNames [ materialIndex ] } on { renderer . gameObject . FullName ( ) } ") ;
283
292
continue ;
284
293
}
285
294
@@ -339,12 +348,14 @@ private void FillMaterialInfos(Renderer renderer, string[] matNames, List<Materi
339
348
if ( arguments . Length != 3 )
340
349
{
341
350
Mod . Instance . Errors . Add ( $ "{ arguments [ 0 ] } property on { renderer . gameObject . FullName ( ) } must have 2 arguments") ;
351
+ Mod . Log . LogInfo ( $ "{ arguments [ 0 ] } property on { renderer . gameObject . FullName ( ) } must have 2 arguments") ;
342
352
continue ;
343
353
}
344
354
345
355
if ( ! int . TryParse ( arguments [ 1 ] , out int index ) )
346
356
{
347
357
Mod . Instance . Errors . Add ( $ "First argument of { arguments [ 0 ] } on { renderer . gameObject . FullName ( ) } property must be a number") ;
358
+ Mod . Log . LogInfo ( $ "First argument of { arguments [ 0 ] } on { renderer . gameObject . FullName ( ) } property must be a number") ;
348
359
continue ;
349
360
}
350
361
@@ -358,12 +369,14 @@ private void FillMaterialInfos(Renderer renderer, string[] matNames, List<Materi
358
369
if ( arguments . Length != 5 )
359
370
{
360
371
Mod . Instance . Errors . Add ( $ "{ arguments [ 0 ] } property on { renderer . gameObject . FullName ( ) } must have 4 arguments") ;
372
+ Mod . Log . LogInfo ( $ "{ arguments [ 0 ] } property on { renderer . gameObject . FullName ( ) } must have 4 arguments") ;
361
373
continue ;
362
374
}
363
375
364
376
if ( ! int . TryParse ( arguments [ 1 ] , out int index ) )
365
377
{
366
378
Mod . Instance . Errors . Add ( $ "First argument of { arguments [ 0 ] } on { renderer . gameObject . FullName ( ) } property must be a number") ;
379
+ Mod . Log . LogInfo ( $ "First argument of { arguments [ 0 ] } on { renderer . gameObject . FullName ( ) } property must be a number") ;
367
380
continue ;
368
381
}
369
382
@@ -388,6 +401,7 @@ private void FillMaterialInfos(Renderer renderer, string[] matNames, List<Materi
388
401
if ( ! found )
389
402
{
390
403
Mod . Instance . Errors . Add ( $ "The property { arguments [ 2 ] } on { renderer . gameObject . FullName ( ) } is not valid") ;
404
+ Mod . Log . LogInfo ( $ "The property { arguments [ 2 ] } on { renderer . gameObject . FullName ( ) } is not valid") ;
391
405
continue ;
392
406
}
393
407
@@ -490,6 +504,7 @@ private void AddMaterialColorChanger(ColorChanger colorChanger, Transform transf
490
504
if ( arguments . Length != 6 )
491
505
{
492
506
Mod . Instance . Errors . Add ( $ "{ arguments [ 0 ] } property on { transform . gameObject . FullName ( ) } must have 5 arguments") ;
507
+ Mod . Log . LogInfo ( $ "{ arguments [ 0 ] } property on { transform . gameObject . FullName ( ) } must have 5 arguments") ;
493
508
continue ;
494
509
}
495
510
@@ -565,6 +580,7 @@ private void SetCarVisuals(CarVisuals visuals, GameObject car)
565
580
if ( visuals == null )
566
581
{
567
582
Mod . Instance . Errors . Add ( "Can't find the CarVisuals component on the base car" ) ;
583
+ Mod . Log . LogInfo ( "Can't find the CarVisuals component on the base car" ) ;
568
584
return ;
569
585
}
570
586
@@ -591,12 +607,14 @@ private void MakeMeshSkinned(SkinnedMeshRenderer renderer)
591
607
if ( mesh == null )
592
608
{
593
609
Mod . Instance . Errors . Add ( $ "The mesh on { renderer . gameObject . FullName ( ) } is null") ;
610
+ Mod . Log . LogInfo ( $ "The mesh on { renderer . gameObject . FullName ( ) } is null") ;
594
611
return ;
595
612
}
596
613
597
614
if ( ! mesh . isReadable )
598
615
{
599
616
Mod . Instance . Errors . Add ( $ "Can't read the car mesh { mesh . name } on { renderer . gameObject . FullName ( ) } You must allow reading on it's unity inspector !") ;
617
+ Mod . Log . LogInfo ( $ "Can't read the car mesh { mesh . name } on { renderer . gameObject . FullName ( ) } You must allow reading on it's unity inspector !") ;
600
618
return ;
601
619
}
602
620
0 commit comments