diff --git a/Launcher2/LauncherMain.cs b/Launcher2/LauncherMain.cs
index 3c943314b..8bc7d87d4 100644
--- a/Launcher2/LauncherMain.cs
+++ b/Launcher2/LauncherMain.cs
@@ -367,7 +367,27 @@ namespace Launcher2
xml = xml.Remove(0, _byteOrderMarkUtf8.Length);
}
- return XDocument.Parse(xml);
+ try
+ {
+ return XDocument.Parse(xml);
+ }
+
+ catch
+ {
+ }
+
+ try
+ {
+ int index = xml.IndexOf('<');
+ xml = xml.Substring(index, xml.Length-index);
+
+ return XDocument.Parse(xml);
+ }
+
+ catch
+ {
+ return null;
+ }
}
private bool CheckUpdateXML(XDocument doc)
diff --git a/Subsurface/Content/Items/Electricity/lamp.png b/Subsurface/Content/Items/Electricity/lamp.png
index 253cfec45..05848b2ae 100644
Binary files a/Subsurface/Content/Items/Electricity/lamp.png and b/Subsurface/Content/Items/Electricity/lamp.png differ
diff --git a/Subsurface/Content/Items/Electricity/lights.xml b/Subsurface/Content/Items/Electricity/lights.xml
index eb34a1660..2bf2cc9eb 100644
--- a/Subsurface/Content/Items/Electricity/lights.xml
+++ b/Subsurface/Content/Items/Electricity/lights.xml
@@ -10,7 +10,9 @@
-
+
+
+
diff --git a/Subsurface/Content/Items/Electricity/signalcomp.png b/Subsurface/Content/Items/Electricity/signalcomp.png
index 8ff3fb93c..82ca40a94 100644
Binary files a/Subsurface/Content/Items/Electricity/signalcomp.png and b/Subsurface/Content/Items/Electricity/signalcomp.png differ
diff --git a/Subsurface/Content/Items/Electricity/signalitems.xml b/Subsurface/Content/Items/Electricity/signalitems.xml
index 048e4981d..4cf60b7d2 100644
--- a/Subsurface/Content/Items/Electricity/signalitems.xml
+++ b/Subsurface/Content/Items/Electricity/signalitems.xml
@@ -221,7 +221,7 @@
-
+
diff --git a/Subsurface/Content/Items/Weapons/railgun.xml b/Subsurface/Content/Items/Weapons/railgun.xml
index 4d423b81d..2601f3a2b 100644
--- a/Subsurface/Content/Items/Weapons/railgun.xml
+++ b/Subsurface/Content/Items/Weapons/railgun.xml
@@ -13,7 +13,7 @@
rotationlimits="180,360"
powerconsumption="500.0">
-
+
diff --git a/Subsurface/Content/UI/style.xml b/Subsurface/Content/UI/style.xml
index 52dcfec9d..de7bb89eb 100644
--- a/Subsurface/Content/UI/style.xml
+++ b/Subsurface/Content/UI/style.xml
@@ -55,7 +55,7 @@
diff --git a/Subsurface/Source/Characters/Limb.cs b/Subsurface/Source/Characters/Limb.cs
index 974531362..24c7ef5dd 100644
--- a/Subsurface/Source/Characters/Limb.cs
+++ b/Subsurface/Source/Characters/Limb.cs
@@ -499,7 +499,7 @@ namespace Barotrauma
damagedSprite.Draw(spriteBatch,
new Vector2(body.DrawPosition.X, -body.DrawPosition.Y),
- color*Math.Min(damage/50.0f,1.0f), sprite.origin,
+ color*Math.Min(damage/50.0f,1.0f), sprite.Origin,
-body.DrawRotation,
1.0f, spriteEffect, depth);
}
diff --git a/Subsurface/Source/GUI/GUITextBox.cs b/Subsurface/Source/GUI/GUITextBox.cs
index 735e84a1c..ade97466e 100644
--- a/Subsurface/Source/GUI/GUITextBox.cs
+++ b/Subsurface/Source/GUI/GUITextBox.cs
@@ -70,6 +70,19 @@ namespace Barotrauma
}
}
+ public override Color HoverColor
+ {
+ get
+ {
+ return base.HoverColor;
+ }
+ set
+ {
+ base.HoverColor = value;
+ textBlock.HoverColor = value;
+ }
+ }
+
public bool CaretEnabled;
public String Text
diff --git a/Subsurface/Source/Items/Components/Signal/Connection.cs b/Subsurface/Source/Items/Components/Signal/Connection.cs
index b604bc0ba..887dea405 100644
--- a/Subsurface/Source/Items/Components/Signal/Connection.cs
+++ b/Subsurface/Source/Items/Components/Signal/Connection.cs
@@ -325,10 +325,12 @@ namespace Barotrauma.Items.Components
if (index>-1 && wireComponent!=null && !Wires.Contains(wireComponent))
{
+ bool alreadyConnected = wireComponent.IsConnectedTo(item);
+
wireComponent.RemoveConnection(item);
Wires[index] = wireComponent;
- wireComponent.Connect(this);
+ wireComponent.Connect(this, !alreadyConnected);
}
}
//far away -> disconnect if the wire is linked to this connector
diff --git a/Subsurface/Source/Items/Components/Signal/LightComponent.cs b/Subsurface/Source/Items/Components/Signal/LightComponent.cs
index 6ab43eafa..433096815 100644
--- a/Subsurface/Source/Items/Components/Signal/LightComponent.cs
+++ b/Subsurface/Source/Items/Components/Signal/LightComponent.cs
@@ -13,13 +13,11 @@ namespace Barotrauma.Items.Components
private Color lightColor;
- //private Sprite sprite;
+ private LightSource light;
- LightSource light;
+ private float range;
- float range;
-
- float lightBrightness;
+ private float lightBrightness;
private float flicker;
@@ -81,18 +79,17 @@ namespace Barotrauma.Items.Components
public LightComponent(Item item, XElement element)
: base (item, element)
{
- //foreach (XElement subElement in element.Elements())
- //{
- // if (subElement.Name.ToString().ToLower() != "sprite") continue;
- // sprite = new Sprite(subElement);
- // break;
- //}
-
light = new LightSource(item.Position, 100.0f, Color.White, item.CurrentHull == null ? null : item.CurrentHull.Submarine);
IsActive = true;
- //lightColor = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One));
+ foreach (XElement subElement in element.Elements())
+ {
+ if (subElement.Name.ToString().ToLower() != "sprite") continue;
+ light.LightSprite = new Sprite(subElement);
+ light.LightSprite.Origin = light.LightSprite.size / 2.0f;
+ break;
+ }
}
public override void Update(float deltaTime, Camera cam)
@@ -101,9 +98,7 @@ namespace Barotrauma.Items.Components
if (item.CurrentHull != null)
{
light.Submarine = item.CurrentHull.Submarine;
- }
-
-
+ }
if (item.container != null)
{
diff --git a/Subsurface/Source/Items/Components/Signal/Wire.cs b/Subsurface/Source/Items/Components/Signal/Wire.cs
index 5d1c2b33c..6fa379a41 100644
--- a/Subsurface/Source/Items/Components/Signal/Wire.cs
+++ b/Subsurface/Source/Items/Components/Signal/Wire.cs
@@ -57,6 +57,12 @@ namespace Barotrauma.Items.Components
return null;
}
+ public bool IsConnectedTo(Item item)
+ {
+ if (connections[0] != null && connections[0].Item == item) return true;
+ return (connections[1] != null && connections[1].Item == item);
+ }
+
public void RemoveConnection(Item item)
{
for (int i = 0; i<2; i++)
diff --git a/Subsurface/Source/Map/Lights/LightManager.cs b/Subsurface/Source/Map/Lights/LightManager.cs
index 93eeba402..446f522c3 100644
--- a/Subsurface/Source/Map/Lights/LightManager.cs
+++ b/Subsurface/Source/Map/Lights/LightManager.cs
@@ -8,7 +8,16 @@ namespace Barotrauma.Lights
class LightManager
{
//public static Vector2 ViewPos;
- public static Entity ViewTarget;
+ private static Entity viewTarget;
+
+ public static Entity ViewTarget
+ {
+ get { return viewTarget; }
+ set {
+ if (viewTarget == value) return;
+ viewTarget = value;
+ }
+ }
public Color AmbientLight;
diff --git a/Subsurface/Source/Map/Lights/LightSource.cs b/Subsurface/Source/Map/Lights/LightSource.cs
index f0194a173..f867e7e63 100644
--- a/Subsurface/Source/Map/Lights/LightSource.cs
+++ b/Subsurface/Source/Map/Lights/LightSource.cs
@@ -19,6 +19,8 @@ namespace Barotrauma.Lights
private Texture2D texture;
+ public Sprite LightSprite;
+
public Entity Submarine;
//what was the range of the light when HullsInRange were last updated
@@ -85,7 +87,7 @@ namespace Barotrauma.Lights
this.range = range;
this.color = color;
- texture = lightTexture;
+ texture = LightTexture;
GameMain.LightManager.AddLight(this);
}
@@ -106,6 +108,11 @@ namespace Barotrauma.Lights
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)
+ {
+ LightSprite.Draw(spriteBatch, new Vector2(WorldPosition.X, -WorldPosition.Y), Color);
+ }
}
public void Remove()
diff --git a/Subsurface/Source/Map/SubmarineBody.cs b/Subsurface/Source/Map/SubmarineBody.cs
index 62efe1c17..41fa8f50a 100644
--- a/Subsurface/Source/Map/SubmarineBody.cs
+++ b/Subsurface/Source/Map/SubmarineBody.cs
@@ -35,7 +35,7 @@ namespace Barotrauma
private Body body;
- private Vector2 targetPosition;
+ private Vector2? targetPosition;
float mass = 10000.0f;
@@ -60,7 +60,7 @@ namespace Barotrauma
public Vector2 TargetPosition
{
- get { return targetPosition; }
+ //get { return targetPosition; }
set
{
if (!MathUtils.IsValid(value)) return;
@@ -210,26 +210,33 @@ namespace Barotrauma
public void Update(float deltaTime)
{
- if (targetPosition != Vector2.Zero && targetPosition != Position)
+ if (targetPosition != null && targetPosition != Position)
{
- float dist = Vector2.Distance(targetPosition, Position);
+ Vector2 targetSimPos = ConvertUnits.ToSimUnits((Vector2)targetPosition);
+ float dist = Vector2.Distance((Vector2)targetPosition, Position);
if (dist > 1000.0f)
{
- body.SetTransform(ConvertUnits.ToSimUnits(targetPosition), 0.0f);
- targetPosition = Vector2.Zero;
+ body.SetTransform(targetSimPos, 0.0f);
+ targetPosition = null;
}
else if (dist > 50.0f)
{
- body.SetTransform((ConvertUnits.ToSimUnits(targetPosition) - body.Position) * 0.01f, 0.0f);
+ Vector2 moveAmount = Vector2.Normalize(targetSimPos - body.Position);
+ moveAmount *= Math.Min(dist, 100.0f);
+
+ body.SetTransform(body.Position + moveAmount * deltaTime, 0.0f);
+ }
+ else
+ {
+ targetPosition = null;
}
}
else
{
- targetPosition = Vector2.Zero;
+ targetPosition = null;
}
-
//-------------------------
Vector2 totalForce = CalculateBuoyancy();
diff --git a/Subsurface/Source/Map/WayPoint.cs b/Subsurface/Source/Map/WayPoint.cs
index 96518f06a..ca740db60 100644
--- a/Subsurface/Source/Map/WayPoint.cs
+++ b/Subsurface/Source/Map/WayPoint.cs
@@ -15,6 +15,8 @@ namespace Barotrauma
{
public static List WayPointList = new List();
+ public static bool ShowWayPoints, ShowSpawnPoints;
+
private SpawnType spawnType;
//characters spawning at the waypoint will be given an ID card with these tags
@@ -84,6 +86,15 @@ namespace Barotrauma
{
if (!editing && !GameMain.DebugDraw) return;
+ if (spawnType == SpawnType.Path)
+ {
+ if (!GameMain.DebugDraw && !ShowWayPoints) return;
+ }
+ else
+ {
+ if (!GameMain.DebugDraw && !ShowSpawnPoints) return;
+ }
+
Rectangle drawRect =
Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height);
@@ -96,7 +107,7 @@ namespace Barotrauma
foreach (MapEntity e in linkedTo)
{
GUI.DrawLine(spriteBatch,
- new Vector2(drawRect.X, -drawRect.Y),
+ new Vector2(drawRect.X+rect.Width/2.0f, -drawRect.Y+rect.Height/2.0f),
new Vector2(e.DrawPosition.X, -e.DrawPosition.Y),
Color.Green);
}
diff --git a/Subsurface/Source/Particles/Particle.cs b/Subsurface/Source/Particles/Particle.cs
index 6481ef1e3..3cdf3ea91 100644
--- a/Subsurface/Source/Particles/Particle.cs
+++ b/Subsurface/Source/Particles/Particle.cs
@@ -271,7 +271,7 @@ namespace Barotrauma.Particles
prefab.Sprites[spriteIndex].Draw(spriteBatch,
new Vector2(drawPosition.X, -drawPosition.Y),
color * alpha,
- prefab.Sprites[spriteIndex].origin, drawRotation,
+ prefab.Sprites[spriteIndex].Origin, drawRotation,
drawSize, SpriteEffects.None, prefab.Sprites[spriteIndex].Depth);
prevPosition = position;
diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs
index 4ee8a0fe2..a83713ed8 100644
--- a/Subsurface/Source/Screens/EditMapScreen.cs
+++ b/Subsurface/Source/Screens/EditMapScreen.cs
@@ -143,28 +143,24 @@ namespace Barotrauma
}
-
- button = new GUIButton(new Rectangle(0, y+50, 0, 20), "Character mode", Alignment.Left, GUI.Style, GUIpanel);
+ y+=50;
+ button = new GUIButton(new Rectangle(0, y, 0, 20), "Character mode", Alignment.Left, GUI.Style, GUIpanel);
button.ToolTip = "Allows you to pick up and use items. Useful for things such as placing items inside closets, turning devices on/off and doing the wiring.";
button.OnClicked = ToggleCharacterMode;
-
- button = new GUIButton(new Rectangle(0, y+100, 0, 20), "Generate waypoints", Alignment.Left, GUI.Style, GUIpanel);
+
+ y+=50;
+ button = new GUIButton(new Rectangle(0, y, 0, 20), "Generate waypoints", Alignment.Left, GUI.Style, GUIpanel);
button.OnClicked = GenerateWaypoints;
+
+ y+=50;
+ new GUITextBlock(new Rectangle(0, y, 0, 20), "Show:", GUI.Style, GUIpanel);
-
- //GUItabs[0] = new GUIFrame(new Rectangle(GameMain.GraphicsWidth/2-width/2, GameMain.GraphicsHeight/2-height/2, width, height), GUI.Style);
- //GUItabs[0].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
- //GUIListBox itemList = new GUIListBox(new Rectangle(0, 0, 0, 0), Color.White * 0.7f, GUI.Style, GUItabs[0]);
- //itemList.OnSelected = SelectPrefab;
- //itemList.CheckSelected = MapEntityPrefab.GetSelected;
-
- //GUItabs[1] = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style);
- //GUItabs[1].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
- //GUIListBox structureList = new GUIListBox(new Rectangle(0, 0, 0, 0), Color.White * 0.7f, GUI.Style, GUItabs[1]);
- //structureList.OnSelected = SelectPrefab;
- //structureList.CheckSelected = MapEntityPrefab.GetSelected;
-
+ var tickBox = new GUITickBox(new Rectangle(0,y+20,20,20), "Waypoints", Alignment.TopLeft, GUIpanel);
+ tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowWayPoints = !WayPoint.ShowWayPoints; return true; };
+ tickBox = new GUITickBox(new Rectangle(0, y + 40, 20, 20), "Spawnpoints", Alignment.TopLeft, GUIpanel);
+ tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowSpawnPoints = !WayPoint.ShowSpawnPoints; return true; };
+
}
public override void Select()
diff --git a/Subsurface/Source/Sprite.cs b/Subsurface/Source/Sprite.cs
index 1d520df66..cbc1ed45e 100644
--- a/Subsurface/Source/Sprite.cs
+++ b/Subsurface/Source/Sprite.cs
@@ -22,7 +22,7 @@ namespace Barotrauma
//the offset used when drawing the sprite
Vector2 offset;
- public Vector2 origin;
+ private Vector2 origin;
//the size of the drawn sprite, if larger than the source,
//the sprite is tiled to fill the target size
@@ -43,7 +43,7 @@ namespace Barotrauma
public float Depth
{
get { return depth; }
- set { depth = Math.Min(Math.Max(value, 0.0f), 1.0f); }
+ set { depth = MathHelper.Clamp(value, 0.0f, 1.0f); }
}
public Vector2 Origin
diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo
index 807cd1d1b..eb1deec25 100644
Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ