@@ -127,7 +127,6 @@ public override void OnLoad(ConfigNode node) {
127127 body_data . disabled = Convert . ToBoolean ( node_body . GetValue ( "Disabled" ) ) ;
128128 }
129129 }
130- getSettingsCoverage ( ) ; //Rebuild the settings menu coverage percentages
131130 Resources ( FlightGlobals . currentMainBody ) ;
132131 dataRebuild = false ; //Used for the one-time update to the new integer array
133132 }
@@ -191,28 +190,56 @@ public void Resources(CelestialBody b) //Repopulates the master resources list w
191190 if ( resourceOverlayType == 0 ) {
192191 foreach ( ConfigNode node in GameDatabase . Instance . GetConfigNodes ( "PLANETARY_RESOURCE_DEFINITION" ) ) {
193192 if ( node != null ) {
193+ SCANdata . SCANResource resource = null ; //Setup initial values, get the resource name and celestial body name
194+ double scalar = 1d ;
195+ double Threshold = 1d ;
196+ double mult = 1d ;
197+ bool scale = false ;
198+ string name = node . GetValue ( "name" ) ;
194199 string body = node . GetValue ( "celestialBodyName" ) ;
195- if ( body == b . name ) {
196- string name = node . GetValue ( "name" ) ;
197- double scalar = 1d ;
198- double Threshold = 1d ;
199- double mult = 1d ;
200- bool scale = false ;
201- if ( node . GetValue ( "resourceScale" ) == "LINEAR_SCALE" ) scale = true ;
202- else if ( node . GetValue ( "resourceScale" ) == "LOG_SCALE" ) scale = false ;
203- double . TryParse ( node . GetValue ( "displayThreshold" ) , out Threshold ) ;
204- if ( scale ) {
205- Threshold *= 10 ;
200+ foreach ( SCANdata . SCANResource res in ResourcesList ) { //Check to see if the resource is already in the list
201+ if ( name == res . name ) {
202+ resource = res ;
203+ break ;
206204 }
207- else {
208- Threshold *= 10000 ;
209- double . TryParse ( node . GetValue ( "scaleFactor" ) , out scalar ) ;
205+ }
206+ if ( resource != null ) { //If the resource is already in the list check to see if this node represents the current body and assign values
207+ if ( body == b . name ) {
208+ if ( node . GetValue ( "resourceScale" ) == "LINEAR_SCALE" ) scale = true ;
209+ else if ( node . GetValue ( "resourceScale" ) == "LOG_SCALE" ) scale = false ;
210+ double . TryParse ( node . GetValue ( "displayThreshold" ) , out Threshold ) ;
211+ if ( scale ) {
212+ Threshold *= 10 ;
213+ }
214+ else {
215+ Threshold *= 10000 ;
216+ double . TryParse ( node . GetValue ( "scaleFactor" ) , out scalar ) ;
217+ }
218+ double . TryParse ( node . GetValue ( "scaleMultiplier" ) , out mult ) ;
219+ resource . linear = scale ; //Reassign resource properties with the proper values if this is the current body
220+ resource . ORS_Threshold = Threshold ;
221+ resource . ORS_Scalar = scalar ;
222+ resource . ORS_Multiplier = mult ;
210223 }
211- double . TryParse ( node . GetValue ( "scaleMultiplier" ) , out mult ) ;
224+ }
225+ else { //If the resource isn't in the list check to see if this node is the right celestial body and assign values
212226 Color full = palette . xkcd_PurplyPink ;
213227 Color empty = palette . magenta ;
214228 SCANdata . SCANtype type = OverlayResourceType ( name ) ;
215- ResourcesList . Add ( new SCANdata . SCANResource ( name , full , empty , scale , scalar , mult , Threshold , 1f , type ) ) ;
229+ if ( body == b . name ) {
230+ if ( node . GetValue ( "resourceScale" ) == "LINEAR_SCALE" ) scale = true ;
231+ else if ( node . GetValue ( "resourceScale" ) == "LOG_SCALE" ) scale = false ;
232+ double . TryParse ( node . GetValue ( "displayThreshold" ) , out Threshold ) ;
233+ if ( scale ) {
234+ Threshold *= 10 ;
235+ }
236+ else {
237+ Threshold *= 10000 ;
238+ double . TryParse ( node . GetValue ( "scaleFactor" ) , out scalar ) ;
239+ }
240+ double . TryParse ( node . GetValue ( "scaleMultiplier" ) , out mult ) ;
241+ }
242+ ResourcesList . Add ( new SCANdata . SCANResource ( name , full , empty , scale , scalar , mult , Threshold , 1f , type ) ) ; //Add the resource to the list, with the proper values if applicable
216243 }
217244 }
218245 }
@@ -228,7 +255,15 @@ public void Resources(CelestialBody b) //Repopulates the master resources list w
228255 float max = 1000000f ;
229256 ConfigNode subNode = node . GetNode ( "Generator" ) ;
230257 if ( subNode != null ) {
231- float . TryParse ( subNode . GetValue ( "MaxQuantity" ) , out max ) ;
258+ float . TryParse ( subNode . GetValue ( "MaxQuantity" ) , out max ) ; //Global max quantity
259+ foreach ( ConfigNode bodySubNode in subNode . GetNodes ( "Body" ) ) {
260+ string body = bodySubNode . GetValue ( "name" ) ;
261+ if ( body == b . name )
262+ {
263+ if ( bodySubNode . HasValue ( "MaxQuantity" ) )
264+ float . TryParse ( bodySubNode . GetValue ( "MaxQuantity" ) , out max ) ; //Optional body-specific max quantity
265+ }
266+ }
232267 }
233268 SCANdata . SCANtype type = OverlayResourceType ( name ) ;
234269 ResourcesList . Add ( new SCANdata . SCANResource ( name , full , empty , true , 1d , 1d , 1d , max , type ) ) ;
@@ -250,7 +285,8 @@ public SCANdata.SCANtype OverlayResourceType(string s) //Assign the proper resou
250285 case "Thorium" : return SCANdata . SCANtype . Thorium ;
251286 case "Alumina" : return SCANdata . SCANtype . Alumina ;
252287 case "Water" : return SCANdata . SCANtype . Water ;
253- case "Ore" : return SCANdata . SCANtype . Ore_ORS ;
288+ case "Aquifer" : return SCANdata . SCANtype . Aquifer ;
289+ case "Ore" : return SCANdata . SCANtype . Ore ;
254290 case "Minerals" : return SCANdata . SCANtype . Minerals ;
255291 case "Substrate" : return SCANdata . SCANtype . Substrate ;
256292 case "KEEZO" : return SCANdata . SCANtype . KEEZO ;
@@ -262,6 +298,9 @@ public SCANdata.SCANtype OverlayResourceType(string s) //Assign the proper resou
262298 {
263299 case "Kethane" : return SCANdata . SCANtype . Kethane ;
264300 case "Ore" : return SCANdata . SCANtype . Ore ;
301+ case "Water" : return SCANdata . SCANtype . Water ;
302+ case "Minerals" : return SCANdata . SCANtype . Minerals ;
303+ case "Substrate" : return SCANdata . SCANtype . Substrate ;
265304 default : return SCANdata . SCANtype . Nothing ;
266305 }
267306 }
@@ -432,14 +471,6 @@ public SCANdata getData(CelestialBody body) {
432471 return data ;
433472 }
434473
435- public void getSettingsCoverage ( ) //This handles the scanning coverage value in the settings menu
436- {
437- foreach ( CelestialBody body in FlightGlobals . Bodies ) {
438- SCANdata data = getData ( body ) ;
439- data . coveragePercentage = data . getCoveragePercentage ( SCANdata . SCANtype . Nothing ) ;
440- }
441- }
442-
443474 //public void registerPass(CelestialBody body, float lon, float lat, SCANdata.SCANtype type) {
444475 // getData(body).registerPass(lon, lat, type);
445476 //}
0 commit comments