@@ -86,6 +86,18 @@ public SDShape(STFReader stf)
8686 new STFReader . TokenProcessor ( "esd_ortsbellanimationfps" , ( ) => { ESD_CustomAnimationFPS = stf . ReadFloatBlock ( STFReader . UNITS . Frequency , null ) ; } ) ,
8787 new STFReader . TokenProcessor ( "esd_ortscustomanimationfps" , ( ) => { ESD_CustomAnimationFPS = stf . ReadFloatBlock ( STFReader . UNITS . Frequency , null ) ; } ) ,
8888 new STFReader . TokenProcessor ( "esd_ortstexturereplacement" , ( ) => { ParseReplacementStrings ( stf , ref ESD_TextureReplacement ) ; } ) ,
89+ new STFReader . TokenProcessor ( "esd_ortsshaderreplacement" , ( ) => {
90+ stf . MustMatch ( "(" ) ;
91+ // Allow for multiple pairs of replaced and replacement values
92+ while ( ! stf . EndOfBlock ( ) )
93+ {
94+ int replacedIdx = stf . ReadInt ( - 1 ) ;
95+ string replacement = stf . ReadString ( ) ;
96+ // Add pair of values so long as we haven't reached the end of block
97+ if ( ! string . IsNullOrEmpty ( replacement ) && ! ESD_ShaderReplacement . ContainsKey ( replacedIdx ) )
98+ ESD_ShaderReplacement . Add ( replacedIdx , replacement ) ;
99+ }
100+ } ) ,
89101 new STFReader . TokenProcessor ( "esd_ortsmatrixrename" , ( ) => { ParseReplacementStrings ( stf , ref ESD_MatrixRename ) ; } ) ,
90102 new STFReader . TokenProcessor ( "esd_ortsmatrixparent" , ( ) => { ParseReplacementStrings ( stf , ref ESD_MatrixParent ) ; } ) ,
91103 new STFReader . TokenProcessor ( "esd_ortsmatrixtranslation" , ( ) => { ParseMatrixOverride ( STFReader . UNITS . Distance , stf , ref ESD_MatrixTranslation ) ; } ) ,
@@ -96,11 +108,11 @@ public SDShape(STFReader stf)
96108 // Allow for multiple pairs of replaced and replacement values
97109 while ( ! stf . EndOfBlock ( ) )
98110 {
99- int replaced = stf . ReadInt ( null ) ;
111+ int replacedIdx = stf . ReadInt ( null ) ;
100112 float replacement = stf . ReadFloat ( STFReader . UNITS . Distance , null ) ;
101113 // Add pair of values so long as we haven't reached the end of block
102- if ( replacement != 0 )
103- ESD_LODOverride . Add ( replaced , replacement ) ;
114+ if ( replacement != 0 && ! ESD_LODOverride . ContainsKey ( replacedIdx ) )
115+ ESD_LODOverride . Add ( replacedIdx , replacement ) ;
104116 }
105117 } ) ,
106118 } ) ;
@@ -127,6 +139,8 @@ public SDShape(STFReader stf)
127139 public float ESD_CustomAnimationFPS = 8 ;
128140 // Dictionary of <original texture name, replacement texture name>
129141 public Dictionary < string , string > ESD_TextureReplacement = new Dictionary < string , string > ( ) ;
142+ // Dictionary of <shader index, shader name>
143+ public Dictionary < int , string > ESD_ShaderReplacement = new Dictionary < int , string > ( ) ;
130144 // Dictionary of <original matrix name, replacement matrix name>
131145 public Dictionary < string , string > ESD_MatrixRename = new Dictionary < string , string > ( ) ;
132146 // Dictionary of <matrix name, new matrix parent name>
@@ -152,22 +166,23 @@ protected void ParseReplacementStrings(STFReader stf, ref Dictionary<string, str
152166 string replaced = stf . ReadString ( ) ;
153167 string replacement = stf . ReadString ( ) ;
154168 // Add pair of values so long as we haven't reached the end of block
155- if ( replaced != ")" && replacement != ")" )
169+ if ( replaced != ")" && replacement != ")" && ! renamePairs . ContainsKey ( replaced ) )
156170 renamePairs . Add ( replaced , replacement ) ;
157171 }
158172 }
159173
160174 // Handle matrix adjustment parameters
161175 protected void ParseMatrixOverride ( STFReader . UNITS units , STFReader stf , ref Dictionary < string , Vector3 > matrixParams )
162176 {
163- Vector3 data = new Vector3 ( 0 ) ;
177+ Vector3 data = Vector3 . Zero ;
164178
165179 stf . MustMatch ( "(" ) ;
166180 string matName = stf . ReadString ( ) ;
167181 data = stf . ReadVector3 ( units , Vector3 . Zero ) ;
168182 stf . SkipRestOfBlock ( ) ;
169183
170- matrixParams . Add ( matName , data ) ;
184+ if ( ! matrixParams . ContainsKey ( matName ) )
185+ matrixParams . Add ( matName , data ) ;
171186 }
172187 }
173188
0 commit comments