level seeds
This commit is contained in:
@@ -113,15 +113,15 @@ namespace Subsurface
|
||||
|
||||
public void StartShift(TimeSpan duration, string levelSeed, int scriptedEventCount = 1)
|
||||
{
|
||||
Level level = Level.CreateRandom(levelSeed);
|
||||
|
||||
StartShift(duration, level, scriptedEventCount);
|
||||
}
|
||||
|
||||
public void StartShift(TimeSpan duration, Level level, int scriptedEventCount = 1)
|
||||
{
|
||||
//if (crewManager.characterInfos.Count == 0) return;
|
||||
|
||||
|
||||
|
||||
this.level = level;
|
||||
|
||||
if (Submarine.Loaded!=submarine) submarine.Load();
|
||||
|
||||
@@ -61,10 +61,9 @@ namespace Subsurface
|
||||
|
||||
public static Level CreateRandom(string seed = "")
|
||||
{
|
||||
|
||||
if (seed == "")
|
||||
{
|
||||
seed = Rand.Range(0, int.MaxValue).ToString();
|
||||
seed = Rand.Range(0, int.MaxValue, false).ToString();
|
||||
}
|
||||
return new Level((string)seed, 100000, 40000, 2000);
|
||||
}
|
||||
|
||||
@@ -212,23 +212,20 @@ namespace Subsurface.Networking
|
||||
int seed = inc.ReadInt32();
|
||||
Rand.SetSyncedSeed(seed);
|
||||
|
||||
string levelSeed = inc.ReadString();
|
||||
|
||||
string mapName = inc.ReadString();
|
||||
string mapHash = inc.ReadString();
|
||||
|
||||
Game1.NetLobbyScreen.TrySelectMap(mapName, mapHash);
|
||||
|
||||
|
||||
//Map.Load(mapFile);
|
||||
|
||||
|
||||
|
||||
|
||||
double durationMinutes = inc.ReadDouble();
|
||||
|
||||
TimeSpan duration = new TimeSpan(0,(int)durationMinutes,0);
|
||||
|
||||
//int gameModeIndex = inc.ReadInt32();
|
||||
Game1.GameSession = new GameSession(Submarine.Loaded);
|
||||
Game1.GameSession.StartShift(duration, "asdf");
|
||||
Game1.GameSession.StartShift(duration, levelSeed);
|
||||
|
||||
myCharacter = ReadCharacterData(inc);
|
||||
Character.Controlled = myCharacter;
|
||||
|
||||
@@ -273,7 +273,7 @@ namespace Subsurface.Networking
|
||||
//selectedMap.Load();
|
||||
|
||||
Game1.GameSession = new GameSession(selectedMap, Game1.NetLobbyScreen.SelectedMode);
|
||||
Game1.GameSession.StartShift(Game1.NetLobbyScreen.GameDuration, "asdf", 1);
|
||||
Game1.GameSession.StartShift(Game1.NetLobbyScreen.GameDuration, Game1.NetLobbyScreen.LevelSeed, 1);
|
||||
//EventManager.SelectEvent(Game1.netLobbyScreen.SelectedEvent);
|
||||
|
||||
foreach (Client client in connectedClients)
|
||||
@@ -304,6 +304,8 @@ namespace Subsurface.Networking
|
||||
|
||||
msg.Write(seed);
|
||||
|
||||
msg.Write(Game1.NetLobbyScreen.LevelSeed);
|
||||
|
||||
msg.Write(Game1.NetLobbyScreen.SelectedMap.Name);
|
||||
msg.Write(Game1.NetLobbyScreen.SelectedMap.Hash.MD5Hash);
|
||||
|
||||
|
||||
@@ -180,6 +180,7 @@ namespace Subsurface
|
||||
GUI.style, 0.1f, infoFrame);
|
||||
durationBar.BarSize = 0.1f;
|
||||
durationBar.Enabled = (Game1.Server != null);
|
||||
LevelSeed = ToolBox.RandomSeed(8);
|
||||
|
||||
new GUITextBlock(new Rectangle((int)(modeList.Rect.Right + 20 - 80), 100, 100, 20),
|
||||
"Level Seed: ", GUI.style, Alignment.Left, Alignment.TopLeft, infoFrame);
|
||||
|
||||
@@ -247,6 +247,15 @@ namespace Subsurface
|
||||
return floatArray;
|
||||
}
|
||||
|
||||
public static string RandomSeed(int length)
|
||||
{
|
||||
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
return new string(
|
||||
Enumerable.Repeat(chars, length)
|
||||
.Select(s => s[Rand.Int(s.Length)])
|
||||
.ToArray());
|
||||
}
|
||||
|
||||
public static int SeedToInt(string seed)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user