1+ using System . Collections . Generic ;
2+ using System . Linq ;
13using System . Threading . Tasks ;
24using FunkEngine ;
35using Godot ;
4- using GodotSteam ;
56
67/**
78 * <summary>StageProducer: Handles scene transitions and persistent gameplay data.</summary>
@@ -14,6 +15,7 @@ public partial class StageProducer : Node
1415 public static readonly RandomNumberGenerator GlobalRng = new ( ) ;
1516
1617 public static MapLevels CurLevel { get ; private set ; }
18+ public static List < int > BattlePool { get ; private set ; }
1719
1820 public static MapGrid Map { get ; private set ; } = new ( ) ;
1921 private Stages _curStage = Stages . Title ;
@@ -70,6 +72,8 @@ private void StartNewGame()
7072 PlayerStats = new PlayerStats ( ) ;
7173
7274 CurRoom = Map . GetRooms ( ) [ 0 ] . Idx ;
75+ BattlePool = null ;
76+ EventScene . EventPool = null ;
7377 Scribe . InitRelicPools ( ) ;
7478 IsInitialized = true ;
7579 }
@@ -84,6 +88,8 @@ private bool LoadGame()
8488 }
8589 GlobalRng . Seed = sv . RngSeed ;
8690 CurLevel = MapLevels . GetLevelFromId ( sv . Area ) ;
91+ BattlePool = sv . BattlePool . ToList ( ) ;
92+ EventScene . EventPool = sv . EventPool . ToList ( ) ;
8793 GenerateMapConsistent ( ) ;
8894 GlobalRng . State = sv . RngState ;
8995 CurRoom = sv . LastRoomIdx ;
@@ -216,6 +222,16 @@ public void TransitionStage(Stages nextStage, int nextRoomIdx = -1)
216222 }
217223 #endregion
218224
225+ private void RefreshBattlePool ( )
226+ {
227+ BattlePool = new List < int > ( CurLevel . NormalBattles ) ;
228+ for ( int i = 0 ; i < BattlePool . Count - 2 ; i ++ )
229+ {
230+ int randIdx = GlobalRng . RandiRange ( 0 , CurLevel . NormalBattles . Length - 1 ) ;
231+ ( BattlePool [ i ] , BattlePool [ randIdx ] ) = ( BattlePool [ randIdx ] , BattlePool [ i ] ) ; //rad
232+ }
233+ }
234+
219235 private BattleConfig MakeBattleConfig ( Stages nextRoom , int nextRoomIdx )
220236 {
221237 BattleConfig result = new BattleConfig
@@ -228,11 +244,12 @@ private BattleConfig MakeBattleConfig(Stages nextRoom, int nextRoomIdx)
228244 switch ( nextRoom )
229245 {
230246 case Stages . Battle :
231- int songIdx = stageRng . RandiRange ( 0 , CurLevel . NormalBattles . Length - 1 ) ;
232- result . CurSong = Scribe . SongDictionary [ CurLevel . NormalBattles [ songIdx ] ] ;
233- result . EnemyScenePath = Scribe
234- . SongDictionary [ CurLevel . NormalBattles [ songIdx ] ]
235- . EnemyScenePath ;
247+ if ( BattlePool == null || BattlePool . Count == 0 )
248+ RefreshBattlePool ( ) ;
249+ int songIdx = stageRng . RandiRange ( 0 , BattlePool . Count - 1 ) ;
250+ result . CurSong = Scribe . SongDictionary [ BattlePool [ songIdx ] ] ;
251+ result . EnemyScenePath = Scribe . SongDictionary [ BattlePool [ songIdx ] ] . EnemyScenePath ;
252+ BattlePool . RemoveAt ( songIdx ) ;
236253 break ;
237254 case Stages . Elite :
238255 int elitIdx = stageRng . RandiRange ( 0 , CurLevel . EliteBattles . Length - 1 ) ;
@@ -291,6 +308,7 @@ public void ProgressLevels()
291308 Map = new ( ) ;
292309 GenerateMapConsistent ( ) ;
293310 CurRoom = Map . GetRooms ( ) [ 0 ] . Idx ;
311+ BattlePool = null ;
294312 }
295313
296314 #endregion
0 commit comments