Option to configure alternate sprites for broken items
This commit is contained in:
@@ -1,11 +1,41 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class BrokenItemSprite
|
||||
{
|
||||
//sprite will be rendered if the condition of the item is below this
|
||||
public readonly float MaxCondition;
|
||||
public readonly Sprite Sprite;
|
||||
|
||||
public BrokenItemSprite(Sprite sprite, float maxCondition)
|
||||
{
|
||||
Sprite = sprite;
|
||||
MaxCondition = maxCondition;
|
||||
}
|
||||
}
|
||||
|
||||
partial class ItemPrefab : MapEntityPrefab
|
||||
{
|
||||
public List<BrokenItemSprite> BrokenSprites = new List<BrokenItemSprite>();
|
||||
|
||||
public Sprite GetActiveSprite(float condition)
|
||||
{
|
||||
Sprite activeSprite = sprite;
|
||||
foreach (BrokenItemSprite brokenSprite in BrokenSprites)
|
||||
{
|
||||
if (condition <= brokenSprite.MaxCondition)
|
||||
{
|
||||
activeSprite = brokenSprite.Sprite;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return activeSprite;
|
||||
}
|
||||
|
||||
public override void DrawPlacing(SpriteBatch spriteBatch, Camera cam)
|
||||
{
|
||||
Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
|
||||
@@ -40,9 +70,6 @@ namespace Barotrauma
|
||||
|
||||
if (sprite != null) sprite.DrawTiled(spriteBatch, new Vector2(position.X, -position.Y), placeSize, SpriteColor);
|
||||
}
|
||||
|
||||
//if (PlayerInput.GetMouseState.RightButton == ButtonState.Pressed) selected = null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user