Lighting improvements: lightmap is drawn over all structures and blurred, flashlight item, OnContained statuseffects are also applied when the item is contained in a characterinventory

This commit is contained in:
Regalis
2016-05-07 09:13:23 +03:00
parent ef05650c01
commit d5f6fff2c2
14 changed files with 384 additions and 129 deletions
@@ -90,8 +90,9 @@ namespace Barotrauma.Items.Components
set
{
if (base.IsActive == value) return;
base.IsActive = value;
if (light == null) return;
light.Color = value ? lightColor : Color.Transparent;
if (!value) lightBrightness = 0.0f;
}
@@ -105,7 +106,7 @@ namespace Barotrauma.Items.Components
light.Position = item.Position;
light.CastShadows = castShadows;
IsActive = true;
IsActive = IsOn;
//foreach (XElement subElement in element.Elements())
//{
@@ -157,6 +158,8 @@ namespace Barotrauma.Items.Components
else
{
lightBrightness = MathHelper.Lerp(lightBrightness, Math.Min(voltage, 1.0f), 0.1f);
ApplyStatusEffects(ActionType.OnActive, deltaTime);
}
light.Color = lightColor * lightBrightness * (1.0f-Rand.Range(0.0f,Flicker));
@@ -165,6 +168,11 @@ namespace Barotrauma.Items.Components
voltage = 0.0f;
}
public override bool Use(float deltaTime, Character character = null)
{
return true;
}
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, bool editing = false)
{
if (light.LightSprite != null && (item.body == null || item.body.Enabled))
+1 -2
View File
@@ -673,7 +673,7 @@ namespace Barotrauma
}
ic.WasUsed = false;
if (Container != null) ic.ApplyStatusEffects(ActionType.OnContained, deltaTime);
if (parentInventory!=null) ic.ApplyStatusEffects(ActionType.OnContained, deltaTime);
if (!ic.IsActive) continue;
@@ -795,7 +795,6 @@ namespace Barotrauma
{
if (prefab.ResizeHorizontal || prefab.ResizeVertical)
{
prefab.sprite.DrawTiled(spriteBatch, new Vector2(DrawPosition.X-rect.Width/2, -(DrawPosition.Y+rect.Height/2)), new Vector2(rect.Width, rect.Height), color);
}
else