New pump & railguncont sprites, saving fixes (disappearing items fixed?), moving LightManager.ViewPos to railgun when aiming, generating waypoints outside sub, easier wire node editing, characters stand when using a controller, shiftsummary crew status scrolling, stuff

This commit is contained in:
Regalis
2016-01-04 01:03:37 +02:00
parent cb1513f5e6
commit bc9ff32023
29 changed files with 279 additions and 126 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 16 KiB

+4 -4
View File
@@ -32,12 +32,12 @@
linkable="true" linkable="true"
pickdistance="150"> pickdistance="150">
<Sprite texture ="railguncontroller.png" depth="0.8"/> <Sprite texture ="railguncontroller.png" depth="0.8" sourcerect="0,0,61,97"/>
<Controller UserPos="-1.0" direction ="Right" canbeselected = "true"> <Controller UserPos="-1.0" direction ="Right" canbeselected = "true">
<limbposition limb="Head" position="0,-124"/> <limbposition limb="Head" position="-5,-62"/>
<limbposition limb="LeftHand" position="38,-125"/> <limbposition limb="LeftHand" position="43,-85"/>
<limbposition limb="RightHand" position="38,-125"/> <limbposition limb="RightHand" position="43,-85"/>
</Controller> </Controller>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]"> <ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

+1 -1
View File
@@ -28,7 +28,7 @@
<GUITextBlock <GUITextBlock
textcolor="1.0, 1.0, 1.0, 1.0" textcolor="1.0, 1.0, 1.0, 1.0"
hovercolor="1.0, 1.0, 1.0, 0.3" hovercolor="0.3, 0.3, 0.3, 0.5"
selectedcolor="1.0, 0.6, 0.0, 0.3" selectedcolor="1.0, 0.6, 0.0, 0.3"
padding="10.0, 0.0, 10.0, 0.0"/> padding="10.0, 0.0, 10.0, 0.0"/>
@@ -117,7 +117,7 @@ namespace Barotrauma
DebugConsole.ThrowError("Pathfinding error, couldn't find a start node"); DebugConsole.ThrowError("Pathfinding error, couldn't find a start node");
return new SteeringPath(); return new SteeringPath();
} }
closestDist = 0.0f; closestDist = 0.0f;
PathNode endNode = null; PathNode endNode = null;
foreach (PathNode node in nodes) foreach (PathNode node in nodes)
@@ -151,6 +151,7 @@ namespace Barotrauma
UpdateClimbing(); UpdateClimbing();
break; break;
case Animation.UsingConstruction: case Animation.UsingConstruction:
UpdateStanding();
break; break;
default: default:
if (inWater) if (inWater)
+27 -9
View File
@@ -412,6 +412,12 @@ namespace Barotrauma
if (Info.PickedItemIDs[i] == 0) continue; if (Info.PickedItemIDs[i] == 0) continue;
Item item = FindEntityByID(Info.PickedItemIDs[i]) as Item; Item item = FindEntityByID(Info.PickedItemIDs[i]) as Item;
if (item==null)
{
int a = 1;
}
System.Diagnostics.Debug.Assert(item != null); System.Diagnostics.Debug.Assert(item != null);
if (item == null) continue; if (item == null) continue;
@@ -891,6 +897,7 @@ namespace Barotrauma
if (controlled == this) if (controlled == this)
{ {
Lights.LightManager.ViewTarget = this;
CharacterHUD.Update(deltaTime,this); CharacterHUD.Update(deltaTime,this);
ControlLocalPlayer(deltaTime, cam); ControlLocalPlayer(deltaTime, cam);
} }
@@ -1276,15 +1283,18 @@ namespace Barotrauma
if (secondaryHeld) 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.Write(Lights.LightManager.ViewTarget == null ? (ushort)0 : Lights.LightManager.ViewTarget.ID);
message.WriteRangedSingle(relativeCursorPosition.Y, -5000.0f, 5000.0f, 16);
message.WriteRangedSingle(relativeCursorPosition.X, -500.0f, 500.0f, 8);
message.WriteRangedSingle(relativeCursorPosition.Y, -500.0f, 500.0f, 8);
} }
else else
{ {
@@ -1443,13 +1453,17 @@ namespace Barotrauma
float dir = 1.0f; float dir = 1.0f;
Vector2 pos = Vector2.Zero; Vector2 pos = Vector2.Zero;
ushort viewTargetId = 0;
try try
{ {
if (secondaryKeyState) if (secondaryKeyState)
{ {
viewTargetId = message.ReadUInt16();
relativeCursorPos = new Vector2( relativeCursorPos = new Vector2(
message.ReadRangedSingle(-5000.0f, 5000.0f, 16), message.ReadRangedSingle(-500.0f, 500.0f, 8),
message.ReadRangedSingle(-5000.0f, 5000.0f, 16)); message.ReadRangedSingle(-500.0f, 500.0f, 8));
} }
else else
{ {
@@ -1481,8 +1495,12 @@ namespace Barotrauma
if (secondaryKeyState) 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 else
{ {
+7
View File
@@ -425,11 +425,18 @@ namespace Barotrauma
msg.Pos = MathUtils.SmoothStep(msg.Pos, currPos, deltaTime*20.0f); 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, spriteBatch.DrawString(Font, msg.Text,
new Vector2((int)msg.Pos.X, (int)msg.Pos.Y), new Vector2((int)msg.Pos.X, (int)msg.Pos.Y),
msg.Color * alpha, 0.0f, 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); new Vector2((int)(0.5f * msg.Size.X), (int)(0.5f * msg.Size.Y)), 1.0f, SpriteEffects.None, 0.0f);
currPos.Y += 30.0f; currPos.Y += 30.0f;
messages[0].LifeTime -= deltaTime/i; messages[0].LifeTime -= deltaTime/i;
+30 -13
View File
@@ -158,13 +158,13 @@ namespace Barotrauma
scrollBar.BarScroll = 0.0f; 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++) for (int i = 0; i < children.Count; i++)
{ {
if (children[i].UserData != selection) continue; if (children[i].UserData != selection) continue;
Select(i); Select(i, force);
//if (OnSelected != null) OnSelected(Selected, Selected.UserData); //if (OnSelected != null) OnSelected(Selected, Selected.UserData);
if (!SelectMultiple) return; 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; if (childIndex >= children.Count || childIndex < 0) return;
bool wasSelected = true; 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; if (!wasSelected) return;
@@ -270,14 +271,14 @@ namespace Barotrauma
private void ShowScrollBar() 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; scrollBarHidden = false;
} }
private void HideScrollBar() 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; scrollBarHidden = true;
} }
@@ -297,7 +298,7 @@ namespace Barotrauma
scrollBar.Draw(spriteBatch); scrollBar.Draw(spriteBatch);
if (scrollBar.IsHorizontal) if (scrollBar.IsHorizontal)
{ {
x -= (int)((totalSize - rect.Height) * scrollBar.BarScroll); x -= (int)((totalSize - rect.Width) * scrollBar.BarScroll);
} }
else else
{ {
@@ -322,14 +323,30 @@ namespace Barotrauma
child.Visible = false; child.Visible = false;
if (child.Rect.Y + child.Rect.Height < rect.Y) continue; if (scrollBar.IsHorizontal)
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; if (child.Rect.Right < rect.X) continue;
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; child.Visible = true;
+23 -20
View File
@@ -64,26 +64,31 @@ namespace Barotrauma
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.8f); 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; int y = 0;
string summaryText = InfoTextManager.GetInfoText(gameOver ? "gameover" : string summaryText = InfoTextManager.GetInfoText(gameOver ? "gameover" :
(progress ? "progress" : "return")); (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; 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; y += 30;
GUIListBox listBox = new GUIListBox(new Rectangle(0,y,0,90), null, Alignment.TopLeft, GUI.Style, innerFrame, true);
int x = 0; int x = 0;
foreach (Character character in gameSession.CrewManager.characters) 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); var characterFrame = new GUIFrame(new Rectangle(x, y, 170, 70), character.IsDead ? Color.DarkRed * 0.7f : Color.Transparent, GUI.Style, listBox);
characterFrame.Padding = new Vector4(5.0f,5.0f,5.0f,5.0f); characterFrame.OutlineColor = Color.Transparent;
character.Info.CreateCharacterFrame(characterFrame, characterFrame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
character.Info.Job!=null ? (character.Info.Name + '\n'+"("+character.Info.Job.Name+")") : character.Info.Name, null); character.Info.CreateCharacterFrame(characterFrame,
character.Info.Job != null ? (character.Info.Name + '\n' + "(" + character.Info.Job.Name + ")") : character.Info.Name, null);
string statusText; string statusText;
Color statusColor; Color statusColor;
@@ -100,30 +105,28 @@ namespace Barotrauma
statusText = (character.Health / character.MaxHealth > 0.8f) ? "OK" : "Injured"; statusText = (character.Health / character.MaxHealth > 0.8f) ? "OK" : "Injured";
statusColor = Color.DarkGreen; statusColor = Color.DarkGreen;
} }
new GUITextBlock(new Rectangle(0,0,0,20), statusText, new GUITextBlock(new Rectangle(0, 0, 0, 20), statusText,
GUI.Style, Alignment.BottomLeft, Alignment.TopCenter, characterFrame, true, GUI.SmallFont).Color = statusColor*0.7f; GUI.Style, Alignment.BottomLeft, Alignment.TopCenter, characterFrame, true, GUI.SmallFont).Color = statusColor * 0.7f;
x += characterFrame.Rect.Width + 10; x += characterFrame.Rect.Width + 10;
} }
y += 80; y += 120;
if (GameMain.GameSession.Mission != null) 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; 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, (GameMain.GameSession.Mission.Completed) ? GameMain.GameSession.Mission.SuccessMessage : GameMain.GameSession.Mission.FailureMessage,
GUI.Style, innerFrame); GUI.Style, innerFrame);
if (GameMain.GameSession.Mission.Completed) 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; return frame;
@@ -81,7 +81,9 @@ namespace Barotrauma.Items.Components
return; 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); 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) 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.TargetMovement = new Vector2(Math.Sign(diff.X), 0.0f);
character.AnimController.TargetDir = (Math.Sign(diff.X) == 1) ? Direction.Right : Direction.Left; character.AnimController.TargetDir = (Math.Sign(diff.X) == 1) ? Direction.Right : Direction.Left;
return; return;
} }
else
{
character.AnimController.TargetMovement = Vector2.Zero;
}
} }
ApplyStatusEffects(ActionType.OnActive, deltaTime, character); ApplyStatusEffects(ActionType.OnActive, deltaTime, character);
@@ -103,6 +109,7 @@ namespace Barotrauma.Items.Components
character.AnimController.Anim = AnimController.Animation.UsingConstruction; character.AnimController.Anim = AnimController.Animation.UsingConstruction;
character.AnimController.ResetPullJoints(); character.AnimController.ResetPullJoints();
if (dir != 0) character.AnimController.TargetDir = dir; if (dir != 0) character.AnimController.TargetDir = dir;
foreach (LimbPos lb in limbPositions) foreach (LimbPos lb in limbPositions)
@@ -110,6 +117,8 @@ namespace Barotrauma.Items.Components
Limb limb = character.AnimController.GetLimb(lb.limbType); Limb limb = character.AnimController.GetLimb(lb.limbType);
if (limb == null) continue; if (limb == null) continue;
limb.Disabled = true;
FixedMouseJoint fmj = limb.pullJoint; FixedMouseJoint fmj = limb.pullJoint;
if (fmj == null) continue; if (fmj == null) continue;
@@ -138,7 +147,7 @@ namespace Barotrauma.Items.Components
public override void SecondaryUse(float deltaTime, Character character = null) 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; character = null;
return; return;
@@ -150,13 +159,13 @@ namespace Barotrauma.Items.Components
foreach (Connection c2 in c.Recipients) 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; Vector2 centerPos = c2.Item.WorldPosition;
if (character == Character.Controlled && cam != null) if (character == Character.Controlled && cam != null)
{ {
Lights.LightManager.ViewPos = centerPos; Lights.LightManager.ViewTarget = c2.Item;
cam.TargetPos = c2.Item.WorldPosition; cam.TargetPos = c2.Item.WorldPosition;
} }
@@ -74,7 +74,7 @@ namespace Barotrauma.Items.Components
pingState = 0.0f; pingState = 0.0f;
} }
voltage = 0.0f; voltage -= deltaTime;
} }
public override bool Use(float deltaTime, Character character = null) public override bool Use(float deltaTime, Character character = null)
@@ -21,6 +21,7 @@ namespace Barotrauma.Items.Components
private Vector2 newNodePos; private Vector2 newNodePos;
private static Wire draggingWire;
private static int? selectedNodeIndex; private static int? selectedNodeIndex;
public Wire(Item item, XElement element) public Wire(Item item, XElement element)
@@ -310,31 +311,34 @@ namespace Barotrauma.Items.Components
//nodes.Add(newNodePos); //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]; 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; 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 || 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; continue;
} }
MapEntity.DisableSelect = true;
GUI.DrawRectangle(spriteBatch, worldPos + new Vector2(-10, -10), new Vector2(20, 20), Color.Red, false, 0.0f); 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) if (PlayerInput.LeftButtonDown() && PlayerInput.GetOldMouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released)
{ {
MapEntity.SelectEntity(item); MapEntity.SelectEntity(item);
draggingWire = this;
selectedNodeIndex = i; selectedNodeIndex = i;
MapEntity.DisableSelect = true; break;
} }
else if (PlayerInput.RightButtonClicked()) else if (PlayerInput.RightButtonClicked())
{ {
@@ -346,22 +350,27 @@ namespace Barotrauma.Items.Components
if (PlayerInput.LeftButtonDown()) if (PlayerInput.LeftButtonDown())
{ {
if (selectedNodeIndex != null && item.IsSelected) if (selectedNodeIndex != null && draggingWire == this)
{ {
MapEntity.DisableSelect = true; 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); MapEntity.SelectEntity(item);
} }
} }
else else
{ {
selectedNodeIndex = null; selectedNodeIndex = null;
draggingWire = null;
} }
} }
+1 -1
View File
@@ -134,7 +134,7 @@ namespace Barotrauma.Items.Components
var projectiles = GetLoadedProjectiles(true); var projectiles = GetLoadedProjectiles(true);
if (projectiles.Count == 0) return false; if (projectiles.Count == 0) return false;
if (GetAvailablePower() < currPowerConsumption) return false; if (GetAvailablePower() < powerConsumption) return false;
var batteries = item.GetConnectedComponents<PowerContainer>(); var batteries = item.GetConnectedComponents<PowerContainer>();
+9 -6
View File
@@ -7,7 +7,8 @@ namespace Barotrauma.Lights
{ {
class LightManager class LightManager
{ {
public static Vector2 ViewPos; //public static Vector2 ViewPos;
public static Entity ViewTarget;
public Color AmbientLight; public Color AmbientLight;
@@ -58,9 +59,11 @@ namespace Barotrauma.Lights
lights.Remove(light); 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); 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); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, cam.Transform);
Vector2 diff = lookAtPosition - ViewPos; Vector2 diff = lookAtPosition - ViewTarget.WorldPosition;
diff.Y = -diff.Y; diff.Y = -diff.Y;
float rotation = MathUtils.VectorToAngle(diff); float rotation = MathUtils.VectorToAngle(diff);
Vector2 scale = new Vector2(MathHelper.Clamp(diff.Length()/256.0f, 2.0f, 5.0f), 2.0f); 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); new Vector2(LightSource.LightTexture.Width*0.2f, LightSource.LightTexture.Height/2), scale, SpriteEffects.None, 0.0f);
spriteBatch.End(); spriteBatch.End();
+7 -10
View File
@@ -232,21 +232,19 @@ namespace Barotrauma
/// </summary> /// </summary>
public static void UpdateSelecting(Camera cam) public static void UpdateSelecting(Camera cam)
{ {
if (DisableSelect)
{
DisableSelect = false;
return;
}
foreach (MapEntity e in mapEntityList) foreach (MapEntity e in mapEntityList)
{ {
e.isHighlighted = false; e.isHighlighted = false;
e.isSelected = 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) if (MapEntityPrefab.Selected != null)
{ {
@@ -261,8 +259,7 @@ namespace Barotrauma
selectedList.Clear(); selectedList.Clear();
} }
Vector2 position = new Vector2(PlayerInput.GetMouseState.X, PlayerInput.GetMouseState.Y); Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
position = cam.ScreenToWorld(position);
MapEntity highLightedEntity = null; MapEntity highLightedEntity = null;
+1 -1
View File
@@ -312,11 +312,11 @@ namespace Barotrauma
(Rand.Int(2) == 0) ? Borders.Y : Borders.Y - Borders.Height); (Rand.Int(2) == 0) ? Borders.Y : Borders.Y - Borders.Height);
} }
damagePos += submarine.Position + Submarine.HiddenSubPosition;
SoundPlayer.PlayDamageSound(DamageSoundType.Pressure, 50.0f, damagePos, 10000.0f); SoundPlayer.PlayDamageSound(DamageSoundType.Pressure, 50.0f, damagePos, 10000.0f);
GameMain.GameScreen.Cam.Shake = depth * PressureDamageMultiplier * 0.1f; GameMain.GameScreen.Cam.Shake = depth * PressureDamageMultiplier * 0.1f;
damagePos += submarine.Position + Submarine.HiddenSubPosition;
Explosion.RangedStructureDamage(damagePos, depth * PressureDamageMultiplier * 50.0f, depth * PressureDamageMultiplier); Explosion.RangedStructureDamage(damagePos, depth * PressureDamageMultiplier * 50.0f, depth * PressureDamageMultiplier);
//SoundPlayer.PlayDamageSound(DamageSoundType.StructureBlunt, Rand.Range(0.0f, 100.0f), damagePos, 5000.0f); //SoundPlayer.PlayDamageSound(DamageSoundType.StructureBlunt, Rand.Range(0.0f, 100.0f), damagePos, 5000.0f);
+51 -1
View File
@@ -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<Structure> stairList = new List<Structure>(); List<Structure> stairList = new List<Structure>();
foreach (MapEntity me in MapEntity.mapEntityList) foreach (MapEntity me in MapEntity.mapEntityList)
{ {
@@ -292,7 +342,7 @@ namespace Barotrauma
for (int dir = -1; dir <= 1; dir += 2) 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; if (closest == null) continue;
wayPoint.ConnectTo(closest); wayPoint.ConnectTo(closest);
} }
+5
View File
@@ -222,6 +222,11 @@ namespace Barotrauma
get { return oldMouseState; } get { return oldMouseState; }
} }
public static bool MouseInsideWindow
{
get { return new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight).Contains(MousePosition); }
}
public static Vector2 MouseSpeed public static Vector2 MouseSpeed
{ {
get get
+17 -4
View File
@@ -26,10 +26,10 @@ namespace Barotrauma
get { return cam; } get { return cam; }
} }
public string GetSubName() //public string GetSubName()
{ //{
return ((Submarine.Loaded == null) ? "" : Submarine.Loaded.Name); // return ((Submarine.Loaded == null) ? "" : Submarine.Loaded.Name);
} //}
private string GetItemCount() private string GetItemCount()
{ {
@@ -64,6 +64,7 @@ namespace Barotrauma
new GUITextBlock(new Rectangle(0, 20, 0, 20), "Submarine:", GUI.Style, GUIpanel); 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 = new GUITextBox(new Rectangle(0, 40, 0, 20), GUI.Style, GUIpanel);
nameBox.OnEnterPressed = ChangeSubName;
//nameBlock.TextGetter = GetSubName; //nameBlock.TextGetter = GetSubName;
GUIButton button = new GUIButton(new Rectangle(0,70,0,20), "Save", GUI.Style, GUIpanel); 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"); Submarine.SaveCurrent(nameBox.Text + ".sub");
GUI.AddMessage("Submarine saved to " + Submarine.Loaded.FilePath, Color.DarkGreen, 3.0f);
return false; return false;
@@ -271,6 +274,16 @@ namespace Barotrauma
return true; 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) private bool SelectPrefab(GUIComponent component, object obj)
{ {
MapEntityPrefab.SelectPrefab(obj); MapEntityPrefab.SelectPrefab(obj);
+9 -7
View File
@@ -135,10 +135,10 @@ namespace Barotrauma
while (Physics.accumulator >= Physics.step) while (Physics.accumulator >= Physics.step)
{ {
cam.MoveCamera((float)Physics.step); cam.MoveCamera((float)Physics.step);
if (Character.Controlled != null) if (Character.Controlled != null && Lights.LightManager.ViewTarget != null)
{ {
cam.TargetPos = Character.Controlled.WorldPosition; cam.TargetPos = Lights.LightManager.ViewTarget.WorldPosition;
Lights.LightManager.ViewPos = Character.Controlled.WorldPosition; //Lights.LightManager.ViewPos = Character.Controlled.WorldPosition;
} }
if (Submarine.Loaded != null) Submarine.Loaded.SetPrevTransform(Submarine.Loaded.Position); 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.ObstructVision = Character.Controlled != null && Character.Controlled.ObstructVision;
GameMain.LightManager.UpdateLightMap(graphics, spriteBatch, cam); GameMain.LightManager.UpdateLightMap(graphics, spriteBatch, cam);
GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, if (Character.Controlled!=null)
Character.Controlled==null ? LightManager.ViewPos : Character.Controlled.CursorWorldPosition); {
GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled.CursorWorldPosition);
}
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
//1. draw the background, characters and the parts of the submarine that are behind them //1. draw the background, characters and the parts of the submarine that are behind them
@@ -335,7 +337,7 @@ namespace Barotrauma
spriteBatch.End(); spriteBatch.End();
GameMain.LightManager.DrawLOS(graphics, spriteBatch, cam, LightManager.ViewPos); GameMain.LightManager.DrawLOS(graphics, spriteBatch, cam);
} }
} }
} }
+1 -1
View File
@@ -537,7 +537,7 @@ namespace Barotrauma
private IEnumerable<object> ShiftLoading() private IEnumerable<object> ShiftLoading()
{ {
GameMain.GameSession.StartShift(selectedLevel, false); GameMain.GameSession.StartShift(selectedLevel, true);
GameMain.GameScreen.Select(); GameMain.GameScreen.Select();
yield return CoroutineStatus.Success; yield return CoroutineStatus.Success;
@@ -3,6 +3,7 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Networking; using Barotrauma.Networking;
using System.Xml.Linq; using System.Xml.Linq;
using System.IO;
namespace Barotrauma namespace Barotrauma
{ {
@@ -474,6 +475,15 @@ namespace Barotrauma
Submarine selectedSub = mapList.SelectedData as Submarine; Submarine selectedSub = mapList.SelectedData as Submarine;
if (selectedSub == null) return false; if (selectedSub == null) return false;
if (!Directory.Exists(SaveUtil.TempPath))
{
Directory.CreateDirectory(SaveUtil.TempPath);
}
File.Copy(selectedSub.FilePath, Path.Combine(SaveUtil.TempPath, "map.sub"), true);
selectedSub = new Submarine(Path.Combine(SaveUtil.TempPath, "map.sub"), "");
GameMain.GameSession = new GameSession(selectedSub, saveNameBox.Text, GameModePreset.list.Find(gm => gm.Name == "Single Player")); GameMain.GameSession = new GameSession(selectedSub, saveNameBox.Text, GameModePreset.list.Find(gm => gm.Name == "Single Player"));
(GameMain.GameSession.gameMode as SinglePlayerMode).GenerateMap(seedBox.Text); (GameMain.GameSession.gameMode as SinglePlayerMode).GenerateMap(seedBox.Text);
+2 -2
View File
@@ -859,7 +859,7 @@ namespace Barotrauma
} }
else else
{ {
subList.Select(sub); subList.Select(sub, true);
//map.Load(); //map.Load();
return true; return true;
} }
@@ -950,7 +950,7 @@ namespace Barotrauma
if (!string.IsNullOrWhiteSpace(mapName) && !GameMain.NetworkMember.Voting.AllowSubVoting) TrySelectSub(mapName, md5Hash); if (!string.IsNullOrWhiteSpace(mapName) && !GameMain.NetworkMember.Voting.AllowSubVoting) TrySelectSub(mapName, md5Hash);
if (!GameMain.NetworkMember.Voting.AllowModeVoting) modeList.Select(modeIndex); if (!GameMain.NetworkMember.Voting.AllowModeVoting) modeList.Select(modeIndex, true);
autoRestartBox.Selected = autoRestart; autoRestartBox.Selected = autoRestart;
autoRestartTimer = restartTimer; autoRestartTimer = restartTimer;
+2 -2
View File
@@ -65,7 +65,7 @@ namespace Barotrauma
public int AlBufferId public int AlBufferId
{ {
get { return oggSound.AlBufferId; } get { return oggSound==null ? -1 : oggSound.AlBufferId; }
} }
public static void Init() public static void Init()
@@ -260,7 +260,7 @@ namespace Barotrauma
//System.Diagnostics.Debug.WriteLine("Removing sound " + filePath + " (buffer id" + AlBufferId + ")"); //System.Diagnostics.Debug.WriteLine("Removing sound " + filePath + " (buffer id" + AlBufferId + ")");
SoundManager.ClearAlSource(AlBufferId); SoundManager.ClearAlSource(AlBufferId);
oggSound.Dispose(); if (oggSound!=null) oggSound.Dispose();
} }
+3 -12
View File
@@ -240,7 +240,7 @@ namespace Barotrauma
{ {
suitableMusic = musicClips.Where(x => x != null && x.type == OverrideMusicType).ToList(); suitableMusic = musicClips.Where(x => x != null && x.type == OverrideMusicType).ToList();
} }
else if (Submarine.Loaded!=null && Submarine.Loaded.Position.Y<SubmarineBody.DamageDepth+10000.0f) else if (Submarine.Loaded!=null && Submarine.Loaded.AtDamageDepth)
{ {
suitableMusic = musicClips.Where(x => x != null && x.type == "deep").ToList(); suitableMusic = musicClips.Where(x => x != null && x.type == "deep").ToList();
} }
@@ -302,17 +302,8 @@ namespace Barotrauma
int selectedSound = Rand.Int(sounds.Count()); int selectedSound = Rand.Int(sounds.Count());
int i = 0; sounds[selectedSound].sound.Play(1.0f, range, position);
foreach (var s in sounds) Debug.WriteLine("playing: " + sounds[selectedSound].sound);
{
if (i == selectedSound)
{
s.sound.Play(1.0f, range, position);
Debug.WriteLine("playing: " + s.sound);
return;
}
i++;
}
} }
} }
+30 -12
View File
@@ -14,18 +14,34 @@ namespace Barotrauma
public delegate void ProgressDelegate(string sMessage); public delegate void ProgressDelegate(string sMessage);
public static string TempPath
{
get { return Path.Combine(SaveFolder, "temp"); }
}
public static void SaveGame(string fileName) public static void SaveGame(string fileName)
{ {
fileName = Path.Combine(SaveFolder, fileName); fileName = Path.Combine(SaveFolder, fileName);
string tempPath = Path.Combine(SaveFolder, "temp"); string tempPath = Path.Combine(SaveFolder, "temp");
if (Directory.Exists(tempPath)) //if (Directory.Exists(tempPath))
//{
// Directory.Delete(tempPath, true);
//}
if (!Directory.Exists(tempPath))
{ {
Directory.Delete(tempPath, true); // DecompressToDirectory(fileName, tempPath, null);
//}
//else
//{
Directory.CreateDirectory(tempPath);
} }
Directory.CreateDirectory(tempPath);
//
//Directory.CreateDirectory(Path.GetDirectoryName(filePath) + "\\temp"); //Directory.CreateDirectory(Path.GetDirectoryName(filePath) + "\\temp");
try try
@@ -34,10 +50,6 @@ namespace Barotrauma
{ {
Submarine.Loaded.SaveAs(Path.Combine(tempPath, "map.sub")); Submarine.Loaded.SaveAs(Path.Combine(tempPath, "map.sub"));
} }
else
{
File.Copy(GameMain.GameSession.Submarine.FilePath, Path.Combine(tempPath, "map.sub"));
}
} }
catch (Exception e) catch (Exception e)
{ {
@@ -68,12 +80,11 @@ namespace Barotrauma
public static void LoadGame(string fileName) public static void LoadGame(string fileName)
{ {
string filePath = Path.Combine(SaveFolder, fileName+".save"); string filePath = Path.Combine(SaveFolder, fileName+".save");
string tempPath = Path.Combine(SaveFolder, "temp");
DecompressToDirectory(filePath, tempPath, null); DecompressToDirectory(filePath, TempPath, null);
Submarine selectedMap = new Submarine(Path.Combine(tempPath, "map.sub"), "");// Submarine.Load(); Submarine selectedMap = new Submarine(Path.Combine(TempPath, "map.sub"), "");// Submarine.Load();
GameMain.GameSession = new GameSession(selectedMap, fileName, Path.Combine(tempPath, "gamesession.xml")); GameMain.GameSession = new GameSession(selectedMap, fileName, Path.Combine(TempPath, "gamesession.xml"));
//Directory.Delete(tempPath, true); //Directory.Delete(tempPath, true);
} }
@@ -84,7 +95,14 @@ namespace Barotrauma
string tempPath = Path.Combine(SaveFolder, "temp"); string tempPath = Path.Combine(SaveFolder, "temp");
DecompressToDirectory(filePath, tempPath, null); try
{
DecompressToDirectory(filePath, tempPath, null);
}
catch
{
return null;
}
return ToolBox.TryLoadXml(Path.Combine(tempPath, "gamesession.xml")); return ToolBox.TryLoadXml(Path.Combine(tempPath, "gamesession.xml"));
} }
+1 -1
View File
@@ -47,7 +47,7 @@ Graphics - James Bear ("Moonsaber99")
------------------------------------------------------------------------ ------------------------------------------------------------------------
"Enter the Maze", "Simplex", "Unseen Horrors" "The Descent", "Enter the Maze", "Road to Hell", "Simplex", "Unseen Horrors"
Kevin MacLeod (incompetech.com) Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 3.0 Licensed under Creative Commons: By Attribution 3.0
http://creativecommons.org/licenses/by/3.0/ http://creativecommons.org/licenses/by/3.0/
Binary file not shown.