Merge remote-tracking branch 'barotrauma/master' into new-netcode

# Conflicts:
#	Subsurface/Properties/AssemblyInfo.cs
#	Subsurface/Source/Characters/AI/EnemyAIController.cs
#	Subsurface/Source/Characters/AICharacter.cs
#	Subsurface/Source/Characters/Character.cs
#	Subsurface/Source/Items/Components/Signal/Connection.cs
#	Subsurface/Source/Items/Item.cs
#	Subsurface/Source/Map/Structure.cs
#	Subsurface/Source/Networking/GameClient.cs
#	Subsurface/Source/Networking/GameServer.cs
#	Subsurface/Source/Screens/NetLobbyScreen.cs
This commit is contained in:
juanjp600
2016-11-05 18:18:20 -03:00
57 changed files with 454 additions and 362 deletions
+4
View File
@@ -319,6 +319,10 @@
<Reference Include="RestSharp"> <Reference Include="RestSharp">
<HintPath>..\packages\RestSharp.105.1.0\lib\net4\RestSharp.dll</HintPath> <HintPath>..\packages\RestSharp.105.1.0\lib\net4\RestSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="SharpDX, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\MonoGame\v3.0\Assemblies\Windows\SharpDX.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
Binary file not shown.

Before

Width:  |  Height:  |  Size: 799 KiB

After

Width:  |  Height:  |  Size: 2.8 MiB

@@ -119,9 +119,6 @@ namespace Barotrauma
if (canOpenDoors && !character.LockHands) CheckDoorsInPath(); if (canOpenDoors && !character.LockHands) CheckDoorsInPath();
float allowedDistance = character.AnimController.InWater ? 1.0f : 0.6f;
//if (currentPath.CurrentNode!=null && currentPath.CurrentNode.SimPosition.Y > character.SimPosition.Y+1.0f) allowedDistance*=0.5f;
Vector2 pos = host.SimPosition; Vector2 pos = host.SimPosition;
if (character != null && currentPath.CurrentNode != null) if (character != null && currentPath.CurrentNode != null)
@@ -160,8 +157,6 @@ namespace Barotrauma
if (currentPath.CurrentNode == null) return Vector2.Zero; if (currentPath.CurrentNode == null) return Vector2.Zero;
var hull = character.AnimController.CurrentHull;
if (character.AnimController.Anim == AnimController.Animation.Climbing) if (character.AnimController.Anim == AnimController.Animation.Climbing)
{ {
Vector2 diff = currentPath.CurrentNode.SimPosition - pos; Vector2 diff = currentPath.CurrentNode.SimPosition - pos;
@@ -161,9 +161,6 @@ namespace Barotrauma
{ {
movement = TargetMovement*swimSpeed; movement = TargetMovement*swimSpeed;
Limb torso = GetLimb(LimbType.Torso);
Limb head = GetLimb(LimbType.Head);
MainLimb.pullJoint.Enabled = true; MainLimb.pullJoint.Enabled = true;
MainLimb.pullJoint.WorldAnchorB = collider.SimPosition; MainLimb.pullJoint.WorldAnchorB = collider.SimPosition;
@@ -193,7 +190,7 @@ namespace Barotrauma
} }
for (int i = 0; i < Limbs.Count(); i++) for (int i = 0; i < Limbs.Length; i++)
{ {
if (Limbs[i].SteerForce <= 0.0f) continue; if (Limbs[i].SteerForce <= 0.0f) continue;
@@ -24,14 +24,6 @@ namespace Barotrauma
private float inWaterTimer; private float inWaterTimer;
private bool swimming; private bool swimming;
protected override float HeadPosition
{
get
{
return Crouching ? base.HeadPosition : base.HeadPosition;
}
}
protected override float TorsoPosition protected override float TorsoPosition
{ {
get get
@@ -255,7 +247,7 @@ namespace Barotrauma
if (limb.inWater) limbsInWater++; if (limb.inWater) limbsInWater++;
} }
float slowdownFactor = (float)limbsInWater / (float)Limbs.Count(); float slowdownFactor = (float)limbsInWater / (float)Limbs.Length;
float maxSpeed = Math.Max(TargetMovement.Length() - slowdownFactor, 1.0f); float maxSpeed = Math.Max(TargetMovement.Length() - slowdownFactor, 1.0f);
// if (character.SelectedCharacter!=null) maxSpeed = Math.Min(maxSpeed, 1.0f); // if (character.SelectedCharacter!=null) maxSpeed = Math.Min(maxSpeed, 1.0f);
@@ -306,16 +298,21 @@ namespace Barotrauma
if (onGround && (!character.IsRemotePlayer || GameMain.Server != null)) if (onGround && (!character.IsRemotePlayer || GameMain.Server != null))
{ {
collider.LinearVelocity = new Vector2( collider.LinearVelocity = new Vector2(
movement.X, movement.X,
collider.LinearVelocity.Y > 0.0f ? collider.LinearVelocity.Y * 0.5f : collider.LinearVelocity.Y); collider.LinearVelocity.Y > 0.0f ? collider.LinearVelocity.Y * 0.5f : collider.LinearVelocity.Y);
} }
ClimbOverObstacles();
getUpSpeed = getUpSpeed * Math.Max(head.SimPosition.Y - colliderPos.Y, 0.5f); getUpSpeed = getUpSpeed * Math.Max(head.SimPosition.Y - colliderPos.Y, 0.5f);
torso.pullJoint.Enabled = true; torso.pullJoint.Enabled = true;
head.pullJoint.Enabled = true; head.pullJoint.Enabled = true;
waist.pullJoint.Enabled = true; waist.pullJoint.Enabled = true;
collider.FarseerBody.Friction = 0.05f;
collider.FarseerBody.Restitution = 0.05f;
if (stairs != null) if (stairs != null)
{ {
torso.pullJoint.WorldAnchorB = new Vector2( torso.pullJoint.WorldAnchorB = new Vector2(
@@ -430,7 +427,7 @@ namespace Barotrauma
} }
else else
{ {
float movementFactor = (movement.X / 4.0f) * movement.X * Math.Sign(movement.X); //float movementFactor = (movement.X / 4.0f) * movement.X * Math.Sign(movement.X);
for (int i = -1; i < 2; i += 2) for (int i = -1; i < 2; i += 2)
{ {
@@ -462,8 +459,6 @@ namespace Barotrauma
leftArm.body.SmoothRotate(0.0f, 20.0f); leftArm.body.SmoothRotate(0.0f, 20.0f);
} }
} }
} }
void UpdateStandingSimple() void UpdateStandingSimple()
@@ -474,20 +469,51 @@ namespace Barotrauma
{ {
movement = Vector2.Normalize(movement); movement = Vector2.Normalize(movement);
} }
}
return; private void ClimbOverObstacles()
//RefLimb.pullJoint.Enabled = true; {
//RefLimb.pullJoint.WorldAnchorB = if (collider.FarseerBody.ContactList == null || Math.Abs(movement.X) < 0.01f) return;
// RefLimb.SimPosition + movement * 0.15f;
//RefLimb.body.SmoothRotate(0.0f); //check if the collider is touching a suitable obstacle to climb over
Vector2? handle = null;
FarseerPhysics.Dynamics.Contacts.ContactEdge ce = collider.FarseerBody.ContactList;
while (ce != null && ce.Contact != null)
{
if (ce.Contact.Enabled && ce.Contact.IsTouching && ce.Contact.FixtureA.CollisionCategories.HasFlag(Physics.CollisionWall))
{
Vector2 contactNormal;
FarseerPhysics.Common.FixedArray2<Vector2> contactPos;
ce.Contact.GetWorldManifold(out contactNormal, out contactPos);
//foreach (Limb l in Limbs) //only climb if moving towards the obstacle
//{ if (Math.Sign(contactPos[0].X - collider.SimPosition.X) == Math.Sign(movement.X) &&
// if (l == RefLimb) continue; (handle == null || contactPos[0].Y > ((Vector2)handle).Y))
// l.body.SetTransform(RefLimb.SimPosition, RefLimb.Rotation); {
//} handle = contactPos[0];
//new Vector2(movement.X, floorY + HeadPosition), 0.5f); }
}
ce = ce.Next;
}
if (handle == null) return;
float colliderBottomY = GetColliderBottom().Y;
//the contact point should be higher than the bottom of the collider
if (((Vector2)handle).Y < colliderBottomY + 0.01f) return;
//find the height of the floor below the torso
//(if moving towards towards an obstacle that's low enough to climb over, the torso should be above it)
float obstacleY = GetFloorY(GetLimb(LimbType.Torso));
if (obstacleY > colliderBottomY)
{
//higher vertical velocity for taller obstacles
collider.LinearVelocity += Vector2.UnitY * (((Vector2)handle).Y - colliderBottomY + 0.01f) * 10;
onGround = true;
}
} }
void UpdateSwimming() void UpdateSwimming()
@@ -828,63 +854,7 @@ namespace Barotrauma
var head = GetLimb(LimbType.Head); var head = GetLimb(LimbType.Head);
head.pullJoint.WorldAnchorB = new Vector2(targetHead.SimPosition.X, targetHead.SimPosition.Y + 0.6f + yPos); head.pullJoint.WorldAnchorB = new Vector2(targetHead.SimPosition.X, targetHead.SimPosition.Y + 0.6f + yPos);
head.pullJoint.Enabled = true; head.pullJoint.Enabled = true;
//RefLimb.pullJoint.WorldAnchorB = new Vector2(targetHead.SimPosition.X - Math.Sign(headDiff.X) * 0.5f, targetHead.SimPosition.Y + 0.4f + yPos);
//head.pullJoint.Enabled = true;
//DragCharacter(character.SelectedCharacter, LimbType.Torso, LimbType.Head);
} }
//float punchTimer;
//bool punching;
//public void Punch()
//{
// if (punchTimer < 0.01f) punching = true;
// Limb rightHand = GetLimb(LimbType.RightHand);
// Limb head = GetLimb(LimbType.Head);
// Vector2 diff = Vector2.Normalize(Character.CursorPosition - RefLimb.Position);
// rightHand.body.ApplyLinearImpulse(diff * 20.0f);
// head.body.ApplyLinearImpulse(diff * 5.0f);
// head.body.ApplyTorque(Dir*100.0f);
//}
//public void Block(float deltaTime)
//{
// Limb head = GetLimb(LimbType.Head);
// Limb torso = GetLimb(LimbType.Torso);
// Limb leftHand = GetLimb(LimbType.LeftHand);
// Limb leftFoot = GetLimb(LimbType.LeftFoot);
// Limb rightHand = GetLimb(LimbType.RightHand);
// Vector2 pos = head.SimPosition;
// rightHand.Disabled = true;
// leftHand.Disabled = true;
// HandIK(leftHand, pos + new Vector2(0.25f*Dir, 0.0f));
// if (punching)
// {
// punchTimer += deltaTime*10.0f;
// if (punchTimer>2.0f)
// {
// punching = false;
// }
// }
// else
// {
// punchTimer = MathHelper.Lerp(punchTimer, 0.0f, 0.3f);
// HandIK(rightHand, pos + new Vector2((0.3f + punchTimer) * Dir, 0.1f));
// }
//}
public override void DragCharacter(Character target, LimbType rightHandTarget = LimbType.RightHand, LimbType leftHandTarget = LimbType.LeftHand) public override void DragCharacter(Character target, LimbType rightHandTarget = LimbType.RightHand, LimbType leftHandTarget = LimbType.LeftHand)
{ {
if (target == null) return; if (target == null) return;
@@ -464,15 +464,15 @@ namespace Barotrauma
float impact = Vector2.Dot(velocity, -normal); float impact = Vector2.Dot(velocity, -normal);
float volume = Math.Min(impact, 1.0f); float volume = Math.Min(impact-3.0f, 1.0f);
if (f1.Body.UserData is Limb) if (f1.Body.UserData is Limb)
{ {
Limb limb = (Limb)f1.Body.UserData; Limb limb = (Limb)f1.Body.UserData;
if (impact > 0.5f && limb.HitSound != null && limb.soundTimer <= 0.0f) if (impact > 3.0f && limb.HitSound != null && limb.soundTimer <= 0.0f)
{ {
limb.soundTimer = Limb.SoundInterval; limb.soundTimer = Limb.SoundInterval;
limb.HitSound.Play(volume, impact * 250.0f, limb.WorldPosition); limb.HitSound.Play(volume, impact * 100.0f, limb.WorldPosition);
} }
} }
else if (f1.Body == collider.FarseerBody) else if (f1.Body == collider.FarseerBody)
@@ -578,7 +578,7 @@ namespace Barotrauma
{ {
dir = (dir == Direction.Left) ? Direction.Right : Direction.Left; dir = (dir == Direction.Left) ? Direction.Right : Direction.Left;
for (int i = 0; i < limbJoints.Count(); i++) for (int i = 0; i < limbJoints.Length; i++)
{ {
float lowerLimit = -limbJoints[i].UpperLimit; float lowerLimit = -limbJoints[i].UpperLimit;
float upperLimit = -limbJoints[i].LowerLimit; float upperLimit = -limbJoints[i].LowerLimit;
@@ -591,7 +591,7 @@ namespace Barotrauma
} }
for (int i = 0; i < Limbs.Count(); i++) for (int i = 0; i < Limbs.Length; i++)
{ {
if (Limbs[i] == null) continue; if (Limbs[i] == null) continue;
@@ -834,7 +834,7 @@ namespace Barotrauma
{ {
//create a splash particle //create a splash particle
var p = GameMain.ParticleManager.CreateParticle("watersplash", GameMain.ParticleManager.CreateParticle("watersplash",
new Vector2(limb.Position.X, limbHull.Surface) + limbHull.Submarine.Position, new Vector2(limb.Position.X, limbHull.Surface) + limbHull.Submarine.Position,
new Vector2(0.0f, Math.Abs(-limb.LinearVelocity.Y * 20.0f)), new Vector2(0.0f, Math.Abs(-limb.LinearVelocity.Y * 20.0f)),
0.0f, limbHull); 0.0f, limbHull);
@@ -934,9 +934,11 @@ namespace Barotrauma
} }
private float GetFloorY() protected float GetFloorY(Limb refLimb = null)
{ {
Vector2 rayStart = collider.SimPosition; PhysicsBody refBody = refLimb == null ? collider : refLimb.body;
Vector2 rayStart = refBody.SimPosition;
Vector2 rayEnd = rayStart - new Vector2(0.0f, TorsoPosition); Vector2 rayEnd = rayStart - new Vector2(0.0f, TorsoPosition);
var lowestLimb = FindLowestLimb(); var lowestLimb = FindLowestLimb();
@@ -1088,7 +1090,11 @@ namespace Barotrauma
} }
else else
{ {
collider.CorrectPosition(character.MemPos, deltaTime, out overrideTargetMovement); if (character.MemPos.Count > 0)
{
collider.LinearVelocity = Vector2.Zero;
collider.CorrectPosition(character.MemPos, deltaTime, out overrideTargetMovement);
}
} }
} }
+6 -6
View File
@@ -585,9 +585,9 @@ namespace Barotrauma
var soundElements = doc.Root.Elements("sound").ToList(); var soundElements = doc.Root.Elements("sound").ToList();
if (soundElements.Any()) if (soundElements.Any())
{ {
sounds = new Sound[soundElements.Count()]; sounds = new Sound[soundElements.Count];
soundStates = new AIController.AiState[soundElements.Count()]; soundStates = new AIController.AiState[soundElements.Count];
soundRange = new float[soundElements.Count()]; soundRange = new float[soundElements.Count];
int i = 0; int i = 0;
foreach (XElement soundElement in soundElements) foreach (XElement soundElement in soundElements)
{ {
@@ -868,7 +868,7 @@ namespace Barotrauma
{ {
attackPos = Submarine.LastPickedPosition; attackPos = Submarine.LastPickedPosition;
if (body != null && body.UserData is Submarine) if (body.UserData is Submarine)
{ {
var sub = ((Submarine)body.UserData); var sub = ((Submarine)body.UserData);
@@ -1538,10 +1538,10 @@ namespace Barotrauma
if (sounds == null || !sounds.Any()) return; if (sounds == null || !sounds.Any()) return;
var matchingSoundStates = soundStates.Where(x => x == state).ToList(); var matchingSoundStates = soundStates.Where(x => x == state).ToList();
int selectedSound = Rand.Int(matchingSoundStates.Count()); int selectedSound = Rand.Int(matchingSoundStates.Count);
int n = 0; int n = 0;
for (int i = 0; i < sounds.Count(); i++) for (int i = 0; i < sounds.Length; i++)
{ {
if (soundStates[i] != state) continue; if (soundStates[i] != state) continue;
if (n == selectedSound && sounds[i]!=null) if (n == selectedSound && sounds[i]!=null)
@@ -1,8 +1,5 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
+1 -1
View File
@@ -63,7 +63,7 @@ namespace Barotrauma
Sound hitSound; Sound hitSound;
//a timer for delaying when a hitsound/attacksound can be played again //a timer for delaying when a hitsound/attacksound can be played again
public float soundTimer; public float soundTimer;
public const float SoundInterval = 0.2f; public const float SoundInterval = 0.4f;
public readonly Attack attack; public readonly Attack attack;
+6 -6
View File
@@ -92,8 +92,8 @@ namespace Barotrauma
type = (ActionType)Enum.Parse(typeof(ActionType), split[0], true); type = (ActionType)Enum.Parse(typeof(ActionType), split[0], true);
string[] containingNames = split[1].Split(','); string[] containingNames = split[1].Split(',');
onContainingNames = new string[containingNames.Count()]; onContainingNames = new string[containingNames.Length];
for (int i =0; i < containingNames.Count(); i++) for (int i =0; i < containingNames.Length; i++)
{ {
onContainingNames[i] = containingNames[i].Trim(); onContainingNames[i] = containingNames[i].Trim();
} }
@@ -116,8 +116,8 @@ namespace Barotrauma
break; break;
case "targetnames": case "targetnames":
string[] names = attribute.Value.Split(','); string[] names = attribute.Value.Split(',');
targetNames = new string[names.Count()]; targetNames = new string[names.Length];
for (int i=0; i < names.Count(); i++ ) for (int i=0; i < names.Length; i++ )
{ {
targetNames[i] = names[i].Trim(); targetNames[i] = names[i].Trim();
} }
@@ -134,7 +134,7 @@ namespace Barotrauma
} }
} }
int count = propertyAttributes.Count(); int count = propertyAttributes.Count;
propertyNames = new string[count]; propertyNames = new string[count];
propertyEffects = new object[count]; propertyEffects = new object[count];
@@ -227,7 +227,7 @@ namespace Barotrauma
foreach (IPropertyObject target in targets) foreach (IPropertyObject target in targets)
{ {
for (int i = 0; i < propertyNames.Count(); i++) for (int i = 0; i < propertyNames.Length; i++)
{ {
ObjectProperty property; ObjectProperty property;
+1 -1
View File
@@ -171,7 +171,7 @@ namespace Barotrauma
} }
//string str = sb.ToString(); //string str = sb.ToString();
byte[] bytes = new byte[hashes.Count()*16]; byte[] bytes = new byte[hashes.Count*16];
for (int i = 0; i < hashes.Count; i++ ) for (int i = 0; i < hashes.Count; i++ )
{ {
hashes[i].CopyTo(bytes, i*16); hashes[i].CopyTo(bytes, i*16);
+17 -7
View File
@@ -64,6 +64,15 @@ namespace Barotrauma
textBox = new GUITextBox(new Rectangle(0,0,0,20), Color.Black, Color.White, Alignment.BottomLeft, Alignment.Left, GUI.Style, frame); textBox = new GUITextBox(new Rectangle(0,0,0,20), Color.Black, Color.White, Alignment.BottomLeft, Alignment.Left, GUI.Style, frame);
textBox.Color = Color.Black * 0.7f; textBox.Color = Color.Black * 0.7f;
//messages already added before initialization -> add them to the listbox
List<ColoredText> unInitializedMessages = new List<ColoredText>(Messages);
Messages.Clear();
foreach (ColoredText msg in unInitializedMessages)
{
NewMessage(msg.Text, msg.Color);
}
NewMessage("Press F3 to open/close the debug console", Color.Cyan); NewMessage("Press F3 to open/close the debug console", Color.Cyan);
NewMessage("Enter \"help\" for a list of available console commands", Color.Cyan); NewMessage("Enter \"help\" for a list of available console commands", Color.Cyan);
@@ -740,6 +749,14 @@ namespace Barotrauma
Messages.Add(new ColoredText(msg, color)); Messages.Add(new ColoredText(msg, color));
if (Messages.Count > MaxMessages)
{
Messages.RemoveRange(0, Messages.Count - MaxMessages);
}
//listbox not created yet, don't attempt to add
if (listBox == null) return;
try try
{ {
var textBlock = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width, 0), msg, GUI.Style, Alignment.TopLeft, Alignment.Left, null, true, GUI.SmallFont); var textBlock = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width, 0), msg, GUI.Style, Alignment.TopLeft, Alignment.Left, null, true, GUI.SmallFont);
@@ -754,13 +771,6 @@ namespace Barotrauma
return; return;
} }
if (Messages.Count > MaxMessages)
{
Messages.RemoveRange(0, Messages.Count - MaxMessages);
}
//messages.Add(new ColoredText(msg, color));
selectedIndex = listBox.children.Count; selectedIndex = listBox.children.Count;
} }
@@ -39,7 +39,7 @@ namespace Barotrauma
LoadItemAsChild(subElement, null); LoadItemAsChild(subElement, null);
} }
if (requiredDeliveryAmount == 0) requiredDeliveryAmount = items.Count(); if (requiredDeliveryAmount == 0) requiredDeliveryAmount = items.Count;
} }
private void LoadItemAsChild(XElement element, Item parent) private void LoadItemAsChild(XElement element, Item parent)
+1 -1
View File
@@ -124,7 +124,7 @@ namespace Barotrauma
public int CountChildren public int CountChildren
{ {
get { return children.Count(); } get { return children.Count; }
} }
public virtual Color Color public virtual Color Color
+1 -27
View File
@@ -412,38 +412,14 @@ namespace Barotrauma
//base.Draw(spriteBatch); //base.Draw(spriteBatch);
frame.Draw(spriteBatch); frame.Draw(spriteBatch);
//GUI.DrawRectangle(spriteBatch, rect, color*alpha, true);
int x = rect.X, y = rect.Y; if (!scrollBarHidden) scrollBar.Draw(spriteBatch);
if (!scrollBarHidden)
{
scrollBar.Draw(spriteBatch);
if (scrollBar.IsHorizontal)
{
x -= (int)((totalSize - rect.Width) * scrollBar.BarScroll);
}
else
{
y -= (int)((totalSize - rect.Height) * scrollBar.BarScroll);
}
}
for (int i = 0; i < children.Count; i++) for (int i = 0; i < children.Count; i++)
{ {
GUIComponent child = children[i]; GUIComponent child = children[i];
if (child == frame || !child.Visible) continue; if (child == frame || !child.Visible) continue;
if (scrollBar.IsHorizontal)
{
x += child.Rect.Width + spacing;
}
else
{
y += child.Rect.Height + spacing;
}
if (scrollBar.IsHorizontal) if (scrollBar.IsHorizontal)
{ {
if (child.Rect.Right < rect.X) continue; if (child.Rect.Right < rect.X) continue;
@@ -451,7 +427,6 @@ namespace Barotrauma
if (child.Rect.X < rect.X && child.Rect.Right >= rect.X) if (child.Rect.X < rect.X && child.Rect.Right >= rect.X)
{ {
x = rect.X;
continue; continue;
} }
} }
@@ -462,7 +437,6 @@ namespace Barotrauma
if (child.Rect.Y < rect.Y && child.Rect.Y + child.Rect.Height >= rect.Y) if (child.Rect.Y < rect.Y && child.Rect.Y + child.Rect.Height >= rect.Y)
{ {
y = rect.Y;
continue; continue;
} }
} }
-10
View File
@@ -169,26 +169,16 @@ namespace Barotrauma
private void MoveButton() private void MoveButton()
{ {
//if (!enabled) return false;
//if (barSize == 1.0f) return false;
int newX = bar.Rect.X - frame.Rect.X, newY = bar.Rect.Y - frame.Rect.Y;
float moveAmount; float moveAmount;
if (isHorizontal) if (isHorizontal)
{ {
moveAmount = PlayerInput.MouseSpeed.X; moveAmount = PlayerInput.MouseSpeed.X;
barScroll += moveAmount / (frame.Rect.Width - bar.Rect.Width); barScroll += moveAmount / (frame.Rect.Width - bar.Rect.Width);
//newX = Math.Min(Math.Max(newX + moveAmount, 0), frame.Rect.Width - bar.Rect.Width);
//barScroll = (float)newX / ((float)frame.Rect.Width - (float)bar.Rect.Width);
} }
else else
{ {
moveAmount = PlayerInput.MouseSpeed.Y; moveAmount = PlayerInput.MouseSpeed.Y;
barScroll += moveAmount / (frame.Rect.Height - bar.Rect.Height); barScroll += moveAmount / (frame.Rect.Height - bar.Rect.Height);
//newY = Math.Min(Math.Max(newY+moveAmount, 0), frame.Rect.Height - bar.Rect.Height);
//barScroll = (float)newY / ((float)frame.Rect.Height - (float)bar.Rect.Height);
} }
BarScroll = barScroll; BarScroll = barScroll;
+27 -19
View File
@@ -65,7 +65,7 @@ namespace Barotrauma
public static World World; public static World World;
public static LoadingScreen TitleScreen; public static LoadingScreen TitleScreen;
private static bool titleScreenOpen; private static bool loadingScreenOpen;
public static GameSettings Config; public static GameSettings Config;
@@ -123,20 +123,10 @@ namespace Barotrauma
Config.Save("config.xml"); Config.Save("config.xml");
} }
graphicsWidth = Config.GraphicsWidth; ApplyGraphicsSettings();
graphicsHeight = Config.GraphicsHeight;
Graphics.SynchronizeWithVerticalRetrace = Config.VSyncEnabled;
Graphics.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
Graphics.IsFullScreen = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed;
Graphics.PreferredBackBufferWidth = graphicsWidth;
Graphics.PreferredBackBufferHeight = graphicsHeight;
Content.RootDirectory = "Content"; Content.RootDirectory = "Content";
//graphics.SynchronizeWithVerticalRetrace = false;
//graphics.ApplyChanges();
FrameCounter = new FrameCounter(); FrameCounter = new FrameCounter();
//IsMouseVisible = true; //IsMouseVisible = true;
@@ -153,6 +143,20 @@ namespace Barotrauma
FarseerPhysics.Settings.VelocityIterations = 1; FarseerPhysics.Settings.VelocityIterations = 1;
FarseerPhysics.Settings.PositionIterations = 1; FarseerPhysics.Settings.PositionIterations = 1;
}
public void ApplyGraphicsSettings()
{
graphicsWidth = Config.GraphicsWidth;
graphicsHeight = Config.GraphicsHeight;
Graphics.SynchronizeWithVerticalRetrace = Config.VSyncEnabled;
Graphics.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
Graphics.IsFullScreen = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed;
Graphics.PreferredBackBufferWidth = graphicsWidth;
Graphics.PreferredBackBufferHeight = graphicsHeight;
Graphics.ApplyChanges(); Graphics.ApplyChanges();
} }
@@ -190,7 +194,7 @@ namespace Barotrauma
spriteBatch = new SpriteBatch(GraphicsDevice); spriteBatch = new SpriteBatch(GraphicsDevice);
TextureLoader.Init(GraphicsDevice); TextureLoader.Init(GraphicsDevice);
titleScreenOpen = true; loadingScreenOpen = true;
TitleScreen = new LoadingScreen(GraphicsDevice); TitleScreen = new LoadingScreen(GraphicsDevice);
CoroutineManager.StartCoroutine(Load()); CoroutineManager.StartCoroutine(Load());
@@ -237,7 +241,7 @@ namespace Barotrauma
while (!SoundPlayer.Initialized) while (!SoundPlayer.Initialized)
{ {
i++; i++;
TitleScreen.LoadState = Math.Min((float)TitleScreen.LoadState + 40.0f / 41, 70.0f); TitleScreen.LoadState = Math.Min((float)TitleScreen.LoadState + 0.5f*i, 70.0f);
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
} }
@@ -307,12 +311,17 @@ namespace Barotrauma
PlayerInput.Update(Timing.Step); PlayerInput.Update(Timing.Step);
if (titleScreenOpen) if (loadingScreenOpen)
{ {
//reset accumulator if loading
// -> less choppy loading screens because the screen is rendered after each update
// -> no pause caused by leftover time in the accumulator when starting a new shift
Timing.Accumulator = 0.0f;
if (TitleScreen.LoadState >= 100.0f && if (TitleScreen.LoadState >= 100.0f &&
(!waitForKeyHit || PlayerInput.GetKeyboardState.GetPressedKeys().Length>0 || PlayerInput.LeftButtonClicked())) (!waitForKeyHit || PlayerInput.GetKeyboardState.GetPressedKeys().Length>0 || PlayerInput.LeftButtonClicked()))
{ {
titleScreenOpen = false; loadingScreenOpen = false;
} }
} }
else if (hasLoaded) else if (hasLoaded)
@@ -339,7 +348,6 @@ namespace Barotrauma
GUI.Update((float)Timing.Step); GUI.Update((float)Timing.Step);
} }
CoroutineManager.Update((float)Timing.Step, paused ? 0.0f : (float)Timing.Step); CoroutineManager.Update((float)Timing.Step, paused ? 0.0f : (float)Timing.Step);
Timing.Accumulator -= Timing.Step; Timing.Accumulator -= Timing.Step;
@@ -358,7 +366,7 @@ namespace Barotrauma
FrameCounter.Update(deltaTime); FrameCounter.Update(deltaTime);
if (titleScreenOpen) if (loadingScreenOpen)
{ {
TitleScreen.Draw(spriteBatch, GraphicsDevice, (float)deltaTime); TitleScreen.Draw(spriteBatch, GraphicsDevice, (float)deltaTime);
} }
@@ -372,7 +380,7 @@ namespace Barotrauma
public static CoroutineHandle ShowLoading(IEnumerable<object> loader, bool waitKeyHit = true) public static CoroutineHandle ShowLoading(IEnumerable<object> loader, bool waitKeyHit = true)
{ {
waitForKeyHit = waitKeyHit; waitForKeyHit = waitKeyHit;
titleScreenOpen = true; loadingScreenOpen = true;
TitleScreen.LoadState = null; TitleScreen.LoadState = null;
return CoroutineManager.StartCoroutine(TitleScreen.DoLoading(loader)); return CoroutineManager.StartCoroutine(TitleScreen.DoLoading(loader));
} }
+1 -1
View File
@@ -237,7 +237,7 @@ namespace Barotrauma
GUITextBlock textBlock = new GUITextBlock( GUITextBlock textBlock = new GUITextBlock(
new Rectangle(40, 0, 0, 25), new Rectangle(40, 0, 0, 25),
character.Info.Name + " (" + character.Info.Job.Name + ")", ToolBox.LimitString(character.Info.Name + " (" + character.Info.Job.Name + ")", GUI.Font, frame.Rect.Width-20),
Color.Transparent, Color.White, Color.Transparent, Color.White,
Alignment.Left, Alignment.Left, Alignment.Left, Alignment.Left,
null, frame); null, frame);
@@ -261,7 +261,6 @@ namespace Barotrauma
{ {
if (leavingSub != Submarine.MainSub && !leavingSub.DockedTo.Contains(Submarine.MainSub)) if (leavingSub != Submarine.MainSub && !leavingSub.DockedTo.Contains(Submarine.MainSub))
{ {
Submarine oldMainSub = Submarine.MainSub;
Submarine.MainSub = leavingSub; Submarine.MainSub = leavingSub;
GameMain.GameSession.Submarine = leavingSub; GameMain.GameSession.Submarine = leavingSub;
@@ -283,7 +283,7 @@ namespace Barotrauma.Tutorials
infoBox = CreateInfoFrame("Steer the submarine downwards, heading further into the cavern."); infoBox = CreateInfoFrame("Steer the submarine downwards, heading further into the cavern.");
while (Submarine.MainSub.WorldPosition.Y > 31900.0f) while (Submarine.MainSub.WorldPosition.Y > 36500.0f)
{ {
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
} }
+11 -1
View File
@@ -144,7 +144,17 @@ namespace Barotrauma
{ {
dummyLocations = new Location[2]; dummyLocations = new Location[2];
MTRandom rand = new MTRandom(ToolBox.StringToInt(GameMain.NetLobbyScreen.LevelSeed)); string seed = "";
if (GameMain.GameSession != null && GameMain.GameSession.Level != null)
{
seed = GameMain.GameSession.Level.Seed;
}
else if (GameMain.NetLobbyScreen != null)
{
seed = GameMain.NetLobbyScreen.LevelSeed;
}
MTRandom rand = new MTRandom(ToolBox.StringToInt(seed));
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
dummyLocations[i] = Location.CreateRandom(new Vector2((float)rand.NextDouble() * 10000.0f, (float)rand.NextDouble() * 10000.0f)); dummyLocations[i] = Location.CreateRandom(new Vector2((float)rand.NextDouble() * 10000.0f, (float)rand.NextDouble() * 10000.0f));
+7 -4
View File
@@ -186,17 +186,20 @@ namespace Barotrauma
foreach (XAttribute attribute in subElement.Attributes()) foreach (XAttribute attribute in subElement.Attributes())
{ {
InputType inputType; InputType inputType;
Keys key;
int mouseButton;
if (Enum.TryParse(attribute.Name.ToString(), true, out inputType)) if (Enum.TryParse(attribute.Name.ToString(), true, out inputType))
{ {
int mouseButton;
if (int.TryParse(attribute.Value.ToString(), out mouseButton)) if (int.TryParse(attribute.Value.ToString(), out mouseButton))
{ {
keyMapping[(int)inputType] = new KeyOrMouse(mouseButton); keyMapping[(int)inputType] = new KeyOrMouse(mouseButton);
} }
else if (Enum.TryParse(attribute.Value.ToString(), true, out key)) else
{ {
keyMapping[(int)inputType] = new KeyOrMouse(key); Keys key;
if (Enum.TryParse(attribute.Value.ToString(), true, out key))
{
keyMapping[(int)inputType] = new KeyOrMouse(key);
}
} }
} }
} }
@@ -117,8 +117,6 @@ namespace Barotrauma.Items.Components
foreach (FabricableItem fi in fabricableItems) foreach (FabricableItem fi in fabricableItems)
{ {
Color color = ((itemList.CountChildren % 2) == 0) ? Color.Transparent : Color.Black * 0.3f;
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 50), Color.Transparent, null, itemList) GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 50), Color.Transparent, null, itemList)
{ {
UserData = fi, UserData = fi,
@@ -429,7 +427,7 @@ namespace Barotrauma.Items.Components
ItemContainer container = item.GetComponent<ItemContainer>(); ItemContainer container = item.GetComponent<ItemContainer>();
foreach (Tuple<ItemPrefab, int> ip in fabricableItem.RequiredItems) foreach (Tuple<ItemPrefab, int> ip in fabricableItem.RequiredItems)
{ {
if (Array.FindAll(container.Inventory.Items, it => it != null && it.Prefab == ip.Item1).Count() < ip.Item2) return false; if (Array.FindAll(container.Inventory.Items, it => it != null && it.Prefab == ip.Item1).Length < ip.Item2) return false;
} }
return true; return true;
@@ -433,13 +433,12 @@ namespace Barotrauma.Items.Components
{ {
IsActive = true; IsActive = true;
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
int x = GuiFrame.Rect.X; int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y; int y = GuiFrame.Rect.Y;
GuiFrame.Draw(spriteBatch); GuiFrame.Draw(spriteBatch);
float xOffset = (graphTimer / (float)updateGraphInterval); float xOffset = graphTimer / updateGraphInterval;
//GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true); //GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
@@ -130,7 +130,7 @@ namespace Barotrauma.Items.Components
levelEndTickBox = new GUITickBox( levelEndTickBox = new GUITickBox(
new Rectangle(5, 90, 15, 15), new Rectangle(5, 90, 15, 15),
GameMain.GameSession == null ? "" : ToolBox.LimitString(GameMain.GameSession.StartLocation.Name, 20), GameMain.GameSession == null ? "" : ToolBox.LimitString(GameMain.GameSession.EndLocation.Name, 20),
Alignment.TopLeft, GUI.SmallFont, GuiFrame); Alignment.TopLeft, GUI.SmallFont, GuiFrame);
levelEndTickBox.Enabled = false; levelEndTickBox.Enabled = false;
levelEndTickBox.OnSelected = SelectDestination; levelEndTickBox.OnSelected = SelectDestination;
@@ -109,8 +109,6 @@ namespace Barotrauma.Items.Components
ApplyStatusEffects(ActionType.OnActive, deltaTime, null); ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
List<Connection> alreadyChecked = new List<Connection>();
List<Connection> connections = item.Connections; List<Connection> connections = item.Connections;
if (connections == null) return; if (connections == null) return;
@@ -151,8 +149,6 @@ namespace Barotrauma.Items.Components
{ {
fullPower += powerContainer.CurrPowerOutput; fullPower += powerContainer.CurrPowerOutput;
} }
alreadyChecked.Add(recipient);
} }
else else
{ {
+1 -1
View File
@@ -92,7 +92,7 @@ namespace Barotrauma.Items.Components
List<Body>ropeList = PathManager.EvenlyDistributeShapesAlongPath(GameMain.World, ropePath, shape, BodyType.Dynamic, (int)(length/sectionLength)); List<Body>ropeList = PathManager.EvenlyDistributeShapesAlongPath(GameMain.World, ropePath, shape, BodyType.Dynamic, (int)(length/sectionLength));
ropeBodies = new PhysicsBody[ropeList.Count()]; ropeBodies = new PhysicsBody[ropeList.Count];
for (int i = 0; i<ropeBodies.Length; i++) for (int i = 0; i<ropeBodies.Length; i++)
{ {
ropeList[i].Mass = 0.01f; ropeList[i].Mass = 0.01f;
@@ -12,7 +12,7 @@ namespace Barotrauma.Items.Components
{ {
private static Texture2D panelTexture; private static Texture2D panelTexture;
private static Sprite connector; private static Sprite connector;
private static Sprite wireCorner, wireVertical, wireHorizontal; private static Sprite wireVertical;
//how many wires can be linked to a single connector //how many wires can be linked to a single connector
public const int MaxLinked = 5; public const int MaxLinked = 5;
@@ -67,9 +67,7 @@ namespace Barotrauma.Items.Components
connector = new Sprite(panelTexture, new Rectangle(470, 102, 19,43), Vector2.Zero, 0.0f); connector = new Sprite(panelTexture, new Rectangle(470, 102, 19,43), Vector2.Zero, 0.0f);
connector.Origin = new Vector2(9.5f, 10.0f); connector.Origin = new Vector2(9.5f, 10.0f);
wireCorner = new Sprite(panelTexture, new Rectangle(448, 0, 64, 64), new Vector2(-32.0f, -32.0f), 0.0f);
wireVertical = new Sprite(panelTexture, new Rectangle(408, 1, 11, 102), Vector2.Zero, 0.0f); wireVertical = new Sprite(panelTexture, new Rectangle(408, 1, 11, 102), Vector2.Zero, 0.0f);
wireHorizontal = new Sprite(panelTexture, new Rectangle(496, 64, 16, 16), new Vector2(-8.0f, -8.0f), 0.0f);
} }
this.item = item; this.item = item;
@@ -243,8 +241,6 @@ namespace Barotrauma.Items.Components
int wireInterval = (height - 20) / Math.Max(totalWireCount,1); int wireInterval = (height - 20) / Math.Max(totalWireCount,1);
float rightWireX = x + width;
float leftWireX = x;
foreach (Connection c in panel.Connections) foreach (Connection c in panel.Connections)
{ {
//if dragging a wire, let the Inventory know so that the wire can be //if dragging a wire, let the Inventory know so that the wire can be
@@ -284,6 +280,18 @@ namespace Barotrauma.Items.Components
} }
} }
if (draggingConnected != null)
{
DrawWire(spriteBatch, draggingConnected, draggingConnected.Item, PlayerInput.MousePosition, new Vector2(x + width / 2, y + height), mouseInRect, false);
if (!PlayerInput.LeftButtonHeld())
{
panel.Item.NewComponentEvent(panel, true, true);
//draggingConnected.Drop(Character);
draggingConnected = null;
}
}
//if the Character using the panel has a wire item equipped //if the Character using the panel has a wire item equipped
//and the wire hasn't been connected yet, draw it on the panel //and the wire hasn't been connected yet, draw it on the panel
if (equippedWire!=null) if (equippedWire!=null)
@@ -211,10 +211,11 @@ namespace Barotrauma.Items.Components
if (connections[0] != null && connections[0].Item.Submarine != null) sub = connections[0].Item.Submarine; if (connections[0] != null && connections[0].Item.Submarine != null) sub = connections[0].Item.Submarine;
if (connections[1] != null && connections[1].Item.Submarine != null) sub = connections[1].Item.Submarine; if (connections[1] != null && connections[1].Item.Submarine != null) sub = connections[1].Item.Submarine;
if (item.Submarine != null && item.Submarine != sub) if (item.Submarine != sub)
{ {
ClearConnections(); ClearConnections();
Nodes.Clear(); Nodes.Clear();
return;
} }
newNodePos = RoundNode(item.Position, item.CurrentHull) - sub.HiddenSubPosition; newNodePos = RoundNode(item.Position, item.CurrentHull) - sub.HiddenSubPosition;
@@ -480,8 +481,8 @@ namespace Barotrauma.Items.Components
if (Nodes == null || Nodes.Count == 0) return componentElement; if (Nodes == null || Nodes.Count == 0) return componentElement;
string[] nodeCoords = new string[Nodes.Count() * 2]; string[] nodeCoords = new string[Nodes.Count * 2];
for (int i = 0; i < Nodes.Count(); i++) for (int i = 0; i < Nodes.Count; i++)
{ {
nodeCoords[i * 2] = Nodes[i].X.ToString(CultureInfo.InvariantCulture); nodeCoords[i * 2] = Nodes[i].X.ToString(CultureInfo.InvariantCulture);
nodeCoords[i * 2 + 1] = Nodes[i].Y.ToString(CultureInfo.InvariantCulture); nodeCoords[i * 2 + 1] = Nodes[i].Y.ToString(CultureInfo.InvariantCulture);
+1 -10
View File
@@ -64,7 +64,7 @@ namespace Barotrauma.Items.Components
this.item = item; this.item = item;
var sprites = element.Elements().Where(x => x.Name.ToString() == "sprite").ToList(); var sprites = element.Elements().Where(x => x.Name.ToString() == "sprite").ToList();
int spriteCount = sprites.Count(); int spriteCount = sprites.Count;
wearableSprites = new WearableSprite[spriteCount]; wearableSprites = new WearableSprite[spriteCount];
limbType = new LimbType[spriteCount]; limbType = new LimbType[spriteCount];
limb = new Limb[spriteCount]; limb = new Limb[spriteCount];
@@ -172,18 +172,9 @@ namespace Barotrauma.Items.Components
item.SetTransform(picker.SimPosition, 0.0f); item.SetTransform(picker.SimPosition, 0.0f);
Item[] containedItems = item.ContainedItems;
ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker); ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
PlaySound(ActionType.OnWearing, picker.WorldPosition); PlaySound(ActionType.OnWearing, picker.WorldPosition);
//if (containedItems == null) return;
//for (int j = 0; j < containedItems.Length; j++)
//{
// if (containedItems[j] == null) continue;
// containedItems[j].ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
//}
} }
protected override void RemoveComponentSpecific() protected override void RemoveComponentSpecific()
+1 -1
View File
@@ -433,7 +433,7 @@ namespace Barotrauma
int itemCapacity = container.Capacity; int itemCapacity = container.Capacity;
var slot = slots[slotIndex]; var slot = slots[slotIndex];
Rectangle containerRect = new Rectangle(slot.Rect.X - 5, slot.Rect.Y - (40 + 10) * itemCapacity - 5, new Rectangle(slot.Rect.X - 5, slot.Rect.Y - (40 + 10) * itemCapacity - 5,
slot.Rect.Width + 10, slot.Rect.Height + (40 + 10) * itemCapacity + 10); slot.Rect.Width + 10, slot.Rect.Height + (40 + 10) * itemCapacity + 10);
Rectangle subRect = slot.Rect; Rectangle subRect = slot.Rect;
+1 -1
View File
@@ -249,7 +249,7 @@ namespace Barotrauma
if (c.Position.X < position.X - range || c.Position.X > position.X + size.X + range) continue; if (c.Position.X < position.X - range || c.Position.X > position.X + size.X + range) continue;
if (c.Position.Y < position.Y - size.Y || c.Position.Y > hull.Rect.Y) continue; if (c.Position.Y < position.Y - size.Y || c.Position.Y > hull.Rect.Y) continue;
float dmg = (float)Math.Sqrt(size.X) * deltaTime / c.AnimController.Limbs.Count(); float dmg = (float)Math.Sqrt(size.X) * deltaTime / c.AnimController.Limbs.Length;
foreach (Limb limb in c.AnimController.Limbs) foreach (Limb limb in c.AnimController.Limbs)
{ {
if (limb.WearingItems.Find(w => w!=null && w.WearableComponent.Item.FireProof)!=null) continue; if (limb.WearingItems.Find(w => w!=null && w.WearableComponent.Item.FireProof)!=null) continue;
+1 -1
View File
@@ -311,7 +311,7 @@ namespace Barotrauma
positionsOfInterest.Add(new InterestingPosition(tunnel.Last(), PositionType.Cave)); positionsOfInterest.Add(new InterestingPosition(tunnel.Last(), PositionType.Cave));
if (tunnel.Count() > 4) positionsOfInterest.Add(new InterestingPosition(tunnel[tunnel.Count() / 2], PositionType.Cave)); if (tunnel.Count > 4) positionsOfInterest.Add(new InterestingPosition(tunnel[tunnel.Count / 2], PositionType.Cave));
pathCells.AddRange(newPathCells); pathCells.AddRange(newPathCells);
} }
@@ -124,14 +124,8 @@ namespace Barotrauma
if (backgroundCreatureManager!=null) backgroundCreatureManager.Draw(spriteBatch); if (backgroundCreatureManager!=null) backgroundCreatureManager.Draw(spriteBatch);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront, for (int i = 0; i < 4; i++)
BlendState.Additive,
SamplerState.LinearWrap, DepthStencilState.Default, null, null,
cam.Transform);
for (int i = 1; i < 4; i++)
{ {
float scale = 1.0f - i * 0.2f; float scale = 1.0f - i * 0.2f;
@@ -151,7 +145,7 @@ namespace Barotrauma
spriteBatch.Draw(dustParticles.Texture, spriteBatch.Draw(dustParticles.Texture,
new Vector2(cam.WorldViewCenter.X, -cam.WorldViewCenter.Y), new Vector2(cam.WorldViewCenter.X, -cam.WorldViewCenter.Y),
dustParticles.SourceRect, Color.White * alpha, 0.0f, dustParticles.SourceRect, Color.White * alpha, 0.0f,
new Vector2(cam.WorldView.Width, cam.WorldView.Height) * 0.5f / scale, scale, SpriteEffects.None, 0); new Vector2(cam.WorldView.Width, cam.WorldView.Height) * 0.5f / scale, scale, SpriteEffects.None, 1.0f - scale);
} }
spriteBatch.End(); spriteBatch.End();
@@ -271,8 +271,6 @@ namespace Barotrauma.RuinGeneration
foreach (Corridor corridor in corridors) foreach (Corridor corridor in corridors)
{ {
List<Line> corridorWalls = new List<Line>();
corridor.CreateWalls(); corridor.CreateWalls();
foreach (BTRoom leaf in rooms) foreach (BTRoom leaf in rooms)
@@ -361,7 +359,7 @@ namespace Barotrauma.RuinGeneration
var prop = RuinStructure.GetRandom(RuinStructureType.Prop, alignments[Rand.Int(alignments.Length, false)]); var prop = RuinStructure.GetRandom(RuinStructureType.Prop, alignments[Rand.Int(alignments.Length, false)]);
Vector2 size = (prop.Prefab is StructurePrefab) ? (prop.Prefab as StructurePrefab).Size : Vector2.Zero; Vector2 size = (prop.Prefab is StructurePrefab) ? ((StructurePrefab)prop.Prefab).Size : Vector2.Zero;
var shape = shapes[Rand.Int(shapes.Count, false)]; var shape = shapes[Rand.Int(shapes.Count, false)];
@@ -385,7 +383,7 @@ namespace Barotrauma.RuinGeneration
if (prop.Prefab is ItemPrefab) if (prop.Prefab is ItemPrefab)
{ {
var item = new Item(prop.Prefab as ItemPrefab, position, null); var item = new Item((ItemPrefab)prop.Prefab, position, null);
item.MoveWithLevel = true; item.MoveWithLevel = true;
} }
else else
+1 -1
View File
@@ -182,7 +182,7 @@ namespace Barotrauma.Lights
{ {
ClearCachedShadows(); ClearCachedShadows();
for (int i = 0; i < vertices.Count(); i++) for (int i = 0; i < vertices.Length; i++)
{ {
vertices[i] += amount; vertices[i] += amount;
losVertices[i] += amount; losVertices[i] += amount;
+2 -2
View File
@@ -98,8 +98,8 @@ namespace Barotrauma.Lights
public LightSource (XElement element) public LightSource (XElement element)
: this(Vector2.Zero, 100.0f, Color.White, null) : this(Vector2.Zero, 100.0f, Color.White, null)
{ {
float range = ToolBox.GetAttributeFloat(element, "range", 100.0f); range = ToolBox.GetAttributeFloat(element, "range", 100.0f);
Color color = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One)); color = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One));
CastShadows = ToolBox.GetAttributeBool(element, "castshadows", true); CastShadows = ToolBox.GetAttributeBool(element, "castshadows", true);
-3
View File
@@ -96,9 +96,6 @@ namespace Barotrauma
(int)sl.wallVertices.Max(v => v.X + position.X), (int)sl.wallVertices.Max(v => v.X + position.X),
(int)sl.wallVertices.Min(v => v.Y + position.Y)); (int)sl.wallVertices.Min(v => v.Y + position.Y));
int width = sl.rect.Width - sl.rect.X;
int height = sl.rect.Y - sl.rect.Height;
sl.rect = new Rectangle((int)position.X, (int)position.Y, 1, 1); sl.rect = new Rectangle((int)position.X, (int)position.Y, 1, 1);
return sl; return sl;
+30 -18
View File
@@ -28,12 +28,16 @@ namespace Barotrauma
public WallSection(Rectangle rect) public WallSection(Rectangle rect)
{ {
System.Diagnostics.Debug.Assert(rect.Width > 0 && rect.Height > 0);
this.rect = rect; this.rect = rect;
damage = 0.0f; damage = 0.0f;
} }
public WallSection(Rectangle rect, float damage) public WallSection(Rectangle rect, float damage)
{ {
System.Diagnostics.Debug.Assert(rect.Width > 0 && rect.Height > 0);
this.rect = rect; this.rect = rect;
this.damage = 0.0f; this.damage = 0.0f;
} }
@@ -182,7 +186,7 @@ namespace Barotrauma
{ {
base.Move(amount); base.Move(amount);
for (int i = 0; i < sections.Count(); i++) for (int i = 0; i < sections.Length; i++)
{ {
Rectangle r = sections[i].rect; Rectangle r = sections[i].rect;
r.X += (int)amount.X; r.X += (int)amount.X;
@@ -209,6 +213,7 @@ namespace Barotrauma
: base(sp, submarine) : base(sp, submarine)
{ {
if (rectangle.Width == 0 || rectangle.Height == 0) return; if (rectangle.Width == 0 || rectangle.Height == 0) return;
System.Diagnostics.Debug.Assert(rectangle.Width > 0 && rectangle.Height > 0);
rect = rectangle; rect = rectangle;
prefab = sp; prefab = sp;
@@ -290,32 +295,39 @@ namespace Barotrauma
private void CreateSections() private void CreateSections()
{ {
int xsections = 1, ysections = 1; int xsections = 1, ysections = 1;
int width, height; int width = rect.Width, height = rect.Height;
if (!HasBody) if (!HasBody)
{ {
sections = new WallSection[1]; if (flippedX && isHorizontal)
sections[0] = new WallSection(rect); {
return; xsections = (int)Math.Ceiling((float)rect.Width / prefab.sprite.SourceRect.Width);
width = prefab.sprite.SourceRect.Width;
} }
else
if (isHorizontal) {
{ xsections = 1;
xsections = (int)Math.Ceiling((float)rect.Width / wallSectionSize); ysections = 1;
}
sections = new WallSection[xsections]; sections = new WallSection[xsections];
width = (int)wallSectionSize;
height = rect.Height;
} }
else else
{ {
ysections = (int)Math.Ceiling((float)rect.Height / wallSectionSize); if (isHorizontal)
sections = new WallSection[ysections]; {
width = rect.Width; xsections = (int)Math.Ceiling((float)rect.Width / wallSectionSize);
height = (int)wallSectionSize; sections = new WallSection[xsections];
width = (int)wallSectionSize;
}
else
{
ysections = (int)Math.Ceiling((float)rect.Height / wallSectionSize);
sections = new WallSection[ysections];
height = (int)wallSectionSize;
}
} }
for (int x = 0; x < xsections; x++) for (int x = 0; x < xsections; x++)
{ {
for (int y = 0; y < ysections; y++) for (int y = 0; y < ysections; y++)
@@ -885,7 +897,7 @@ namespace Barotrauma
(int)(rect.Y - Submarine.HiddenSubPosition.Y) + "," + (int)(rect.Y - Submarine.HiddenSubPosition.Y) + "," +
rect.Width + "," + rect.Height)); rect.Width + "," + rect.Height));
for (int i = 0; i < sections.Count(); i++) for (int i = 0; i < sections.Length; i++)
{ {
if (sections[i].damage == 0.0f) continue; if (sections[i].damage == 0.0f) continue;
+19 -17
View File
@@ -172,7 +172,7 @@ namespace Barotrauma
{ {
get get
{ {
return subBody ==null ? Vector2.Zero : subBody.Position; return subBody == null ? Vector2.Zero : subBody.Position;
} }
} }
@@ -304,18 +304,23 @@ namespace Barotrauma
{ {
MapEntity.mapEntityList[i].Draw(spriteBatch, editing); MapEntity.mapEntityList[i].Draw(spriteBatch, editing);
} }
} }
public static void DrawFront(SpriteBatch spriteBatch, bool editing = false) public static void DrawFront(SpriteBatch spriteBatch, bool editing = false, Predicate<MapEntity> predicate = null)
{ {
for (int i = 0; i < MapEntity.mapEntityList.Count; i++) for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{ {
if (MapEntity.mapEntityList[i].DrawOverWater) if (!MapEntity.mapEntityList[i].DrawOverWater) continue;
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, false);
}
if (predicate != null)
{
if (!predicate(MapEntity.mapEntityList[i])) continue;
}
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, false);
}
if (GameMain.DebugDraw) if (GameMain.DebugDraw)
{ {
foreach (Submarine sub in Submarine.Loaded) foreach (Submarine sub in Submarine.Loaded)
@@ -335,10 +340,7 @@ namespace Barotrauma
prevPos = currPos; prevPos = currPos;
} }
} }
} }
} }
@@ -361,13 +363,14 @@ namespace Barotrauma
{ {
for (int i = 0; i < MapEntity.mapEntityList.Count; i++) for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{ {
if (!MapEntity.mapEntityList[i].DrawBelowWater) continue;
if (predicate != null) if (predicate != null)
{ {
if (!predicate(MapEntity.mapEntityList[i])) continue; if (!predicate(MapEntity.mapEntityList[i])) continue;
} }
if (MapEntity.mapEntityList[i].DrawBelowWater) MapEntity.mapEntityList[i].Draw(spriteBatch, editing, true);
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, true);
} }
} }
@@ -484,14 +487,14 @@ namespace Barotrauma
/// check visibility between two points (in sim units) /// check visibility between two points (in sim units)
/// </summary> /// </summary>
/// <returns>a physics body that was between the points (or null)</returns> /// <returns>a physics body that was between the points (or null)</returns>
public static Body CheckVisibility(Vector2 rayStart, Vector2 rayEnd, bool ignoreLevel = false) public static Body CheckVisibility(Vector2 rayStart, Vector2 rayEnd, bool ignoreLevel = false, bool ignoreSubs = false)
{ {
Body closestBody = null; Body closestBody = null;
float closestFraction = 1.0f; float closestFraction = 1.0f;
if (Vector2.Distance(rayStart, rayEnd) < 0.01f) if (Vector2.Distance(rayStart, rayEnd) < 0.01f)
{ {
closestFraction = 0.01f; lastPickedPosition = rayEnd;
return null; return null;
} }
@@ -501,6 +504,7 @@ namespace Barotrauma
(!fixture.CollisionCategories.HasFlag(Physics.CollisionWall) && !fixture.CollisionCategories.HasFlag(Physics.CollisionLevel))) return -1; (!fixture.CollisionCategories.HasFlag(Physics.CollisionWall) && !fixture.CollisionCategories.HasFlag(Physics.CollisionLevel))) return -1;
if (ignoreLevel && fixture.CollisionCategories == Physics.CollisionLevel) return -1; if (ignoreLevel && fixture.CollisionCategories == Physics.CollisionLevel) return -1;
if (ignoreSubs && fixture.Body.UserData is Submarine) return -1;
Structure structure = fixture.Body.UserData as Structure; Structure structure = fixture.Body.UserData as Structure;
if (structure != null) if (structure != null)
@@ -527,7 +531,7 @@ namespace Barotrauma
//movement ---------------------------------------------------- //movement ----------------------------------------------------
private bool flippedX = false; private bool flippedX;
public bool FlippedX public bool FlippedX
{ {
get { return flippedX; } get { return flippedX; }
@@ -644,8 +648,6 @@ namespace Barotrauma
{ {
if (!MathUtils.IsValid(position)) return; if (!MathUtils.IsValid(position)) return;
Vector2 prevPos = subBody.Position;
subBody.SetPosition(position); subBody.SetPosition(position);
foreach (Submarine sub in loaded) foreach (Submarine sub in loaded)
@@ -674,7 +676,7 @@ namespace Barotrauma
{ {
Submarine closest = null; Submarine closest = null;
float closestDist = 0.0f; float closestDist = 0.0f;
foreach (Submarine sub in Submarine.loaded) foreach (Submarine sub in loaded)
{ {
float dist = Vector2.Distance(worldPosition, sub.WorldPosition); float dist = Vector2.Distance(worldPosition, sub.WorldPosition);
if (closest == null || dist < closestDist) if (closest == null || dist < closestDist)
+1 -1
View File
@@ -397,7 +397,7 @@ namespace Barotrauma
int particleAmount = (int)(wallImpact*10.0f); int particleAmount = (int)(wallImpact*10.0f);
for (int i = 0; i < particleAmount; i++) for (int i = 0; i < particleAmount; i++)
{ {
var particle = GameMain.ParticleManager.CreateParticle("iceshards", GameMain.ParticleManager.CreateParticle("iceshards",
ConvertUnits.ToDisplayUnits(particlePos[0]) + Rand.Vector(Rand.Range(1.0f, 50.0f)), ConvertUnits.ToDisplayUnits(particlePos[0]) + Rand.Vector(Rand.Range(1.0f, 50.0f)),
Rand.Vector(Rand.Range(50.0f,500.0f)) + Velocity); Rand.Vector(Rand.Range(50.0f,500.0f)) + Velocity);
} }
+1 -3
View File
@@ -465,10 +465,8 @@ namespace Barotrauma
WayPoint[] ladderPoints = new WayPoint[2]; WayPoint[] ladderPoints = new WayPoint[2];
ladderPoints[0] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y - item.Rect.Height + heightFromFloor), SpawnType.Path, submarine); ladderPoints[0] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y - item.Rect.Height + heightFromFloor), SpawnType.Path, submarine);
ladderPoints[1] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y-1.0f), SpawnType.Path, submarine); ladderPoints[1] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y-1.0f), SpawnType.Path, submarine);
WayPoint prevPoint = ladderPoints[0]; WayPoint prevPoint = ladderPoints[0];
Vector2 prevPos = prevPoint.SimPosition; Vector2 prevPos = prevPoint.SimPosition;
@@ -619,7 +617,7 @@ namespace Barotrauma
float dist = Vector2.Distance(wp.Position, Position); float dist = Vector2.Distance(wp.Position, Position);
if (closest == null || dist < closestDist) if (closest == null || dist < closestDist)
{ {
var body = Submarine.CheckVisibility(SimPosition, wp.SimPosition, true); var body = Submarine.CheckVisibility(SimPosition, wp.SimPosition, true, true);
if (body != null && body != ignoredBody && !(body.UserData is Submarine)) if (body != null && body != ignoredBody && !(body.UserData is Submarine))
{ {
if (body.UserData is Structure || body.FixtureList[0].CollisionCategories.HasFlag(Physics.CollisionWall)) continue; if (body.UserData is Structure || body.FixtureList[0].CollisionCategories.HasFlag(Physics.CollisionWall)) continue;
+26 -16
View File
@@ -835,19 +835,36 @@ namespace Barotrauma.Networking
roundStartSeed = DateTime.Now.Millisecond; roundStartSeed = DateTime.Now.Millisecond;
Rand.SetSyncedSeed(roundStartSeed); Rand.SetSyncedSeed(roundStartSeed);
GameMain.GameSession = new GameSession(selectedSub, "", selectedMode, Mission.MissionTypes[GameMain.NetLobbyScreen.MissionTypeIndex]); bool couldNotStart = false;
yield return CoroutineStatus.Running;
int teamCount = 1; int teamCount = 1;
int hostTeam = 1; int hostTeam = 1;
if (GameMain.GameSession.gameMode.Mission != null &&
GameMain.GameSession.gameMode.Mission.AssignTeamIDs(connectedClients,out hostTeam)) try
{ {
teamCount = 2; GameMain.GameSession = new GameSession(selectedSub, "", selectedMode, Mission.MissionTypes[GameMain.NetLobbyScreen.MissionTypeIndex]);
if (GameMain.GameSession.gameMode.Mission != null &&
GameMain.GameSession.gameMode.Mission.AssignTeamIDs(connectedClients,out hostTeam))
{
teamCount = 2;
}
GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.LevelSeed, teamCount > 1);
} }
GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.LevelSeed, teamCount > 1); catch (Exception e)
{
DebugConsole.ThrowError("Failed to start a new round", e);
//try again in >5 seconds
if (autoRestart) AutoRestartTimer = Math.Max(AutoRestartInterval, 5.0f);
GameMain.NetLobbyScreen.StartButton.Enabled = true;
couldNotStart = true;
}
if (couldNotStart) yield return CoroutineStatus.Failure;
GameServer.Log("Starting a new round...", Color.Cyan); GameServer.Log("Starting a new round...", Color.Cyan);
GameServer.Log("Submarine: " + selectedSub.Name, Color.Cyan); GameServer.Log("Submarine: " + selectedSub.Name, Color.Cyan);
@@ -1014,6 +1031,7 @@ namespace Barotrauma.Networking
var cinematic = new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, endPreviewLength); var cinematic = new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, endPreviewLength);
new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, endPreviewLength);
float secondsLeft = endPreviewLength; float secondsLeft = endPreviewLength;
do do
@@ -1119,18 +1137,10 @@ namespace Barotrauma.Networking
private void UpdateCrewFrame() private void UpdateCrewFrame()
{ {
List<Character> crew = new List<Character>();
foreach (Client c in connectedClients) foreach (Client c in connectedClients)
{ {
if (c.Character == null || !c.inGame) continue; if (c.Character == null || !c.inGame) continue;
crew.Add(c.Character);
} }
if (myCharacter != null) crew.Add(myCharacter);
//if (GameMain.GameSession!=null) GameMain.GameSession.CrewManager.CreateCrewFrame(crew);
} }
public void NewTraitor(Character traitor, Character target) public void NewTraitor(Character traitor, Character target)
@@ -1184,7 +1194,7 @@ namespace Barotrauma.Networking
int resentMessages = 0; int resentMessages = 0;
int clientListHeight = connectedClients.Count() * 40; int clientListHeight = connectedClients.Count * 40;
float scrollBarHeight = (height - 110) / (float)Math.Max(clientListHeight, 110); float scrollBarHeight = (height - 110) / (float)Math.Max(clientListHeight, 110);
if (clientListScrollBar.BarSize != scrollBarHeight) if (clientListScrollBar.BarSize != scrollBarHeight)
+2 -1
View File
@@ -119,8 +119,9 @@ namespace Barotrauma.Networking
text = text.ToLower(); text = text.ToLower();
foreach (GUITextBlock textBlock in listBox.children) foreach (GUIComponent child in listBox.children)
{ {
var textBlock = child as GUITextBlock;
if (textBlock == null) continue; if (textBlock == null) continue;
textBlock.Visible = textBlock.Text.ToLower().Contains(text); textBlock.Visible = textBlock.Text.ToLower().Contains(text);
+82 -12
View File
@@ -8,6 +8,7 @@ using System.Text;
#if WINDOWS #if WINDOWS
using System.Management; using System.Management;
using System.Windows.Forms; using System.Windows.Forms;
using Microsoft.Xna.Framework.Graphics;
#endif #endif
#endregion #endregion
@@ -20,6 +21,8 @@ namespace Barotrauma
/// </summary> /// </summary>
public static class Program public static class Program
{ {
private static int restartAttempts;
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
@@ -28,21 +31,87 @@ namespace Barotrauma
{ {
using (var game = new GameMain()) using (var game = new GameMain())
{ {
#if !DEBUG #if DEBUG
try game.Run();
#else
bool attemptRestart = false;
do
{ {
#endif try
game.Run(); {
#if !DEBUG game.Run();
} attemptRestart = false;
catch (Exception e) }
{ catch (Exception e)
CrashDump(game, "crashreport.txt", e); {
} if (restartAttempts < 5 && CheckException(game, e))
{
attemptRestart = true;
restartAttempts++;
}
else
{
CrashDump(game, "crashreport.txt", e);
}
}
} while (attemptRestart);
#endif #endif
} }
} }
private static bool CheckException(GameMain game, Exception e)
{
#if WINDOWS
if (e is SharpDX.SharpDXException)
{
switch ((uint)((SharpDX.SharpDXException)e).ResultCode.Code)
{
case 0x887A0022: //DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
switch (restartAttempts)
{
case 0:
//just wait and try again
System.Threading.Thread.Sleep(100);
return true;
case 1:
//force focus to this window
var myForm = (System.Windows.Forms.Form)System.Windows.Forms.Form.FromHandle(game.Window.Handle);
myForm.Focus();
return true;
case 2:
//try disabling hardware mode switch
if (GameMain.Config.WindowMode == WindowMode.Fullscreen)
{
DebugConsole.NewMessage("Failed to set fullscreen mode, switching configuration to borderless windowed", Microsoft.Xna.Framework.Color.Red);
GameMain.Config.WindowMode = WindowMode.BorderlessWindowed;
GameMain.Config.Save("config.xml");
}
return false;
default:
return false;
}
case 0x80070057: //E_INVALIDARG/Invalid Arguments
DebugConsole.NewMessage("Invalid graphics settings, attempting to fix", Microsoft.Xna.Framework.Color.Red);
GameMain.Config.GraphicsWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
GameMain.Config.GraphicsHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
game.ApplyGraphicsSettings();
return true;
default:
return false;
}
}
#endif
return false;
}
public static void CrashMessageBox(string message) public static void CrashMessageBox(string message)
{ {
#if WINDOWS #if WINDOWS
@@ -63,9 +132,10 @@ namespace Barotrauma
sb.AppendLine("If you'd like to help fix the bug that caused the crash, please send this file to the developers on the Undertow Games forums."); sb.AppendLine("If you'd like to help fix the bug that caused the crash, please send this file to the developers on the Undertow Games forums.");
sb.AppendLine("\n"); sb.AppendLine("\n");
sb.AppendLine("Game version " + GameMain.Version); sb.AppendLine("Game version " + GameMain.Version);
sb.AppendLine("Graphics mode: " + GameMain.Config.GraphicsWidth + "x" + GameMain.Config.GraphicsHeight + " (" + GameMain.Config.WindowMode.ToString() + ")");
sb.AppendLine("Selected content package: " + GameMain.SelectedPackage.Name); sb.AppendLine("Selected content package: " + GameMain.SelectedPackage.Name);
sb.AppendLine("Level seed: "+ ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed)); sb.AppendLine("Level seed: " + ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed));
sb.AppendLine("Loaded submarine: " + ((Submarine.MainSub == null) ? "none" : Submarine.MainSub.Name +" ("+Submarine.MainSub.MD5Hash+")")); sb.AppendLine("Loaded submarine: " + ((Submarine.MainSub == null) ? "None" : Submarine.MainSub.Name + " (" + Submarine.MainSub.MD5Hash + ")"));
sb.AppendLine("Selected screen: " + (Screen.Selected == null ? "None" : Screen.Selected.ToString())); sb.AppendLine("Selected screen: " + (Screen.Selected == null ? "None" : Screen.Selected.ToString()));
if (GameMain.Server != null) if (GameMain.Server != null)
@@ -152,10 +152,10 @@ namespace Barotrauma
EditLimb(spriteBatch); EditLimb(spriteBatch);
int x = 0, y = 0; int y = 0;
for (int i = 0; i < textures.Count; i++ ) for (int i = 0; i < textures.Count; i++ )
{ {
x = GameMain.GraphicsWidth - textures[i].Width; int x = GameMain.GraphicsWidth - textures[i].Width;
spriteBatch.Draw(textures[i], new Vector2(x, y), Color.White); spriteBatch.Draw(textures[i], new Vector2(x, y), Color.White);
foreach (Limb limb in editingCharacter.AnimController.Limbs) foreach (Limb limb in editingCharacter.AnimController.Limbs)
+3 -5
View File
@@ -304,7 +304,7 @@ namespace Barotrauma
for (int i = 0; i<dummyCharacter.Inventory.SlotPositions.Length; i++) for (int i = 0; i<dummyCharacter.Inventory.SlotPositions.Length; i++)
{ {
dummyCharacter.Inventory.SlotPositions[i].X += false ? -1000 : leftPanel.Rect.Width+10; dummyCharacter.Inventory.SlotPositions[i].X += leftPanel.Rect.Width+10;
} }
Character.Controlled = dummyCharacter; Character.Controlled = dummyCharacter;
@@ -472,16 +472,14 @@ namespace Barotrauma
var deleteButton = new GUIButton(new Rectangle(0, 0, 70, 20), "Delete", Alignment.BottomLeft, GUI.Style, loadFrame); var deleteButton = new GUIButton(new Rectangle(0, 0, 70, 20), "Delete", Alignment.BottomLeft, GUI.Style, loadFrame);
deleteButton.Enabled = false; deleteButton.Enabled = false;
deleteButton.UserData = "delete"; deleteButton.UserData = "delete";
deleteButton.OnClicked = (GUIButton btn, object userdata) => deleteButton.OnClicked = (btn, userdata) =>
{ {
var subListBox = loadFrame.GetChild<GUIListBox>();
if (subList.Selected!=null) if (subList.Selected!=null)
{ {
Submarine sub = subList.Selected.UserData as Submarine; Submarine sub = subList.Selected.UserData as Submarine;
try try
{ {
System.IO.File.Delete(sub.FilePath); File.Delete(sub.FilePath);
} }
catch (Exception e) catch (Exception e)
{ {
+17 -14
View File
@@ -37,10 +37,10 @@ namespace Barotrauma
cam = new Camera(); cam = new Camera();
cam.Translate(new Vector2(-10.0f, 50.0f)); cam.Translate(new Vector2(-10.0f, 50.0f));
renderTargetBackground = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight); renderTargetBackground = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight); renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
renderTargetWater = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight); renderTargetWater = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
renderTargetAir = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight); renderTargetAir = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
var files = GameMain.SelectedPackage.GetFilesOfType(ContentType.BackgroundCreaturePrefabs); var files = GameMain.SelectedPackage.GetFilesOfType(ContentType.BackgroundCreaturePrefabs);
if(files.Count > 0) if(files.Count > 0)
@@ -244,7 +244,7 @@ namespace Barotrauma
null, null, null, null, null, null, null, null,
cam.Transform); cam.Transform);
Submarine.DrawBack(spriteBatch,false,s => s is Structure && ((s as Structure).resizeHorizontal || (s as Structure).resizeVertical)); Submarine.DrawBack(spriteBatch, false, s => s is Structure);
spriteBatch.End(); spriteBatch.End();
@@ -260,7 +260,7 @@ namespace Barotrauma
null, null, null, null, null, null, null, null,
cam.Transform); cam.Transform);
Submarine.DrawBack(spriteBatch, false, s => (!(s is Structure)) || (!(s as Structure).resizeHorizontal && !(s as Structure).resizeHorizontal)); Submarine.DrawBack(spriteBatch, false, s => !(s is Structure));
foreach (Character c in Character.CharacterList) c.Draw(spriteBatch); foreach (Character c in Character.CharacterList) c.Draw(spriteBatch);
@@ -330,18 +330,21 @@ namespace Barotrauma
{ {
graphics.SetRenderTarget(renderTarget); graphics.SetRenderTarget(renderTarget);
spriteBatch.Begin(SpriteSortMode.Deferred, spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.Opaque, null, null, null, lightBlur.Effect); BlendState.Opaque, null, null, null, lightBlur.Effect);
spriteBatch.Draw(renderTargetBackground, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White); spriteBatch.Draw(renderTargetBackground, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
spriteBatch.End(); spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront, spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend, SamplerState.LinearWrap, BlendState.AlphaBlend, SamplerState.LinearWrap,
null, null, null, null, null, null,
cam.Transform); cam.Transform);
Submarine.DrawDamageable(spriteBatch, null);
spriteBatch.End();
//GameMain.LightManager.DrawLightMap(spriteBatch, lightBlur.Effect); Submarine.DrawDamageable(spriteBatch, null);
Submarine.DrawFront(spriteBatch, false, s => s is Structure);
spriteBatch.End();
GameMain.LightManager.DrawLOS(spriteBatch, lightBlur.Effect, true); GameMain.LightManager.DrawLOS(spriteBatch, lightBlur.Effect, true);
} }
@@ -404,7 +407,7 @@ namespace Barotrauma
GameMain.LightManager.DrawLOS(spriteBatch, lightBlur.Effect,false); GameMain.LightManager.DrawLOS(spriteBatch, lightBlur.Effect,false);
spriteBatch.Begin(SpriteSortMode.Immediate, spriteBatch.Begin(SpriteSortMode.Immediate,
BlendState.AlphaBlend); BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullNone, null);
float r = Math.Min(CharacterHUD.damageOverlayTimer * 0.5f, 0.5f); float r = Math.Min(CharacterHUD.damageOverlayTimer * 0.5f, 0.5f);
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
+1 -1
View File
@@ -94,7 +94,7 @@ namespace Barotrauma
var subsToShow = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)); var subsToShow = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus));
foreach (Submarine sub in Submarine.SavedSubmarines) foreach (Submarine sub in subsToShow)
{ {
var textBlock = new GUITextBlock( var textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25), new Rectangle(0, 0, 0, 25),
+4 -5
View File
@@ -9,12 +9,10 @@ using FarseerPhysics.Dynamics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using System.ComponentModel;
namespace Barotrauma namespace Barotrauma
{ {
partial class NetLobbyScreen : Screen class NetLobbyScreen : Screen
{ {
private GUIFrame menu; private GUIFrame menu;
private GUIFrame infoFrame; private GUIFrame infoFrame;
@@ -167,10 +165,11 @@ namespace Barotrauma
if (GameMain.Server != null) if (GameMain.Server != null)
{ {
if (!GameMain.Server.AutoRestart) return ""; if (!GameMain.Server.AutoRestart) return "";
return "Restarting in " + ToolBox.SecondsToReadableTime(GameMain.Server.AutoRestartTimer); return "Restarting in " + ToolBox.SecondsToReadableTime(Math.Max(GameMain.Server.AutoRestartTimer, 0));
} }
if (autoRestartTimer == 0.0f) return ""; if (autoRestartTimer == 0.0f) return "";
return "Restarting in " + ToolBox.SecondsToReadableTime(autoRestartTimer); return "Restarting in " + ToolBox.SecondsToReadableTime(Math.Max(autoRestartTimer, 0));
} }
public NetLobbyScreen() public NetLobbyScreen()
@@ -176,13 +176,13 @@ namespace Barotrauma
passwordBox.Enabled = false; passwordBox.Enabled = false;
passwordBox.UserData = "password"; passwordBox.UserData = "password";
var nameText = new GUITextBlock(new Rectangle(columnX[0], 0, 0, 0), serverName, GUI.Style, serverFrame); new GUITextBlock(new Rectangle(columnX[0], 0, 0, 0), serverName, GUI.Style, serverFrame);
int playerCount = 0, maxPlayers = 1; int playerCount = 0, maxPlayers = 1;
int.TryParse(currPlayersStr, out playerCount); int.TryParse(currPlayersStr, out playerCount);
int.TryParse(maxPlayersStr, out maxPlayers); int.TryParse(maxPlayersStr, out maxPlayers);
var playerCountText = new GUITextBlock(new Rectangle(columnX[1], 0, 0, 0), playerCount + "/" + maxPlayers, GUI.Style, serverFrame); new GUITextBlock(new Rectangle(columnX[1], 0, 0, 0), playerCount + "/" + maxPlayers, GUI.Style, serverFrame);
var gameStartedBox = new GUITickBox(new Rectangle(columnX[2] + (columnX[3] - columnX[2])/ 2, 0, 20, 20), "", Alignment.TopLeft, serverFrame); var gameStartedBox = new GUITickBox(new Rectangle(columnX[2] + (columnX[3] - columnX[2])/ 2, 0, 20, 20), "", Alignment.TopLeft, serverFrame);
gameStartedBox.Selected = gameStarted == "1"; gameStartedBox.Selected = gameStarted == "1";
+3 -3
View File
@@ -138,7 +138,7 @@ namespace Barotrauma
if (xDamageSounds.Any()) if (xDamageSounds.Any())
{ {
damageSounds = new DamageSound[xDamageSounds.Count()]; damageSounds = new DamageSound[xDamageSounds.Count];
int i = 0; int i = 0;
foreach (XElement element in xDamageSounds) foreach (XElement element in xDamageSounds)
{ {
@@ -249,7 +249,7 @@ namespace Barotrauma
if (suitableMusic.Count > 0 && !suitableMusic.Contains(currentMusic)) if (suitableMusic.Count > 0 && !suitableMusic.Contains(currentMusic))
{ {
int index = Rand.Int(suitableMusic.Count()); int index = Rand.Int(suitableMusic.Count);
if (currentMusic == null || suitableMusic[index].file != currentMusic.file) if (currentMusic == null || suitableMusic[index].file != currentMusic.file)
{ {
@@ -355,7 +355,7 @@ namespace Barotrauma
var sounds = damageSounds.Where(x => damage >= x.damageRange.X && damage <= x.damageRange.Y && x.damageType == damageType).ToList(); var sounds = damageSounds.Where(x => damage >= x.damageRange.X && damage <= x.damageRange.Y && x.damageType == damageType).ToList();
if (!sounds.Any()) return; if (!sounds.Any()) return;
int selectedSound = Rand.Int(sounds.Count()); int selectedSound = Rand.Int(sounds.Count);
sounds[selectedSound].sound.Play(1.0f, range, position); sounds[selectedSound].sound.Play(1.0f, range, position);
Debug.WriteLine("playing: " + sounds[selectedSound].sound); Debug.WriteLine("playing: " + sounds[selectedSound].sound);
+1 -1
View File
@@ -510,7 +510,7 @@ namespace Barotrauma
StreamReader file = new StreamReader(filePath); StreamReader file = new StreamReader(filePath);
var lines = File.ReadLines(filePath).ToList(); var lines = File.ReadLines(filePath).ToList();
int lineCount = lines.Count(); int lineCount = lines.Count;
if (lineCount == 0) if (lineCount == 0)
{ {
Binary file not shown.
Binary file not shown.
Binary file not shown.
+54
View File
@@ -1,3 +1,57 @@
---------------------------------------------------------------------------------------------------------
v0.5.3.1
---------------------------------------------------------------------------------------------------------
- fixed monster movement!
---------------------------------------------------------------------------------------------------------
v0.5.3.0
---------------------------------------------------------------------------------------------------------
Multiplayer:
- submarine vs submarine missions
- server hosts can disable spawning of certain characters
- server hosts can have subs spawn with additional items
Changes to ragdoll movement/animation logic:
- movement is now controlled by a single invisible physics body which the rest of the ragdoll follows
- character position syncing is now more accurate and there's less "teleporting"
- characters are less likely to take impact damage by stumbling in stairs
- (+ makes working on the new improved netcode much easier)
- ladders can be slid down by holding the sprint key
Submarine Editor:
- zoom now works relative to the mouse's position rather than the center of the screen
- fixed selection rectangle not being visible when dragging from bottom right to top left
- rectangles now have line widths dependent on the camera zoom (lines are still visible after zooming out)
Items:
- added a particle trail to railgun shells
- added dim emergency lights which require no power
- a "glow effect" when moving items between inventory slots
- option to select which location the autopilot should navigate to
- fabricator UI shows item descriptions and items that can't be fabricated are grayed out
Bugfixes:
- attempt to fix "DXGI_ERROR_NOT_CURRENTLY_AVAILABLE" errors on startup
- fixed water flow sounds taking up all the audio channels and preventing other sounds from playing
when the sub is heavily flooded
- the start button in the server lobby is re-enabled and autorestart countdown is reset if starting
a new round fails for whatever reason
- the colliders of the ice walls match the shape of the walls more accurately
- player-controlled monsters can damage the submarine from the outside
- waypoint generation and pathfinding bugfixes
Misc:
- improved line of sight effect (instead of a solid black "fog of war", a faint image of the
surrounding rooms can be seen through walls)
- less ambient light, and it gets darker when diving deeper
- a hull-specific ambient light system: light sources increase the amount of light inside rooms,
preventing shadows from looking unnaturally dark in fully lit submarines
- option to disable vsync
- added a near-indestructible alien ruin wall variant - breaking through the walls with a railgun
or a plasma cutter is not always an option anymore
- added a parallax effect to the particles floating in the ocean
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------
v0.5.2.0 v0.5.2.0
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------