Progress bars that show the health of wall sections when welding/cutting

This commit is contained in:
Regalis
2016-09-20 18:40:30 +03:00
parent f8368f464a
commit 5918e845ac
7 changed files with 140 additions and 41 deletions
@@ -7,7 +7,7 @@ using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
class Pickable : ItemComponent, IDrawableComponent
class Pickable : ItemComponent
{
protected Character picker;
@@ -125,6 +125,13 @@ namespace Barotrauma.Items.Components
yield return CoroutineStatus.Success;
}
picker.UpdateHUDProgressBar(
this,
item.WorldPosition,
pickTimer / requiredTime,
Color.Red, Color.Green);
picker.AnimController.Anim = AnimController.Animation.UsingConstruction;
picker.AnimController.TargetMovement = Vector2.Zero;
@@ -175,23 +182,7 @@ namespace Barotrauma.Items.Components
}
}
}
public void Draw(SpriteBatch spriteBatch, bool editing = false)
{
if (pickTimer <= 0.0f)
{
Drawable = false;
return;
}
float progressBarWidth = 100.0f;
GUI.DrawProgressBar(spriteBatch, item.DrawPosition + new Vector2(-progressBarWidth/2.0f, 50.0f), new Vector2(progressBarWidth, 15.0f),
pickTimer / PickingTime,
Color.Lerp(Color.Red, Color.Green, pickTimer / PickingTime));
}
public override void Drop(Character dropper)
{
if (picker == null)
@@ -182,7 +182,13 @@ namespace Barotrauma.Items.Components
int sectionIndex = targetStructure.FindSectionIndex(ConvertUnits.ToDisplayUnits(pickedPosition));
if (sectionIndex < 0) return;
targetStructure.HighLightSection(sectionIndex);
var progressBar = user.UpdateHUDProgressBar(
targetStructure,
targetStructure.SectionPosition(sectionIndex) + targetStructure.Submarine.DrawPosition,
1.0f - targetStructure.SectionDamage(sectionIndex) / targetStructure.Health,
Color.Red, Color.Green);
progressBar.Size = new Vector2(60.0f, 20.0f);
targetStructure.AddDamage(sectionIndex, -StructureFixAmount * degreeOfSuccess);
@@ -195,7 +201,7 @@ namespace Barotrauma.Items.Components
(sectionIndex == targetStructure.SectionCount - 2 && i == 1) ||
(nextSectionLength > 0 && nextSectionLength < Structure.wallSectionSize * 0.3f))
{
targetStructure.HighLightSection(sectionIndex + i);
//targetStructure.HighLightSection(sectionIndex + i);
targetStructure.AddDamage(sectionIndex + i, -StructureFixAmount * degreeOfSuccess);
}
}
@@ -213,7 +219,7 @@ namespace Barotrauma.Items.Components
ApplyStatusEffects(ActionType.OnUse, targetItem.AllPropertyObjects, deltaTime);
}
}
public override bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
{
Gap leak = objective.OperateTarget as Gap;
@@ -222,7 +228,7 @@ namespace Barotrauma.Items.Components
float dist = Vector2.Distance(leak.WorldPosition, item.WorldPosition);
//too far away -> consider this done and hope the AI is smart enough to move closer
if (dist > range*5.0f) return true;
if (dist > range * 5.0f) return true;
//steer closer if almost in range
if (dist > range)
@@ -240,8 +246,6 @@ namespace Barotrauma.Items.Components
//close enough -> stop moving
character.AIController.SteeringManager.Reset();
}
character.CursorPosition = leak.Position;
character.SetInput(InputType.Aim, false, true);