(d9829ac) v0.9.4.0

This commit is contained in:
Regalis
2019-10-24 18:05:42 +02:00
parent 9aa12bcac2
commit b39922a074
319 changed files with 12516 additions and 6815 deletions
@@ -50,38 +50,25 @@ namespace Barotrauma
public Job(XElement element)
{
string identifier = element.GetAttributeString("identifier", "").ToLowerInvariant();
prefab = JobPrefab.List.Find(jp => jp.Identifier.ToLowerInvariant() == identifier);
string name = "";
if (prefab == null)
if (!JobPrefab.List.TryGetValue(identifier, out JobPrefab p))
{
name = element.GetAttributeString("name", "").ToLowerInvariant();
prefab = JobPrefab.List.Find(jp => jp.Name.ToLowerInvariant() == name);
DebugConsole.ThrowError($"Could not find the job {identifier}. Giving the character a random job.");
p = JobPrefab.Random();
}
if (prefab == null)
{
DebugConsole.ThrowError("Could not find the job \"" + name + "\" (identifier " + identifier + "). Giving the character a random job.");
prefab = JobPrefab.List[Rand.Int(JobPrefab.List.Count)];
}
prefab = p;
skills = new Dictionary<string, Skill>();
foreach (XElement subElement in element.Elements())
{
if (subElement.Name.ToString().ToLowerInvariant() != "skill") continue;
if (subElement.Name.ToString().ToLowerInvariant() != "skill") { continue; }
string skillIdentifier = subElement.GetAttributeString("identifier", "");
if (string.IsNullOrEmpty(skillIdentifier)) continue;
if (string.IsNullOrEmpty(skillIdentifier)) { continue; }
skills.Add(
skillIdentifier,
new Skill(skillIdentifier, subElement.GetAttributeFloat("level", 0)));
}
}
public static Job Random(Rand.RandSync randSync)
{
JobPrefab prefab = JobPrefab.List[Rand.Int(JobPrefab.List.Count - 1, randSync)];
return new Job(prefab);
}
public static Job Random(Rand.RandSync randSync = Rand.RandSync.Unsynced) => new Job(JobPrefab.Random(randSync));
public float GetSkillLevel(string skillIdentifier)
{
@@ -186,7 +173,7 @@ namespace Barotrauma
wifiComponent.TeamID = character.TeamID;
}
if (parentItem != null) parentItem.Combine(item);
if (parentItem != null) parentItem.Combine(item, user: null);
foreach (XElement childItemElement in itemElement.Elements())
{