Skip to content

Commit 64b1b44

Browse files
committed
initial dual stations prototype
1 parent d0976e2 commit 64b1b44

4 files changed

Lines changed: 41 additions & 16 deletions

File tree

Content.Server/GameTicking/GameTicker.RoundFlow.cs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ public bool CanUpdateMap()
9494
/// </remarks>
9595
private void LoadMaps()
9696
{
97-
if (_map.MapExists(DefaultMap))
98-
return;
97+
/* if (_map.MapExists(DefaultMap))
98+
return; */
9999

100100
AddGamePresetRules();
101101

@@ -113,9 +113,18 @@ private void LoadMaps()
113113

114114
// Small chance the above could return no map.
115115
// ideally SelectMapByConfigRules will always find a valid map
116+
//starlight start
117+
var defaultMaps = new List<GameMapPrototype>();
116118
if (mainStationMap != null)
117119
{
120+
var elligibleMaps = _gameMapManager.CurrentlyEligibleMaps();
121+
//select a random
122+
var selected = _robustRandom.Pick(elligibleMaps.ToList());
118123
maps.Add(mainStationMap);
124+
maps.Add(selected);
125+
defaultMaps.Add(mainStationMap);
126+
defaultMaps.Add(selected);
127+
//starlight end
119128
}
120129
else
121130
{
@@ -139,7 +148,8 @@ private void LoadMaps()
139148
if (maps.Count == 0)
140149
{
141150
_map.CreateMap(out var mapId, runMapInit: false);
142-
DefaultMap = mapId;
151+
//starlight
152+
DefaultMap.Add(mapId);
143153
return;
144154
}
145155

@@ -148,8 +158,11 @@ private void LoadMaps()
148158
LoadGameMap(maps[i], out var mapId);
149159
DebugTools.Assert(!_map.IsInitialized(mapId));
150160

151-
if (i == 0)
152-
DefaultMap = mapId;
161+
//starlight account for list format
162+
if (defaultMaps.Contains(maps[i]))
163+
{
164+
DefaultMap.Add(mapId);
165+
}
153166
}
154167
}
155168

@@ -419,7 +432,11 @@ public void StartRound(bool force = false)
419432
}
420433

421434
// MapInitialize *before* spawning players, our codebase is too shit to do it afterwards...
422-
_map.InitializeMap(DefaultMap);
435+
//starlight for each loop
436+
foreach (var map in DefaultMap)
437+
{
438+
_map.InitializeMap(map);
439+
}
423440

424441
SpawnPlayers(readyPlayers, readyPlayerIds, force);
425442

Content.Server/GameTicking/GameTicker.Spawning.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,11 +568,15 @@ public EntityCoordinates GetObserverSpawnPoint()
568568
return spawn;
569569
}
570570

571-
if (_map.MapExists(DefaultMap))
571+
//starlight for loop added
572+
foreach (var map in DefaultMap)
572573
{
573-
var mapUid = _map.GetMapOrInvalid(DefaultMap);
574-
if (!TerminatingOrDeleted(mapUid))
575-
return new EntityCoordinates(mapUid, Vector2.Zero);
574+
if (_map.MapExists(map))
575+
{
576+
var mapUid = _map.GetMapOrInvalid(map);
577+
if (!TerminatingOrDeleted(mapUid))
578+
return new EntityCoordinates(mapUid, Vector2.Zero);
579+
}
576580
}
577581

578582
// Just pick a point at this point I guess.

Content.Server/GameTicking/GameTicker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public sealed partial class GameTicker : SharedGameTicker
7171
[ViewVariables] private bool _initialized;
7272
[ViewVariables] private bool _postInitialized;
7373

74-
[ViewVariables] public MapId DefaultMap { get; private set; }
74+
[ViewVariables] public List<MapId> DefaultMap = new(); //starlight, made into a list
7575

7676
private ISawmill _sawmill = default!;
7777

Content.Server/Worldgen/Systems/WorldgenConfigSystem.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,17 @@ private void OnLoadingMaps(RoundStartingEvent ev)
7373
if (_enabled == false)
7474
return;
7575

76-
var target = _map.GetMapOrInvalid(_gameTicker.DefaultMap);
77-
Log.Debug($"Trying to configure {_gameTicker.DefaultMap}, aka {ToPrettyString(target)} aka {target}");
78-
var cfg = _proto.Index<WorldgenConfigPrototype>(_worldgenConfig);
76+
//starlight, foreach loop added
77+
foreach (var map in _gameTicker.DefaultMap)
78+
{
79+
var target = _map.GetMapOrInvalid(map);
80+
Log.Debug($"Trying to configure {map}, aka {ToPrettyString(target)} aka {target}");
81+
var cfg = _proto.Index<WorldgenConfigPrototype>(_worldgenConfig);
7982

80-
cfg.Apply(target, _ser, EntityManager); // Apply the config to the map.
83+
cfg.Apply(target, _ser, EntityManager); // Apply the config to the map.
8184

82-
DebugTools.Assert(HasComp<WorldControllerComponent>(target));
85+
DebugTools.Assert(HasComp<WorldControllerComponent>(target));
86+
}
8387
}
8488
}
8589

0 commit comments

Comments
 (0)