diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj index 370f034f5..96c031f73 100644 --- a/Subsurface/Barotrauma.csproj +++ b/Subsurface/Barotrauma.csproj @@ -982,6 +982,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/Subsurface/Content/Items/Diving/divinggear.xml b/Subsurface/Content/Items/Diving/divinggear.xml index 6de52afec..1fe544707 100644 --- a/Subsurface/Content/Items/Diving/divinggear.xml +++ b/Subsurface/Content/Items/Diving/divinggear.xml @@ -13,6 +13,10 @@ + + + + diff --git a/Subsurface/Content/Items/Electricity/signalitems.xml b/Subsurface/Content/Items/Electricity/signalitems.xml index 3949324cc..0e6855c90 100644 --- a/Subsurface/Content/Items/Electricity/signalitems.xml +++ b/Subsurface/Content/Items/Electricity/signalitems.xml @@ -282,7 +282,7 @@ linkable="true" price="20"> - + diff --git a/Subsurface/Content/Items/Tools/tools.xml b/Subsurface/Content/Items/Tools/tools.xml index 80e3f5f3d..d321b66eb 100644 --- a/Subsurface/Content/Items/Tools/tools.xml +++ b/Subsurface/Content/Items/Tools/tools.xml @@ -96,6 +96,10 @@ + + + + diff --git a/Subsurface/Content/Sounds/fire.ogg b/Subsurface/Content/Sounds/fire.ogg new file mode 100644 index 000000000..80e6d9cfc Binary files /dev/null and b/Subsurface/Content/Sounds/fire.ogg differ diff --git a/Subsurface/Content/Sounds/firelarge.ogg b/Subsurface/Content/Sounds/firelarge.ogg new file mode 100644 index 000000000..452f32150 Binary files /dev/null and b/Subsurface/Content/Sounds/firelarge.ogg differ diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index ab78afe27..61ba42294 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -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); } diff --git a/Subsurface/Source/Items/Components/Machines/Reactor.cs b/Subsurface/Source/Items/Components/Machines/Reactor.cs index a3d0ce692..767be9f35 100644 --- a/Subsurface/Source/Items/Components/Machines/Reactor.cs +++ b/Subsurface/Source/Items/Components/Machines/Reactor.cs @@ -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 meltDownTemp) { MeltDown(); diff --git a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs index 9dbde12e1..fd3df461a 100644 --- a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs +++ b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs @@ -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); } } diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 8ae2982e2..1868bee07 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -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 { diff --git a/Subsurface/Source/Items/ItemPrefab.cs b/Subsurface/Source/Items/ItemPrefab.cs index 0f33fb54e..76c2658d2 100644 --- a/Subsurface/Source/Items/ItemPrefab.cs +++ b/Subsurface/Source/Items/ItemPrefab.cs @@ -31,6 +31,8 @@ namespace Barotrauma //the construction can be Activated() by a Character inside the area public List 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)); diff --git a/Subsurface/Source/Map/Explosion.cs b/Subsurface/Source/Map/Explosion.cs index be8fb4fcd..256d9d1cb 100644 --- a/Subsurface/Source/Map/Explosion.cs +++ b/Subsurface/Source/Map/Explosion.cs @@ -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, diff --git a/Subsurface/Source/Map/FireSource.cs b/Subsurface/Source/Map/FireSource.cs index 723576e36..e301522f7 100644 --- a/Subsurface/Source/Map/FireSource.cs +++ b/Subsurface/Source/Map/FireSource.cs @@ -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); } } diff --git a/Subsurface/Source/Map/Hull.cs b/Subsurface/Source/Map/Hull.cs index 3dcffaac1..9ad2b00f0 100644 --- a/Subsurface/Source/Map/Hull.cs +++ b/Subsurface/Source/Map/Hull.cs @@ -201,6 +201,12 @@ namespace Barotrauma Item.UpdateHulls(); Gap.UpdateHulls(); + List fireSourcesToRemove = new List(fireSources); + foreach (FireSource fireSource in fireSourcesToRemove) + { + fireSource.Remove(); + } + //renderer.Dispose(); hullList.Remove(this); diff --git a/Subsurface/Source/Map/WaterRenderer.cs b/Subsurface/Source/Map/WaterRenderer.cs index fcbe29b14..b1a1382bc 100644 --- a/Subsurface/Source/Map/WaterRenderer.cs +++ b/Subsurface/Source/Map/WaterRenderer.cs @@ -20,6 +20,11 @@ namespace Barotrauma private Texture2D waterTexture; + public Texture2D WaterTexture + { + get { return waterTexture; } + } + public WaterRenderer(GraphicsDevice graphicsDevice) { #if WINDOWS diff --git a/Subsurface/Source/Particles/ParticleManager.cs b/Subsurface/Source/Particles/ParticleManager.cs index 04b2da216..e63e8e780 100644 --- a/Subsurface/Source/Particles/ParticleManager.cs +++ b/Subsurface/Source/Particles/ParticleManager.cs @@ -9,7 +9,7 @@ namespace Barotrauma.Particles { enum ParticleBlendState { - AlphaBlend, Additive + AlphaBlend, Additive, Distortion } class ParticleManager diff --git a/Subsurface/Source/Particles/ParticlePrefab.cs b/Subsurface/Source/Particles/ParticlePrefab.cs index 04ceb3be2..0a8be8995 100644 --- a/Subsurface/Source/Particles/ParticlePrefab.cs +++ b/Subsurface/Source/Particles/ParticlePrefab.cs @@ -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); diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 09f6f31b2..0637bc213 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ