Console colors, begin RNG rework

This is gonna be a PAIN
This commit is contained in:
juanjp600
2017-06-19 21:30:57 -03:00
parent 384819c528
commit 7003214847
37 changed files with 261 additions and 130 deletions
@@ -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)
{
+1 -7
View File
@@ -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,27 @@
using System.Collections.Generic;
namespace Barotrauma
{
class HireManager
{
public List<CharacterInfo> availableCharacters;
public const int MaxAvailableCharacters = 10;
public HireManager()
{
availableCharacters = new List<CharacterInfo>();
}
public void GenerateCharacters(Location location, int amount)
{
for (int i = 0 ; i<amount ; i++)
{
JobPrefab job = location.Type.GetRandomHireable();
if (job == null) return;
availableCharacters.Add(new CharacterInfo(Character.HumanConfigFile, "", Gender.None, job));
}
}
}
}
@@ -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