@@ -35,24 +35,22 @@ public class SpreadsheetGenMod : BaseUnityPlugin // Plugin config: "C:\Program
3535 {
3636 public const string pluginGuid = "greyhak.dysonsphereprogram.resourcespreadsheetgen" ;
3737 public const string pluginName = "DSP Star Sector Resource Spreadsheet Generator" ;
38- public const string pluginVersion = "3.1.1 " ;
38+ public const string pluginVersion = "3.1.2 " ;
3939
40- public static BepInEx . Configuration . ConfigEntry < bool > enablePlanetLoadingFlag ;
41- public static bool enableOnStartTrigger = false ;
42- public static bool enableOnPauseTrigger = false ;
4340 public static bool spreadsheetGenRequestFlag = false ;
4441 public static List < PlanetData > planetsToLoad = new List < PlanetData > { } ;
4542 public static Dictionary < int , string > planetResourceData = new Dictionary < int , string > ( ) ;
4643 public static bool checkForPlanetsToUnload = false ;
47- public static BepInEx . Configuration . ConfigEntry < string > spreadsheetFileNameTemplate ;
48- public static BepInEx . Configuration . ConfigEntry < string > spreadsheetColumnSeparator ;
4944 public static CultureInfo spreadsheetLocale = CultureInfo . CurrentUICulture ;
50- public static BepInEx . Configuration . ConfigEntry < int > spreadsheetFloatPrecision ;
5145 new internal static ManualLogSource Logger ;
5246 new internal static BepInEx . Configuration . ConfigFile Config ;
5347 public static readonly int [ ] gases = { 1120 , 1121 , 1011 } ;
5448 public static int planetCount = 0 ;
55-
49+
50+ public static BepInEx . Configuration . ConfigEntry < bool > enablePlanetLoadingFlag ;
51+ public static BepInEx . Configuration . ConfigEntry < string > spreadsheetFileNameTemplate ;
52+ public static BepInEx . Configuration . ConfigEntry < string > spreadsheetColumnSeparator ;
53+ public static BepInEx . Configuration . ConfigEntry < int > spreadsheetFloatPrecision ;
5654 public class ConfigExtraFlags
5755 {
5856 public static BepInEx . Configuration . ConfigEntry < bool > starAge ;
@@ -73,6 +71,7 @@ public class ConfigExtraFlags
7371 public static BepInEx . Configuration . ConfigEntry < bool > planetRotationPeriod ;
7472 public static BepInEx . Configuration . ConfigEntry < bool > planetRotationPhase ;
7573 public static BepInEx . Configuration . ConfigEntry < bool > planetSunDistance ;
74+ public static BepInEx . Configuration . ConfigEntry < bool > veinCounts ;
7675 }
7776
7877 private static Thread veinGenerationThread ;
@@ -114,6 +113,7 @@ public void Awake()
114113 ConfigExtraFlags . planetRotationPeriod = Config . Bind < bool > ( "ExtraData" , "PlanetRotationPeriod" , false , "Add planets' rotation period to the spreadsheet" ) ;
115114 ConfigExtraFlags . planetRotationPhase = Config . Bind < bool > ( "ExtraData" , "PlanetRotationPhase" , false , "Add planets' rotation phase to the spreadsheet" ) ;
116115 ConfigExtraFlags . planetSunDistance = Config . Bind < bool > ( "ExtraData" , "PlanetSunDistance" , false , "Add planets' distance from their star to the spreadsheet" ) ;
116+ ConfigExtraFlags . veinCounts = Config . Bind < bool > ( "ExtraData" , "VeinCounts" , false , "Add the number of veins for each vein resource in addition to the total number of items." ) ;
117117
118118 Config . SettingChanged += OnConfigSettingChanged ;
119119
@@ -140,6 +140,10 @@ public static void OnConfigSettingChanged(object sender, BepInEx.Configuration.S
140140 spreadsheetGenRequestFlag = false ;
141141 planetsToLoad . Clear ( ) ;
142142 planetResourceData . Clear ( ) ;
143+ if ( progressImage != null )
144+ {
145+ progressImage . fillAmount = 0 ;
146+ }
143147 Monitor . Exit ( planetComputeThreadMutexLock ) ;
144148
145149 if ( changedSetting . Section == "Output" && changedSetting . Key == "SpreadsheetLocale" )
@@ -177,7 +181,7 @@ public static void QueuePlanetLoading()
177181 {
178182 foreach ( PlanetData planet in star . planets )
179183 {
180- if ( ! planetResourceData . ContainsKey ( planet . id ) && ( planet . type != EPlanetType . Gas ) && ( planet . veinGroups . Length == 0 ) )
184+ if ( enablePlanetLoadingFlag . Value && ( planet . type != EPlanetType . Gas ) && ( planet . veinGroups . Length == 0 ) && ! planetResourceData . ContainsKey ( planet . id ) )
181185 {
182186 planetsToLoad . Add ( planet ) ;
183187
@@ -369,9 +373,19 @@ public static void GenerateResourceSpreadsheet()
369373 sb . Append ( "Singularity" ) . Append ( spreadsheetColumnSeparator . Value ) ;
370374 sb . Append ( "Ocean" ) . Append ( spreadsheetColumnSeparator . Value ) ;
371375
376+ EVeinType type = ( EVeinType ) 1 ;
372377 foreach ( VeinProto item in LDB . veins . dataArray )
373378 {
374- sb . Append ( item . name ) . Append ( spreadsheetColumnSeparator . Value ) ;
379+ if ( type == EVeinType . Oil || ! ConfigExtraFlags . veinCounts . Value )
380+ {
381+ sb . Append ( item . name ) . Append ( spreadsheetColumnSeparator . Value ) ;
382+ }
383+ else
384+ {
385+ sb . Append ( item . name + " (items)" ) . Append ( spreadsheetColumnSeparator . Value ) ;
386+ sb . Append ( item . name + " (veins)" ) . Append ( spreadsheetColumnSeparator . Value ) ;
387+ }
388+ type ++ ;
375389 }
376390 foreach ( int item in gases )
377391 {
@@ -505,9 +519,15 @@ public static void CapturePlanetResourceData(PlanetData planet, StringBuilder sb
505519 if ( planet . type == EPlanetType . Gas )
506520 {
507521 sb . Append ( "None" ) . Append ( spreadsheetColumnSeparator . Value ) ; // Ocean
522+ EVeinType type = ( EVeinType ) 1 ;
508523 foreach ( VeinProto item in LDB . veins . dataArray )
509524 {
510525 sb . Append ( "0" ) . Append ( spreadsheetColumnSeparator . Value ) ;
526+ if ( type != EVeinType . Oil && ConfigExtraFlags . veinCounts . Value )
527+ {
528+ sb . Append ( "0" ) . Append ( spreadsheetColumnSeparator . Value ) ;
529+ }
530+ type ++ ;
511531 }
512532 foreach ( int item in gases )
513533 {
@@ -540,9 +560,15 @@ public static void CapturePlanetResourceData(PlanetData planet, StringBuilder sb
540560
541561 if ( planet . veinGroups . Length == 0 )
542562 {
563+ EVeinType type = ( EVeinType ) 1 ;
543564 foreach ( VeinProto item in LDB . veins . dataArray )
544565 {
545566 sb . Append ( "Unloaded" ) . Append ( spreadsheetColumnSeparator . Value ) ;
567+ if ( type != EVeinType . Oil && ConfigExtraFlags . veinCounts . Value )
568+ {
569+ sb . Append ( "Unloaded" ) . Append ( spreadsheetColumnSeparator . Value ) ;
570+ }
571+ type ++ ;
546572 }
547573 }
548574 else
@@ -558,6 +584,20 @@ public static void CapturePlanetResourceData(PlanetData planet, StringBuilder sb
558584 else
559585 {
560586 sb . Append ( amount . ToString ( spreadsheetLocale ) ) . Append ( spreadsheetColumnSeparator . Value ) ;
587+
588+ if ( ConfigExtraFlags . veinCounts . Value )
589+ {
590+ long numVeins = 0 ;
591+ foreach ( PlanetData . VeinGroup veinGroup in planet . veinGroups )
592+ {
593+ if ( veinGroup . type == type )
594+ {
595+ numVeins += veinGroup . count ;
596+ }
597+ }
598+
599+ sb . Append ( numVeins . ToString ( spreadsheetLocale ) ) . Append ( spreadsheetColumnSeparator . Value ) ;
600+ }
561601 }
562602 type ++ ;
563603 }
@@ -597,7 +637,7 @@ public static void GameMain_Begin_Prefix()
597637
598638 if ( GameMain . instance != null && GameObject . Find ( "Game Menu/button-1-bg" ) )
599639 {
600- if ( GameObject . Find ( "greyhak-csv-trigger-button" ) )
640+ if ( progressImage != null )
601641 {
602642 progressImage . fillAmount = 0 ;
603643 }
@@ -639,20 +679,6 @@ public static void GameMain_Begin_Prefix()
639679 Logger . LogInfo ( "Button load complete" ) ;
640680 }
641681 }
642-
643- if ( enableOnStartTrigger )
644- {
645- QueuePlanetLoading ( ) ;
646- }
647- }
648-
649- [ HarmonyPrefix , HarmonyPatch ( typeof ( GameMain ) , "Pause" ) ]
650- public static void GameMain_Pause_Prefix ( )
651- {
652- if ( enableOnPauseTrigger )
653- {
654- QueuePlanetLoading ( ) ;
655- }
656682 }
657683
658684 public static Sprite GetSprite ( )
0 commit comments