Console colors, begin RNG rework
This is gonna be a PAIN
This commit is contained in:
@@ -97,6 +97,7 @@
|
||||
<Compile Include="Source\GameSession\GameModes\Tutorials\TutorialMode.cs" />
|
||||
<Compile Include="Source\GameSession\GameModes\Tutorials\TutorialType.cs" />
|
||||
<Compile Include="Source\GameSession\GameSession.cs" />
|
||||
<Compile Include="Source\GameSession\HireManager.cs" />
|
||||
<Compile Include="Source\GameSession\ShiftSummary.cs" />
|
||||
<Compile Include="Source\GameSettings.cs" />
|
||||
<Compile Include="Source\GUI\ComponentStyle.cs" />
|
||||
@@ -157,6 +158,7 @@
|
||||
<Compile Include="Source\Map\Lights\LightManager.cs" />
|
||||
<Compile Include="Source\Map\Lights\LightSource.cs" />
|
||||
<Compile Include="Source\Map\LinkedSubmarine.cs" />
|
||||
<Compile Include="Source\Map\Map\Location.cs" />
|
||||
<Compile Include="Source\Map\Map.cs" />
|
||||
<Compile Include="Source\Map\MapEntity.cs" />
|
||||
<Compile Include="Source\Map\MapEntityPrefab.cs" />
|
||||
|
||||
@@ -64,14 +64,14 @@ namespace Barotrauma
|
||||
var wayPoints = WayPoint.WayPointList.FindAll(wp => wp.Submarine==null);
|
||||
if (wayPoints.Any())
|
||||
{
|
||||
WayPoint wp = wayPoints[Rand.Int(wayPoints.Count, false)];
|
||||
WayPoint wp = wayPoints[Rand.Int(wayPoints.Count, Rand.RandSync.ClientOnly)];
|
||||
|
||||
pos = new Vector2(wp.Rect.X, wp.Rect.Y);
|
||||
pos += Rand.Vector(200.0f, false);
|
||||
pos += Rand.Vector(200.0f, Rand.RandSync.ClientOnly);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = Rand.Vector(2000.0f, false);
|
||||
pos = Rand.Vector(2000.0f, Rand.RandSync.ClientOnly);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -80,9 +80,9 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
|
||||
var prefab = prefabs[Rand.Int(prefabs.Count, false)];
|
||||
var prefab = prefabs[Rand.Int(prefabs.Count, Rand.RandSync.ClientOnly)];
|
||||
|
||||
int amount = Rand.Range(prefab.SwarmMin, prefab.SwarmMax, false);
|
||||
int amount = Rand.Range(prefab.SwarmMin, prefab.SwarmMax, Rand.RandSync.ClientOnly);
|
||||
List<BackgroundCreature> swarmMembers = new List<BackgroundCreature>();
|
||||
|
||||
for (int n = 0; n < amount; n++)
|
||||
|
||||
@@ -101,10 +101,10 @@ namespace Barotrauma
|
||||
rotation = MathUtils.VectorToAngle(new Vector2(edgeNormal.Y, edgeNormal.X));
|
||||
}
|
||||
|
||||
rotation += Rand.Range(prefab.RandomRotation.X, prefab.RandomRotation.Y, false);
|
||||
rotation += Rand.Range(prefab.RandomRotation.X, prefab.RandomRotation.Y, Rand.RandSync.ClientOnly);
|
||||
|
||||
var newSprite = new BackgroundSprite(prefab,
|
||||
new Vector3((Vector2)pos, Rand.Range(prefab.DepthRange.X, prefab.DepthRange.Y, false)), Rand.Range(prefab.Scale.X, prefab.Scale.Y, false), rotation);
|
||||
new Vector3((Vector2)pos, Rand.Range(prefab.DepthRange.X, prefab.DepthRange.Y, Rand.RandSync.ClientOnly)), Rand.Range(prefab.Scale.X, prefab.Scale.Y, Rand.RandSync.ClientOnly), rotation);
|
||||
|
||||
//calculate the positions of the corners of the rotated sprite
|
||||
Vector2 halfSize = newSprite.Prefab.Sprite.size * newSprite.Scale / 2;
|
||||
@@ -155,8 +155,8 @@ namespace Barotrauma
|
||||
edgeNormal = Vector2.One;
|
||||
|
||||
Vector2 randomPos = new Vector2(
|
||||
Rand.Range(0.0f, level.Size.X, false),
|
||||
Rand.Range(0.0f, level.Size.Y, false));
|
||||
Rand.Range(0.0f, level.Size.X, Rand.RandSync.ClientOnly),
|
||||
Rand.Range(0.0f, level.Size.Y, Rand.RandSync.ClientOnly));
|
||||
|
||||
if (!prefab.SpawnOnWalls) return randomPos;
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace Barotrauma
|
||||
|
||||
if (cells.Any())
|
||||
{
|
||||
VoronoiCell cell = cells[Rand.Int(cells.Count, false)];
|
||||
VoronoiCell cell = cells[Rand.Int(cells.Count, Rand.RandSync.ClientOnly)];
|
||||
|
||||
foreach (GraphEdge edge in cell.edges)
|
||||
{
|
||||
@@ -220,13 +220,13 @@ namespace Barotrauma
|
||||
|
||||
if (!edges.Any()) return null;
|
||||
|
||||
int index = Rand.Int(edges.Count, false);
|
||||
int index = Rand.Int(edges.Count, Rand.RandSync.ClientOnly);
|
||||
closestEdge = edges[index];
|
||||
edgeNormal = normals[index];
|
||||
|
||||
float length = Vector2.Distance(closestEdge.point1, closestEdge.point2);
|
||||
Vector2 dir = (closestEdge.point1 - closestEdge.point2) / length;
|
||||
Vector2 pos = closestEdge.point2 + dir * Rand.Range(prefab.Sprite.size.X / 2.0f, length - prefab.Sprite.size.X / 2.0f, false);
|
||||
Vector2 pos = closestEdge.point2 + dir * Rand.Range(prefab.Sprite.size.X / 2.0f, length - prefab.Sprite.size.X / 2.0f, Rand.RandSync.ClientOnly);
|
||||
|
||||
return pos;
|
||||
}
|
||||
@@ -331,7 +331,7 @@ namespace Barotrauma
|
||||
totalCommonness += prefab.GetCommonness(levelType);
|
||||
}
|
||||
|
||||
float randomNumber = Rand.Int(totalCommonness+1, false);
|
||||
float randomNumber = Rand.Int(totalCommonness+1, Rand.RandSync.ClientOnly);
|
||||
|
||||
foreach (BackgroundSpritePrefab prefab in prefabs)
|
||||
{
|
||||
|
||||
@@ -29,13 +29,7 @@ namespace Barotrauma
|
||||
static GUIFrame frame;
|
||||
static GUIListBox listBox;
|
||||
static GUITextBox textBox;
|
||||
|
||||
private static string InputText
|
||||
{
|
||||
get { return textBox.Text; }
|
||||
set { textBox.Text = value; }
|
||||
}
|
||||
|
||||
|
||||
public static void Init(GameWindow window)
|
||||
{
|
||||
int x = 20, y = 20;
|
||||
|
||||
@@ -281,7 +281,7 @@ namespace Barotrauma
|
||||
listBox.ClearChildren();
|
||||
characters.Clear();
|
||||
|
||||
WayPoint[] waypoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSub);
|
||||
WayPoint[] waypoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSub, false);
|
||||
|
||||
for (int i = 0; i < waypoints.Length; i++)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class Location
|
||||
{
|
||||
private HireManager hireManager;
|
||||
|
||||
public HireManager HireManager
|
||||
{
|
||||
get { return hireManager; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ namespace Barotrauma.Networking
|
||||
fileReceiver = new FileReceiver("Submarines/Downloaded");
|
||||
fileReceiver.OnFinished += OnFileReceived;
|
||||
|
||||
characterInfo = new CharacterInfo(Character.HumanConfigFile, name);
|
||||
characterInfo = new CharacterInfo(Character.HumanConfigFile, name,Gender.None,null);
|
||||
characterInfo.Job = null;
|
||||
|
||||
otherClients = new List<Client>();
|
||||
|
||||
@@ -565,7 +565,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (tickBox.Selected)
|
||||
{
|
||||
GameMain.Server.CharacterInfo = new CharacterInfo(Character.HumanConfigFile, GameMain.Server.Name);
|
||||
GameMain.Server.CharacterInfo = new CharacterInfo(Character.HumanConfigFile, GameMain.Server.Name,Gender.None,null);
|
||||
UpdatePlayerFrame(GameMain.Server.CharacterInfo);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="MonoGame.Framework, Version=3.5.1.1679, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>C:\Program Files (x86)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll</HintPath>
|
||||
<HintPath>C:\Program Files (x86)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath>..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll</HintPath>
|
||||
@@ -90,6 +90,7 @@
|
||||
<Compile Include="Source\Program.cs" />
|
||||
<Compile Include="Source\Screens\NetLobbyScreen.cs" />
|
||||
<Compile Include="Source\Sprite\Sprite.cs" />
|
||||
<Compile Include="Source\Utils\XnaToConsoleColor.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
|
||||
@@ -13,11 +13,41 @@ namespace Barotrauma
|
||||
{
|
||||
static partial class DebugConsole
|
||||
{
|
||||
private static string InputText;
|
||||
public static List<string> QueuedCommands = new List<string>();
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
lock (QueuedCommands)
|
||||
{
|
||||
while (QueuedCommands.Count>0)
|
||||
{
|
||||
ExecuteCommand(QueuedCommands[0], GameMain.Instance);
|
||||
QueuedCommands.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ExecProjSpecific(string[] commands)
|
||||
{
|
||||
return false; //command not found
|
||||
switch (commands[0].ToLower())
|
||||
{
|
||||
case "startgame":
|
||||
case "startround":
|
||||
case "start":
|
||||
if (Screen.Selected == GameMain.GameScreen) break;
|
||||
if (!GameMain.Server.StartGame()) NewMessage("Failed to start server",Color.Yellow);
|
||||
break;
|
||||
case "endgame":
|
||||
case "endround":
|
||||
case "end":
|
||||
if (Screen.Selected == GameMain.NetLobbyScreen) break;
|
||||
GameMain.Server.EndGame();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return true; //command found
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,12 @@ namespace Barotrauma
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
World = new World(new Vector2(0, -9.82f));
|
||||
FarseerPhysics.Settings.AllowSleep = true;
|
||||
FarseerPhysics.Settings.ContinuousPhysics = false;
|
||||
FarseerPhysics.Settings.VelocityIterations = 1;
|
||||
FarseerPhysics.Settings.PositionIterations = 1;
|
||||
|
||||
Config = new GameSettings("serverconfig.xml");
|
||||
if (Config.WasGameUpdated)
|
||||
{
|
||||
@@ -65,6 +71,8 @@ namespace Barotrauma
|
||||
Config.WasGameUpdated = false;
|
||||
Config.Save("serverconfig.xml");
|
||||
}
|
||||
|
||||
GameScreen = new GameScreen();
|
||||
}
|
||||
|
||||
public void Run()
|
||||
@@ -91,9 +99,10 @@ namespace Barotrauma
|
||||
|
||||
NetLobbyScreen = new NetLobbyScreen();
|
||||
|
||||
Server = new GameServer("Dedicated Server Test", 14242, true, "asd", false, 10);
|
||||
Server = new GameServer("Dedicated Server Test", 14242, false, "asd", false, 10);
|
||||
while (true)
|
||||
{
|
||||
DebugConsole.Update();
|
||||
NetLobbyScreen.Update((float)Timing.Step);
|
||||
Server.Update((float)Timing.Step);
|
||||
CoroutineManager.Update((float)Timing.Step, (float)Timing.Step);
|
||||
@@ -107,7 +116,10 @@ namespace Barotrauma
|
||||
while (true)
|
||||
{
|
||||
string input = Console.ReadLine();
|
||||
DebugConsole.ExecuteCommand(input, this);
|
||||
lock (DebugConsole.QueuedCommands)
|
||||
{
|
||||
DebugConsole.QueuedCommands.Add(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,16 +33,24 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void Select()
|
||||
public NetLobbyScreen()
|
||||
{
|
||||
List<Submarine> subsToShow = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)).ToList();
|
||||
LevelSeed = ToolBox.RandomSeed(8);
|
||||
|
||||
SelectedSub = subsToShow[0];
|
||||
SelectedShuttle = subsToShow[0]; //TODO: don't use the same sub as a shuttle by default
|
||||
subs = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)).ToList();
|
||||
|
||||
SelectedSub = subs[0];
|
||||
SelectedShuttle = subs[0]; //TODO: don't use the same sub as a shuttle by default
|
||||
|
||||
DebugConsole.NewMessage("Selected sub: " + SelectedSub.Name, Color.White);
|
||||
DebugConsole.NewMessage("Selected shuttle: " + SelectedShuttle.Name, Color.White);
|
||||
|
||||
GameModes = GameModePreset.list.ToArray();
|
||||
}
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private List<Submarine> subs = new List<Submarine>();
|
||||
@@ -62,6 +70,7 @@ namespace Barotrauma
|
||||
if (levelSeed == value) return;
|
||||
|
||||
levelSeed = value;
|
||||
LocationType.Random(levelSeed); //call to sync up with clients
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
public static class XnaToConsoleColor
|
||||
{
|
||||
static Dictionary<Color, ConsoleColor> dictionary;
|
||||
|
||||
public static ConsoleColor Convert(Color xnaCol)
|
||||
{
|
||||
if (dictionary == null)
|
||||
{
|
||||
dictionary = new Dictionary<Color, ConsoleColor>();
|
||||
dictionary.Add(Color.White, ConsoleColor.White);
|
||||
dictionary.Add(Color.Gray, ConsoleColor.Gray);
|
||||
dictionary.Add(Color.LightGray, ConsoleColor.Gray);
|
||||
dictionary.Add(Color.DarkGray, ConsoleColor.Gray);
|
||||
dictionary.Add(Color.Red, ConsoleColor.Red);
|
||||
dictionary.Add(Color.DarkRed, ConsoleColor.DarkRed);
|
||||
dictionary.Add(Color.Yellow, ConsoleColor.Yellow);
|
||||
dictionary.Add(Color.Orange, ConsoleColor.Yellow);
|
||||
dictionary.Add(Color.Green, ConsoleColor.Green);
|
||||
dictionary.Add(Color.Lime, ConsoleColor.Green);
|
||||
dictionary.Add(Color.Blue, ConsoleColor.Blue);
|
||||
dictionary.Add(Color.Cyan, ConsoleColor.Cyan);
|
||||
dictionary.Add(Color.DarkBlue, ConsoleColor.DarkBlue);
|
||||
dictionary.Add(Color.Pink, ConsoleColor.Magenta);
|
||||
}
|
||||
|
||||
ConsoleColor val = ConsoleColor.White;
|
||||
if (dictionary.TryGetValue(xnaCol, out val))
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
return ConsoleColor.White;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1343,7 +1343,6 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\GameSession\GameModes\MissionMode.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\GameSession\GameModes\TraitorManager.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\GameSession\GameSession.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\GameSession\HireManager.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\GameSession\InfoTextManager.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\GameSettings.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\IPropertyObject.cs" />
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Barotrauma
|
||||
if (gender == Gender.None)
|
||||
{
|
||||
float femaleRatio = ToolBox.GetAttributeFloat(doc.Root, "femaleratio", 0.5f);
|
||||
this.gender = (Rand.Range(0.0f, 1.0f, false) < femaleRatio) ? Gender.Female : Gender.Male;
|
||||
this.gender = (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) < femaleRatio) ? Gender.Female : Gender.Male;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Barotrauma
|
||||
|
||||
public static Job Random()
|
||||
{
|
||||
JobPrefab prefab = JobPrefab.List[Rand.Int(JobPrefab.List.Count - 1, false)];
|
||||
JobPrefab prefab = JobPrefab.List[Rand.Int(JobPrefab.List.Count - 1, Rand.RandSync.Server)];
|
||||
|
||||
return new Job(prefab);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Barotrauma
|
||||
|
||||
if (!commands[0].ToLowerInvariant().Equals("admin"))
|
||||
{
|
||||
NewMessage(InputText, Color.White);
|
||||
NewMessage(command, Color.White);
|
||||
}
|
||||
|
||||
#if !DEBUG
|
||||
@@ -499,6 +499,7 @@ namespace Barotrauma
|
||||
Messages.Add(new ColoredText(msg, color));
|
||||
#if SERVER
|
||||
//TODO: REMOVE
|
||||
Console.ForegroundColor = XnaToConsoleColor.Convert(color);
|
||||
Console.WriteLine(msg);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Vector2 position = new Vector2(
|
||||
cargoSpawnPos.Position.X + Rand.Range(-20.0f, 20.0f, false),
|
||||
cargoSpawnPos.Position.X + Rand.Range(-20.0f, 20.0f, Rand.RandSync.Server),
|
||||
cargoRoom.Rect.Y - cargoRoom.Rect.Height + itemPrefab.Size.Y / 2);
|
||||
|
||||
var item = new Item(itemPrefab, position, cargoRoom.Submarine);
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Barotrauma
|
||||
|
||||
Vector2 spawnPos = Level.Loaded.GetRandomInterestingPosition(true, spawnPosType, true);
|
||||
|
||||
int amount = Rand.Range(minAmount, maxAmount, false);
|
||||
int amount = Rand.Range(minAmount, maxAmount, Rand.RandSync.Server);
|
||||
|
||||
monsters = new Character[amount];
|
||||
|
||||
@@ -84,8 +84,8 @@ namespace Barotrauma
|
||||
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
spawnPos.X += Rand.Range(-0.5f, 0.5f, false);
|
||||
spawnPos.Y += Rand.Range(-0.5f, 0.5f, false);
|
||||
spawnPos.X += Rand.Range(-0.5f, 0.5f, Rand.RandSync.Server);
|
||||
spawnPos.Y += Rand.Range(-0.5f, 0.5f, Rand.RandSync.Server);
|
||||
monsters[i] = Character.Create(characterFile, spawnPos, null, GameMain.Client != null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@ namespace Barotrauma
|
||||
{
|
||||
for (float y = edges.Y + siteInterval; y < edges.W - siteInterval; y += siteInterval)
|
||||
{
|
||||
if (Rand.Int(5, false) == 0) continue; //skip some positions to make the cells more irregular
|
||||
if (Rand.Int(5, Rand.RandSync.Server) == 0) continue; //skip some positions to make the cells more irregular
|
||||
|
||||
sites.Add(new Vector2(x, y) + Rand.Vector(siteVariance, false));
|
||||
sites.Add(new Vector2(x, y) + Rand.Vector(siteVariance, Rand.RandSync.Server));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,10 +126,10 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
//randomly pick one of the adjacent cells as the next cell
|
||||
pathCell = allowedNextCells[Rand.Int(allowedNextCells.Count, false)];
|
||||
pathCell = allowedNextCells[Rand.Int(allowedNextCells.Count, Rand.RandSync.Server)];
|
||||
|
||||
//randomly take steps further away from the startpoint to make the cave expand further
|
||||
if (Rand.Int(4, false) == 0)
|
||||
if (Rand.Int(4, Rand.RandSync.Server) == 0)
|
||||
{
|
||||
float furthestDist = 0.0f;
|
||||
foreach (VoronoiCell nextCell in allowedNextCells)
|
||||
@@ -300,7 +300,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
//steer towards target
|
||||
if (Rand.Range(0.0f, 1.0f, false) > wanderAmount || allowedEdges.Count == 0)
|
||||
if (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) > wanderAmount || allowedEdges.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < currentCell.edges.Count; i++)
|
||||
{
|
||||
@@ -321,7 +321,7 @@ namespace Barotrauma
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
edgeIndex = Rand.Int(allowedEdges.Count, false);
|
||||
edgeIndex = Rand.Int(allowedEdges.Count, Rand.RandSync.Server);
|
||||
if (mirror && edgeIndex > 0) edgeIndex = allowedEdges.Count - edgeIndex;
|
||||
edgeIndex = currentCell.edges.IndexOf(allowedEdges[edgeIndex]);
|
||||
//}
|
||||
|
||||
@@ -148,12 +148,12 @@ namespace Barotrauma
|
||||
{
|
||||
if (seed == "")
|
||||
{
|
||||
seed = Rand.Range(0, int.MaxValue, false).ToString();
|
||||
seed = Rand.Range(0, int.MaxValue, Rand.RandSync.Server).ToString();
|
||||
}
|
||||
|
||||
Rand.SetSyncedSeed(ToolBox.StringToInt(seed));
|
||||
|
||||
return new Level(seed, Rand.Range(30.0f, 80.0f, false), LevelGenerationParams.GetRandom(seed));
|
||||
return new Level(seed, Rand.Range(30.0f, 80.0f, Rand.RandSync.Server), LevelGenerationParams.GetRandom(seed));
|
||||
}
|
||||
|
||||
public void Generate(bool mirror = false)
|
||||
@@ -190,12 +190,12 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
startPosition = new Vector2(
|
||||
Rand.Range(minWidth, minWidth * 2, false),
|
||||
Rand.Range(borders.Height * 0.5f, borders.Height - minWidth * 2, false));
|
||||
Rand.Range(minWidth, minWidth * 2, Rand.RandSync.Server),
|
||||
Rand.Range(borders.Height * 0.5f, borders.Height - minWidth * 2, Rand.RandSync.Server));
|
||||
|
||||
endPosition = new Vector2(
|
||||
borders.Width - Rand.Range(minWidth, minWidth * 2, false),
|
||||
Rand.Range(borders.Height * 0.5f, borders.Height - minWidth * 2, false));
|
||||
borders.Width - Rand.Range(minWidth, minWidth * 2, Rand.RandSync.Server),
|
||||
Rand.Range(borders.Height * 0.5f, borders.Height - minWidth * 2, Rand.RandSync.Server));
|
||||
|
||||
List<Vector2> pathNodes = new List<Vector2>();
|
||||
Rectangle pathBorders = borders;// new Rectangle((int)minWidth, (int)minWidth, borders.Width - (int)minWidth * 2, borders.Height - (int)minWidth);
|
||||
@@ -205,11 +205,11 @@ namespace Barotrauma
|
||||
|
||||
Vector2 nodeInterval = generationParams.MainPathNodeIntervalRange;
|
||||
|
||||
for (float x = startPosition.X + Rand.Range(nodeInterval.X, nodeInterval.Y, false);
|
||||
x < endPosition.X - Rand.Range(nodeInterval.X, nodeInterval.Y, false);
|
||||
x += Rand.Range(nodeInterval.X, nodeInterval.Y, false))
|
||||
for (float x = startPosition.X + Rand.Range(nodeInterval.X, nodeInterval.Y, Rand.RandSync.Server);
|
||||
x < endPosition.X - Rand.Range(nodeInterval.X, nodeInterval.Y, Rand.RandSync.Server);
|
||||
x += Rand.Range(nodeInterval.X, nodeInterval.Y, Rand.RandSync.Server))
|
||||
{
|
||||
pathNodes.Add(new Vector2(x, Rand.Range(pathBorders.Y, pathBorders.Bottom, false)));
|
||||
pathNodes.Add(new Vector2(x, Rand.Range(pathBorders.Y, pathBorders.Bottom, Rand.RandSync.Server)));
|
||||
}
|
||||
|
||||
pathNodes.Add(new Vector2(endPosition.X, borders.Height));
|
||||
@@ -222,17 +222,17 @@ namespace Barotrauma
|
||||
List<List<Vector2>> smallTunnels = new List<List<Vector2>>();
|
||||
for (int i = 0; i < generationParams.SmallTunnelCount; i++)
|
||||
{
|
||||
var tunnelStartPos = pathNodes[Rand.Range(2, pathNodes.Count - 2, false)];
|
||||
var tunnelStartPos = pathNodes[Rand.Range(2, pathNodes.Count - 2, Rand.RandSync.Server)];
|
||||
tunnelStartPos.X = MathHelper.Clamp(tunnelStartPos.X, pathBorders.X, pathBorders.Right);
|
||||
|
||||
float tunnelLength = Rand.Range(
|
||||
generationParams.SmallTunnelLengthRange.X,
|
||||
generationParams.SmallTunnelLengthRange.Y,
|
||||
false);
|
||||
Rand.RandSync.Server);
|
||||
|
||||
var tunnelNodes = MathUtils.GenerateJaggedLine(
|
||||
tunnelStartPos,
|
||||
new Vector2(tunnelStartPos.X, pathBorders.Bottom)+Rand.Vector(tunnelLength,false),
|
||||
new Vector2(tunnelStartPos.X, pathBorders.Bottom)+Rand.Vector(tunnelLength, Rand.RandSync.Server),
|
||||
4, 1000.0f);
|
||||
|
||||
List<Vector2> tunnel = new List<Vector2>();
|
||||
@@ -252,8 +252,8 @@ namespace Barotrauma
|
||||
for (float y = siteInterval.Y / 2; y < borders.Height; y += siteInterval.Y)
|
||||
{
|
||||
Vector2 site = new Vector2(
|
||||
x + Rand.Range(-siteVariance.X, siteVariance.X, false),
|
||||
y + Rand.Range(-siteVariance.Y, siteVariance.Y, false));
|
||||
x + Rand.Range(-siteVariance.X, siteVariance.X, Rand.RandSync.Server),
|
||||
y + Rand.Range(-siteVariance.Y, siteVariance.Y, Rand.RandSync.Server));
|
||||
|
||||
if (smallTunnels.Any(t => t.Any(node => Vector2.Distance(node, site) < siteInterval.Length())))
|
||||
{
|
||||
@@ -359,7 +359,7 @@ namespace Barotrauma
|
||||
int maxTries = 5, tries = 0;
|
||||
while (tries<maxTries)
|
||||
{
|
||||
startCell = cells[Rand.Int(cells.Count, false)];
|
||||
startCell = cells[Rand.Int(cells.Count, Rand.RandSync.Server)];
|
||||
|
||||
//find an edge between the cell and the already carved path
|
||||
GraphEdge startEdge =
|
||||
@@ -497,7 +497,7 @@ namespace Barotrauma
|
||||
List<VoronoiCell> toBeRemoved = new List<VoronoiCell>();
|
||||
foreach (VoronoiCell cell in cells)
|
||||
{
|
||||
if (Rand.Range(0.0f, 1.0f, false) > holeProbability) continue;
|
||||
if (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) > holeProbability) continue;
|
||||
|
||||
if (!limits.Contains(cell.Center)) continue;
|
||||
|
||||
@@ -665,10 +665,10 @@ namespace Barotrauma
|
||||
private void GenerateRuin(List<VoronoiCell> mainPath)
|
||||
{
|
||||
|
||||
Vector2 ruinSize = new Vector2(Rand.Range(5000.0f, 8000.0f, false), Rand.Range(5000.0f, 8000.0f, false));
|
||||
Vector2 ruinSize = new Vector2(Rand.Range(5000.0f, 8000.0f, Rand.RandSync.Server), Rand.Range(5000.0f, 8000.0f, Rand.RandSync.Server));
|
||||
float ruinRadius = Math.Max(ruinSize.X, ruinSize.Y) * 0.5f;
|
||||
|
||||
Vector2 ruinPos = cells[Rand.Int(cells.Count, false)].Center;
|
||||
Vector2 ruinPos = cells[Rand.Int(cells.Count, Rand.RandSync.Server)].Center;
|
||||
|
||||
int iter = 0;
|
||||
|
||||
@@ -762,7 +762,7 @@ namespace Barotrauma
|
||||
{
|
||||
Vector2 startPos = Level.Loaded.GetRandomInterestingPosition(true, spawnPosType, true);
|
||||
|
||||
startPos += Rand.Vector(Rand.Range(0.0f, randomSpread, false), false);
|
||||
startPos += Rand.Vector(Rand.Range(0.0f, randomSpread, Rand.RandSync.Server), Rand.RandSync.Server);
|
||||
|
||||
Vector2 endPos = startPos - Vector2.UnitY * Size.Y;
|
||||
|
||||
@@ -804,10 +804,10 @@ namespace Barotrauma
|
||||
|
||||
if (!matchingPositions.Any())
|
||||
{
|
||||
return positionsOfInterest[Rand.Int(positionsOfInterest.Count, !useSyncedRand)].Position;
|
||||
return positionsOfInterest[Rand.Int(positionsOfInterest.Count, (useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced))].Position;
|
||||
}
|
||||
|
||||
return matchingPositions[Rand.Int(matchingPositions.Count, !useSyncedRand)].Position;
|
||||
return matchingPositions[Rand.Int(matchingPositions.Count, (useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced))].Position;
|
||||
}
|
||||
|
||||
public void Update(float deltaTime)
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Barotrauma
|
||||
return new LevelGenerationParams(null);
|
||||
}
|
||||
|
||||
return presets[Rand.Range(0, presets.Count, false)];
|
||||
return presets[Rand.Range(0, presets.Count, Rand.RandSync.Server)];
|
||||
}
|
||||
|
||||
private LevelGenerationParams(XElement element)
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Barotrauma.RuinGeneration
|
||||
{
|
||||
subRooms = new BTRoom[2];
|
||||
|
||||
if (Rand.Range(0.0f, 1.0f, false) < verticalProbability &&
|
||||
if (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) < verticalProbability &&
|
||||
rect.Width * minDivRatio >= minWidth)
|
||||
{
|
||||
SplitVertical(minDivRatio);
|
||||
@@ -65,7 +65,7 @@ namespace Barotrauma.RuinGeneration
|
||||
|
||||
private void SplitHorizontal(float minDivRatio)
|
||||
{
|
||||
float div = Rand.Range(minDivRatio, 1.0f - minDivRatio, false);
|
||||
float div = Rand.Range(minDivRatio, 1.0f - minDivRatio, Rand.RandSync.Server);
|
||||
subRooms[0] = new BTRoom(new Rectangle(rect.X, rect.Y, rect.Width, (int)(rect.Height * div)));
|
||||
subRooms[1] = new BTRoom(new Rectangle(rect.X, rect.Y + subRooms[0].rect.Height, rect.Width, rect.Height - subRooms[0].rect.Height));
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Barotrauma.RuinGeneration
|
||||
|
||||
private void SplitVertical(float minDivRatio)
|
||||
{
|
||||
float div = Rand.Range(minDivRatio, 1.0f - minDivRatio, false);
|
||||
float div = Rand.Range(minDivRatio, 1.0f - minDivRatio, Rand.RandSync.Server);
|
||||
subRooms[0] = new BTRoom(new Rectangle(rect.X, rect.Y, (int)(rect.Width * div), rect.Height));
|
||||
subRooms[1] = new BTRoom(new Rectangle(rect.X + subRooms[0].rect.Width, rect.Y, rect.Width - subRooms[0].rect.Width, rect.Height));
|
||||
}
|
||||
@@ -118,7 +118,7 @@ namespace Barotrauma.RuinGeneration
|
||||
{
|
||||
if (Adjacent != null && Corridor == null)
|
||||
{
|
||||
Corridor = new Corridor(this, Rand.Range(minWidth, maxWidth, false), corridors);
|
||||
Corridor = new Corridor(this, Rand.Range(minWidth, maxWidth, Rand.RandSync.Server), corridors);
|
||||
}
|
||||
|
||||
if (subRooms != null)
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Barotrauma.RuinGeneration
|
||||
int top = Math.Max(room1.Y, room2.Y);
|
||||
int bottom = Math.Min(room1.Bottom, room2.Bottom);
|
||||
|
||||
int yPos = Rand.Range(top, bottom - width, false);
|
||||
int yPos = Rand.Range(top, bottom - width, Rand.RandSync.Server);
|
||||
|
||||
rect = new Rectangle(left, yPos, right - left, width);
|
||||
}
|
||||
@@ -84,7 +84,7 @@ namespace Barotrauma.RuinGeneration
|
||||
int top = Math.Min(room1.Bottom, room2.Bottom);
|
||||
int bottom = Math.Max(room1.Y, room2.Y);
|
||||
|
||||
int xPos = Rand.Range(left, right - width, false);
|
||||
int xPos = Rand.Range(left, right - width, Rand.RandSync.Server);
|
||||
|
||||
rect = new Rectangle(xPos, top, width, bottom - top);
|
||||
}
|
||||
@@ -146,8 +146,8 @@ namespace Barotrauma.RuinGeneration
|
||||
/// <returns></returns>
|
||||
private BTRoom[] GetSuitableLeafRooms(List<BTRoom> leaves1, List<BTRoom> leaves2, int width, bool isHorizontal)
|
||||
{
|
||||
int iOffset = Rand.Int(leaves1.Count, false);
|
||||
int jOffset = Rand.Int(leaves2.Count, false);
|
||||
int iOffset = Rand.Int(leaves1.Count, Rand.RandSync.Server);
|
||||
int jOffset = Rand.Int(leaves2.Count, Rand.RandSync.Server);
|
||||
|
||||
|
||||
for (int iCount = 0; iCount < leaves1.Count; iCount++)
|
||||
|
||||
@@ -202,9 +202,9 @@ namespace Barotrauma.RuinGeneration
|
||||
|
||||
//area = new Rectangle(area.X, area.Y - area.Height, area.Width, area.Height);
|
||||
|
||||
int iterations = Rand.Range(3, 4, false);
|
||||
int iterations = Rand.Range(3, 4, Rand.RandSync.Server);
|
||||
|
||||
float verticalProbability = Rand.Range(0.4f, 0.6f, false);
|
||||
float verticalProbability = Rand.Range(0.4f, 0.6f, Rand.RandSync.Server);
|
||||
|
||||
BTRoom baseRoom = new BTRoom(area);
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace Barotrauma.RuinGeneration
|
||||
{
|
||||
leaf.Scale
|
||||
(
|
||||
new Vector2(Rand.Range(0.5f, 0.9f, false), Rand.Range(0.5f, 0.9f, false))
|
||||
new Vector2(Rand.Range(0.5f, 0.9f, Rand.RandSync.Server), Rand.Range(0.5f, 0.9f, Rand.RandSync.Server))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ namespace Barotrauma.RuinGeneration
|
||||
wallType = RuinStructureType.CorridorWall;
|
||||
}
|
||||
//rooms further from the entrance are more likely to have hard-to-break walls
|
||||
else if (Rand.Range(0.0f, leaf.DistanceFromEntrance, false) > 1.5f)
|
||||
else if (Rand.Range(0.0f, leaf.DistanceFromEntrance, Rand.RandSync.Server) > 1.5f)
|
||||
{
|
||||
wallType = RuinStructureType.HeavyWall;
|
||||
}
|
||||
@@ -352,28 +352,28 @@ namespace Barotrauma.RuinGeneration
|
||||
{
|
||||
Alignment[] alignments = new Alignment[] { Alignment.Top, Alignment.Bottom, Alignment.Right, Alignment.Left, Alignment.Center };
|
||||
|
||||
var prop = RuinStructure.GetRandom(RuinStructureType.Prop, alignments[Rand.Int(alignments.Length, false)]);
|
||||
var prop = RuinStructure.GetRandom(RuinStructureType.Prop, alignments[Rand.Int(alignments.Length, Rand.RandSync.Server)]);
|
||||
|
||||
Vector2 size = (prop.Prefab is StructurePrefab) ? ((StructurePrefab)prop.Prefab).Size : Vector2.Zero;
|
||||
|
||||
var shape = shapes[Rand.Int(shapes.Count, false)];
|
||||
var shape = shapes[Rand.Int(shapes.Count, Rand.RandSync.Server)];
|
||||
|
||||
Vector2 position = shape.Rect.Center.ToVector2();
|
||||
if (prop.Alignment.HasFlag(Alignment.Top))
|
||||
{
|
||||
position = new Vector2(Rand.Range(shape.Rect.X+size.X, shape.Rect.Right - size.X, false), shape.Rect.Bottom - 64);
|
||||
position = new Vector2(Rand.Range(shape.Rect.X+size.X, shape.Rect.Right - size.X, Rand.RandSync.Server), shape.Rect.Bottom - 64);
|
||||
}
|
||||
else if (prop.Alignment.HasFlag(Alignment.Bottom))
|
||||
{
|
||||
position = new Vector2(Rand.Range(shape.Rect.X + size.X, shape.Rect.Right - size.X, false), shape.Rect.Top + 64);
|
||||
position = new Vector2(Rand.Range(shape.Rect.X + size.X, shape.Rect.Right - size.X, Rand.RandSync.Server), shape.Rect.Top + 64);
|
||||
}
|
||||
else if (prop.Alignment.HasFlag(Alignment.Right))
|
||||
{
|
||||
position = new Vector2(shape.Rect.Right - 64, Rand.Range(shape.Rect.Y + size.X, shape.Rect.Bottom - size.Y, false));
|
||||
position = new Vector2(shape.Rect.Right - 64, Rand.Range(shape.Rect.Y + size.X, shape.Rect.Bottom - size.Y, Rand.RandSync.Server));
|
||||
}
|
||||
else if (prop.Alignment.HasFlag(Alignment.Left))
|
||||
{
|
||||
position = new Vector2(shape.Rect.X + 64, Rand.Range(shape.Rect.Y + size.X, shape.Rect.Bottom - size.Y, false));
|
||||
position = new Vector2(shape.Rect.X + 64, Rand.Range(shape.Rect.Y + size.X, shape.Rect.Bottom - size.Y, Rand.RandSync.Server));
|
||||
}
|
||||
|
||||
if (prop.Prefab is ItemPrefab)
|
||||
@@ -410,7 +410,7 @@ namespace Barotrauma.RuinGeneration
|
||||
Vector2 doorPos = corridor.Center;
|
||||
|
||||
//choose a random wall to place the door next to
|
||||
var wall = suitableWalls[Rand.Int(suitableWalls.Count, false)];
|
||||
var wall = suitableWalls[Rand.Int(suitableWalls.Count, Rand.RandSync.Server)];
|
||||
if (corridor.IsHorizontal)
|
||||
{
|
||||
doorPos.X = (wall.A.X + wall.B.X) / 2.0f;
|
||||
@@ -423,7 +423,7 @@ namespace Barotrauma.RuinGeneration
|
||||
var door = new Item(doorPrefab.Prefab as ItemPrefab, doorPos, null);
|
||||
door.MoveWithLevel = true;
|
||||
|
||||
door.GetComponent<Items.Components.Door>().IsOpen = Rand.Range(0.0f, 1.0f, false) < 0.8f;
|
||||
door.GetComponent<Items.Components.Door>().IsOpen = Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) < 0.8f;
|
||||
|
||||
if (sensorPrefab == null || wirePrefab == null) continue;
|
||||
|
||||
@@ -431,8 +431,8 @@ namespace Barotrauma.RuinGeneration
|
||||
if (sensorRoom == null) continue;
|
||||
|
||||
var sensor = new Item(sensorPrefab, new Vector2(
|
||||
Rand.Range(sensorRoom.Rect.X, sensorRoom.Rect.Right, false),
|
||||
Rand.Range(sensorRoom.Rect.Y, sensorRoom.Rect.Bottom,false)), null);
|
||||
Rand.Range(sensorRoom.Rect.X, sensorRoom.Rect.Right, Rand.RandSync.Server),
|
||||
Rand.Range(sensorRoom.Rect.Y, sensorRoom.Rect.Bottom, Rand.RandSync.Server)), null);
|
||||
sensor.MoveWithLevel = true;
|
||||
|
||||
var wire = new Item(wirePrefab, sensorRoom.Center, null).GetComponent<Items.Components.Wire>();
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Barotrauma.RuinGeneration
|
||||
|
||||
int totalCommonness = matchingStructures.Sum(m => m.commonness);
|
||||
|
||||
int randomNumber = Rand.Int(totalCommonness + 1, false);
|
||||
int randomNumber = Rand.Int(totalCommonness + 1, Rand.RandSync.Server);
|
||||
|
||||
foreach (RuinStructure ruinStructure in matchingStructures)
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Barotrauma
|
||||
float normalizedDist = distFromEdge / (WallWidth / 2);
|
||||
|
||||
float variance = 1000.0f * normalizedDist;
|
||||
bottomVertices.Add(center + new Vector2(Rand.Range(-variance, variance, false), Rand.Range(-variance, variance, false)*2.0f));
|
||||
bottomVertices.Add(center + new Vector2(Rand.Range(-variance, variance, Rand.RandSync.Server), Rand.Range(-variance, variance, Rand.RandSync.Server) *2.0f));
|
||||
}
|
||||
|
||||
for (int i = 1; i < bottomVertices.Count; i++)
|
||||
|
||||
@@ -3,8 +3,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
|
||||
class Location
|
||||
partial class Location
|
||||
{
|
||||
private string name;
|
||||
|
||||
@@ -12,8 +11,6 @@ namespace Barotrauma
|
||||
|
||||
private LocationType type;
|
||||
|
||||
private HireManager hireManager;
|
||||
|
||||
public List<LocationConnection> Connections;
|
||||
|
||||
public string Name
|
||||
@@ -33,11 +30,6 @@ namespace Barotrauma
|
||||
get { return type; }
|
||||
}
|
||||
|
||||
public HireManager HireManager
|
||||
{
|
||||
get { return hireManager; }
|
||||
}
|
||||
|
||||
public Location(Vector2 mapPosition)
|
||||
{
|
||||
this.type = LocationType.Random();
|
||||
@@ -46,11 +38,13 @@ namespace Barotrauma
|
||||
|
||||
this.mapPosition = mapPosition;
|
||||
|
||||
#if CLIENT
|
||||
if (type.HasHireableCharacters)
|
||||
{
|
||||
hireManager = new HireManager();
|
||||
hireManager.GenerateCharacters(this, HireManager.MaxAvailableCharacters);
|
||||
}
|
||||
#endif
|
||||
|
||||
Connections = new List<LocationConnection>();
|
||||
}
|
||||
@@ -63,7 +57,7 @@ namespace Barotrauma
|
||||
private string RandomName(LocationType type)
|
||||
{
|
||||
string randomName = ToolBox.GetRandomLine("Content/Map/locationNames.txt");
|
||||
int nameFormatIndex = Rand.Int(type.NameFormats.Count, false);
|
||||
int nameFormatIndex = Rand.Int(type.NameFormats.Count, Rand.RandSync.Server);
|
||||
return type.NameFormats[nameFormatIndex].Replace("[name]", randomName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Barotrauma
|
||||
Rand.SetSyncedSeed(ToolBox.StringToInt(seed));
|
||||
}
|
||||
|
||||
int randInt = Rand.Int(totalWeight, false);
|
||||
int randInt = Rand.Int(totalWeight, Rand.RandSync.Server);
|
||||
|
||||
foreach (LocationType type in list)
|
||||
{
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace Barotrauma
|
||||
List<Vector2> sites = new List<Vector2>();
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
sites.Add(new Vector2(Rand.Range(0.0f, size, false), Rand.Range(0.0f, size, false)));
|
||||
sites.Add(new Vector2(Rand.Range(0.0f, size, Rand.RandSync.Server), Rand.Range(0.0f, size, Rand.RandSync.Server)));
|
||||
}
|
||||
|
||||
List<GraphEdge> edges = voronoi.MakeVoronoiGraph(sites, size, size);
|
||||
@@ -148,7 +148,7 @@ namespace Barotrauma
|
||||
|
||||
Vector2[] points = new Vector2[] { edge.point1, edge.point2 };
|
||||
|
||||
int positionIndex = Rand.Int(1, false);
|
||||
int positionIndex = Rand.Int(1, Rand.RandSync.Server);
|
||||
|
||||
Vector2 position = points[positionIndex];
|
||||
if (newLocations[1 - i] != null && newLocations[1 - i].MapPosition == position) position = points[1 - positionIndex];
|
||||
@@ -215,8 +215,8 @@ namespace Barotrauma
|
||||
private void GenerateDifficulties(Location start, List<LocationConnection> locations, float currDifficulty)
|
||||
{
|
||||
//start.Difficulty = currDifficulty;
|
||||
currDifficulty += Rand.Range(difficultyIncrease.X, difficultyIncrease.Y, false);
|
||||
if (currDifficulty > Rand.Range(difficultyCutoff.X, difficultyCutoff.Y, false)) currDifficulty = 10.0f;
|
||||
currDifficulty += Rand.Range(difficultyIncrease.X, difficultyIncrease.Y, Rand.RandSync.Server);
|
||||
if (currDifficulty > Rand.Range(difficultyCutoff.X, difficultyCutoff.Y, Rand.RandSync.Server)) currDifficulty = 10.0f;
|
||||
|
||||
foreach (LocationConnection connection in start.Connections)
|
||||
{
|
||||
|
||||
@@ -475,10 +475,10 @@ namespace Barotrauma
|
||||
|
||||
if (!wayPoints.Any()) return null;
|
||||
|
||||
return wayPoints[Rand.Int(wayPoints.Count, !useSyncedRand)];
|
||||
return wayPoints[Rand.Int(wayPoints.Count, (useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced))];
|
||||
}
|
||||
|
||||
public static WayPoint[] SelectCrewSpawnPoints(List<CharacterInfo> crew, Submarine submarine)
|
||||
public static WayPoint[] SelectCrewSpawnPoints(List<CharacterInfo> crew, Submarine submarine, bool tryAssignWayPoint = true)
|
||||
{
|
||||
List<WayPoint> subWayPoints = WayPointList.FindAll(wp => wp.Submarine == submarine);
|
||||
|
||||
@@ -515,12 +515,15 @@ namespace Barotrauma
|
||||
|
||||
if (assignedWayPoints[i] != null) continue;
|
||||
|
||||
//try to assign a spawnpoint that isn't meant for any specific job
|
||||
var nonJobSpecificPoints = subWayPoints.FindAll(wp => wp.spawnType == SpawnType.Human && wp.assignedJob == null);
|
||||
|
||||
if (nonJobSpecificPoints.Any())
|
||||
if (tryAssignWayPoint)
|
||||
{
|
||||
assignedWayPoints[i] = nonJobSpecificPoints[Rand.Int(nonJobSpecificPoints.Count, false)];
|
||||
//try to assign a spawnpoint that isn't meant for any specific job
|
||||
var nonJobSpecificPoints = subWayPoints.FindAll(wp => wp.spawnType == SpawnType.Human && wp.assignedJob == null);
|
||||
|
||||
if (nonJobSpecificPoints.Any())
|
||||
{
|
||||
assignedWayPoints[i] = nonJobSpecificPoints[Rand.Int(nonJobSpecificPoints.Count, Rand.RandSync.Server)];
|
||||
}
|
||||
}
|
||||
|
||||
if (assignedWayPoints[i] != null) continue;
|
||||
|
||||
@@ -14,6 +14,12 @@ namespace Barotrauma
|
||||
get { return cam; }
|
||||
}
|
||||
|
||||
public GameScreen()
|
||||
{
|
||||
cam = new Camera();
|
||||
cam.Translate(new Vector2(-10.0f, 50.0f));
|
||||
}
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
base.Select();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Barotrauma
|
||||
return ServerName;
|
||||
}
|
||||
|
||||
private string levelSeed;
|
||||
private string levelSeed = "";
|
||||
|
||||
private float autoRestartTimer;
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ namespace Barotrauma
|
||||
|
||||
Vector2 normal = Vector2.Normalize(endSegment - startSegment);
|
||||
normal = new Vector2(-normal.Y, normal.X);
|
||||
midPoint += normal * Rand.Range(-offsetAmount, offsetAmount, false);
|
||||
midPoint += normal * Rand.Range(-offsetAmount, offsetAmount, Rand.RandSync.Server);
|
||||
|
||||
segments.Insert(i, new Vector2[] { startSegment, midPoint });
|
||||
segments.Insert(i + 1, new Vector2[] { midPoint, endSegment });
|
||||
|
||||
@@ -5,37 +5,61 @@ namespace Barotrauma
|
||||
{
|
||||
static class Rand
|
||||
{
|
||||
public enum RandSync
|
||||
{
|
||||
Unsynced = -1, //not synced, used for unimportant details like minor particle properties
|
||||
Server = 0, //synced with the server (used for gameplay elements that the players can interact with)
|
||||
ClientOnly = 1 //set to match between clients (used for misc elements that the server doesn't track, but clients want to match anyway)
|
||||
}
|
||||
|
||||
private static Random localRandom = new Random();
|
||||
private static Random syncedRandom = new MTRandom();
|
||||
private static Random[] syncedRandom = new MTRandom[] {
|
||||
new MTRandom(), new MTRandom()
|
||||
};
|
||||
|
||||
public static void SetSyncedSeed(int seed)
|
||||
{
|
||||
syncedRandom = new MTRandom(seed);
|
||||
syncedRandom[(int)RandSync.Server] = new MTRandom(seed);
|
||||
syncedRandom[(int)RandSync.ClientOnly] = new MTRandom(seed);
|
||||
}
|
||||
|
||||
private static void Assert(RandSync sync)
|
||||
{
|
||||
//TODO: REMOVE AFTER FINDING ALL WRONG RNG USAGE
|
||||
#if CLIENT
|
||||
string trace = Environment.StackTrace.ToString();
|
||||
if (sync != RandSync.Server) return;
|
||||
if (trace.ToLower().Contains("barotraumaclient\\source")) DebugConsole.NewMessage("WARNING: Client code using RandSync.Server\n"+trace,Color.Yellow);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static float Range(float minimum, float maximum, bool local = true)
|
||||
public static float Range(float minimum, float maximum, RandSync sync=RandSync.Unsynced)
|
||||
{
|
||||
return (float)(local ? localRandom : syncedRandom).NextDouble() * (maximum - minimum) + minimum;
|
||||
Assert(sync);
|
||||
return (float)(sync == RandSync.Unsynced ? localRandom : (syncedRandom[(int)sync])).NextDouble() * (maximum - minimum) + minimum;
|
||||
}
|
||||
|
||||
public static int Range(int minimum, int maximum, bool local = true)
|
||||
public static int Range(int minimum, int maximum, RandSync sync = RandSync.Unsynced)
|
||||
{
|
||||
return (local ? localRandom : syncedRandom).Next(maximum - minimum) + minimum;
|
||||
Assert(sync);
|
||||
return (sync == RandSync.Unsynced ? localRandom : (syncedRandom[(int)sync])).Next(maximum - minimum) + minimum;
|
||||
}
|
||||
|
||||
public static int Int(int max = int.MaxValue, bool local = true)
|
||||
public static int Int(int max, RandSync sync = RandSync.Unsynced)
|
||||
{
|
||||
return (local ? localRandom : syncedRandom).Next(max);
|
||||
Assert(sync);
|
||||
return (sync == RandSync.Unsynced ? localRandom : (syncedRandom[(int)sync])).Next(max);
|
||||
}
|
||||
|
||||
public static Vector2 Vector(float length = 1.0f, bool local = true)
|
||||
public static Vector2 Vector(float length, RandSync sync = RandSync.Unsynced)
|
||||
{
|
||||
Vector2 randomVector = new Vector2(Range(-1.0f, 1.0f, local), Range(-1.0f, 1.0f, local));
|
||||
Assert(sync);
|
||||
Vector2 randomVector = new Vector2(Range(-1.0f, 1.0f, sync), Range(-1.0f, 1.0f, sync));
|
||||
|
||||
if (randomVector == Vector2.Zero) return new Vector2(0.0f, length);
|
||||
|
||||
return Vector2.Normalize(randomVector) * length;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,7 +482,7 @@ namespace Barotrauma
|
||||
return "";
|
||||
}
|
||||
|
||||
int lineNumber = Rand.Int(lineCount, false);
|
||||
int lineNumber = Rand.Int(lineCount, Rand.RandSync.Server);
|
||||
|
||||
int i = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user