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

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;
@@ -187,7 +187,7 @@ namespace Barotrauma
spriteBatch = new SpriteBatch(GraphicsDevice);
TextureLoader.Init(GraphicsDevice);
titleScreenOpen = true;
loadingScreenOpen = true;
TitleScreen = new LoadingScreen(GraphicsDevice);
CoroutineManager.StartCoroutine(Load());
@@ -304,12 +304,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)
@@ -334,8 +339,7 @@ namespace Barotrauma
}
GUI.Update((float)Timing.Step);
}
}
CoroutineManager.Update((float)Timing.Step, paused ? 0.0f : (float)Timing.Step);
@@ -355,7 +359,7 @@ namespace Barotrauma
FrameCounter.Update(deltaTime);
if (titleScreenOpen)
if (loadingScreenOpen)
{
TitleScreen.Draw(spriteBatch, GraphicsDevice, (float)deltaTime);
}
@@ -369,7 +373,7 @@ namespace Barotrauma
public static CoroutineHandle ShowLoading(IEnumerable<object> loader, bool waitKeyHit = true)
{
waitForKeyHit = waitKeyHit;
titleScreenOpen = true;
loadingScreenOpen = true;
TitleScreen.LoadState = null;
return CoroutineManager.StartCoroutine(TitleScreen.DoLoading(loader));
}

View File

@@ -294,18 +294,23 @@ namespace Barotrauma
{
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++)
{
if (MapEntity.mapEntityList[i].DrawOverWater)
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, false);
}
if (!MapEntity.mapEntityList[i].DrawOverWater) continue;
if (predicate != null)
{
if (!predicate(MapEntity.mapEntityList[i])) continue;
}
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, false);
}
if (GameMain.DebugDraw)
{
foreach (Submarine sub in Submarine.Loaded)
@@ -325,10 +330,7 @@ namespace Barotrauma
prevPos = currPos;
}
}
}
}
@@ -351,13 +353,14 @@ namespace Barotrauma
{
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{
if (!MapEntity.mapEntityList[i].DrawBelowWater) continue;
if (predicate != null)
{
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);
}
}

View File

@@ -242,7 +242,7 @@ namespace Barotrauma
null, null, null, null,
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();
@@ -258,7 +258,7 @@ namespace Barotrauma
null, null, null, null,
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);
@@ -328,19 +328,22 @@ namespace Barotrauma
{
graphics.SetRenderTarget(renderTarget);
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.End();
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend, SamplerState.LinearWrap,
null, null, null,
cam.Transform);
BlendState.AlphaBlend, SamplerState.LinearWrap,
null, null, null,
cam.Transform);
Submarine.DrawDamageable(spriteBatch, null);
Submarine.DrawFront(spriteBatch, false, s => s is Structure);
spriteBatch.End();
//GameMain.LightManager.DrawLightMap(spriteBatch, lightBlur.Effect);
GameMain.LightManager.DrawLOS(spriteBatch, lightBlur.Effect, true);
}