From c99f94b1deae5b47113cf0866851d3ad37b00e22 Mon Sep 17 00:00:00 2001 From: Regalis Date: Sat, 12 Mar 2016 21:28:39 +0200 Subject: [PATCH] Fixed projectiles (e.g. railgun shells) not colliding with the sub when shot from outside, fixed lightcomponents not being positioned correctly on moving items --- .../Content/Items/Electricity/signalitems.xml | 1 + Subsurface/Content/Items/Tools/tools.xml | 4 ++-- Subsurface/Source/Items/Components/Projectile.cs | 10 ++++++++++ .../Items/Components/Signal/LightComponent.cs | 14 +++++++++----- Subsurface/Source/Map/SubmarineBody.cs | 2 +- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Subsurface/Content/Items/Electricity/signalitems.xml b/Subsurface/Content/Items/Electricity/signalitems.xml index 8128c1d74..d4ebf5678 100644 --- a/Subsurface/Content/Items/Electricity/signalitems.xml +++ b/Subsurface/Content/Items/Electricity/signalitems.xml @@ -305,6 +305,7 @@ + diff --git a/Subsurface/Content/Items/Tools/tools.xml b/Subsurface/Content/Items/Tools/tools.xml index 560e8c436..be03cf31b 100644 --- a/Subsurface/Content/Items/Tools/tools.xml +++ b/Subsurface/Content/Items/Tools/tools.xml @@ -43,7 +43,7 @@ - + @@ -88,7 +88,7 @@ - + diff --git a/Subsurface/Source/Items/Components/Projectile.cs b/Subsurface/Source/Items/Components/Projectile.cs index 4e271594e..fbe4b69dd 100644 --- a/Subsurface/Source/Items/Components/Projectile.cs +++ b/Subsurface/Source/Items/Components/Projectile.cs @@ -149,6 +149,16 @@ namespace Barotrauma.Items.Components AttackResult attackResult = new AttackResult(0.0f, 0.0f); if (attack != null) { + var submarine = f2.Body.UserData as Submarine; + if (submarine != null) + { + item.Move(-submarine.Position); + item.Submarine = submarine; + item.body.Submarine = submarine; + item.FindHull(); + return false; + } + Limb limb; Structure structure; if ((limb = (f2.Body.UserData as Limb)) != null) diff --git a/Subsurface/Source/Items/Components/Signal/LightComponent.cs b/Subsurface/Source/Items/Components/Signal/LightComponent.cs index 0b1c251a8..7ad1ed8f0 100644 --- a/Subsurface/Source/Items/Components/Signal/LightComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/LightComponent.cs @@ -92,10 +92,8 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { base.Update(deltaTime, cam); - if (item.CurrentHull != null) - { - light.Submarine = item.CurrentHull.Submarine; - } + + light.Submarine = (item.CurrentHull == null) ? null : item.CurrentHull.Submarine; if (item.Container != null) { @@ -105,7 +103,13 @@ namespace Barotrauma.Items.Components if (item.body != null) { - light.Position = item.WorldPosition; + light.Position = item.Position; + + if (!item.body.Enabled) + { + light.Color = Color.Transparent; + return; + } } if (powerConsumption == 0.0f) diff --git a/Subsurface/Source/Map/SubmarineBody.cs b/Subsurface/Source/Map/SubmarineBody.cs index 9fb1fcbb9..7246e820e 100644 --- a/Subsurface/Source/Map/SubmarineBody.cs +++ b/Subsurface/Source/Map/SubmarineBody.cs @@ -150,7 +150,7 @@ namespace Barotrauma body.BodyType = BodyType.Dynamic; body.CollisionCategories = Physics.CollisionMisc | Physics.CollisionWall; - body.CollidesWith = Physics.CollisionLevel | Physics.CollisionCharacter; + body.CollidesWith = Physics.CollisionLevel | Physics.CollisionCharacter | Physics.CollisionProjectile; body.Restitution = Restitution; body.Friction = Friction; body.FixedRotation = true;