Small optimization: items have a list of components that have to be drawn
This commit is contained in:
@@ -7,7 +7,7 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
class Pickable : ItemComponent
|
||||
class Pickable : ItemComponent, IDrawableComponent
|
||||
{
|
||||
protected Character picker;
|
||||
|
||||
@@ -112,6 +112,7 @@ namespace Barotrauma.Items.Components
|
||||
var leftHand = picker.AnimController.GetLimb(LimbType.LeftHand);
|
||||
var rightHand = picker.AnimController.GetLimb(LimbType.RightHand);
|
||||
|
||||
Drawable = true;
|
||||
|
||||
pickTimer = 0.0f;
|
||||
while (pickTimer < requiredTime)
|
||||
@@ -150,8 +151,10 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private void StopPicking(Character picker)
|
||||
{
|
||||
Drawable = false;
|
||||
|
||||
picker.AnimController.Anim = AnimController.Animation.None;
|
||||
pickTimer = 0.0f;
|
||||
pickTimer = 0.0f;
|
||||
}
|
||||
|
||||
protected void DropConnectedWires(Character character)
|
||||
@@ -174,9 +177,13 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
{
|
||||
if (pickTimer <= 0.0f) return;
|
||||
if (pickTimer <= 0.0f)
|
||||
{
|
||||
Drawable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
float progressBarWidth = 100.0f;
|
||||
|
||||
|
||||
@@ -105,8 +105,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
//if (DoesUseFail(Character)) return false;
|
||||
|
||||
IsActive = true;
|
||||
|
||||
//targetPosition = targetPosition.X, -targetPosition.Y);
|
||||
|
||||
float degreeOfSuccess = DegreeOfSuccess(character)/100.0f;
|
||||
@@ -195,7 +193,6 @@ namespace Barotrauma.Items.Components
|
||||
if (character.IsKeyDown(InputType.Aim))
|
||||
{
|
||||
targetLimb.character.AddDamage(CauseOfDeath.Damage, -LimbFixAmount * degreeOfSuccess, character);
|
||||
//isActive = true;
|
||||
}
|
||||
}
|
||||
else if ((targetItem = (targetBody.UserData as Item)) != null)
|
||||
@@ -203,12 +200,12 @@ namespace Barotrauma.Items.Components
|
||||
targetItem.IsHighlighted = true;
|
||||
|
||||
ApplyStatusEffects(ActionType.OnUse, targetItem.AllPropertyObjects, deltaTime);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
GameMain.ParticleManager.CreateParticle(particles, item.WorldPosition + TransformedBarrelPos,
|
||||
-item.body.Rotation + ((item.body.Dir > 0.0f) ? 0.0f : MathHelper.Pi), ParticleSpeed);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -247,33 +244,6 @@ namespace Barotrauma.Items.Components
|
||||
Use(deltaTime, character);
|
||||
|
||||
return leak.Open <= 0.0f;
|
||||
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
{
|
||||
if (!IsActive) return;
|
||||
|
||||
//Vector2 particleSpeed = new Vector2(
|
||||
// (float)Math.Cos(item.body.Rotation),
|
||||
// (float)Math.Sin(item.body.Rotation)) *item.body.Dir * 0.1f;
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(particles))
|
||||
{
|
||||
GameMain.ParticleManager.CreateParticle(particles, item.WorldPosition+TransformedBarrelPos,
|
||||
-item.body.Rotation + ((item.body.Dir>0.0f) ? 0.0f : MathHelper.Pi), ParticleSpeed);
|
||||
}
|
||||
|
||||
//Vector2 startPos = ConvertUnits.ToDisplayUnits(item.body.Position);
|
||||
//Vector2 endPos = ConvertUnits.ToDisplayUnits(pickedPosition);
|
||||
//endPos = new Vector2(endPos.X + Game1.localRandom.Next(-2, 2), endPos.Y + Game1.localRandom.Next(-2, 2));
|
||||
|
||||
//GUI.DrawLine(spriteBatch, startPos, endPos, Color.Orange, 0.0f);
|
||||
|
||||
IsActive = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user