From f4c5c5e542b40d7207b628225eb609844e6e0a88 Mon Sep 17 00:00:00 2001 From: Regalis Date: Sun, 9 Oct 2016 15:13:41 +0300 Subject: [PATCH] Added a particle trail to railgun shells --- Subsurface/Content/Items/Weapons/railgun.xml | 9 +++++++++ .../Source/Items/Components/Projectile.cs | 6 ++++++ Subsurface/Source/Map/Map/Map.cs | 5 +++++ .../Source/Particles/ParticleEmitter.cs | 20 ++++++++++++++++++- 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Subsurface/Content/Items/Weapons/railgun.xml b/Subsurface/Content/Items/Weapons/railgun.xml index 3540372e6..5d5922029 100644 --- a/Subsurface/Content/Items/Weapons/railgun.xml +++ b/Subsurface/Content/Items/Weapons/railgun.xml @@ -82,6 +82,10 @@ + + + + @@ -110,9 +114,14 @@ + + + + + diff --git a/Subsurface/Source/Items/Components/Projectile.cs b/Subsurface/Source/Items/Components/Projectile.cs index b9a173a0a..06571e940 100644 --- a/Subsurface/Source/Items/Components/Projectile.cs +++ b/Subsurface/Source/Items/Components/Projectile.cs @@ -88,6 +88,8 @@ namespace Barotrauma.Items.Components item.body.CollisionCategories = Physics.CollisionProjectile; item.body.CollidesWith = Physics.CollisionCharacter | Physics.CollisionWall | Physics.CollisionLevel; + IsActive = true; + if (stickJoint == null || !doesStick) return; if (stickTarget != null) @@ -111,6 +113,8 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { + ApplyStatusEffects(ActionType.OnActive, deltaTime, null); + if (stickJoint != null && stickJoint.JointTranslation < 0.01f) { if (stickTarget != null) @@ -174,6 +178,8 @@ namespace Barotrauma.Items.Components ApplyStatusEffects(ActionType.OnUse, 1.0f); ApplyStatusEffects(ActionType.OnImpact, 1.0f); + IsActive = false; + item.body.FarseerBody.OnCollision -= OnProjectileCollision; item.body.FarseerBody.IsBullet = false; diff --git a/Subsurface/Source/Map/Map/Map.cs b/Subsurface/Source/Map/Map/Map.cs index a15b19bea..64eae3e71 100644 --- a/Subsurface/Source/Map/Map/Map.cs +++ b/Subsurface/Source/Map/Map/Map.cs @@ -309,6 +309,11 @@ namespace Barotrauma { crackColor = Color.Red; } + else if (highlightedLocation != currentLocation && + (connection.Locations.Contains(highlightedLocation) && connection.Locations.Contains(currentLocation))) + { + crackColor = Color.Red * 0.5f; + } else if (!connection.Passed) { crackColor *= 0.2f; diff --git a/Subsurface/Source/Particles/ParticleEmitter.cs b/Subsurface/Source/Particles/ParticleEmitter.cs index 593f9abc5..3defc25f0 100644 --- a/Subsurface/Source/Particles/ParticleEmitter.cs +++ b/Subsurface/Source/Particles/ParticleEmitter.cs @@ -15,6 +15,8 @@ namespace Barotrauma.Particles public readonly float VelocityMin, VelocityMax; + public readonly float ScaleMin, ScaleMax; + public readonly float ParticleAmount; public ParticleEmitterPrefab(XElement element) @@ -37,6 +39,17 @@ namespace Barotrauma.Particles AngleMin = MathHelper.ToRadians(AngleMin); AngleMax = MathHelper.ToRadians(AngleMax); + if (element.Attribute("scalemin")==null) + { + ScaleMin = 1.0f; + ScaleMax = 1.0f; + } + else + { + ScaleMin = ToolBox.GetAttributeFloat(element,"scalemin",1.0f); + ScaleMax = Math.Max(ScaleMin, ToolBox.GetAttributeFloat(element, "scalemax", 1.0f)); + } + if (element.Attribute("velocity") == null) { VelocityMin = ToolBox.GetAttributeFloat(element, "velocitymin", 0.0f); @@ -58,7 +71,12 @@ namespace Barotrauma.Particles float angle = Rand.Range(AngleMin, AngleMax); Vector2 velocity = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * Rand.Range(VelocityMin, VelocityMax); - GameMain.ParticleManager.CreateParticle(particlePrefab, position, velocity, 0.0f, hullGuess); + var particle = GameMain.ParticleManager.CreateParticle(particlePrefab, position, velocity, 0.0f, hullGuess); + + if (particle!=null) + { + particle.Size *= Rand.Range(ScaleMin, ScaleMax); + } } } }