diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj
index e324edba1..c4c48d9c9 100644
--- a/Subsurface/Barotrauma.csproj
+++ b/Subsurface/Barotrauma.csproj
@@ -122,6 +122,7 @@
+
@@ -1048,6 +1049,9 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest
diff --git a/Subsurface/Content/Items/Artifacts/aliendoor.ogg b/Subsurface/Content/Items/Artifacts/aliendoor.ogg
new file mode 100644
index 000000000..50013e009
Binary files /dev/null and b/Subsurface/Content/Items/Artifacts/aliendoor.ogg differ
diff --git a/Subsurface/Content/Items/Artifacts/artifacts.xml b/Subsurface/Content/Items/Artifacts/artifacts.xml
index 4d733d6e2..db383e154 100644
--- a/Subsurface/Content/Items/Artifacts/artifacts.xml
+++ b/Subsurface/Content/Items/Artifacts/artifacts.xml
@@ -144,4 +144,61 @@
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Subsurface/Content/Map/RuinConfig.xml b/Subsurface/Content/Map/RuinConfig.xml
index 82645b337..1b97eb801 100644
--- a/Subsurface/Content/Map/RuinConfig.xml
+++ b/Subsurface/Content/Map/RuinConfig.xml
@@ -20,5 +20,7 @@
-
+
+
+
\ No newline at end of file
diff --git a/Subsurface/Content/Map/StructurePrefabs.xml b/Subsurface/Content/Map/StructurePrefabs.xml
index 1c3b75238..aad9b4f8f 100644
--- a/Subsurface/Content/Map/StructurePrefabs.xml
+++ b/Subsurface/Content/Map/StructurePrefabs.xml
@@ -109,16 +109,17 @@
+
-
-
diff --git a/Subsurface/Content/Map/ruins.png b/Subsurface/Content/Map/ruins.png
index 08f38ca14..01076d5c9 100644
Binary files a/Subsurface/Content/Map/ruins.png and b/Subsurface/Content/Map/ruins.png differ
diff --git a/Subsurface/Source/Items/Components/Door.cs b/Subsurface/Source/Items/Components/Door.cs
index e130dd930..6f51ce370 100644
--- a/Subsurface/Source/Items/Components/Door.cs
+++ b/Subsurface/Source/Items/Components/Door.cs
@@ -127,13 +127,14 @@ namespace Barotrauma.Items.Components
// isOpen = false;
foreach (XElement subElement in element.Elements())
{
+ string texturePath = ToolBox.GetAttributeString(subElement, "texture", "");
switch (subElement.Name.ToString().ToLowerInvariant())
{
case "sprite":
- doorSprite = new Sprite(subElement, Path.GetDirectoryName(item.Prefab.ConfigFile));
+ doorSprite = new Sprite(subElement, texturePath.Contains("/") ? "" : Path.GetDirectoryName(item.Prefab.ConfigFile));
break;
case "weldedsprite":
- weldedSprite = new Sprite(subElement, Path.GetDirectoryName(item.Prefab.ConfigFile));
+ weldedSprite = new Sprite(subElement, texturePath.Contains("/") ? "" : Path.GetDirectoryName(item.Prefab.ConfigFile));
break;
}
}
@@ -336,7 +337,7 @@ namespace Barotrauma.Items.Components
pos.Y = -pos.Y;
spriteBatch.Draw(doorSprite.Texture, pos,
- new Rectangle(doorSprite.SourceRect.X, (int)(doorSprite.size.Y * openState),
+ new Rectangle(doorSprite.SourceRect.X, (int)(doorSprite.SourceRect.Y + doorSprite.size.Y * openState),
(int)doorSprite.size.X, (int)(doorSprite.size.Y * (1.0f - openState))),
color, 0.0f, doorSprite.Origin, 1.0f, SpriteEffects.None, doorSprite.Depth);
}
@@ -346,6 +347,7 @@ namespace Barotrauma.Items.Components
public override void OnMapLoaded()
{
LinkedGap.ConnectedDoor = this;
+ LinkedGap.Open = openState;
Vector2[] corners = GetConvexHullCorners(doorRect);
diff --git a/Subsurface/Source/Items/Components/Signal/MotionSensor.cs b/Subsurface/Source/Items/Components/Signal/MotionSensor.cs
new file mode 100644
index 000000000..982302616
--- /dev/null
+++ b/Subsurface/Source/Items/Components/Signal/MotionSensor.cs
@@ -0,0 +1,91 @@
+using Microsoft.Xna.Framework;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace Barotrauma.Items.Components
+{
+ class MotionSensor : ItemComponent
+ {
+ private const float UpdateInterval = 0.1f;
+
+ private string output, falseOutput;
+
+ private bool motionDetected;
+
+ private float range;
+
+ private float updateTimer;
+
+ [InGameEditable, HasDefaultValue(0.0f, true)]
+ public float Range
+ {
+ get { return range; }
+ set
+ {
+ range = MathHelper.Clamp(value, 0.0f, 500.0f);
+ }
+ }
+
+ [InGameEditable, HasDefaultValue("1", true)]
+ public string Output
+ {
+ get { return output; }
+ set { output = value; }
+ }
+
+ [InGameEditable, HasDefaultValue("", true)]
+ public string FalseOutput
+ {
+ get { return falseOutput; }
+ set { falseOutput = value; }
+ }
+
+ public MotionSensor(Item item, XElement element)
+ : base (item, element)
+ {
+ IsActive = true;
+ }
+
+ public override void Update(float deltaTime, Camera cam)
+ {
+ if (motionDetected)
+ {
+ item.SendSignal(1, output, "state_out");
+ }
+ else if (!string.IsNullOrWhiteSpace(falseOutput))
+ {
+ item.SendSignal(1, falseOutput, "state_out");
+ }
+
+ updateTimer -= deltaTime;
+ if (updateTimer>0.0f) return;
+
+ motionDetected = false;
+ updateTimer = UpdateInterval;
+
+ if (item.body != null && item.body.Enabled)
+ {
+ if (Math.Abs(item.body.LinearVelocity.X) > 0.01f || Math.Abs(item.body.LinearVelocity.Y) > 0.1f)
+ {
+ motionDetected = true;
+ }
+ }
+
+ foreach (Character c in Character.CharacterList)
+ {
+ if (Math.Abs(c.WorldPosition.X - item.WorldPosition.X) < range &&
+ Math.Abs(c.WorldPosition.Y - item.WorldPosition.Y) < range)
+ {
+ if (!c.AnimController.Limbs.Any(l => l.body.FarseerBody.Awake)) continue;
+
+ motionDetected = true;
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs
index 05396c507..20683d075 100644
--- a/Subsurface/Source/Map/Levels/Level.cs
+++ b/Subsurface/Source/Map/Levels/Level.cs
@@ -175,11 +175,12 @@ namespace Barotrauma
Rand.SetSyncedSeed(ToolBox.StringToInt(seed));
float brightness = Rand.Range(1.0f, 1.3f, false);
- backgroundColor = Color.Lerp(new Color(11, 18, 26), new Color(11, 26, 18), Rand.Range(0.0f, 1.0f, false)) * brightness;
-
-
+ backgroundColor = Color.Lerp(new Color(11, 18, 26), new Color(50, 46, 20), Rand.Range(0.0f, 1.0f, false)) * brightness;
backgroundColor = new Color(backgroundColor, 1.0f);
+ float avgValue = (backgroundColor.R + backgroundColor.G + backgroundColor.G) / 3;
+ GameMain.LightManager.AmbientLight = new Color(backgroundColor*(40.0f/avgValue), 1.0f);
+
float minWidth = Submarine.Loaded == null ? 0.0f : Math.Max(Submarine.Borders.Width, Submarine.Borders.Height);
minWidth = Math.Max(minWidth, 6500.0f);
@@ -789,7 +790,7 @@ namespace Barotrauma
public void Update (float deltaTime)
{
- if (Submarine.Loaded!=null)
+ if (Submarine.Loaded != null)
{
WrappingWall.UpdateWallShift(Submarine.Loaded.WorldPosition, wrappingWalls);
}
@@ -879,6 +880,8 @@ namespace Barotrauma
if (renderer!=null) renderer.Dispose();
renderer = null;
+ ruins.Clear();
+
for (int side = 0; side < 2; side++)
{
for (int i = 0; i < 2; i++)
diff --git a/Subsurface/Source/Map/Levels/Ruins/RuinGenerator.cs b/Subsurface/Source/Map/Levels/Ruins/RuinGenerator.cs
index 9d9318642..7b5103efc 100644
--- a/Subsurface/Source/Map/Levels/Ruins/RuinGenerator.cs
+++ b/Subsurface/Source/Map/Levels/Ruins/RuinGenerator.cs
@@ -412,6 +412,42 @@ namespace Barotrauma.RuinGeneration
}
}
+ var sensorPrefab = ItemPrefab.list.Find(ip => ip.Name == "Alien Motion Sensor") as ItemPrefab;
+ var wirePrefab = ItemPrefab.list.Find(ip => ip.Name == "Wire") as ItemPrefab;
+
+
+ foreach (Corridor corridor in corridors)
+ {
+ var door = RuinStructure.GetRandom(corridor.IsHorizontal ? RuinStructureType.Door : RuinStructureType.Hatch, Alignment.Center);
+ if (door == null) continue;
+
+ var item = new Item(door.Prefab as ItemPrefab, corridor.Center - new Vector2(door.Prefab.sprite.size.X, -door.Prefab.sprite.size.Y)/2.0f, null);
+ item.MoveWithLevel = true;
+
+ item.GetComponent().IsOpen = Rand.Range(0.0f, 1.0f, false) < 0.8f;
+
+ if (sensorPrefab == null || wirePrefab == null) continue;
+
+ var sensorRoom = corridor.ConnectedRooms.FirstOrDefault(r => r != null && rooms.Contains(r));
+ if (sensorRoom == null) continue;
+
+ var sensor = new Item(sensorPrefab, new Vector2(
+ Rand.Range(sensorRoom.Rect.X, sensorRoom.Rect.Right, false),
+ Rand.Range(sensorRoom.Rect.Y, sensorRoom.Rect.Bottom,false)), null);
+ sensor.MoveWithLevel = true;
+
+ var wire = new Item(wirePrefab, sensorRoom.Center, null).GetComponent();
+ wire.Item.MoveWithLevel = false;
+
+ var conn1 = item.Connections.Find(c => c.Name == "set_state");
+ conn1.AddLink(0, wire);
+ wire.Connect(conn1, false);
+
+ var conn2 = sensor.Connections.Find(c => c.Name == "state_out");
+ conn2.AddLink(0, wire);
+ wire.Connect(conn2, false);
+ }
+
return shapes;
}
diff --git a/Subsurface/Source/Map/Levels/Ruins/RuinStructure.cs b/Subsurface/Source/Map/Levels/Ruins/RuinStructure.cs
index 361d0c658..48a5d7ed2 100644
--- a/Subsurface/Source/Map/Levels/Ruins/RuinStructure.cs
+++ b/Subsurface/Source/Map/Levels/Ruins/RuinStructure.cs
@@ -10,7 +10,7 @@ namespace Barotrauma.RuinGeneration
[Flags]
enum RuinStructureType
{
- Wall = 1, CorridorWall = 2, Prop = 4, Back = 8
+ Wall = 1, CorridorWall = 2, Prop = 4, Back = 8, Door=16, Hatch=32
}
class RuinStructure