@@ -6,6 +6,7 @@ using System;
66using System . IO ;
77using System . Collections ;
88using System . Collections . Generic ;
9+ using System . Collections . Concurrent ;
910using System . Linq ;
1011using System . Text ;
1112using System . Threading ;
@@ -28,8 +29,8 @@ foreach (DirectoryInfo di in dir.GetDirectories())
2829
2930string exportedTexturesFolder = Path . Combine ( dir . FullName , "Textures" ) ;
3031TextureWorker worker = null ;
31- Dictionary < string , int [ ] > assetCoordinateDict = new ( ) ;
32- Dictionary < string , string > assetTypeDict = new ( ) ;
32+ ConcurrentDictionary < string , int [ ] > assetCoordinateDict = new ( ) ;
33+ ConcurrentDictionary < string , string > assetTypeDict = new ( ) ;
3334using ( worker = new ( ) )
3435{
3536 Directory . CreateDirectory ( exportedTexturesFolder ) ;
@@ -70,8 +71,8 @@ void DumpSprite(UndertaleSprite sprite)
7071 {
7172 UndertaleTexturePageItem tex = sprite . Textures [ i ] . Texture ;
7273 worker . ExportAsPNG ( tex , Path . Combine ( exportedTexturesFolder , $ "{ sprite . Name . Content } _{ i } .png") ) ;
73- assetCoordinateDict . Add ( $ "{ sprite . Name . Content } _{ i } ", new int [ ] { tex . TargetX , tex . TargetY , tex . SourceWidth , tex . SourceHeight , tex . TargetWidth , tex . TargetHeight , tex . BoundingWidth , tex . BoundingHeight } ) ;
74- assetTypeDict . Add ( $ "{ sprite . Name . Content } _{ i } ", "spr" ) ;
74+ assetCoordinateDict . TryAdd ( $ "{ sprite . Name . Content } _{ i } ", new int [ ] { tex . TargetX , tex . TargetY , tex . SourceWidth , tex . SourceHeight , tex . TargetWidth , tex . TargetHeight , tex . BoundingWidth , tex . BoundingHeight } ) ;
75+ assetTypeDict . TryAdd ( $ "{ sprite . Name . Content } _{ i } ", "spr" ) ;
7576 }
7677 }
7778 }
@@ -87,8 +88,8 @@ void DumpFont(UndertaleFont font)
8788 {
8889 UndertaleTexturePageItem tex = font . Texture ;
8990 worker . ExportAsPNG ( tex , Path . Combine ( exportedTexturesFolder , $ "{ font . Name . Content } .png") ) ;
90- assetCoordinateDict . Add ( font . Name . Content , new int [ ] { tex . TargetX , tex . TargetY , tex . SourceWidth , tex . SourceHeight , tex . TargetWidth , tex . TargetHeight , tex . BoundingWidth , tex . BoundingHeight } ) ;
91- assetTypeDict . Add ( font . Name . Content , "fnt" ) ;
91+ assetCoordinateDict . TryAdd ( font . Name . Content , new int [ ] { tex . TargetX , tex . TargetY , tex . SourceWidth , tex . SourceHeight , tex . TargetWidth , tex . TargetHeight , tex . BoundingWidth , tex . BoundingHeight } ) ;
92+ assetTypeDict . TryAdd ( font . Name . Content , "fnt" ) ;
9293
9394 IncrementProgressParallel ( ) ;
9495 }
@@ -102,8 +103,8 @@ void DumpBackground(UndertaleBackground background)
102103 {
103104 UndertaleTexturePageItem tex = background . Texture ;
104105 worker . ExportAsPNG ( tex , Path . Combine ( exportedTexturesFolder , $ "{ background . Name . Content } .png") ) ;
105- assetCoordinateDict . Add ( background . Name . Content , new int [ ] { tex . TargetX , tex . TargetY , tex . SourceWidth , tex . SourceHeight , tex . TargetWidth , tex . TargetHeight , tex . BoundingWidth , tex . BoundingHeight } ) ;
106- assetTypeDict . Add ( background . Name . Content , "bg" ) ;
106+ assetCoordinateDict . TryAdd ( background . Name . Content , new int [ ] { tex . TargetX , tex . TargetY , tex . SourceWidth , tex . SourceHeight , tex . TargetWidth , tex . TargetHeight , tex . BoundingWidth , tex . BoundingHeight } ) ;
107+ assetTypeDict . TryAdd ( background . Name . Content , "bg" ) ;
107108 IncrementProgressParallel ( ) ;
108109 }
109110}
0 commit comments