Spectating, fire, damaged limb sprites, water detector, engineer jumpsuit, new signal comp sprites, resharper cleanup (god knows what else, commit more often)
This commit is contained in:
@@ -0,0 +1,186 @@
|
||||
using Barotrauma.Lights;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class FireSource
|
||||
{
|
||||
const float OxygenConsumption = 10.0f;
|
||||
const float GrowSpeed = 5.0f;
|
||||
|
||||
Hull hull;
|
||||
|
||||
LightSource lightSource;
|
||||
|
||||
Vector2 position;
|
||||
Vector2 size;
|
||||
|
||||
public Vector2 Size
|
||||
{
|
||||
get { return size; }
|
||||
}
|
||||
|
||||
public FireSource(Vector2 position)
|
||||
{
|
||||
hull = Hull.FindHull(position);
|
||||
if (hull == null) return;
|
||||
|
||||
lightSource = new LightSource(position, 50.0f, new Color(1.0f, 0.9f, 0.6f));
|
||||
|
||||
hull.AddFireSource(this);
|
||||
|
||||
this.position = position - new Vector2(-5.0f, 5.0f);
|
||||
|
||||
this.position.Y = hull.Rect.Y - hull.Rect.Height;
|
||||
|
||||
size = new Vector2(10.0f, 10.0f);
|
||||
}
|
||||
|
||||
private void LimitSize()
|
||||
{
|
||||
position.X = Math.Max(hull.Rect.X, position.X);
|
||||
position.Y = Math.Min(hull.Rect.Y, position.Y);
|
||||
|
||||
size.X = Math.Min(hull.Rect.Width - (position.X - hull.Rect.X), size.X);
|
||||
size.Y = Math.Min(hull.Rect.Height - (hull.Rect.Y - position.Y), size.Y);
|
||||
}
|
||||
|
||||
public static void UpdateAll(List<FireSource> fireSources, float deltaTime)
|
||||
{
|
||||
for (int i = fireSources.Count - 1; i >= 0; i--)
|
||||
{
|
||||
fireSources[i].Update(deltaTime);
|
||||
}
|
||||
|
||||
//combine overlapping fires
|
||||
for (int i = fireSources.Count - 1; i >= 0; i--)
|
||||
{
|
||||
for (int j = i-1; j>=0 ; j--)
|
||||
{
|
||||
if (!fireSources[i].CheckOverLap(fireSources[j])) continue;
|
||||
|
||||
fireSources[j].position.X = Math.Min(fireSources[i].position.X, fireSources[j].position.X);
|
||||
|
||||
fireSources[j].size.X =
|
||||
Math.Max(fireSources[i].position.X + fireSources[i].size.X, fireSources[j].position.X + fireSources[j].size.X)
|
||||
- fireSources[j].position.X;
|
||||
|
||||
fireSources[i].Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckOverLap(FireSource fireSource)
|
||||
{
|
||||
return !(position.X > fireSource.position.X + fireSource.size.X &&
|
||||
position.X + size.X < fireSource.position.X);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
float count = Rand.Range(0.0f, (float)Math.Sqrt(size.X)/2.0f);
|
||||
|
||||
for (int i = 0; i < count; i++ )
|
||||
{
|
||||
float normalizedPos = 0.5f-(i / count);
|
||||
|
||||
Vector2 spawnPos = new Vector2(position.X + Rand.Range(0.0f, size.X), Rand.Range(position.Y - size.Y, position.Y)+10.0f);
|
||||
|
||||
Vector2 speed = new Vector2((spawnPos.X - (position.X + size.X/2.0f)), (float)Math.Sqrt(size.X)*Rand.Range(10.0f,15.0f));
|
||||
|
||||
var particle = GameMain.ParticleManager.CreateParticle("flame",
|
||||
spawnPos, speed, 0.0f, hull);
|
||||
|
||||
if (particle == null) continue;
|
||||
|
||||
if (Rand.Int(20) == 1) particle.OnChangeHull = OnChangeHull;
|
||||
|
||||
|
||||
particle.Size *= MathHelper.Clamp(size.X/100.0f * (hull.Oxygen/hull.FullVolume), 0.5f, 4.0f);
|
||||
}
|
||||
|
||||
DamageCharacters(deltaTime);
|
||||
|
||||
if (hull.Volume > 0.0f) Extinquish(deltaTime);
|
||||
|
||||
lightSource.Range = Math.Max(size.X, size.Y)*Rand.Range(8.0f, 10.0f)/2.0f;
|
||||
lightSource.Color = new Color(1.0f, 0.9f, 0.6f) * Rand.Range(0.8f, 1.0f);
|
||||
|
||||
hull.Oxygen -= size.X*deltaTime*OxygenConsumption;
|
||||
|
||||
float growModifier = hull.OxygenPercentage < 20.0f ? hull.OxygenPercentage/20.0f : 1.0f;
|
||||
|
||||
position.X -= GrowSpeed * growModifier * 0.5f * deltaTime;
|
||||
//position.Y += GrowSpeed*0.5f * deltaTime;
|
||||
|
||||
size.X += GrowSpeed * growModifier * deltaTime;
|
||||
//size.Y += GrowSpeed * deltaTime;
|
||||
|
||||
LimitSize();
|
||||
}
|
||||
|
||||
private void OnChangeHull(Vector2 pos, Hull particleHull)
|
||||
{
|
||||
if (particleHull == hull || particleHull==null) return;
|
||||
|
||||
if (particleHull.FireSources.Find(fs => pos.X > fs.position.X && pos.X < fs.position.X+fs.size.X)!=null) return;
|
||||
|
||||
new FireSource(new Vector2(pos.X, particleHull.Rect.Y-particleHull.Rect.Height + 5.0f));
|
||||
}
|
||||
|
||||
private void DamageCharacters(float deltaTime)
|
||||
{
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
if (c.AnimController.CurrentHull == null) continue;
|
||||
|
||||
float range = (float)Math.Sqrt(size.X) * 10.0f;
|
||||
if (c.Position.X < position.X - range || c.Position.X > position.X + size.X + range) continue;
|
||||
if (c.Position.Y < position.Y - size.Y || c.Position.Y > hull.Rect.Y) continue;
|
||||
|
||||
c.Health -= (float)Math.Sqrt(size.X) * deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
private void Extinquish(float deltaTime)
|
||||
{
|
||||
float extinquishAmount = Math.Min(hull.Volume / 100.0f, size.X);
|
||||
|
||||
float steamCount = Rand.Range(-5.0f, (float)Math.Sqrt(extinquishAmount));
|
||||
|
||||
for (int i = 0; i < steamCount; i++)
|
||||
{
|
||||
Vector2 spawnPos = new Vector2(position.X + size.X * (i / steamCount) + Rand.Range(-5.0f, 5.0f), Rand.Range(position.Y - size.Y, position.Y) + 10.0f);
|
||||
|
||||
Vector2 speed = new Vector2((spawnPos.X - (position.X + size.X / 2.0f)), (float)Math.Sqrt(size.X) * Rand.Range(20.0f, 25.0f));
|
||||
|
||||
var particle = GameMain.ParticleManager.CreateParticle("steam",
|
||||
spawnPos, speed, 0.0f, hull);
|
||||
|
||||
if (particle == null) continue;
|
||||
|
||||
particle.Size *= MathHelper.Clamp(size.X / 10.0f, 0.5f, 3.0f);
|
||||
}
|
||||
|
||||
position.X += extinquishAmount * 0.1f / 2.0f;
|
||||
size.X -= extinquishAmount * 0.1f;
|
||||
|
||||
hull.Volume -= extinquishAmount;
|
||||
|
||||
if (size.X < 1.0f) Remove();
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
lightSource.Remove();
|
||||
|
||||
hull.RemoveFire(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -609,7 +609,7 @@ namespace Barotrauma
|
||||
Gap g = new Gap(rect);
|
||||
g.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
||||
|
||||
g.linkedToID = new List<int>();
|
||||
g.linkedToID = new List<ushort>();
|
||||
//int i = 0;
|
||||
//while (element.Attribute("linkedto" + i) != null)
|
||||
//{
|
||||
|
||||
@@ -15,9 +15,11 @@ namespace Barotrauma
|
||||
{
|
||||
public static List<Hull> hullList = new List<Hull>();
|
||||
|
||||
public static bool EditWater;
|
||||
public static bool EditWater, EditFire;
|
||||
|
||||
public static WaterRenderer renderer;
|
||||
|
||||
private List<FireSource> fireSources;
|
||||
|
||||
public const float OxygenDistributionSpeed = 500.0f;
|
||||
public const float OxygenDetoriationSpeed = 0.3f;
|
||||
@@ -126,12 +128,19 @@ namespace Barotrauma
|
||||
get { return waveVel; }
|
||||
}
|
||||
|
||||
public List<FireSource> FireSources
|
||||
{
|
||||
get { return fireSources; }
|
||||
}
|
||||
|
||||
public Hull(Rectangle rectangle)
|
||||
{
|
||||
rect = rectangle;
|
||||
|
||||
OxygenPercentage = Rand.Range(90.0f, 100.0f, false);
|
||||
|
||||
fireSources = new List<FireSource>();
|
||||
|
||||
properties = TypeDescriptor.GetProperties(GetType())
|
||||
.Cast<PropertyDescriptor>()
|
||||
.ToDictionary(pr => pr.Name);
|
||||
@@ -197,6 +206,11 @@ namespace Barotrauma
|
||||
hullList.Remove(this);
|
||||
}
|
||||
|
||||
public void AddFireSource(FireSource fireSource)
|
||||
{
|
||||
fireSources.Add(fireSource);
|
||||
}
|
||||
|
||||
public override void Update(Camera cam, float deltaTime)
|
||||
{
|
||||
Oxygen -= OxygenDetoriationSpeed * deltaTime;
|
||||
@@ -217,7 +231,20 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (EditFire)
|
||||
{
|
||||
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
if (Submarine.RectContains(rect, position))
|
||||
{
|
||||
if (PlayerInput.LeftButtonClicked())
|
||||
{
|
||||
new FireSource(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FireSource.UpdateAll(fireSources, deltaTime);
|
||||
|
||||
//update client hulls if the amount of water has changed by >10%
|
||||
if (Math.Abs(lastSentVolume - volume) > FullVolume * 0.1f)
|
||||
{
|
||||
@@ -292,8 +319,11 @@ namespace Barotrauma
|
||||
|
||||
LethalPressure += ( Submarine.Loaded!=null && Submarine.Loaded.AtDamageDepth) ? 100.0f*deltaTime : 10.0f * deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void RemoveFire(FireSource fire)
|
||||
{
|
||||
fireSources.Remove(fire);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
@@ -441,6 +471,27 @@ namespace Barotrauma
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Gap> FindGaps()
|
||||
{
|
||||
List<Gap> gaps = new List<Gap>();
|
||||
|
||||
foreach (Gap gap in Gap.GapList)
|
||||
{
|
||||
if (gap.Open < 0.01f) continue;
|
||||
if (gap.linkedTo.Count == 0) continue;
|
||||
|
||||
var gapHull = gap.linkedTo[0] as Hull;
|
||||
if (gapHull == this) gaps.Add(gap);
|
||||
|
||||
if (gap.linkedTo.Count < 2) continue;
|
||||
|
||||
gapHull = gap.linkedTo[1] as Hull;
|
||||
if (gapHull == this) gaps.Add(gap);
|
||||
}
|
||||
|
||||
return gaps;
|
||||
}
|
||||
|
||||
public override XElement Save(XDocument doc)
|
||||
{
|
||||
XElement element = new XElement("Hull");
|
||||
|
||||
@@ -731,10 +731,8 @@ namespace Barotrauma
|
||||
// cell.body.SetTransform(cell.body.Position + simAmount, cell.body.Rotation);
|
||||
//}
|
||||
|
||||
int i = 0;
|
||||
foreach (Body body in bodies)
|
||||
{
|
||||
i++;
|
||||
body.SetTransform(body.Position + simAmount, body.Rotation);
|
||||
}
|
||||
|
||||
@@ -759,7 +757,6 @@ namespace Barotrauma
|
||||
Vector2 prevVelocity;
|
||||
public void Move(Vector2 amount)
|
||||
{
|
||||
Vector2 velocity = amount;
|
||||
Vector2 simVelocity = ConvertUnits.ToSimUnits(amount / (float)Physics.step);
|
||||
|
||||
foreach (Body body in bodies)
|
||||
|
||||
@@ -62,10 +62,6 @@ namespace Voronoi2
|
||||
{
|
||||
public double x, y;
|
||||
|
||||
public Point ()
|
||||
{
|
||||
}
|
||||
|
||||
public void setPoint ( double x, double y )
|
||||
{
|
||||
this.x = x;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Barotrauma
|
||||
nameFormats = new List<string>();
|
||||
foreach (XAttribute nameFormat in element.Element("nameformats").Attributes())
|
||||
{
|
||||
nameFormats.Add(nameFormat.Value.ToString());
|
||||
nameFormats.Add(nameFormat.Value);
|
||||
}
|
||||
|
||||
string spritePath = ToolBox.GetAttributeString(element, "symbol", "Content/Map/beaconSymbol.png");
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Barotrauma
|
||||
|
||||
protected static Vector2 startMovingPos = Vector2.Zero;
|
||||
|
||||
protected List<int> linkedToID;
|
||||
protected List<ushort> linkedToID;
|
||||
|
||||
//observable collection because some entities may need to be notified when the collection is modified
|
||||
public ObservableCollection<MapEntity> linkedTo;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Barotrauma
|
||||
waterEffect.Parameters["xWaveWidth"].SetValue(0.05f);
|
||||
waterEffect.Parameters["xWaveHeight"].SetValue(0.05f);
|
||||
#if WINDOWS
|
||||
waterEffect.Parameters["xTexture"].SetValue(waterTexture);
|
||||
//waterEffect.Parameters["xTexture"].SetValue(waterTexture);
|
||||
#endif
|
||||
#if LINUX
|
||||
waterEffect.Parameters["xWaterBumpMap"].SetValue(waterTexture);
|
||||
|
||||
@@ -327,11 +327,11 @@ namespace Barotrauma
|
||||
w.assignedJob = JobPrefab.List.Find(jp => jp.Name.ToLower() == jobName);
|
||||
}
|
||||
|
||||
w.linkedToID = new List<int>();
|
||||
w.linkedToID = new List<ushort>();
|
||||
int i = 0;
|
||||
while (element.Attribute("linkedto" + i) != null)
|
||||
{
|
||||
w.linkedToID.Add(int.Parse(element.Attribute("linkedto" + i).Value));
|
||||
w.linkedToID.Add((ushort)int.Parse(element.Attribute("linkedto" + i).Value));
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user