diff --git a/Subsurface/Content/Items/Pump/pump.png b/Subsurface/Content/Items/Pump/pump.png
index 8fe06b478..8e7280aa3 100644
Binary files a/Subsurface/Content/Items/Pump/pump.png and b/Subsurface/Content/Items/Pump/pump.png differ
diff --git a/Subsurface/Content/Items/Weapons/railgun.xml b/Subsurface/Content/Items/Weapons/railgun.xml
index 50c33d30c..4d423b81d 100644
--- a/Subsurface/Content/Items/Weapons/railgun.xml
+++ b/Subsurface/Content/Items/Weapons/railgun.xml
@@ -32,12 +32,12 @@
linkable="true"
pickdistance="150">
-
+
-
-
-
+
+
+
diff --git a/Subsurface/Content/Items/Weapons/railguncontroller.png b/Subsurface/Content/Items/Weapons/railguncontroller.png
index c28517160..725051347 100644
Binary files a/Subsurface/Content/Items/Weapons/railguncontroller.png and b/Subsurface/Content/Items/Weapons/railguncontroller.png differ
diff --git a/Subsurface/Content/UI/style.xml b/Subsurface/Content/UI/style.xml
index 278857a32..52dcfec9d 100644
--- a/Subsurface/Content/UI/style.xml
+++ b/Subsurface/Content/UI/style.xml
@@ -28,7 +28,7 @@
diff --git a/Subsurface/Source/Characters/AI/PathFinder.cs b/Subsurface/Source/Characters/AI/PathFinder.cs
index d6ccf8b9e..8b3ab05c3 100644
--- a/Subsurface/Source/Characters/AI/PathFinder.cs
+++ b/Subsurface/Source/Characters/AI/PathFinder.cs
@@ -117,7 +117,7 @@ namespace Barotrauma
DebugConsole.ThrowError("Pathfinding error, couldn't find a start node");
return new SteeringPath();
}
-
+
closestDist = 0.0f;
PathNode endNode = null;
foreach (PathNode node in nodes)
diff --git a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs
index 061e02b30..9454cdb4f 100644
--- a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs
+++ b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs
@@ -151,6 +151,7 @@ namespace Barotrauma
UpdateClimbing();
break;
case Animation.UsingConstruction:
+ UpdateStanding();
break;
default:
if (inWater)
diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs
index 75dae6eb8..7989068f0 100644
--- a/Subsurface/Source/Characters/Character.cs
+++ b/Subsurface/Source/Characters/Character.cs
@@ -412,6 +412,12 @@ namespace Barotrauma
if (Info.PickedItemIDs[i] == 0) continue;
Item item = FindEntityByID(Info.PickedItemIDs[i]) as Item;
+
+ if (item==null)
+ {
+ int a = 1;
+ }
+
System.Diagnostics.Debug.Assert(item != null);
if (item == null) continue;
@@ -891,6 +897,7 @@ namespace Barotrauma
if (controlled == this)
{
+ Lights.LightManager.ViewTarget = this;
CharacterHUD.Update(deltaTime,this);
ControlLocalPlayer(deltaTime, cam);
}
@@ -1276,15 +1283,18 @@ namespace Barotrauma
if (secondaryHeld)
{
- Vector2 relativeCursorPosition = cursorPosition - Position;
+ Vector2 relativeCursorPosition = cursorPosition;
+ relativeCursorPosition -= Lights.LightManager.ViewTarget == null ? Position : Lights.LightManager.ViewTarget.Position;
- if (relativeCursorPosition.Length()>4950.0f)
+ if (relativeCursorPosition.Length()>500.0f)
{
- relativeCursorPosition = Vector2.Normalize(relativeCursorPosition) * 4950.0f;
+ relativeCursorPosition = Vector2.Normalize(relativeCursorPosition) * 495.0f;
}
- message.WriteRangedSingle(relativeCursorPosition.X, -5000.0f, 5000.0f, 16);
- message.WriteRangedSingle(relativeCursorPosition.Y, -5000.0f, 5000.0f, 16);
+ message.Write(Lights.LightManager.ViewTarget == null ? (ushort)0 : Lights.LightManager.ViewTarget.ID);
+
+ message.WriteRangedSingle(relativeCursorPosition.X, -500.0f, 500.0f, 8);
+ message.WriteRangedSingle(relativeCursorPosition.Y, -500.0f, 500.0f, 8);
}
else
{
@@ -1443,13 +1453,17 @@ namespace Barotrauma
float dir = 1.0f;
Vector2 pos = Vector2.Zero;
+ ushort viewTargetId = 0;
+
try
{
if (secondaryKeyState)
{
+ viewTargetId = message.ReadUInt16();
+
relativeCursorPos = new Vector2(
- message.ReadRangedSingle(-5000.0f, 5000.0f, 16),
- message.ReadRangedSingle(-5000.0f, 5000.0f, 16));
+ message.ReadRangedSingle(-500.0f, 500.0f, 8),
+ message.ReadRangedSingle(-500.0f, 500.0f, 8));
}
else
{
@@ -1481,8 +1495,12 @@ namespace Barotrauma
if (secondaryKeyState)
{
- cursorPosition = MathUtils.IsValid(relativeCursorPos) ?
- ConvertUnits.ToDisplayUnits(pos)+relativeCursorPos : Vector2.Zero;
+
+ cursorPosition = MathUtils.IsValid(relativeCursorPos) ? relativeCursorPos : Vector2.Zero;
+ Entity viewTarget = viewTargetId == 0 ? this : Entity.FindEntityByID(viewTargetId);
+ if (viewTarget == null) viewTarget = this;
+
+ cursorPosition += viewTarget.Position;
}
else
{
diff --git a/Subsurface/Source/GUI/GUI.cs b/Subsurface/Source/GUI/GUI.cs
index cfa5ea8c8..9d9b66a5b 100644
--- a/Subsurface/Source/GUI/GUI.cs
+++ b/Subsurface/Source/GUI/GUI.cs
@@ -425,11 +425,18 @@ namespace Barotrauma
msg.Pos = MathUtils.SmoothStep(msg.Pos, currPos, deltaTime*20.0f);
+ spriteBatch.DrawString(Font, msg.Text,
+ new Vector2((int)msg.Pos.X - 1, (int)msg.Pos.Y - 1),
+ Color.Black * alpha*0.5f, 0.0f,
+ new Vector2((int)(0.5f * msg.Size.X), (int)(0.5f * msg.Size.Y)), 1.0f, SpriteEffects.None, 0.0f);
+
spriteBatch.DrawString(Font, msg.Text,
new Vector2((int)msg.Pos.X, (int)msg.Pos.Y),
msg.Color * alpha, 0.0f,
new Vector2((int)(0.5f * msg.Size.X), (int)(0.5f * msg.Size.Y)), 1.0f, SpriteEffects.None, 0.0f);
+
+
currPos.Y += 30.0f;
messages[0].LifeTime -= deltaTime/i;
diff --git a/Subsurface/Source/GUI/GUIListBox.cs b/Subsurface/Source/GUI/GUIListBox.cs
index 7401f7bcf..d269010a5 100644
--- a/Subsurface/Source/GUI/GUIListBox.cs
+++ b/Subsurface/Source/GUI/GUIListBox.cs
@@ -158,13 +158,13 @@ namespace Barotrauma
scrollBar.BarScroll = 0.0f;
}
- public void Select(object selection)
+ public void Select(object selection, bool force = false)
{
for (int i = 0; i < children.Count; i++)
{
if (children[i].UserData != selection) continue;
- Select(i);
+ Select(i, force);
//if (OnSelected != null) OnSelected(Selected, Selected.UserData);
if (!SelectMultiple) return;
@@ -185,12 +185,13 @@ namespace Barotrauma
}
}
- public void Select(int childIndex)
+ public void Select(int childIndex, bool force = false)
{
if (childIndex >= children.Count || childIndex < 0) return;
bool wasSelected = true;
- if (OnSelected != null) wasSelected = OnSelected(children[childIndex], children[childIndex].UserData);
+ if (OnSelected != null) wasSelected = OnSelected(children[childIndex], children[childIndex].UserData) || force;
+
if (!wasSelected) return;
@@ -270,14 +271,14 @@ namespace Barotrauma
private void ShowScrollBar()
{
- if (scrollBarHidden) Rect = new Rectangle(rect.X, rect.Y, rect.Width - scrollBar.Rect.Width, rect.Height);
+ if (scrollBarHidden && !scrollBar.IsHorizontal) Rect = new Rectangle(rect.X, rect.Y, rect.Width - scrollBar.Rect.Width, rect.Height);
scrollBarHidden = false;
}
private void HideScrollBar()
{
- if (!scrollBarHidden) Rect = new Rectangle(rect.X, rect.Y, rect.Width + scrollBar.Rect.Width, rect.Height);
+ if (!scrollBarHidden && !scrollBar.IsHorizontal) Rect = new Rectangle(rect.X, rect.Y, rect.Width + scrollBar.Rect.Width, rect.Height);
scrollBarHidden = true;
}
@@ -297,7 +298,7 @@ namespace Barotrauma
scrollBar.Draw(spriteBatch);
if (scrollBar.IsHorizontal)
{
- x -= (int)((totalSize - rect.Height) * scrollBar.BarScroll);
+ x -= (int)((totalSize - rect.Width) * scrollBar.BarScroll);
}
else
{
@@ -322,14 +323,30 @@ namespace Barotrauma
child.Visible = false;
- if (child.Rect.Y + child.Rect.Height < rect.Y) continue;
- if (child.Rect.Y + child.Rect.Height > rect.Y + rect.Height) break;
-
- if (child.Rect.Y < rect.Y && child.Rect.Y + child.Rect.Height >= rect.Y)
+ if (scrollBar.IsHorizontal)
{
- y = rect.Y;
- continue;
+ if (child.Rect.Right < rect.X) continue;
+ if (child.Rect.Right > rect.Right) break;
+
+ if (child.Rect.X < rect.X && child.Rect.Right >= rect.X)
+ {
+ x = rect.X;
+ continue;
+ }
}
+ else
+ {
+ if (child.Rect.Y + child.Rect.Height < rect.Y) continue;
+ if (child.Rect.Y + child.Rect.Height > rect.Y + rect.Height) break;
+
+ if (child.Rect.Y < rect.Y && child.Rect.Y + child.Rect.Height >= rect.Y)
+ {
+ y = rect.Y;
+ continue;
+ }
+ }
+
+
child.Visible = true;
diff --git a/Subsurface/Source/GameSession/ShiftSummary.cs b/Subsurface/Source/GameSession/ShiftSummary.cs
index 42f4ff93f..7788aeb6f 100644
--- a/Subsurface/Source/GameSession/ShiftSummary.cs
+++ b/Subsurface/Source/GameSession/ShiftSummary.cs
@@ -64,26 +64,31 @@ namespace Barotrauma
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.8f);
- int width = 700, height = 400;
- GUIFrame innerFrame = new GUIFrame(new Rectangle(0,0,width,height), null, Alignment.Center, GUI.Style, frame);
+
+ int width = 760, height = 400;
+ GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, width, height), null, Alignment.Center, GUI.Style, frame);
+
int y = 0;
string summaryText = InfoTextManager.GetInfoText(gameOver ? "gameover" :
(progress ? "progress" : "return"));
- var infoText = new GUITextBlock(new Rectangle(0,y,0,50), summaryText, GUI.Style, innerFrame, true);
+ var infoText = new GUITextBlock(new Rectangle(0, y, 0, 50), summaryText, GUI.Style, innerFrame, true);
y += infoText.Rect.Height;
- new GUITextBlock(new Rectangle(0,y,0,20), "Crew status:", GUI.Style, innerFrame, GUI.LargeFont);
+ new GUITextBlock(new Rectangle(0, y, 0, 20), "Crew status:", GUI.Style, innerFrame, GUI.LargeFont);
y += 30;
+ GUIListBox listBox = new GUIListBox(new Rectangle(0,y,0,90), null, Alignment.TopLeft, GUI.Style, innerFrame, true);
+
int x = 0;
foreach (Character character in gameSession.CrewManager.characters)
{
- var characterFrame = new GUIFrame(new Rectangle(x,y,170,70), character.IsDead ? Color.DarkRed*0.7f : Color.Transparent, GUI.Style, innerFrame);
- characterFrame.Padding = new Vector4(5.0f,5.0f,5.0f,5.0f);
- character.Info.CreateCharacterFrame(characterFrame,
- character.Info.Job!=null ? (character.Info.Name + '\n'+"("+character.Info.Job.Name+")") : character.Info.Name, null);
+ var characterFrame = new GUIFrame(new Rectangle(x, y, 170, 70), character.IsDead ? Color.DarkRed * 0.7f : Color.Transparent, GUI.Style, listBox);
+ characterFrame.OutlineColor = Color.Transparent;
+ characterFrame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
+ character.Info.CreateCharacterFrame(characterFrame,
+ character.Info.Job != null ? (character.Info.Name + '\n' + "(" + character.Info.Job.Name + ")") : character.Info.Name, null);
string statusText;
Color statusColor;
@@ -100,30 +105,28 @@ namespace Barotrauma
statusText = (character.Health / character.MaxHealth > 0.8f) ? "OK" : "Injured";
statusColor = Color.DarkGreen;
}
-
- new GUITextBlock(new Rectangle(0,0,0,20), statusText,
- GUI.Style, Alignment.BottomLeft, Alignment.TopCenter, characterFrame, true, GUI.SmallFont).Color = statusColor*0.7f;
-
-
+
+ new GUITextBlock(new Rectangle(0, 0, 0, 20), statusText,
+ GUI.Style, Alignment.BottomLeft, Alignment.TopCenter, characterFrame, true, GUI.SmallFont).Color = statusColor * 0.7f;
+
x += characterFrame.Rect.Width + 10;
}
- y += 80;
+ y += 120;
if (GameMain.GameSession.Mission != null)
{
- new GUITextBlock(new Rectangle(0, y, 0, 20), "Mission: "+GameMain.GameSession.Mission.Name, GUI.Style, innerFrame, GUI.LargeFont);
+ new GUITextBlock(new Rectangle(0, y, 0, 20), "Mission: " + GameMain.GameSession.Mission.Name, GUI.Style, innerFrame, GUI.LargeFont);
y += 30;
-
- new GUITextBlock(new Rectangle(0,y,0,30),
+
+ new GUITextBlock(new Rectangle(0, y, 0, 30),
(GameMain.GameSession.Mission.Completed) ? GameMain.GameSession.Mission.SuccessMessage : GameMain.GameSession.Mission.FailureMessage,
GUI.Style, innerFrame);
if (GameMain.GameSession.Mission.Completed)
{
- new GUITextBlock(new Rectangle(0, y+40, 0, 30), "Reward: "+GameMain.GameSession.Mission.Reward, GUI.Style, innerFrame);
- }
-
+ new GUITextBlock(new Rectangle(0, y + 40, 0, 30), "Reward: " + GameMain.GameSession.Mission.Reward, GUI.Style, innerFrame);
+ }
}
return frame;
diff --git a/Subsurface/Source/Items/Components/Machines/Controller.cs b/Subsurface/Source/Items/Components/Machines/Controller.cs
index 0e8716283..14120a924 100644
--- a/Subsurface/Source/Items/Components/Machines/Controller.cs
+++ b/Subsurface/Source/Items/Components/Machines/Controller.cs
@@ -81,7 +81,9 @@ namespace Barotrauma.Items.Components
return;
}
- if (userPos != 0.0f && character.AnimController.Anim != AnimController.Animation.UsingConstruction)
+ character.AnimController.Anim = AnimController.Animation.UsingConstruction;
+
+ if (userPos != 0.0f)
{
float torsoX = ConvertUnits.ToDisplayUnits(character.AnimController.RefLimb.SimPosition.X);
@@ -89,12 +91,16 @@ namespace Barotrauma.Items.Components
if (diff!= Vector2.Zero && diff.Length() > 10.0f)
{
- character.AnimController.Anim = AnimController.Animation.None;
+ //character.AnimController.Anim = AnimController.Animation.None;
character.AnimController.TargetMovement = new Vector2(Math.Sign(diff.X), 0.0f);
character.AnimController.TargetDir = (Math.Sign(diff.X) == 1) ? Direction.Right : Direction.Left;
return;
}
+ else
+ {
+ character.AnimController.TargetMovement = Vector2.Zero;
+ }
}
ApplyStatusEffects(ActionType.OnActive, deltaTime, character);
@@ -103,6 +109,7 @@ namespace Barotrauma.Items.Components
character.AnimController.Anim = AnimController.Animation.UsingConstruction;
character.AnimController.ResetPullJoints();
+
if (dir != 0) character.AnimController.TargetDir = dir;
foreach (LimbPos lb in limbPositions)
@@ -110,6 +117,8 @@ namespace Barotrauma.Items.Components
Limb limb = character.AnimController.GetLimb(lb.limbType);
if (limb == null) continue;
+ limb.Disabled = true;
+
FixedMouseJoint fmj = limb.pullJoint;
if (fmj == null) continue;
@@ -138,7 +147,7 @@ namespace Barotrauma.Items.Components
public override void SecondaryUse(float deltaTime, Character character = null)
{
- if (this.character == null || this.character!=character || this.character.SelectedConstruction!=item)
+ if (this.character == null || this.character != character || this.character.SelectedConstruction != item)
{
character = null;
return;
@@ -150,13 +159,13 @@ namespace Barotrauma.Items.Components
foreach (Connection c2 in c.Recipients)
{
- if (c2 == null || c2.Item==null || !c2.Item.Prefab.FocusOnSelected) continue;
+ if (c2 == null || c2.Item == null || !c2.Item.Prefab.FocusOnSelected) continue;
Vector2 centerPos = c2.Item.WorldPosition;
if (character == Character.Controlled && cam != null)
{
- Lights.LightManager.ViewPos = centerPos;
+ Lights.LightManager.ViewTarget = c2.Item;
cam.TargetPos = c2.Item.WorldPosition;
}
diff --git a/Subsurface/Source/Items/Components/Machines/Radar.cs b/Subsurface/Source/Items/Components/Machines/Radar.cs
index d137a7f97..2a6798ae7 100644
--- a/Subsurface/Source/Items/Components/Machines/Radar.cs
+++ b/Subsurface/Source/Items/Components/Machines/Radar.cs
@@ -74,7 +74,7 @@ namespace Barotrauma.Items.Components
pingState = 0.0f;
}
- voltage = 0.0f;
+ voltage -= deltaTime;
}
public override bool Use(float deltaTime, Character character = null)
diff --git a/Subsurface/Source/Items/Components/Signal/Wire.cs b/Subsurface/Source/Items/Components/Signal/Wire.cs
index 4236a6f7d..5d1c2b33c 100644
--- a/Subsurface/Source/Items/Components/Signal/Wire.cs
+++ b/Subsurface/Source/Items/Components/Signal/Wire.cs
@@ -21,6 +21,7 @@ namespace Barotrauma.Items.Components
private Vector2 newNodePos;
+ private static Wire draggingWire;
private static int? selectedNodeIndex;
public Wire(Item item, XElement element)
@@ -310,31 +311,34 @@ namespace Barotrauma.Items.Components
//nodes.Add(newNodePos);
}
- if (!editing) return;
+ if (!editing || !PlayerInput.MouseInsideWindow) return;
- for (int i = 1; i < Nodes.Count; i++)
+ for (int i = 0; i < Nodes.Count; i++)
{
Vector2 worldPos = Nodes[i];
- if (item.Submarine != null) worldPos += item.Submarine.Position;
+ if (item.Submarine != null) worldPos += item.Submarine.Position + Submarine.HiddenSubPosition;
worldPos.Y = -worldPos.Y;
- GUI.DrawRectangle(spriteBatch, worldPos+new Vector2(-3,-3), new Vector2(6, 6), Color.Red, true, 0.0f);
+ GUI.DrawRectangle(spriteBatch, worldPos + new Vector2(-3, -3), new Vector2(6, 6), item.Color, true, 0.0f);
if (GUIComponent.MouseOn != null ||
- Vector2.Distance(GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), Nodes[i]) > 10.0f)
+ Vector2.Distance(GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), new Vector2(worldPos.X, -worldPos.Y)) > 10.0f)
{
continue;
}
+
+ MapEntity.DisableSelect = true;
GUI.DrawRectangle(spriteBatch, worldPos + new Vector2(-10, -10), new Vector2(20, 20), Color.Red, false, 0.0f);
- if (selectedNodeIndex == null && !MapEntity.SelectedAny)
+ if (selectedNodeIndex == null && draggingWire == null)// && !MapEntity.SelectedAny)
{
if (PlayerInput.LeftButtonDown() && PlayerInput.GetOldMouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released)
{
MapEntity.SelectEntity(item);
+ draggingWire = this;
selectedNodeIndex = i;
- MapEntity.DisableSelect = true;
+ break;
}
else if (PlayerInput.RightButtonClicked())
{
@@ -346,22 +350,27 @@ namespace Barotrauma.Items.Components
if (PlayerInput.LeftButtonDown())
{
- if (selectedNodeIndex != null && item.IsSelected)
+ if (selectedNodeIndex != null && draggingWire == this)
{
MapEntity.DisableSelect = true;
- Nodes[(int)selectedNodeIndex] = GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
+ //Nodes[(int)selectedNodeIndex] = GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition)-Submarine.HiddenSubPosition+Submarine.Loaded.Position;
- Vector2 nodeWorldPos = Nodes[(int)selectedNodeIndex];
+ Vector2 nodeWorldPos = GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition) - Submarine.HiddenSubPosition - Submarine.Loaded.Position;// Nodes[(int)selectedNodeIndex];
- if (item.Submarine != null) nodeWorldPos += item.Submarine.Position;
+ nodeWorldPos.X = MathUtils.Round(nodeWorldPos.X, Submarine.GridSize.X/2.0f);
+ nodeWorldPos.Y = MathUtils.Round(nodeWorldPos.Y, Submarine.GridSize.Y/2.0f);
+
+ //if (item.Submarine != null) nodeWorldPos += item.Submarine.Position;
+
+ Nodes[(int)selectedNodeIndex] = nodeWorldPos;
- Nodes[(int)selectedNodeIndex] = RoundNode(Nodes[(int)selectedNodeIndex], Hull.FindHull(nodeWorldPos));
MapEntity.SelectEntity(item);
}
}
else
{
selectedNodeIndex = null;
+ draggingWire = null;
}
}
diff --git a/Subsurface/Source/Items/Components/Turret.cs b/Subsurface/Source/Items/Components/Turret.cs
index 3515b3062..c1e69f169 100644
--- a/Subsurface/Source/Items/Components/Turret.cs
+++ b/Subsurface/Source/Items/Components/Turret.cs
@@ -134,7 +134,7 @@ namespace Barotrauma.Items.Components
var projectiles = GetLoadedProjectiles(true);
if (projectiles.Count == 0) return false;
- if (GetAvailablePower() < currPowerConsumption) return false;
+ if (GetAvailablePower() < powerConsumption) return false;
var batteries = item.GetConnectedComponents();
diff --git a/Subsurface/Source/Map/Lights/LightManager.cs b/Subsurface/Source/Map/Lights/LightManager.cs
index e2d905acf..93eeba402 100644
--- a/Subsurface/Source/Map/Lights/LightManager.cs
+++ b/Subsurface/Source/Map/Lights/LightManager.cs
@@ -7,7 +7,8 @@ namespace Barotrauma.Lights
{
class LightManager
{
- public static Vector2 ViewPos;
+ //public static Vector2 ViewPos;
+ public static Entity ViewTarget;
public Color AmbientLight;
@@ -58,9 +59,11 @@ namespace Barotrauma.Lights
lights.Remove(light);
}
- public void DrawLOS(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, Vector2 pos)
+ public void DrawLOS(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam)
{
- if (!LosEnabled) return;
+ if (!LosEnabled || ViewTarget==null) return;
+
+ Vector2 pos = ViewTarget.WorldPosition;
Rectangle camView = new Rectangle(cam.WorldView.X, cam.WorldView.Y - cam.WorldView.Height, cam.WorldView.Width, cam.WorldView.Height);
@@ -167,13 +170,13 @@ namespace Barotrauma.Lights
spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, cam.Transform);
- Vector2 diff = lookAtPosition - ViewPos;
+ Vector2 diff = lookAtPosition - ViewTarget.WorldPosition;
diff.Y = -diff.Y;
float rotation = MathUtils.VectorToAngle(diff);
Vector2 scale = new Vector2(MathHelper.Clamp(diff.Length()/256.0f, 2.0f, 5.0f), 2.0f);
-
- spriteBatch.Draw(visionCircle, new Vector2(ViewPos.X, -ViewPos.Y), null, Color.White, rotation,
+
+ spriteBatch.Draw(visionCircle, new Vector2(ViewTarget.WorldPosition.X, -ViewTarget.WorldPosition.Y), null, Color.White, rotation,
new Vector2(LightSource.LightTexture.Width*0.2f, LightSource.LightTexture.Height/2), scale, SpriteEffects.None, 0.0f);
spriteBatch.End();
diff --git a/Subsurface/Source/Map/MapEntity.cs b/Subsurface/Source/Map/MapEntity.cs
index 9877f463b..0808d1021 100644
--- a/Subsurface/Source/Map/MapEntity.cs
+++ b/Subsurface/Source/Map/MapEntity.cs
@@ -232,21 +232,19 @@ namespace Barotrauma
///
public static void UpdateSelecting(Camera cam)
{
- if (DisableSelect)
- {
- DisableSelect = false;
- return;
- }
-
foreach (MapEntity e in mapEntityList)
{
e.isHighlighted = false;
e.isSelected = false;
}
- if (GUIComponent.MouseOn != null) return;
-
+ if (DisableSelect)
+ {
+ DisableSelect = false;
+ return;
+ }
+ if (GUIComponent.MouseOn != null || !PlayerInput.MouseInsideWindow) return;
if (MapEntityPrefab.Selected != null)
{
@@ -261,8 +259,7 @@ namespace Barotrauma
selectedList.Clear();
}
- Vector2 position = new Vector2(PlayerInput.GetMouseState.X, PlayerInput.GetMouseState.Y);
- position = cam.ScreenToWorld(position);
+ Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
MapEntity highLightedEntity = null;
diff --git a/Subsurface/Source/Map/SubmarineBody.cs b/Subsurface/Source/Map/SubmarineBody.cs
index 7eba2e664..62efe1c17 100644
--- a/Subsurface/Source/Map/SubmarineBody.cs
+++ b/Subsurface/Source/Map/SubmarineBody.cs
@@ -312,11 +312,11 @@ namespace Barotrauma
(Rand.Int(2) == 0) ? Borders.Y : Borders.Y - Borders.Height);
}
+ damagePos += submarine.Position + Submarine.HiddenSubPosition;
SoundPlayer.PlayDamageSound(DamageSoundType.Pressure, 50.0f, damagePos, 10000.0f);
GameMain.GameScreen.Cam.Shake = depth * PressureDamageMultiplier * 0.1f;
- damagePos += submarine.Position + Submarine.HiddenSubPosition;
Explosion.RangedStructureDamage(damagePos, depth * PressureDamageMultiplier * 50.0f, depth * PressureDamageMultiplier);
//SoundPlayer.PlayDamageSound(DamageSoundType.StructureBlunt, Rand.Range(0.0f, 100.0f), damagePos, 5000.0f);
diff --git a/Subsurface/Source/Map/WayPoint.cs b/Subsurface/Source/Map/WayPoint.cs
index 772f6641b..96518f06a 100644
--- a/Subsurface/Source/Map/WayPoint.cs
+++ b/Subsurface/Source/Map/WayPoint.cs
@@ -249,6 +249,56 @@ namespace Barotrauma
}
}
+ float outSideWaypointInterval = 200.0f;
+ int outsideWaypointDist = 100;
+
+ Rectangle borders = new Rectangle(Submarine.Borders.X - outsideWaypointDist, Submarine.Borders.Y + outsideWaypointDist,
+ Submarine.Borders.Width + outsideWaypointDist*2, Submarine.Borders.Height+outsideWaypointDist*2);
+
+ WayPoint[,] cornerWaypoint = new WayPoint[2,2];
+ for (int i = 0; i<2; i++)
+ {
+ for (float x = borders.X + outSideWaypointInterval; x < borders.Right - outSideWaypointInterval; x += outSideWaypointInterval)
+ {
+ var wayPoint = new WayPoint(
+ new Vector2(x, borders.Y - borders.Height * i) + Submarine.HiddenSubPosition,
+ SpawnType.Path, Submarine.Loaded);
+ if (x == borders.X + outSideWaypointInterval)
+ {
+ cornerWaypoint[i, 0] = wayPoint;
+ }
+ else
+ {
+ wayPoint.ConnectTo(WayPoint.WayPointList[WayPointList.Count-2]);
+ }
+ }
+
+ cornerWaypoint[i, 1] = WayPoint.WayPointList[WayPointList.Count - 1];
+ }
+
+ for (int i = 0; i < 2; i++)
+ {
+ WayPoint wayPoint = null;
+ for (float y = borders.Y - borders.Height; y < borders.Y; y += outSideWaypointInterval)
+ {
+ wayPoint = new WayPoint(
+ new Vector2(borders.X + borders.Width * i, y) + Submarine.HiddenSubPosition,
+ SpawnType.Path, Submarine.Loaded);
+ if (y == borders.Y - borders.Height)
+ {
+ wayPoint.ConnectTo(cornerWaypoint[1, i]);
+ }
+ else
+ {
+ wayPoint.ConnectTo(WayPoint.WayPointList[WayPointList.Count - 2]);
+
+ }
+
+ }
+
+ wayPoint.ConnectTo(cornerWaypoint[0, i]);
+ }
+
List stairList = new List();
foreach (MapEntity me in MapEntity.mapEntityList)
{
@@ -292,7 +342,7 @@ namespace Barotrauma
for (int dir = -1; dir <= 1; dir += 2)
{
- WayPoint closest = wayPoint.FindClosest(dir, true, 30.0f);
+ WayPoint closest = wayPoint.FindClosest(dir, true, gap.IsRoomToRoom ? 30.0f : outSideWaypointInterval/2.0f);
if (closest == null) continue;
wayPoint.ConnectTo(closest);
}
diff --git a/Subsurface/Source/PlayerInput.cs b/Subsurface/Source/PlayerInput.cs
index 3d0eb8d1f..c545b22ca 100644
--- a/Subsurface/Source/PlayerInput.cs
+++ b/Subsurface/Source/PlayerInput.cs
@@ -222,6 +222,11 @@ namespace Barotrauma
get { return oldMouseState; }
}
+ public static bool MouseInsideWindow
+ {
+ get { return new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight).Contains(MousePosition); }
+ }
+
public static Vector2 MouseSpeed
{
get
diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs
index 37fc2371d..4ee8a0fe2 100644
--- a/Subsurface/Source/Screens/EditMapScreen.cs
+++ b/Subsurface/Source/Screens/EditMapScreen.cs
@@ -26,10 +26,10 @@ namespace Barotrauma
get { return cam; }
}
- public string GetSubName()
- {
- return ((Submarine.Loaded == null) ? "" : Submarine.Loaded.Name);
- }
+ //public string GetSubName()
+ //{
+ // return ((Submarine.Loaded == null) ? "" : Submarine.Loaded.Name);
+ //}
private string GetItemCount()
{
@@ -64,6 +64,7 @@ namespace Barotrauma
new GUITextBlock(new Rectangle(0, 20, 0, 20), "Submarine:", GUI.Style, GUIpanel);
nameBox = new GUITextBox(new Rectangle(0, 40, 0, 20), GUI.Style, GUIpanel);
+ nameBox.OnEnterPressed = ChangeSubName;
//nameBlock.TextGetter = GetSubName;
GUIButton button = new GUIButton(new Rectangle(0,70,0,20), "Save", GUI.Style, GUIpanel);
@@ -227,6 +228,8 @@ namespace Barotrauma
}
Submarine.SaveCurrent(nameBox.Text + ".sub");
+
+ GUI.AddMessage("Submarine saved to " + Submarine.Loaded.FilePath, Color.DarkGreen, 3.0f);
return false;
@@ -271,6 +274,16 @@ namespace Barotrauma
return true;
}
+ private bool ChangeSubName(GUITextBox textBox, string text)
+ {
+ if (Submarine.Loaded != null) Submarine.Loaded.Name = text;
+ textBox.Deselect();
+
+ textBox.Text = text;
+
+ return true;
+ }
+
private bool SelectPrefab(GUIComponent component, object obj)
{
MapEntityPrefab.SelectPrefab(obj);
diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs
index 3e2649c02..91e3c8d71 100644
--- a/Subsurface/Source/Screens/GameScreen.cs
+++ b/Subsurface/Source/Screens/GameScreen.cs
@@ -135,10 +135,10 @@ namespace Barotrauma
while (Physics.accumulator >= Physics.step)
{
cam.MoveCamera((float)Physics.step);
- if (Character.Controlled != null)
+ if (Character.Controlled != null && Lights.LightManager.ViewTarget != null)
{
- cam.TargetPos = Character.Controlled.WorldPosition;
- Lights.LightManager.ViewPos = Character.Controlled.WorldPosition;
+ cam.TargetPos = Lights.LightManager.ViewTarget.WorldPosition;
+ //Lights.LightManager.ViewPos = Character.Controlled.WorldPosition;
}
if (Submarine.Loaded != null) Submarine.Loaded.SetPrevTransform(Submarine.Loaded.Position);
@@ -213,9 +213,11 @@ namespace Barotrauma
GameMain.LightManager.ObstructVision = Character.Controlled != null && Character.Controlled.ObstructVision;
GameMain.LightManager.UpdateLightMap(graphics, spriteBatch, cam);
- GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam,
- Character.Controlled==null ? LightManager.ViewPos : Character.Controlled.CursorWorldPosition);
-
+ if (Character.Controlled!=null)
+ {
+ GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled.CursorWorldPosition);
+ }
+
//----------------------------------------------------------------------------------------
//1. draw the background, characters and the parts of the submarine that are behind them
@@ -335,7 +337,7 @@ namespace Barotrauma
spriteBatch.End();
- GameMain.LightManager.DrawLOS(graphics, spriteBatch, cam, LightManager.ViewPos);
+ GameMain.LightManager.DrawLOS(graphics, spriteBatch, cam);
}
}
}
diff --git a/Subsurface/Source/Screens/LobbyScreen.cs b/Subsurface/Source/Screens/LobbyScreen.cs
index 8c115b1c7..d00e4e90c 100644
--- a/Subsurface/Source/Screens/LobbyScreen.cs
+++ b/Subsurface/Source/Screens/LobbyScreen.cs
@@ -537,7 +537,7 @@ namespace Barotrauma
private IEnumerable