Fixed timestep logic is disabled during loading (less choppy loading screens & no pause at the start of the game), damageable structures visible in LOS again, footstep sound tweaking

This commit is contained in:
Regalis
2016-11-01 19:05:09 +02:00
parent 9b29c52a1b
commit 1b818b6422
5 changed files with 41 additions and 31 deletions
@@ -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)
+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;
+11 -7
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;
@@ -187,7 +187,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());
@@ -304,12 +304,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)
@@ -336,7 +341,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;
@@ -355,7 +359,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);
} }
@@ -369,7 +373,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));
} }
+13 -10
View File
@@ -294,18 +294,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)
@@ -325,10 +330,7 @@ namespace Barotrauma
prevPos = currPos; prevPos = currPos;
} }
} }
} }
} }
@@ -351,13 +353,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);
} }
} }
+12 -9
View File
@@ -242,7 +242,7 @@ namespace Barotrauma
null, null, null, null, null, null, null, null,
cam.Transform); cam.Transform);
Submarine.DrawBack(spriteBatch,false,s => s is Structure && (((Structure)s).resizeHorizontal || ((Structure)s).resizeVertical)); Submarine.DrawBack(spriteBatch, false, s => s is Structure);
spriteBatch.End(); spriteBatch.End();
@@ -258,7 +258,7 @@ namespace Barotrauma
null, null, null, null, null, null, null, null,
cam.Transform); cam.Transform);
Submarine.DrawBack(spriteBatch, false, s => !(s is Structure) || (!((Structure)s).resizeHorizontal && !((Structure)s).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);
@@ -328,18 +328,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);
} }