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

View File

@@ -454,7 +454,7 @@ namespace Barotrauma
{
AnimController = new HumanoidAnimController(this, doc.Root.Element("ragdoll"));
AnimController.TargetDir = Direction.Right;
inventory = new CharacterInventory(15, this);
inventory = new CharacterInventory(16, this);
}
else
{
@@ -594,39 +594,7 @@ namespace Barotrauma
{
if (info == null || info.Job == null) return;
for (int i = 0; i < info.Job.SpawnItemNames.Count; i++ )
{
string itemName = info.Job.SpawnItemNames[i];
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.");
continue;
}
Item item = new Item(itemPrefab, Position, null);
if (info.Job.EquipSpawnItem[i])
{
List<LimbSlot> allowedSlots = new List<LimbSlot>(item.AllowedSlots);
allowedSlots.Remove(LimbSlot.Any);
inventory.TryPutItem(item, allowedSlots, false);
}
else
{
inventory.TryPutItem(item, item.AllowedSlots, false);
}
if (item.Prefab.Name == "ID Card" && spawnPoint != null)
{
foreach (string s in spawnPoint.IdCardTags)
{
item.AddTag(s);
}
}
}
info.Job.GiveJobItems(this, spawnPoint);
}
public int GetSkillLevel(string skillName)
@@ -988,6 +956,16 @@ namespace Barotrauma
if (!Enabled) return;
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
if (inventory!=null)
{
foreach (Item item in inventory.Items)
{
if (item == null || item.body == null || item.body.Enabled) continue;
item.Submarine = Submarine;
item.SetTransform(SimPosition, 0.0f);
}
}
if (isDead) return;

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");

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())