38f1ddb...178a853: v0.8.9.1, removed content folder

This commit is contained in:
Joonas Rikkonen
2019-03-18 19:46:58 +02:00
parent 38f1ddb6fe
commit 6c0679c297
1054 changed files with 151673 additions and 144931 deletions
@@ -7,7 +7,6 @@ namespace Barotrauma
{
class Job
{
private readonly JobPrefab prefab;
private Dictionary<string, Skill> skills;
@@ -31,12 +30,7 @@ namespace Barotrauma
{
get { return prefab.Items; }
}
//public List<bool> EquipSpawnItem
//{
// get { return prefab.EquipItem; }
//}
public List<Skill> Skills
{
get { return skills.Values.ToList(); }
@@ -49,61 +43,94 @@ namespace Barotrauma
skills = new Dictionary<string, Skill>();
foreach (SkillPrefab skillPrefab in prefab.Skills)
{
skills.Add(skillPrefab.Name, new Skill(skillPrefab));
skills.Add(skillPrefab.Identifier, new Skill(skillPrefab));
}
}
public Job(XElement element)
{
string name = element.GetAttributeString("name", "").ToLowerInvariant();
prefab = JobPrefab.List.Find(jp => jp.Name.ToLowerInvariant() == name);
string identifier = element.GetAttributeString("identifier", "").ToLowerInvariant();
prefab = JobPrefab.List.Find(jp => jp.Identifier.ToLowerInvariant() == identifier);
string name = "";
if (prefab == null)
{
name = element.GetAttributeString("name", "").ToLowerInvariant();
prefab = JobPrefab.List.Find(jp => jp.Name.ToLowerInvariant() == name);
}
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)];
}
skills = new Dictionary<string, Skill>();
foreach (XElement subElement in element.Elements())
{
if (subElement.Name.ToString().ToLowerInvariant() != "skill") continue;
string skillName = subElement.GetAttributeString("name", "");
if (string.IsNullOrEmpty(name)) continue;
string skillIdentifier = subElement.GetAttributeString("identifier", "");
if (string.IsNullOrEmpty(skillIdentifier)) continue;
skills.Add(
skillName,
new Skill(skillName, subElement.GetAttributeInt("level", 0)));
skillIdentifier,
new Skill(skillIdentifier, subElement.GetAttributeFloat("level", 0)));
}
}
public static Job Random()
public static Job Random(Rand.RandSync randSync)
{
JobPrefab prefab = JobPrefab.List[Rand.Int(JobPrefab.List.Count - 1, Rand.RandSync.Server)];
JobPrefab prefab = JobPrefab.List[Rand.Int(JobPrefab.List.Count - 1, randSync)];
return new Job(prefab);
}
public int GetSkillLevel(string skillName)
public float GetSkillLevel(string skillIdentifier)
{
Skill skill = null;
skills.TryGetValue(skillName, out skill);
skills.TryGetValue(skillIdentifier, out Skill skill);
return (skill==null) ? 0 : skill.Level;
return (skill == null) ? 0.0f : skill.Level;
}
public void GiveJobItems(Character character, WayPoint spawnPoint)
public void IncreaseSkillLevel(string skillIdentifier, float increase)
{
if (skills.TryGetValue(skillIdentifier, out Skill skill))
{
skill.Level += increase;
}
}
public void GiveJobItems(Character character, WayPoint spawnPoint = null)
{
if (SpawnItems == null) return;
foreach (XElement itemElement in SpawnItems.Elements())
{
InitializeJobItem(character, spawnPoint, itemElement);
InitializeJobItem(character, itemElement, spawnPoint);
}
}
private void InitializeJobItem(Character character, WayPoint spawnPoint, XElement itemElement, Item parentItem = null)
private void InitializeJobItem(Character character, XElement itemElement, WayPoint spawnPoint = null, Item parentItem = null)
{
string itemName = itemElement.GetAttributeString("name", "");
ItemPrefab itemPrefab = MapEntityPrefab.Find(itemName) as ItemPrefab;
if (itemPrefab == null)
ItemPrefab itemPrefab;
if (itemElement.Attribute("name") != null)
{
DebugConsole.ThrowError("Tried to spawn \"" + Name + "\" with the item \"" + itemName + "\". Matching item prefab not found.");
return;
string itemName = itemElement.Attribute("name").Value;
DebugConsole.ThrowError("Error in Job config (" + Name + ") - use item identifiers instead of names to configure the items.");
itemPrefab = MapEntityPrefab.Find(itemName) as ItemPrefab;
if (itemPrefab == null)
{
DebugConsole.ThrowError("Tried to spawn \"" + Name + "\" with the item \"" + itemName + "\". Matching item prefab not found.");
return;
}
}
else
{
string itemIdentifier = itemElement.GetAttributeString("identifier", "");
itemPrefab = MapEntityPrefab.Find(null, itemIdentifier) as ItemPrefab;
if (itemPrefab == null)
{
DebugConsole.ThrowError("Tried to spawn \"" + Name + "\" with the item \"" + itemIdentifier + "\". Matching item prefab not found.");
return;
}
}
Item item = new Item(itemPrefab, character.Position, null);
@@ -125,7 +152,7 @@ namespace Barotrauma
character.Inventory.TryPutItem(item, null, item.AllowedSlots);
}
if (item.Prefab.NameMatches("ID Card") && spawnPoint != null)
if (item.Prefab.Identifier == "idcard" && spawnPoint != null)
{
foreach (string s in spawnPoint.IdCardTags)
{
@@ -146,7 +173,7 @@ namespace Barotrauma
foreach (XElement childItemElement in itemElement.Elements())
{
InitializeJobItem(character, spawnPoint, childItemElement, item);
InitializeJobItem(character, childItemElement, spawnPoint, item);
}
}
@@ -158,7 +185,7 @@ namespace Barotrauma
foreach (KeyValuePair<string, Skill> skill in skills)
{
jobElement.Add(new XElement("skill", new XAttribute("name", skill.Value.Name), new XAttribute("level", skill.Value.Level)));
jobElement.Add(new XElement("skill", new XAttribute("identifier", skill.Value.Identifier), new XAttribute("level", skill.Value.Level)));
}
parentElement.Add(jobElement);
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Xml.Linq;
namespace Barotrauma
@@ -11,31 +12,53 @@ namespace Barotrauma
public readonly List<string> ItemNames;
public List<SkillPrefab> Skills;
[Serialize("1,1,1,1", false)]
public Color UIColor
{
get;
private set;
}
//the number of these characters in the crew the player starts with
public readonly int InitialCount;
[Serialize("notfound", false)]
public string Identifier
{
get;
private set;
}
[Serialize("notfound", false)]
public string Name
{
get;
private set;
}
[Serialize("", false)]
public string Description
{
get;
private set;
}
//the number of these characters in the crew the player starts with in the single player campaign
[Serialize(0, false)]
public int InitialCount
{
get;
private set;
}
//if set to true, a client that has chosen this as their preferred job will get it no matter what
[Serialize(false, false)]
public bool AllowAlways
{
get;
private set;
}
//how many crew members can have the job (only one captain etc)
//how many crew members can have the job (only one captain etc)
[Serialize(100, false)]
public int MaxNumber
{
get;
@@ -44,39 +67,46 @@ namespace Barotrauma
//how many crew members are REQUIRED to have the job
//(i.e. if one captain is required, one captain is chosen even if all the players have set captain to lowest preference)
[Serialize(0, false)]
public int MinNumber
{
get;
private set;
}
[Serialize(0.0f, false)]
public float MinKarma
{
get;
private set;
}
[Serialize(10.0f, false)]
public float Commonness
{
get;
private set;
}
//how much the vitality of the character is increased/reduced from the default value
[Serialize(0.0f, false)]
public float VitalityModifier
{
get;
private set;
}
public XElement ClothingElement { get; private set; }
public JobPrefab(XElement element)
{
Name = element.GetAttributeString("name", "name not found");
SerializableProperty.DeserializeProperties(this, element);
Description = element.GetAttributeString("description", "");
string translatedName = TextManager.Get("JobName." + Identifier, true);
if (!string.IsNullOrEmpty(translatedName)) Name = translatedName;
MinNumber = element.GetAttributeInt("minnumber", 0);
MaxNumber = element.GetAttributeInt("maxnumber", 10);
MinKarma = element.GetAttributeFloat("minkarma", 0.0f);
InitialCount = element.GetAttributeInt("initialcount", 0);
Commonness = element.GetAttributeInt("commonness", 10);
AllowAlways = element.GetAttributeBool("allowalways", false);
string translatedDescription = TextManager.Get("JobDescription." + Identifier, true);
if (!string.IsNullOrEmpty(translatedDescription)) Description = translatedDescription;
ItemNames = new List<string>();
@@ -90,8 +120,32 @@ namespace Barotrauma
Items = subElement;
foreach (XElement itemElement in subElement.Elements())
{
string itemName = itemElement.GetAttributeString("name", "");
if (!string.IsNullOrWhiteSpace(itemName)) ItemNames.Add(itemName);
if (itemElement.Element("name") != null)
{
DebugConsole.ThrowError("Error in job config \"" + Name + "\" - use identifiers instead of names to configure the items.");
ItemNames.Add(itemElement.GetAttributeString("name", ""));
continue;
}
string itemIdentifier = itemElement.GetAttributeString("identifier", "");
if (string.IsNullOrWhiteSpace(itemIdentifier))
{
DebugConsole.ThrowError("Error in job config \"" + Name + "\" - item with no identifier.");
ItemNames.Add("");
}
else
{
var prefab = MapEntityPrefab.Find(null, itemIdentifier) as ItemPrefab;
if (prefab == null)
{
DebugConsole.ThrowError("Error in job config \"" + Name + "\" - item prefab \""+itemIdentifier+"\" not found.");
ItemNames.Add("");
}
else
{
ItemNames.Add(prefab.Name);
}
}
}
break;
case "skills":
@@ -104,6 +158,12 @@ namespace Barotrauma
}
Skills.Sort((x,y) => y.LevelRange.X.CompareTo(x.LevelRange.X));
ClothingElement = element.Element("PortraitClothing");
if (ClothingElement == null)
{
ClothingElement = element.Element("portraitclothing");
}
}
public static JobPrefab Random()
@@ -111,7 +171,7 @@ namespace Barotrauma
return List[Rand.Int(List.Count)];
}
public static void LoadAll(List<string> filePaths)
public static void LoadAll(IEnumerable<string> filePaths)
{
List = new List<JobPrefab>();
@@ -5,48 +5,47 @@ namespace Barotrauma
{
class Skill
{
SkillPrefab prefab;
string name;
int level;
private SkillPrefab prefab;
private float level;
static string[] levelNames = new string[] {
"Untrained", "Incompetent", "Novice",
"Adequate", "Competent", "Proficient",
"Professional", "Master", "Legendary" };
public string Name
string identifier;
public string Identifier
{
get { return name; }
get { return identifier; }
}
public int Level
public float Level
{
get { return level; }
set { level = MathHelper.Clamp(value, 0, 100); }
set { level = MathHelper.Clamp(value, 0.0f, 100.0f); }
}
public Skill(SkillPrefab prefab)
{
this.prefab = prefab;
this.name = prefab.Name;
this.identifier = prefab.Identifier;
this.level = (int)Rand.Range(prefab.LevelRange.X, prefab.LevelRange.Y);
this.level = Rand.Range(prefab.LevelRange.X, prefab.LevelRange.Y, Rand.RandSync.Server);
}
public Skill(string name, int level)
public Skill(string identifier, float level)
{
this.name = name;
this.identifier = identifier;
this.level = level;
}
/// <summary>
/// returns the "name" of some skill level (0-10 -> untrained, etc)
/// </summary>
public static string GetLevelName(int level)
public static string GetLevelName(float level)
{
level = MathHelper.Clamp(level, 0, 100);
level = MathHelper.Clamp(level, 0.0f, 100.0f);
int scaledLevel = (int)Math.Floor((level / 100.0f) * levelNames.Length);
return levelNames[Math.Min(scaledLevel, levelNames.Length - 1)];
@@ -5,17 +5,12 @@ namespace Barotrauma
{
class SkillPrefab
{
private string name;
private string description;
private Vector2 levelRange;
public string Name
{
get { return name; }
}
public readonly string Identifier;
public string Description
{
get { return description; }
@@ -28,7 +23,7 @@ namespace Barotrauma
public SkillPrefab(XElement element)
{
name = element.GetAttributeString("name", "");
Identifier = element.GetAttributeString("identifier", "");
var levelString = element.GetAttributeString("level", "");
if (levelString.Contains(","))
@@ -41,7 +36,5 @@ namespace Barotrauma
levelRange = new Vector2(skillLevel, skillLevel);
}
}
}
}