Merge branch 'walldamage'
This commit is contained in:
@@ -93,6 +93,8 @@ namespace Barotrauma
|
||||
protected Item closestItem;
|
||||
private Character closestCharacter, selectedCharacter;
|
||||
|
||||
private Dictionary<object, HUDProgressBar> hudProgressBars;
|
||||
|
||||
protected bool isDead;
|
||||
private CauseOfDeath lastAttackCauseOfDeath;
|
||||
private CauseOfDeath causeOfDeath;
|
||||
@@ -301,6 +303,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<object, HUDProgressBar> HUDProgressBars
|
||||
{
|
||||
get { return hudProgressBars; }
|
||||
}
|
||||
|
||||
public HuskInfection huskInfection;
|
||||
public float HuskInfectionState
|
||||
{
|
||||
@@ -498,6 +505,8 @@ namespace Barotrauma
|
||||
|
||||
selectedItems = new Item[2];
|
||||
|
||||
hudProgressBars = new Dictionary<object, HUDProgressBar>();
|
||||
|
||||
IsNetworkPlayer = isNetworkPlayer;
|
||||
|
||||
oxygen = 100.0f;
|
||||
@@ -516,8 +525,6 @@ namespace Barotrauma
|
||||
|
||||
XDocument doc = ToolBox.TryLoadXml(file);
|
||||
if (doc == null || doc.Root == null) return;
|
||||
|
||||
|
||||
|
||||
SpeciesName = ToolBox.GetAttributeString(doc.Root, "name", "Unknown");
|
||||
|
||||
@@ -1184,6 +1191,16 @@ namespace Barotrauma
|
||||
{
|
||||
Lights.LightManager.ViewTarget = this;
|
||||
CharacterHUD.Update(deltaTime, this);
|
||||
|
||||
foreach (HUDProgressBar progressBar in hudProgressBars.Values)
|
||||
{
|
||||
progressBar.Update(deltaTime);
|
||||
}
|
||||
|
||||
foreach (var pb in hudProgressBars.Where(pb => pb.Value.FadeTimer<=0.0f).ToList())
|
||||
{
|
||||
hudProgressBars.Remove(pb.Key);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsUnconscious)
|
||||
@@ -1277,10 +1294,6 @@ namespace Barotrauma
|
||||
if (!Enabled) return;
|
||||
|
||||
AnimController.Draw(spriteBatch);
|
||||
|
||||
//GUI.DrawLine(spriteBatch, ConvertUnits.ToDisplayUnits(animController.limbs[0].SimPosition.X, animController.limbs[0].SimPosition.Y),
|
||||
// ConvertUnits.ToDisplayUnits(animController.limbs[0].SimPosition.X, animController.limbs[0].SimPosition.Y) +
|
||||
// ConvertUnits.ToDisplayUnits(animController.targetMovement.X, animController.targetMovement.Y), Color.Green);
|
||||
}
|
||||
|
||||
public void DrawHUD(SpriteBatch spriteBatch, Camera cam)
|
||||
@@ -1292,9 +1305,6 @@ namespace Barotrauma
|
||||
{
|
||||
if (!Enabled) return;
|
||||
|
||||
Vector2 pos = DrawPosition;
|
||||
pos.Y = -pos.Y;
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
AnimController.DebugDraw(spriteBatch);
|
||||
@@ -1303,6 +1313,9 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
if (this == controlled) return;
|
||||
|
||||
Vector2 pos = DrawPosition;
|
||||
pos.Y = -pos.Y;
|
||||
|
||||
if (info != null)
|
||||
{
|
||||
@@ -1333,6 +1346,26 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a progress bar that's "linked" to the specified object (or updates an existing one if there's one already linked to the object)
|
||||
/// The progress bar will automatically fade out after 1 sec if the method hasn't been called during that time
|
||||
/// </summary>
|
||||
public HUDProgressBar UpdateHUDProgressBar(object linkedObject, Vector2 worldPosition, float progress, Color emptyColor, Color fullColor)
|
||||
{
|
||||
HUDProgressBar progressBar = null;
|
||||
if (!hudProgressBars.TryGetValue(linkedObject, out progressBar))
|
||||
{
|
||||
progressBar = new HUDProgressBar(worldPosition, Submarine, emptyColor, fullColor);
|
||||
hudProgressBars.Add(linkedObject, progressBar);
|
||||
}
|
||||
|
||||
progressBar.WorldPosition = worldPosition;
|
||||
progressBar.FadeTimer = Math.Max(progressBar.FadeTimer, 1.0f);
|
||||
progressBar.Progress = progress;
|
||||
|
||||
return progressBar;
|
||||
}
|
||||
|
||||
public void PlaySound(AIController.AiState state)
|
||||
{
|
||||
if (sounds == null || !sounds.Any()) return;
|
||||
|
||||
@@ -150,7 +150,12 @@ namespace Barotrauma
|
||||
|
||||
textPos.Y += 25;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (HUDProgressBar progressBar in character.HUDProgressBars.Values)
|
||||
{
|
||||
progressBar.Draw(spriteBatch, cam);
|
||||
}
|
||||
}
|
||||
|
||||
if (Screen.Selected == GameMain.EditMapScreen) return;
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class HUDProgressBar
|
||||
{
|
||||
private float progress;
|
||||
|
||||
public float Progress
|
||||
{
|
||||
get { return progress; }
|
||||
set { progress = MathHelper.Clamp(value, 0.0f, 1.0f); }
|
||||
}
|
||||
|
||||
public float FadeTimer;
|
||||
|
||||
private Color fullColor, emptyColor;
|
||||
|
||||
private Vector2 worldPosition;
|
||||
|
||||
public Vector2 WorldPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return worldPosition;
|
||||
}
|
||||
set
|
||||
{
|
||||
worldPosition = value;
|
||||
if (parentSub != null)
|
||||
{
|
||||
worldPosition -= parentSub.DrawPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 Size;
|
||||
|
||||
private Submarine parentSub;
|
||||
|
||||
public HUDProgressBar(Vector2 worldPosition, Submarine parentSubmarine = null)
|
||||
: this(worldPosition, parentSubmarine, Color.Red, Color.Green)
|
||||
{
|
||||
}
|
||||
|
||||
public HUDProgressBar(Vector2 worldPosition, Submarine parentSubmarine, Color emptyColor, Color fullColor)
|
||||
{
|
||||
this.emptyColor = emptyColor;
|
||||
this.fullColor = fullColor;
|
||||
|
||||
parentSub = parentSubmarine;
|
||||
|
||||
WorldPosition = worldPosition;
|
||||
|
||||
Size = new Vector2(100.0f, 20.0f);
|
||||
|
||||
FadeTimer = 1.0f;
|
||||
}
|
||||
|
||||
public void Update(float deltatime)
|
||||
{
|
||||
FadeTimer -= deltatime;
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, Camera cam)
|
||||
{
|
||||
float a = Math.Min(FadeTimer, 1.0f);
|
||||
|
||||
Vector2 pos = new Vector2(WorldPosition.X - Size.X / 2, WorldPosition.Y + Size.Y / 2);
|
||||
|
||||
if (parentSub != null)
|
||||
{
|
||||
pos += parentSub.DrawPosition;
|
||||
}
|
||||
|
||||
pos = cam.WorldToScreen(pos);
|
||||
|
||||
GUI.DrawProgressBar(spriteBatch,
|
||||
new Vector2(pos.X, -pos.Y),
|
||||
Size, progress,
|
||||
Color.Lerp(emptyColor, fullColor, progress) * a,
|
||||
Color.White * a * 0.8f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -273,12 +273,15 @@ namespace Barotrauma
|
||||
|
||||
public static void DrawProgressBar(SpriteBatch sb, Vector2 start, Vector2 size, float progress, Color clr, float depth = 0.0f)
|
||||
{
|
||||
//outlinecolor = "0.5, 0.57, 0.6, 1.0" >
|
||||
DrawProgressBar(sb, start, size, progress, clr, new Color(0.5f, 0.57f, 0.6f, 1.0f), depth);
|
||||
}
|
||||
|
||||
DrawRectangle(sb, new Vector2(start.X, -start.Y), size, new Color(0.5f, 0.57f, 0.6f, 1.0f), false, depth);
|
||||
public static void DrawProgressBar(SpriteBatch sb, Vector2 start, Vector2 size, float progress, Color clr, Color outlineColor, float depth = 0.0f)
|
||||
{
|
||||
DrawRectangle(sb, new Vector2(start.X, -start.Y), size, outlineColor, false, depth);
|
||||
|
||||
int padding = 2;
|
||||
DrawRectangle(sb, new Rectangle((int)start.X + padding, -(int)(start.Y - padding), (int)((size.X - padding * 2)*progress), (int)size.Y - padding * 2),
|
||||
DrawRectangle(sb, new Rectangle((int)start.X + padding, -(int)(start.Y - padding), (int)((size.X - padding * 2) * progress), (int)size.Y - padding * 2),
|
||||
clr, true, depth);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -178,11 +178,24 @@ namespace Barotrauma.Items.Components
|
||||
if ((targetStructure = (targetBody.UserData as Structure)) != null)
|
||||
{
|
||||
if (!fixableEntities.Contains(targetStructure.Name)) return;
|
||||
if (targetStructure.IsPlatform) return;
|
||||
|
||||
int sectionIndex = targetStructure.FindSectionIndex(ConvertUnits.ToDisplayUnits(pickedPosition));
|
||||
if (sectionIndex < 0) return;
|
||||
|
||||
targetStructure.HighLightSection(sectionIndex);
|
||||
Vector2 progressBarPos = targetStructure.SectionPosition(sectionIndex);
|
||||
if (targetStructure.Submarine != null)
|
||||
{
|
||||
progressBarPos += targetStructure.Submarine.DrawPosition;
|
||||
}
|
||||
|
||||
var progressBar = user.UpdateHUDProgressBar(
|
||||
targetStructure,
|
||||
progressBarPos,
|
||||
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,12 +208,10 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if ((targetLimb = (targetBody.UserData as Limb)) != null)
|
||||
{
|
||||
@@ -213,7 +224,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 +233,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 +251,6 @@ namespace Barotrauma.Items.Components
|
||||
//close enough -> stop moving
|
||||
character.AIController.SteeringManager.Reset();
|
||||
}
|
||||
|
||||
|
||||
|
||||
character.CursorPosition = leak.Position;
|
||||
character.SetInput(InputType.Aim, false, true);
|
||||
|
||||
@@ -163,6 +163,8 @@ namespace Barotrauma
|
||||
hulls[1] = temp;
|
||||
}
|
||||
|
||||
flowTargetHull = hulls[0];
|
||||
|
||||
for (int i = 0 ; i <2; i++)
|
||||
{
|
||||
if (hulls[i]==null) continue;
|
||||
|
||||
@@ -86,6 +86,30 @@ namespace Barotrauma
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public virtual bool DrawBelowWater
|
||||
{
|
||||
get
|
||||
{
|
||||
return Sprite != null && Sprite.Depth > 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool DrawOverWater
|
||||
{
|
||||
get
|
||||
{
|
||||
return !DrawBelowWater;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool DrawDamageEffect
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsLinkable
|
||||
{
|
||||
@@ -203,6 +227,8 @@ namespace Barotrauma
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch, bool editing, bool back=true) {}
|
||||
|
||||
public virtual void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect) {}
|
||||
|
||||
public override void Remove()
|
||||
{
|
||||
base.Remove();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using FarseerPhysics;
|
||||
@@ -21,11 +20,10 @@ namespace Barotrauma
|
||||
public float damage;
|
||||
public Gap gap;
|
||||
|
||||
public int GapIndex;
|
||||
public int GapID;
|
||||
|
||||
public float lastSentDamage;
|
||||
|
||||
public bool isHighLighted;
|
||||
public ConvexHull hull;
|
||||
|
||||
public WallSection(Rectangle rect)
|
||||
@@ -43,7 +41,7 @@ namespace Barotrauma
|
||||
|
||||
class Structure : MapEntity, IDamageable
|
||||
{
|
||||
public static int wallSectionSize = 100;
|
||||
public static int wallSectionSize = 96;
|
||||
public static List<Structure> WallList = new List<Structure>();
|
||||
|
||||
List<ConvexHull> convexHulls;
|
||||
@@ -105,6 +103,30 @@ namespace Barotrauma
|
||||
get { return prefab.MaxHealth; }
|
||||
}
|
||||
|
||||
public override bool DrawBelowWater
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.DrawBelowWater || prefab.BackgroundSprite != null;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool DrawOverWater
|
||||
{
|
||||
get
|
||||
{
|
||||
return !DrawDamageEffect;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool DrawDamageEffect
|
||||
{
|
||||
get
|
||||
{
|
||||
return prefab.HasBody;
|
||||
}
|
||||
}
|
||||
|
||||
public override Rectangle Rect
|
||||
{
|
||||
get
|
||||
@@ -373,6 +395,20 @@ namespace Barotrauma
|
||||
{
|
||||
if (prefab.sprite == null) return;
|
||||
|
||||
Draw(spriteBatch, editing, back, null);
|
||||
}
|
||||
|
||||
public override void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect)
|
||||
{
|
||||
Draw(spriteBatch, false, false, damageEffect);
|
||||
}
|
||||
|
||||
private static float prevCutoff;
|
||||
|
||||
private void Draw(SpriteBatch spriteBatch, bool editing, bool back = true, Effect damageEffect = null)
|
||||
{
|
||||
if (prefab.sprite == null) return;
|
||||
|
||||
Color color = (isHighlighted) ? Color.Orange : Color.White;
|
||||
if (isSelected && editing)
|
||||
{
|
||||
@@ -382,51 +418,46 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Vector2 drawOffset = Submarine == null ? Vector2.Zero : Submarine.DrawPosition;
|
||||
if(sections.Length == 1)
|
||||
prefab.sprite.DrawTiled(spriteBatch, new Vector2(rect.X + drawOffset.X, -(rect.Y + drawOffset.Y)), new Vector2(rect.Width, rect.Height), Vector2.Zero, color,Point.Zero);
|
||||
|
||||
foreach (WallSection s in sections)
|
||||
if (back && damageEffect == null)
|
||||
{
|
||||
Point offset = new Point(Math.Abs(rect.Location.X - s.rect.Location.X), Math.Abs(rect.Location.Y - s.rect.Location.Y));
|
||||
if (sections.Length != 1 && s.damage < prefab.MaxHealth)
|
||||
prefab.sprite.DrawTiled(spriteBatch, new Vector2(s.rect.X + drawOffset.X, -(s.rect.Y + drawOffset.Y)), new Vector2(s.rect.Width, s.rect.Height), Vector2.Zero, color, offset);
|
||||
|
||||
if (s.isHighLighted)
|
||||
if (prefab.BackgroundSprite != null)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(s.rect.X + drawOffset.X, -(s.rect.Y + drawOffset.Y)), new Vector2(s.rect.Width, s.rect.Height),
|
||||
new Color((s.damage / prefab.MaxHealth), 1.0f - (s.damage / prefab.MaxHealth), 0.0f, 1.0f), true);
|
||||
prefab.BackgroundSprite.DrawTiled(
|
||||
spriteBatch,
|
||||
new Vector2(rect.X + drawOffset.X, -(rect.Y + drawOffset.Y)),
|
||||
new Vector2(rect.Width, rect.Height),
|
||||
Vector2.Zero, color, Point.Zero);
|
||||
}
|
||||
|
||||
s.isHighLighted = false;
|
||||
|
||||
if (s.damage < 0.01f) continue;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(s.rect.X + drawOffset.X, -(s.rect.Y + drawOffset.Y)), new Vector2(s.rect.Width, s.rect.Height),
|
||||
Color.Black * (s.damage / prefab.MaxHealth), true);
|
||||
}
|
||||
/*
|
||||
if(_convexHulls == null) return;
|
||||
var rand = new Random(32434324);
|
||||
foreach (var hull in _convexHulls)
|
||||
|
||||
if (back == prefab.sprite.Depth > 0.5f || editing)
|
||||
{
|
||||
if (sections.Count(x => x.hull == hull) <= 1)
|
||||
continue;
|
||||
var col = new Color((int) (255 * rand.NextDouble()), (int)(255 * rand.NextDouble()), (int)(255 * rand.NextDouble()), 255);
|
||||
GUI.DrawRectangle(spriteBatch,new Vector2 (hull.BoundingBox.X + drawOffset.X, -(hull.BoundingBox.Y + drawOffset.Y)), new Vector2(hull.BoundingBox.Width, hull.BoundingBox.Height),col,true );
|
||||
}*/
|
||||
foreach (WallSection s in sections)
|
||||
{
|
||||
if (damageEffect != null)
|
||||
{
|
||||
float newCutoff = Math.Min((s.damage / prefab.MaxHealth), 0.65f);
|
||||
|
||||
if (Math.Abs(newCutoff - prevCutoff) > 0.01f)
|
||||
{
|
||||
damageEffect.Parameters["aCutoff"].SetValue(newCutoff);
|
||||
damageEffect.Parameters["cCutoff"].SetValue(newCutoff*1.2f);
|
||||
|
||||
damageEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
prevCutoff = newCutoff;
|
||||
}
|
||||
}
|
||||
|
||||
Point offset = new Point(Math.Abs(rect.Location.X - s.rect.Location.X), Math.Abs(rect.Location.Y - s.rect.Location.Y));
|
||||
prefab.sprite.DrawTiled(spriteBatch, new Vector2(s.rect.X + drawOffset.X, -(s.rect.Y + drawOffset.Y)), new Vector2(s.rect.Width, s.rect.Height), Vector2.Zero, color, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool OnWallCollision(Fixture f1, Fixture f2, Contact contact)
|
||||
{
|
||||
//Structure structure = f1.Body.UserData as Structure;
|
||||
|
||||
//if (f2.Body.UserData as Item != null)
|
||||
//{
|
||||
// if (prefab.IsPlatform || prefab.StairDirection != Direction.None) return false;
|
||||
//}
|
||||
|
||||
if (prefab.IsPlatform)
|
||||
{
|
||||
Limb limb;
|
||||
@@ -468,9 +499,12 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
public void HighLightSection(int sectionIndex)
|
||||
public WallSection GetSection(int sectionIndex)
|
||||
{
|
||||
sections[sectionIndex].isHighLighted = true;
|
||||
if (sectionIndex < 0 || sectionIndex >= sections.Length) return null;
|
||||
|
||||
return sections[sectionIndex];
|
||||
|
||||
}
|
||||
|
||||
public bool SectionBodyDisabled(int sectionIndex)
|
||||
@@ -503,8 +537,24 @@ namespace Barotrauma
|
||||
|
||||
if (sectionIndex < 0 || sectionIndex > sections.Length - 1) return;
|
||||
|
||||
if (GameMain.Client == null) SetDamage(sectionIndex, sections[sectionIndex].damage + damage);
|
||||
var section = sections[sectionIndex];
|
||||
|
||||
int particleAmount = (int)(Math.Min(Health - section.damage, damage) * Rand.Range(0.01f, 1.0f));
|
||||
|
||||
particleAmount = Math.Min(particleAmount, 200);
|
||||
for (int i = 0; i < particleAmount; i++)
|
||||
{
|
||||
Vector2 particlePos = new Vector2(
|
||||
Rand.Range(section.rect.X, section.rect.Right),
|
||||
Rand.Range(section.rect.Y - section.rect.Height, section.rect.Y));
|
||||
|
||||
if (Submarine != null) particlePos += Submarine.DrawPosition;
|
||||
|
||||
var particle = GameMain.ParticleManager.CreateParticle("shrapnel", particlePos, Rand.Vector(Rand.Range(1.0f, 50.0f)));
|
||||
if (particle == null) break;
|
||||
}
|
||||
|
||||
if (GameMain.Client == null) SetDamage(sectionIndex, section.damage + damage);
|
||||
}
|
||||
|
||||
public int FindSectionIndex(Vector2 displayPos)
|
||||
@@ -763,7 +813,7 @@ namespace Barotrauma
|
||||
s.sections[index].damage =
|
||||
ToolBox.GetAttributeFloat(subElement, "damage", 0.0f);
|
||||
|
||||
s.sections[index].GapIndex = ToolBox.GetAttributeInt(subElement, "gap", -1);
|
||||
s.sections[index].GapID = ToolBox.GetAttributeInt(subElement, "gap", -1);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -774,9 +824,9 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (WallSection s in sections)
|
||||
{
|
||||
if (s.GapIndex == -1) continue;
|
||||
if (s.GapID == -1) continue;
|
||||
|
||||
s.gap = FindEntityByID((ushort)s.GapIndex) as Gap;
|
||||
s.gap = FindEntityByID((ushort)s.GapID) as Gap;
|
||||
if (s.gap != null) s.gap.ConnectedWall = this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,12 @@ namespace Barotrauma
|
||||
{
|
||||
get { return size; }
|
||||
}
|
||||
|
||||
public Sprite BackgroundSprite
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public static void LoadAll(List<string> filePaths)
|
||||
{
|
||||
@@ -74,22 +80,45 @@ namespace Barotrauma
|
||||
StructurePrefab sp = new StructurePrefab();
|
||||
sp.name = element.Name.ToString();
|
||||
|
||||
Vector4 sourceVector = ToolBox.GetAttributeVector4(element, "sourcerect", new Vector4(0,0,1,1));
|
||||
//Vector4 sourceVector = ToolBox.GetAttributeVector4(element, "sourcerect", new Vector4(0,0,1,1));
|
||||
|
||||
Rectangle sourceRect = new Rectangle(
|
||||
(int)sourceVector.X,
|
||||
(int)sourceVector.Y,
|
||||
(int)sourceVector.Z,
|
||||
(int)sourceVector.W);
|
||||
//Rectangle sourceRect = new Rectangle(
|
||||
// (int)sourceVector.X,
|
||||
// (int)sourceVector.Y,
|
||||
// (int)sourceVector.Z,
|
||||
// (int)sourceVector.W);
|
||||
|
||||
if (element.Attribute("sprite") != null)
|
||||
{
|
||||
sp.sprite = new Sprite(element.Attribute("sprite").Value, sourceRect, Vector2.Zero);
|
||||
//if (element.Attribute("sprite") != null)
|
||||
//{
|
||||
// sp.sprite = new Sprite(element.Attribute("sprite").Value, sourceRect, Vector2.Zero);
|
||||
|
||||
sp.sprite.Depth = ToolBox.GetAttributeFloat(element, "depth", 0.0f);
|
||||
// sp.sprite.Depth = ToolBox.GetAttributeFloat(element, "depth", 0.0f);
|
||||
|
||||
if (ToolBox.GetAttributeBool(element, "fliphorizontal", false)) sp.sprite.effects = SpriteEffects.FlipHorizontally;
|
||||
if (ToolBox.GetAttributeBool(element, "flipvertical", false)) sp.sprite.effects = SpriteEffects.FlipVertically;
|
||||
//}
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString())
|
||||
{
|
||||
case "sprite":
|
||||
sp.sprite = new Sprite(subElement);
|
||||
|
||||
if (ToolBox.GetAttributeBool(subElement, "fliphorizontal", false))
|
||||
sp.sprite.effects = SpriteEffects.FlipHorizontally;
|
||||
if (ToolBox.GetAttributeBool(subElement, "flipvertical", false))
|
||||
sp.sprite.effects = SpriteEffects.FlipVertically;
|
||||
|
||||
break;
|
||||
case "backgroundsprite":
|
||||
sp.BackgroundSprite = new Sprite(subElement);
|
||||
|
||||
if (ToolBox.GetAttributeBool(subElement, "fliphorizontal", false))
|
||||
sp.BackgroundSprite.effects = SpriteEffects.FlipHorizontally;
|
||||
if (ToolBox.GetAttributeBool(subElement, "flipvertical", false))
|
||||
sp.BackgroundSprite.effects = SpriteEffects.FlipVertically;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MapEntityCategory category;
|
||||
@@ -119,8 +148,7 @@ namespace Barotrauma
|
||||
sp.stairDirection = (Direction)Enum.Parse(typeof(Direction), ToolBox.GetAttributeString(element, "stairdirection", "None"), true);
|
||||
|
||||
sp.castShadow = ToolBox.GetAttributeBool(element, "castshadow", false);
|
||||
|
||||
|
||||
|
||||
sp.hasBody = ToolBox.GetAttributeBool(element, "body", false);
|
||||
|
||||
return sp;
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace Barotrauma
|
||||
{
|
||||
get
|
||||
{
|
||||
return subBody.Position;
|
||||
return subBody ==null ? Vector2.Zero : subBody.Position;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,16 +287,28 @@ namespace Barotrauma
|
||||
{
|
||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
||||
{
|
||||
if (MapEntity.mapEntityList[i].Sprite == null || MapEntity.mapEntityList[i].Sprite.Depth < 0.5f)
|
||||
if (MapEntity.mapEntityList[i].DrawOverWater)
|
||||
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawDamageable(SpriteBatch spriteBatch, Effect damageEffect, bool editing = false)
|
||||
{
|
||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
||||
{
|
||||
if (MapEntity.mapEntityList[i].DrawDamageEffect)
|
||||
MapEntity.mapEntityList[i].DrawDamage(spriteBatch, damageEffect);
|
||||
}
|
||||
damageEffect.Parameters["aCutoff"].SetValue(0.0f);
|
||||
damageEffect.Parameters["cCutoff"].SetValue(0.0f);
|
||||
}
|
||||
|
||||
|
||||
public static void DrawBack(SpriteBatch spriteBatch, bool editing = false)
|
||||
{
|
||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
||||
{
|
||||
if (MapEntity.mapEntityList[i].Sprite == null || MapEntity.mapEntityList[i].Sprite.Depth >= 0.5f)
|
||||
if (MapEntity.mapEntityList[i].DrawBelowWater)
|
||||
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,6 +444,18 @@ namespace Barotrauma
|
||||
float wallImpact = Vector2.Dot(Velocity, -collisionNormal);
|
||||
|
||||
ApplyImpact(wallImpact, -collisionNormal, contact);
|
||||
|
||||
Vector2 n;
|
||||
FixedArray2<Vector2> particlePos;
|
||||
contact.GetWorldManifold(out n, out particlePos);
|
||||
|
||||
int particleAmount = (int)(wallImpact*10.0f);
|
||||
for (int i = 0; i < particleAmount; i++)
|
||||
{
|
||||
var particle = GameMain.ParticleManager.CreateParticle("iceshards",
|
||||
ConvertUnits.ToDisplayUnits(particlePos[0]) + Rand.Vector(Rand.Range(1.0f, 50.0f)),
|
||||
Rand.Vector(Rand.Range(50.0f,500.0f)) + Velocity);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,9 +37,8 @@ namespace Barotrauma.Particles
|
||||
private Vector2 velocityChange;
|
||||
|
||||
private Vector2 drawPosition;
|
||||
|
||||
//private float checkCollisionTimer;
|
||||
|
||||
private float drawRotation;
|
||||
|
||||
private Hull currentHull;
|
||||
|
||||
private List<Gap> hullGaps;
|
||||
@@ -65,35 +64,33 @@ namespace Barotrauma.Particles
|
||||
get { return velocityChange; }
|
||||
set { velocityChange = value; }
|
||||
}
|
||||
|
||||
public Vector2 Velocity
|
||||
{
|
||||
get { return velocity; }
|
||||
set { velocity = value; }
|
||||
}
|
||||
|
||||
public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation, Hull hullGuess = null)
|
||||
{
|
||||
|
||||
this.prefab = prefab;
|
||||
|
||||
spriteIndex = Rand.Int(prefab.Sprites.Count);
|
||||
|
||||
currentHull = Hull.FindHull(position, hullGuess);
|
||||
//if (currentHull != null && currentHull.Submarine != null)
|
||||
//{
|
||||
// Vector2 subVel = ConvertUnits.ToDisplayUnits(currentHull.Submarine.Velocity);
|
||||
// //subVel.Y = -subVel.Y;
|
||||
// speed += subVel;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// int a = 1;
|
||||
//}
|
||||
//if (currentHull == null) position = Submarine.Loaded == null ? position : position + Submarine.Loaded.Position;
|
||||
|
||||
this.position = position;
|
||||
prevPosition = position;
|
||||
|
||||
|
||||
drawPosition = position;
|
||||
|
||||
|
||||
velocity = MathUtils.IsValid(speed) ? speed : Vector2.Zero;
|
||||
|
||||
if (currentHull != null && currentHull.Submarine != null)
|
||||
{
|
||||
velocity += ConvertUnits.ToDisplayUnits(currentHull.Submarine.Velocity);
|
||||
}
|
||||
|
||||
this.rotation = rotation + Rand.Range(prefab.StartRotationMin, prefab.StartRotationMax);
|
||||
prevRotation = rotation;
|
||||
|
||||
@@ -106,7 +103,7 @@ namespace Barotrauma.Particles
|
||||
|
||||
sizeChange = prefab.SizeChangeMin + (prefab.SizeChangeMax - prefab.SizeChangeMin) * Rand.Range(0.0f, 1.0f);
|
||||
|
||||
color = prefab.StartColor;
|
||||
color = new Color(prefab.StartColor, 1.0f);
|
||||
alpha = prefab.StartAlpha;
|
||||
|
||||
velocityChange = prefab.VelocityChange;
|
||||
@@ -116,8 +113,6 @@ namespace Barotrauma.Particles
|
||||
if (prefab.DeleteOnCollision || prefab.CollidesWithWalls)
|
||||
{
|
||||
hullGaps = currentHull == null ? new List<Gap>() : currentHull.ConnectedGaps;
|
||||
//hullLimits = new List<Hull>();
|
||||
//hullLimits = FindLimits(position);
|
||||
}
|
||||
|
||||
if (prefab.RotateToDirection)
|
||||
@@ -128,26 +123,14 @@ namespace Barotrauma.Particles
|
||||
}
|
||||
}
|
||||
|
||||
//private List<Hull> FindLimits(Vector2 position)
|
||||
//{
|
||||
// List<Hull> hullList = new List<Hull>();
|
||||
|
||||
// currentHull = Hull.FindHull(position);
|
||||
// if (currentHull == null) return hullList;
|
||||
|
||||
// hullList.Add(currentHull);
|
||||
|
||||
// return FindAdjacentHulls(hullList, currentHull, Math.Abs(velocity.X) > Math.Abs(velocity.Y));
|
||||
//}
|
||||
|
||||
public bool Update(float deltaTime)
|
||||
{
|
||||
|
||||
Vector2 subVel = currentHull ==null || currentHull.Submarine==null ? Vector2.Zero : ConvertUnits.ToDisplayUnits(currentHull.Submarine.Velocity);
|
||||
prevPosition = position;
|
||||
prevRotation = rotation;
|
||||
|
||||
//over 3 times faster than position += velocity * deltatime
|
||||
position.X += (velocity.X+subVel.X) * deltaTime;
|
||||
position.Y += (velocity.Y+subVel.Y) * deltaTime;
|
||||
position.X += velocity.X * deltaTime;
|
||||
position.Y += velocity.Y * deltaTime;
|
||||
|
||||
if (prefab.RotateToDirection)
|
||||
{
|
||||
@@ -161,6 +144,16 @@ namespace Barotrauma.Particles
|
||||
rotation += angularVelocity * deltaTime;
|
||||
}
|
||||
|
||||
if (prefab.WaterDrag > 0.0f &&
|
||||
(currentHull == null || (currentHull.Submarine != null && position.Y - currentHull.Submarine.DrawPosition.Y < currentHull.Surface)))
|
||||
{
|
||||
ApplyDrag(prefab.WaterDrag, deltaTime);
|
||||
}
|
||||
else if (prefab.Drag > 0.0f)
|
||||
{
|
||||
ApplyDrag(prefab.Drag, deltaTime);
|
||||
}
|
||||
|
||||
velocity.X += velocityChange.X * deltaTime;
|
||||
velocity.Y += velocityChange.Y * deltaTime;
|
||||
|
||||
@@ -174,11 +167,21 @@ namespace Barotrauma.Particles
|
||||
color.G / 255.0f + prefab.ColorChange.Y * deltaTime,
|
||||
color.B / 255.0f + prefab.ColorChange.Z * deltaTime);
|
||||
|
||||
if ((prefab.DeleteOnCollision || prefab.CollidesWithWalls) && currentHull!=null)
|
||||
if (prefab.DeleteOnCollision || prefab.CollidesWithWalls)
|
||||
{
|
||||
Vector2 edgePos = position + prefab.CollisionRadius * Vector2.Normalize(velocity) * size.X;
|
||||
|
||||
if (!Submarine.RectContains(currentHull.WorldRect, edgePos))
|
||||
|
||||
if (currentHull == null)
|
||||
{
|
||||
Hull collidedHull = Hull.FindHull(position);
|
||||
if (collidedHull != null)
|
||||
{
|
||||
if (prefab.DeleteOnCollision) return false;
|
||||
OnWallCollisionOutside(collidedHull);
|
||||
}
|
||||
|
||||
}
|
||||
else if (!Submarine.RectContains(currentHull.WorldRect, edgePos))
|
||||
{
|
||||
if (prefab.DeleteOnCollision) return false;
|
||||
|
||||
@@ -196,15 +199,13 @@ namespace Barotrauma.Particles
|
||||
if (Math.Sign(velocity.X) != Math.Sign(gap.WorldRect.Center.X - currentHull.WorldRect.Center.X)) continue;
|
||||
}
|
||||
|
||||
//Rectangle enlargedRect = new Rectangle(gap.Rect.X - 10, gap.Rect.Y + 10, gap.Rect.Width + 20, gap.Rect.Height + 20);
|
||||
//if (!Submarine.RectContains(enlargedRect, position)) continue;
|
||||
gapFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!gapFound)
|
||||
{
|
||||
|
||||
OnWallCollision(currentHull, edgePos);
|
||||
OnWallCollisionInside(currentHull, edgePos);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -212,21 +213,8 @@ namespace Barotrauma.Particles
|
||||
hullGaps = currentHull == null ? new List<Gap>() : currentHull.ConnectedGaps;
|
||||
|
||||
if (OnChangeHull != null) OnChangeHull(edgePos, currentHull);
|
||||
|
||||
}
|
||||
|
||||
//Hull prevHull = Hull.FindHull(prevPosition, hullLimits, currentHull);
|
||||
|
||||
//if (prevHull == null) return false;
|
||||
|
||||
}
|
||||
|
||||
//if (position.Y < currentHull.Rect.Y-currentHull.Rect.Height)
|
||||
//{
|
||||
// position.Y = currentHull.Rect.Y - currentHull.Rect.Height;
|
||||
// velocity.Y *= -0.2f;
|
||||
//}
|
||||
//if (!Submarine.RectContains(currentHull.Rect, position)) return false;
|
||||
}
|
||||
|
||||
lifeTime -= deltaTime;
|
||||
@@ -236,58 +224,104 @@ namespace Barotrauma.Particles
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnWallCollision(Hull prevHull, Vector2 position)
|
||||
private void ApplyDrag(float dragCoefficient, float deltaTime)
|
||||
{
|
||||
if (velocity == Vector2.Zero) return;
|
||||
|
||||
float speed = velocity.Length();
|
||||
velocity -= (velocity / speed) * Math.Min(speed * speed * prefab.WaterDrag * deltaTime, 1.0f);
|
||||
}
|
||||
|
||||
private void OnWallCollisionInside(Hull prevHull, Vector2 position)
|
||||
{
|
||||
Rectangle prevHullRect = prevHull.WorldRect;
|
||||
|
||||
Vector2 subVel = ConvertUnits.ToDisplayUnits(prevHull.Submarine.Velocity);
|
||||
|
||||
velocity -= subVel;
|
||||
|
||||
if (position.Y < prevHullRect.Y - prevHullRect.Height)
|
||||
{
|
||||
position.Y = prevHullRect.Y - prevHullRect.Height + 1.0f;
|
||||
position.Y = prevHullRect.Y - prevHullRect.Height + prefab.CollisionRadius;
|
||||
velocity.Y = -velocity.Y;
|
||||
}
|
||||
else if (position.Y > prevHullRect.Y)
|
||||
{
|
||||
position.Y = prevHullRect.Y - 1.0f;
|
||||
position.Y = prevHullRect.Y - prefab.CollisionRadius;
|
||||
velocity.X = Math.Abs(velocity.Y) * Math.Sign(velocity.X);
|
||||
velocity.Y = -velocity.Y * 0.1f;
|
||||
}
|
||||
|
||||
if (position.X < prevHullRect.X)
|
||||
{
|
||||
position.X = prevHullRect.X + 1.0f;
|
||||
position.X = prevHullRect.X + prefab.CollisionRadius;
|
||||
velocity.X = -velocity.X;
|
||||
}
|
||||
else if (position.X > prevHullRect.X + prevHullRect.Width)
|
||||
{
|
||||
position.X = prevHullRect.X + prevHullRect.Width - 1.0f;
|
||||
position.X = prevHullRect.X + prevHullRect.Width - prefab.CollisionRadius;
|
||||
velocity.X = -velocity.X;
|
||||
}
|
||||
|
||||
velocity *= prefab.Restitution;
|
||||
|
||||
velocity += subVel;
|
||||
}
|
||||
|
||||
|
||||
private void OnWallCollisionOutside(Hull collisionHull)
|
||||
{
|
||||
Rectangle hullRect = collisionHull.WorldRect;
|
||||
|
||||
if (position.Y < hullRect.Y - hullRect.Height)
|
||||
{
|
||||
position.Y = hullRect.Y - hullRect.Height - prefab.CollisionRadius;
|
||||
velocity.Y = -velocity.Y;
|
||||
}
|
||||
else if (position.Y > hullRect.Y)
|
||||
{
|
||||
position.Y = hullRect.Y + prefab.CollisionRadius;
|
||||
velocity.X = Math.Abs(velocity.Y) * Math.Sign(velocity.X);
|
||||
velocity.Y = -velocity.Y;
|
||||
}
|
||||
|
||||
if (position.X < hullRect.X)
|
||||
{
|
||||
position.X = hullRect.X - prefab.CollisionRadius;
|
||||
velocity.X = -velocity.X;
|
||||
}
|
||||
else if (position.X > hullRect.X + hullRect.Width)
|
||||
{
|
||||
position.X = hullRect.X + hullRect.Width + prefab.CollisionRadius;
|
||||
velocity.X = -velocity.X;
|
||||
}
|
||||
|
||||
velocity *= prefab.Restitution;
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
|
||||
public void UpdateDrawPos()
|
||||
{
|
||||
drawPosition = Physics.Interpolate(prevPosition, position);
|
||||
float drawRotation = Physics.Interpolate(prevRotation, rotation);
|
||||
|
||||
//drawPosition = ConvertUnits.ToDisplayUnits(drawPosition);
|
||||
|
||||
Vector2 drawSize = size;
|
||||
|
||||
if (prefab.GrowTime>0.0f && totalLifeTime-lifeTime < prefab.GrowTime)
|
||||
{
|
||||
drawSize *= ((totalLifeTime - lifeTime) / prefab.GrowTime);
|
||||
}
|
||||
|
||||
prefab.Sprites[spriteIndex].Draw(spriteBatch,
|
||||
new Vector2(drawPosition.X, -drawPosition.Y),
|
||||
color * alpha,
|
||||
prefab.Sprites[spriteIndex].Origin, drawRotation,
|
||||
drawSize, SpriteEffects.None, prefab.Sprites[spriteIndex].Depth);
|
||||
drawRotation = Physics.Interpolate(prevRotation, rotation);
|
||||
|
||||
prevPosition = position;
|
||||
prevRotation = rotation;
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Vector2 drawSize = size;
|
||||
|
||||
if (prefab.GrowTime > 0.0f && totalLifeTime - lifeTime < prefab.GrowTime)
|
||||
{
|
||||
drawSize *= ((totalLifeTime - lifeTime) / prefab.GrowTime);
|
||||
}
|
||||
|
||||
prefab.Sprites[spriteIndex].Draw(spriteBatch,
|
||||
new Vector2(drawPosition.X, -drawPosition.Y),
|
||||
color * alpha,
|
||||
prefab.Sprites[spriteIndex].Origin, drawRotation,
|
||||
drawSize, SpriteEffects.None, prefab.Sprites[spriteIndex].Depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,14 @@ namespace Barotrauma.Particles
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateTransforms()
|
||||
{
|
||||
for (int i = 0; i < particleCount; i++)
|
||||
{
|
||||
particles[i].UpdateDrawPos();
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool inWater, ParticleBlendState blendState)
|
||||
{
|
||||
ParticlePrefab.DrawTargetType drawTarget = inWater ? ParticlePrefab.DrawTargetType.Water : ParticlePrefab.DrawTargetType.Air;
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Barotrauma.Particles
|
||||
public readonly Vector2 StartSizeMin, StartSizeMax;
|
||||
public readonly Vector2 SizeChangeMin, SizeChangeMax;
|
||||
|
||||
public readonly float Drag, WaterDrag;
|
||||
|
||||
public readonly Color StartColor;
|
||||
public readonly float StartAlpha;
|
||||
|
||||
@@ -89,6 +91,9 @@ namespace Barotrauma.Particles
|
||||
SizeChangeMax = SizeChangeMin;
|
||||
}
|
||||
|
||||
Drag = ToolBox.GetAttributeFloat(element, "drag", 0.0f);
|
||||
WaterDrag = ToolBox.GetAttributeFloat(element, "waterdrag", 0.0f);
|
||||
|
||||
Restitution = ToolBox.GetAttributeFloat(element, "restitution", 0.5f);
|
||||
|
||||
switch (ToolBox.GetAttributeString(element, "blendstate", "alphablend"))
|
||||
|
||||
@@ -18,6 +18,10 @@ namespace Barotrauma
|
||||
|
||||
private BlurEffect lightBlur;
|
||||
|
||||
private Effect damageEffect;
|
||||
|
||||
private Texture2D damageStencil;
|
||||
|
||||
public BackgroundCreatureManager BackgroundCreatureManager;
|
||||
|
||||
public Camera Cam
|
||||
@@ -46,10 +50,14 @@ namespace Barotrauma
|
||||
var blurEffect = content.Load<Effect>("blurshader");
|
||||
#endif
|
||||
|
||||
damageStencil = TextureLoader.FromFile("Content/Map/walldamage.png");
|
||||
|
||||
damageEffect = content.Load<Effect>("damageshader");
|
||||
damageEffect.Parameters["xStencil"].SetValue(damageStencil);
|
||||
damageEffect.Parameters["aMultiplier"].SetValue(50.0f);
|
||||
damageEffect.Parameters["cMultiplier"].SetValue(200.0f);
|
||||
|
||||
lightBlur = new BlurEffect(blurEffect, 0.001f, 0.001f);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void Select()
|
||||
@@ -101,23 +109,24 @@ namespace Barotrauma
|
||||
}
|
||||
#endif
|
||||
|
||||
if (GameMain.GameSession!=null) GameMain.GameSession.Update((float)deltaTime);
|
||||
//EventManager.Update(gameTime);
|
||||
|
||||
if (Level.Loaded != null) Level.Loaded.Update((float)deltaTime);
|
||||
|
||||
Character.UpdateAll(cam, (float)deltaTime);
|
||||
|
||||
BackgroundCreatureManager.Update(cam, (float)deltaTime);
|
||||
|
||||
GameMain.ParticleManager.Update((float)deltaTime);
|
||||
|
||||
StatusEffect.UpdateAll((float)deltaTime);
|
||||
|
||||
Physics.accumulator = Math.Min(Physics.accumulator, Physics.step * 6);
|
||||
//Physics.accumulator = Physics.step;
|
||||
while (Physics.accumulator >= Physics.step)
|
||||
{
|
||||
|
||||
if (GameMain.GameSession != null) GameMain.GameSession.Update((float)Physics.step);
|
||||
//EventManager.Update(gameTime);
|
||||
|
||||
if (Level.Loaded != null) Level.Loaded.Update((float)Physics.step);
|
||||
|
||||
Character.UpdateAll(cam, (float)Physics.step);
|
||||
|
||||
BackgroundCreatureManager.Update(cam, (float)Physics.step);
|
||||
|
||||
GameMain.ParticleManager.Update((float)Physics.step);
|
||||
|
||||
StatusEffect.UpdateAll((float)Physics.step);
|
||||
|
||||
if (Character.Controlled != null && Lights.LightManager.ViewTarget != null)
|
||||
{
|
||||
cam.TargetPos = Lights.LightManager.ViewTarget.WorldPosition;
|
||||
@@ -160,7 +169,10 @@ namespace Barotrauma
|
||||
|
||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||
{
|
||||
cam.UpdateTransform(true);
|
||||
cam.UpdateTransform(true);
|
||||
|
||||
|
||||
//damageStencil = TextureLoader.FromFile("Content/Map/background.png");
|
||||
|
||||
DrawMap(graphics, spriteBatch);
|
||||
|
||||
@@ -199,6 +211,8 @@ namespace Barotrauma
|
||||
sub.UpdateTransform();
|
||||
}
|
||||
|
||||
GameMain.ParticleManager.UpdateTransforms();
|
||||
|
||||
GameMain.LightManager.ObstructVision = Character.Controlled != null && Character.Controlled.ObstructVision;
|
||||
|
||||
GameMain.LightManager.UpdateLightMap(graphics, spriteBatch, cam);
|
||||
@@ -324,6 +338,17 @@ namespace Barotrauma
|
||||
Submarine.DrawFront(spriteBatch);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate,
|
||||
BlendState.NonPremultiplied, SamplerState.LinearWrap,
|
||||
null, null,
|
||||
damageEffect,
|
||||
cam.Transform);
|
||||
|
||||
Submarine.DrawDamageable(spriteBatch, damageEffect);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
|
||||
GameMain.LightManager.DrawLightMap(spriteBatch, cam, lightBlur.Effect);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user