diff --git a/Subsurface/Content/Characters/Watcher/watcher.png b/Subsurface/Content/Characters/Watcher/watcher.png index d20e99f89..d0e3c370b 100644 Binary files a/Subsurface/Content/Characters/Watcher/watcher.png and b/Subsurface/Content/Characters/Watcher/watcher.png differ diff --git a/Subsurface/Content/Characters/Watcher/watcher.xml b/Subsurface/Content/Characters/Watcher/watcher.xml index 14b2c3abd..dd12088cc 100644 --- a/Subsurface/Content/Characters/Watcher/watcher.xml +++ b/Subsurface/Content/Characters/Watcher/watcher.xml @@ -11,6 +11,10 @@ + + + + diff --git a/Subsurface/Source/Characters/Limb.cs b/Subsurface/Source/Characters/Limb.cs index 3198bb8f6..c6b4d546b 100644 --- a/Subsurface/Source/Characters/Limb.cs +++ b/Subsurface/Source/Characters/Limb.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Barotrauma.Items.Components; using System.Collections.Generic; +using Barotrauma.Lights; namespace Barotrauma { @@ -41,6 +42,8 @@ namespace Barotrauma public FixedMouseJoint pullJoint; + public readonly Lights.LightSource LightSource; + public readonly LimbType type; public readonly bool ignoreCollisions; @@ -289,6 +292,10 @@ namespace Barotrauma } damagedSprite = new Sprite(subElement, "", damagedSpritePath); + break; + case "lightsource": + LightSource = new LightSource(subElement); + break; case "attack": attack = new Attack(subElement); @@ -397,6 +404,11 @@ namespace Barotrauma public void Update(float deltaTime) { + if (LightSource != null) + { + LightSource.Submarine = body.Submarine; + LightSource.Position = Position; + } if (!character.IsDead) damage = Math.Max(0.0f, damage-deltaTime*0.1f); @@ -541,7 +553,7 @@ namespace Barotrauma bodyShapeTexture, new Vector2(body.DrawPosition.X, -body.DrawPosition.Y), null, - Color.White, + character.Submarine!=null ? Color.White : Color.Cyan, -body.DrawRotation, new Vector2(bodyShapeTexture.Width / 2, bodyShapeTexture.Height / 2), 1.0f, SpriteEffects.None, 0.0f); } @@ -550,6 +562,7 @@ namespace Barotrauma public void Remove() { sprite.Remove(); + if (LightSource != null) LightSource.Remove(); if (damagedSprite != null) damagedSprite.Remove(); body.Remove(); @@ -559,7 +572,6 @@ namespace Barotrauma bodyShapeTexture.Dispose(); } - if (hitSound != null) hitSound.Remove(); } } diff --git a/Subsurface/Source/Map/Lights/LightManager.cs b/Subsurface/Source/Map/Lights/LightManager.cs index 6d1bb92c4..d352300b7 100644 --- a/Subsurface/Source/Map/Lights/LightManager.cs +++ b/Subsurface/Source/Map/Lights/LightManager.cs @@ -152,8 +152,8 @@ namespace Barotrauma.Lights foreach (LightSource light in lights) { - if (light.hullsInRange.Count > 0 || light.Color.A < 0.01f || light.Range < 1.0f) continue; - if (!MathUtils.CircleIntersectsRectangle(light.WorldPosition, light.Range, viewRect)) continue; + if (light.hullsInRange.Count > 0 || light.Color.A < 0.01f) continue; + //if (!MathUtils.CircleIntersectsRectangle(light.WorldPosition, light.Range, viewRect)) continue; light.Draw(spriteBatch); } diff --git a/Subsurface/Source/Map/Lights/LightSource.cs b/Subsurface/Source/Map/Lights/LightSource.cs index aea928f57..c1b79f52d 100644 --- a/Subsurface/Source/Map/Lights/LightSource.cs +++ b/Subsurface/Source/Map/Lights/LightSource.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Xml.Linq; namespace Barotrauma.Lights { @@ -82,6 +83,21 @@ namespace Barotrauma.Lights } } + public LightSource (XElement element) + :this(Vector2.Zero, 100.0f, Color.White, null) + { + float range = ToolBox.GetAttributeFloat(element, "range", 100.0f); + Color color = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One)); + + foreach (XElement subElement in element.Elements()) + { + if (subElement.Name.ToString().ToLowerInvariant() != "sprite") continue; + + LightSprite = new Sprite(subElement); + LightSprite.Origin = LightSprite.size / 2.0f; + } + } + public LightSource(Vector2 position, float range, Color color, Submarine submarine) { hullsInRange = new List(); @@ -110,9 +126,13 @@ namespace Barotrauma.Lights public void Draw(SpriteBatch spriteBatch) { - Vector2 center = new Vector2(LightTexture.Width / 2, LightTexture.Height / 2); - float scale = range / (lightTexture.Width / 2.0f); - spriteBatch.Draw(lightTexture, new Vector2(WorldPosition.X, -WorldPosition.Y), null, color, 0, center, scale, SpriteEffects.None, 1); + if (range > 1.0f) + { + Vector2 center = new Vector2(LightTexture.Width / 2, LightTexture.Height / 2); + float scale = range / (lightTexture.Width / 2.0f); + + spriteBatch.Draw(lightTexture, new Vector2(WorldPosition.X, -WorldPosition.Y), null, color, 0, center, scale, SpriteEffects.None, 1); + } if (LightSprite != null) {