Server job assigning logic, submarine movement syncing, submarine collision improvements, spawnpoints in levels
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user