Mid-round chat messages have a limited range, headset item which can be used to communicate with players further away, new inventory slot for items like masks and headsets

This commit is contained in:
Regalis
2016-04-20 17:19:38 +03:00
parent a45f58cd08
commit e33f30dad1
21 changed files with 597 additions and 177 deletions
+57 -6
View File
@@ -26,15 +26,15 @@ namespace Barotrauma
get { return prefab; }
}
public List<string> SpawnItemNames
public XElement SpawnItems
{
get { return prefab.ItemNames; }
get { return prefab.Items; }
}
public List<bool> EquipSpawnItem
{
get { return prefab.EquipItem; }
}
//public List<bool> EquipSpawnItem
//{
// get { return prefab.EquipItem; }
//}
public List<Skill> Skills
{
@@ -84,6 +84,57 @@ namespace Barotrauma
return (skill==null) ? 0 : skill.Level;
}
public void GiveJobItems(Character character, WayPoint spawnPoint)
{
foreach (XElement itemElement in SpawnItems.Elements())
{
InitializeJobItem(character, spawnPoint, itemElement);
}
}
private void InitializeJobItem(Character character, WayPoint spawnPoint, XElement itemElement, Item parentItem = null)
{
string itemName = ToolBox.GetAttributeString(itemElement, "name", "");
ItemPrefab itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab;
if (itemPrefab == null)
{
DebugConsole.ThrowError("Tried to spawn ''" + Name + "'' with the item ''" + itemName + "''. Matching item prefab not found.");
return;
}
Item item = new Item(itemPrefab, character.Position, null);
if (ToolBox.GetAttributeBool(itemElement, "equip", false))
{
List<LimbSlot> allowedSlots = new List<LimbSlot>(item.AllowedSlots);
allowedSlots.Remove(LimbSlot.Any);
character.Inventory.TryPutItem(item, allowedSlots, false);
}
else
{
character.Inventory.TryPutItem(item, item.AllowedSlots, false);
}
if (item.Prefab.Name == "ID Card" && spawnPoint != null)
{
foreach (string s in spawnPoint.IdCardTags)
{
item.AddTag(s);
}
}
if (parentItem != null) parentItem.Combine(item);
foreach (XElement childItemElement in itemElement.Elements())
{
InitializeJobItem(character, spawnPoint, childItemElement, item);
}
}
public virtual XElement Save(XElement parentElement)
{
XElement jobElement = new XElement("job");
+15 -9
View File
@@ -10,9 +10,9 @@ namespace Barotrauma
{
public static List<JobPrefab> List;
//names of the items the Character spawns with
public List<string> ItemNames;
public List<bool> EquipItem;
public readonly XElement Items;
public readonly List<string> ItemNames;
//public List<bool> EquipItem;
public List<SkillPrefab> Skills;
@@ -71,7 +71,7 @@ namespace Barotrauma
AllowAlways = ToolBox.GetAttributeBool(element, "allowalways", false);
ItemNames = new List<string>();
EquipItem = new List<bool>();
//EquipItem = new List<bool>();
Skills = new List<SkillPrefab>();
@@ -79,14 +79,20 @@ namespace Barotrauma
{
switch (subElement.Name.ToString().ToLower())
{
case "item":
string itemName = ToolBox.GetAttributeString(subElement, "name", "");
bool equipItem = ToolBox.GetAttributeBool(subElement, "equip", false);
if (!string.IsNullOrEmpty(itemName))
case "items":
Items = subElement;
foreach (XElement itemElement in subElement.Elements())
{
string itemName = ToolBox.GetAttributeString(subElement, "name", "");
ItemNames.Add(itemName);
EquipItem.Add(equipItem);
}
//string itemName = ToolBox.GetAttributeString(subElement, "name", "");
//bool equipItem = ToolBox.GetAttributeBool(subElement, "equip", false);
//if (!string.IsNullOrEmpty(itemName))
//{
// ItemNames.Add(itemName);
// EquipItem.Add(equipItem);
//}
break;
case "skills":
foreach (XElement skillElement in subElement.Elements())