diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj
index 58e062cef..bb9218ec6 100644
--- a/Subsurface/Barotrauma.csproj
+++ b/Subsurface/Barotrauma.csproj
@@ -319,6 +319,10 @@
..\packages\RestSharp.105.1.0\lib\net4\RestSharp.dll
+
+ False
+ C:\Program Files (x86)\MonoGame\v3.0\Assemblies\Windows\SharpDX.dll
+
diff --git a/Subsurface/Content/Map/dustparticles.png b/Subsurface/Content/Map/dustparticles.png
index 607e7c33b..02a88d389 100644
Binary files a/Subsurface/Content/Map/dustparticles.png and b/Subsurface/Content/Map/dustparticles.png differ
diff --git a/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs b/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs
index a1aa98d75..d5c045ee8 100644
--- a/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs
+++ b/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs
@@ -118,10 +118,7 @@ namespace Barotrauma
}
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;
if (character != null && currentPath.CurrentNode != null)
@@ -159,9 +156,7 @@ namespace Barotrauma
}
if (currentPath.CurrentNode == null) return Vector2.Zero;
-
- var hull = character.AnimController.CurrentHull;
-
+
if (character.AnimController.Anim == AnimController.Animation.Climbing)
{
Vector2 diff = currentPath.CurrentNode.SimPosition - pos;
diff --git a/Subsurface/Source/Characters/Animation/FishAnimController.cs b/Subsurface/Source/Characters/Animation/FishAnimController.cs
index b28c589bf..fa1ef8eed 100644
--- a/Subsurface/Source/Characters/Animation/FishAnimController.cs
+++ b/Subsurface/Source/Characters/Animation/FishAnimController.cs
@@ -160,10 +160,7 @@ namespace Barotrauma
void UpdateSineAnim(float deltaTime)
{
movement = TargetMovement*swimSpeed;
-
- Limb torso = GetLimb(LimbType.Torso);
- Limb head = GetLimb(LimbType.Head);
-
+
MainLimb.pullJoint.Enabled = true;
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;
diff --git a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs
index 8a99f86f9..eba834401 100644
--- a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs
+++ b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs
@@ -23,15 +23,7 @@ namespace Barotrauma
private float inWaterTimer;
private bool swimming;
-
- protected override float HeadPosition
- {
- get
- {
- return Crouching ? base.HeadPosition : base.HeadPosition;
- }
- }
-
+
protected override float TorsoPosition
{
get
@@ -255,7 +247,7 @@ namespace Barotrauma
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);
// if (character.SelectedCharacter!=null) maxSpeed = Math.Min(maxSpeed, 1.0f);
@@ -306,16 +298,21 @@ namespace Barotrauma
if (onGround && (!character.IsRemotePlayer || GameMain.Server != null))
{
collider.LinearVelocity = new Vector2(
- movement.X,
- collider.LinearVelocity.Y > 0.0f ? collider.LinearVelocity.Y * 0.5f : collider.LinearVelocity.Y);
+ movement.X,
+ 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);
torso.pullJoint.Enabled = true;
head.pullJoint.Enabled = true;
waist.pullJoint.Enabled = true;
+ collider.FarseerBody.Friction = 0.05f;
+ collider.FarseerBody.Restitution = 0.05f;
+
if (stairs != null)
{
torso.pullJoint.WorldAnchorB = new Vector2(
@@ -430,7 +427,7 @@ namespace Barotrauma
}
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)
{
@@ -462,8 +459,6 @@ namespace Barotrauma
leftArm.body.SmoothRotate(0.0f, 20.0f);
}
}
-
-
}
void UpdateStandingSimple()
@@ -474,20 +469,51 @@ namespace Barotrauma
{
movement = Vector2.Normalize(movement);
}
+ }
- return;
- //RefLimb.pullJoint.Enabled = true;
- //RefLimb.pullJoint.WorldAnchorB =
- // RefLimb.SimPosition + movement * 0.15f;
+ private void ClimbOverObstacles()
+ {
+ if (collider.FarseerBody.ContactList == null || Math.Abs(movement.X) < 0.01f) return;
- //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 contactPos;
+ ce.Contact.GetWorldManifold(out contactNormal, out contactPos);
- //foreach (Limb l in Limbs)
- //{
- // if (l == RefLimb) continue;
- // l.body.SetTransform(RefLimb.SimPosition, RefLimb.Rotation);
- //}
- //new Vector2(movement.X, floorY + HeadPosition), 0.5f);
+ //only climb if moving towards the obstacle
+ if (Math.Sign(contactPos[0].X - collider.SimPosition.X) == Math.Sign(movement.X) &&
+ (handle == null || contactPos[0].Y > ((Vector2)handle).Y))
+ {
+ handle = contactPos[0];
+ }
+ }
+
+ 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()
@@ -828,63 +854,7 @@ namespace Barotrauma
var head = GetLimb(LimbType.Head);
head.pullJoint.WorldAnchorB = new Vector2(targetHead.SimPosition.X, targetHead.SimPosition.Y + 0.6f + yPos);
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)
{
if (target == null) return;
diff --git a/Subsurface/Source/Characters/Animation/Ragdoll.cs b/Subsurface/Source/Characters/Animation/Ragdoll.cs
index 3f802293c..bc236ab74 100644
--- a/Subsurface/Source/Characters/Animation/Ragdoll.cs
+++ b/Subsurface/Source/Characters/Animation/Ragdoll.cs
@@ -464,15 +464,15 @@ namespace Barotrauma
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)
{
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.HitSound.Play(volume, impact * 250.0f, limb.WorldPosition);
+ limb.HitSound.Play(volume, impact * 100.0f, limb.WorldPosition);
}
}
else if (f1.Body == collider.FarseerBody)
@@ -578,7 +578,7 @@ namespace Barotrauma
{
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 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;
@@ -834,7 +834,7 @@ namespace Barotrauma
{
//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(0.0f, Math.Abs(-limb.LinearVelocity.Y * 20.0f)),
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);
var lowestLimb = FindLowestLimb();
@@ -1088,7 +1090,11 @@ namespace Barotrauma
}
else
{
- collider.CorrectPosition(character.MemPos, deltaTime, out overrideTargetMovement);
+ if (character.MemPos.Count > 0)
+ {
+ collider.LinearVelocity = Vector2.Zero;
+ collider.CorrectPosition(character.MemPos, deltaTime, out overrideTargetMovement);
+ }
}
}
diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs
index 2e1214eb4..4956bd207 100644
--- a/Subsurface/Source/Characters/Character.cs
+++ b/Subsurface/Source/Characters/Character.cs
@@ -585,9 +585,9 @@ namespace Barotrauma
var soundElements = doc.Root.Elements("sound").ToList();
if (soundElements.Any())
{
- sounds = new Sound[soundElements.Count()];
- soundStates = new AIController.AiState[soundElements.Count()];
- soundRange = new float[soundElements.Count()];
+ sounds = new Sound[soundElements.Count];
+ soundStates = new AIController.AiState[soundElements.Count];
+ soundRange = new float[soundElements.Count];
int i = 0;
foreach (XElement soundElement in soundElements)
{
@@ -868,7 +868,7 @@ namespace Barotrauma
{
attackPos = Submarine.LastPickedPosition;
- if (body != null && body.UserData is Submarine)
+ if (body.UserData is Submarine)
{
var sub = ((Submarine)body.UserData);
@@ -1538,10 +1538,10 @@ namespace Barotrauma
if (sounds == null || !sounds.Any()) return;
var matchingSoundStates = soundStates.Where(x => x == state).ToList();
- int selectedSound = Rand.Int(matchingSoundStates.Count());
+ int selectedSound = Rand.Int(matchingSoundStates.Count);
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 (n == selectedSound && sounds[i]!=null)
diff --git a/Subsurface/Source/Characters/Jobs/Skill.cs b/Subsurface/Source/Characters/Jobs/Skill.cs
index c0dd3b117..3248bb623 100644
--- a/Subsurface/Source/Characters/Jobs/Skill.cs
+++ b/Subsurface/Source/Characters/Jobs/Skill.cs
@@ -1,8 +1,5 @@
using Microsoft.Xna.Framework;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
namespace Barotrauma
{
diff --git a/Subsurface/Source/Characters/Limb.cs b/Subsurface/Source/Characters/Limb.cs
index 4532a846a..348c84739 100644
--- a/Subsurface/Source/Characters/Limb.cs
+++ b/Subsurface/Source/Characters/Limb.cs
@@ -63,7 +63,7 @@ namespace Barotrauma
Sound hitSound;
//a timer for delaying when a hitsound/attacksound can be played again
public float soundTimer;
- public const float SoundInterval = 0.2f;
+ public const float SoundInterval = 0.4f;
public readonly Attack attack;
diff --git a/Subsurface/Source/Characters/StatusEffect.cs b/Subsurface/Source/Characters/StatusEffect.cs
index a32588f7f..7518fa4e7 100644
--- a/Subsurface/Source/Characters/StatusEffect.cs
+++ b/Subsurface/Source/Characters/StatusEffect.cs
@@ -92,8 +92,8 @@ namespace Barotrauma
type = (ActionType)Enum.Parse(typeof(ActionType), split[0], true);
string[] containingNames = split[1].Split(',');
- onContainingNames = new string[containingNames.Count()];
- for (int i =0; i < containingNames.Count(); i++)
+ onContainingNames = new string[containingNames.Length];
+ for (int i =0; i < containingNames.Length; i++)
{
onContainingNames[i] = containingNames[i].Trim();
}
@@ -116,8 +116,8 @@ namespace Barotrauma
break;
case "targetnames":
string[] names = attribute.Value.Split(',');
- targetNames = new string[names.Count()];
- for (int i=0; i < names.Count(); i++ )
+ targetNames = new string[names.Length];
+ for (int i=0; i < names.Length; i++ )
{
targetNames[i] = names[i].Trim();
}
@@ -134,7 +134,7 @@ namespace Barotrauma
}
}
- int count = propertyAttributes.Count();
+ int count = propertyAttributes.Count;
propertyNames = new string[count];
propertyEffects = new object[count];
@@ -227,7 +227,7 @@ namespace Barotrauma
foreach (IPropertyObject target in targets)
{
- for (int i = 0; i < propertyNames.Count(); i++)
+ for (int i = 0; i < propertyNames.Length; i++)
{
ObjectProperty property;
diff --git a/Subsurface/Source/ContentPackage.cs b/Subsurface/Source/ContentPackage.cs
index b07b314ee..20d6d4995 100644
--- a/Subsurface/Source/ContentPackage.cs
+++ b/Subsurface/Source/ContentPackage.cs
@@ -171,7 +171,7 @@ namespace Barotrauma
}
//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++ )
{
hashes[i].CopyTo(bytes, i*16);
diff --git a/Subsurface/Source/DebugConsole.cs b/Subsurface/Source/DebugConsole.cs
index 3f1eac6f4..913a05290 100644
--- a/Subsurface/Source/DebugConsole.cs
+++ b/Subsurface/Source/DebugConsole.cs
@@ -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.Color = Color.Black * 0.7f;
+ //messages already added before initialization -> add them to the listbox
+ List unInitializedMessages = new List(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("Enter \"help\" for a list of available console commands", Color.Cyan);
@@ -740,6 +749,14 @@ namespace Barotrauma
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
{
var textBlock = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width, 0), msg, GUI.Style, Alignment.TopLeft, Alignment.Left, null, true, GUI.SmallFont);
@@ -753,14 +770,7 @@ namespace Barotrauma
{
return;
}
-
- if (Messages.Count > MaxMessages)
- {
- Messages.RemoveRange(0, Messages.Count - MaxMessages);
- }
-
- //messages.Add(new ColoredText(msg, color));
-
+
selectedIndex = listBox.children.Count;
}
diff --git a/Subsurface/Source/Events/Missions/CargoMission.cs b/Subsurface/Source/Events/Missions/CargoMission.cs
index c1d6a0e1d..acb048d58 100644
--- a/Subsurface/Source/Events/Missions/CargoMission.cs
+++ b/Subsurface/Source/Events/Missions/CargoMission.cs
@@ -39,7 +39,7 @@ namespace Barotrauma
LoadItemAsChild(subElement, null);
}
- if (requiredDeliveryAmount == 0) requiredDeliveryAmount = items.Count();
+ if (requiredDeliveryAmount == 0) requiredDeliveryAmount = items.Count;
}
private void LoadItemAsChild(XElement element, Item parent)
diff --git a/Subsurface/Source/GUI/GUIComponent.cs b/Subsurface/Source/GUI/GUIComponent.cs
index 5a61587a9..f3cabe95b 100644
--- a/Subsurface/Source/GUI/GUIComponent.cs
+++ b/Subsurface/Source/GUI/GUIComponent.cs
@@ -124,7 +124,7 @@ namespace Barotrauma
public int CountChildren
{
- get { return children.Count(); }
+ get { return children.Count; }
}
public virtual Color Color
diff --git a/Subsurface/Source/GUI/GUIListBox.cs b/Subsurface/Source/GUI/GUIListBox.cs
index ea271ddc6..2fa4ea438 100644
--- a/Subsurface/Source/GUI/GUIListBox.cs
+++ b/Subsurface/Source/GUI/GUIListBox.cs
@@ -412,38 +412,14 @@ namespace Barotrauma
//base.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 (scrollBar.IsHorizontal)
- {
- x -= (int)((totalSize - rect.Width) * scrollBar.BarScroll);
- }
- else
- {
- y -= (int)((totalSize - rect.Height) * scrollBar.BarScroll);
- }
- }
+ if (!scrollBarHidden) scrollBar.Draw(spriteBatch);
+
for (int i = 0; i < children.Count; i++)
{
GUIComponent child = children[i];
if (child == frame || !child.Visible) continue;
-
- if (scrollBar.IsHorizontal)
- {
- x += child.Rect.Width + spacing;
- }
- else
- {
- y += child.Rect.Height + spacing;
- }
-
-
+
if (scrollBar.IsHorizontal)
{
if (child.Rect.Right < rect.X) continue;
@@ -451,7 +427,6 @@ namespace Barotrauma
if (child.Rect.X < rect.X && child.Rect.Right >= rect.X)
{
- x = rect.X;
continue;
}
}
@@ -462,7 +437,6 @@ namespace Barotrauma
if (child.Rect.Y < rect.Y && child.Rect.Y + child.Rect.Height >= rect.Y)
{
- y = rect.Y;
continue;
}
}
diff --git a/Subsurface/Source/GUI/GUIScrollBar.cs b/Subsurface/Source/GUI/GUIScrollBar.cs
index 847be1243..60bb9d1ed 100644
--- a/Subsurface/Source/GUI/GUIScrollBar.cs
+++ b/Subsurface/Source/GUI/GUIScrollBar.cs
@@ -169,26 +169,16 @@ namespace Barotrauma
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;
if (isHorizontal)
{
moveAmount = PlayerInput.MouseSpeed.X;
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
{
moveAmount = PlayerInput.MouseSpeed.Y;
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;
diff --git a/Subsurface/Source/GameMain.cs b/Subsurface/Source/GameMain.cs
index 50e8beae1..558816a71 100644
--- a/Subsurface/Source/GameMain.cs
+++ b/Subsurface/Source/GameMain.cs
@@ -65,7 +65,7 @@ namespace Barotrauma
public static World World;
public static LoadingScreen TitleScreen;
- private static bool titleScreenOpen;
+ private static bool loadingScreenOpen;
public static GameSettings Config;
@@ -103,7 +103,7 @@ namespace Barotrauma
{
get { return NetworkMember as GameClient; }
}
-
+
public GameMain()
{
Graphics = new GraphicsDeviceManager(this)
@@ -122,21 +122,11 @@ namespace Barotrauma
Config.WasGameUpdated = false;
Config.Save("config.xml");
}
-
- graphicsWidth = Config.GraphicsWidth;
- graphicsHeight = Config.GraphicsHeight;
- Graphics.SynchronizeWithVerticalRetrace = Config.VSyncEnabled;
- Graphics.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
+ ApplyGraphicsSettings();
- Graphics.IsFullScreen = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed;
- Graphics.PreferredBackBufferWidth = graphicsWidth;
- Graphics.PreferredBackBufferHeight = graphicsHeight;
Content.RootDirectory = "Content";
- //graphics.SynchronizeWithVerticalRetrace = false;
- //graphics.ApplyChanges();
-
FrameCounter = new FrameCounter();
//IsMouseVisible = true;
@@ -153,6 +143,20 @@ namespace Barotrauma
FarseerPhysics.Settings.VelocityIterations = 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();
}
@@ -190,7 +194,7 @@ namespace Barotrauma
spriteBatch = new SpriteBatch(GraphicsDevice);
TextureLoader.Init(GraphicsDevice);
- titleScreenOpen = true;
+ loadingScreenOpen = true;
TitleScreen = new LoadingScreen(GraphicsDevice);
CoroutineManager.StartCoroutine(Load());
@@ -237,7 +241,7 @@ namespace Barotrauma
while (!SoundPlayer.Initialized)
{
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;
}
@@ -307,12 +311,17 @@ namespace Barotrauma
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 &&
(!waitForKeyHit || PlayerInput.GetKeyboardState.GetPressedKeys().Length>0 || PlayerInput.LeftButtonClicked()))
{
- titleScreenOpen = false;
+ loadingScreenOpen = false;
}
}
else if (hasLoaded)
@@ -337,8 +346,7 @@ namespace Barotrauma
}
GUI.Update((float)Timing.Step);
- }
-
+ }
CoroutineManager.Update((float)Timing.Step, paused ? 0.0f : (float)Timing.Step);
@@ -358,7 +366,7 @@ namespace Barotrauma
FrameCounter.Update(deltaTime);
- if (titleScreenOpen)
+ if (loadingScreenOpen)
{
TitleScreen.Draw(spriteBatch, GraphicsDevice, (float)deltaTime);
}
@@ -372,7 +380,7 @@ namespace Barotrauma
public static CoroutineHandle ShowLoading(IEnumerable