- 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:
Regalis
2016-03-26 18:15:44 +02:00
parent 6c0927a564
commit ca492bf0d4
14 changed files with 342 additions and 118 deletions

View File

@@ -122,6 +122,7 @@
<Compile Include="Source\Items\Components\Signal\WifiComponent.cs" />
<Compile Include="Source\Items\Components\Signal\SignalCheckComponent.cs" />
<Compile Include="Source\Items\Components\ItemLabel.cs" />
<Compile Include="Source\Items\Components\StatusHUD.cs" />
<Compile Include="Source\Items\FixRequirement.cs" />
<Compile Include="Source\Items\ItemSpawner.cs" />
<Compile Include="Source\Map\EntityGrid.cs" />

View File

@@ -188,10 +188,28 @@
</Item>
<Item
name="Doctor's Coat"
category="Equipment"
pickdistance="150"
tags="smallitem">
name="Health Scanner HUD"
category="Equipment"
pickdistance="150"
tags="smallitem"
description="A heads-up display that displays information of the vital signs and status of nearby humans.">
<Sprite texture ="doctorgear.png" sourcerect="0,120,20,8" depth="0.6"/>
<Body width="18" height="6" density="30"/>
<Wearable limbtype="Head" slots="Any,Head">
<sprite texture ="doctorgear.png" sourcerect="0,120,20,8" limb="Head" origin="0.45,0.9"/>
</Wearable>
<StatusHUD/>
</Item>
<Item
name="Doctor's Coat"
category="Equipment"
pickdistance="150"
tags="smallitem">
<Sprite texture ="doctorgear.png" sourcerect="75,0,53,18" depth="0.6"/>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -14,15 +14,25 @@
<GuiFrame rect="0,0,600,400" alignment="Center" color="0.0,0.0,0.0,0.6"/>
<sound file="fabricator.ogg" type="OnActive" range="1000.0" loop="true"/>
<fabricableitem name="Harpoon Gun" requireditems="Steel Bar, Polycarbonate Bar" requiredtime="20"/>
<fabricableitem name="Spear" requireditems="Steel Bar" requiredtime="10"/>
<fabricableitem name="Plasma Cutter" requireditems="Steel Bar, Polycarbonate Bar" requiredtime="20"/>
<fabricableitem name="Welding Tool" requireditems="Steel Bar, Polycarbonate Bar" requiredtime="20"/>
<fabricableitem name="Railgun Shell" requireditems="Steel Bar, Steel Bar, Polycarbonate Bar" requiredtime="20"/>
<fabricableitem name="Nuclear Shell" requireditems="Steel Bar, Steel Bar, Uranium Bar, Polycarbonate Bar" requiredtime="30"/>
<fabricableitem name="Harpoon Gun" requireditems="Steel Bar, Polycarbonate Bar" requiredtime="20">
<RequiredSkill name="Construction" level="30"/>
</fabricableitem>
<fabricableitem name="Spear" requireditems="Steel Bar" requiredtime="10"/>
<fabricableitem name="Plasma Cutter" requireditems="Steel Bar, Polycarbonate Bar" requiredtime="20">
<RequiredSkill name="Construction" level="30"/>
</fabricableitem>
<fabricableitem name="Welding Tool" requireditems="Steel Bar, Polycarbonate Bar" requiredtime="20">
<RequiredSkill name="Construction" level="30"/>
</fabricableitem>
<fabricableitem name="Railgun Shell" requireditems="Steel Bar, Steel Bar, Polycarbonate Bar" requiredtime="20">
<RequiredSkill name="Construction" level="25"/>
</fabricableitem>
<fabricableitem name="Nuclear Shell" requireditems="Steel Bar, Steel Bar, Uranium Bar, Polycarbonate Bar" requiredtime="30">
<RequiredSkill name="Construction" level="40"/>
</fabricableitem>
<fabricableitem name="Wire" requireditems="Copper Bar" requiredtime="5"/>
@@ -43,9 +53,13 @@
<fabricableitem name="Fulgurium Battery Cell" requireditems="Steel Bar, Fulgurium Bar, FPGA Circuit" requiredtime="10"/>
<fabricableitem name ="Stun Grenade" requireditems="Steel Bar, Flash Powder, Chloral Hydrate" requiredtime="20"/>
<fabricableitem name ="Stun Grenade" requireditems="Steel Bar, Flash Powder, Chloral Hydrate" requiredtime="20">
<RequiredSkill name="Construction" level="30"/>
</fabricableitem>
<fabricableitem name ="Incendium Grenade" requireditems="Stun Grenade, Incendium Bar" requiredtime="20"/>
<fabricableitem name ="Incendium Grenade" requireditems="Stun Grenade, Incendium Bar" requiredtime="20">
<RequiredSkill name="Construction" level="40"/>
</fabricableitem>
<fabricableitem name ="IC-4 Block" requireditems="C-4 Block, Incendium Bar" requiredtime="20"/>
@@ -72,25 +86,37 @@
category="Machine"
description="A machine that can be used to manufacture various medicines.">
<Sprite texture="Content/Items/machines.png" depth="0.8" sourcerect="0,128,64,128"/>
<Sprite texture="Content/Items/machines.png" depth="0.8" sourcerect="128,0,64,128"/>
<Fabricator canbeselected = "true" powerconsumption="100.0">
<GuiFrame rect="0,0,600,400" alignment="Center" color="0.0,0.0,0.0,0.6"/>
<sound file="fabricator.ogg" type="OnActive" range="1000.0" loop="true"/>
<fabricableitem name="Corrigodone" requireditems="Stabilozine, Chloral Hydrate" requiredtime="20"/>
<fabricableitem name="Corrigodone" requireditems="Stabilozine, Chloral Hydrate" requiredtime="20">
<RequiredSkill name="Medical" level="50"/>
</fabricableitem>
<fabricableitem name="Chloral Hydrate" requireditems="Chlorine, Ethanol" requiredtime="20"/>
<fabricableitem name="Erythrozine" requireditems="Stabilozine, Iron Powder" requiredtime="20"/>
<fabricableitem name="Fibrinozine" requireditems="Stabilozine, Phosphorus" requiredtime="20"/>
<fabricableitem name="Chloral Hydrate" requireditems="Chlorine, Ethanol" requiredtime="20">
<RequiredSkill name="Medical" level="30"/>
</fabricableitem>
<fabricableitem name="Flash Powder" requireditems="Aluminium, Potassium" requiredtime="25"/>
<fabricableitem name="Auxiliorizine" requireditems="Corrigodone, Flash Powder" requiredtime="25"/>
<fabricableitem name="Erythrozine" requireditems="Stabilozine, Iron Powder" requiredtime="20">
<RequiredSkill name="Medical" level="50"/>
</fabricableitem>
<fabricableitem name="Fibrinozine" requireditems="Stabilozine, Phosphorus" requiredtime="20">
<RequiredSkill name="Medical" level="50"/>
</fabricableitem>
<fabricableitem name="Flash Powder" requireditems="Aluminium, Potassium" requiredtime="25">
<RequiredSkill name="Medical" level="40"/>
</fabricableitem>
<fabricableitem name="Auxiliorizine" requireditems="Corrigodone, Flash Powder" requiredtime="25">
<RequiredSkill name="Medical" level="60"/>
</fabricableitem>
</Fabricator>
@@ -109,8 +135,8 @@
pickdistance="150"
category="Machine"
description="Disassembles and breaks down items to reusable components and material bars.">
<Sprite texture="Content/Items/machines.png" depth="0.8" sourcerect="64,128,64,128"/>
<Sprite texture="Content/Items/machines.png" depth="0.8" sourcerect="0,128,64,128"/>
<Deconstructor canbeselected = "true" powerconsumption="500.0">
<sound file="deconstructor.ogg" type="OnActive" range="1000.0" loop="true"/>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<Items>
<Items>
<Item
name="Medical Syringe"
category="Equipment"
@@ -16,38 +16,10 @@
<MeleeWeapon slots="Any,RightHand,LeftHand"
aimpos="5,0" handle1="-5,0" holdangle="10" reload="1.0">
<StatusEffect type="OnUse" target="Contained" Condition="-25.0" disabledeltatime="true" sound="Content/Items/Medical/syringe.ogg">
<StatusEffect type="OnUse" target="Contained, Character" Condition="-25.0" disabledeltatime="true" sound="Content/Items/Medical/syringe.ogg">
<RequiredItem name="chem" type="Contained"/>
<Use/>
</StatusEffect>
<StatusEffect type="OnUse" target="Character" Health="-3.0" Oxygen="20.0" disabledeltatime="true">
<RequiredItem name="Erythrozine" type="Contained"/>
</StatusEffect>
<StatusEffect type="OnUse" target="Character" Health="3.0" Oxygen="3" disabledeltatime="true">
<RequiredItem name="Stabilozine" type="Contained"/>
</StatusEffect>
<StatusEffect type="OnUse" target="Character" Bleeding="-10.0" disabledeltatime="true">
<RequiredItem name="Fibrinozine" type="Contained"/>
</StatusEffect>
<StatusEffect type="OnUse" target="Character" Health="10.0" disabledeltatime="true">
<RequiredItem name="Corrigodone" type="Contained"/>
</StatusEffect>
<StatusEffect type="OnUse" target="Character" Health="20.0" Oxygen="100.0" disabledeltatime="true">
<RequiredItem name="Auxiliorizine" type="Contained"/>
</StatusEffect>
<StatusEffect type="OnUse" target="Character" Health="-5.0" disabledeltatime="true">
<RequiredItem name="Chlorine" type="Contained"/>
</StatusEffect>
<StatusEffect type="OnUse" target="Character" Health="-5.0" Stun="10.0" disabledeltatime="true">
<RequiredItem name="Chloral Hydrate" type="Contained"/>
</StatusEffect>
</MeleeWeapon>
<ItemContainer capacity="1" hideitems="true">
@@ -88,6 +60,7 @@
category="Equipment"
Tags="smallitem"
pickdistance="150"
canuseonself="true"
price="20"
description="Treated with a hemostatic agent that quickly seals most minor wounds.">
@@ -95,9 +68,10 @@
<Body width="11" height="16" density="20"/>
<Holdable slots="Any,RightHand,LeftHand" RemoveOnUse="true">
<StatusEffect type="OnUse" target="This, Character" bleeding="-10.0" Condition="-100.0" disabledeltatime="true" sound="Content/Items/Medical/bandage.ogg"/>
</Holdable>
<MeleeWeapon slots="Any,RightHand,LeftHand"
aimpos="5,0" handle1="-5,0" holdangle="10" reload="1.0">
<StatusEffect type="OnUse" target="This, Character" bleeding="-10.0" Condition="-25.0" disabledeltatime="true" sound="Content/Items/Medical/bandage.ogg"/>
</MeleeWeapon>
</Item>
<Item
@@ -116,7 +90,7 @@
<Item
name="Stabilozine"
category="Material"
spritecolor="1.0,1.0,0.8,1.0"
spritecolor="1.0,1.0,0.7,1.0"
Tags="smallitem,chem"
pickdistance="150"
description="A mild stimulant which is used as an incredient in the manufacture of various medicines.">
@@ -125,13 +99,17 @@
<Body width="25" height="5" density="20"/>
<Holdable slots="Any,RightHand,LeftHand"/>
<Holdable slots="Any,RightHand,LeftHand">
<StatusEffect type="OnUse" target="Character" Health="3.0" Oxygen="3" disabledeltatime="true">
<RequiredItem name="Medical Syringe" type="Container"/>
</StatusEffect>
</Holdable>
</Item>
<Item
name="Erythrozine"
category="Material"
spritecolor="0.9,0.9,1.0,1.0"
spritecolor="0.5,0.5,1.0,1.0"
Tags="smallitem,chem"
pickdistance="150"
description="Most commonly used for treating oxygen deprivation.">
@@ -140,7 +118,11 @@
<Body width="25" height="5" density="20"/>
<Holdable slots="Any,RightHand,LeftHand"/>
<Holdable slots="Any,RightHand,LeftHand">
<StatusEffect type="OnUse" target="Character" Health="-3.0" Oxygen="20.0" disabledeltatime="true">
<RequiredItem name="Medical Syringe" type="Container"/>
</StatusEffect>
</Holdable>
</Item>
<Item
@@ -154,8 +136,12 @@
<Sprite texture ="med.png" sourcerect="24,16,8,16" depth="0.6" />
<Body width="25" height="5" density="20"/>
<Holdable slots="Any,RightHand,LeftHand"/>
<Holdable slots="Any,RightHand,LeftHand">
<StatusEffect type="OnUse" target="Character" Bleeding="-10.0" disabledeltatime="true">
<RequiredItem name="Medical Syringe" type="Container"/>
</StatusEffect>
</Holdable>
</Item>
<Item
@@ -170,13 +156,17 @@
<Body width="25" height="5" density="20"/>
<Holdable slots="Any,RightHand,LeftHand"/>
<Holdable slots="Any,RightHand,LeftHand">
<StatusEffect type="OnUse" target="Character" Health="10.0" disabledeltatime="true">
<RequiredItem name="Medical Syringe" type="Container"/>
</StatusEffect>
</Holdable>
</Item>
<Item
name="Auxiliorizine"
category="Material"
spritecolor="1.0,1.0,1.0,1.0"
spritecolor="1.0,1.0,0.0,1.0"
Tags="smallitem,chem"
pickdistance="150"
description="A highly potent corrigodone-based stimulant.">
@@ -185,12 +175,17 @@
<Body width="25" height="5" density="20"/>
<Holdable slots="Any,RightHand,LeftHand"/>
<Holdable slots="Any,RightHand,LeftHand">
<StatusEffect type="OnUse" target="Character" Health="20.0" Oxygen="100.0" disabledeltatime="true">
<RequiredItem name="Medical Syringe" type="Container"/>
</StatusEffect>
</Holdable>
</Item>
<Item
name="Chlorine"
category="Material"
spritecolor="1.0,1.0,1.0,1.0"
spritecolor="1.0,1.0,1.0,0.6"
Tags="smallitem,chem"
pickdistance="150">
@@ -198,21 +193,34 @@
<Body width="25" height="5" density="10"/>
<Holdable slots="Any,RightHand,LeftHand"/>
<Holdable slots="Any,RightHand,LeftHand">
<StatusEffect type="OnUse" target="Character" Health="-5.0" disabledeltatime="true">
<RequiredItem name="Medical Syringe" type="Container"/>
</StatusEffect>
</Holdable>
</Item>
<Item
name="Ethanol"
category="Material"
spritecolor="1.0,1.0,1.0,1.0"
spritecolor="0.0,0.9,0.1,1.0"
Tags="smallitem,chem"
canuseonself="true"
pickdistance="150">
<ItemComponent>
<StatusEffect type="OnUse" target="Character" Health="-2.0" disabledeltatime="true"/>
</ItemComponent>
<Sprite texture ="med.png" sourcerect="24,16,8,16" depth="0.6"/>
<Body width="25" height="5" density="10"/>
<Holdable slots="Any,RightHand,LeftHand"/>
<Holdable slots="Any,RightHand,LeftHand">
<StatusEffect type="OnUse" target="Character" Health="-5.0" disabledeltatime="true">
<RequiredItem name="Medical Syringe" type="Container"/>
</StatusEffect>
</Holdable>
</Item>
<Item
@@ -225,8 +233,12 @@
<Sprite texture ="med.png" sourcerect="24,16,8,16" depth="0.6"/>
<Body width="25" height="5" density="10"/>
<Holdable slots="Any,RightHand,LeftHand"/>
<Holdable slots="Any,RightHand,LeftHand">
<StatusEffect type="OnUse" target="Character" Health="-5.0" disabledeltatime="true">
<RequiredItem name="Medical Syringe" type="Container"/>
</StatusEffect>
</Holdable>
</Item>
<Item
@@ -239,17 +251,20 @@
<Sprite texture ="med.png" sourcerect="24,16,8,16" depth="0.6"/>
<Body width="25" height="5" density="10"/>
<Holdable slots="Any,RightHand,LeftHand"/>
<Holdable slots="Any,RightHand,LeftHand">
<StatusEffect type="OnUse" target="Character" Health="-5.0" disabledeltatime="true">
<RequiredItem name="Medical Syringe" type="Container"/>
</StatusEffect>
</Holdable>
</Item>
<Item
name="Flash Powder"
category="Material"
spritecolor="0.8,0.8,0.8,1.0"
spritecolor="0.1,0.1,0.1,1.0"
Tags="smallitem,chem,explosive"
pickdistance="150"
description="An analgesic which is highly effective at treating various types of physical trauma.">
pickdistance="150">
<Sprite texture ="med.png" sourcerect="24,16,8,16" depth="0.6"/>
@@ -260,17 +275,13 @@
<Explosion range="500" damage="5" stun="3" force="0.1"/>
</StatusEffect>
</Holdable>
<StatusEffect type="OnUse" target="This" Condition="-100.0" delay="3.0" sound="Content/Items/Weapons/stungrenade.ogg">
<Explosion range="500" damage="5" stun="25" force="0.1"/>
</StatusEffect>
</Item>
<Item
name="Chloral Hydrate"
category="Material"
spritecolor="1.0,1.0,1.0,1.0"
spritecolor="1.0,1.0,1.0,0.8"
Tags="smallitem,chem"
pickdistance="150">
@@ -278,7 +289,29 @@
<Body width="25" height="5" density="10"/>
<Holdable slots="Any,RightHand,LeftHand"/>
<Holdable slots="Any,RightHand,LeftHand">
<StatusEffect type="OnUse" target="Character" Health="-5.0" Stun="10" disabledeltatime="true">
<RequiredItem name="Medical Syringe" type="Container"/>
</StatusEffect>
</Holdable>
</Item>
<Item
name="Phosphorus"
category="Material"
spritecolor="0.5,0.0,0.0,1.0"
Tags="smallitem,chem"
pickdistance="150">
<Sprite texture ="med.png" sourcerect="24,16,8,16" depth="0.6"/>
<Body width="25" height="5" density="10"/>
<Holdable slots="Any,RightHand,LeftHand">
<StatusEffect type="OnUse" target="Character" Health="-5.0" disabledeltatime="true">
<RequiredItem name="Medical Syringe" type="Container"/>
</StatusEffect>
</Holdable>
</Item>
</Items>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

@@ -10,14 +10,16 @@
<Skill name="Weapons" level="50,60"/>
<Skill name="Construction" level="20,30"/>
<Skill name="Electrical Engineering" level="20,30"/>
<Skill name="Medical" level="10,30"/>
</Skills>
</Job>
<Job name="Engineer" description="Engineers have above-average construction and mechanic skills, but fixing complex mechanical devices is still usually out of their skill set. They are competent at fixing electrical devices however, and are the ones to turn to when the power grid starts failing." minnumber="1">
<Skills>
<Skill name="Weapons" level="10,30"/>
<Skill name="Construction" level="30,30"/>
<Skill name="Construction" level="20,30"/>
<Skill name="Electrical Engineering" level="50,60"/>
<Skill name="Medical" level="10,20"/>
</Skills>
<Item name="ID Card"/>
<Item name="Wrench"/>
@@ -30,6 +32,7 @@
<Skill name="Weapons" level="10,30"/>
<Skill name="Construction" level="50,60"/>
<Skill name="Electrical Engineering" level="30,35"/>
<Skill name="Medical" level="10,20"/>
</Skills>
<Item name="ID Card"/>
<Item name="Wrench"/>
@@ -40,6 +43,7 @@
<Job name="Security Officer" description="Security officers are are responsible for keeping the submarine safe from potential attackers. The creatures inhabiting the ocean aren't the only threat they need to worry about, as several of the renegade groups opposing the Europa Coalition are known to have sent infiltrators on board the vessels." maxnumber="2">
<Skills>
<Skill name="Weapons" level="50,60"/>
<Skill name="Medical" level="30,40"/>
<Skill name="Construction" level="10,20"/>
<Skill name="Electrical Engineering" level="10,20"/>
</Skills>
@@ -61,6 +65,8 @@
<Item name="ID Card"/>
<Item name="Doctor's Coat" equip="true"/>
<Item name="Doctor's Trousers" equip="true"/>
<Item name="Health Scanner HUD" equip="true"/>
<Item name="Medical Syringe"/>
</Job>
<Job name="Assistant" description="Assistants don't have any specific responsibilities or areas of expertise. This job is a good choice for newcomers who want to get a hang of working on board the submarine without taking up tasks that they aren't qualified for." allowalways="true">
@@ -68,6 +74,7 @@
<Skill name="Weapons" level="20,30"/>
<Skill name="Construction" level="20,30"/>
<Skill name="Electrical Engineering" level="20,30"/>
<Skill name="Medical" level="10,20"/>
</Skills>
<Item name="ID Card"/>
<Item name="Wrench"/>

View File

@@ -97,6 +97,8 @@ namespace Barotrauma
divingGearObjective = new AIObjectiveFindDivingGear(character, false);
}
if (divingGearObjective.IsCompleted()) return true;
divingGearObjective.TryComplete(deltaTime);
return divingGearObjective.IsCompleted();
}

View File

@@ -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);
}
}
}

View File

@@ -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)
{

View File

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

View 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;
}
}
}
}

View File

@@ -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;
}

View File

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