Merge branch 'master' into animcontroller-overhaul

This commit is contained in:
Regalis
2016-10-19 21:15:44 +03:00
9 changed files with 116 additions and 29 deletions
@@ -1053,6 +1053,8 @@ namespace Barotrauma
private void UpdateNetPlayerPosition(float deltaTime) private void UpdateNetPlayerPosition(float deltaTime)
{ {
if (GameMain.NetworkMember == null) return;
if (character == GameMain.NetworkMember.Character) if (character == GameMain.NetworkMember.Character)
{ {
if (character.MemPos.Count < 2) return; if (character.MemPos.Count < 2) return;
+21 -7
View File
@@ -18,7 +18,7 @@ namespace Barotrauma
private static GUIProgressBar drowningBar, healthBar; private static GUIProgressBar drowningBar, healthBar;
private static float damageOverlayTimer; public static float damageOverlayTimer { get; private set; }
public static void Reset() public static void Reset()
{ {
@@ -49,9 +49,24 @@ namespace Barotrauma
if (!character.IsUnconscious && character.Stun <= 0.0f) if (!character.IsUnconscious && character.Stun <= 0.0f)
{ {
if (character.Inventory != null && !character.LockHands && character.Stun >= -0.1f)
if (character.Inventory != null)
{ {
character.Inventory.Update(deltaTime); if (!character.LockHands && character.Stun >= -0.1f)
{
character.Inventory.Update(deltaTime);
}
for (int i = 0; i < character.Inventory.Items.Length - 1; i++)
{
var item = character.Inventory.Items[i];
if (item == null || CharacterInventory.limbSlots[i] == InvSlotType.Any) continue;
foreach (ItemComponent ic in item.components)
{
if (ic.DrawHudWhenEquipped) ic.UpdateHUD(character);
}
}
} }
if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null) if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null)
@@ -80,12 +95,11 @@ namespace Barotrauma
if (character.Inventory != null) if (character.Inventory != null)
{ {
for (int i = 0; i< character.Inventory.Items.Length-1; i++) for (int i = 0; i < character.Inventory.Items.Length - 1; i++)
{ {
var item = character.Inventory.Items[i]; var item = character.Inventory.Items[i];
if (item == null || CharacterInventory.limbSlots[i]==InvSlotType.Any) continue; if (item == null || CharacterInventory.limbSlots[i] == InvSlotType.Any) continue;
//var statusHUD = item.GetComponent<StatusHUD>();
//if (statusHUD == null) continue;
foreach (ItemComponent ic in item.components) foreach (ItemComponent ic in item.components)
{ {
if (ic.DrawHudWhenEquipped) ic.DrawHUD(spriteBatch, character); if (ic.DrawHudWhenEquipped) ic.DrawHUD(spriteBatch, character);
+3 -4
View File
@@ -872,13 +872,12 @@ namespace Barotrauma
prefab.sprite.effects = oldEffects; prefab.sprite.effects = oldEffects;
for (int i = 0; i < drawableComponents.Count; i++ ) List<IDrawableComponent> staticDrawableComponents = new List<IDrawableComponent>(drawableComponents); //static list to compensate for drawable toggling
for (int i = 0; i < staticDrawableComponents.Count; i++)
{ {
drawableComponents[i].Draw(spriteBatch, editing); staticDrawableComponents[i].Draw(spriteBatch, editing);
} }
//foreach (ItemComponent component in components) component.Draw(spriteBatch, editing);
if (GameMain.DebugDraw && aiTarget!=null) aiTarget.Draw(spriteBatch); if (GameMain.DebugDraw && aiTarget!=null) aiTarget.Draw(spriteBatch);
if (!editing || (body != null && !body.Enabled)) if (!editing || (body != null && !body.Enabled))
@@ -419,9 +419,12 @@ namespace Barotrauma
for (int i = 0; i < triangles.Count; i++) for (int i = 0; i < triangles.Count; i++)
{ {
if (triangles[i][0].Y == triangles[i][1].Y && triangles[i][0].Y == triangles[i][2].Y) continue; //don't create a triangle if any of the vertices are too close to each other
if (triangles[i][0].X == triangles[i][1].X && triangles[i][0].X == triangles[i][2].X) continue; //(apparently Farseer doesn't like polygons with a very small area, see Shape.ComputeProperties)
if (Vector2.Distance(triangles[i][0], triangles[i][1]) < 0.05f ||
Vector2.Distance(triangles[i][0], triangles[i][2]) < 0.05f ||
Vector2.Distance(triangles[i][1], triangles[i][2]) < 0.05f) continue;
Vertices bodyVertices = new Vertices(triangles[i]); Vertices bodyVertices = new Vertices(triangles[i]);
FixtureFactory.AttachPolygon(bodyVertices, 5.0f, cellBody); FixtureFactory.AttachPolygon(bodyVertices, 5.0f, cellBody);
} }
+10 -4
View File
@@ -366,15 +366,15 @@ namespace Barotrauma.Lights
spriteBatch.End(); spriteBatch.End();
} }
public void DrawLOS(SpriteBatch spriteBatch, Effect effect) public void DrawLOS(SpriteBatch spriteBatch, Effect effect,bool renderingBackground)
{ {
if (!LosEnabled || ViewTarget == null) return; if (!LosEnabled || ViewTarget == null) return;
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.Multiplicative, null, null, null, effect); spriteBatch.Begin(SpriteSortMode.Deferred, renderingBackground ? CustomBlendStates.LOS : CustomBlendStates.Multiplicative, null, null, null, effect);
spriteBatch.Draw(losTexture, Vector2.Zero, Color.White); spriteBatch.Draw(losTexture, Vector2.Zero, Color.White);
spriteBatch.End(); spriteBatch.End();
ObstructVision = false; if (!renderingBackground) ObstructVision = false;
} }
public void ClearLights() public void ClearLights()
@@ -399,10 +399,16 @@ namespace Barotrauma.Lights
MultiplyWithAlpha = new BlendState(); MultiplyWithAlpha = new BlendState();
MultiplyWithAlpha.ColorDestinationBlend = MultiplyWithAlpha.AlphaDestinationBlend = Blend.One; MultiplyWithAlpha.ColorDestinationBlend = MultiplyWithAlpha.AlphaDestinationBlend = Blend.One;
MultiplyWithAlpha.ColorSourceBlend = MultiplyWithAlpha.AlphaSourceBlend = Blend.DestinationAlpha; MultiplyWithAlpha.ColorSourceBlend = MultiplyWithAlpha.AlphaSourceBlend = Blend.DestinationAlpha;
LOS = new BlendState();
LOS.ColorSourceBlend = LOS.AlphaSourceBlend = Blend.Zero;
LOS.ColorDestinationBlend = LOS.AlphaDestinationBlend = Blend.InverseSourceColor;
LOS.ColorBlendFunction = LOS.AlphaBlendFunction = BlendFunction.Add;
} }
public static BlendState Multiplicative { get; private set; } public static BlendState Multiplicative { get; private set; }
public static BlendState WriteToAlpha { get; private set; } public static BlendState WriteToAlpha { get; private set; }
public static BlendState MultiplyWithAlpha { get; private set; } public static BlendState MultiplyWithAlpha { get; private set; }
public static BlendState LOS { get; private set; }
} }
} }
+3 -3
View File
@@ -31,9 +31,9 @@ namespace Barotrauma
protected ConstructorInfo constructor; protected ConstructorInfo constructor;
//is it possible to stretch the entity horizontally/vertically //is it possible to stretch the entity horizontally/vertically
protected bool resizeHorizontal; public bool resizeHorizontal { get; protected set; }
protected bool resizeVertical; public bool resizeVertical { get; protected set; }
//which prefab has been selected for placing //which prefab has been selected for placing
protected static MapEntityPrefab selected; protected static MapEntityPrefab selected;
+10
View File
@@ -67,6 +67,16 @@ namespace Barotrauma
public SpriteEffects SpriteEffects = SpriteEffects.None; public SpriteEffects SpriteEffects = SpriteEffects.None;
public bool resizeHorizontal
{
get { return prefab.resizeHorizontal; }
}
public bool resizeVertical
{
get { return prefab.resizeVertical; }
}
private bool flippedX; private bool flippedX;
public override Sprite Sprite public override Sprite Sprite
+11 -3
View File
@@ -317,15 +317,23 @@ namespace Barotrauma
if (MapEntity.mapEntityList[i].DrawDamageEffect) if (MapEntity.mapEntityList[i].DrawDamageEffect)
MapEntity.mapEntityList[i].DrawDamage(spriteBatch, damageEffect); MapEntity.mapEntityList[i].DrawDamage(spriteBatch, damageEffect);
} }
damageEffect.Parameters["aCutoff"].SetValue(0.0f); if (damageEffect != null)
damageEffect.Parameters["cCutoff"].SetValue(0.0f); {
damageEffect.Parameters["aCutoff"].SetValue(0.0f);
damageEffect.Parameters["cCutoff"].SetValue(0.0f);
}
} }
public static void DrawBack(SpriteBatch spriteBatch, bool editing = false) public static void DrawBack(SpriteBatch spriteBatch, bool editing = false, Predicate<MapEntity> predicate = null)
{ {
for (int i = 0; i < MapEntity.mapEntityList.Count; i++) for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{ {
if (predicate != null)
{
if (!predicate(MapEntity.mapEntityList[i])) continue;
}
if (MapEntity.mapEntityList[i].DrawBelowWater) if (MapEntity.mapEntityList[i].DrawBelowWater)
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, true); MapEntity.mapEntityList[i].Draw(spriteBatch, editing, true);
} }
+50 -5
View File
@@ -12,6 +12,7 @@ namespace Barotrauma
{ {
Camera cam; Camera cam;
readonly RenderTarget2D renderTargetBackground;
readonly RenderTarget2D renderTarget; readonly RenderTarget2D renderTarget;
readonly RenderTarget2D renderTargetWater; readonly RenderTarget2D renderTargetWater;
readonly RenderTarget2D renderTargetAir; readonly RenderTarget2D renderTargetAir;
@@ -33,7 +34,8 @@ namespace Barotrauma
{ {
cam = new Camera(); cam = new Camera();
cam.Translate(new Vector2(-10.0f, 50.0f)); cam.Translate(new Vector2(-10.0f, 50.0f));
renderTargetBackground = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight); renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
renderTargetWater = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight); renderTargetWater = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
renderTargetAir = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight); renderTargetAir = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
@@ -223,7 +225,7 @@ namespace Barotrauma
//1. draw the background, characters and the parts of the submarine that are behind them //1. draw the background, characters and the parts of the submarine that are behind them
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
graphics.SetRenderTarget(renderTarget); graphics.SetRenderTarget(renderTargetBackground);
if (Level.Loaded == null) if (Level.Loaded == null)
{ {
@@ -239,7 +241,23 @@ namespace Barotrauma
null, null, null, null, null, null, null, null,
cam.Transform); cam.Transform);
Submarine.DrawBack(spriteBatch); Submarine.DrawBack(spriteBatch,false,s => s is Structure && ((s as Structure).resizeHorizontal || (s as Structure).resizeVertical));
spriteBatch.End();
graphics.SetRenderTarget(renderTarget);
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.Opaque);
spriteBatch.Draw(renderTargetBackground, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend,
null, null, null, null,
cam.Transform);
Submarine.DrawBack(spriteBatch, false, s => (!(s is Structure)) || (!(s as Structure).resizeHorizontal && !(s as Structure).resizeHorizontal));
foreach (Character c in Character.CharacterList) c.Draw(spriteBatch); foreach (Character c in Character.CharacterList) c.Draw(spriteBatch);
@@ -305,6 +323,25 @@ namespace Barotrauma
GameMain.ParticleManager.Draw(spriteBatch, false, Particles.ParticleBlendState.Additive); GameMain.ParticleManager.Draw(spriteBatch, false, Particles.ParticleBlendState.Additive);
spriteBatch.End(); spriteBatch.End();
if (Character.Controlled != null && GameMain.LightManager.LosEnabled)
{
graphics.SetRenderTarget(renderTarget);
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.Opaque, null, null, null, lightBlur.Effect);
spriteBatch.Draw(renderTargetBackground, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend, SamplerState.LinearWrap,
null, null, null,
cam.Transform);
Submarine.DrawDamageable(spriteBatch, null);
spriteBatch.End();
GameMain.LightManager.DrawLightMap(spriteBatch, lightBlur.Effect);
GameMain.LightManager.DrawLOS(spriteBatch, lightBlur.Effect, true);
}
graphics.SetRenderTarget(null); graphics.SetRenderTarget(null);
@@ -359,9 +396,17 @@ namespace Barotrauma
spriteBatch.End(); spriteBatch.End();
if (Character.Controlled != null) if (Character.Controlled != null && GameMain.LightManager.LosEnabled)
{ {
GameMain.LightManager.DrawLOS(spriteBatch, lightBlur.Effect); GameMain.LightManager.DrawLOS(spriteBatch, lightBlur.Effect,false);
spriteBatch.Begin(SpriteSortMode.Immediate,
BlendState.AlphaBlend);
float r = Math.Min(CharacterHUD.damageOverlayTimer * 0.5f, 0.5f);
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
Color.Lerp(new Color(0.1f, 0.1f, 0.1f), Color.Red, r));
spriteBatch.End();
} }
} }