Server job assigning logic, submarine movement syncing, submarine collision improvements, spawnpoints in levels
This commit is contained in:
@@ -24,7 +24,7 @@ namespace Subsurface
|
||||
// return gender.ToString();
|
||||
//}
|
||||
|
||||
public CharacterInfo(string file, string name = "", Gender gender = Gender.None, Job job = null)
|
||||
public CharacterInfo(string file, string name = "", Gender gender = Gender.None, JobPrefab jobPrefab = null)
|
||||
{
|
||||
this.File = file;
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Subsurface
|
||||
HeadSpriteId = Rand.Range((int)headSpriteRange.X, (int)headSpriteRange.Y + 1);
|
||||
}
|
||||
|
||||
this.Job = (job == null) ? Job.Random() : job;
|
||||
this.Job = (jobPrefab == null) ? Job.Random() : new Job(jobPrefab);
|
||||
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
@@ -72,14 +72,14 @@ namespace Subsurface
|
||||
|
||||
if (doc.Root.Element("name") != null)
|
||||
{
|
||||
string firstNamePath = (ToolBox.GetAttributeString(doc.Root.Element("name"), "firstname", ""));
|
||||
string firstNamePath = ToolBox.GetAttributeString(doc.Root.Element("name"), "firstname", "");
|
||||
if (firstNamePath != "")
|
||||
{
|
||||
firstNamePath = firstNamePath.Replace("[GENDER]", (this.Gender == Gender.Female) ? "f" : "");
|
||||
this.Name = ToolBox.GetRandomLine(firstNamePath);
|
||||
}
|
||||
|
||||
string lastNamePath = (ToolBox.GetAttributeString(doc.Root.Element("name"), "lastname", ""));
|
||||
string lastNamePath = ToolBox.GetAttributeString(doc.Root.Element("name"), "lastname", "");
|
||||
if (lastNamePath != "")
|
||||
{
|
||||
lastNamePath = lastNamePath.Replace("[GENDER]", (this.Gender == Gender.Female) ? "f" : "");
|
||||
@@ -101,21 +101,31 @@ namespace Subsurface
|
||||
Salary = ToolBox.GetAttributeInt(element, "salary", 1000);
|
||||
|
||||
HeadSpriteId = ToolBox.GetAttributeInt(element, "headspriteid", 1);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().ToLower() != "job") continue;
|
||||
|
||||
Job = new Job(subElement);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual XElement Save(XElement parentElement)
|
||||
{
|
||||
XElement componentElement = new XElement("character");
|
||||
XElement charElement = new XElement("character");
|
||||
|
||||
componentElement.Add(
|
||||
charElement.Add(
|
||||
new XAttribute("name", Name),
|
||||
new XAttribute("file", File),
|
||||
new XAttribute("gender", Gender == Gender.Male ? "male" : "female"),
|
||||
new XAttribute("salary", Salary),
|
||||
new XAttribute("headspriteid", HeadSpriteId));
|
||||
|
||||
parentElement.Add(componentElement);
|
||||
return componentElement;
|
||||
Job.Save(charElement);
|
||||
|
||||
parentElement.Add(charElement);
|
||||
return charElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,9 +98,7 @@ namespace Subsurface
|
||||
{
|
||||
floorY = rayStart.Y + (rayEnd.Y - rayStart.Y) * closestFraction;
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine(floorY+" - "+inWater);
|
||||
|
||||
|
||||
|
||||
IgnorePlatforms = (TargetMovement.Y < 0.0f);
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Subsurface.Characters
|
||||
{
|
||||
class Job
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
@@ -23,17 +24,29 @@ namespace Subsurface
|
||||
get { return prefab.Description; }
|
||||
}
|
||||
|
||||
|
||||
public Job(JobPrefab jobPrefab)
|
||||
{
|
||||
prefab = jobPrefab;
|
||||
|
||||
skills = new Dictionary<string, float>();
|
||||
foreach (KeyValuePair<string, Vector2> skill in prefab.skills)
|
||||
foreach (KeyValuePair<string, Vector2> skill in prefab.Skills)
|
||||
{
|
||||
skills.Add(skill.Key, Rand.Range(skill.Value.X, skill.Value.Y, false));
|
||||
}
|
||||
}
|
||||
|
||||
public Job(XElement element)
|
||||
{
|
||||
string name = ToolBox.GetAttributeString(element, "name", "").ToLower();
|
||||
prefab = JobPrefab.List.Find(jp => jp.Name.ToLower() == name);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
skills.Add(subElement.Name.ToString(), ToolBox.GetAttributeFloat(subElement, "level", 0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
public static Job Random()
|
||||
{
|
||||
JobPrefab prefab = JobPrefab.List[Rand.Int(JobPrefab.List.Count-1, false)];
|
||||
@@ -48,5 +61,20 @@ namespace Subsurface
|
||||
|
||||
return skillLevel;
|
||||
}
|
||||
|
||||
public virtual XElement Save(XElement parentElement)
|
||||
{
|
||||
XElement jobElement = new XElement("job");
|
||||
|
||||
jobElement.Add(new XAttribute("name", Name));
|
||||
|
||||
foreach (KeyValuePair<string, float> skill in skills)
|
||||
{
|
||||
jobElement.Add(new XElement(skill.Key, new XAttribute("level", skill.Value)));
|
||||
}
|
||||
|
||||
parentElement.Add(jobElement);
|
||||
return jobElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,25 @@ namespace Subsurface
|
||||
|
||||
string name;
|
||||
string description;
|
||||
|
||||
//how many crew members can have the job (only one captain etc)
|
||||
private int maxNumber;
|
||||
|
||||
//how many crew members are REQUIRED to have a job
|
||||
//(i.e. if one captain is required, one captain is chosen even if all the players have set captain to lowest preference)
|
||||
private int minNumber;
|
||||
|
||||
//if set to true, a client that has chosen this as their preferred job will get it no matter what
|
||||
public bool AllowAlways
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
//names of the items the character spawns with
|
||||
public List<string> itemNames;
|
||||
public List<string> ItemNames;
|
||||
|
||||
public Dictionary<string, Vector2> skills;
|
||||
public Dictionary<string, Vector2> Skills;
|
||||
|
||||
public string Name
|
||||
{
|
||||
@@ -27,19 +41,15 @@ namespace Subsurface
|
||||
get { return description; }
|
||||
}
|
||||
|
||||
//public float GetSkill(string skillName)
|
||||
//{
|
||||
// float skillLevel = 0.0f;
|
||||
// if (skills.TryGetValue(skillName.ToLower(), out skillLevel))
|
||||
// {
|
||||
// return skillLevel;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// DebugConsole.ThrowError("Skill ''"+skillName+" not found!");
|
||||
// return skillLevel;
|
||||
// }
|
||||
//}
|
||||
public int MaxNumber
|
||||
{
|
||||
get { return maxNumber; }
|
||||
}
|
||||
|
||||
public int MinNumber
|
||||
{
|
||||
get { return minNumber; }
|
||||
}
|
||||
|
||||
public JobPrefab(XElement element)
|
||||
{
|
||||
@@ -47,9 +57,14 @@ namespace Subsurface
|
||||
|
||||
description = ToolBox.GetAttributeString(element, "description", "");
|
||||
|
||||
itemNames = new List<string>();
|
||||
minNumber = ToolBox.GetAttributeInt(element, "minnumber", 0);
|
||||
maxNumber = ToolBox.GetAttributeInt(element, "maxnumber", 10);
|
||||
|
||||
skills = new Dictionary<string, Vector2>();
|
||||
AllowAlways = ToolBox.GetAttributeBool(element, "allowalways", false);
|
||||
|
||||
ItemNames = new List<string>();
|
||||
|
||||
Skills = new Dictionary<string, Vector2>();
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
@@ -57,7 +72,7 @@ namespace Subsurface
|
||||
{
|
||||
case "item":
|
||||
string itemName = ToolBox.GetAttributeString(subElement, "name", "");
|
||||
if (!string.IsNullOrEmpty(itemName)) itemNames.Add(itemName);
|
||||
if (!string.IsNullOrEmpty(itemName)) ItemNames.Add(itemName);
|
||||
break;
|
||||
case "skills":
|
||||
LoadSkills(subElement);
|
||||
@@ -70,18 +85,18 @@ namespace Subsurface
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
string skillName = subElement.Name.ToString().ToLower();
|
||||
if (skills.ContainsKey(skillName)) continue;
|
||||
string skillName = subElement.Name.ToString();
|
||||
if (Skills.ContainsKey(skillName)) continue;
|
||||
|
||||
var levelAttribute = subElement.Attribute("level").ToString();
|
||||
if (levelAttribute.Contains("'"))
|
||||
{
|
||||
skills.Add(skillName, ToolBox.ParseToVector2(levelAttribute, false));
|
||||
Skills.Add(skillName, ToolBox.ParseToVector2(levelAttribute, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
float skillLevel = float.Parse(levelAttribute, CultureInfo.InvariantCulture);
|
||||
skills.Add(skillName, new Vector2(skillLevel, skillLevel));
|
||||
Skills.Add(skillName, new Vector2(skillLevel, skillLevel));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace Subsurface
|
||||
|
||||
if (commands[1].ToLower()=="human")
|
||||
{
|
||||
WayPoint spawnPoint = WayPoint.GetRandom(WayPoint.SpawnType.Human);
|
||||
WayPoint spawnPoint = WayPoint.GetRandom(SpawnType.Human);
|
||||
Character.Controlled = new Character("Content/Characters/Human/human.xml", (spawnPoint == null) ? Vector2.Zero : spawnPoint.SimPosition);
|
||||
if (Game1.GameSession != null)
|
||||
{
|
||||
@@ -158,7 +158,7 @@ namespace Subsurface
|
||||
}
|
||||
else
|
||||
{
|
||||
WayPoint spawnPoint = WayPoint.GetRandom(WayPoint.SpawnType.Enemy);
|
||||
WayPoint spawnPoint = WayPoint.GetRandom(SpawnType.Enemy);
|
||||
new Character("Content/Characters/" + commands[1] + "/" + commands[1] + ".xml", (spawnPoint == null) ? Vector2.Zero : spawnPoint.SimPosition);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Subsurface
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
WayPoint randomWayPoint = WayPoint.GetRandom(WayPoint.SpawnType.Enemy);
|
||||
WayPoint randomWayPoint = WayPoint.GetRandom(SpawnType.Enemy);
|
||||
|
||||
int amount = Rand.Range(minAmount, maxAmount, false);
|
||||
|
||||
|
||||
@@ -92,11 +92,13 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
|
||||
public static ScriptedEvent LoadRandom()
|
||||
public static ScriptedEvent LoadRandom(string seed)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(configFile);
|
||||
if (doc == null) return null;
|
||||
|
||||
Random rand = new Random(seed.GetHashCode());
|
||||
|
||||
int eventCount = doc.Root.Elements().Count();
|
||||
//int[] commonness = new int[eventCount];
|
||||
float[] eventProbability = new float[eventCount];
|
||||
@@ -123,9 +125,9 @@ namespace Subsurface
|
||||
probabilitySum += eventProbability[i];
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
float randomNumber = Rand.Range(0.0f,probabilitySum);
|
||||
float randomNumber = (float)rand.NextDouble() * probabilitySum;
|
||||
|
||||
i = 0;
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace Subsurface
|
||||
tasks.Add(newTask);
|
||||
}
|
||||
|
||||
public void StartShift(int scriptedEventCount)
|
||||
public void StartShift(Level level)
|
||||
{
|
||||
CreateScriptedEvents(scriptedEventCount);
|
||||
CreateScriptedEvents(level);
|
||||
|
||||
taskListBox.ClearChildren();
|
||||
}
|
||||
@@ -59,13 +59,11 @@ namespace Subsurface
|
||||
tasks.Clear();
|
||||
}
|
||||
|
||||
private void CreateScriptedEvents(int scriptedEventCount)
|
||||
private void CreateScriptedEvents(Level level)
|
||||
{
|
||||
for (int i = 0; i < scriptedEventCount; i++)
|
||||
{
|
||||
ScriptedEvent scriptedEvent = ScriptedEvent.LoadRandom();
|
||||
AddTask(new ScriptedTask(scriptedEvent));
|
||||
}
|
||||
ScriptedEvent scriptedEvent = ScriptedEvent.LoadRandom(level.Seed);
|
||||
AddTask(new ScriptedTask(scriptedEvent));
|
||||
|
||||
}
|
||||
|
||||
public void TaskStarted(Task task)
|
||||
|
||||
+11
-8
@@ -264,15 +264,18 @@ namespace Subsurface
|
||||
|
||||
public static void Draw(float deltaTime, SpriteBatch spriteBatch, Camera cam)
|
||||
{
|
||||
//spriteBatch.DrawString(font,
|
||||
// "FPS: " + (int)Game1.frameCounter.AverageFramesPerSecond
|
||||
// + " - render: " + Game1.renderTimeElapsed,
|
||||
// new Vector2(10, 10), Color.White);
|
||||
spriteBatch.DrawString(font,
|
||||
"FPS: " + (int)Game1.frameCounter.AverageFramesPerSecond,
|
||||
new Vector2(10, 10), Color.White);
|
||||
|
||||
//spriteBatch.DrawString(font,
|
||||
// "Physics: " + Game1.world.UpdateTime
|
||||
// + " - bodies: " + Game1.world.BodyList.Count,
|
||||
// new Vector2(10, 30), Color.White);
|
||||
spriteBatch.DrawString(font,
|
||||
"Physics: " + Game1.World.UpdateTime
|
||||
+ " - bodies: " + Game1.World.BodyList.Count,
|
||||
new Vector2(10, 30), Color.White);
|
||||
|
||||
spriteBatch.DrawString(font,
|
||||
"Camera pos: " + Game1.GameScreen.Cam.Position,
|
||||
new Vector2(10, 50), Color.White);
|
||||
|
||||
|
||||
if (Character.Controlled != null && cam!=null) Character.Controlled.DrawHud(spriteBatch, cam);
|
||||
|
||||
@@ -142,6 +142,8 @@ namespace Subsurface
|
||||
sprites = new List<Sprite>();
|
||||
children = new List<GUIComponent>();
|
||||
|
||||
|
||||
|
||||
if (style!=null) style.Apply(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +89,11 @@ namespace Subsurface
|
||||
public GUITextBox(Rectangle rect, Color? color, Color? textColor, Alignment alignment, Alignment textAlignment = Alignment.Left, GUIStyle style = null, GUIComponent parent = null)
|
||||
: base(style)
|
||||
{
|
||||
Enabled = true;
|
||||
|
||||
this.rect = rect;
|
||||
|
||||
if (color!=null) this.color = (Color)color;
|
||||
if (color != null) this.color = (Color)color;
|
||||
|
||||
this.alignment = alignment;
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Subsurface
|
||||
|
||||
foreach (CharacterInfo ci in characterInfos)
|
||||
{
|
||||
WayPoint randomWayPoint = WayPoint.GetRandom(WayPoint.SpawnType.Human);
|
||||
WayPoint randomWayPoint = WayPoint.GetRandom(SpawnType.Human);
|
||||
Vector2 position = (randomWayPoint == null) ? Vector2.Zero : randomWayPoint.SimPosition;
|
||||
|
||||
Character character = new Character(ci.File, position, ci);
|
||||
|
||||
@@ -111,14 +111,14 @@ namespace Subsurface
|
||||
this.savePath = savePath;
|
||||
}
|
||||
|
||||
public void StartShift(TimeSpan duration, string levelSeed, int scriptedEventCount = 1)
|
||||
public void StartShift(TimeSpan duration, string levelSeed)
|
||||
{
|
||||
Level level = Level.CreateRandom(levelSeed);
|
||||
|
||||
StartShift(duration, level, scriptedEventCount);
|
||||
StartShift(duration, level);
|
||||
}
|
||||
|
||||
public void StartShift(TimeSpan duration, Level level, int scriptedEventCount = 1)
|
||||
public void StartShift(TimeSpan duration, Level level)
|
||||
{
|
||||
//if (crewManager.characterInfos.Count == 0) return;
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
//crewManager.StartShift();
|
||||
taskManager.StartShift(scriptedEventCount);
|
||||
taskManager.StartShift(level);
|
||||
}
|
||||
|
||||
public void EndShift(string endMessage)
|
||||
|
||||
@@ -285,7 +285,7 @@ namespace Subsurface
|
||||
{
|
||||
base.Move(amount);
|
||||
|
||||
if (itemList != null && body!=null)
|
||||
if (itemList != null && body != null)
|
||||
{
|
||||
amount = ConvertUnits.ToSimUnits(amount);
|
||||
//Vector2 pos = new Vector2(rect.X + rect.Width / 2.0f, rect.Y - rect.Height / 2.0f);
|
||||
@@ -296,7 +296,7 @@ namespace Subsurface
|
||||
ic.Move(amount);
|
||||
}
|
||||
|
||||
FindHull();
|
||||
if (body != null) FindHull();
|
||||
}
|
||||
|
||||
public Rectangle TransformTrigger(Rectangle trigger)
|
||||
|
||||
+61
-21
@@ -51,6 +51,11 @@ namespace Subsurface
|
||||
get { return ConvertUnits.ToDisplayUnits(cells[0].body.Position); }
|
||||
}
|
||||
|
||||
public string Seed
|
||||
{
|
||||
get { return seed; }
|
||||
}
|
||||
|
||||
public Level(string seed, int width, int height, int siteInterval)
|
||||
{
|
||||
this.seed = seed;
|
||||
@@ -66,7 +71,7 @@ namespace Subsurface
|
||||
{
|
||||
seed = Rand.Range(0, int.MaxValue, false).ToString();
|
||||
}
|
||||
return new Level((string)seed, 100000, 40000, 2000);
|
||||
return new Level(seed, 100000, 40000, 2000);
|
||||
}
|
||||
|
||||
public void Generate(float minWidth)
|
||||
@@ -86,7 +91,10 @@ namespace Subsurface
|
||||
Voronoi voronoi = new Voronoi(1.0);
|
||||
|
||||
List<Vector2> sites = new List<Vector2>();
|
||||
Random rand = new Random(ToolBox.SeedToInt(seed));
|
||||
|
||||
int aa = seed.GetHashCode();
|
||||
|
||||
Random rand = new Random(seed.GetHashCode());
|
||||
|
||||
float siteVariance = siteInterval * 0.8f;
|
||||
for (int x = siteInterval / 2; x < borders.Width; x += siteInterval)
|
||||
@@ -153,21 +161,29 @@ namespace Subsurface
|
||||
|
||||
//generate a path from the left edge of the map to right edge
|
||||
Rectangle pathBorders = new Rectangle(
|
||||
borders.X + (int)minWidth, borders.Y + (int)minWidth,
|
||||
borders.Right - (int)minWidth, borders.Y + borders.Height - (int)minWidth);
|
||||
borders.X + (int)minWidth * 2, borders.Y + (int)minWidth * 2,
|
||||
borders.Right - (int)minWidth * 4, borders.Y + borders.Height - (int)minWidth * 4);
|
||||
|
||||
List<VoronoiCell> pathCells = GeneratePath(rand,
|
||||
new Vector2((int)minWidth, rand.Next((int)minWidth, borders.Height - (int)minWidth)),
|
||||
new Vector2(borders.Width - (int)minWidth, rand.Next((int)minWidth, borders.Height - (int)minWidth)),
|
||||
new Vector2((int)minWidth * 2, rand.Next((int)minWidth * 2, borders.Height - (int)minWidth * 2)),
|
||||
new Vector2(borders.Width - (int)minWidth * 2, rand.Next((int)minWidth * 2, borders.Height - (int)minWidth * 2)),
|
||||
cells, pathBorders, minWidth);
|
||||
|
||||
for (int i = 0; i <3 ; i++ )
|
||||
{
|
||||
Vector2 position = pathCells[rand.Next((int)(pathCells.Count*0.5f), pathCells.Count - 2)].Center;
|
||||
WayPoint wayPoint = new WayPoint(new Rectangle((int)position.X, (int)position.Y, 10, 10));
|
||||
wayPoint.MoveWithLevel = true;
|
||||
wayPoint.SpawnType = SpawnType.Enemy;
|
||||
}
|
||||
|
||||
|
||||
//generate a couple of random paths
|
||||
for (int i = 0; i < rand.Next() % 3; i++)
|
||||
{
|
||||
pathBorders = new Rectangle(
|
||||
borders.X + siteInterval * 2, borders.Y - siteInterval * 2,
|
||||
borders.Right - siteInterval * 2, borders.Y + borders.Height - siteInterval * 2);
|
||||
//pathBorders = new Rectangle(
|
||||
//borders.X + siteInterval * 2, borders.Y - siteInterval * 2,
|
||||
//borders.Right - siteInterval * 2, borders.Y + borders.Height - siteInterval * 2);
|
||||
|
||||
Vector2 start = pathCells[rand.Next(1, pathCells.Count - 2)].Center;
|
||||
|
||||
@@ -236,7 +252,6 @@ namespace Subsurface
|
||||
|
||||
private List<VoronoiCell> GeneratePath(Random rand, Vector2 start, Vector2 end, List<VoronoiCell> cells, Microsoft.Xna.Framework.Rectangle limits, float minWidth, float wanderAmount = 0.3f)
|
||||
{
|
||||
|
||||
Stopwatch sw2 = new Stopwatch();
|
||||
sw2.Start();
|
||||
|
||||
@@ -503,6 +518,13 @@ namespace Subsurface
|
||||
bodyPoints[i] = ConvertUnits.ToSimUnits(bodyPoints[i]);
|
||||
}
|
||||
|
||||
for (int i = bodyPoints.Count-1; i >0 ; i--)
|
||||
{
|
||||
if (Vector2.Distance(bodyPoints[i], bodyPoints[i - 1]) < 0.1f) bodyPoints.RemoveAt(i);
|
||||
}
|
||||
|
||||
if (bodyPoints.Count < 2) continue;
|
||||
|
||||
Vertices bodyVertices = new Vertices(bodyPoints);
|
||||
|
||||
Body edgeBody = BodyFactory.CreateLoopShape(Game1.World, bodyVertices);
|
||||
@@ -528,12 +550,28 @@ namespace Subsurface
|
||||
|
||||
public void SetPosition(Vector2 pos)
|
||||
{
|
||||
Vector2 amount = ConvertUnits.ToSimUnits(pos - Position);
|
||||
Vector2 amount = pos - Position;
|
||||
Vector2 simAmount = ConvertUnits.ToSimUnits(amount);
|
||||
foreach (VoronoiCell cell in cells)
|
||||
{
|
||||
if (cell.body == null) continue;
|
||||
cell.body.SleepingAllowed = false;
|
||||
cell.body.SetTransform(cell.body.Position + amount, cell.body.Rotation);
|
||||
cell.body.SetTransform(cell.body.Position + simAmount, cell.body.Rotation);
|
||||
}
|
||||
|
||||
foreach (MapEntity mapEntity in MapEntity.mapEntityList)
|
||||
{
|
||||
Item item = mapEntity as Item;
|
||||
if (item == null)
|
||||
{
|
||||
if (!mapEntity.MoveWithLevel) continue;
|
||||
mapEntity.Move(amount);
|
||||
}
|
||||
else if (item.body != null)
|
||||
{
|
||||
if (item.CurrentHull != null) continue;
|
||||
item.SetTransform(item.SimPosition+amount, item.body.Rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,25 +602,27 @@ namespace Subsurface
|
||||
}
|
||||
else
|
||||
{
|
||||
if (limb.type == LimbType.LeftFoot || limb.type == LimbType.RightFoot) continue;
|
||||
limb.body.ApplyForce((simVelocity - prevVelocity) * 10.0f * limb.Mass);
|
||||
//if (limb.type == LimbType.LeftFoot || limb.type == LimbType.RightFoot) continue;
|
||||
//limb.body.ApplyForce((simVelocity - prevVelocity) * 10.0f * limb.Mass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Item item in Item.itemList)
|
||||
{
|
||||
if (item.CurrentHull != null) continue;
|
||||
if (item.body == null)
|
||||
foreach (MapEntity mapEntity in MapEntity.mapEntityList)
|
||||
{
|
||||
Item item = mapEntity as Item;
|
||||
if (item == null)
|
||||
{
|
||||
item.Move(velocity);
|
||||
if (!mapEntity.MoveWithLevel) continue;
|
||||
mapEntity.Move(velocity);
|
||||
}
|
||||
else
|
||||
else if (item.body!=null)
|
||||
{
|
||||
if (item.CurrentHull != null) continue;
|
||||
item.body.LinearVelocity += simVelocity;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
prevVelocity = simVelocity;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,12 @@ namespace Subsurface
|
||||
protected bool isHighlighted;
|
||||
|
||||
protected bool isSelected;
|
||||
|
||||
public bool MoveWithLevel
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
//the position and dimensions of the entity
|
||||
protected Rectangle rect;
|
||||
|
||||
+30
-13
@@ -148,6 +148,8 @@ namespace Subsurface
|
||||
//this.mapHash = new MapHash(md5Hash);
|
||||
}
|
||||
|
||||
base.Remove();
|
||||
|
||||
}
|
||||
|
||||
private List<Vector2> GenerateConvexHull()
|
||||
@@ -410,7 +412,7 @@ namespace Subsurface
|
||||
|
||||
if (targetPosition != Vector2.Zero && Vector2.Distance(targetPosition, Position) > 5.0f)
|
||||
{
|
||||
translateAmount += (targetPosition - Position)*0.1f;
|
||||
translateAmount += (targetPosition - Position) * 0.05f;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -433,7 +435,7 @@ namespace Subsurface
|
||||
//hullBodies[0].body.LinearVelocity = -hullBodies[0].body.Position;
|
||||
|
||||
//hullBody.SetTransform(Vector2.Zero , 0.0f);
|
||||
hullBody.LinearVelocity = -hullBody.Position;
|
||||
hullBody.LinearVelocity = -hullBody.Position/(float)Physics.step;
|
||||
|
||||
if (collidingCell == null)
|
||||
{
|
||||
@@ -515,13 +517,18 @@ namespace Subsurface
|
||||
VoronoiCell cell = f2.Body.UserData as VoronoiCell;
|
||||
if (cell==null) return true;
|
||||
|
||||
Vector2 normal = contact.Manifold.LocalNormal;
|
||||
float impact = Vector2.Dot(ConvertUnits.ToSimUnits(speed), normal);
|
||||
Vector2 normal = -contact.Manifold.LocalNormal;
|
||||
Vector2 simSpeed = ConvertUnits.ToSimUnits(speed);
|
||||
float impact = -Vector2.Dot(simSpeed, normal);
|
||||
|
||||
Vector2 u = Vector2.Dot(simSpeed, normal)*normal;
|
||||
Vector2 w = simSpeed - u;
|
||||
|
||||
speed = ConvertUnits.ToDisplayUnits(w*f2.Body.Friction - u*0.5f);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("IMPACT:"+impact);
|
||||
if (impact < 5.0f) return true;
|
||||
|
||||
|
||||
collisionRigidness = 0.8f;
|
||||
|
||||
collidingCell = cell;
|
||||
@@ -540,6 +547,9 @@ namespace Subsurface
|
||||
message.Write(Position.X);
|
||||
message.Write(Position.Y);
|
||||
|
||||
message.Write(speed.X);
|
||||
message.Write(speed.Y);
|
||||
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, NetIncomingMessage message)
|
||||
@@ -548,15 +558,16 @@ namespace Subsurface
|
||||
|
||||
if (sendingTime <= lastNetworkUpdate) return;
|
||||
|
||||
Vector2 newPosition = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||
if (newPosition == Position) return;
|
||||
if ((newPosition - Position).Length() > 500.0f)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Submarine has moved over 500 pixels since last update");
|
||||
return;
|
||||
}
|
||||
//Vector2 newPosition =
|
||||
//if (newPosition == Position) return;
|
||||
//if ((newPosition - Position).Length() > 500.0f)
|
||||
//{
|
||||
// System.Diagnostics.Debug.WriteLine("Submarine has moved over 500 pixels since last update");
|
||||
// return;
|
||||
//}
|
||||
|
||||
targetPosition = Position;
|
||||
targetPosition = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||
speed = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||
|
||||
lastNetworkUpdate = sendingTime;
|
||||
}
|
||||
@@ -809,6 +820,8 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
ID = 1;
|
||||
|
||||
loaded = this;
|
||||
}
|
||||
|
||||
@@ -825,6 +838,10 @@ namespace Subsurface
|
||||
public static void Unload()
|
||||
{
|
||||
if (loaded == null) return;
|
||||
|
||||
|
||||
loaded.Remove();
|
||||
|
||||
loaded.Clear();
|
||||
loaded = null;
|
||||
}
|
||||
|
||||
@@ -10,12 +10,19 @@ using System.Collections.ObjectModel;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
public enum SpawnType { None, Human, Enemy };
|
||||
class WayPoint : MapEntity
|
||||
{
|
||||
public enum SpawnType { None, Human, Enemy };
|
||||
|
||||
|
||||
private SpawnType spawnType;
|
||||
|
||||
public SpawnType SpawnType
|
||||
{
|
||||
get { return spawnType; }
|
||||
set { spawnType = value; }
|
||||
}
|
||||
|
||||
public override Vector2 SimPosition
|
||||
{
|
||||
get { return ConvertUnits.ToSimUnits(new Vector2(rect.X, rect.Y)); }
|
||||
@@ -31,7 +38,7 @@ namespace Subsurface
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
{
|
||||
if (!editing) return;
|
||||
//if (!editing) return;
|
||||
|
||||
Color clr = (isSelected) ? Color.Red : Color.LightGreen;
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(rect.X, -rect.Y, rect.Width, rect.Height), clr, true);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Diagnostics;
|
||||
using Lidgren.Network;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Subsurface.Networking
|
||||
{
|
||||
@@ -13,6 +14,8 @@ namespace Subsurface.Networking
|
||||
|
||||
private Character myCharacter;
|
||||
private CharacterInfo characterInfo;
|
||||
|
||||
List<Client> otherClients;
|
||||
|
||||
public Character Character
|
||||
{
|
||||
@@ -30,6 +33,8 @@ namespace Subsurface.Networking
|
||||
name = newName;
|
||||
|
||||
characterInfo = new CharacterInfo("Content/Characters/Human/human.xml", name);
|
||||
|
||||
otherClients = new List<Client>();
|
||||
}
|
||||
|
||||
public bool ConnectToServer(string hostIP)
|
||||
@@ -75,7 +80,7 @@ namespace Subsurface.Networking
|
||||
// Funtion that waits for connection approval info from server
|
||||
WaitForStartingInfo();
|
||||
|
||||
if (Client.ConnectionStatus!=NetConnectionStatus.Connected)
|
||||
if (Client.ConnectionStatus != NetConnectionStatus.Connected)
|
||||
{
|
||||
DebugConsole.ThrowError("Couldn't connect to server");
|
||||
return false;
|
||||
@@ -115,17 +120,21 @@ namespace Subsurface.Networking
|
||||
case NetIncomingMessageType.Data:
|
||||
if (inc.ReadByte() == (byte)PacketTypes.LoggedIn)
|
||||
{
|
||||
int myID = inc.ReadInt32();
|
||||
|
||||
//add the names of other connected clients to the lobby screen
|
||||
int existingClients = inc.ReadInt32();
|
||||
for (int i = 1; i <= existingClients; i++)
|
||||
{
|
||||
Game1.NetLobbyScreen.AddPlayer(inc.ReadString());
|
||||
Client otherClient = new Client(inc.ReadString(), inc.ReadInt32());
|
||||
|
||||
Game1.NetLobbyScreen.AddPlayer(otherClient);
|
||||
}
|
||||
|
||||
//add the name of own client to the lobby screen
|
||||
Game1.NetLobbyScreen.AddPlayer(name);
|
||||
Game1.NetLobbyScreen.AddPlayer(new Client(name, myID));
|
||||
|
||||
CanStart = true;
|
||||
CanStart = true;
|
||||
}
|
||||
else if (inc.ReadByte() == (byte)PacketTypes.KickedOut)
|
||||
{
|
||||
@@ -249,19 +258,18 @@ namespace Subsurface.Networking
|
||||
break;
|
||||
case (byte)PacketTypes.PlayerJoined:
|
||||
|
||||
Client otherClient = new Client();
|
||||
otherClient.name = inc.ReadString();
|
||||
Client otherClient = new Client(inc.ReadString(), inc.ReadInt32());
|
||||
|
||||
Game1.NetLobbyScreen.AddPlayer(otherClient.name);
|
||||
Game1.NetLobbyScreen.AddPlayer(otherClient);
|
||||
|
||||
AddChatMessage(otherClient.name + " has joined the server", ChatMessageType.Server);
|
||||
|
||||
break;
|
||||
case (byte)PacketTypes.PlayerLeft:
|
||||
string leavingName = inc.ReadString();
|
||||
int leavingID = inc.ReadInt32();
|
||||
|
||||
AddChatMessage(inc.ReadString(), ChatMessageType.Server);
|
||||
Game1.NetLobbyScreen.RemovePlayer(leavingName);
|
||||
Game1.NetLobbyScreen.RemovePlayer(otherClients.Find(c => c.ID==leavingID));
|
||||
break;
|
||||
|
||||
case (byte)PacketTypes.KickedOut:
|
||||
@@ -330,8 +338,15 @@ namespace Subsurface.Networking
|
||||
msg.Write(characterInfo.Gender == Gender.Male);
|
||||
msg.Write(characterInfo.HeadSpriteId);
|
||||
|
||||
Client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
|
||||
var jobPreferences = Game1.NetLobbyScreen.JobPreferences;
|
||||
int count = Math.Min(jobPreferences.Count, 3);
|
||||
msg.Write(count);
|
||||
for (int i = 0; i < count; i++ )
|
||||
{
|
||||
msg.Write(jobPreferences[i].Name);
|
||||
}
|
||||
|
||||
Client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
|
||||
}
|
||||
|
||||
private Character ReadCharacterData(NetIncomingMessage inc)
|
||||
@@ -340,9 +355,17 @@ namespace Subsurface.Networking
|
||||
int ID = inc.ReadInt32();
|
||||
bool isFemale = inc.ReadBoolean();
|
||||
int inventoryID = inc.ReadInt32();
|
||||
|
||||
int headSpriteID = inc.ReadInt32();
|
||||
|
||||
|
||||
string jobName = inc.ReadString();
|
||||
JobPrefab jobPrefab = JobPrefab.List.Find(jp => jp.Name == jobName);
|
||||
|
||||
Vector2 position = new Vector2(inc.ReadFloat(), inc.ReadFloat());
|
||||
|
||||
CharacterInfo ch = new CharacterInfo("Content/Characters/Human/human.xml", newName, isFemale ? Gender.Female : Gender.Male);
|
||||
CharacterInfo ch = new CharacterInfo("Content/Characters/Human/human.xml", newName, isFemale ? Gender.Female : Gender.Male, jobPrefab);
|
||||
ch.HeadSpriteId = headSpriteID;
|
||||
Character character = new Character(ch, position);
|
||||
character.ID = ID;
|
||||
character.Inventory.ID = inventoryID;
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace Subsurface.Networking
|
||||
|
||||
public List<Client> connectedClients = new List<Client>();
|
||||
|
||||
const int SparseUpdateInterval = 150;
|
||||
int sparseUpdateTimer;
|
||||
TimeSpan SparseUpdateInterval = new TimeSpan(0, 0, 0, 1);
|
||||
DateTime sparseUpdateTimer;
|
||||
|
||||
Client myClient;
|
||||
|
||||
@@ -61,16 +61,15 @@ namespace Subsurface.Networking
|
||||
if (inc != null) ReadMessage(inc);
|
||||
|
||||
// if 30ms has passed
|
||||
if ((updateTimer) < DateTime.Now)
|
||||
if (updateTimer < DateTime.Now)
|
||||
{
|
||||
if (Server.ConnectionsCount > 0)
|
||||
{
|
||||
if (sparseUpdateTimer <= 0) SparseUpdate();
|
||||
if (sparseUpdateTimer < DateTime.Now) SparseUpdate();
|
||||
|
||||
SendNetworkEvents();
|
||||
}
|
||||
|
||||
sparseUpdateTimer -= 1;
|
||||
updateTimer = DateTime.Now + updateInterval;
|
||||
}
|
||||
}
|
||||
@@ -88,10 +87,18 @@ namespace Subsurface.Networking
|
||||
|
||||
//Character ch = new Character("Content/Characters/Human/human.xml");
|
||||
|
||||
Client newClient = new Client();
|
||||
newClient.version = inc.ReadString();
|
||||
newClient.name = inc.ReadString();
|
||||
string version = inc.ReadString();
|
||||
string name = inc.ReadString();
|
||||
|
||||
int id = 1;
|
||||
while (connectedClients.Find(c=>c.ID==id)!=null)
|
||||
{
|
||||
id++;
|
||||
}
|
||||
|
||||
Client newClient = new Client(name, id);
|
||||
newClient.Connection = inc.SenderConnection;
|
||||
newClient.version = version;
|
||||
|
||||
connectedClients.Add(newClient);
|
||||
|
||||
@@ -101,8 +108,6 @@ namespace Subsurface.Networking
|
||||
Debug.WriteLine(inc.SenderConnection + " status changed. " + (NetConnectionStatus)inc.SenderConnection.Status);
|
||||
if (inc.SenderConnection.Status == NetConnectionStatus.Connected)
|
||||
{
|
||||
|
||||
|
||||
Client sender = connectedClients.Find(x => x.Connection == inc.SenderConnection);
|
||||
|
||||
if (sender == null) break;
|
||||
@@ -115,20 +120,24 @@ namespace Subsurface.Networking
|
||||
}
|
||||
else
|
||||
{
|
||||
AssignJobs();
|
||||
|
||||
Game1.NetLobbyScreen.AddPlayer(sender.name);
|
||||
Game1.NetLobbyScreen.AddPlayer(sender);
|
||||
|
||||
// Notify the client that they have logged in
|
||||
outmsg = Server.CreateMessage();
|
||||
|
||||
outmsg.Write((byte)PacketTypes.LoggedIn);
|
||||
|
||||
outmsg.Write(sender.ID);
|
||||
|
||||
//notify the client about other clients already logged in
|
||||
outmsg.Write((myClient == null) ? connectedClients.Count - 1 : connectedClients.Count);
|
||||
foreach (Client c in connectedClients)
|
||||
{
|
||||
if (c.Connection == inc.SenderConnection) continue;
|
||||
outmsg.Write(c.name);
|
||||
outmsg.Write(c.ID);
|
||||
}
|
||||
|
||||
if (myClient != null) outmsg.Write(myClient.name);
|
||||
@@ -141,6 +150,7 @@ namespace Subsurface.Networking
|
||||
outmsg.Write((byte)PacketTypes.PlayerJoined);
|
||||
|
||||
outmsg.Write(sender.name);
|
||||
outmsg.Write(sender.ID);
|
||||
|
||||
//send the message to everyone except the client who just logged in
|
||||
SendMessage(outmsg, NetDeliveryMethod.ReliableUnordered, inc.SenderConnection);
|
||||
@@ -223,7 +233,9 @@ namespace Subsurface.Networking
|
||||
}
|
||||
}
|
||||
|
||||
sparseUpdateTimer = SparseUpdateInterval;
|
||||
new NetworkEvent(Submarine.Loaded.ID, false);
|
||||
|
||||
sparseUpdateTimer = DateTime.Now + SparseUpdateInterval;
|
||||
}
|
||||
|
||||
private void SendMessage(NetOutgoingMessage msg, NetDeliveryMethod deliveryMethod, NetConnection excludedConnection)
|
||||
@@ -256,8 +268,12 @@ namespace Subsurface.Networking
|
||||
|
||||
networkEvent.FillData(message);
|
||||
|
||||
Server.SendMessage(message, Server.Connections,
|
||||
(networkEvent.IsImportant) ? NetDeliveryMethod.Unreliable : NetDeliveryMethod.ReliableUnordered, 0);
|
||||
if (Server.ConnectionsCount>0)
|
||||
{
|
||||
Server.SendMessage(message, Server.Connections,
|
||||
(networkEvent.IsImportant) ? NetDeliveryMethod.Unreliable : NetDeliveryMethod.ReliableUnordered, 0);
|
||||
}
|
||||
|
||||
}
|
||||
NetworkEvent.events.Clear();
|
||||
}
|
||||
@@ -273,14 +289,14 @@ namespace Subsurface.Networking
|
||||
//selectedMap.Load();
|
||||
|
||||
Game1.GameSession = new GameSession(selectedMap, Game1.NetLobbyScreen.SelectedMode);
|
||||
Game1.GameSession.StartShift(Game1.NetLobbyScreen.GameDuration, Game1.NetLobbyScreen.LevelSeed, 1);
|
||||
Game1.GameSession.StartShift(Game1.NetLobbyScreen.GameDuration, Game1.NetLobbyScreen.LevelSeed);
|
||||
//EventManager.SelectEvent(Game1.netLobbyScreen.SelectedEvent);
|
||||
|
||||
foreach (Client client in connectedClients)
|
||||
{
|
||||
client.inGame = true;
|
||||
|
||||
WayPoint spawnPoint = WayPoint.GetRandom(WayPoint.SpawnType.Human);
|
||||
WayPoint spawnPoint = WayPoint.GetRandom(SpawnType.Human);
|
||||
|
||||
if (client.characterInfo==null)
|
||||
{
|
||||
@@ -292,7 +308,7 @@ namespace Subsurface.Networking
|
||||
|
||||
if (myClient != null)
|
||||
{
|
||||
WayPoint spawnPoint = WayPoint.GetRandom(WayPoint.SpawnType.Human);
|
||||
WayPoint spawnPoint = WayPoint.GetRandom(SpawnType.Human);
|
||||
CharacterInfo ch = new CharacterInfo("Content/Characters/Human/human.xml", myClient.name);
|
||||
myClient.character = new Character(ch, (spawnPoint == null) ? Vector2.Zero : spawnPoint.SimPosition);
|
||||
}
|
||||
@@ -390,10 +406,10 @@ namespace Subsurface.Networking
|
||||
|
||||
outmsg = Server.CreateMessage();
|
||||
outmsg.Write((byte)PacketTypes.PlayerLeft);
|
||||
outmsg.Write(client.name);
|
||||
outmsg.Write(client.ID);
|
||||
outmsg.Write(msg);
|
||||
|
||||
Game1.NetLobbyScreen.RemovePlayer(client.name);
|
||||
Game1.NetLobbyScreen.RemovePlayer(client);
|
||||
|
||||
if (Server.Connections.Count > 0)
|
||||
{
|
||||
@@ -482,11 +498,24 @@ namespace Subsurface.Networking
|
||||
Gender gender = message.ReadBoolean() ? Gender.Male : Gender.Female;
|
||||
int headSpriteId = message.ReadInt32();
|
||||
|
||||
|
||||
List<JobPrefab> jobPreferences = new List<JobPrefab>();
|
||||
int count = message.ReadInt32();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
string jobName = message.ReadString();
|
||||
JobPrefab jobPrefab = JobPrefab.List.Find(jp => jp.Name == jobName);
|
||||
if (jobPrefab != null) jobPreferences.Add(jobPrefab);
|
||||
}
|
||||
|
||||
foreach (Client c in connectedClients)
|
||||
{
|
||||
if (c.Connection != message.SenderConnection) continue;
|
||||
|
||||
c.characterInfo = new CharacterInfo("Content/Characters/Human/human.xml", name, gender);
|
||||
c.characterInfo.HeadSpriteId = headSpriteId;
|
||||
c.jobPreferences = jobPreferences;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,19 +525,116 @@ namespace Subsurface.Networking
|
||||
message.Write(character.ID);
|
||||
message.Write(character.Info.Gender == Gender.Female);
|
||||
message.Write(character.Inventory.ID);
|
||||
|
||||
message.Write(character.Info.HeadSpriteId);
|
||||
|
||||
message.Write(character.SimPosition.X);
|
||||
message.Write(character.SimPosition.Y);
|
||||
|
||||
message.Write(character.Info.Job.Name);
|
||||
}
|
||||
|
||||
private void AssignJobs()
|
||||
{
|
||||
List<Client> unassigned = new List<Client>(connectedClients);
|
||||
|
||||
int[] assignedClientCount = new int[JobPrefab.List.Count];
|
||||
|
||||
//if any of the players has chosen a job that is Always Allowed, give them that job
|
||||
for (int i = unassigned.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (!unassigned[i].jobPreferences[0].AllowAlways) continue;
|
||||
unassigned[i].assignedJob = unassigned[i].jobPreferences[0];
|
||||
unassigned.RemoveAt(i);
|
||||
}
|
||||
|
||||
//go throught the jobs whose MinNumber>0 (i.e. at least one crew member has to have the job)
|
||||
bool unassignedJobsFound = true;
|
||||
while (unassignedJobsFound && unassigned.Count > 0)
|
||||
{
|
||||
unassignedJobsFound = false;
|
||||
for (int i = 0; i < JobPrefab.List.Count; i++)
|
||||
{
|
||||
if (unassigned.Count == 0) break;
|
||||
if (JobPrefab.List[i].MinNumber < 1 || assignedClientCount[i] >= JobPrefab.List[i].MinNumber) continue;
|
||||
|
||||
//find the client that wants the job the most, or force it to random client if none of them want it
|
||||
Client assignedClient = FindClientWithJobPreference(unassigned, JobPrefab.List[i], true);
|
||||
|
||||
assignedClient.assignedJob = JobPrefab.List[i];
|
||||
|
||||
assignedClientCount[i]++;
|
||||
unassigned.Remove(assignedClient);
|
||||
|
||||
//the job still needs more crew members, set unassignedJobsFound to true to keep the while loop running
|
||||
if (assignedClientCount[i] < JobPrefab.List[i].MinNumber) unassignedJobsFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (int preferenceIndex = 0; preferenceIndex < 3; preferenceIndex++)
|
||||
{
|
||||
for (int i = unassigned.Count - 1; i >= 0; i--)
|
||||
{
|
||||
int jobIndex = JobPrefab.List.FindIndex(jp => jp == unassigned[i].jobPreferences[preferenceIndex]);
|
||||
|
||||
//if there's enough crew members assigned to the job already, continue
|
||||
if (assignedClientCount[jobIndex] >= JobPrefab.List[jobIndex].MaxNumber) continue;
|
||||
|
||||
unassigned[i].assignedJob = JobPrefab.List[i];
|
||||
|
||||
assignedClientCount[jobIndex]++;
|
||||
unassigned.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateNetLobby(null);
|
||||
|
||||
}
|
||||
|
||||
private Client FindClientWithJobPreference(List<Client> clients, JobPrefab job, bool forceAssign = false)
|
||||
{
|
||||
int bestPreference = 0;
|
||||
Client preferredClient = null;
|
||||
foreach (Client c in clients)
|
||||
{
|
||||
int index = c.jobPreferences.FindIndex(jp => jp == job);
|
||||
if (preferredClient == null || index < bestPreference)
|
||||
{
|
||||
bestPreference = index;
|
||||
preferredClient = c;
|
||||
}
|
||||
}
|
||||
|
||||
//none of the clients wants the job
|
||||
if (forceAssign && preferredClient == null)
|
||||
{
|
||||
preferredClient = clients[Rand.Int(clients.Count)];
|
||||
}
|
||||
|
||||
return preferredClient;
|
||||
}
|
||||
}
|
||||
|
||||
class Client
|
||||
{
|
||||
public string name;
|
||||
public int ID;
|
||||
|
||||
public Character character;
|
||||
public CharacterInfo characterInfo;
|
||||
public NetConnection Connection { get; set; }
|
||||
public string version;
|
||||
public bool inGame;
|
||||
|
||||
public List<JobPrefab> jobPreferences;
|
||||
public JobPrefab assignedJob;
|
||||
|
||||
public Client(string name, int ID)
|
||||
{
|
||||
this.name = name;
|
||||
this.ID = ID;
|
||||
|
||||
jobPreferences = new List<JobPrefab>(JobPrefab.List.GetRange(0,3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using FarseerPhysics;
|
||||
using FarseerPhysics.Factories;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
@@ -17,8 +18,13 @@ namespace Subsurface
|
||||
private GUIListBox playerList;
|
||||
|
||||
private GUIListBox subList, modeList, chatBox;
|
||||
|
||||
private GUIListBox jobList;
|
||||
|
||||
private GUITextBox textBox;
|
||||
|
||||
private GUITextBox seedBox;
|
||||
|
||||
private GUIScrollBar durationBar;
|
||||
|
||||
private GUIFrame playerFrame;
|
||||
@@ -50,10 +56,34 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
public List<JobPrefab> JobPreferences
|
||||
{
|
||||
get
|
||||
{
|
||||
List<JobPrefab> jobPreferences = new List<JobPrefab>();
|
||||
foreach (GUIComponent child in jobList.children)
|
||||
{
|
||||
JobPrefab jobPrefab = child.UserData as JobPrefab;
|
||||
if (jobPrefab == null) continue;
|
||||
jobPreferences.Add(jobPrefab);
|
||||
}
|
||||
return jobPreferences;
|
||||
}
|
||||
}
|
||||
|
||||
private string levelSeed;
|
||||
|
||||
public string LevelSeed
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
get
|
||||
{
|
||||
return levelSeed;
|
||||
}
|
||||
private set
|
||||
{
|
||||
levelSeed = value;
|
||||
seedBox.Text = levelSeed;
|
||||
}
|
||||
}
|
||||
|
||||
public string DurationText()
|
||||
@@ -99,7 +129,7 @@ namespace Subsurface
|
||||
(int)(panelRect.Width * 0.4f - 20), (int)(panelRect.Height * 0.4f - 20)),
|
||||
GUI.style, menu);
|
||||
|
||||
playerList = new GUIListBox(new Rectangle(0,0,0,0), Color.White, null, playerListFrame);
|
||||
playerList = new GUIListBox(new Rectangle(0,0,0,0), null, GUI.style, playerListFrame);
|
||||
}
|
||||
|
||||
public override void Deselect()
|
||||
@@ -133,7 +163,7 @@ namespace Subsurface
|
||||
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected submarine:", null, null, Alignment.Left, null, infoFrame);
|
||||
subList = new GUIListBox(new Rectangle(0, 60, 200, 200), Color.White, GUI.style, infoFrame);
|
||||
subList.OnSelected = SelectMap;
|
||||
subList.Enabled = (Game1.Server!=null);
|
||||
subList.Enabled = (Game1.Server != null);
|
||||
|
||||
if (Submarine.SavedSubmarines.Count > 0)
|
||||
{
|
||||
@@ -180,17 +210,18 @@ 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);
|
||||
|
||||
GUITextBox seedBox = new GUITextBox(new Rectangle((int)(modeList.Rect.Right + 20 - 80), 130, 180, 20),
|
||||
seedBox = new GUITextBox(new Rectangle((int)(modeList.Rect.Right + 20 - 80), 130, 180, 20),
|
||||
Alignment.TopLeft, GUI.style, infoFrame);
|
||||
seedBox.OnEnter = SelectSeed;
|
||||
seedBox.Enabled = (Game1.Server != null);
|
||||
|
||||
if (IsServer && Game1.Server!=null)
|
||||
LevelSeed = ToolBox.RandomSeed(8);
|
||||
|
||||
if (IsServer && Game1.Server != null)
|
||||
{
|
||||
GUIButton startButton = new GUIButton(new Rectangle(0, 0, 200, 30), "Start", GUI.style, infoFrame);
|
||||
startButton.OnClicked = Game1.Server.StartGame;
|
||||
@@ -225,11 +256,13 @@ namespace Subsurface
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 150, 200, 30), "Job preferences:", GUI.style, playerFrame);
|
||||
|
||||
GUIListBox jobList = new GUIListBox(new Rectangle(0,180,200,0), GUI.style, playerFrame);
|
||||
jobList = new GUIListBox(new Rectangle(0, 180, 200, 0), GUI.style, playerFrame);
|
||||
|
||||
foreach (JobPrefab job in JobPrefab.List)
|
||||
{
|
||||
GUITextBlock jobText = new GUITextBlock(new Rectangle(0,0,0,20), job.Name, GUI.style, jobList);
|
||||
jobText.UserData = job;
|
||||
|
||||
GUIButton upButton = new GUIButton(new Rectangle(jobText.Rect.Width - 40, 0, 20, 20), "u", GUI.style, jobText);
|
||||
upButton.UserData = -1;
|
||||
upButton.OnClicked += ChangeJobPreference;
|
||||
@@ -250,33 +283,32 @@ namespace Subsurface
|
||||
{
|
||||
if (Game1.Server != null) Game1.Server.UpdateNetLobby(obj);
|
||||
|
||||
Submarine map = (Submarine)obj;
|
||||
Submarine sub = (Submarine)obj;
|
||||
|
||||
//map already loaded
|
||||
if (Submarine.Loaded!=null && map.FilePath == Submarine.Loaded.FilePath) return true;
|
||||
//submarine already loaded
|
||||
if (Submarine.Loaded != null && sub.FilePath == Submarine.Loaded.FilePath) return true;
|
||||
|
||||
map.Load();
|
||||
sub.Load();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void AddPlayer(string name)
|
||||
public void AddPlayer(Client client)
|
||||
{
|
||||
GUITextBlock textBlock = new GUITextBlock(
|
||||
new Rectangle(0, 0, 0, 25),
|
||||
name,
|
||||
GUI.style,
|
||||
Alignment.Left,
|
||||
Alignment.Left,
|
||||
client.name + ((client.assignedJob==null) ? "" : " (" + client.assignedJob.Name + ")"),
|
||||
GUI.style, Alignment.Left, Alignment.Left,
|
||||
playerList);
|
||||
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
|
||||
textBlock.UserData = name;
|
||||
textBlock.UserData = client;
|
||||
}
|
||||
|
||||
public void RemovePlayer(string name)
|
||||
public void RemovePlayer(Client client)
|
||||
{
|
||||
playerList.RemoveChild(playerList.GetChild(name));
|
||||
if (client == null) return;
|
||||
playerList.RemoveChild(playerList.GetChild(client));
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
@@ -378,15 +410,15 @@ namespace Subsurface
|
||||
Game1.Client.Character = character;
|
||||
|
||||
character.AnimController.IsStanding = true;
|
||||
|
||||
if (previewPlatform==null)
|
||||
|
||||
if (previewPlatform == null)
|
||||
{
|
||||
Body platform = BodyFactory.CreateRectangle(Game1.World, 3.0f, 1.0f, 5.0f);
|
||||
platform.SetTransform(new Vector2(pos.X, pos.Y - 2.5f), 0.0f);
|
||||
platform.IsStatic = true;
|
||||
}
|
||||
|
||||
if (previewHull==null)
|
||||
if (previewHull == null)
|
||||
{
|
||||
pos = ConvertUnits.ToDisplayUnits(pos);
|
||||
previewHull = new Hull(new Rectangle((int)pos.X - 100, (int)pos.Y + 100, 200, 200));
|
||||
@@ -400,6 +432,8 @@ namespace Subsurface
|
||||
character.AnimController.UpdateAnim((float)Physics.step);
|
||||
Game1.World.Step((float)Physics.step);
|
||||
}
|
||||
|
||||
Game1.Client.SendCharacterData();
|
||||
}
|
||||
|
||||
private bool SwitchGender(GUIButton button, object obj)
|
||||
@@ -420,15 +454,16 @@ namespace Subsurface
|
||||
|
||||
private bool SelectSeed(GUITextBox textBox, string seed)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(seed))
|
||||
{
|
||||
textBox.Text = LevelSeed;
|
||||
}
|
||||
else
|
||||
if (!string.IsNullOrWhiteSpace(seed))
|
||||
{
|
||||
LevelSeed = seed;
|
||||
}
|
||||
|
||||
//textBox.Text = LevelSeed;
|
||||
textBox.Selected = false;
|
||||
|
||||
if (Game1.Server != null) Game1.Server.UpdateNetLobby(null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -473,6 +508,8 @@ namespace Subsurface
|
||||
|
||||
listBox.children[i].Color = color;
|
||||
}
|
||||
|
||||
Game1.Client.SendCharacterData();
|
||||
}
|
||||
|
||||
public bool TrySelectMap(string mapName, string md5Hash)
|
||||
@@ -518,9 +555,18 @@ namespace Subsurface
|
||||
msg.Write(selectedMap.Hash.MD5Hash);
|
||||
}
|
||||
|
||||
msg.Write(modeList.SelectedIndex);
|
||||
msg.Write(modeList.SelectedIndex-1);
|
||||
msg.Write(durationBar.BarScroll);
|
||||
msg.Write(LevelSeed);
|
||||
|
||||
msg.Write(playerList.CountChildren - 1);
|
||||
for (int i = 1; i < playerList.CountChildren; i++)
|
||||
{
|
||||
Client client = playerList.children[i].UserData as Client;
|
||||
msg.Write(client.ID);
|
||||
msg.Write(client.assignedJob==null ? "" : client.assignedJob.Name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -539,6 +585,32 @@ namespace Subsurface
|
||||
durationBar.BarScroll = msg.ReadFloat();
|
||||
|
||||
LevelSeed = msg.ReadString();
|
||||
|
||||
int playerCount = msg.ReadInt32();
|
||||
for (int i = 0; i < playerCount; i++)
|
||||
{
|
||||
int clientID = msg.ReadInt32();
|
||||
string jobName = msg.ReadString();
|
||||
|
||||
|
||||
Client client = null;
|
||||
GUITextBlock textBlock = null;
|
||||
foreach (GUIComponent child in playerList.children)
|
||||
{
|
||||
Client tempClient = child.UserData as Client;
|
||||
if (tempClient == null || tempClient.ID != clientID) continue;
|
||||
|
||||
client = tempClient;
|
||||
textBlock = child as GUITextBlock;
|
||||
break;
|
||||
}
|
||||
if (client == null) continue;
|
||||
|
||||
client.assignedJob = JobPrefab.List.Find(jp => jp.Name == jobName);
|
||||
|
||||
textBlock.Text = client.name + ((client.assignedJob==null) ? "" : " (" + client.assignedJob.Name + ")");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+72
-78
@@ -1,8 +1,5 @@
|
||||
<stylecopresultscache>
|
||||
<version>12</version>
|
||||
<project key="2115933639">
|
||||
<configuration>DEBUG;TRACE;WINDOWS</configuration>
|
||||
</project>
|
||||
<sourcecode name="Camera.cs" parser="StyleCop.CSharp.CsParser">
|
||||
<timestamps>
|
||||
<styleCop>2014.04.01 10:18:24.000</styleCop>
|
||||
@@ -305,52 +302,6 @@
|
||||
</violation>
|
||||
</violations>
|
||||
</sourcecode>
|
||||
<sourcecode name="CharacterInfo.cs" parser="StyleCop.CSharp.CsParser">
|
||||
<timestamps>
|
||||
<styleCop>2014.04.01 10:18:24.000</styleCop>
|
||||
<settingsFile>2015.07.02 21:22:42.115</settingsFile>
|
||||
<sourceFile>2015.07.02 21:02:52.124</sourceFile>
|
||||
<parser>2014.04.01 10:18:24.000</parser>
|
||||
<StyleCop.CSharp.DocumentationRules>2014.04.01 10:18:24.000</StyleCop.CSharp.DocumentationRules>
|
||||
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-1945363787</StyleCop.CSharp.DocumentationRules.FilesHashCode>
|
||||
<StyleCop.CSharp.LayoutRules>2014.04.01 10:18:24.000</StyleCop.CSharp.LayoutRules>
|
||||
<StyleCop.CSharp.LayoutRules.FilesHashCode>0</StyleCop.CSharp.LayoutRules.FilesHashCode>
|
||||
<StyleCop.CSharp.MaintainabilityRules>2014.04.01 10:18:24.000</StyleCop.CSharp.MaintainabilityRules>
|
||||
<StyleCop.CSharp.MaintainabilityRules.FilesHashCode>0</StyleCop.CSharp.MaintainabilityRules.FilesHashCode>
|
||||
<StyleCop.CSharp.NamingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.NamingRules>
|
||||
<StyleCop.CSharp.NamingRules.FilesHashCode>0</StyleCop.CSharp.NamingRules.FilesHashCode>
|
||||
<StyleCop.CSharp.OrderingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.OrderingRules>
|
||||
<StyleCop.CSharp.OrderingRules.FilesHashCode>0</StyleCop.CSharp.OrderingRules.FilesHashCode>
|
||||
<StyleCop.CSharp.ReadabilityRules>2014.04.01 10:18:24.000</StyleCop.CSharp.ReadabilityRules>
|
||||
<StyleCop.CSharp.ReadabilityRules.FilesHashCode>0</StyleCop.CSharp.ReadabilityRules.FilesHashCode>
|
||||
<StyleCop.CSharp.SpacingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.SpacingRules>
|
||||
<StyleCop.CSharp.SpacingRules.FilesHashCode>0</StyleCop.CSharp.SpacingRules.FilesHashCode>
|
||||
</timestamps>
|
||||
<violations>
|
||||
<violation namespace="StyleCop.CSharp.MaintainabilityRules" rule="StatementMustNotUseUnnecessaryParenthesis" ruleCheckId="SA1119">
|
||||
<context>The line contains unnecessary parenthesis.</context>
|
||||
<line>73</line>
|
||||
<index>2090</index>
|
||||
<endIndex>2160</endIndex>
|
||||
<startLine>73</startLine>
|
||||
<startColumn>40</startColumn>
|
||||
<endLine>73</endLine>
|
||||
<endColumn>110</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.MaintainabilityRules" rule="StatementMustNotUseUnnecessaryParenthesis" ruleCheckId="SA1119">
|
||||
<context>The line contains unnecessary parenthesis.</context>
|
||||
<line>80</line>
|
||||
<index>2470</index>
|
||||
<endIndex>2539</endIndex>
|
||||
<startLine>80</startLine>
|
||||
<startColumn>39</startColumn>
|
||||
<endLine>80</endLine>
|
||||
<endColumn>108</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
</violations>
|
||||
</sourcecode>
|
||||
<sourcecode name="DelayedEffect.cs" parser="StyleCop.CSharp.CsParser">
|
||||
<timestamps>
|
||||
<styleCop>2014.04.01 10:18:24.000</styleCop>
|
||||
@@ -3993,35 +3944,6 @@
|
||||
</timestamps>
|
||||
<violations />
|
||||
</sourcecode>
|
||||
<sourcecode name="Level.cs" parser="StyleCop.CSharp.CsParser">
|
||||
<timestamps>
|
||||
<styleCop>2014.04.01 10:18:24.000</styleCop>
|
||||
<settingsFile>2015.07.02 21:22:42.115</settingsFile>
|
||||
<sourceFile>2015.07.02 21:17:30.557</sourceFile>
|
||||
<parser>2014.04.01 10:18:24.000</parser>
|
||||
<StyleCop.CSharp.DocumentationRules>2014.04.01 10:18:24.000</StyleCop.CSharp.DocumentationRules>
|
||||
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-1945363787</StyleCop.CSharp.DocumentationRules.FilesHashCode>
|
||||
<StyleCop.CSharp.LayoutRules>2014.04.01 10:18:24.000</StyleCop.CSharp.LayoutRules>
|
||||
<StyleCop.CSharp.LayoutRules.FilesHashCode>0</StyleCop.CSharp.LayoutRules.FilesHashCode>
|
||||
<StyleCop.CSharp.MaintainabilityRules>2014.04.01 10:18:24.000</StyleCop.CSharp.MaintainabilityRules>
|
||||
<StyleCop.CSharp.MaintainabilityRules.FilesHashCode>0</StyleCop.CSharp.MaintainabilityRules.FilesHashCode>
|
||||
<StyleCop.CSharp.NamingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.NamingRules>
|
||||
<StyleCop.CSharp.NamingRules.FilesHashCode>0</StyleCop.CSharp.NamingRules.FilesHashCode>
|
||||
<StyleCop.CSharp.OrderingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.OrderingRules>
|
||||
<StyleCop.CSharp.OrderingRules.FilesHashCode>0</StyleCop.CSharp.OrderingRules.FilesHashCode>
|
||||
<StyleCop.CSharp.ReadabilityRules>2014.04.01 10:18:24.000</StyleCop.CSharp.ReadabilityRules>
|
||||
<StyleCop.CSharp.ReadabilityRules.FilesHashCode>0</StyleCop.CSharp.ReadabilityRules.FilesHashCode>
|
||||
<StyleCop.CSharp.SpacingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.SpacingRules>
|
||||
<StyleCop.CSharp.SpacingRules.FilesHashCode>0</StyleCop.CSharp.SpacingRules.FilesHashCode>
|
||||
</timestamps>
|
||||
<violations>
|
||||
<violation namespace="StyleCop.CSharp.NamingRules" rule="ConstFieldNamesMustBeginWithUpperCaseLetter" ruleCheckId="SA1303">
|
||||
<context>Constants must start with an upper-case letter: gridCellWidth.</context>
|
||||
<line>27</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
</violations>
|
||||
</sourcecode>
|
||||
<sourcecode name="ConvexHull.cs" parser="StyleCop.CSharp.CsParser">
|
||||
<timestamps>
|
||||
<styleCop>2014.04.01 10:18:24.000</styleCop>
|
||||
@@ -6489,4 +6411,76 @@
|
||||
</timestamps>
|
||||
<violations />
|
||||
</sourcecode>
|
||||
<sourcecode name="CharacterInfo.cs" parser="StyleCop.CSharp.CsParser">
|
||||
<timestamps>
|
||||
<styleCop>2014.04.01 10:18:24.000</styleCop>
|
||||
<settingsFile>2015.07.02 21:22:42.115</settingsFile>
|
||||
<sourceFile>2015.07.06 23:42:06.929</sourceFile>
|
||||
<parser>2014.04.01 10:18:24.000</parser>
|
||||
<StyleCop.CSharp.DocumentationRules>2014.04.01 10:18:24.000</StyleCop.CSharp.DocumentationRules>
|
||||
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-1945363787</StyleCop.CSharp.DocumentationRules.FilesHashCode>
|
||||
<StyleCop.CSharp.LayoutRules>2014.04.01 10:18:24.000</StyleCop.CSharp.LayoutRules>
|
||||
<StyleCop.CSharp.LayoutRules.FilesHashCode>0</StyleCop.CSharp.LayoutRules.FilesHashCode>
|
||||
<StyleCop.CSharp.MaintainabilityRules>2014.04.01 10:18:24.000</StyleCop.CSharp.MaintainabilityRules>
|
||||
<StyleCop.CSharp.MaintainabilityRules.FilesHashCode>0</StyleCop.CSharp.MaintainabilityRules.FilesHashCode>
|
||||
<StyleCop.CSharp.NamingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.NamingRules>
|
||||
<StyleCop.CSharp.NamingRules.FilesHashCode>0</StyleCop.CSharp.NamingRules.FilesHashCode>
|
||||
<StyleCop.CSharp.OrderingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.OrderingRules>
|
||||
<StyleCop.CSharp.OrderingRules.FilesHashCode>0</StyleCop.CSharp.OrderingRules.FilesHashCode>
|
||||
<StyleCop.CSharp.ReadabilityRules>2014.04.01 10:18:24.000</StyleCop.CSharp.ReadabilityRules>
|
||||
<StyleCop.CSharp.ReadabilityRules.FilesHashCode>0</StyleCop.CSharp.ReadabilityRules.FilesHashCode>
|
||||
<StyleCop.CSharp.SpacingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.SpacingRules>
|
||||
<StyleCop.CSharp.SpacingRules.FilesHashCode>0</StyleCop.CSharp.SpacingRules.FilesHashCode>
|
||||
</timestamps>
|
||||
<violations>
|
||||
<violation namespace="StyleCop.CSharp.MaintainabilityRules" rule="StatementMustNotUseUnnecessaryParenthesis" ruleCheckId="SA1119">
|
||||
<context>The line contains unnecessary parenthesis.</context>
|
||||
<line>75</line>
|
||||
<index>2171</index>
|
||||
<endIndex>2241</endIndex>
|
||||
<startLine>75</startLine>
|
||||
<startColumn>40</startColumn>
|
||||
<endLine>75</endLine>
|
||||
<endColumn>110</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.MaintainabilityRules" rule="StatementMustNotUseUnnecessaryParenthesis" ruleCheckId="SA1119">
|
||||
<context>The line contains unnecessary parenthesis.</context>
|
||||
<line>82</line>
|
||||
<index>2551</index>
|
||||
<endIndex>2620</endIndex>
|
||||
<startLine>82</startLine>
|
||||
<startColumn>39</startColumn>
|
||||
<endLine>82</endLine>
|
||||
<endColumn>108</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
</violations>
|
||||
</sourcecode>
|
||||
<project key="2115933639">
|
||||
<configuration>DEBUG;TRACE;WINDOWS</configuration>
|
||||
</project>
|
||||
<sourcecode name="Level.cs" parser="StyleCop.CSharp.CsParser">
|
||||
<timestamps>
|
||||
<styleCop>2014.04.01 10:18:24.000</styleCop>
|
||||
<settingsFile>2015.07.02 21:22:42.115</settingsFile>
|
||||
<sourceFile>2015.07.07 16:37:45.662</sourceFile>
|
||||
<parser>2014.04.01 10:18:24.000</parser>
|
||||
<StyleCop.CSharp.DocumentationRules>2014.04.01 10:18:24.000</StyleCop.CSharp.DocumentationRules>
|
||||
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-1945363787</StyleCop.CSharp.DocumentationRules.FilesHashCode>
|
||||
<StyleCop.CSharp.LayoutRules>2014.04.01 10:18:24.000</StyleCop.CSharp.LayoutRules>
|
||||
<StyleCop.CSharp.LayoutRules.FilesHashCode>0</StyleCop.CSharp.LayoutRules.FilesHashCode>
|
||||
<StyleCop.CSharp.MaintainabilityRules>2014.04.01 10:18:24.000</StyleCop.CSharp.MaintainabilityRules>
|
||||
<StyleCop.CSharp.MaintainabilityRules.FilesHashCode>0</StyleCop.CSharp.MaintainabilityRules.FilesHashCode>
|
||||
<StyleCop.CSharp.NamingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.NamingRules>
|
||||
<StyleCop.CSharp.NamingRules.FilesHashCode>0</StyleCop.CSharp.NamingRules.FilesHashCode>
|
||||
<StyleCop.CSharp.OrderingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.OrderingRules>
|
||||
<StyleCop.CSharp.OrderingRules.FilesHashCode>0</StyleCop.CSharp.OrderingRules.FilesHashCode>
|
||||
<StyleCop.CSharp.ReadabilityRules>2014.04.01 10:18:24.000</StyleCop.CSharp.ReadabilityRules>
|
||||
<StyleCop.CSharp.ReadabilityRules.FilesHashCode>0</StyleCop.CSharp.ReadabilityRules.FilesHashCode>
|
||||
<StyleCop.CSharp.SpacingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.SpacingRules>
|
||||
<StyleCop.CSharp.SpacingRules.FilesHashCode>0</StyleCop.CSharp.SpacingRules.FilesHashCode>
|
||||
</timestamps>
|
||||
<violations />
|
||||
</sourcecode>
|
||||
</stylecopresultscache>
|
||||
@@ -59,7 +59,6 @@
|
||||
<Compile Include="Characters\CharacterInfo.cs" />
|
||||
<Compile Include="Characters\AI\ISteerable.cs" />
|
||||
<Compile Include="Characters\DelayedEffect.cs" />
|
||||
<Compile Include="Characters\Job.cs" />
|
||||
<Compile Include="Characters\Jobs\Job.cs" />
|
||||
<Compile Include="Characters\Jobs\JobPrefab.cs" />
|
||||
<Compile Include="Characters\AI\SteeringManager.cs" />
|
||||
@@ -198,10 +197,6 @@
|
||||
<Compile Include="Map\Hull.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FarseerPhysics MonoGame, Version=3.5.0.30657, Culture=neutral, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>bin\Windows\Debug\FarseerPhysics MonoGame.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Lidgren.Network, Version=3.3.0.2069, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>.\Lidgren.Network.dll</HintPath>
|
||||
@@ -720,6 +715,10 @@
|
||||
<Folder Include="Data\Saves\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Farseer Physics Engine 3.5\Farseer Physics MonoGame.csproj">
|
||||
<Project>{0aad36e3-51a5-4a07-ab60-5c8a66bd38b7}</Project>
|
||||
<Name>Farseer Physics MonoGame</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Subsurface_content\Subsurface_content\Subsurface_content.csproj">
|
||||
<Project>{1e6bf44d-6e31-40cc-8321-3d5958c983e7}</Project>
|
||||
<Name>Subsurface_content</Name>
|
||||
|
||||
+1
-11
@@ -255,17 +255,7 @@ namespace Subsurface
|
||||
.Select(s => s[Rand.Int(s.Length)])
|
||||
.ToArray());
|
||||
}
|
||||
|
||||
public static int SeedToInt(string seed)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < seed.Length; i++)
|
||||
{
|
||||
sb.Append((int)seed[i]);
|
||||
}
|
||||
return int.Parse(sb.ToString()) % int.MaxValue;
|
||||
}
|
||||
|
||||
|
||||
public static string WrapText(string text, float lineWidth)
|
||||
{
|
||||
if (GUI.font.MeasureString(text).X < lineWidth) return text;
|
||||
|
||||
Reference in New Issue
Block a user