Displaying the condition of contained items in the inventory slot of the parent item (i.e. the amount of oxygen left in a diving suit is visible without highlighting the suit), some debug logging, colored speech bubbles
This commit is contained in:
@@ -65,9 +65,9 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
var pickable = targetItem.GetComponent<Pickable>();
|
var pickable = targetItem.GetComponent<Pickable>();
|
||||||
//check if all the slots required by the item are free
|
//check if all the slots required by the item are free
|
||||||
foreach (LimbSlot slots in pickable.AllowedSlots)
|
foreach (InvSlotType slots in pickable.AllowedSlots)
|
||||||
{
|
{
|
||||||
if (slots.HasFlag(LimbSlot.Any)) continue;
|
if (slots.HasFlag(InvSlotType.Any)) continue;
|
||||||
|
|
||||||
for (int i = 0; i<character.Inventory.Items.Length; i++)
|
for (int i = 0; i<character.Inventory.Items.Length; i++)
|
||||||
{
|
{
|
||||||
@@ -80,7 +80,7 @@ namespace Barotrauma
|
|||||||
if (character.Inventory.Items[i] == null) continue;
|
if (character.Inventory.Items[i] == null) continue;
|
||||||
|
|
||||||
//try to move the existing item to LimbSlot.Any and continue if successful
|
//try to move the existing item to LimbSlot.Any and continue if successful
|
||||||
if (character.Inventory.TryPutItem(character.Inventory.Items[i], new List<LimbSlot>() { LimbSlot.Any }, false)) continue;
|
if (character.Inventory.TryPutItem(character.Inventory.Items[i], new List<InvSlotType>() { InvSlotType.Any }, false)) continue;
|
||||||
|
|
||||||
//if everything else fails, simply drop the existing item
|
//if everything else fails, simply drop the existing item
|
||||||
character.Inventory.Items[i].Drop();
|
character.Inventory.Items[i].Drop();
|
||||||
@@ -90,7 +90,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
targetItem.Pick(character, false, true);
|
targetItem.Pick(character, false, true);
|
||||||
|
|
||||||
if (targetSlot > -1 && character.Inventory.IsInLimbSlot(targetItem, LimbSlot.Any))
|
if (targetSlot > -1 && character.Inventory.IsInLimbSlot(targetItem, InvSlotType.Any))
|
||||||
{
|
{
|
||||||
character.Inventory.TryPutItem(targetItem, targetSlot, true, false);
|
character.Inventory.TryPutItem(targetItem, targetSlot, true, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,8 @@ namespace Barotrauma
|
|||||||
get { return inventory; }
|
get { return inventory; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public float SpeechBubbleTimer;
|
private Color speechBubbleColor;
|
||||||
|
private float speechBubbleTimer;
|
||||||
|
|
||||||
private float lockHandsTimer;
|
private float lockHandsTimer;
|
||||||
public bool LockHands
|
public bool LockHands
|
||||||
@@ -694,6 +695,11 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasEquippedItem(Item item)
|
||||||
|
{
|
||||||
|
return !inventory.IsInLimbSlot(item, InvSlotType.Any);
|
||||||
|
}
|
||||||
|
|
||||||
public bool HasSelectedItem(Item item)
|
public bool HasSelectedItem(Item item)
|
||||||
{
|
{
|
||||||
return selectedItems.Contains(item);
|
return selectedItems.Contains(item);
|
||||||
@@ -701,8 +707,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public bool TrySelectItem(Item item)
|
public bool TrySelectItem(Item item)
|
||||||
{
|
{
|
||||||
bool rightHand = ((CharacterInventory)inventory).IsInLimbSlot(item, LimbSlot.RightHand);
|
bool rightHand = inventory.IsInLimbSlot(item, InvSlotType.RightHand);
|
||||||
bool leftHand = ((CharacterInventory)inventory).IsInLimbSlot(item, LimbSlot.LeftHand);
|
bool leftHand = inventory.IsInLimbSlot(item, InvSlotType.LeftHand);
|
||||||
|
|
||||||
bool selected = false;
|
bool selected = false;
|
||||||
if (rightHand && SelectedItems[0] == null)
|
if (rightHand && SelectedItems[0] == null)
|
||||||
@@ -956,7 +962,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (!Enabled) return;
|
if (!Enabled) return;
|
||||||
|
|
||||||
SpeechBubbleTimer = Math.Max(0.0f, SpeechBubbleTimer - deltaTime);
|
speechBubbleTimer = Math.Max(0.0f, speechBubbleTimer - deltaTime);
|
||||||
|
|
||||||
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
|
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
|
||||||
|
|
||||||
@@ -1086,6 +1092,12 @@ namespace Barotrauma
|
|||||||
aiTarget.SightRange = Mass*10.0f + AnimController.RefLimb.LinearVelocity.Length()*500.0f;
|
aiTarget.SightRange = Mass*10.0f + AnimController.RefLimb.LinearVelocity.Length()*500.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ShowSpeechBubble(float duration, Color color)
|
||||||
|
{
|
||||||
|
speechBubbleTimer = Math.Max(speechBubbleTimer, duration);
|
||||||
|
speechBubbleColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch spriteBatch)
|
public void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
if (!Enabled) return;
|
if (!Enabled) return;
|
||||||
@@ -1136,9 +1148,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
GUI.DrawProgressBar(spriteBatch, healthBarPos, new Vector2(100.0f, 15.0f), health / maxHealth, Color.Lerp(Color.Red, Color.Green, health / maxHealth) * 0.8f);
|
GUI.DrawProgressBar(spriteBatch, healthBarPos, new Vector2(100.0f, 15.0f), health / maxHealth, Color.Lerp(Color.Red, Color.Green, health / maxHealth) * 0.8f);
|
||||||
|
|
||||||
if (SpeechBubbleTimer > 0.0f)
|
if (speechBubbleTimer > 0.0f)
|
||||||
{
|
{
|
||||||
GUI.SpeechBubbleIcon.Draw(spriteBatch, pos - Vector2.UnitY * 100.0f, Color.White * Math.Min(SpeechBubbleTimer, 1.0f));
|
GUI.SpeechBubbleIcon.Draw(spriteBatch, pos - Vector2.UnitY * 100.0f,
|
||||||
|
speechBubbleColor * Math.Min(speechBubbleTimer, 1.0f), 0.0f,
|
||||||
|
Math.Min((float)speechBubbleTimer, 1.0f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace Barotrauma
|
|||||||
for (int i = 0; i< character.Inventory.Items.Length-1; i++)
|
for (int i = 0; i< character.Inventory.Items.Length-1; i++)
|
||||||
{
|
{
|
||||||
var item = character.Inventory.Items[i];
|
var item = character.Inventory.Items[i];
|
||||||
if (item == null || CharacterInventory.limbSlots[i]==LimbSlot.Any) continue;
|
if (item == null || CharacterInventory.limbSlots[i]==InvSlotType.Any) continue;
|
||||||
//var statusHUD = item.GetComponent<StatusHUD>();
|
//var statusHUD = item.GetComponent<StatusHUD>();
|
||||||
//if (statusHUD == null) continue;
|
//if (statusHUD == null) continue;
|
||||||
foreach (ItemComponent ic in item.components)
|
foreach (ItemComponent ic in item.components)
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ namespace Barotrauma
|
|||||||
foreach (XElement itemElement in SpawnItems.Elements())
|
foreach (XElement itemElement in SpawnItems.Elements())
|
||||||
{
|
{
|
||||||
InitializeJobItem(character, spawnPoint, itemElement);
|
InitializeJobItem(character, spawnPoint, itemElement);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,8 +107,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (ToolBox.GetAttributeBool(itemElement, "equip", false))
|
if (ToolBox.GetAttributeBool(itemElement, "equip", false))
|
||||||
{
|
{
|
||||||
List<LimbSlot> allowedSlots = new List<LimbSlot>(item.AllowedSlots);
|
List<InvSlotType> allowedSlots = new List<InvSlotType>(item.AllowedSlots);
|
||||||
allowedSlots.Remove(LimbSlot.Any);
|
allowedSlots.Remove(InvSlotType.Any);
|
||||||
|
|
||||||
character.Inventory.TryPutItem(item, allowedSlots, false);
|
character.Inventory.TryPutItem(item, allowedSlots, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
static class DebugConsole
|
static class DebugConsole
|
||||||
{
|
{
|
||||||
|
const int MaxMessages = 100;
|
||||||
|
|
||||||
public static List<ColoredText> Messages = new List<ColoredText>();
|
public static List<ColoredText> Messages = new List<ColoredText>();
|
||||||
|
|
||||||
static bool isOpen;
|
static bool isOpen;
|
||||||
@@ -600,11 +602,21 @@ namespace Barotrauma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Messages.Count > MaxMessages)
|
||||||
|
{
|
||||||
|
Messages.RemoveRange(0, Messages.Count - MaxMessages);
|
||||||
|
}
|
||||||
|
|
||||||
//messages.Add(new ColoredText(msg, color));
|
//messages.Add(new ColoredText(msg, color));
|
||||||
|
|
||||||
selectedIndex = listBox.children.Count;
|
selectedIndex = listBox.children.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Log(string message)
|
||||||
|
{
|
||||||
|
if (GameSettings.VerboseLogging) NewMessage(message, Color.Gray);
|
||||||
|
}
|
||||||
|
|
||||||
public static void ThrowError(string error, Exception e = null)
|
public static void ThrowError(string error, Exception e = null)
|
||||||
{
|
{
|
||||||
if (e != null) error += " {" + e.Message + "}";
|
if (e != null) error += " {" + e.Message + "}";
|
||||||
|
|||||||
@@ -189,12 +189,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
GUIComponent.Init(Window);
|
GUIComponent.Init(Window);
|
||||||
DebugConsole.Init(Window);
|
DebugConsole.Init(Window);
|
||||||
yield return CoroutineStatus.Running;
|
DebugConsole.Log(SelectedPackage == null ? "No content package selected" : "Content package ''" + SelectedPackage.Name + "'' selected");
|
||||||
|
yield return CoroutineStatus.Running;
|
||||||
|
|
||||||
LightManager = new Lights.LightManager(GraphicsDevice);
|
LightManager = new Lights.LightManager(GraphicsDevice);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Hull.renderer = new WaterRenderer(GraphicsDevice, Content);
|
Hull.renderer = new WaterRenderer(GraphicsDevice, Content);
|
||||||
TitleScreen.LoadState = 1.0f;
|
TitleScreen.LoadState = 1.0f;
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
@@ -223,7 +222,7 @@ namespace Barotrauma
|
|||||||
while (!SoundPlayer.Initialized)
|
while (!SoundPlayer.Initialized)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
TitleScreen.LoadState = Math.Min((float)TitleScreen.LoadState + 40.0f/41, 70.0f);
|
TitleScreen.LoadState = Math.Min((float)TitleScreen.LoadState + 40.0f / 41, 70.0f);
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ namespace Barotrauma.Tutorials
|
|||||||
character.GiveJobItems(null);
|
character.GiveJobItems(null);
|
||||||
|
|
||||||
var idCard = character.Inventory.FindItem("ID Card");
|
var idCard = character.Inventory.FindItem("ID Card");
|
||||||
|
if (idCard == null)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Item prefab ''ID Card'' not found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
idCard.AddTag("com");
|
idCard.AddTag("com");
|
||||||
idCard.AddTag("eng");
|
idCard.AddTag("eng");
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ namespace Barotrauma
|
|||||||
public bool AutoCheckUpdates { get; set; }
|
public bool AutoCheckUpdates { get; set; }
|
||||||
public bool WasGameUpdated { get; set; }
|
public bool WasGameUpdated { get; set; }
|
||||||
|
|
||||||
|
public static bool VerboseLogging { get; set; }
|
||||||
|
|
||||||
public bool UnsavedSettings
|
public bool UnsavedSettings
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -130,6 +132,8 @@ namespace Barotrauma
|
|||||||
SoundVolume = ToolBox.GetAttributeFloat(doc.Root, "soundvolume", 1.0f);
|
SoundVolume = ToolBox.GetAttributeFloat(doc.Root, "soundvolume", 1.0f);
|
||||||
MusicVolume = ToolBox.GetAttributeFloat(doc.Root, "musicvolume", 0.3f);
|
MusicVolume = ToolBox.GetAttributeFloat(doc.Root, "musicvolume", 0.3f);
|
||||||
|
|
||||||
|
VerboseLogging = ToolBox.GetAttributeBool(doc.Root, "verboselogging", false);
|
||||||
|
|
||||||
keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length];
|
keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length];
|
||||||
keyMapping[(int)InputType.Up] = new KeyOrMouse(Keys.W);
|
keyMapping[(int)InputType.Up] = new KeyOrMouse(Keys.W);
|
||||||
keyMapping[(int)InputType.Down] = new KeyOrMouse(Keys.S);
|
keyMapping[(int)InputType.Down] = new KeyOrMouse(Keys.S);
|
||||||
@@ -152,6 +156,8 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
case "contentpackage":
|
case "contentpackage":
|
||||||
string path = ToolBox.GetAttributeString(subElement, "path", "");
|
string path = ToolBox.GetAttributeString(subElement, "path", "");
|
||||||
|
|
||||||
|
|
||||||
SelectedContentPackage = ContentPackage.list.Find(cp => cp.Path == path);
|
SelectedContentPackage = ContentPackage.list.Find(cp => cp.Path == path);
|
||||||
|
|
||||||
if (SelectedContentPackage == null) SelectedContentPackage = new ContentPackage(path);
|
if (SelectedContentPackage == null) SelectedContentPackage = new ContentPackage(path);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using System.Collections.Generic;
|
|||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum LimbSlot
|
public enum InvSlotType
|
||||||
{
|
{
|
||||||
None = 0, Any = 1, RightHand = 2, LeftHand = 4, Head = 8, Torso = 16, Legs = 32, Face=64
|
None = 0, Any = 1, RightHand = 2, LeftHand = 4, Head = 8, Torso = 16, Legs = 32, Face=64
|
||||||
};
|
};
|
||||||
@@ -20,10 +20,10 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private Character character;
|
private Character character;
|
||||||
|
|
||||||
public static LimbSlot[] limbSlots = new LimbSlot[] {
|
public static InvSlotType[] limbSlots = new InvSlotType[] {
|
||||||
LimbSlot.Head, LimbSlot.Torso, LimbSlot.Legs, LimbSlot.LeftHand, LimbSlot.RightHand, LimbSlot.Face,
|
InvSlotType.Head, InvSlotType.Torso, InvSlotType.Legs, InvSlotType.LeftHand, InvSlotType.RightHand, InvSlotType.Face,
|
||||||
LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any,
|
InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any,
|
||||||
LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any};
|
InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any};
|
||||||
|
|
||||||
public Vector2[] SlotPositions;
|
public Vector2[] SlotPositions;
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int FindLimbSlot(LimbSlot limbSlot)
|
public int FindLimbSlot(InvSlotType limbSlot)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Items.Length; i++)
|
for (int i = 0; i < Items.Length; i++)
|
||||||
{
|
{
|
||||||
@@ -120,7 +120,7 @@ namespace Barotrauma
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInLimbSlot(Item item, LimbSlot limbSlot)
|
public bool IsInLimbSlot(Item item, InvSlotType limbSlot)
|
||||||
{
|
{
|
||||||
for (int i = 0; i<Items.Length; i++)
|
for (int i = 0; i<Items.Length; i++)
|
||||||
{
|
{
|
||||||
@@ -132,16 +132,16 @@ namespace Barotrauma
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// If there is room, puts the item in the inventory and returns true, otherwise returns false
|
/// If there is room, puts the item in the inventory and returns true, otherwise returns false
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool TryPutItem(Item item, List<LimbSlot> allowedSlots = null, bool createNetworkEvent = true)
|
public override bool TryPutItem(Item item, List<InvSlotType> allowedSlots = null, bool createNetworkEvent = true)
|
||||||
{
|
{
|
||||||
if (allowedSlots == null) return false;
|
if (allowedSlots == null) return false;
|
||||||
|
|
||||||
//try to place the item in LimBlot.Any slot if that's allowed
|
//try to place the item in LimBlot.Any slot if that's allowed
|
||||||
if (allowedSlots.Contains(LimbSlot.Any))
|
if (allowedSlots.Contains(InvSlotType.Any))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < capacity; i++)
|
for (int i = 0; i < capacity; i++)
|
||||||
{
|
{
|
||||||
if (Items[i] != null || limbSlots[i] != LimbSlot.Any) continue;
|
if (Items[i] != null || limbSlots[i] != InvSlotType.Any) continue;
|
||||||
|
|
||||||
PutItem(item, i, createNetworkEvent);
|
PutItem(item, i, createNetworkEvent);
|
||||||
item.Unequip(character);
|
item.Unequip(character);
|
||||||
@@ -150,7 +150,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool placed = false;
|
bool placed = false;
|
||||||
foreach (LimbSlot allowedSlot in allowedSlots)
|
foreach (InvSlotType allowedSlot in allowedSlots)
|
||||||
{
|
{
|
||||||
//check if all the required slots are free
|
//check if all the required slots are free
|
||||||
bool free = true;
|
bool free = true;
|
||||||
@@ -235,20 +235,20 @@ namespace Barotrauma
|
|||||||
return combined;
|
return combined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (limbSlots[index] == LimbSlot.Any)
|
if (limbSlots[index] == InvSlotType.Any)
|
||||||
{
|
{
|
||||||
if (!item.AllowedSlots.Contains(LimbSlot.Any)) return false;
|
if (!item.AllowedSlots.Contains(InvSlotType.Any)) return false;
|
||||||
if (Items[index] != null) return Items[index] == item;
|
if (Items[index] != null) return Items[index] == item;
|
||||||
|
|
||||||
PutItem(item, index, createNetworkEvent, true);
|
PutItem(item, index, createNetworkEvent, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LimbSlot placeToSlots = LimbSlot.None;
|
InvSlotType placeToSlots = InvSlotType.None;
|
||||||
|
|
||||||
bool slotsFree = true;
|
bool slotsFree = true;
|
||||||
List<LimbSlot> allowedSlots = item.AllowedSlots;
|
List<InvSlotType> allowedSlots = item.AllowedSlots;
|
||||||
foreach (LimbSlot allowedSlot in allowedSlots)
|
foreach (InvSlotType allowedSlot in allowedSlots)
|
||||||
{
|
{
|
||||||
if (!allowedSlot.HasFlag(limbSlots[index])) continue;
|
if (!allowedSlot.HasFlag(limbSlots[index])) continue;
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (!slotsFree) return false;
|
if (!slotsFree) return false;
|
||||||
|
|
||||||
return TryPutItem(item, new List<LimbSlot>() {placeToSlots}, createNetworkEvent);
|
return TryPutItem(item, new List<InvSlotType>() {placeToSlots}, createNetworkEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawOwn(SpriteBatch spriteBatch, Vector2 offset)
|
public void DrawOwn(SpriteBatch spriteBatch, Vector2 offset)
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
protected Character picker;
|
protected Character picker;
|
||||||
|
|
||||||
protected List<LimbSlot> allowedSlots;
|
protected List<InvSlotType> allowedSlots;
|
||||||
|
|
||||||
private float pickTimer;
|
private float pickTimer;
|
||||||
|
|
||||||
|
|
||||||
public List<LimbSlot> AllowedSlots
|
public List<InvSlotType> AllowedSlots
|
||||||
{
|
{
|
||||||
get { return allowedSlots; }
|
get { return allowedSlots; }
|
||||||
}
|
}
|
||||||
@@ -29,23 +29,23 @@ namespace Barotrauma.Items.Components
|
|||||||
public Pickable(Item item, XElement element)
|
public Pickable(Item item, XElement element)
|
||||||
: base(item, element)
|
: base(item, element)
|
||||||
{
|
{
|
||||||
allowedSlots = new List<LimbSlot>();
|
allowedSlots = new List<InvSlotType>();
|
||||||
|
|
||||||
string slotString = ToolBox.GetAttributeString(element, "slots", "Any");
|
string slotString = ToolBox.GetAttributeString(element, "slots", "Any");
|
||||||
string[] slotCombinations = slotString.Split(',');
|
string[] slotCombinations = slotString.Split(',');
|
||||||
foreach (string slotCombination in slotCombinations)
|
foreach (string slotCombination in slotCombinations)
|
||||||
{
|
{
|
||||||
string[] slots = slotCombination.Split('+');
|
string[] slots = slotCombination.Split('+');
|
||||||
LimbSlot allowedSlot = LimbSlot.None;
|
InvSlotType allowedSlot = InvSlotType.None;
|
||||||
foreach (string slot in slots)
|
foreach (string slot in slots)
|
||||||
{
|
{
|
||||||
if (slot.ToLower()=="bothhands")
|
if (slot.ToLower()=="bothhands")
|
||||||
{
|
{
|
||||||
allowedSlot = LimbSlot.LeftHand | LimbSlot.RightHand;
|
allowedSlot = InvSlotType.LeftHand | InvSlotType.RightHand;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
allowedSlot = allowedSlot | (LimbSlot)Enum.Parse(typeof(LimbSlot), slot.Trim());
|
allowedSlot = allowedSlot | (InvSlotType)Enum.Parse(typeof(InvSlotType), slot.Trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
allowedSlots.Add(allowedSlot);
|
allowedSlots.Add(allowedSlot);
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
protected int capacity;
|
protected int capacity;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Vector2 centerPos;
|
private Vector2 centerPos;
|
||||||
|
|
||||||
protected int selectedSlot;
|
protected int selectedSlot;
|
||||||
@@ -95,7 +93,7 @@ namespace Barotrauma
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// If there is room, puts the item in the inventory and returns true, otherwise returns false
|
/// If there is room, puts the item in the inventory and returns true, otherwise returns false
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool TryPutItem(Item item, List<LimbSlot> allowedSlots = null, bool createNetworkEvent = true)
|
public virtual bool TryPutItem(Item item, List<InvSlotType> allowedSlots = null, bool createNetworkEvent = true)
|
||||||
{
|
{
|
||||||
int slot = FindAllowedSlot(item);
|
int slot = FindAllowedSlot(item);
|
||||||
if (slot < 0) return false;
|
if (slot < 0) return false;
|
||||||
@@ -334,14 +332,30 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
GUI.DrawRectangle(spriteBatch, rect, (isHighLighted ? Color.Red : Color.White) * alpha*0.75f, true);
|
GUI.DrawRectangle(spriteBatch, rect, (isHighLighted ? Color.Red : Color.White) * alpha*0.75f, true);
|
||||||
|
|
||||||
if (item != null && item.Condition < 100.0f)
|
if (item != null)
|
||||||
{
|
{
|
||||||
GUI.DrawRectangle(spriteBatch, new Rectangle(rect.X, rect.Bottom - 4, rect.Width, 4), Color.Black, true);
|
if (item.Condition < 100.0f)
|
||||||
GUI.DrawRectangle(spriteBatch,
|
{
|
||||||
new Rectangle(rect.X, rect.Bottom - 4, (int)(rect.Width * item.Condition / 100.0f), 4),
|
GUI.DrawRectangle(spriteBatch, new Rectangle(rect.X, rect.Bottom - 8, rect.Width, 8), Color.Black*0.8f, true);
|
||||||
Color.Lerp(Color.Red, Color.Green, item.Condition / 100.0f), true);
|
GUI.DrawRectangle(spriteBatch,
|
||||||
|
new Rectangle(rect.X, rect.Bottom - 8, (int)(rect.Width * item.Condition / 100.0f), 8),
|
||||||
|
Color.Lerp(Color.Red, Color.Green, item.Condition / 100.0f)*0.8f, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isHighLighted)
|
||||||
|
{
|
||||||
|
var containedItems = item.ContainedItems;
|
||||||
|
if (containedItems != null && containedItems.Length == 1 && containedItems[0].Condition < 100.0f)
|
||||||
|
{
|
||||||
|
GUI.DrawRectangle(spriteBatch, new Rectangle(rect.X, rect.Y, rect.Width, 8), Color.Black*0.8f, true);
|
||||||
|
GUI.DrawRectangle(spriteBatch,
|
||||||
|
new Rectangle(rect.X, rect.Y, (int)(rect.Width * containedItems[0].Condition / 100.0f), 8),
|
||||||
|
Color.Lerp(Color.Red, Color.Green, containedItems[0].Condition / 100.0f)*0.8f, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch, rect, (isHighLighted ? Color.Red : Color.White) * alpha, false);
|
GUI.DrawRectangle(spriteBatch, rect, (isHighLighted ? Color.Red : Color.White) * alpha, false);
|
||||||
|
|
||||||
if (item == null || !drawItem) return;
|
if (item == null || !drawItem) return;
|
||||||
|
|||||||
@@ -236,12 +236,12 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
//which type of inventory slots (head, torso, any, etc) the item can be placed in
|
//which type of inventory slots (head, torso, any, etc) the item can be placed in
|
||||||
public List<LimbSlot> AllowedSlots
|
public List<InvSlotType> AllowedSlots
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Pickable p = GetComponent<Pickable>();
|
Pickable p = GetComponent<Pickable>();
|
||||||
return (p==null) ? new List<LimbSlot>() { LimbSlot.Any } : p.AllowedSlots;
|
return (p==null) ? new List<InvSlotType>() { InvSlotType.Any } : p.AllowedSlots;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,10 +175,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public static void LoadAll(List<string> filePaths)
|
public static void LoadAll(List<string> filePaths)
|
||||||
{
|
{
|
||||||
//string[] files = Directory.GetFiles(contentFolder, "*.xml", SearchOption.AllDirectories);
|
DebugConsole.Log("Loading item prefabs: ");
|
||||||
|
|
||||||
foreach (string filePath in filePaths)
|
foreach (string filePath in filePaths)
|
||||||
{
|
{
|
||||||
|
DebugConsole.Log("*** "+filePath+" ***");
|
||||||
|
|
||||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||||
if (doc == null) return;
|
if (doc == null) return;
|
||||||
|
|
||||||
@@ -200,12 +202,13 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public ItemPrefab (XElement element, string filePath)
|
public ItemPrefab (XElement element, string filePath)
|
||||||
{
|
{
|
||||||
|
|
||||||
configFile = filePath;
|
configFile = filePath;
|
||||||
|
|
||||||
name = ToolBox.GetAttributeString(element, "name", "");
|
name = ToolBox.GetAttributeString(element, "name", "");
|
||||||
if (name == "") DebugConsole.ThrowError("Unnamed item in "+filePath+"!");
|
if (name == "") DebugConsole.ThrowError("Unnamed item in "+filePath+"!");
|
||||||
|
|
||||||
|
DebugConsole.Log(" "+name);
|
||||||
|
|
||||||
Description = ToolBox.GetAttributeString(element, "description", "");
|
Description = ToolBox.GetAttributeString(element, "description", "");
|
||||||
|
|
||||||
pickThroughWalls = ToolBox.GetAttributeBool(element, "pickthroughwalls", false);
|
pickThroughWalls = ToolBox.GetAttributeBool(element, "pickthroughwalls", false);
|
||||||
@@ -226,13 +229,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
ImpactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 0.0f);
|
ImpactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 0.0f);
|
||||||
|
|
||||||
|
|
||||||
string categoriesStr = ToolBox.GetAttributeString(element, "category", "Misc");
|
string categoriesStr = ToolBox.GetAttributeString(element, "category", "Misc");
|
||||||
string[] categories = categoriesStr.Split(',');
|
string[] categories = categoriesStr.Split(',');
|
||||||
|
|
||||||
for (int i = 0; i<categories.Length; i++)
|
for (int i = 0; i < categories.Length; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
MapEntityCategory category;
|
MapEntityCategory category;
|
||||||
if (Enum.TryParse(ToolBox.GetAttributeString(element, "category", "Misc"), out category))
|
if (Enum.TryParse(ToolBox.GetAttributeString(element, "category", "Misc"), out category))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ namespace Barotrauma.Networking
|
|||||||
if (sender == null) return false;
|
if (sender == null) return false;
|
||||||
|
|
||||||
var radio = sender.Inventory.Items.First(i => i != null && i.GetComponent<WifiComponent>() != null);
|
var radio = sender.Inventory.Items.First(i => i != null && i.GetComponent<WifiComponent>() != null);
|
||||||
if (radio == null) return false;
|
if (radio == null || !sender.HasEquippedItem(radio)) return false;
|
||||||
|
|
||||||
var radioComponent = radio.GetComponent<WifiComponent>();
|
var radioComponent = radio.GetComponent<WifiComponent>();
|
||||||
return radioComponent.HasRequiredContainedItems(false);
|
return radioComponent.HasRequiredContainedItems(false);
|
||||||
@@ -236,6 +236,8 @@ namespace Barotrauma.Networking
|
|||||||
var radio = message.Sender.Inventory.Items.First(i => i != null && i.GetComponent<WifiComponent>() != null);
|
var radio = message.Sender.Inventory.Items.First(i => i != null && i.GetComponent<WifiComponent>() != null);
|
||||||
if (radio == null) return;
|
if (radio == null) return;
|
||||||
|
|
||||||
|
message.Sender.ShowSpeechBubble(2.0f, ChatMessage.MessageColor[(int)ChatMessageType.Radio]);
|
||||||
|
|
||||||
var radioComponent = radio.GetComponent<WifiComponent>();
|
var radioComponent = radio.GetComponent<WifiComponent>();
|
||||||
radioComponent.Transmit(message.TextWithSender);
|
radioComponent.Transmit(message.TextWithSender);
|
||||||
return;
|
return;
|
||||||
@@ -251,7 +253,7 @@ namespace Barotrauma.Networking
|
|||||||
if (string.IsNullOrWhiteSpace(displayedText)) return;
|
if (string.IsNullOrWhiteSpace(displayedText)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.Sender.SpeechBubbleTimer = Math.Max(message.Sender.SpeechBubbleTimer, 2.0f);
|
message.Sender.ShowSpeechBubble(2.0f, ChatMessage.MessageColor[(int)ChatMessageType.Default]);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMain.NetLobbyScreen.NewChatMessage(message);
|
GameMain.NetLobbyScreen.NewChatMessage(message);
|
||||||
|
|||||||
@@ -469,7 +469,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
var item = new Item(screwdriverPrefab, Vector2.Zero, null);
|
var item = new Item(screwdriverPrefab, Vector2.Zero, null);
|
||||||
|
|
||||||
dummyCharacter.Inventory.TryPutItem(item, new List<LimbSlot>() {LimbSlot.RightHand}, false);
|
dummyCharacter.Inventory.TryPutItem(item, new List<InvSlotType>() {InvSlotType.RightHand}, false);
|
||||||
|
|
||||||
wiringToolPanel = CreateWiringPanel();
|
wiringToolPanel = CreateWiringPanel();
|
||||||
}
|
}
|
||||||
@@ -537,7 +537,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
var wire = new Item(userData as ItemPrefab, Vector2.Zero, null);
|
var wire = new Item(userData as ItemPrefab, Vector2.Zero, null);
|
||||||
|
|
||||||
int slotIndex = dummyCharacter.Inventory.FindLimbSlot(LimbSlot.LeftHand);
|
int slotIndex = dummyCharacter.Inventory.FindLimbSlot(InvSlotType.LeftHand);
|
||||||
|
|
||||||
//if there's some other type of wire in the inventory, remove it
|
//if there's some other type of wire in the inventory, remove it
|
||||||
existingWire = dummyCharacter.Inventory.Items[slotIndex];
|
existingWire = dummyCharacter.Inventory.Items[slotIndex];
|
||||||
|
|||||||
Reference in New Issue
Block a user