New Game Random Team Placement
Overview
This feature ensures that when starting a new game, the TeamMarker is always randomly placed in a town/village, regardless of whether there are saved positions for the current map seed. The load functionality continues to work as before, preserving the player's saved team position.
How It Works
New Game Flow
- Player clicks "New Game" on title screen
GameStateManager.StartNewGame() is called
- The
isNewGame flag is set to true
- When the map scene loads,
SimpleTeamPlacement checks this flag
- If
isNewGame is true, saved positions are ignored and team is randomly placed
- After placement, the
isNewGame flag is cleared
- The new random position is saved for future loads
Load Game Flow
- Player clicks "Load Game" on title screen
GameStateManager.LoadGame() is called
- The
isNewGame flag is set to false
- When the map scene loads,
SimpleTeamPlacement loads the saved position
- Team is placed at the previously saved location
Key Features
Random Placement Even for Same Seeds
- Even if a new game uses the same seed as a previous game, the team will be randomly placed
- This ensures true randomness for new games while preserving saved positions for loads
Exploration System Support
- The feature works with both regular map mode and exploration system
- In exploration mode, new games will randomly select from available settlements
- Load games in exploration mode will use the saved position
Debug Information
- Enhanced debug logs show whether placement is for a new game or loaded game
- Clear distinction in console output for troubleshooting
Testing
Manual Testing
- Start a new game → Team should be randomly placed
- Save the game and load it → Team should be at same position
- Start another new game with same seed → Team should be at different random position
- Load the saved game again → Team should be at original saved position
Context Menu Testing
Right-click on SimpleTeamPlacement in Inspector and use:
- "Force New Game Random Placement" - Simulates new game behavior
- "Randomly Place Team" - Normal random placement
- "Show Marker Info" - Shows current team position details
Technical Details
Modified Files
GameStateManager.cs: Added isNewGame flag and related methods
SimpleTeamPlacement.cs: Added new game detection logic
Key Methods
GameStateManager.IsNewGameForceRandom(): Checks if random placement should be forced
GameStateManager.ClearNewGameFlag(): Clears flag after initial placement
SimpleTeamPlacement.WaitAndPlaceTeam(): Main placement logic with new game detection
PlayerPrefs Impact
- Saved positions are still stored with map seed keys
- New games overwrite saved positions for their seed
- Load games continue to read from saved positions
Backward Compatibility
- Existing save games continue to work exactly as before
- No changes to save/load data structures
- Feature is transparent to existing gameplay mechanics