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:
Regalis
2016-04-21 17:17:32 +03:00
parent e46ec1ade2
commit 12dc494e42
15 changed files with 114 additions and 62 deletions
@@ -65,9 +65,9 @@ namespace Barotrauma
{
var pickable = targetItem.GetComponent<Pickable>();
//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++)
{
@@ -80,7 +80,7 @@ namespace Barotrauma
if (character.Inventory.Items[i] == null) continue;
//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
character.Inventory.Items[i].Drop();
@@ -90,7 +90,7 @@ namespace Barotrauma
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);
}
+20 -6
View File
@@ -156,7 +156,8 @@ namespace Barotrauma
get { return inventory; }
}
public float SpeechBubbleTimer;
private Color speechBubbleColor;
private float speechBubbleTimer;
private float lockHandsTimer;
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)
{
return selectedItems.Contains(item);
@@ -701,8 +707,8 @@ namespace Barotrauma
public bool TrySelectItem(Item item)
{
bool rightHand = ((CharacterInventory)inventory).IsInLimbSlot(item, LimbSlot.RightHand);
bool leftHand = ((CharacterInventory)inventory).IsInLimbSlot(item, LimbSlot.LeftHand);
bool rightHand = inventory.IsInLimbSlot(item, InvSlotType.RightHand);
bool leftHand = inventory.IsInLimbSlot(item, InvSlotType.LeftHand);
bool selected = false;
if (rightHand && SelectedItems[0] == null)
@@ -956,7 +962,7 @@ namespace Barotrauma
{
if (!Enabled) return;
SpeechBubbleTimer = Math.Max(0.0f, SpeechBubbleTimer - deltaTime);
speechBubbleTimer = Math.Max(0.0f, speechBubbleTimer - deltaTime);
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
@@ -1086,6 +1092,12 @@ namespace Barotrauma
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)
{
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);
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));
}
}
+1 -1
View File
@@ -65,7 +65,7 @@ namespace Barotrauma
for (int i = 0; i< character.Inventory.Items.Length-1; 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>();
//if (statusHUD == null) continue;
foreach (ItemComponent ic in item.components)
+2 -3
View File
@@ -89,7 +89,6 @@ namespace Barotrauma
foreach (XElement itemElement in SpawnItems.Elements())
{
InitializeJobItem(character, spawnPoint, itemElement);
}
}
@@ -108,8 +107,8 @@ namespace Barotrauma
if (ToolBox.GetAttributeBool(itemElement, "equip", false))
{
List<LimbSlot> allowedSlots = new List<LimbSlot>(item.AllowedSlots);
allowedSlots.Remove(LimbSlot.Any);
List<InvSlotType> allowedSlots = new List<InvSlotType>(item.AllowedSlots);
allowedSlots.Remove(InvSlotType.Any);
character.Inventory.TryPutItem(item, allowedSlots, false);
}