- health scanner item
- specific skills are required to fabricate some items - changes to medical syringes: the status effects are defined in the chemical item instead of the syringe
This commit is contained in:
@@ -97,6 +97,8 @@ namespace Barotrauma
|
||||
divingGearObjective = new AIObjectiveFindDivingGear(character, false);
|
||||
}
|
||||
|
||||
if (divingGearObjective.IsCompleted()) return true;
|
||||
|
||||
divingGearObjective.TryComplete(deltaTime);
|
||||
return divingGearObjective.IsCompleted();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace Barotrauma
|
||||
|
||||
private string[] onContainingNames;
|
||||
|
||||
private readonly bool useItem;
|
||||
|
||||
public readonly ActionType type;
|
||||
|
||||
private Explosion explosion;
|
||||
@@ -147,6 +149,10 @@ namespace Barotrauma
|
||||
case "fire":
|
||||
FireSize = ToolBox.GetAttributeFloat(subElement,"size",10.0f);
|
||||
break;
|
||||
case "use":
|
||||
case "useitem":
|
||||
useItem = true;
|
||||
break;
|
||||
case "requireditem":
|
||||
case "requireditems":
|
||||
RelatedItem newRequiredItem = RelatedItem.Load(subElement);
|
||||
@@ -223,17 +229,28 @@ namespace Barotrauma
|
||||
|
||||
if (sound != null) sound.Play(1.0f, 1000.0f, entity.WorldPosition);
|
||||
|
||||
for (int i = 0; i < propertyNames.Count(); i++)
|
||||
if (useItem)
|
||||
{
|
||||
ObjectProperty property;
|
||||
foreach (IPropertyObject target in targets)
|
||||
foreach (Item item in targets.FindAll(t => t is Item).Cast<Item>())
|
||||
{
|
||||
item.Use(deltaTime, targets.FirstOrDefault(t => t is Character) as Character);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (IPropertyObject target in targets)
|
||||
{
|
||||
for (int i = 0; i < propertyNames.Count(); i++)
|
||||
{
|
||||
ObjectProperty property;
|
||||
|
||||
//if (targetNames!=null && !targetNames.Contains(target.Name)) continue;
|
||||
|
||||
if (!target.ObjectProperties.TryGetValue(propertyNames[i], out property)) continue;
|
||||
|
||||
ApplyToProperty(property, propertyEffects[i], deltaTime);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -416,15 +416,7 @@ namespace Barotrauma.Items.Components
|
||||
public virtual void Draw(SpriteBatch spriteBatch, bool editing = false) { }
|
||||
|
||||
public virtual void DrawHUD(SpriteBatch spriteBatch, Character character) { }
|
||||
|
||||
/// <summary>
|
||||
/// a construction has activated the item (such as a turret shooting a projectile)
|
||||
/// call the Activate-methods of the components</summary>
|
||||
/// <param name="c"> The construction which activated the item</param>
|
||||
/// <param name="modifier"> A vector that can be used to pass additional information to the components</param>
|
||||
public virtual void ItemActivate(Item item, Vector2 modifier) { }
|
||||
|
||||
|
||||
|
||||
/// <returns>true if the operation was completed</returns>
|
||||
public virtual bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public readonly float RequiredTime;
|
||||
|
||||
//ListOrSomething requiredLevels
|
||||
public readonly List<Skill> RequiredSkills;
|
||||
|
||||
public FabricableItem(XElement element)
|
||||
{
|
||||
@@ -29,6 +29,8 @@ namespace Barotrauma.Items.Components
|
||||
return;
|
||||
}
|
||||
|
||||
RequiredSkills = new List<Skill>();
|
||||
|
||||
RequiredTime = ToolBox.GetAttributeFloat(element, "requiredtime", 1.0f);
|
||||
|
||||
RequiredItems = new List<Tuple<ItemPrefab, int>>();
|
||||
@@ -58,7 +60,18 @@ namespace Barotrauma.Items.Components
|
||||
RequiredItems.Remove(existing);
|
||||
RequiredItems.Add(new Tuple<ItemPrefab, int>(requiredItem, existing.Item2+1));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLower())
|
||||
{
|
||||
case "requiredskill":
|
||||
RequiredSkills.Add(new Skill(
|
||||
ToolBox.GetAttributeString(subElement, "name", ""),
|
||||
ToolBox.GetAttributeInt(subElement, "level", 0)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -143,17 +156,41 @@ namespace Barotrauma.Items.Components
|
||||
Alignment.TopLeft, null,
|
||||
selectedItemFrame, true);
|
||||
|
||||
string text = "Required items:\n";
|
||||
foreach (Tuple<ItemPrefab,int> ip in targetItem.RequiredItems)
|
||||
|
||||
List<Skill> inadequateSkills = new List<Skill>();
|
||||
|
||||
if (Character.Controlled != null)
|
||||
{
|
||||
text += " - " + ip.Item1.Name + " x"+ip.Item2+"\n";
|
||||
|
||||
inadequateSkills = targetItem.RequiredSkills.FindAll(skill => Character.Controlled.GetSkillLevel(skill.Name) < skill.Level);
|
||||
}
|
||||
|
||||
Color textColor = Color.White;
|
||||
string text;
|
||||
if (!inadequateSkills.Any())
|
||||
{
|
||||
text = "Required items:\n";
|
||||
foreach (Tuple<ItemPrefab,int> ip in targetItem.RequiredItems)
|
||||
{
|
||||
text += " - " + ip.Item1.Name + " x"+ip.Item2+"\n";
|
||||
}
|
||||
text += "Required time: " + targetItem.RequiredTime + " s";
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "Skills required to calibrate:\n";
|
||||
foreach (Skill skill in inadequateSkills)
|
||||
{
|
||||
text += " - " + skill.Name + " lvl " + skill.Level + "\n";
|
||||
}
|
||||
|
||||
textColor = Color.Red;
|
||||
}
|
||||
text += "Required time: " + targetItem.RequiredTime + " s";
|
||||
|
||||
new GUITextBlock(
|
||||
new Rectangle(0, 50, 0, 25),
|
||||
text,
|
||||
Color.Transparent, Color.White,
|
||||
Color.Transparent, textColor,
|
||||
Alignment.TopLeft,
|
||||
Alignment.TopLeft, null,
|
||||
selectedItemFrame);
|
||||
@@ -284,21 +321,32 @@ namespace Barotrauma.Items.Components
|
||||
FabricableItem targetItem = itemList.SelectedData as FabricableItem;
|
||||
if (targetItem != null)
|
||||
{
|
||||
activateButton.Enabled = true;
|
||||
|
||||
ItemContainer container = item.GetComponent<ItemContainer>();
|
||||
foreach (Tuple<ItemPrefab,int> ip in targetItem.RequiredItems)
|
||||
{
|
||||
if (Array.FindAll(container.Inventory.Items, it => it != null && it.Prefab == ip.Item1).Count() >= ip.Item2) continue;
|
||||
activateButton.Enabled = false;
|
||||
break;
|
||||
}
|
||||
activateButton.Enabled = CanBeFabricated(targetItem, character);
|
||||
}
|
||||
|
||||
GuiFrame.Update((float)Physics.step);
|
||||
GuiFrame.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
private bool CanBeFabricated(FabricableItem fabricableItem, Character user)
|
||||
{
|
||||
if (fabricableItem == null) return false;
|
||||
|
||||
if (user != null &&
|
||||
fabricableItem.RequiredSkills.Any(skill => user.GetSkillLevel(skill.Name) < skill.Level))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemContainer container = item.GetComponent<ItemContainer>();
|
||||
foreach (Tuple<ItemPrefab, int> ip in fabricableItem.RequiredItems)
|
||||
{
|
||||
if (Array.FindAll(container.Inventory.Items, it => it != null && it.Prefab == ip.Item1).Count() < ip.Item2) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||
{
|
||||
int itemIndex = fabricatedItem == null ? -1 : fabricableItems.IndexOf(fabricatedItem);
|
||||
|
||||
75
Subsurface/Source/Items/Components/StatusHUD.cs
Normal file
75
Subsurface/Source/Items/Components/StatusHUD.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
class StatusHUD : ItemComponent
|
||||
{
|
||||
private static readonly string[] BleedingTexts = {"Minor bleeding", "Bleeding", "Bleeding heavily", "Catastrophic Bleeding"};
|
||||
|
||||
private static readonly string[] HealthTexts = { "No visible injuries", "Minor injuries", "Injured", "Major injuries", "Critically injured" };
|
||||
|
||||
private static readonly string[] OxygenTexts = { "Oxygen level normal", "Gasping for air", "Signs of oxygen deprivation", "Not breathing" };
|
||||
|
||||
public StatusHUD(Item item, XElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
}
|
||||
|
||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||
{
|
||||
if (character == null) return;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
|
||||
Color.Green * 0.1f, true);
|
||||
|
||||
if (character.ClosestCharacter == null) return;
|
||||
|
||||
var target = character.ClosestCharacter;
|
||||
|
||||
Vector2 hudPos = GameMain.GameScreen.Cam.WorldToScreen(target.WorldPosition);
|
||||
hudPos += Vector2.UnitX * 50.0f;
|
||||
|
||||
List<string> texts = new List<string>();
|
||||
|
||||
texts.Add(target.Name);
|
||||
|
||||
if (target.IsDead)
|
||||
{
|
||||
texts.Add("Deceased");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (target.IsUnconscious) texts.Add("Unconscious");
|
||||
if (target.Stun > 0.01f) texts.Add("Stunned");
|
||||
|
||||
int healthTextIndex = target.Health > 95.0f ? 0 :
|
||||
MathHelper.Clamp((int)Math.Ceiling((1.0f - (target.Health / 200.0f + 0.5f)) * HealthTexts.Length), 0, HealthTexts.Length - 1);
|
||||
|
||||
texts.Add(HealthTexts[healthTextIndex]);
|
||||
|
||||
int oxygenTextIndex = MathHelper.Clamp((int)Math.Floor((1.0f - (target.Oxygen / 200.0f + 0.5f)) * OxygenTexts.Length), 0, OxygenTexts.Length - 1);
|
||||
texts.Add(OxygenTexts[oxygenTextIndex]);
|
||||
|
||||
if (target.Bleeding > 0.0f)
|
||||
{
|
||||
int bleedingTextIndex = MathHelper.Clamp((int)Math.Floor(target.Bleeding / 4.0f) * BleedingTexts.Length, 0, BleedingTexts.Length - 1);
|
||||
texts.Add(BleedingTexts[bleedingTextIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach (string text in texts)
|
||||
{
|
||||
GUI.DrawString(spriteBatch, hudPos, text, Color.LightGreen, Color.Black * 0.7f, 2);
|
||||
hudPos.Y += 24.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1110,7 +1110,7 @@ namespace Barotrauma
|
||||
picked = true;
|
||||
ic.ApplyStatusEffects(ActionType.OnPicked, 1.0f, picker);
|
||||
|
||||
GUIComponent.MouseOn = null;
|
||||
if (picker==Character.Controlled) GUIComponent.MouseOn = null;
|
||||
|
||||
if (ic.CanBeSelected) selected = true;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace Barotrauma
|
||||
None = 0,
|
||||
Contained = 1,
|
||||
Equipped = 2,
|
||||
Picked = 4
|
||||
Picked = 4,
|
||||
Container = 8
|
||||
}
|
||||
|
||||
string[] names;
|
||||
@@ -86,6 +87,10 @@ namespace Barotrauma
|
||||
if (contained.Condition > 0.0f && MatchesItem(contained)) return true;
|
||||
}
|
||||
break;
|
||||
case RelationType.Container:
|
||||
if (parentItem == null || parentItem.Container == null) return false;
|
||||
|
||||
return parentItem.Container.Condition > 0.0f && MatchesItem(parentItem.Container);
|
||||
case RelationType.Equipped:
|
||||
if (character == null) return false;
|
||||
foreach (Item equippedItem in character.SelectedItems)
|
||||
|
||||
Reference in New Issue
Block a user