Build 0.21.6.0
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -65,15 +64,9 @@ namespace Barotrauma
|
||||
|
||||
public Texture2D WaterTexture { get; }
|
||||
|
||||
public WaterRenderer(GraphicsDevice graphicsDevice, ContentManager content)
|
||||
public WaterRenderer(GraphicsDevice graphicsDevice)
|
||||
{
|
||||
#if WINDOWS
|
||||
WaterEffect = content.Load<Effect>("Effects/watershader");
|
||||
#endif
|
||||
#if LINUX || OSX
|
||||
|
||||
WaterEffect = content.Load<Effect>("Effects/watershader_opengl");
|
||||
#endif
|
||||
WaterEffect = EffectLoader.Load("Effects/watershader");
|
||||
|
||||
WaterTexture = TextureLoader.FromFile("Content/Effects/waterbump.png");
|
||||
WaterEffect.Parameters["xWaterBumpMap"].SetValue(WaterTexture);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
@@ -73,12 +72,14 @@ namespace Barotrauma.Lights
|
||||
|
||||
private int recalculationCount;
|
||||
|
||||
private float time;
|
||||
|
||||
public IEnumerable<LightSource> Lights
|
||||
{
|
||||
get { return lights; }
|
||||
}
|
||||
|
||||
public LightManager(GraphicsDevice graphics, ContentManager content)
|
||||
public LightManager(GraphicsDevice graphics)
|
||||
{
|
||||
lights = new List<LightSource>(100);
|
||||
|
||||
@@ -96,13 +97,8 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
CreateRenderTargets(graphics);
|
||||
|
||||
#if WINDOWS
|
||||
LosEffect = content.Load<Effect>("Effects/losshader");
|
||||
SolidColorEffect = content.Load<Effect>("Effects/solidcolor");
|
||||
#else
|
||||
LosEffect = content.Load<Effect>("Effects/losshader_opengl");
|
||||
SolidColorEffect = content.Load<Effect>("Effects/solidcolor_opengl");
|
||||
#endif
|
||||
LosEffect = EffectLoader.Load("Effects/losshader");
|
||||
SolidColorEffect = EffectLoader.Load("Effects/solidcolor");
|
||||
|
||||
if (lightEffect == null)
|
||||
{
|
||||
@@ -171,10 +167,12 @@ namespace Barotrauma.Lights
|
||||
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
//wrap around if the timer gets very large, otherwise we'd start running into floating point accuracy issues
|
||||
time = (time + deltaTime) % 100000.0f;
|
||||
foreach (LightSource light in activeLights)
|
||||
{
|
||||
if (!light.Enabled) { continue; }
|
||||
light.Update(deltaTime);
|
||||
light.Update(time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -200,8 +200,6 @@ namespace Barotrauma.Lights
|
||||
|
||||
private static Texture2D lightTexture;
|
||||
|
||||
private float blinkTimer, flickerState, pulseState;
|
||||
|
||||
private VertexPositionColorTexture[] vertices;
|
||||
private short[] indices;
|
||||
|
||||
@@ -486,12 +484,12 @@ namespace Barotrauma.Lights
|
||||
if (addLight) { GameMain.LightManager.AddLight(this); }
|
||||
}
|
||||
|
||||
public void Update(float deltaTime)
|
||||
public void Update(float time)
|
||||
{
|
||||
float brightness = 1.0f;
|
||||
if (lightSourceParams.BlinkFrequency > 0.0f)
|
||||
{
|
||||
blinkTimer = (blinkTimer + deltaTime * lightSourceParams.BlinkFrequency) % 1.0f;
|
||||
float blinkTimer = (time * lightSourceParams.BlinkFrequency) % 1.0f;
|
||||
if (blinkTimer > 0.5f)
|
||||
{
|
||||
CurrentBrightness = 0.0f;
|
||||
@@ -500,14 +498,13 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
if (lightSourceParams.PulseFrequency > 0.0f && lightSourceParams.PulseAmount > 0.0f)
|
||||
{
|
||||
pulseState = (pulseState + deltaTime * lightSourceParams.PulseFrequency) % 1.0f;
|
||||
float pulseState = (time * lightSourceParams.PulseFrequency) % 1.0f;
|
||||
//oscillate between 0-1
|
||||
brightness *= 1.0f - (float)(Math.Sin(pulseState * MathHelper.TwoPi) + 1.0f) / 2.0f * lightSourceParams.PulseAmount;
|
||||
}
|
||||
if (lightSourceParams.Flicker > 0.0f)
|
||||
if (lightSourceParams.Flicker > 0.0f && lightSourceParams.FlickerSpeed > 0.0f)
|
||||
{
|
||||
flickerState += deltaTime * lightSourceParams.FlickerSpeed;
|
||||
flickerState %= 255;
|
||||
float flickerState = (time * lightSourceParams.FlickerSpeed) % 255;
|
||||
brightness *= 1.0f - PerlinNoise.GetPerlin(flickerState, flickerState * 0.5f) * lightSourceParams.Flicker;
|
||||
}
|
||||
CurrentBrightness = brightness;
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Barotrauma
|
||||
|
||||
private (Rectangle targetArea, RichString tip)? tooltip;
|
||||
|
||||
private (SubmarineInfo pendingSub, float realWorldCrushDepth) pendingSubInfo;
|
||||
private SubmarineInfo.PendingSubInfo pendingSubInfo;
|
||||
|
||||
private RichString beaconStationActiveText, beaconStationInactiveText;
|
||||
|
||||
@@ -936,39 +936,8 @@ namespace Barotrauma
|
||||
if (connection.LevelData.HasHuntingGrounds) { iconCount++; }
|
||||
if (connection.Locked) { iconCount++; }
|
||||
string tooltip = null;
|
||||
float subCrushDepth = Level.DefaultRealWorldCrushDepth;
|
||||
var currentOrPendingSub = SubmarineSelection.CurrentOrPendingSubmarine();
|
||||
if (Submarine.MainSub != null && Submarine.MainSub.Info == currentOrPendingSub)
|
||||
{
|
||||
subCrushDepth = Submarine.MainSub.RealWorldCrushDepth;
|
||||
}
|
||||
else if (currentOrPendingSub != null)
|
||||
{
|
||||
if (pendingSubInfo.pendingSub != currentOrPendingSub)
|
||||
{
|
||||
// Store the real world crush depth for the pending sub so that we don't have to calculate it again every time
|
||||
pendingSubInfo = (currentOrPendingSub, currentOrPendingSub.GetRealWorldCrushDepth());
|
||||
}
|
||||
subCrushDepth = pendingSubInfo.realWorldCrushDepth;
|
||||
}
|
||||
if (GameMain.GameSession?.Campaign?.UpgradeManager != null)
|
||||
{
|
||||
var hullUpgradePrefab = UpgradePrefab.Find("increasewallhealth".ToIdentifier());
|
||||
if (hullUpgradePrefab != null)
|
||||
{
|
||||
int pendingLevel = GameMain.GameSession.Campaign.UpgradeManager.GetUpgradeLevel(hullUpgradePrefab, hullUpgradePrefab.UpgradeCategories.First());
|
||||
int currentLevel = GameMain.GameSession.Campaign.UpgradeManager.GetRealUpgradeLevel(hullUpgradePrefab, hullUpgradePrefab.UpgradeCategories.First());
|
||||
if (pendingLevel > currentLevel)
|
||||
{
|
||||
string updateValueStr = hullUpgradePrefab.SourceElement?.GetChildElement("Structure")?.GetAttributeString("crushdepth", null);
|
||||
if (!string.IsNullOrEmpty(updateValueStr))
|
||||
{
|
||||
subCrushDepth = PropertyReference.CalculateUpgrade(subCrushDepth, pendingLevel - currentLevel, updateValueStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float subCrushDepth = SubmarineInfo.GetSubCrushDepth(SubmarineSelection.CurrentOrPendingSubmarine(), ref pendingSubInfo);
|
||||
string crushDepthWarningIconStyle = null;
|
||||
if (connection.LevelData.InitialDepth * Physics.DisplayToRealWorldRatio > subCrushDepth)
|
||||
{
|
||||
@@ -1125,6 +1094,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets <see cref="pendingSubInfo"/> and forces crush depth to be calculated again for icon displaying purposes
|
||||
/// </summary>
|
||||
public void ResetPendingSub()
|
||||
{
|
||||
pendingSubInfo = new SubmarineInfo.PendingSubInfo();
|
||||
}
|
||||
|
||||
partial void RemoveProjSpecific()
|
||||
{
|
||||
noiseOverlay?.Remove();
|
||||
|
||||
@@ -89,7 +89,11 @@ namespace Barotrauma
|
||||
CreateSpecsWindow(descriptionBox, font, includeDescription: true);
|
||||
}
|
||||
|
||||
public void CreateSpecsWindow(GUIListBox parent, GUIFont font, bool includeTitle = true, bool includeClass = true, bool includeDescription = false)
|
||||
public void CreateSpecsWindow(GUIListBox parent, GUIFont font,
|
||||
bool includeTitle = true,
|
||||
bool includeClass = true,
|
||||
bool includeDescription = false,
|
||||
bool includeCrushDepth = false)
|
||||
{
|
||||
float leftPanelWidth = 0.6f;
|
||||
float rightPanelWidth = 0.4f / leftPanelWidth;
|
||||
@@ -155,6 +159,22 @@ namespace Barotrauma
|
||||
{ CanBeFocused = false };
|
||||
cargoCapacityText.RectTransform.MinSize = new Point(0, cargoCapacityText.Children.First().Rect.Height);
|
||||
|
||||
if (includeCrushDepth)
|
||||
{
|
||||
var crushDepthText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
|
||||
TextManager.Get("CrushDepth"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), crushDepthText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
|
||||
TextManager.GetWithVariable("meterformat", "[meters]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", GetSubCrushDepth())),
|
||||
textAlignment: Alignment.TopLeft, font: font, wrap: true)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
crushDepthText.RectTransform.MinSize = new Point(0, crushDepthText.Children.First().Rect.Height);
|
||||
}
|
||||
|
||||
if (RecommendedCrewSizeMax > 0)
|
||||
{
|
||||
var crewSizeText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
|
||||
@@ -227,5 +247,57 @@ namespace Barotrauma
|
||||
GUITextBlock.AutoScaleAndNormalize(parent.Content.GetAllChildren<GUITextBlock>().Where(c => c != submarineNameText && c != descBlock));
|
||||
parent.ForceLayoutRecalculation();
|
||||
}
|
||||
|
||||
public readonly record struct PendingSubInfo(SubmarineInfo PendingSub = null, bool StructuresDefineRealWorldCrushDepth = false, float RealWorldCrushDepth = Level.DefaultRealWorldCrushDepth);
|
||||
|
||||
private float GetSubCrushDepth()
|
||||
{
|
||||
var pendingSubInfo = new PendingSubInfo();
|
||||
return GetSubCrushDepth(this, ref pendingSubInfo);
|
||||
}
|
||||
|
||||
public static float GetSubCrushDepth(SubmarineInfo subInfo, ref PendingSubInfo pendingSubInfo)
|
||||
{
|
||||
float subCrushDepth = Level.DefaultRealWorldCrushDepth;
|
||||
if (Submarine.MainSub != null && Submarine.MainSub.Info == subInfo)
|
||||
{
|
||||
subCrushDepth = Submarine.MainSub.RealWorldCrushDepth;
|
||||
}
|
||||
else if (subInfo != null)
|
||||
{
|
||||
if (pendingSubInfo.PendingSub != subInfo)
|
||||
{
|
||||
// Store the real world crush depth for the pending sub so that we don't have to calculate it again every time
|
||||
pendingSubInfo = new PendingSubInfo(subInfo, subInfo.IsCrushDepthDefinedInStructures(out float realWorldCrushDepth), realWorldCrushDepth);
|
||||
}
|
||||
subCrushDepth = pendingSubInfo.RealWorldCrushDepth;
|
||||
}
|
||||
if (GameMain.GameSession?.Campaign?.UpgradeManager != null && UpgradePrefab.Find("increasewallhealth".ToIdentifier()) is UpgradePrefab hullUpgradePrefab)
|
||||
{
|
||||
int pendingLevel = GameMain.GameSession.Campaign.UpgradeManager.GetUpgradeLevel(hullUpgradePrefab, hullUpgradePrefab.UpgradeCategories.First(), info: subInfo);
|
||||
// If there is a sub switch pending, unless its structures have crush depth defined in their elements,
|
||||
// calculate the value based on the default crush depth and pending upgrade level
|
||||
int currentLevel = 0;
|
||||
if (pendingSubInfo.PendingSub is null || pendingSubInfo.StructuresDefineRealWorldCrushDepth)
|
||||
{
|
||||
currentLevel = GameMain.GameSession.Campaign.UpgradeManager.GetRealUpgradeLevelForSub(hullUpgradePrefab, hullUpgradePrefab.UpgradeCategories.First(), subInfo);
|
||||
}
|
||||
if (pendingLevel > currentLevel)
|
||||
{
|
||||
string updateValueStr = hullUpgradePrefab.SourceElement?.GetChildElement("Structure")?.GetAttributeString("crushdepth", null);
|
||||
if (!string.IsNullOrEmpty(updateValueStr))
|
||||
{
|
||||
if (currentLevel > 0)
|
||||
{
|
||||
// If the current level is greater than 0, reset the crush depth value back to the base value before calculating the upgrade
|
||||
int upgradePercentage = UpgradePrefab.ParsePercentage(updateValueStr, Identifier.Empty, suppressWarnings: true);
|
||||
subCrushDepth /= (1f + (upgradePercentage / 100f * currentLevel));
|
||||
}
|
||||
subCrushDepth = PropertyReference.CalculateUpgrade(subCrushDepth, pendingLevel, updateValueStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
return subCrushDepth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private struct Door
|
||||
private readonly struct Door
|
||||
{
|
||||
public readonly Rectangle Rect;
|
||||
|
||||
@@ -153,7 +153,9 @@ namespace Barotrauma
|
||||
ScrollBarVisible = false,
|
||||
Spacing = GUI.IntScale(5)
|
||||
};
|
||||
subInfo.CreateSpecsWindow(specsContainer, GUIStyle.Font, includeTitle: false, includeDescription: true);
|
||||
subInfo.CreateSpecsWindow(specsContainer, GUIStyle.Font,
|
||||
includeTitle: false,
|
||||
includeDescription: true);
|
||||
int width = specsContainer.Rect.Width;
|
||||
void recalculateSpecsContainerHeight()
|
||||
{
|
||||
@@ -191,6 +193,7 @@ namespace Barotrauma
|
||||
|
||||
TaskPool.Add(nameof(GeneratePreviewMeshes), GeneratePreviewMeshes(), _ =>
|
||||
{
|
||||
if (isDisposed) { return; }
|
||||
// Reset the camera's position on the main thread,
|
||||
// because the Camera class is not thread-safe and
|
||||
// it's possible for its state to not get updated
|
||||
|
||||
Reference in New Issue
Block a user