Fire improvements

This commit is contained in:
Regalis
2015-11-11 07:33:17 +02:00
parent 4d949e3be1
commit 9c2aec4c8e
18 changed files with 145 additions and 21 deletions

View File

@@ -982,6 +982,12 @@
<None Include="Content\Sounds\Damage\StructureBlunt7.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\fire.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\firelarge.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Music\amb_JD_drone_clattering_machine.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

View File

@@ -13,6 +13,10 @@
<Pickable holdpos="30,-15" handle1="0,1" slots="RightHand,LeftHand,Any">
<StatusEffect type="OnWearing" target="This" Condition="-0.5"/>
<StatusEffect type="OnWearing" target="Character" Oxygen="20.0"/>
<StatusEffect type="OnFire" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg" disabledeltatime="true">
<Explosion range="500.0" structuredamage="100" damage="200" stun="5" force="3.0"/>
</StatusEffect>
</Pickable>
</Item>

View File

@@ -282,7 +282,7 @@
linkable="true"
price="20">
<Sprite texture="signalcomp.png" depth="0.8" sourcerect="0,13,16,19"/>
<Sprite texture="signalcomp.png" depth="0.8" sourcerect="0,32,15,19"/>
<WifiComponent canbeselected = "true"/>

View File

@@ -96,6 +96,10 @@
<Holdable slots="RightHand,Any" holdpos="30,-15" handle1="0,5" handle2="0,-5">
<StatusEffect type="OnWearing" target="This" Condition="-0.5"/>
<StatusEffect type="OnWearing" target="Character" Oxygen="-40.0"/>
<StatusEffect type="OnFire" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg" disabledeltatime="true">
<Explosion range="500.0" structuredamage="100" damage="200" stun="5" force="3.0"/>
</StatusEffect>
</Holdable>
</Item>

Binary file not shown.

Binary file not shown.

View File

@@ -201,7 +201,8 @@ namespace Barotrauma
{
get { return health; }
set
{
{
if (!MathUtils.IsValid(value)) return;
health = MathHelper.Clamp(value, 0.0f, maxHealth);
if (health <= 0.0f) Kill(CauseOfDeath.Damage);
}

View File

@@ -28,7 +28,7 @@ namespace Barotrauma.Items.Components
//turned down and cooling increased
private float shutDownTemp;
private float meltDownTemp;
private float fireTemp, meltDownTemp;
//how much power is provided to the grid per 1 temperature unit
private float powerPerTemp;
@@ -58,6 +58,16 @@ namespace Barotrauma.Items.Components
}
}
[Editable, HasDefaultValue(9000.0f, true)]
public float FireTemp
{
get { return fireTemp; }
set
{
fireTemp = Math.Max(0.0f, value);
}
}
[Editable, HasDefaultValue(1.0f, true)]
public float PowerPerTemp
{
@@ -127,8 +137,6 @@ namespace Barotrauma.Items.Components
tempGraph = new float[graphSize];
loadGraph = new float[graphSize];
meltDownTemp = 9000.0f;
shutDownTemp = 500.0f;
powerPerTemp = 1.0f;
@@ -148,6 +156,20 @@ namespace Barotrauma.Items.Components
float deltaTemp = (((heat - heatDissipation) * 5) - temperature) / 10000.0f;
Temperature = temperature + deltaTemp;
if (temperature>fireTemp && temperature-deltaTemp<fireTemp)
{
Vector2 baseVel = Rand.Vector(300.0f);
for (int i = 0; i < 10; i++)
{
var particle = GameMain.ParticleManager.CreateParticle("spark", item.Position,
baseVel + Rand.Vector(100.0f), 0.0f);
if (particle != null) particle.Size *= Rand.Range(0.5f, 1.0f);
}
new FireSource(item.Position);
}
if (temperature > meltDownTemp)
{
MeltDown();

View File

@@ -60,7 +60,7 @@ namespace Barotrauma.Items.Components
if (pt.item.Condition<=0.0f && prevCondition > 0.0f)
{
sparkSounds[Rand.Int(sparkSounds.Length)].Play(1.0f, 600.0f, item.Position);
sparkSounds[Rand.Int(sparkSounds.Length)].Play(1.0f, 600.0f, pt.item.Position);
Vector2 baseVel = Rand.Vector(300.0f);
for (int i = 0; i < 10; i++)
@@ -70,6 +70,8 @@ namespace Barotrauma.Items.Components
if (particle != null) particle.Size *= Rand.Range(0.5f, 1.0f);
}
new FireSource(pt.item.Position);
}
}

View File

@@ -18,7 +18,7 @@ namespace Barotrauma
public enum ActionType
{
OnPicked, OnWearing, OnContaining, OnContained, OnActive, OnUse, OnFailure, OnBroken
OnPicked, OnWearing, OnContaining, OnContained, OnActive, OnUse, OnFailure, OnBroken, OnFire
}
class Item : MapEntity, IDamageable, IPropertyObject
@@ -148,10 +148,10 @@ namespace Barotrauma
}
}
//public override AITarget AiTarget
//{
// get { return aiTarget; }
//}
public bool FireProof
{
get { return prefab.FireProof; }
}
public bool Updated
{

View File

@@ -31,6 +31,8 @@ namespace Barotrauma
//the construction can be Activated() by a Character inside the area
public List<Rectangle> Triggers;
public readonly bool FireProof;
public string ConfigFile
{
get { return configFile; }
@@ -171,6 +173,8 @@ namespace Barotrauma
offsetOnSelected = ToolBox.GetAttributeFloat(element, "offsetonselected", 0.0f);
FireProof = ToolBox.GetAttributeBool(element, "fireproof", false);
string spriteColorStr = ToolBox.GetAttributeString(element, "spritecolor", "1.0,1.0,1.0,1.0");
SpriteColor = new Color(ToolBox.ParseToVector4(spriteColorStr));

View File

@@ -79,6 +79,18 @@ namespace Barotrauma
if (force == 0.0f && attack.Stun == 0.0f && attack.GetDamage(1.0f) == 0.0f) return;
Hull hull = Hull.FindHull(displayPosition);
foreach (Item item in Item.ItemList)
{
if (item.body == null || item.CurrentHull != hull) continue;
Vector2 dir = (item.SimPosition == simPosition) ? Rand.Vector(1.0f) : Vector2.Normalize(item.SimPosition - simPosition);
float distFactor = 1.0f - Vector2.Distance(item.SimPosition, simPosition) / attack.Range;
item.body.ApplyLinearImpulse(dir * distFactor * force);
}
foreach (Character c in Character.CharacterList)
{
float dist = Vector2.Distance(c.SimPosition, simPosition);
@@ -89,6 +101,7 @@ namespace Barotrauma
foreach (Limb limb in c.AnimController.Limbs)
{
if (limb.SimPosition == simPosition) continue;
distFactor = 1.0f - Vector2.Distance(limb.SimPosition, simPosition)/attack.Range;
c.AddDamage(limb.SimPosition, DamageType.None,

View File

@@ -9,9 +9,13 @@ namespace Barotrauma
{
class FireSource
{
const float OxygenConsumption = 10.0f;
static Sound fireSoundBasic, fireSoundLarge;
const float OxygenConsumption = 50.0f;
const float GrowSpeed = 5.0f;
private int basicSoundIndex, largeSoundIndex;
Hull hull;
LightSource lightSource;
@@ -29,13 +33,19 @@ namespace Barotrauma
hull = Hull.FindHull(position);
if (hull == null) return;
if (fireSoundBasic==null)
{
fireSoundBasic = Sound.Load("Content/Sounds/fire.ogg");
fireSoundLarge = Sound.Load("Content/Sounds/firelarge.ogg");
}
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;
//this.position.Y = hull.Rect.Y - hull.Rect.Height;
size = new Vector2(10.0f, 10.0f);
}
@@ -61,12 +71,15 @@ namespace Barotrauma
{
for (int j = i-1; j>=0 ; j--)
{
i = Math.Min(i, fireSources.Count - 1);
j = Math.Min(j, i - 1);
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].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();
@@ -85,7 +98,15 @@ namespace Barotrauma
public void Update(float deltaTime)
{
float count = Rand.Range(0.0f, (float)Math.Sqrt(size.X)/2.0f);
basicSoundIndex = fireSoundBasic.Loop(basicSoundIndex, Math.Min(size.X/100.0f,1.0f), position+size/2.0f, 2000.0f);
largeSoundIndex = fireSoundLarge.Loop(largeSoundIndex, MathHelper.Clamp((size.X-200.0f) / 100.0f, 0.0f, 1.0f), position + size / 2.0f, 2000.0f);
if (size.X>50.0f)
{
this.position.Y = MathHelper.Lerp(this.position.Y, hull.Rect.Y - hull.Rect.Height, deltaTime);
}
for (int i = 0; i < count; i++ )
{
float normalizedPos = 0.5f-(i / count);
@@ -106,6 +127,7 @@ namespace Barotrauma
}
DamageCharacters(deltaTime);
DamageItems(deltaTime);
if (hull.Volume > 0.0f) Extinquish(deltaTime);
@@ -114,7 +136,7 @@ namespace Barotrauma
hull.Oxygen -= size.X*deltaTime*OxygenConsumption;
float growModifier = hull.OxygenPercentage < 20.0f ? hull.OxygenPercentage/20.0f : 1.0f;
float growModifier = hull.OxygenPercentage < 20.0f ? (hull.OxygenPercentage/10.0f)-1.0f : 1.0f;
position.X -= GrowSpeed * growModifier * 0.5f * deltaTime;
//position.Y += GrowSpeed*0.5f * deltaTime;
@@ -136,6 +158,8 @@ namespace Barotrauma
private void DamageCharacters(float deltaTime)
{
if (size.X <= 0.0f) return;
foreach (Character c in Character.CharacterList)
{
if (c.AnimController.CurrentHull == null) continue;
@@ -143,11 +167,29 @@ namespace Barotrauma
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 DamageItems(float deltaTime)
{
if (size.X <= 0.0f) return;
foreach (Item item in Item.ItemList)
{
if (item.CurrentHull != hull || item.FireProof || item.Condition <= 0.0f) continue;
float range = (float)Math.Sqrt(size.X) * 10.0f;
if (item.Position.X < position.X - range || item.Position.X > position.X + size.X + range) continue;
if (item.Position.Y < position.Y - size.Y || item.Position.Y > hull.Rect.Y) continue;
item.Condition -= (float)Math.Sqrt(size.X) * deltaTime;
item.ApplyStatusEffects(ActionType.OnFire, deltaTime);
}
}
private void Extinquish(float deltaTime)
{
float extinquishAmount = Math.Min(hull.Volume / 100.0f, size.X);
@@ -180,6 +222,9 @@ namespace Barotrauma
{
lightSource.Remove();
if (basicSoundIndex > -1) Sounds.SoundManager.Stop(basicSoundIndex);
if (largeSoundIndex > -1) Sounds.SoundManager.Stop(largeSoundIndex);
hull.RemoveFire(this);
}
}

View File

@@ -201,6 +201,12 @@ namespace Barotrauma
Item.UpdateHulls();
Gap.UpdateHulls();
List<FireSource> fireSourcesToRemove = new List<FireSource>(fireSources);
foreach (FireSource fireSource in fireSourcesToRemove)
{
fireSource.Remove();
}
//renderer.Dispose();
hullList.Remove(this);

View File

@@ -20,6 +20,11 @@ namespace Barotrauma
private Texture2D waterTexture;
public Texture2D WaterTexture
{
get { return waterTexture; }
}
public WaterRenderer(GraphicsDevice graphicsDevice)
{
#if WINDOWS

View File

@@ -9,7 +9,7 @@ namespace Barotrauma.Particles
{
enum ParticleBlendState
{
AlphaBlend, Additive
AlphaBlend, Additive, Distortion
}
class ParticleManager

View File

@@ -86,9 +86,21 @@ namespace Barotrauma.Particles
SizeChangeMax = SizeChangeMin;
}
var blendState = ToolBox.GetAttributeString(element, "blendstate", "alphablend");
BlendState = (blendState != "additive") ? ParticleBlendState.AlphaBlend : ParticleBlendState.Additive;
switch (ToolBox.GetAttributeString(element, "blendstate", "alphablend"))
{
case "alpha":
case "alphablend":
BlendState = ParticleBlendState.AlphaBlend;
break;
case "add":
case "additive":
BlendState = ParticleBlendState.Additive;
break;
case "distort":
case "distortion":
BlendState = ParticleBlendState.Distortion;
break;
}
GrowTime = ToolBox.GetAttributeFloat(element, "growtime", 0.0f);

Binary file not shown.