diff --git a/Barotrauma/BarotraumaClient/ClientSource/Camera.cs b/Barotrauma/BarotraumaClient/ClientSource/Camera.cs
index e8d9f99f1..db7c27941 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Camera.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Camera.cs
@@ -6,7 +6,7 @@ using System;
namespace Barotrauma
{
- public class Camera
+ public class Camera : IDisposable
{
public static bool FollowSub = true;
@@ -147,15 +147,19 @@ namespace Barotrauma
position = Vector2.Zero;
CreateMatrices();
- // TODO: Needs to unregister if ever destroy cameras.
+ // TODO: this has the potential to cause a resource leak
+ // by sneakily creating a reference to cameras that we might
+ // fail to release.
GameMain.Instance.ResolutionChanged += CreateMatrices;
UpdateTransform(false);
}
- ~Camera()
+ private bool disposed = false;
+ public void Dispose()
{
- GameMain.Instance.ResolutionChanged -= CreateMatrices;
+ if (!disposed) { GameMain.Instance.ResolutionChanged -= CreateMatrices; }
+ disposed = true;
}
public Vector2 TargetPos { get; set; }
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Characters/CharacterInfo.cs b/Barotrauma/BarotraumaClient/ClientSource/Characters/CharacterInfo.cs
index d96f35a87..deca50826 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Characters/CharacterInfo.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Characters/CharacterInfo.cs
@@ -988,11 +988,6 @@ namespace Barotrauma
HeadSelectionList = null;
}
}
-
- ~AppearanceCustomizationMenu()
- {
- Dispose();
- }
}
}
}
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Events/EventActions/ConversationAction.cs b/Barotrauma/BarotraumaClient/ClientSource/Events/EventActions/ConversationAction.cs
index 7f8c08485..d9dd3a9cc 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Events/EventActions/ConversationAction.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Events/EventActions/ConversationAction.cs
@@ -308,7 +308,7 @@ namespace Barotrauma
AlwaysOverrideCursor = true
};
- LocalizedString translatedText = TextManager.Get(text);
+ LocalizedString translatedText = TextManager.Get(text).Fallback(text);
if (speaker?.Info != null && drawChathead)
{
@@ -335,7 +335,7 @@ namespace Barotrauma
{
foreach (string option in options)
{
- var btn = new GUIButton(new RectTransform(new Vector2(0.9f, 0.01f), textContent.RectTransform), TextManager.Get(option), style: "ListBoxElement");
+ var btn = new GUIButton(new RectTransform(new Vector2(0.9f, 0.01f), textContent.RectTransform), TextManager.Get(option).Fallback(option), style: "ListBoxElement");
btn.TextBlock.TextAlignment = Alignment.CenterLeft;
btn.TextColor = btn.HoverTextColor = GUIStyle.Green;
btn.TextBlock.Wrap = true;
diff --git a/Barotrauma/BarotraumaClient/ClientSource/GUI/GUI.cs b/Barotrauma/BarotraumaClient/ClientSource/GUI/GUI.cs
index 8d65228ff..ddddc7fc9 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/GUI/GUI.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/GUI/GUI.cs
@@ -301,6 +301,7 @@ namespace Barotrauma
}
float startY = 10.0f;
+ float yStep = AdjustForTextScale(18) * yScale;
if (GameMain.ShowFPS || GameMain.DebugDraw || GameMain.ShowPerf)
{
float y = startY;
@@ -309,11 +310,38 @@ namespace Barotrauma
Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
if (GameMain.GameSession != null && Timing.TotalTime > GameMain.GameSession.RoundStartTime + 1.0)
{
- y += AdjustForTextScale(15) * yScale;
+ y += yStep;
DrawString(spriteBatch, new Vector2(10, y),
$"Physics: {GameMain.CurrentUpdateRate}",
(GameMain.CurrentUpdateRate < Timing.FixedUpdateRate) ? Color.Red : Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
}
+ if (GameMain.DebugDraw || GameMain.ShowPerf)
+ {
+ y += yStep;
+ DrawString(spriteBatch, new Vector2(10, y),
+ "Active lights: " + Lights.LightManager.ActiveLightCount,
+ Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
+ y += yStep;
+ DrawString(spriteBatch, new Vector2(10, y),
+ "Physics: " + GameMain.World.UpdateTime.TotalMilliseconds + " ms",
+ Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
+ y += yStep;
+ try
+ {
+ DrawString(spriteBatch, new Vector2(10, y),
+ $"Bodies: {GameMain.World.BodyList.Count} ({GameMain.World.BodyList.Count(b => b != null && b.Awake && b.Enabled)} awake, {GameMain.World.BodyList.Count(b => b != null && b.Awake && b.BodyType == BodyType.Dynamic && b.Enabled)} dynamic)",
+ Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
+ }
+ catch (InvalidOperationException)
+ {
+ DebugConsole.AddWarning("Exception while rendering debug info. Physics bodies may have been created or removed while rendering.");
+ }
+ y += yStep;
+ DrawString(spriteBatch, new Vector2(10, y),
+ "Particle count: " + GameMain.ParticleManager.ParticleCount + "/" + GameMain.ParticleManager.MaxParticles,
+ Color.Lerp(GUIStyle.Green, GUIStyle.Red, (GameMain.ParticleManager.ParticleCount / (float)GameMain.ParticleManager.MaxParticles)), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
+
+ }
}
if (GameMain.ShowPerf)
@@ -324,67 +352,59 @@ namespace Barotrauma
"Draw - Avg: " + GameMain.PerformanceCounter.DrawTimeGraph.Average().ToString("0.00") + " ms" +
" Max: " + GameMain.PerformanceCounter.DrawTimeGraph.LargestValue().ToString("0.00") + " ms",
GUIStyle.Green, Color.Black * 0.8f, font: GUIStyle.SmallFont);
- y += 15 * yScale;
+ y += yStep;
GameMain.PerformanceCounter.DrawTimeGraph.Draw(spriteBatch, new Rectangle((int)x, (int)y, 170, 50), color: GUIStyle.Green);
- y += 50 * yScale;
+ y += yStep * 3;
DrawString(spriteBatch, new Vector2(x, y),
"Update - Avg: " + GameMain.PerformanceCounter.UpdateTimeGraph.Average().ToString("0.00") + " ms" +
" Max: " + GameMain.PerformanceCounter.UpdateTimeGraph.LargestValue().ToString("0.00") + " ms",
Color.LightBlue, Color.Black * 0.8f, font: GUIStyle.SmallFont);
- y += 15 * yScale;
+ y += yStep;
GameMain.PerformanceCounter.UpdateTimeGraph.Draw(spriteBatch, new Rectangle((int)x, (int)y, 170, 50), color: Color.LightBlue);
- y += 50 * yScale;
+ y += yStep * 3;
foreach (string key in GameMain.PerformanceCounter.GetSavedIdentifiers)
{
float elapsedMillisecs = GameMain.PerformanceCounter.GetAverageElapsedMillisecs(key);
DrawString(spriteBatch, new Vector2(x, y),
key + ": " + elapsedMillisecs.ToString("0.00"),
Color.Lerp(Color.LightGreen, GUIStyle.Red, elapsedMillisecs / 10.0f), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
- y += 15 * yScale;
+ y += yStep;
foreach (string childKey in GameMain.PerformanceCounter.GetSavedPartialIdentifiers(key))
{
elapsedMillisecs = GameMain.PerformanceCounter.GetPartialAverageElapsedMillisecs(key, childKey);
DrawString(spriteBatch, new Vector2(x + 15, y),
childKey + ": " + elapsedMillisecs.ToString("0.00"),
Color.Lerp(Color.LightGreen, GUIStyle.Red, elapsedMillisecs / 10.0f), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
- y += 15 * yScale;
+ y += yStep;
}
}
if (Powered.Grids != null)
{
DrawString(spriteBatch, new Vector2(x, y), "Grids: " + Powered.Grids.Count, Color.LightGreen, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
- y += 15 * yScale;
+ y += yStep;
}
if (Settings.EnableDiagnostics)
{
- x += 20 * xScale;
+ x += yStep * 2;
DrawString(spriteBatch, new Vector2(x, y), "ContinuousPhysicsTime: " + GameMain.World.ContinuousPhysicsTime.TotalMilliseconds, Color.Lerp(Color.LightGreen, GUIStyle.Red, (float)GameMain.World.ContinuousPhysicsTime.TotalMilliseconds / 10.0f), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
- DrawString(spriteBatch, new Vector2(x, y + 15 * yScale), "ControllersUpdateTime: " + GameMain.World.ControllersUpdateTime.TotalMilliseconds, Color.Lerp(Color.LightGreen, GUIStyle.Red, (float)GameMain.World.ControllersUpdateTime.TotalMilliseconds / 10.0f), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
- DrawString(spriteBatch, new Vector2(x, y + 30 * yScale), "AddRemoveTime: " + GameMain.World.AddRemoveTime.TotalMilliseconds, Color.Lerp(Color.LightGreen, GUIStyle.Red, (float)GameMain.World.AddRemoveTime.TotalMilliseconds / 10.0f), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
- DrawString(spriteBatch, new Vector2(x, y + 45 * yScale), "NewContactsTime: " + GameMain.World.NewContactsTime.TotalMilliseconds, Color.Lerp(Color.LightGreen, GUIStyle.Red, (float)GameMain.World.NewContactsTime.TotalMilliseconds / 10.0f), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
- DrawString(spriteBatch, new Vector2(x, y + 60 * yScale), "ContactsUpdateTime: " + GameMain.World.ContactsUpdateTime.TotalMilliseconds, Color.Lerp(Color.LightGreen, GUIStyle.Red, (float)GameMain.World.ContactsUpdateTime.TotalMilliseconds / 10.0f), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
- DrawString(spriteBatch, new Vector2(x, y + 75 * yScale), "SolveUpdateTime: " + GameMain.World.SolveUpdateTime.TotalMilliseconds, Color.Lerp(Color.LightGreen, GUIStyle.Red, (float)GameMain.World.SolveUpdateTime.TotalMilliseconds / 10.0f), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
+ DrawString(spriteBatch, new Vector2(x, y + yStep), "ControllersUpdateTime: " + GameMain.World.ControllersUpdateTime.TotalMilliseconds, Color.Lerp(Color.LightGreen, GUIStyle.Red, (float)GameMain.World.ControllersUpdateTime.TotalMilliseconds / 10.0f), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
+ DrawString(spriteBatch, new Vector2(x, y + yStep * 2), "AddRemoveTime: " + GameMain.World.AddRemoveTime.TotalMilliseconds, Color.Lerp(Color.LightGreen, GUIStyle.Red, (float)GameMain.World.AddRemoveTime.TotalMilliseconds / 10.0f), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
+ DrawString(spriteBatch, new Vector2(x, y + yStep * 3), "NewContactsTime: " + GameMain.World.NewContactsTime.TotalMilliseconds, Color.Lerp(Color.LightGreen, GUIStyle.Red, (float)GameMain.World.NewContactsTime.TotalMilliseconds / 10.0f), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
+ DrawString(spriteBatch, new Vector2(x, y + yStep * 4), "ContactsUpdateTime: " + GameMain.World.ContactsUpdateTime.TotalMilliseconds, Color.Lerp(Color.LightGreen, GUIStyle.Red, (float)GameMain.World.ContactsUpdateTime.TotalMilliseconds / 10.0f), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
+ DrawString(spriteBatch, new Vector2(x, y + yStep * 5), "SolveUpdateTime: " + GameMain.World.SolveUpdateTime.TotalMilliseconds, Color.Lerp(Color.LightGreen, GUIStyle.Red, (float)GameMain.World.SolveUpdateTime.TotalMilliseconds / 10.0f), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
}
}
if (GameMain.DebugDraw && !Submarine.Unloading && !(Screen.Selected is RoundSummaryScreen))
{
- float y = startY + 15 * yScale;
- DrawString(spriteBatch, new Vector2(10, y),
- "Physics: " + GameMain.World.UpdateTime,
- Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
-
- y += 15 * yScale;
- DrawString(spriteBatch, new Vector2(10, y),
- $"Bodies: {GameMain.World.BodyList.Count} ({GameMain.World.BodyList.Count(b => b != null && b.Awake && b.Enabled)} awake, {GameMain.World.BodyList.Count(b => b != null && b.Awake && b.BodyType == BodyType.Dynamic && b.Enabled)} dynamic)",
- Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
+ float y = startY + yStep * 6;
if (Screen.Selected.Cam != null)
{
- y += 15 * yScale;
+ y += yStep;
DrawString(spriteBatch, new Vector2(10, y),
"Camera pos: " + Screen.Selected.Cam.Position.ToPoint() + ", zoom: " + Screen.Selected.Cam.Zoom,
Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
@@ -392,23 +412,18 @@ namespace Barotrauma
if (Submarine.MainSub != null)
{
- y += 15 * yScale;
+ y += yStep;
DrawString(spriteBatch, new Vector2(10, y),
"Sub pos: " + Submarine.MainSub.Position.ToPoint(),
Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
}
- y += 20 * yScale;
- DrawString(spriteBatch, new Vector2(10, y),
- "Particle count: " + GameMain.ParticleManager.ParticleCount + "/" + GameMain.ParticleManager.MaxParticles,
- Color.Lerp(GUIStyle.Green, GUIStyle.Red, (GameMain.ParticleManager.ParticleCount / (float)GameMain.ParticleManager.MaxParticles)), Color.Black * 0.5f, 0, GUIStyle.SmallFont);
-
if (loadedSpritesText == null || DateTime.Now > loadedSpritesUpdateTime)
{
loadedSpritesText = "Loaded sprites: " + Sprite.LoadedSprites.Count() + "\n(" + Sprite.LoadedSprites.Select(s => s.FilePath).Distinct().Count() + " unique textures)";
loadedSpritesUpdateTime = DateTime.Now + new TimeSpan(0, 0, seconds: 5);
}
- y += 25 * yScale;
+ y += yStep * 2;
DrawString(spriteBatch, new Vector2(10, y), loadedSpritesText, Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
if (debugDrawSounds)
@@ -416,21 +431,21 @@ namespace Barotrauma
float soundTextY = 0;
DrawString(spriteBatch, new Vector2(500, soundTextY),
"Sounds (Ctrl+S to hide): ", Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
- soundTextY += 15 * yScale;
+ soundTextY += yStep;
DrawString(spriteBatch, new Vector2(500, soundTextY),
"Current playback amplitude: " + GameMain.SoundManager.PlaybackAmplitude.ToString(), Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
- soundTextY += 15 * yScale;
+ soundTextY += yStep;
DrawString(spriteBatch, new Vector2(500, soundTextY),
"Compressed dynamic range gain: " + GameMain.SoundManager.CompressionDynamicRangeGain.ToString(), Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
- soundTextY += 15 * yScale;
+ soundTextY += yStep;
DrawString(spriteBatch, new Vector2(500, soundTextY),
"Loaded sounds: " + GameMain.SoundManager.LoadedSoundCount + " (" + GameMain.SoundManager.UniqueLoadedSoundCount + " unique)", Color.White, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
- soundTextY += 15 * yScale;
+ soundTextY += yStep;
for (int i = 0; i < SoundManager.SOURCE_COUNT; i++)
{
@@ -479,7 +494,7 @@ namespace Barotrauma
}
DrawString(spriteBatch, new Vector2(500, soundTextY), soundStr, clr, Color.Black * 0.5f, 0, GUIStyle.SmallFont);
- soundTextY += 15 * yScale;
+ soundTextY += yStep;
}
}
else
@@ -1981,7 +1996,7 @@ namespace Barotrauma
var element = new GUIFrame(new RectTransform(new Vector2(0.22f, 1), inputArea.RectTransform) { MinSize = new Point(50, 0), MaxSize = new Point(150, 50) }, style: null);
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), RectComponentLabels[i], font: font, textAlignment: Alignment.CenterLeft);
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight),
- GUINumberInput.NumberType.Int)
+ NumberType.Int)
{
Font = font
};
@@ -2025,7 +2040,7 @@ namespace Barotrauma
var element = new GUIFrame(new RectTransform(new Vector2(0.45f, 1), inputArea.RectTransform), style: null);
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), VectorComponentLabels[i], font: GUIStyle.SmallFont, textAlignment: Alignment.CenterLeft);
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight),
- GUINumberInput.NumberType.Int)
+ NumberType.Int)
{
Font = GUIStyle.SmallFont
};
@@ -2055,7 +2070,7 @@ namespace Barotrauma
{
var element = new GUIFrame(new RectTransform(new Vector2(0.45f, 1), inputArea.RectTransform), style: null);
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), VectorComponentLabels[i], font: font, textAlignment: Alignment.CenterLeft);
- GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight), GUINumberInput.NumberType.Float) { Font = font };
+ GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight), NumberType.Float) { Font = font };
switch (i)
{
case 0:
@@ -2425,8 +2440,7 @@ namespace Barotrauma
verificationTextTag: GameMain.GameSession == null ? "PauseMenuQuitVerificationEditor" : "PauseMenuQuitVerification",
action: () =>
{
- // In the first campaign round we need to save the start items.
- GameMain.QuitToMainMenu(save: GameMain.GameSession.GameMode is SinglePlayerCampaign campaign && campaign.IsFirstRound);
+ GameMain.QuitToMainMenu(save: false);
});
}
else
diff --git a/Barotrauma/BarotraumaClient/ClientSource/GUI/GUINumberInput.cs b/Barotrauma/BarotraumaClient/ClientSource/GUI/GUINumberInput.cs
index b7265c76f..7e049e601 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/GUI/GUINumberInput.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/GUI/GUINumberInput.cs
@@ -7,11 +7,6 @@ namespace Barotrauma
{
class GUINumberInput : GUIComponent
{
- public enum NumberType
- {
- Int, Float
- }
-
public delegate void OnValueEnteredHandler(GUINumberInput numberInput);
public OnValueEnteredHandler OnValueEntered;
diff --git a/Barotrauma/BarotraumaClient/ClientSource/GUI/Store.cs b/Barotrauma/BarotraumaClient/ClientSource/GUI/Store.cs
index 303a207fd..d54f1a9f5 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/GUI/Store.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/GUI/Store.cs
@@ -1546,7 +1546,7 @@ namespace Barotrauma
{
RelativeSpacing = 0.02f
};
- amountInput = new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), shoppingCrateAmountGroup.RectTransform), GUINumberInput.NumberType.Int)
+ amountInput = new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), shoppingCrateAmountGroup.RectTransform), NumberType.Int)
{
MinValueInt = 0,
MaxValueInt = GetMaxAvailable(pi.ItemPrefab, containingTab),
diff --git a/Barotrauma/BarotraumaClient/ClientSource/GUI/TabMenu.cs b/Barotrauma/BarotraumaClient/ClientSource/GUI/TabMenu.cs
index d40a43dc0..8a71ba121 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/GUI/TabMenu.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/GUI/TabMenu.cs
@@ -1064,7 +1064,7 @@ namespace Barotrauma
GUIButton centerButton = new GUIButton(new RectTransform(new Vector2(1f), centerLayout.RectTransform, scaleBasis: ScaleBasis.BothHeight, anchor: Anchor.Center), style: "GUIButtonTransferArrow");
GUILayoutGroup inputLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.25f), paddedTransferMenuLayout.RectTransform), childAnchor: Anchor.Center);
- GUINumberInput transferAmountInput = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1f), inputLayout.RectTransform), GUINumberInput.NumberType.Int, hidePlusMinusButtons: true)
+ GUINumberInput transferAmountInput = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1f), inputLayout.RectTransform), NumberType.Int, hidePlusMinusButtons: true)
{
MinValueInt = 0
};
diff --git a/Barotrauma/BarotraumaClient/ClientSource/GameMain.cs b/Barotrauma/BarotraumaClient/ClientSource/GameMain.cs
index db6a05ff0..188c91bed 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/GameMain.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/GameMain.cs
@@ -1037,6 +1037,11 @@ namespace Barotrauma
{
GUI.SetSavingIndicatorState(true);
+ if (GameSession.Submarine != null && !GameSession.Submarine.Removed)
+ {
+ GameSession.SubmarineInfo = new SubmarineInfo(GameSession.Submarine);
+ }
+
// Update store stock when saving and quitting in an outpost (normally updated when CampaignMode.End() is called)
if (GameSession?.Campaign is SinglePlayerCampaign spCampaign && Level.IsLoadedOutpost && spCampaign.Map?.CurrentLocation != null && spCampaign.CargoManager != null)
{
@@ -1163,7 +1168,7 @@ namespace Barotrauma
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), linkHolder.RectTransform), TextManager.Get("bugreportgithubform"), style: "MainMenuGUIButton", textAlignment: Alignment.Left)
{
- UserData = "https://github.com/Regalis11/Barotrauma/issues/new?template=bug_report.md",
+ UserData = "https://github.com/Regalis11/Barotrauma/issues/new/choose",
OnClicked = (btn, userdata) =>
{
ShowOpenUrlInWebBrowserPrompt(userdata as string);
diff --git a/Barotrauma/BarotraumaClient/ClientSource/GameSession/GameModes/SinglePlayerCampaign.cs b/Barotrauma/BarotraumaClient/ClientSource/GameSession/GameModes/SinglePlayerCampaign.cs
index 7e7506931..382c43a58 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/GameSession/GameModes/SinglePlayerCampaign.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/GameSession/GameModes/SinglePlayerCampaign.cs
@@ -92,7 +92,7 @@ namespace Barotrauma
break;
case "crew":
GameMain.GameSession.CrewManager = new CrewManager(subElement, true);
- ActiveOrdersElement = element.GetChildElement("activeorders");
+ ActiveOrdersElement = subElement.GetChildElement("activeorders");
break;
case "map":
map = Map.Load(this, subElement, Settings);
@@ -461,6 +461,7 @@ namespace Barotrauma
if (success)
{
+ GameMain.GameSession.SubmarineInfo = new SubmarineInfo(GameMain.GameSession.Submarine);
SaveUtil.SaveGame(GameMain.GameSession.SavePath);
}
else
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Growable.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Growable.cs
index d903016ad..8428d53ff 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Growable.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Growable.cs
@@ -321,7 +321,7 @@ namespace Barotrauma.Items.Components
{
GUILayoutGroup layout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.08f), parent), isHorizontal: true);
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), layout.RectTransform), label);
- GUINumberInput input = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1f), layout.RectTransform), GUINumberInput.NumberType.Int) { IntValue = defaultValue };
+ GUINumberInput input = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1f), layout.RectTransform), NumberType.Int) { IntValue = defaultValue };
return input;
}
@@ -329,7 +329,7 @@ namespace Barotrauma.Items.Components
{
GUILayoutGroup layout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.08f), parent), isHorizontal: true);
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), layout.RectTransform), label);
- GUINumberInput input = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1f), layout.RectTransform), GUINumberInput.NumberType.Float) { FloatValue = defaultValue, DecimalsToDisplay = 2 };
+ GUINumberInput input = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1f), layout.RectTransform), NumberType.Float) { FloatValue = defaultValue, DecimalsToDisplay = 2 };
return input;
}
@@ -341,7 +341,7 @@ namespace Barotrauma.Items.Components
for (var i = 0; i < values.Length; i++)
{
float value = values[i];
- GUINumberInput input = new GUINumberInput(new RectTransform(new Vector2(0.5f / values.Length, 1f), layout.RectTransform), GUINumberInput.NumberType.Float)
+ GUINumberInput input = new GUINumberInput(new RectTransform(new Vector2(0.5f / values.Length, 1f), layout.RectTransform), NumberType.Float)
{
FloatValue = value, DecimalsToDisplay = 2,
MinValueFloat = min,
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/ItemContainer.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/ItemContainer.cs
index 5fe3adde1..b1d894203 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/ItemContainer.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/ItemContainer.cs
@@ -280,9 +280,9 @@ namespace Barotrauma.Items.Components
transformedItemPos += new Vector2(item.Rect.X, item.Rect.Y);
if (item.Submarine != null) { transformedItemPos += item.Submarine.DrawPosition; }
- if (Math.Abs(item.Rotation) > 0.01f)
+ if (Math.Abs(item.RotationRad) > 0.01f)
{
- Matrix transform = Matrix.CreateRotationZ(MathHelper.ToRadians(-item.Rotation));
+ Matrix transform = Matrix.CreateRotationZ(-item.RotationRad);
transformedItemPos = Vector2.Transform(transformedItemPos - item.DrawPosition, transform) + item.DrawPosition;
transformedItemInterval = Vector2.Transform(transformedItemInterval, transform);
transformedItemIntervalHorizontal = Vector2.Transform(transformedItemIntervalHorizontal, transform);
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/LightComponent.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/LightComponent.cs
index 52cf7fef1..337a21274 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/LightComponent.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/LightComponent.cs
@@ -56,9 +56,7 @@ namespace Barotrauma.Items.Components
}
else
{
- Vector2 pos = item.DrawPosition;
- if (item.Submarine != null) { pos -= item.Submarine.DrawPosition; }
- Light.Position = pos;
+ Light.Position = item.Position;
}
PhysicsBody body = Light.ParentBody;
if (body != null)
@@ -68,7 +66,7 @@ namespace Barotrauma.Items.Components
}
else
{
- Light.Rotation = -Rotation - MathHelper.ToRadians(item.Rotation);
+ Light.Rotation = -Rotation - item.RotationRad;
Light.LightSpriteEffect = item.SpriteEffects;
}
}
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Deconstructor.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Deconstructor.cs
index 2a6d4328e..52c211c18 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Deconstructor.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Deconstructor.cs
@@ -240,7 +240,7 @@ namespace Barotrauma.Items.Components
private bool OnActivateButtonClicked(GUIButton button, object obj)
{
var disallowedItem = inputContainer.Inventory.FindItem(i => !i.AllowDeconstruct, recursive: false);
- if (disallowedItem != null)
+ if (disallowedItem != null && !DeconstructItemsSimultaneously)
{
int index = inputContainer.Inventory.FindIndex(disallowedItem);
if (index >= 0 && index < inputContainer.Inventory.visualSlots.Length)
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/MiniMap.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/MiniMap.cs
index 87289c772..d14a9b237 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/MiniMap.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/MiniMap.cs
@@ -613,7 +613,7 @@ namespace Barotrauma.Items.Components
if (hullData.Distort)
{
hullData.ReceivedOxygenAmount = Rand.Range(0.0f, 100.0f);
- hullData.ReceivedWaterAmount = Rand.Range(0.0f, 1.0f);
+ hullData.ReceivedWaterAmount = Rand.Range(0.0f, 100.0f);
}
hullData.DistortionTimer = Rand.Range(1.0f, 10.0f);
}
@@ -681,7 +681,7 @@ namespace Barotrauma.Items.Components
var sprite = GUIStyle.UIGlowSolidCircular.Value?.Sprite;
float alpha = (MathF.Sin(blipState / maxBlipState * MathHelper.TwoPi) + 1.5f) * 0.5f;
- if (sprite != null)
+ if (sprite != null && ShowHullIntegrity)
{
Vector2 spriteSize = sprite.size;
Rectangle worldBorders = item.Submarine.GetDockedBorders();
@@ -1014,13 +1014,13 @@ namespace Barotrauma.Items.Components
hullData.HullWaterAmount = 0.0f;
foreach (Hull linkedHull in hullData.LinkedHulls)
{
- hullData.HullWaterAmount += Math.Min(linkedHull.WaterVolume / linkedHull.Volume, 1.0f);
+ hullData.HullWaterAmount += WaterDetector.GetWaterPercentage(linkedHull);
}
hullData.HullWaterAmount /= hullData.LinkedHulls.Count;
}
else
{
- hullData.HullWaterAmount = Math.Min(hull.WaterVolume / hull.Volume, 1.0f);
+ hullData.HullWaterAmount = WaterDetector.GetWaterPercentage(hull);
}
float gapOpenSum = 0.0f;
@@ -1052,8 +1052,8 @@ namespace Barotrauma.Items.Components
LocalizedString line3 = waterAmount == null ?
TextManager.Get("MiniMapWaterLevelUnavailable") :
- TextManager.AddPunctuation(':', TextManager.Get("MiniMapWaterLevel"), (int)Math.Round(waterAmount.Value * 100.0f) + "%");
- Color line3Color = waterAmount == null ? GUIStyle.Red : Color.Lerp(Color.LightGreen, GUIStyle.Red, (float)waterAmount);
+ TextManager.AddPunctuation(':', TextManager.Get("MiniMapWaterLevel"), (int)Math.Round(waterAmount.Value) + "%");
+ Color line3Color = waterAmount == null ? GUIStyle.Red : Color.Lerp(Color.LightGreen, GUIStyle.Red, (float)waterAmount / 100.0f);
SetTooltip(borderComponent.Rect.Center, header, line1, line2, line3, line1Color, line2Color, line3Color);
}
@@ -1188,7 +1188,8 @@ namespace Barotrauma.Items.Components
if (hullsVisible && hullData.HullWaterAmount is { } waterAmount)
{
- if (!RequireWaterDetectors) { waterAmount = hull.WaterPercentage / 100.0f; }
+ if (!RequireWaterDetectors) { waterAmount = WaterDetector.GetWaterPercentage(hull); }
+ waterAmount /= 100.0f;
if (hullFrame.Rect.Height * waterAmount > 1.0f)
{
RectangleF waterRect = new RectangleF(hullFrame.Rect.X, hullFrame.Rect.Y + hullFrame.Rect.Height * (1.0f - waterAmount), hullFrame.Rect.Width, hullFrame.Rect.Height * waterAmount);
@@ -1327,7 +1328,7 @@ namespace Barotrauma.Items.Components
pos.X += inflate;
pos.Y += inflate;
- sprite.Draw(spriteBatch, pos, item.SpriteColor, sprite.Origin, MathHelper.ToRadians(item.Rotation), spriteScale, item.SpriteEffects);
+ sprite.Draw(spriteBatch, pos, item.SpriteColor, sprite.Origin, item.RotationRad, spriteScale, item.SpriteEffects);
void DrawAdditionalSprite(Vector2 basePos, Sprite addSprite, float rotation)
{
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Pump.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Pump.cs
index e50bbcc8d..f3bfe988b 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Pump.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Pump.cs
@@ -133,7 +133,6 @@ namespace Barotrauma.Items.Components
partial void UpdateProjSpecific(float deltaTime)
{
- float rotationRad = MathHelper.ToRadians(item.Rotation);
if (FlowPercentage < 0.0f)
{
foreach (var (position, emitter) in pumpOutEmitters)
@@ -142,8 +141,8 @@ namespace Barotrauma.Items.Components
//only emit "pump out" particles when underwater
Vector2 relativeParticlePos = (item.WorldRect.Location.ToVector2() + position * item.Scale) - item.WorldPosition;
- relativeParticlePos = MathUtils.RotatePoint(relativeParticlePos, item.FlippedX ? rotationRad : -rotationRad);
- float angle = -rotationRad;
+ relativeParticlePos = MathUtils.RotatePoint(relativeParticlePos, item.FlippedX ? item.RotationRad : -item.RotationRad);
+ float angle = -item.RotationRad;
if (item.FlippedX)
{
relativeParticlePos.X = -relativeParticlePos.X;
@@ -163,8 +162,8 @@ namespace Barotrauma.Items.Components
foreach (var (position, emitter) in pumpInEmitters)
{
Vector2 relativeParticlePos = (item.WorldRect.Location.ToVector2() + position * item.Scale) - item.WorldPosition;
- relativeParticlePos = MathUtils.RotatePoint(relativeParticlePos, item.FlippedX ? rotationRad : -rotationRad);
- float angle = -rotationRad;
+ relativeParticlePos = MathUtils.RotatePoint(relativeParticlePos, item.FlippedX ? item.RotationRad : -item.RotationRad);
+ float angle = -item.RotationRad;
if (item.FlippedX)
{
relativeParticlePos.X = -relativeParticlePos.X;
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Repairable.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Repairable.cs
index 5d3e959c3..d1a295c91 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Repairable.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Repairable.cs
@@ -1,11 +1,10 @@
-using System;
-using Barotrauma.Networking;
+using Barotrauma.Networking;
using Barotrauma.Particles;
using Barotrauma.Sounds;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
+using System;
using System.Collections.Generic;
-using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Rope.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Rope.cs
index 36713eab5..9526f7f63 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Rope.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Rope.cs
@@ -92,6 +92,8 @@ namespace Barotrauma.Items.Components
{
if (target == null || target.Removed) { return; }
if (target.ParentInventory != null) { return; }
+ if (source is Limb limb && limb.Removed) { return; }
+ if (source is Entity e && e.Removed) { return; }
Vector2 startPos = GetSourcePos();
startPos.Y = -startPos.Y;
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Signal/CustomInterface.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Signal/CustomInterface.cs
index 1853d569c..706105771 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Signal/CustomInterface.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Signal/CustomInterface.cs
@@ -45,7 +45,7 @@ namespace Barotrauma.Items.Components
};
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), layoutGroup.RectTransform),
TextManager.Get(ciElement.Label).Fallback(ciElement.Label));
- if (!ciElement.IsIntegerInput)
+ if (!ciElement.IsNumberInput)
{
var textBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 1.0f), layoutGroup.RectTransform), ciElement.Signal, style: "GUITextBoxNoIcon")
{
@@ -77,29 +77,71 @@ namespace Barotrauma.Items.Components
}
else
{
- int.TryParse(ciElement.Signal, out int signal);
- var numberInput = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1.0f), layoutGroup.RectTransform), GUINumberInput.NumberType.Int)
+ GUINumberInput numberInput = null;
+ if (ciElement.NumberType == NumberType.Float)
{
- UserData = ciElement,
- MinValueInt = ciElement.NumberInputMin,
- MaxValueInt = ciElement.NumberInputMax,
- IntValue = Math.Clamp(signal, ciElement.NumberInputMin, ciElement.NumberInputMax)
- };
- //reset size restrictions set by the Style to make sure the elements can fit the interface
- numberInput.RectTransform.MinSize = numberInput.LayoutGroup.RectTransform.MinSize = new Point(0, 0);
- numberInput.RectTransform.MaxSize = numberInput.LayoutGroup.RectTransform.MaxSize = new Point(int.MaxValue, int.MaxValue);
- numberInput.OnValueChanged += (ni) =>
+ TryParseFloatInvariantCulture(ciElement.Signal, out float floatSignal);
+ TryParseFloatInvariantCulture(ciElement.NumberInputMin, out float numberInputMin);
+ TryParseFloatInvariantCulture(ciElement.NumberInputMax, out float numberInputMax);
+ TryParseFloatInvariantCulture(ciElement.NumberInputStep, out float numberInputStep);
+ numberInput = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1.0f), layoutGroup.RectTransform), NumberType.Float)
+ {
+ UserData = ciElement,
+ MinValueFloat = numberInputMin,
+ MaxValueFloat = numberInputMax,
+ FloatValue = Math.Clamp(floatSignal, numberInputMin, numberInputMax),
+ DecimalsToDisplay = ciElement.NumberInputDecimalPlaces,
+ valueStep = numberInputStep,
+ OnValueChanged = (ni) =>
+ {
+ if (GameMain.Client == null)
+ {
+ ValueChanged(ni.UserData as CustomInterfaceElement, ni.FloatValue);
+ }
+ else
+ {
+ item.CreateClientEvent(this);
+ }
+ }
+ };
+ }
+ else if (ciElement.NumberType == NumberType.Int)
{
- if (GameMain.Client == null)
+ int.TryParse(ciElement.Signal, out int intSignal);
+ int.TryParse(ciElement.NumberInputMin, out int numberInputMin);
+ int.TryParse(ciElement.NumberInputMax, out int numberInputMax);
+ TryParseFloatInvariantCulture(ciElement.NumberInputStep, out float numberInputStep);
+ numberInput = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1.0f), layoutGroup.RectTransform), NumberType.Int)
{
- ValueChanged(ni.UserData as CustomInterfaceElement, ni.IntValue);
- }
- else
- {
- item.CreateClientEvent(this);
- }
- };
- uiElements.Add(numberInput);
+ UserData = ciElement,
+ MinValueInt = numberInputMin,
+ MaxValueInt = numberInputMax,
+ IntValue = Math.Clamp(intSignal, numberInputMin, numberInputMax),
+ valueStep = numberInputStep,
+ OnValueChanged = (ni) =>
+ {
+ if (GameMain.Client == null)
+ {
+ ValueChanged(ni.UserData as CustomInterfaceElement, ni.IntValue);
+ }
+ else
+ {
+ item.CreateClientEvent(this);
+ }
+ }
+ };
+ }
+ else
+ {
+ DebugConsole.ShowError($"Error creating a CustomInterface component: unexpected NumberType \"{(ciElement.NumberType.HasValue ? ciElement.NumberType.Value.ToString() : "none")}\"");
+ }
+ if (numberInput != null)
+ {
+ //reset size restrictions set by the Style to make sure the elements can fit the interface
+ numberInput.RectTransform.MinSize = numberInput.LayoutGroup.RectTransform.MinSize = new Point(0, 0);
+ numberInput.RectTransform.MaxSize = numberInput.LayoutGroup.RectTransform.MaxSize = new Point(int.MaxValue, int.MaxValue);
+ uiElements.Add(numberInput);
+ }
}
}
else if (ciElement.ContinuousSignal)
@@ -293,7 +335,7 @@ namespace Barotrauma.Items.Components
}
else if (uiElements[i] is GUINumberInput ni)
{
- if (ni.InputType == GUINumberInput.NumberType.Int)
+ if (ni.InputType == NumberType.Int)
{
int.TryParse(customInterfaceElementList[i].Signal, out int value);
ni.IntValue = value;
@@ -307,18 +349,28 @@ namespace Barotrauma.Items.Components
//extradata contains an array of buttons clicked by the player (or nothing if the player didn't click anything)
for (int i = 0; i < customInterfaceElementList.Count; i++)
{
- if (customInterfaceElementList[i].HasPropertyName)
+ var element = customInterfaceElementList[i];
+ if (element.HasPropertyName)
{
- if (!customInterfaceElementList[i].IsIntegerInput)
+ if (!element.IsNumberInput)
{
msg.Write(((GUITextBox)uiElements[i]).Text);
}
else
{
- msg.Write(((GUINumberInput)uiElements[i]).IntValue.ToString());
+ switch (element.NumberType)
+ {
+ case NumberType.Float:
+ msg.Write(((GUINumberInput)uiElements[i]).FloatValue.ToString());
+ break;
+ case NumberType.Int:
+ default:
+ msg.Write(((GUINumberInput)uiElements[i]).IntValue.ToString());
+ break;
+ }
}
}
- else if (customInterfaceElementList[i].ContinuousSignal)
+ else if (element.ContinuousSignal)
{
msg.Write(((GUITickBox)uiElements[i]).Selected);
}
@@ -333,29 +385,38 @@ namespace Barotrauma.Items.Components
{
for (int i = 0; i < customInterfaceElementList.Count; i++)
{
- if (customInterfaceElementList[i].HasPropertyName)
+ var element = customInterfaceElementList[i];
+ if (element.HasPropertyName)
{
- if (!customInterfaceElementList[i].IsIntegerInput)
+ string newValue = msg.ReadString();
+ if (!element.IsNumberInput)
{
- TextChanged(customInterfaceElementList[i], msg.ReadString());
+ TextChanged(element, newValue);
}
else
{
- int.TryParse(msg.ReadString(), out int value);
- ValueChanged(customInterfaceElementList[i], value);
+ switch (element.NumberType)
+ {
+ case NumberType.Int when int.TryParse(newValue, out int value):
+ ValueChanged(element, value);
+ break;
+ case NumberType.Float when TryParseFloatInvariantCulture(newValue, out float value):
+ ValueChanged(element, value);
+ break;
+ }
}
}
else
{
bool elementState = msg.ReadBoolean();
- if (customInterfaceElementList[i].ContinuousSignal)
+ if (element.ContinuousSignal)
{
((GUITickBox)uiElements[i]).Selected = elementState;
- TickBoxToggled(customInterfaceElementList[i], elementState);
+ TickBoxToggled(element, elementState);
}
else if (elementState)
{
- ButtonClicked(customInterfaceElementList[i]);
+ ButtonClicked(element);
}
}
}
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Item.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Item.cs
index e7cc950ab..bda201aa8 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Items/Item.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Item.cs
@@ -352,7 +352,7 @@ namespace Barotrauma
foreach (var decorativeSprite in Prefab.DecorativeSprites)
{
if (!spriteAnimState[decorativeSprite].IsActive) { continue; }
- Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier, flippedX && Prefab.CanSpriteFlipX ? rotationRad : -rotationRad) * Scale;
+ Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier, flippedX && Prefab.CanSpriteFlipX ? RotationRad : -RotationRad) * Scale;
if (flippedX && Prefab.CanSpriteFlipX) { offset.X = -offset.X; }
if (flippedY && Prefab.CanSpriteFlipY) { offset.Y = -offset.Y; }
decorativeSprite.Sprite.DrawTiled(spriteBatch,
@@ -376,17 +376,17 @@ namespace Barotrauma
}
if (color.A > 0)
{
- activeSprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y) + drawOffset, color, origin, rotationRad, Scale, activeSprite.effects, depth);
+ activeSprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y) + drawOffset, color, origin, RotationRad, Scale, activeSprite.effects, depth);
if (fadeInBrokenSprite != null)
{
float d = Math.Min(depth + (fadeInBrokenSprite.Sprite.Depth - activeSprite.Depth - 0.000001f), 0.999f);
- fadeInBrokenSprite.Sprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y) + fadeInBrokenSprite.Offset.ToVector2() * Scale, color * fadeInBrokenSpriteAlpha, origin, rotationRad, Scale, activeSprite.effects, d);
+ fadeInBrokenSprite.Sprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y) + fadeInBrokenSprite.Offset.ToVector2() * Scale, color * fadeInBrokenSpriteAlpha, origin, RotationRad, Scale, activeSprite.effects, d);
}
}
if (Infector != null && (Infector.ParentBallastFlora.HasBrokenThrough || BallastFloraBehavior.AlwaysShowBallastFloraSprite))
{
- Prefab.InfectedSprite?.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y) + drawOffset, color, Prefab.InfectedSprite.Origin, rotationRad, Scale, activeSprite.effects, depth - 0.001f);
- Prefab.DamagedInfectedSprite?.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y) + drawOffset, Infector.HealthColor, Prefab.DamagedInfectedSprite.Origin, rotationRad, Scale, activeSprite.effects, depth - 0.002f);
+ Prefab.InfectedSprite?.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y) + drawOffset, color, Prefab.InfectedSprite.Origin, RotationRad, Scale, activeSprite.effects, depth - 0.001f);
+ Prefab.DamagedInfectedSprite?.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y) + drawOffset, Infector.HealthColor, Prefab.DamagedInfectedSprite.Origin, RotationRad, Scale, activeSprite.effects, depth - 0.002f);
}
foreach (var decorativeSprite in Prefab.DecorativeSprites)
{
@@ -394,11 +394,11 @@ namespace Barotrauma
float rot = decorativeSprite.GetRotation(ref spriteAnimState[decorativeSprite].RotationState, spriteAnimState[decorativeSprite].RandomRotationFactor);
bool flipX = flippedX && Prefab.CanSpriteFlipX;
bool flipY = flippedY && Prefab.CanSpriteFlipY;
- Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier, flipX ^ flipY ? rotationRad : -rotationRad) * Scale;
+ Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier, flipX ^ flipY ? RotationRad : -RotationRad) * Scale;
if (flipX) { offset.X = -offset.X; }
if (flipY) { offset.Y = -offset.Y; }
decorativeSprite.Sprite.Draw(spriteBatch, new Vector2(DrawPosition.X + offset.X, -(DrawPosition.Y + offset.Y)), color,
- rotationRad + rot, decorativeSprite.GetScale(spriteAnimState[decorativeSprite].RandomScaleFactor) * Scale, activeSprite.effects,
+ RotationRad + rot, decorativeSprite.GetScale(spriteAnimState[decorativeSprite].RandomScaleFactor) * Scale, activeSprite.effects,
depth: Math.Min(depth + (decorativeSprite.Sprite.Depth - activeSprite.Depth), 0.999f));
}
}
@@ -445,7 +445,7 @@ namespace Barotrauma
{
if (!spriteAnimState[decorativeSprite].IsActive) { continue; }
float rotation = decorativeSprite.GetRotation(ref spriteAnimState[decorativeSprite].RotationState, spriteAnimState[decorativeSprite].RandomRotationFactor);
- Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier, -rotationRad) * Scale;
+ Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier, -RotationRad) * Scale;
if (flippedX && Prefab.CanSpriteFlipX) { offset.X = -offset.X; }
if (flippedY && Prefab.CanSpriteFlipY) { offset.Y = -offset.Y; }
var ca = (float)Math.Cos(-body.Rotation);
@@ -466,7 +466,7 @@ namespace Barotrauma
{
if (!spriteAnimState[decorativeSprite].IsActive) { continue; }
float rotation = decorativeSprite.GetRotation(ref spriteAnimState[decorativeSprite].RotationState, spriteAnimState[decorativeSprite].RandomRotationFactor);
- Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier, -rotationRad) * Scale;
+ Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier, -RotationRad) * Scale;
if (flippedX && Prefab.CanSpriteFlipX) { offset.X = -offset.X; }
if (flippedY && Prefab.CanSpriteFlipY) { offset.Y = -offset.Y; }
decorativeSprite.Sprite.Draw(spriteBatch, new Vector2(DrawPosition.X + offset.X, -(DrawPosition.Y + offset.Y)), color,
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Map/Levels/LevelRenderer.cs b/Barotrauma/BarotraumaClient/ClientSource/Map/Levels/LevelRenderer.cs
index 475553ddf..f92c7a30f 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Map/Levels/LevelRenderer.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Map/Levels/LevelRenderer.cs
@@ -60,12 +60,6 @@ namespace Barotrauma
}
public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
{
IsDisposed = true;
WallEdgeBuffer?.Dispose();
@@ -482,12 +476,6 @@ namespace Barotrauma
}
public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
{
foreach (var vertexBuffer in vertexBuffers)
{
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Map/Levels/WaterRenderer.cs b/Barotrauma/BarotraumaClient/ClientSource/Map/Levels/WaterRenderer.cs
index ea9eebd9c..a053bcc73 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Map/Levels/WaterRenderer.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Map/Levels/WaterRenderer.cs
@@ -230,14 +230,6 @@ namespace Barotrauma
public void Dispose()
{
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (!disposing) return;
-
if (WaterEffect != null)
{
WaterEffect.Dispose();
@@ -250,6 +242,5 @@ namespace Barotrauma
basicEffect = null;
}
}
-
}
}
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Map/Lights/LightManager.cs b/Barotrauma/BarotraumaClient/ClientSource/Map/Lights/LightManager.cs
index d1764fd10..e49b2cf55 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Map/Lights/LightManager.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Map/Lights/LightManager.cs
@@ -11,6 +11,18 @@ namespace Barotrauma.Lights
{
class LightManager
{
+ ///
+ /// How many light sources are allowed to recalculate their light volumes per frame.
+ /// Pending calculations will be done on subsequent frames, starting from the light sources that have been waiting for a recalculation the longest.
+ ///
+ const int MaxLightVolumeRecalculationsPerFrame = 5;
+
+ ///
+ /// If zoomed further out than this, characters no longer obstruct lights behind them.
+ /// Improves performance, and isn't very noticeable if we do it after zoomed far out enough.
+ ///
+ const float ObstructLightsBehindCharactersZoomThreshold = 0.5f;
+
public static Entity ViewTarget { get; set; }
private float currLightMapScale;
@@ -59,6 +71,8 @@ namespace Barotrauma.Lights
private Vector2 losOffset;
+ private int recalculationCount;
+
public IEnumerable Lights
{
get { return lights; }
@@ -151,6 +165,9 @@ namespace Barotrauma.Lights
}
private readonly List activeLights = new List(capacity: 100);
+ private readonly List activeLightsWithLightVolume = new List(capacity: 100);
+
+ public static int ActiveLightCount { get; private set; }
public void Update(float deltaTime)
{
@@ -180,11 +197,13 @@ namespace Barotrauma.Lights
Rectangle viewRect = cam.WorldView;
viewRect.Y -= cam.WorldView.Height;
//check which lights need to be drawn
+ recalculationCount = 0;
activeLights.Clear();
foreach (LightSource light in lights)
{
if (!light.Enabled) { continue; }
if ((light.Color.A < 1 || light.Range < 1.0f) && !light.LightSourceParams.OverrideLightSpriteAlpha.HasValue) { continue; }
+
if (light.ParentBody != null)
{
light.ParentBody.UpdateDrawPosition();
@@ -205,8 +224,44 @@ namespace Barotrauma.Lights
range = Math.Max(Math.Max(spriteRange, targetSize), range);
}
if (!MathUtils.CircleIntersectsRectangle(light.WorldPosition, range, viewRect)) { continue; }
- activeLights.Add(light);
+
+ light.Priority = lightPriority(range, light);
+
+ int i = 0;
+ while (i < activeLights.Count && light.Priority < activeLights[i].Priority)
+ {
+ i++;
+ }
+ activeLights.Insert(i, light);
}
+ ActiveLightCount = activeLights.Count;
+
+ float lightPriority(float range, LightSource light)
+ {
+ return
+ range *
+ ((Character.Controlled?.Submarine != null && light.ParentSub == Character.Controlled?.Submarine) ? 2.0f : 1.0f) *
+ (light.CastShadows ? 10.0f : 1.0f) *
+ (light.LightSourceParams.OverrideLightSpriteAlpha ?? (light.Color.A / 255.0f));
+ }
+
+ //find the lights with an active light volume
+ activeLightsWithLightVolume.Clear();
+ foreach (var activeLight in activeLights)
+ {
+ if (activeLight.Range < 1.0f || activeLight.Color.A < 1 || activeLight.CurrentBrightness <= 0.0f) { continue; }
+ activeLightsWithLightVolume.Add(activeLight);
+ }
+
+ //remove some lights with a light volume if there's too many of them
+ if (activeLightsWithLightVolume.Count > GameSettings.CurrentConfig.Graphics.VisibleLightLimit)
+ {
+ for (int i = GameSettings.CurrentConfig.Graphics.VisibleLightLimit; i < activeLightsWithLightVolume.Count; i++)
+ {
+ activeLights.Remove(activeLightsWithLightVolume[i]);
+ }
+ }
+ activeLights.Sort((l1, l2) => l1.LastRecalculationTime.CompareTo(l2.LastRecalculationTime));
//draw light sprites attached to characters
//render into a separate rendertarget using alpha blending (instead of on top of everything else with alpha blending)
@@ -235,7 +290,7 @@ namespace Barotrauma.Lights
{
if (!light.IsBackground || light.CurrentBrightness <= 0.0f) { continue; }
light.DrawSprite(spriteBatch, cam);
- light.DrawLightVolume(spriteBatch, lightEffect, transform);
+ light.DrawLightVolume(spriteBatch, lightEffect, transform, recalculationCount < MaxLightVolumeRecalculationsPerFrame, ref recalculationCount);
}
GameMain.ParticleManager.Draw(spriteBatch, true, null, Particles.ParticleBlendState.Additive);
spriteBatch.End();
@@ -243,14 +298,6 @@ namespace Barotrauma.Lights
//draw a black rectangle on hulls to hide background lights behind subs
//---------------------------------------------------------------------------------------------------
- /*if (backgroundObstructor != null)
- {
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
- spriteBatch.Draw(backgroundObstructor, new Rectangle(0, 0,
- (int)(GameMain.GraphicsWidth * currLightMapScale), (int)(GameMain.GraphicsHeight * currLightMapScale)), Color.Black);
- spriteBatch.End();
- }*/
-
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, transformMatrix: spriteBatchTransform);
Dictionary visibleHulls = GetVisibleHulls(cam);
foreach (KeyValuePair hull in visibleHulls)
@@ -292,41 +339,44 @@ namespace Barotrauma.Lights
//draw characters to obstruct the highlighted items/characters and light sprites
//---------------------------------------------------------------------------------------------------
-
- SolidColorEffect.CurrentTechnique = SolidColorEffect.Techniques["SolidVertexColor"];
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, effect: SolidColorEffect, transformMatrix: spriteBatchTransform);
- foreach (Character character in Character.CharacterList)
+ if (cam.Zoom > ObstructLightsBehindCharactersZoomThreshold)
{
- if (character.CurrentHull == null || !character.Enabled || !character.IsVisible) { continue; }
- if (Character.Controlled?.FocusedCharacter == character) { continue; }
- Color lightColor = character.CurrentHull.AmbientLight == Color.TransparentBlack ?
- Color.Black :
- character.CurrentHull.AmbientLight.Multiply(character.CurrentHull.AmbientLight.A / 255.0f).Opaque();
- foreach (Limb limb in character.AnimController.Limbs)
+ SolidColorEffect.CurrentTechnique = SolidColorEffect.Techniques["SolidVertexColor"];
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, effect: SolidColorEffect, transformMatrix: spriteBatchTransform);
+ foreach (Character character in Character.CharacterList)
{
- if (limb.DeformSprite != null) { continue; }
- limb.Draw(spriteBatch, cam, lightColor);
+ if (character.CurrentHull == null || !character.Enabled || !character.IsVisible) { continue; }
+ if (Character.Controlled?.FocusedCharacter == character) { continue; }
+ Color lightColor = character.CurrentHull.AmbientLight == Color.TransparentBlack ?
+ Color.Black :
+ character.CurrentHull.AmbientLight.Multiply(character.CurrentHull.AmbientLight.A / 255.0f).Opaque();
+ foreach (Limb limb in character.AnimController.Limbs)
+ {
+ if (limb.DeformSprite != null) { continue; }
+ limb.Draw(spriteBatch, cam, lightColor);
+ }
}
- }
- spriteBatch.End();
+ spriteBatch.End();
- DeformableSprite.Effect.CurrentTechnique = DeformableSprite.Effect.Techniques["DeformShaderSolidVertexColor"];
- DeformableSprite.Effect.CurrentTechnique.Passes[0].Apply();
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, transformMatrix: spriteBatchTransform);
- foreach (Character character in Character.CharacterList)
- {
- if (character.CurrentHull == null || !character.Enabled || !character.IsVisible) { continue; }
- if (Character.Controlled?.FocusedCharacter == character) { continue; }
- Color lightColor = character.CurrentHull.AmbientLight == Color.TransparentBlack ?
- Color.Black :
- character.CurrentHull.AmbientLight.Multiply(character.CurrentHull.AmbientLight.A / 255.0f).Opaque();
- foreach (Limb limb in character.AnimController.Limbs)
+ DeformableSprite.Effect.CurrentTechnique = DeformableSprite.Effect.Techniques["DeformShaderSolidVertexColor"];
+ DeformableSprite.Effect.CurrentTechnique.Passes[0].Apply();
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, transformMatrix: spriteBatchTransform);
+ foreach (Character character in Character.CharacterList)
{
- if (limb.DeformSprite == null) { continue; }
- limb.Draw(spriteBatch, cam, lightColor);
+ if (character.CurrentHull == null || !character.Enabled || !character.IsVisible) { continue; }
+ if (Character.Controlled?.FocusedCharacter == character) { continue; }
+ Color lightColor = character.CurrentHull.AmbientLight == Color.TransparentBlack ?
+ Color.Black :
+ character.CurrentHull.AmbientLight.Multiply(character.CurrentHull.AmbientLight.A / 255.0f).Opaque();
+ foreach (Limb limb in character.AnimController.Limbs)
+ {
+ if (limb.DeformSprite == null) { continue; }
+ limb.Draw(spriteBatch, cam, lightColor);
+ }
}
+ spriteBatch.End();
}
- spriteBatch.End();
+
DeformableSprite.Effect.CurrentTechnique = DeformableSprite.Effect.Techniques["DeformShader"];
graphics.BlendState = BlendState.Additive;
@@ -344,7 +394,7 @@ namespace Barotrauma.Lights
foreach (LightSource light in activeLights)
{
if (light.IsBackground || light.CurrentBrightness <= 0.0f) { continue; }
- light.DrawLightVolume(spriteBatch, lightEffect, transform);
+ light.DrawLightVolume(spriteBatch, lightEffect, transform, recalculationCount < MaxLightVolumeRecalculationsPerFrame, ref recalculationCount);
}
lightEffect.World = transform;
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Map/Lights/LightSource.cs b/Barotrauma/BarotraumaClient/ClientSource/Map/Lights/LightSource.cs
index 0eacc74f3..5a4454ccf 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Map/Lights/LightSource.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Map/Lights/LightSource.cs
@@ -205,7 +205,7 @@ namespace Barotrauma.Lights
private VertexPositionColorTexture[] vertices;
private short[] indices;
- private List hullsInRange;
+ private readonly List hullsInRange;
public Texture2D texture;
@@ -246,9 +246,9 @@ namespace Barotrauma.Lights
}
//when were the vertices of the light volume last calculated
- private float lastRecalculationTime;
+ public float LastRecalculationTime { get; private set; }
- private Dictionary diffToSub;
+ private readonly Dictionary diffToSub;
private DynamicVertexBuffer lightVolumeBuffer;
private DynamicIndexBuffer lightVolumeIndexBuffer;
@@ -376,6 +376,8 @@ namespace Barotrauma.Lights
}
}
+ public float Priority;
+
private Vector2 lightTextureTargetSize;
public Vector2 LightTextureTargetSize
@@ -423,7 +425,7 @@ namespace Barotrauma.Lights
public bool Enabled = true;
- private ISerializableEntity conditionalTarget;
+ private readonly ISerializableEntity conditionalTarget;
private readonly PropertyConditional.Comparison comparison;
private readonly List conditionals = new List();
@@ -561,7 +563,7 @@ namespace Barotrauma.Lights
foreach (var ch in chList.List)
{
- if (ch.LastVertexChangeTime > lastRecalculationTime && !chList.IsHidden.Contains(ch))
+ if (ch.LastVertexChangeTime > LastRecalculationTime && !chList.IsHidden.Contains(ch))
{
NeedsRecalculation = true;
break;
@@ -1289,7 +1291,7 @@ namespace Barotrauma.Lights
}
//visualize light recalculations
- float timeSinceRecalculation = (float)Timing.TotalTime - lastRecalculationTime;
+ float timeSinceRecalculation = (float)Timing.TotalTime - LastRecalculationTime;
if (timeSinceRecalculation < 0.1f)
{
GUI.DrawRectangle(spriteBatch, drawPos - Vector2.One * 10, Vector2.One * 20, GUIStyle.Red * (1.0f - timeSinceRecalculation * 10.0f), isFilled: true);
@@ -1313,7 +1315,7 @@ namespace Barotrauma.Lights
}
}
- public void DrawLightVolume(SpriteBatch spriteBatch, BasicEffect lightEffect, Matrix transform)
+ public void DrawLightVolume(SpriteBatch spriteBatch, BasicEffect lightEffect, Matrix transform, bool allowRecalculation, ref int recalculationCount)
{
if (Range < 1.0f || Color.A < 1 || CurrentBrightness <= 0.0f) { return; }
@@ -1338,8 +1340,9 @@ namespace Barotrauma.Lights
CheckHullsInRange();
- if (NeedsRecalculation)
+ if (NeedsRecalculation && allowRecalculation)
{
+ recalculationCount++;
var verts = FindRaycastHits();
if (verts == null)
{
@@ -1352,7 +1355,7 @@ namespace Barotrauma.Lights
CalculateLightVertices(verts);
- lastRecalculationTime = (float)Timing.TotalTime;
+ LastRecalculationTime = (float)Timing.TotalTime;
NeedsRecalculation = false;
}
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Map/Map/Map.cs b/Barotrauma/BarotraumaClient/ClientSource/Map/Map/Map.cs
index 4f0dfbe2c..651f40201 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Map/Map/Map.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Map/Map/Map.cs
@@ -977,7 +977,7 @@ namespace Barotrauma
Vector2 center = rectCenter + (connection.CenterPos + viewOffset) * zoom;
if (viewArea.Contains(center) && connection.Biome != null)
{
- GUI.DrawString(spriteBatch, center, connection.Biome.Identifier + " (" + connection.Difficulty + ")", Color.White);
+ GUI.DrawString(spriteBatch, center, (connection.LevelData?.GenerationParams?.Identifier ?? connection.Biome.Identifier) + " (" + (int)connection.Difficulty + ")", Color.White);
}
}
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Map/SubmarinePreview.cs b/Barotrauma/BarotraumaClient/ClientSource/Map/SubmarinePreview.cs
index 5aa7c9197..ad05d0b20 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Map/SubmarinePreview.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Map/SubmarinePreview.cs
@@ -16,7 +16,7 @@ namespace Barotrauma
class SubmarinePreview : IDisposable
{
private SpriteRecorder spriteRecorder;
- private SubmarineInfo submarineInfo;
+ private readonly SubmarineInfo submarineInfo;
private Camera camera;
private Task loadTask;
private volatile bool isDisposed;
@@ -66,7 +66,7 @@ namespace Barotrauma
public static void Close()
{
- instance?.Dispose();
+ instance?.Dispose(); instance = null;
}
private SubmarinePreview(SubmarineInfo subInfo)
@@ -655,7 +655,8 @@ namespace Barotrauma
previewFrame.RectTransform.Parent = null;
previewFrame = null;
}
- spriteRecorder?.Dispose();
+ spriteRecorder?.Dispose(); spriteRecorder = null;
+ camera?.Dispose(); camera = null;
isDisposed = true;
}
}
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Networking/FileTransfer/FileReceiver.cs b/Barotrauma/BarotraumaClient/ClientSource/Networking/FileTransfer/FileReceiver.cs
index 75401668a..1a0efc16c 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Networking/FileTransfer/FileReceiver.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Networking/FileTransfer/FileReceiver.cs
@@ -146,26 +146,19 @@ namespace Barotrauma.Networking
}
private bool disposed = false;
- protected virtual void Dispose(bool disposing)
- {
- if (disposed) return;
-
- if (disposing)
- {
- if (WriteStream != null)
- {
- WriteStream.Flush();
- WriteStream.Close();
- WriteStream.Dispose();
- WriteStream = null;
- }
- }
- disposed = true;
- }
-
+
public void Dispose()
{
- Dispose(true);
+ if (disposed) { return; }
+
+ if (WriteStream != null)
+ {
+ WriteStream.Flush();
+ WriteStream.Close();
+ WriteStream.Dispose();
+ WriteStream = null;
+ }
+ disposed = true;
}
}
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs
index 32fae9689..2e36c70de 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs
@@ -3571,13 +3571,13 @@ namespace Barotrauma.Networking
return true;
};
- durationInputDays = new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), durationContainer.RectTransform), GUINumberInput.NumberType.Int)
+ durationInputDays = new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), durationContainer.RectTransform), NumberType.Int)
{
MinValueInt = 0,
MaxValueFloat = 1000
};
new GUITextBlock(new RectTransform(new Vector2(0.2f, 1.0f), durationContainer.RectTransform), TextManager.Get("Days"));
- durationInputHours = new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), durationContainer.RectTransform), GUINumberInput.NumberType.Int)
+ durationInputHours = new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), durationContainer.RectTransform), NumberType.Int)
{
MinValueInt = 0,
MaxValueFloat = 24
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Networking/KarmaManager.cs b/Barotrauma/BarotraumaClient/ClientSource/Networking/KarmaManager.cs
index e26337d66..050355919 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Networking/KarmaManager.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Networking/KarmaManager.cs
@@ -126,7 +126,7 @@ namespace Barotrauma
ToolTip = TextManager.Get("Karma." + propertyName + "ToolTip")
};
- var numInput = new GUINumberInput(new RectTransform(new Vector2(0.3f, 1.0f), container.RectTransform), GUINumberInput.NumberType.Int)
+ var numInput = new GUINumberInput(new RectTransform(new Vector2(0.3f, 1.0f), container.RectTransform), NumberType.Int)
{
MinValueInt = min,
MaxValueInt = max
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Networking/Primitives/Peers/SteamP2PClientPeer.cs b/Barotrauma/BarotraumaClient/ClientSource/Networking/Primitives/Peers/SteamP2PClientPeer.cs
index 2b72f5dfa..09cb93edc 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Networking/Primitives/Peers/SteamP2PClientPeer.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Networking/Primitives/Peers/SteamP2PClientPeer.cs
@@ -373,12 +373,6 @@ namespace Barotrauma.Networking
OnDisconnect?.Invoke(disableReconnect);
}
- ~SteamP2PClientPeer()
- {
- OnDisconnect = null;
- Close();
- }
-
protected override void SendMsgInternal(DeliveryMethod deliveryMethod, IWriteMessage msg)
{
Steamworks.P2PSend sendType;
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Networking/Primitives/Peers/SteamP2POwnerPeer.cs b/Barotrauma/BarotraumaClient/ClientSource/Networking/Primitives/Peers/SteamP2POwnerPeer.cs
index 580f16b8a..04c501909 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Networking/Primitives/Peers/SteamP2POwnerPeer.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Networking/Primitives/Peers/SteamP2POwnerPeer.cs
@@ -447,12 +447,6 @@ namespace Barotrauma.Networking
ChildServerRelay.Write(bufToSend);
}
- ~SteamP2POwnerPeer()
- {
- OnDisconnect = null;
- Close();
- }
-
protected override void SendMsgInternal(DeliveryMethod deliveryMethod, IWriteMessage msg)
{
//not currently used by SteamP2POwnerPeer
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Networking/ServerSettings.cs b/Barotrauma/BarotraumaClient/ClientSource/Networking/ServerSettings.cs
index 326c6f9a0..f03d7b099 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Networking/ServerSettings.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Networking/ServerSettings.cs
@@ -32,7 +32,7 @@ namespace Barotrauma.Networking
else if (GUIComponent is GUIDropDown dropdown) return dropdown.SelectedData;
else if (GUIComponent is GUINumberInput numInput)
{
- if (numInput.InputType == GUINumberInput.NumberType.Int) { return numInput.IntValue; } else { return numInput.FloatValue; }
+ if (numInput.InputType == NumberType.Int) { return numInput.IntValue; } else { return numInput.FloatValue; }
}
return null;
}
@@ -56,7 +56,7 @@ namespace Barotrauma.Networking
else if (GUIComponent is GUIDropDown dropdown) dropdown.SelectItem(value);
else if (GUIComponent is GUINumberInput numInput)
{
- if (numInput.InputType == GUINumberInput.NumberType.Int)
+ if (numInput.InputType == NumberType.Int)
{
numInput.IntValue = (int)value;
}
@@ -480,15 +480,12 @@ namespace Barotrauma.Networking
// game settings
//--------------------------------------------------------------------------------
- var roundsTab = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), settingsTabs[(int)SettingsTab.Rounds].RectTransform, Anchor.Center))
- {
- Stretch = true,
- RelativeSpacing = 0.02f
- };
+ var roundsTab = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), settingsTabs[(int)SettingsTab.Rounds].RectTransform, Anchor.Center)) { };
+ GUILayoutGroup playStyleLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.2f), roundsTab.RectTransform));
// Play Style Selection
- new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform), TextManager.Get("ServerSettingsPlayStyle"), font: GUIStyle.SubHeadingFont);
- var playstyleList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.16f), roundsTab.RectTransform))
+ new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), playStyleLayout.RectTransform), TextManager.Get("ServerSettingsPlayStyle"), font: GUIStyle.SubHeadingFont);
+ var playstyleList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.7f), playStyleLayout.RectTransform))
{
AutoHideScrollBar = true,
UseGridLayout = true
@@ -510,11 +507,16 @@ namespace Barotrauma.Networking
GUITextBlock.AutoScaleAndNormalize(playStyleTickBoxes.Select(t => t.TextBlock));
playstyleList.RectTransform.MinSize = new Point(0, (int)(playstyleList.Content.Children.First().Rect.Height * 2.0f + playstyleList.Padding.Y + playstyleList.Padding.W));
- var endVoteBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform),
+ GUILayoutGroup sliderLayout = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.35f), roundsTab.RectTransform))
+ {
+ Stretch = true
+ };
+
+ var endVoteBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), sliderLayout.RectTransform),
TextManager.Get("ServerSettingsEndRoundVoting"));
GetPropertyData(nameof(AllowEndVoting)).AssignGUIComponent(endVoteBox);
- CreateLabeledSlider(roundsTab, "ServerSettingsEndRoundVotesRequired", out slider, out sliderLabel);
+ CreateLabeledSlider(sliderLayout, "ServerSettingsEndRoundVotesRequired", out slider, out sliderLabel);
LocalizedString endRoundLabel = sliderLabel.Text;
slider.Step = 0.2f;
@@ -527,11 +529,11 @@ namespace Barotrauma.Networking
};
slider.OnMoved(slider, slider.BarScroll);
- var respawnBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform),
+ var respawnBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), sliderLayout.RectTransform),
TextManager.Get("ServerSettingsAllowRespawning"));
GetPropertyData(nameof(AllowRespawn)).AssignGUIComponent(respawnBox);
- CreateLabeledSlider(roundsTab, "ServerSettingsRespawnInterval", out slider, out sliderLabel);
+ CreateLabeledSlider(sliderLayout, "ServerSettingsRespawnInterval", out slider, out sliderLabel);
LocalizedString intervalLabel = sliderLabel.Text;
slider.Range = new Vector2(10.0f, 600.0f);
slider.StepValue = 10.0f;
@@ -544,7 +546,7 @@ namespace Barotrauma.Networking
};
slider.OnMoved(slider, slider.BarScroll);
- var respawnLayout = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), roundsTab.RectTransform),
+ var respawnLayout = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), sliderLayout.RectTransform),
isHorizontal: true);
var minRespawnLayout
@@ -611,12 +613,13 @@ namespace Barotrauma.Networking
};
slider.OnMoved(slider, slider.BarScroll);
+ GUILayoutGroup losModeLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.14f), roundsTab.RectTransform));
- var losModeLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform),
+ var losModeLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), losModeLayout.RectTransform),
TextManager.Get("LosEffect"));
var losModeRadioButtonLayout
- = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), roundsTab.RectTransform),
+ = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.6f), losModeLayout.RectTransform),
isHorizontal: true)
{
Stretch = true
@@ -631,24 +634,29 @@ namespace Barotrauma.Networking
}
GetPropertyData(nameof(LosMode)).AssignGUIComponent(losModeRadioButtonGroup);
- var traitorsMinPlayerCount = CreateLabeledNumberInput(roundsTab, "ServerSettingsTraitorsMinPlayerCount", 1, 16, "ServerSettingsTraitorsMinPlayerCountToolTip");
+ GUILayoutGroup numberLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.3f), roundsTab.RectTransform))
+ {
+ Stretch = true
+ };
+
+ var traitorsMinPlayerCount = CreateLabeledNumberInput(numberLayout, "ServerSettingsTraitorsMinPlayerCount", 1, 16, "ServerSettingsTraitorsMinPlayerCountToolTip");
GetPropertyData(nameof(TraitorsMinPlayerCount)).AssignGUIComponent(traitorsMinPlayerCount);
- var maximumTransferAmount = CreateLabeledNumberInput(roundsTab, "serversettingsmaximumtransferrequest", 0, CampaignMode.MaxMoney, "serversettingsmaximumtransferrequesttooltip");
+ var maximumTransferAmount = CreateLabeledNumberInput(numberLayout, "serversettingsmaximumtransferrequest", 0, CampaignMode.MaxMoney, "serversettingsmaximumtransferrequesttooltip");
GetPropertyData(nameof(MaximumMoneyTransferRequest)).AssignGUIComponent(maximumTransferAmount);
- var lootedMoneyDestination = CreateLabeledDropdown(roundsTab, "serversettingslootedmoneydestination", numElements: 2, "serversettingslootedmoneydestinationtooltip");
+ var lootedMoneyDestination = CreateLabeledDropdown(numberLayout, "serversettingslootedmoneydestination", numElements: 2, "serversettingslootedmoneydestinationtooltip");
lootedMoneyDestination.AddItem(TextManager.Get("lootedmoneydestination.bank"), LootedMoneyDestination.Bank);
lootedMoneyDestination.AddItem(TextManager.Get("lootedmoneydestination.wallet"), LootedMoneyDestination.Wallet);
GetPropertyData(nameof(LootedMoneyDestination)).AssignGUIComponent(lootedMoneyDestination);
- var ragdollButtonBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform), TextManager.Get("ServerSettingsAllowRagdollButton"));
+ var ragdollButtonBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), numberLayout.RectTransform), TextManager.Get("ServerSettingsAllowRagdollButton"));
GetPropertyData(nameof(AllowRagdollButton)).AssignGUIComponent(ragdollButtonBox);
- var disableBotConversationsBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform), TextManager.Get("ServerSettingsDisableBotConversations"));
+ var disableBotConversationsBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), numberLayout.RectTransform), TextManager.Get("ServerSettingsDisableBotConversations"));
GetPropertyData(nameof(DisableBotConversations)).AssignGUIComponent(disableBotConversationsBox);
- var buttonHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.07f), roundsTab.RectTransform), isHorizontal: true)
+ GUILayoutGroup buttonHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), roundsTab.RectTransform), isHorizontal: true)
{
Stretch = true,
RelativeSpacing = 0.05f
@@ -755,7 +763,7 @@ namespace Barotrauma.Networking
ExtraCargo.TryGetValue(ip, out int cargoVal);
var amountInput = new GUINumberInput(new RectTransform(new Vector2(0.35f, 1.0f), itemFrame.RectTransform),
- GUINumberInput.NumberType.Int, textAlignment: Alignment.CenterLeft)
+ NumberType.Int, textAlignment: Alignment.CenterLeft)
{
MinValueInt = 0,
MaxValueInt = MaxExtraCargoItemsOfType,
@@ -987,7 +995,7 @@ namespace Barotrauma.Networking
{
label.ToolTip = TextManager.Get(toolTipTag);
}
- var input = new GUINumberInput(new RectTransform(new Vector2(0.3f, 1.0f), container.RectTransform), GUINumberInput.NumberType.Int)
+ var input = new GUINumberInput(new RectTransform(new Vector2(0.3f, 1.0f), container.RectTransform), NumberType.Int)
{
MinValueInt = min,
MaxValueInt = max
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/CharacterEditor/CharacterEditorScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/CharacterEditor/CharacterEditorScreen.cs
index e9de25b54..72363e2fe 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Screens/CharacterEditor/CharacterEditorScreen.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/CharacterEditor/CharacterEditorScreen.cs
@@ -2280,7 +2280,7 @@ namespace Barotrauma.CharacterEditor
var colorLabel = new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), colorComponentLabels[i],
font: GUIStyle.SmallFont, textAlignment: Alignment.CenterLeft);
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight),
- GUINumberInput.NumberType.Int, relativeButtonAreaWidth: 0.25f)
+ NumberType.Int, relativeButtonAreaWidth: 0.25f)
{
Font = GUIStyle.SmallFont
};
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/CharacterEditor/Wizard.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/CharacterEditor/Wizard.cs
index 6027aa90a..3f61ef66d 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Screens/CharacterEditor/Wizard.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/CharacterEditor/Wizard.cs
@@ -523,7 +523,7 @@ namespace Barotrauma.CharacterEditor
{
var element = new GUIFrame(new RectTransform(new Vector2(0.22f, 1), inputArea.RectTransform) { MinSize = new Point(50, 0), MaxSize = new Point(150, 50) }, style: null);
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), GUI.RectComponentLabels[i], font: GUIStyle.SmallFont, textAlignment: Alignment.CenterLeft);
- GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight), GUINumberInput.NumberType.Int)
+ GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight), NumberType.Int)
{
Font = GUIStyle.SmallFont
};
@@ -863,7 +863,7 @@ namespace Barotrauma.CharacterEditor
var limbTypeField = GUI.CreateEnumField(limbType, elementSize, GetCharacterEditorTranslation("LimbType"), group.RectTransform, font: GUIStyle.Font);
var sourceRectField = GUI.CreateRectangleField(sourceRect ?? new Rectangle(0, 100 * LimbGUIElements.Count, 100, 100), elementSize, GetCharacterEditorTranslation("SourceRectangle"), group.RectTransform, font: GUIStyle.Font);
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1), idField.RectTransform, Anchor.TopLeft), GetCharacterEditorTranslation("ID"));
- new GUINumberInput(new RectTransform(new Vector2(0.5f, 1), idField.RectTransform, Anchor.TopRight), GUINumberInput.NumberType.Int)
+ new GUINumberInput(new RectTransform(new Vector2(0.5f, 1), idField.RectTransform, Anchor.TopRight), NumberType.Int)
{
MinValueInt = 0,
MaxValueInt = byte.MaxValue,
@@ -912,7 +912,7 @@ namespace Barotrauma.CharacterEditor
};
var limb1Field = new GUIFrame(new RectTransform(new Point(group.Rect.Width, elementSize), group.RectTransform), style: null);
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1), limb1Field.RectTransform, Anchor.TopLeft), GetCharacterEditorTranslation("LimbWithIndex").Replace("[index]", "1"));
- var limb1InputField = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1), limb1Field.RectTransform, Anchor.TopRight), GUINumberInput.NumberType.Int)
+ var limb1InputField = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1), limb1Field.RectTransform, Anchor.TopRight), NumberType.Int)
{
MinValueInt = 0,
MaxValueInt = byte.MaxValue,
@@ -920,7 +920,7 @@ namespace Barotrauma.CharacterEditor
};
var limb2Field = new GUIFrame(new RectTransform(new Point(group.Rect.Width, elementSize), group.RectTransform), style: null);
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1), limb2Field.RectTransform, Anchor.TopLeft), GetCharacterEditorTranslation("LimbWithIndex").Replace("[index]", "2"));
- var limb2InputField = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1), limb2Field.RectTransform, Anchor.TopRight), GUINumberInput.NumberType.Int)
+ var limb2InputField = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1), limb2Field.RectTransform, Anchor.TopRight), NumberType.Int)
{
MinValueInt = 0,
MaxValueInt = byte.MaxValue,
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/EditorScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/EditorScreen.cs
index 9e690bb7b..38202f624 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Screens/EditorScreen.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/EditorScreen.cs
@@ -38,9 +38,9 @@ namespace Barotrauma
}
// attach number inputs to our generated parent elements
- var rInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[0].RectTransform), GUINumberInput.NumberType.Int) { IntValue = BackgroundColor.R };
- var gInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[1].RectTransform), GUINumberInput.NumberType.Int) { IntValue = BackgroundColor.G };
- var bInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[2].RectTransform), GUINumberInput.NumberType.Int) { IntValue = BackgroundColor.B };
+ var rInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[0].RectTransform), NumberType.Int) { IntValue = BackgroundColor.R };
+ var gInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[1].RectTransform), NumberType.Int) { IntValue = BackgroundColor.G };
+ var bInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[2].RectTransform), NumberType.Int) { IntValue = BackgroundColor.B };
rInput.MinValueInt = gInput.MinValueInt = bInput.MinValueInt = 0;
rInput.MaxValueInt = gInput.MaxValueInt = bInput.MaxValueInt = 255;
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/EventEditor/EventEditorScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/EventEditor/EventEditorScreen.cs
index 2e450a813..46b2e753f 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Screens/EventEditor/EventEditorScreen.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/EventEditor/EventEditorScreen.cs
@@ -818,7 +818,7 @@ namespace Barotrauma
}
else if (type == typeof(float) || type == typeof(int))
{
- GUINumberInput valueInput = new GUINumberInput(new RectTransform(Vector2.One, layout.RectTransform), GUINumberInput.NumberType.Float) { FloatValue = (float) (newValue ?? 0.0f) };
+ GUINumberInput valueInput = new GUINumberInput(new RectTransform(Vector2.One, layout.RectTransform), NumberType.Float) { FloatValue = (float) (newValue ?? 0.0f) };
valueInput.OnValueChanged += component => { newValue = component.FloatValue; };
}
else if (type == typeof(bool))
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/LevelEditorScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/LevelEditorScreen.cs
index 146f41f13..64a24a84d 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Screens/LevelEditorScreen.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/LevelEditorScreen.cs
@@ -40,6 +40,8 @@ namespace Barotrauma
private readonly Color[] tunnelDebugColors = new Color[] { Color.White, Color.Cyan, Color.LightGreen, Color.Red, Color.LightYellow, Color.LightSeaGreen };
+ private LevelData currentLevelData;
+
public LevelEditorScreen()
{
Cam = new Camera()
@@ -59,8 +61,9 @@ namespace Barotrauma
paramsList.OnSelected += (GUIComponent component, object obj) =>
{
selectedParams = obj as LevelGenerationParams;
+ currentLevelData = LevelData.CreateRandom(seedBox.Text, generationParams: selectedParams);
editorContainer.ClearChildren();
- SortLevelObjectsList(selectedParams);
+ SortLevelObjectsList(currentLevelData);
new SerializableEntityEditor(editorContainer.Content.RectTransform, selectedParams, false, true, elementHeight: 20);
return true;
};
@@ -149,7 +152,7 @@ namespace Barotrauma
{
OnClicked = (button, userData) =>
{
- if(seedBox == null) { return false; }
+ if (seedBox == null) { return false; }
seedBox.Text = GetLevelSeed();
return true;
}
@@ -184,10 +187,10 @@ namespace Barotrauma
bool wasLevelLoaded = Level.Loaded != null;
Submarine.Unload();
GameMain.LightManager.ClearLights();
- LevelData levelData = LevelData.CreateRandom(seedBox.Text, generationParams: selectedParams);
- levelData.ForceOutpostGenerationParams = outpostParamsList.SelectedData as OutpostGenerationParams;
- levelData.AllowInvalidOutpost = allowInvalidOutpost.Selected;
- Level.Generate(levelData, mirror: mirrorLevel.Selected);
+ currentLevelData = LevelData.CreateRandom(seedBox.Text, generationParams: selectedParams);
+ currentLevelData.ForceOutpostGenerationParams = outpostParamsList.SelectedData as OutpostGenerationParams;
+ currentLevelData.AllowInvalidOutpost = allowInvalidOutpost.Selected;
+ Level.Generate(currentLevelData, mirror: mirrorLevel.Selected);
GameMain.LightManager.AddLight(pointerLightSource);
if (!wasLevelLoaded || Cam.Position.X < 0 || Cam.Position.Y < 0 || Cam.Position.Y > Level.Loaded.Size.X || Cam.Position.Y > Level.Loaded.Size.Y)
{
@@ -417,11 +420,11 @@ namespace Barotrauma
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), commonnessContainer.RectTransform),
TextManager.GetWithVariable("leveleditor.levelobjcommonness", "[leveltype]", selectedParams.Identifier.Value), textAlignment: Alignment.Center);
- new GUINumberInput(new RectTransform(new Vector2(0.5f, 0.4f), commonnessContainer.RectTransform), GUINumberInput.NumberType.Float)
+ new GUINumberInput(new RectTransform(new Vector2(0.5f, 0.4f), commonnessContainer.RectTransform), NumberType.Float)
{
MinValueFloat = 0,
MaxValueFloat = 100,
- FloatValue = caveGenerationParams.GetCommonness(selectedParams, abyss: false),
+ FloatValue = caveGenerationParams.GetCommonness(currentLevelData, abyss: false),
OnValueChanged = (numberInput) =>
{
caveGenerationParams.OverrideCommonness[selectedParams.Identifier] = numberInput.FloatValue;
@@ -482,7 +485,7 @@ namespace Barotrauma
{
var moduleCountGroup = new GUILayoutGroup(new RectTransform(new Point(editorContainer.Content.Rect.Width, (int)(25 * GUI.Scale))), isHorizontal: true, childAnchor: Anchor.CenterLeft);
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), moduleCountGroup.RectTransform), TextManager.Capitalize(moduleCount.Key.Value), textAlignment: Alignment.CenterLeft);
- new GUINumberInput(new RectTransform(new Vector2(0.5f, 1f), moduleCountGroup.RectTransform), GUINumberInput.NumberType.Int)
+ new GUINumberInput(new RectTransform(new Vector2(0.5f, 1f), moduleCountGroup.RectTransform), NumberType.Int)
{
MinValueInt = 0,
MaxValueInt = 100,
@@ -542,7 +545,7 @@ namespace Barotrauma
if (selectedParams != null) { availableIdentifiers.Add(selectedParams.Identifier); }
foreach (var caveParam in CaveGenerationParams.CaveParams)
{
- if (selectedParams != null && caveParam.GetCommonness(selectedParams, abyss: false) <= 0.0f) { continue; }
+ if (selectedParams != null && caveParam.GetCommonness(currentLevelData, abyss: false) <= 0.0f) { continue; }
availableIdentifiers.Add(caveParam.Identifier);
}
availableIdentifiers.Reverse();
@@ -557,11 +560,11 @@ namespace Barotrauma
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), commonnessContainer.RectTransform),
TextManager.GetWithVariable("leveleditor.levelobjcommonness", "[leveltype]", paramsId.Value), textAlignment: Alignment.Center);
- new GUINumberInput(new RectTransform(new Vector2(0.5f, 0.4f), commonnessContainer.RectTransform), GUINumberInput.NumberType.Float)
+ new GUINumberInput(new RectTransform(new Vector2(0.5f, 0.4f), commonnessContainer.RectTransform), NumberType.Float)
{
MinValueFloat = 0,
MaxValueFloat = 100,
- FloatValue = selectedParams.Identifier == paramsId ? levelObjectPrefab.GetCommonness(selectedParams) : levelObjectPrefab.GetCommonness(CaveGenerationParams.CaveParams.Find(p => p.Identifier == paramsId)),
+ FloatValue = selectedParams.Identifier == paramsId ? levelObjectPrefab.GetCommonness(currentLevelData) : levelObjectPrefab.GetCommonness(CaveGenerationParams.CaveParams.Find(p => p.Identifier == paramsId)),
OnValueChanged = (numberInput) =>
{
levelObjectPrefab.OverrideCommonness[paramsId] = numberInput.FloatValue;
@@ -620,7 +623,7 @@ namespace Barotrauma
childObj.AllowedNames = dropdown.SelectedDataMultiple.Select(d => ((LevelObjectPrefab)d).Name).ToList();
return true;
};
- new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), paddedFrame.RectTransform), GUINumberInput.NumberType.Int)
+ new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), paddedFrame.RectTransform), NumberType.Int)
{
MinValueInt = 0,
MaxValueInt = 10,
@@ -630,7 +633,7 @@ namespace Barotrauma
selectedChildObj.MaxCount = Math.Max(selectedChildObj.MaxCount, selectedChildObj.MinCount);
}
}.IntValue = childObj.MinCount;
- new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), paddedFrame.RectTransform), GUINumberInput.NumberType.Int)
+ new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), paddedFrame.RectTransform), NumberType.Int)
{
MinValueInt = 0,
MaxValueInt = 10,
@@ -689,13 +692,13 @@ namespace Barotrauma
buttonContainer.RectTransform.MinSize = buttonContainer.RectTransform.Children.First().MinSize;
}
- private void SortLevelObjectsList(LevelGenerationParams selectedParams)
+ private void SortLevelObjectsList(LevelData levelData)
{
//fade out levelobjects that don't spawn in this type of level
foreach (GUIComponent levelObjFrame in levelObjectList.Content.Children)
{
var levelObj = levelObjFrame.UserData as LevelObjectPrefab;
- float commonness = levelObj.GetCommonness(selectedParams);
+ float commonness = levelObj.GetCommonness(levelData);
levelObjFrame.Color = commonness > 0.0f ? GUIStyle.Green * 0.4f : Color.Transparent;
levelObjFrame.SelectedColor = commonness > 0.0f ? GUIStyle.Green * 0.6f : Color.White * 0.5f;
levelObjFrame.HoverColor = commonness > 0.0f ? GUIStyle.Green * 0.7f : Color.White * 0.6f;
@@ -712,7 +715,7 @@ namespace Barotrauma
{
var levelObj1 = c1.GUIComponent.UserData as LevelObjectPrefab;
var levelObj2 = c2.GUIComponent.UserData as LevelObjectPrefab;
- return Math.Sign(levelObj2.GetCommonness(selectedParams) - levelObj1.GetCommonness(selectedParams));
+ return Math.Sign(levelObj2.GetCommonness(levelData) - levelObj1.GetCommonness(levelData));
});
}
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/NetLobbyScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/NetLobbyScreen.cs
index ff6f3240e..001618db3 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Screens/NetLobbyScreen.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/NetLobbyScreen.cs
@@ -2902,6 +2902,7 @@ namespace Barotrauma
appearanceFrame.ClearChildren();
var info = GameMain.Client.CharacterInfo ?? Character.Controlled?.Info;
+ CharacterAppearanceCustomizationMenu?.Dispose();
CharacterAppearanceCustomizationMenu = new CharacterInfo.AppearanceCustomizationMenu(info, appearanceFrame)
{
OnHeadSwitch = menu =>
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/SpriteEditorScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/SpriteEditorScreen.cs
index aad8f3493..8a78c4e45 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Screens/SpriteEditorScreen.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/SpriteEditorScreen.cs
@@ -291,7 +291,7 @@ namespace Barotrauma
}, style: null, color: Color.Black * 0.6f);
var colorLabel = new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), colorComponentLabels[i],
font: GUIStyle.SmallFont, textAlignment: Alignment.CenterLeft);
- var numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight), GUINumberInput.NumberType.Int)
+ var numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight), NumberType.Int)
{
Font = GUIStyle.SmallFont
};
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs
index 66ea4de08..b4c90e032 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs
@@ -2256,7 +2256,7 @@ namespace Barotrauma
{
ToolTip = TextManager.Get("OutPostModuleMaxCountToolTip")
};
- new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), maxModuleCountGroup.RectTransform), GUINumberInput.NumberType.Int)
+ new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), maxModuleCountGroup.RectTransform), NumberType.Int)
{
ToolTip = TextManager.Get("OutPostModuleMaxCountToolTip"),
IntValue = MainSub?.Info?.OutpostModuleInfo?.MaxCount ?? 1000,
@@ -2274,7 +2274,7 @@ namespace Barotrauma
};
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), commonnessGroup.RectTransform),
TextManager.Get("subeditor.outpostcommonness"), textAlignment: Alignment.CenterLeft, wrap: true);
- new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), commonnessGroup.RectTransform), GUINumberInput.NumberType.Float)
+ new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), commonnessGroup.RectTransform), NumberType.Float)
{
FloatValue = MainSub?.Info?.OutpostModuleInfo?.Commonness ?? 10,
MinValueFloat = 0,
@@ -2304,8 +2304,9 @@ namespace Barotrauma
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), priceGroup.RectTransform),
TextManager.Get("subeditor.price"), textAlignment: Alignment.CenterLeft, wrap: true);
+
int basePrice = (GameMain.DebugDraw ? 0 : MainSub?.CalculateBasePrice()) ?? 1000;
- new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), priceGroup.RectTransform), GUINumberInput.NumberType.Int, hidePlusMinusButtons: true)
+ new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), priceGroup.RectTransform), NumberType.Int, hidePlusMinusButtons: true)
{
IntValue = Math.Max(MainSub?.Info?.Price ?? basePrice, basePrice),
MinValueInt = basePrice,
@@ -2350,13 +2351,13 @@ namespace Barotrauma
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), crewSizeArea.RectTransform),
TextManager.Get("RecommendedCrewSize"), textAlignment: Alignment.CenterLeft, wrap: true, font: GUIStyle.SmallFont);
- var crewSizeMin = new GUINumberInput(new RectTransform(new Vector2(0.17f, 1.0f), crewSizeArea.RectTransform), GUINumberInput.NumberType.Int, relativeButtonAreaWidth: 0.25f)
+ var crewSizeMin = new GUINumberInput(new RectTransform(new Vector2(0.17f, 1.0f), crewSizeArea.RectTransform), NumberType.Int, relativeButtonAreaWidth: 0.25f)
{
MinValueInt = 1,
MaxValueInt = 128
};
new GUITextBlock(new RectTransform(new Vector2(0.06f, 1.0f), crewSizeArea.RectTransform), "-", textAlignment: Alignment.Center);
- var crewSizeMax = new GUINumberInput(new RectTransform(new Vector2(0.17f, 1.0f), crewSizeArea.RectTransform), GUINumberInput.NumberType.Int, relativeButtonAreaWidth: 0.25f)
+ var crewSizeMax = new GUINumberInput(new RectTransform(new Vector2(0.17f, 1.0f), crewSizeArea.RectTransform), NumberType.Int, relativeButtonAreaWidth: 0.25f)
{
MinValueInt = 1,
MaxValueInt = 128
@@ -2947,11 +2948,22 @@ namespace Barotrauma
prevSub = sub;
}
+ string pathWithoutUserName = Path.GetFullPath(sub.FilePath);
+ string saveFolder = Path.GetFullPath(SaveUtil.SaveFolder);
+ if (pathWithoutUserName.StartsWith(saveFolder))
+ {
+ pathWithoutUserName = "..." + pathWithoutUserName[saveFolder.Length..];
+ }
+ else
+ {
+ pathWithoutUserName = sub.FilePath;
+ }
+
GUITextBlock textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), subList.Content.RectTransform) { MinSize = new Point(0, 30) },
ToolBox.LimitString(sub.Name, GUIStyle.Font, subList.Rect.Width - 80))
{
UserData = sub,
- ToolTip = sub.FilePath
+ ToolTip = pathWithoutUserName
};
if (!(ContentPackageManager.VanillaCorePackage?.Files.Any(f => f.Path == sub.FilePath) ?? false))
@@ -3667,17 +3679,17 @@ namespace Barotrauma
GUILayoutGroup hueSliderLayout = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.25f), sliderLayout.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft);
new GUITextBlock(new RectTransform(new Vector2(0.1f, 0.2f), hueSliderLayout.RectTransform), text: "H:", font: GUIStyle.SubHeadingFont) { Padding = Vector4.Zero, ToolTip = "Hue" };
GUIScrollBar hueScrollBar = new GUIScrollBar(new RectTransform(new Vector2(0.7f, 1f), hueSliderLayout.RectTransform), style: "GUISlider", barSize: 0.05f) { BarScroll = currentHue };
- GUINumberInput hueTextBox = new GUINumberInput(new RectTransform(new Vector2(0.2f, 1f), hueSliderLayout.RectTransform), inputType: GUINumberInput.NumberType.Float) { FloatValue = currentHue, MaxValueFloat = 1f, MinValueFloat = 0f, DecimalsToDisplay = 2 };
+ GUINumberInput hueTextBox = new GUINumberInput(new RectTransform(new Vector2(0.2f, 1f), hueSliderLayout.RectTransform), inputType: NumberType.Float) { FloatValue = currentHue, MaxValueFloat = 1f, MinValueFloat = 0f, DecimalsToDisplay = 2 };
GUILayoutGroup satSliderLayout = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.2f), sliderLayout.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft);
new GUITextBlock(new RectTransform(new Vector2(0.1f, 0.2f), satSliderLayout.RectTransform), text: "S:", font: GUIStyle.SubHeadingFont) { Padding = Vector4.Zero, ToolTip = "Saturation"};
GUIScrollBar satScrollBar = new GUIScrollBar(new RectTransform(new Vector2(0.7f, 1f), satSliderLayout.RectTransform), style: "GUISlider", barSize: 0.05f) { BarScroll = colorPicker.SelectedSaturation };
- GUINumberInput satTextBox = new GUINumberInput(new RectTransform(new Vector2(0.2f, 1f), satSliderLayout.RectTransform), inputType: GUINumberInput.NumberType.Float) { FloatValue = colorPicker.SelectedSaturation, MaxValueFloat = 1f, MinValueFloat = 0f, DecimalsToDisplay = 2 };
+ GUINumberInput satTextBox = new GUINumberInput(new RectTransform(new Vector2(0.2f, 1f), satSliderLayout.RectTransform), inputType: NumberType.Float) { FloatValue = colorPicker.SelectedSaturation, MaxValueFloat = 1f, MinValueFloat = 0f, DecimalsToDisplay = 2 };
GUILayoutGroup valueSliderLayout = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.2f), sliderLayout.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft);
new GUITextBlock(new RectTransform(new Vector2(0.1f, 0.2f), valueSliderLayout.RectTransform), text: "V:", font: GUIStyle.SubHeadingFont) { Padding = Vector4.Zero, ToolTip = "Value"};
GUIScrollBar valueScrollBar = new GUIScrollBar(new RectTransform(new Vector2(0.7f, 1f), valueSliderLayout.RectTransform), style: "GUISlider", barSize: 0.05f) { BarScroll = colorPicker.SelectedValue };
- GUINumberInput valueTextBox = new GUINumberInput(new RectTransform(new Vector2(0.2f, 1f), valueSliderLayout.RectTransform), inputType: GUINumberInput.NumberType.Float) { FloatValue = colorPicker.SelectedValue, MaxValueFloat = 1f, MinValueFloat = 0f, DecimalsToDisplay = 2 };
+ GUINumberInput valueTextBox = new GUINumberInput(new RectTransform(new Vector2(0.2f, 1f), valueSliderLayout.RectTransform), inputType: NumberType.Float) { FloatValue = colorPicker.SelectedValue, MaxValueFloat = 1f, MinValueFloat = 0f, DecimalsToDisplay = 2 };
GUILayoutGroup colorInfoLayout = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.3f), sliderLayout.RectTransform), childAnchor: Anchor.CenterLeft, isHorizontal: true) { RelativeSpacing = 0.15f };
@@ -4439,8 +4451,7 @@ namespace Barotrauma
{
Rectangle hullRect = rect;
hullRect.Y = -hullRect.Y;
- Hull newHull = new Hull(MapEntityPrefab.FindByIdentifier("hull".ToIdentifier()),
- hullRect,
+ Hull newHull = new Hull(hullRect,
MainSub);
}
@@ -4452,7 +4463,7 @@ namespace Barotrauma
Rectangle gapRect = e.WorldRect;
gapRect.Y -= 8;
gapRect.Height = 16;
- Gap newGap = new Gap(MapEntityPrefab.FindByIdentifier("gap".ToIdentifier()), gapRect);
+ new Gap(gapRect);
}
}
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Serialization/SerializableEntityEditor.cs b/Barotrauma/BarotraumaClient/ClientSource/Serialization/SerializableEntityEditor.cs
index af4eba036..fb767cd11 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Serialization/SerializableEntityEditor.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Serialization/SerializableEntityEditor.cs
@@ -59,7 +59,7 @@ namespace Barotrauma
{
if (field is GUINumberInput numInput)
{
- if (numInput.InputType == GUINumberInput.NumberType.Float)
+ if (numInput.InputType == NumberType.Float)
{
numInput.FloatValue = f;
if (flash)
@@ -76,7 +76,7 @@ namespace Barotrauma
{
if (field is GUINumberInput numInput)
{
- if (numInput.InputType == GUINumberInput.NumberType.Int)
+ if (numInput.InputType == NumberType.Int)
{
numInput.IntValue = integer;
if (flash)
@@ -127,7 +127,7 @@ namespace Barotrauma
var field = fields[i];
if (field is GUINumberInput numInput)
{
- if (numInput.InputType == GUINumberInput.NumberType.Float)
+ if (numInput.InputType == NumberType.Float)
{
numInput.FloatValue = i == 0 ? v2.X : v2.Y;
if (flash)
@@ -145,7 +145,7 @@ namespace Barotrauma
var field = fields[i];
if (field is GUINumberInput numInput)
{
- if (numInput.InputType == GUINumberInput.NumberType.Float)
+ if (numInput.InputType == NumberType.Float)
{
switch (i)
{
@@ -174,7 +174,7 @@ namespace Barotrauma
var field = fields[i];
if (field is GUINumberInput numInput)
{
- if (numInput.InputType == GUINumberInput.NumberType.Float)
+ if (numInput.InputType == NumberType.Float)
{
switch (i)
{
@@ -206,7 +206,7 @@ namespace Barotrauma
var field = fields[i];
if (field is GUINumberInput numInput)
{
- if (numInput.InputType == GUINumberInput.NumberType.Int)
+ if (numInput.InputType == NumberType.Int)
{
switch (i)
{
@@ -246,7 +246,7 @@ namespace Barotrauma
var field = fields[i];
if (field is GUINumberInput numInput)
{
- if (numInput.InputType == GUINumberInput.NumberType.Int)
+ if (numInput.InputType == NumberType.Int)
{
switch (i)
{
@@ -517,7 +517,7 @@ namespace Barotrauma
}
else
{
- var numberInput = new GUINumberInput(new RectTransform(new Vector2(inputFieldWidth, 1), frame.RectTransform, Anchor.TopRight), GUINumberInput.NumberType.Int)
+ var numberInput = new GUINumberInput(new RectTransform(new Vector2(inputFieldWidth, 1), frame.RectTransform, Anchor.TopRight), NumberType.Int)
{
ToolTip = toolTip,
Font = GUIStyle.SmallFont
@@ -554,7 +554,7 @@ namespace Barotrauma
};
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(inputFieldWidth, 1), frame.RectTransform,
- Anchor.TopRight), GUINumberInput.NumberType.Float)
+ Anchor.TopRight), NumberType.Float)
{
ToolTip = toolTip,
Font = GUIStyle.SmallFont
@@ -770,7 +770,7 @@ namespace Barotrauma
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), componentLabel, font: GUIStyle.SmallFont, textAlignment: Alignment.Center);
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight),
- GUINumberInput.NumberType.Int)
+ NumberType.Int)
{
Font = GUIStyle.SmallFont
};
@@ -838,7 +838,7 @@ namespace Barotrauma
}
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), componentLabel, font: GUIStyle.SmallFont, textAlignment: Alignment.Center);
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight),
- GUINumberInput.NumberType.Float)
+ NumberType.Float)
{
Font = GUIStyle.SmallFont
};
@@ -909,7 +909,7 @@ namespace Barotrauma
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), componentLabel, font: GUIStyle.SmallFont, textAlignment: Alignment.Center);
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight),
- GUINumberInput.NumberType.Float)
+ NumberType.Float)
{
Font = GUIStyle.SmallFont
};
@@ -985,7 +985,7 @@ namespace Barotrauma
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), componentLabel, font: GUIStyle.SmallFont, textAlignment: Alignment.Center);
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight),
- GUINumberInput.NumberType.Float)
+ NumberType.Float)
{
Font = GUIStyle.SmallFont
};
@@ -1078,7 +1078,7 @@ namespace Barotrauma
};
new GUITextBlock(new RectTransform(new Vector2(0.2f, 1), element.RectTransform, Anchor.CenterLeft) { MinSize = new Point(15, 0) }, GUI.ColorComponentLabels[i], font: GUIStyle.SmallFont, textAlignment: Alignment.Center);
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight),
- GUINumberInput.NumberType.Int)
+ NumberType.Int)
{
Font = GUIStyle.SmallFont
};
@@ -1153,7 +1153,7 @@ namespace Barotrauma
var element = new GUIFrame(new RectTransform(new Vector2(0.22f, 1), inputArea.RectTransform) { MinSize = new Point(50, 0), MaxSize = new Point(150, 50) }, style: null);
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), GUI.RectComponentLabels[i], font: GUIStyle.SmallFont, textAlignment: Alignment.Center);
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight),
- GUINumberInput.NumberType.Int)
+ NumberType.Int)
{
Font = GUIStyle.SmallFont
};
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Settings/SettingsMenu.cs b/Barotrauma/BarotraumaClient/ClientSource/Settings/SettingsMenu.cs
index 9a1a30d8a..d4ef4f065 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Settings/SettingsMenu.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Settings/SettingsMenu.cs
@@ -182,7 +182,7 @@ namespace Barotrauma
private void Slider(GUILayoutGroup parent, Vector2 range, int steps, Func labelFunc, float currentValue, Action setter, LocalizedString? tooltip = null)
{
var layout = new GUILayoutGroup(NewItemRectT(parent), isHorizontal: true);
- var slider = new GUIScrollBar(new RectTransform((0.82f, 1.0f), layout.RectTransform), style: "GUISlider")
+ var slider = new GUIScrollBar(new RectTransform((0.72f, 1.0f), layout.RectTransform), style: "GUISlider")
{
Range = range,
BarScrollValue = currentValue,
@@ -193,7 +193,7 @@ namespace Barotrauma
{
slider.ToolTip = tooltip;
}
- var label = new GUITextBlock(new RectTransform((0.18f, 1.0f), layout.RectTransform),
+ var label = new GUITextBlock(new RectTransform((0.28f, 1.0f), layout.RectTransform),
labelFunc(currentValue), wrap: false, textAlignment: Alignment.Center);
slider.OnMoved = (sb, val) =>
{
@@ -217,9 +217,6 @@ namespace Barotrauma
};
}
- private string ScaleResolution(float scale) =>
- $"{Round(unsavedConfig.Graphics.Width * scale)}\nx\n{Round(unsavedConfig.Graphics.Height * scale)}";
-
private string Percentage(float v) => $"{Round(v * 100)}%";
private int Round(float v) => (int)MathF.Round(v);
@@ -259,22 +256,27 @@ namespace Barotrauma
Tickbox(left, TextManager.Get("EnableVSync"), TextManager.Get("EnableVSyncTooltip"), unsavedConfig.Graphics.VSync, (v) => unsavedConfig.Graphics.VSync = v);
Tickbox(left, TextManager.Get("EnableTextureCompression"), TextManager.Get("EnableTextureCompressionTooltip"), unsavedConfig.Graphics.CompressTextures, (v) => unsavedConfig.Graphics.CompressTextures = v);
- Label(right, TextManager.Get("ParticleLimit"), GUIStyle.SubHeadingFont);
- Slider(right, (100, 1500), 15, (v) => Round(v).ToString(), unsavedConfig.Graphics.ParticleLimit, (v) => unsavedConfig.Graphics.ParticleLimit = Round(v));
- Spacer(right);
-
Label(right, TextManager.Get("LOSEffect"), GUIStyle.SubHeadingFont);
DropdownEnum(right, (m) => TextManager.Get($"LosMode{m}"), null, unsavedConfig.Graphics.LosMode, (v) => unsavedConfig.Graphics.LosMode = v);
Spacer(right);
-
+
Label(right, TextManager.Get("LightMapScale"), GUIStyle.SubHeadingFont);
- Slider(right, (0.5f, 1.0f), 10, ScaleResolution, unsavedConfig.Graphics.LightMapScale, (v) => unsavedConfig.Graphics.LightMapScale = v, TextManager.Get("LightMapScaleTooltip"));
+ Slider(right, (0.5f, 1.0f), 11, (v) => TextManager.GetWithVariable("percentageformat", "[value]", Round(v * 100).ToString()).Value, unsavedConfig.Graphics.LightMapScale, (v) => unsavedConfig.Graphics.LightMapScale = v, TextManager.Get("LightMapScaleTooltip"));
Spacer(right);
-
+
+ Label(right, TextManager.Get("VisibleLightLimit"), GUIStyle.SubHeadingFont);
+ Slider(right, (10, 210), 21, (v) => v > 200 ? TextManager.Get("unlimited").Value : Round(v).ToString(), unsavedConfig.Graphics.VisibleLightLimit,
+ (v) => unsavedConfig.Graphics.VisibleLightLimit = v > 200 ? int.MaxValue : Round(v), TextManager.Get("VisibleLightLimitTooltip"));
+ Spacer(right);
+
Tickbox(right, TextManager.Get("RadialDistortion"), TextManager.Get("RadialDistortionTooltip"), unsavedConfig.Graphics.RadialDistortion, (v) => unsavedConfig.Graphics.RadialDistortion = v);
Tickbox(right, TextManager.Get("ChromaticAberration"), TextManager.Get("ChromaticAberrationTooltip"), unsavedConfig.Graphics.ChromaticAberration, (v) => unsavedConfig.Graphics.ChromaticAberration = v);
+
+ Label(right, TextManager.Get("ParticleLimit"), GUIStyle.SubHeadingFont);
+ Slider(right, (100, 1500), 15, (v) => Round(v).ToString(), unsavedConfig.Graphics.ParticleLimit, (v) => unsavedConfig.Graphics.ParticleLimit = Round(v));
+ Spacer(right);
}
-
+
private static string TrimAudioDeviceName(string name)
{
if (string.IsNullOrWhiteSpace(name)) { return string.Empty; }
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Sounds/SoundPrefab.cs b/Barotrauma/BarotraumaClient/ClientSource/Sounds/SoundPrefab.cs
index 9eab19935..14b0b68e2 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Sounds/SoundPrefab.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Sounds/SoundPrefab.cs
@@ -202,11 +202,6 @@ namespace Barotrauma
{
Sound?.Dispose(); Sound = null;
}
-
- ~SoundPrefab()
- {
- Dispose();
- }
}
[TagNames("damagesound")]
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Steam/Workshop.cs b/Barotrauma/BarotraumaClient/ClientSource/Steam/Workshop.cs
index fd9431cc1..7696fbefe 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Steam/Workshop.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Steam/Workshop.cs
@@ -91,11 +91,6 @@ namespace Barotrauma.Steam
}
}
- ~ItemThumbnail()
- {
- Dispose();
- }
-
public void Dispose()
{
if (ItemId == 0) { return; }
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Steam/WorkshopMenu/Mutable/PublishTab.cs b/Barotrauma/BarotraumaClient/ClientSource/Steam/WorkshopMenu/Mutable/PublishTab.cs
index fdc29524d..136290f81 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Steam/WorkshopMenu/Mutable/PublishTab.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Steam/WorkshopMenu/Mutable/PublishTab.cs
@@ -44,12 +44,7 @@ namespace Barotrauma.Steam
}
});
}
-
- ~LocalThumbnail()
- {
- Dispose();
- }
-
+
private bool disposed = false;
public void Dispose()
{
diff --git a/Barotrauma/BarotraumaClient/ClientSource/Utils/WikiImage.cs b/Barotrauma/BarotraumaClient/ClientSource/Utils/WikiImage.cs
index 3dade74cc..272f9e4c9 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/Utils/WikiImage.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/Utils/WikiImage.cs
@@ -76,7 +76,7 @@ namespace Barotrauma
float zoom = (float)texWidth / (float)boundingBox.Width;
int texHeight = (int)(zoom * boundingBox.Height);
- Camera cam = new Camera();
+ using Camera cam = new Camera();
cam.SetResolution(new Point(texWidth, texHeight));
cam.MaxZoom = zoom;
cam.MinZoom = zoom * 0.5f;
diff --git a/Barotrauma/BarotraumaClient/LinuxClient.csproj b/Barotrauma/BarotraumaClient/LinuxClient.csproj
index 6b590be38..f691db09d 100644
--- a/Barotrauma/BarotraumaClient/LinuxClient.csproj
+++ b/Barotrauma/BarotraumaClient/LinuxClient.csproj
@@ -6,7 +6,7 @@
Barotrauma
FakeFish, Undertow Games
Barotrauma
- 0.18.1.0
+ 0.18.2.0
Copyright © FakeFish 2018-2022
AnyCPU;x64
Barotrauma
@@ -64,11 +64,18 @@
true
-
+
+
+
+
+
+
+
+
diff --git a/Barotrauma/BarotraumaClient/LinuxClient.csproj.bak b/Barotrauma/BarotraumaClient/LinuxClient.csproj.bak
deleted file mode 100644
index a2ee9a9e0..000000000
--- a/Barotrauma/BarotraumaClient/LinuxClient.csproj.bak
+++ /dev/null
@@ -1,208 +0,0 @@
-
-
-
- WinExe
- netcoreapp3.1
- Barotrauma
- FakeFish, Undertow Games
- Barotrauma
- 0.18.0.0
- Copyright © FakeFish 2018-2022
- AnyCPU;x64
- Barotrauma
- ..\BarotraumaShared\Icon.ico
- Debug;Release;Unstable
- ;NU1605;CS0114;CS0108CS8597;CS8600;CS8601;CS8602;CS8603;CS8604;CS8605;CS8606;CS8607;CS8608;CS8609;CS8610;CS8611;CS8612;CS8613;CS8614;CS8615;CS8616;CS8617;CS8618;CS8619;CS8620;CS8621;CS8622;CS8624;CS8625;CS8626;CS8629;CS8631;CS8632;CS8633;CS8634;CS8638;CS8643;CS8644;CS8645;CS8653;CS8654;CS8655;CS8667;CS8669;CS8670;CS8714;CS8717;CS8765
-
-
-
-
-
- DEBUG;TRACE;CLIENT;LINUX;USE_STEAM
- x64
- ..\bin\$(Configuration)Linux\
- net6.0
- 8
-
-
-
- TRACE;DEBUG;CLIENT;LINUX;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Linux\
- net6.0
- 8
-
-
-
- TRACE;CLIENT;LINUX;USE_STEAM
- x64
- ..\bin\$(Configuration)Linux\
-
-
-
- TRACE;CLIENT;LINUX;USE_STEAM;UNSTABLE
- x64
- ..\bin\$(Configuration)Linux\
- true
-
-
-
- TRACE;CLIENT;LINUX;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Linux\
-
-
-
- TRACE;CLIENT;LINUX;X64;USE_STEAM;UNSTABLE
- x64
- ..\bin\$(Configuration)Linux\
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-
- PreserveNewest
-
-
-
- Icon.bmp
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(IntermediateOutputPath)gitver
- $(IntermediateOutputPath)gitbranch
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @(GitVersion)
-
-
-
-
-
-
-
-
- @(GitBranch)
-
-
-
-
-
-
- $(IntermediateOutputPath)CustomAssemblyInfo.cs
-
-
-
-
-
-
-
-
- <_Parameter1>GitRevision
- <_Parameter2>$(BuildHash)
-
-
- <_Parameter1>GitBranch
- <_Parameter2>$(BuildBranch)
-
-
- <_Parameter1>ProjectDir
- <_Parameter2>$(ProjectDir)
-
-
-
-
-
-
-
- linux-x64
-
-
-
-
\ No newline at end of file
diff --git a/Barotrauma/BarotraumaClient/MacClient.csproj b/Barotrauma/BarotraumaClient/MacClient.csproj
index 313a64a2f..7842466de 100644
--- a/Barotrauma/BarotraumaClient/MacClient.csproj
+++ b/Barotrauma/BarotraumaClient/MacClient.csproj
@@ -6,7 +6,7 @@
Barotrauma
FakeFish, Undertow Games
Barotrauma
- 0.18.1.0
+ 0.18.2.0
Copyright © FakeFish 2018-2022
AnyCPU;x64
Barotrauma
@@ -55,19 +55,20 @@
true
-
+
+
+
+
+
+
+
+
-
- SharedSource\Prefabs\PrefabSelector.cs
-
-
- SharedSource\Prefabs\PrefabCollectionSubset.cs
-
diff --git a/Barotrauma/BarotraumaClient/MacClient.csproj.bak b/Barotrauma/BarotraumaClient/MacClient.csproj.bak
deleted file mode 100644
index 9360c73bf..000000000
--- a/Barotrauma/BarotraumaClient/MacClient.csproj.bak
+++ /dev/null
@@ -1,214 +0,0 @@
-
-
-
- WinExe
- netcoreapp3.1
- Barotrauma
- FakeFish, Undertow Games
- Barotrauma
- 0.18.0.0
- Copyright © FakeFish 2018-2022
- AnyCPU;x64
- Barotrauma
- ..\BarotraumaShared\Icon.ico
- Debug;Release;Unstable
- ;NU1605;CS0114;CS0108CS8597;CS8600;CS8601;CS8602;CS8603;CS8604;CS8605;CS8606;CS8607;CS8608;CS8609;CS8610;CS8611;CS8612;CS8613;CS8614;CS8615;CS8616;CS8617;CS8618;CS8619;CS8620;CS8621;CS8622;CS8624;CS8625;CS8626;CS8629;CS8631;CS8632;CS8633;CS8634;CS8638;CS8643;CS8644;CS8645;CS8653;CS8654;CS8655;CS8667;CS8669;CS8670;CS8714;CS8717;CS8765
-
-
-
- TRACE;CLIENT;OSX;USE_STEAM;DEBUG;NETCOREAPP;NETCOREAPP3_0
- x64
- ..\bin\$(Configuration)Mac
-
-
-
- TRACE;DEBUG;CLIENT;OSX;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Mac\
-
-
-
- TRACE;CLIENT;OSX;USE_STEAM;RELEASE;NETCOREAPP;NETCOREAPP3_0
- x64
-
- ..\bin\$(Configuration)Mac
-
-
-
- TRACE;CLIENT;OSX;USE_STEAM;RELEASE;NETCOREAPP;NETCOREAPP3_0;UNSTABLE
- x64
-
- ..\bin\$(Configuration)Mac
- true
-
-
-
- TRACE;CLIENT;OSX;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Mac\
-
-
-
- TRACE;CLIENT;OSX;X64;USE_STEAM;UNSTABLE
- x64
- ..\bin\$(Configuration)Mac\
- true
-
-
-
-
-
-
-
-
-
-
- SharedSource\Prefabs\PrefabSelector.cs
-
-
- SharedSource\Prefabs\PrefabCollectionSubset.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-
- Icon.bmp
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- libsteam_api64.dylib
- PreserveNewest
-
-
-
-
- PreserveNewest
-
-
-
-
-
- $(IntermediateOutputPath)gitver
- $(IntermediateOutputPath)gitbranch
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @(GitVersion)
-
-
-
-
-
-
-
-
- @(GitBranch)
-
-
-
-
-
-
- $(IntermediateOutputPath)CustomAssemblyInfo.cs
-
-
-
-
-
-
-
-
- <_Parameter1>GitRevision
- <_Parameter2>$(BuildHash)
-
-
- <_Parameter1>GitBranch
- <_Parameter2>$(BuildBranch)
-
-
- <_Parameter1>ProjectDir
- <_Parameter2>$(ProjectDir)
-
-
-
-
-
-
-
- osx-x64
-
-
-
-
\ No newline at end of file
diff --git a/Barotrauma/BarotraumaClient/WindowsClient.csproj b/Barotrauma/BarotraumaClient/WindowsClient.csproj
index b17eb41f9..fa39bbdbb 100644
--- a/Barotrauma/BarotraumaClient/WindowsClient.csproj
+++ b/Barotrauma/BarotraumaClient/WindowsClient.csproj
@@ -6,7 +6,7 @@
Barotrauma
FakeFish, Undertow Games
Barotrauma
- 0.18.1.0
+ 0.18.2.0
Copyright © FakeFish 2018-2022
AnyCPU;x64
Barotrauma
@@ -61,19 +61,20 @@
true
-
+
+
+
+
+
+
+
-
- SharedSource\Steam\AuthTicket.cs
-
-
- SharedSource\Utils\Result.cs
-
+
-
+
diff --git a/Barotrauma/BarotraumaClient/WindowsClient.csproj.bak b/Barotrauma/BarotraumaClient/WindowsClient.csproj.bak
deleted file mode 100644
index b9fecd89c..000000000
--- a/Barotrauma/BarotraumaClient/WindowsClient.csproj.bak
+++ /dev/null
@@ -1,237 +0,0 @@
-
-
-
- WinExe
- netcoreapp3.1
- Barotrauma
- FakeFish, Undertow Games
- Barotrauma
- 0.18.0.0
- Copyright © FakeFish 2018-2022
- AnyCPU;x64
- Barotrauma
- ..\BarotraumaShared\Icon.ico
- Debug;Release;Unstable
- app.manifest
- ;NU1605;CS0114;CS0108CS8597;CS8600;CS8601;CS8602;CS8603;CS8604;CS8605;CS8606;CS8607;CS8608;CS8609;CS8610;CS8611;CS8612;CS8613;CS8614;CS8615;CS8616;CS8617;CS8618;CS8619;CS8620;CS8621;CS8622;CS8624;CS8625;CS8626;CS8629;CS8631;CS8632;CS8633;CS8634;CS8638;CS8643;CS8644;CS8645;CS8653;CS8654;CS8655;CS8667;CS8669;CS8670;CS8714;CS8717;CS8765
-
-
-
- DEBUG;TRACE;CLIENT;WINDOWS;USE_STEAM
- x64
- ..\bin\$(Configuration)Windows\
-
-
-
- TRACE;DEBUG;CLIENT;WINDOWS;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Windows\
- full
- true
- Auto
-
-
-
- TRACE;CLIENT;WINDOWS;USE_STEAM
- x64
- ..\bin\$(Configuration)Windows\
-
-
-
- TRACE;CLIENT;WINDOWS;USE_STEAM
- x64
- ..\bin\$(Configuration)Windows\
- true
-
-
-
- TRACE;CLIENT;WINDOWS;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Windows\
- full
- true
-
-
-
- TRACE;CLIENT;WINDOWS;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Windows\
- full
- true
- true
-
-
-
-
-
-
-
-
- SharedSource\Steam\AuthTicket.cs
-
-
- SharedSource\Utils\Result.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-
- PreserveNewest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SharedSource\Utils\Result
-
-
-
-
-
-
-
-
-
-
-
- Never
-
-
- Never
-
-
- Never
-
-
- Never
-
-
- Never
-
-
- Never
-
-
- Never
-
-
- Never
-
-
-
-
-
-
-
- $(IntermediateOutputPath)gitver
- $(IntermediateOutputPath)gitbranch
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @(GitVersion)
-
-
-
-
-
-
-
-
- @(GitBranch)
-
-
-
-
-
-
- $(IntermediateOutputPath)CustomAssemblyInfo.cs
-
-
-
-
-
-
-
-
- <_Parameter1>GitRevision
- <_Parameter2>$(BuildHash)
-
-
- <_Parameter1>GitBranch
- <_Parameter2>$(BuildBranch)
-
-
- <_Parameter1>ProjectDir
- <_Parameter2>$(ProjectDir)
-
-
-
-
-
-
-
- win-x64
-
-
-
-
\ No newline at end of file
diff --git a/Barotrauma/BarotraumaServer/LinuxServer.csproj b/Barotrauma/BarotraumaServer/LinuxServer.csproj
index 2eedc6301..dec7d455e 100644
--- a/Barotrauma/BarotraumaServer/LinuxServer.csproj
+++ b/Barotrauma/BarotraumaServer/LinuxServer.csproj
@@ -6,7 +6,7 @@
Barotrauma
FakeFish, Undertow Games
Barotrauma Dedicated Server
- 0.18.1.0
+ 0.18.2.0
Copyright © FakeFish 2018-2022
AnyCPU;x64
DedicatedServer
@@ -65,10 +65,11 @@
-
+
+
diff --git a/Barotrauma/BarotraumaServer/LinuxServer.csproj.bak b/Barotrauma/BarotraumaServer/LinuxServer.csproj.bak
deleted file mode 100644
index ab1e78f08..000000000
--- a/Barotrauma/BarotraumaServer/LinuxServer.csproj.bak
+++ /dev/null
@@ -1,156 +0,0 @@
-
-
-
- Exe
- netcoreapp3.1
- Barotrauma
- FakeFish, Undertow Games
- Barotrauma Dedicated Server
- 0.18.0.0
- Copyright © FakeFish 2018-2022
- AnyCPU;x64
- DedicatedServer
- ..\BarotraumaShared\Icon.ico
- Debug;Release;Unstable
- ;NU1605;CS0114;CS0108CS8597;CS8600;CS8601;CS8602;CS8603;CS8604;CS8605;CS8606;CS8607;CS8608;CS8609;CS8610;CS8611;CS8612;CS8613;CS8614;CS8615;CS8616;CS8617;CS8618;CS8619;CS8620;CS8621;CS8622;CS8624;CS8625;CS8626;CS8629;CS8631;CS8632;CS8633;CS8634;CS8638;CS8643;CS8644;CS8645;CS8653;CS8654;CS8655;CS8667;CS8669;CS8670;CS8714;CS8717;CS8765
-
-
-
-
-
- DEBUG;TRACE;SERVER;LINUX;USE_STEAM
- x64
- ..\bin\$(Configuration)Linux\
- net6.0
- 8
-
-
-
- TRACE;DEBUG;SERVER;LINUX;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Linux\
- net6.0
- 8
-
-
-
- TRACE;SERVER;LINUX;USE_STEAM
- x64
- ..\bin\$(Configuration)Linux\
-
-
-
- TRACE;SERVER;LINUX;USE_STEAM
- x64
- ..\bin\$(Configuration)Linux\
- true
-
-
-
- TRACE;SERVER;LINUX;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Linux\
-
-
-
- TRACE;SERVER;LINUX;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Linux\
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(IntermediateOutputPath)gitver
- $(IntermediateOutputPath)gitbranch
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @(GitVersion)
-
-
-
-
-
-
-
-
- @(GitBranch)
-
-
-
-
-
-
- $(IntermediateOutputPath)CustomAssemblyInfo.cs
-
-
-
-
-
-
-
-
- <_Parameter1>GitRevision
- <_Parameter2>$(BuildHash)
-
-
- <_Parameter1>GitBranch
- <_Parameter2>$(BuildBranch)
-
-
- <_Parameter1>ProjectDir
- <_Parameter2>$(ProjectDir)
-
-
-
-
-
-
-
diff --git a/Barotrauma/BarotraumaServer/MacServer.csproj b/Barotrauma/BarotraumaServer/MacServer.csproj
index 41800c1ca..6d151701f 100644
--- a/Barotrauma/BarotraumaServer/MacServer.csproj
+++ b/Barotrauma/BarotraumaServer/MacServer.csproj
@@ -6,7 +6,7 @@
Barotrauma
FakeFish, Undertow Games
Barotrauma Dedicated Server
- 0.18.1.0
+ 0.18.2.0
Copyright © FakeFish 2018-2022
AnyCPU;x64
DedicatedServer
@@ -58,10 +58,11 @@
-
+
+
diff --git a/Barotrauma/BarotraumaServer/MacServer.csproj.bak b/Barotrauma/BarotraumaServer/MacServer.csproj.bak
deleted file mode 100644
index 105be0054..000000000
--- a/Barotrauma/BarotraumaServer/MacServer.csproj.bak
+++ /dev/null
@@ -1,157 +0,0 @@
-
-
-
- Exe
- netcoreapp3.1
- Barotrauma
- FakeFish, Undertow Games
- Barotrauma Dedicated Server
- 0.18.0.0
- Copyright © FakeFish 2018-2022
- AnyCPU;x64
- DedicatedServer
- ..\BarotraumaShared\Icon.ico
- Debug;Release;Unstable
- ;NU1605;CS0114;CS0108CS8597;CS8600;CS8601;CS8602;CS8603;CS8604;CS8605;CS8606;CS8607;CS8608;CS8609;CS8610;CS8611;CS8612;CS8613;CS8614;CS8615;CS8616;CS8617;CS8618;CS8619;CS8620;CS8621;CS8622;CS8624;CS8625;CS8626;CS8629;CS8631;CS8632;CS8633;CS8634;CS8638;CS8643;CS8644;CS8645;CS8653;CS8654;CS8655;CS8667;CS8669;CS8670;CS8714;CS8717;CS8765
-
-
-
- TRACE;SERVER;OSX;USE_STEAM;DEBUG;NETCOREAPP;NETCOREAPP3_0
- x64
- ..\bin\DebugMac
- true
-
-
-
-
- TRACE;DEBUG;SERVER;OSX;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Mac\
-
-
-
- TRACE;SERVER;OSX;USE_STEAM;RELEASE;NETCOREAPP;NETCOREAPP3_0
- x64
-
- ..\bin\ReleaseMac
-
-
-
- TRACE;SERVER;OSX;USE_STEAM;RELEASE;NETCOREAPP;NETCOREAPP3_0;UNSTABLE
- x64
-
- ..\bin\ReleaseMac
- true
-
-
-
- TRACE;SERVER;OSX;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Mac\
-
-
-
- TRACE;SERVER;OSX;X64;USE_STEAM;UNSTABLE
- x64
- ..\bin\$(Configuration)Mac\
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- libsteam_api64.dylib
- PreserveNewest
-
-
-
-
-
- $(IntermediateOutputPath)gitver
- $(IntermediateOutputPath)gitbranch
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @(GitVersion)
-
-
-
-
-
-
-
-
- @(GitBranch)
-
-
-
-
-
-
- $(IntermediateOutputPath)CustomAssemblyInfo.cs
-
-
-
-
-
-
-
-
- <_Parameter1>GitRevision
- <_Parameter2>$(BuildHash)
-
-
- <_Parameter1>GitBranch
- <_Parameter2>$(BuildBranch)
-
-
- <_Parameter1>ProjectDir
- <_Parameter2>$(ProjectDir)
-
-
-
-
-
-
-
diff --git a/Barotrauma/BarotraumaServer/ServerSource/Items/Components/Signal/CustomInterface.cs b/Barotrauma/BarotraumaServer/ServerSource/Items/Components/Signal/CustomInterface.cs
index 7c2bc102a..c1742cfa7 100644
--- a/Barotrauma/BarotraumaServer/ServerSource/Items/Components/Signal/CustomInterface.cs
+++ b/Barotrauma/BarotraumaServer/ServerSource/Items/Components/Signal/CustomInterface.cs
@@ -26,26 +26,34 @@ namespace Barotrauma.Items.Components
{
for (int i = 0; i < customInterfaceElementList.Count; i++)
{
- if (customInterfaceElementList[i].HasPropertyName)
+ var element = customInterfaceElementList[i];
+ if (element.HasPropertyName)
{
- if (!customInterfaceElementList[i].IsIntegerInput)
+ if (!element.IsNumberInput)
{
- TextChanged(customInterfaceElementList[i], elementValues[i]);
+ TextChanged(element, elementValues[i]);
}
else
{
- int.TryParse(elementValues[i], out int value);
- ValueChanged(customInterfaceElementList[i], value);
+ switch (element.NumberType)
+ {
+ case NumberType.Int when int.TryParse(elementValues[i], out int value):
+ ValueChanged(element, value);
+ break;
+ case NumberType.Float when TryParseFloatInvariantCulture(elementValues[i], out float value):
+ ValueChanged(element, value);
+ break;
+ }
}
}
- else if (customInterfaceElementList[i].ContinuousSignal)
+ else if (element.ContinuousSignal)
{
- TickBoxToggled(customInterfaceElementList[i], elementStates[i]);
+ TickBoxToggled(element, elementStates[i]);
}
else if (elementStates[i])
{
- clickedButton = customInterfaceElementList[i];
- ButtonClicked(customInterfaceElementList[i]);
+ clickedButton = element;
+ ButtonClicked(element);
}
}
}
@@ -61,13 +69,14 @@ namespace Barotrauma.Items.Components
//extradata contains an array of buttons clicked by a client (or nothing if nothing was clicked)
for (int i = 0; i < customInterfaceElementList.Count; i++)
{
- if (customInterfaceElementList[i].HasPropertyName)
+ var element = customInterfaceElementList[i];
+ if (element.HasPropertyName)
{
- msg.Write(customInterfaceElementList[i].Signal);
+ msg.Write(element.Signal);
}
- else if(customInterfaceElementList[i].ContinuousSignal)
+ else if(element.ContinuousSignal)
{
- msg.Write(customInterfaceElementList[i].State);
+ msg.Write(element.State);
}
else
{
diff --git a/Barotrauma/BarotraumaServer/ServerSource/Networking/Voting.cs b/Barotrauma/BarotraumaServer/ServerSource/Networking/Voting.cs
index 12fa0d853..13b9156e4 100644
--- a/Barotrauma/BarotraumaServer/ServerSource/Networking/Voting.cs
+++ b/Barotrauma/BarotraumaServer/ServerSource/Networking/Voting.cs
@@ -208,7 +208,8 @@ namespace Barotrauma
// Do not take unanswered into account for total
int yes = GameMain.Server.ConnectedClients.Count(c => c.InGame && c.GetVote(ActiveVote.VoteType) == 2);
int no = GameMain.Server.ConnectedClients.Count(c => c.InGame && c.GetVote(ActiveVote.VoteType) == 1);
- ActiveVote.Finish(this, passed: yes / (float)(yes + no) >= GameMain.NetworkMember.ServerSettings.VoteRequiredRatio);
+ int total = Math.Max(yes + no, 1);
+ ActiveVote.Finish(this, passed: yes / (float)(total) >= GameMain.NetworkMember.ServerSettings.VoteRequiredRatio);
}
}
diff --git a/Barotrauma/BarotraumaServer/WindowsServer.csproj b/Barotrauma/BarotraumaServer/WindowsServer.csproj
index d83075d47..a1886f6b2 100644
--- a/Barotrauma/BarotraumaServer/WindowsServer.csproj
+++ b/Barotrauma/BarotraumaServer/WindowsServer.csproj
@@ -6,7 +6,7 @@
Barotrauma
FakeFish, Undertow Games
Barotrauma Dedicated Server
- 0.18.1.0
+ 0.18.2.0
Copyright © FakeFish 2018-2022
AnyCPU;x64
DedicatedServer
@@ -60,10 +60,11 @@
-
+
+
diff --git a/Barotrauma/BarotraumaServer/WindowsServer.csproj.bak b/Barotrauma/BarotraumaServer/WindowsServer.csproj.bak
deleted file mode 100644
index 0fbb606a7..000000000
--- a/Barotrauma/BarotraumaServer/WindowsServer.csproj.bak
+++ /dev/null
@@ -1,152 +0,0 @@
-
-
-
- Exe
- netcoreapp3.1
- Barotrauma
- FakeFish, Undertow Games
- Barotrauma Dedicated Server
- 0.18.0.0
- Copyright © FakeFish 2018-2022
- AnyCPU;x64
- DedicatedServer
- ..\BarotraumaShared\Icon.ico
- Debug;Release;Unstable
- ;NU1605;CS0114;CS0108CS8597;CS8600;CS8601;CS8602;CS8603;CS8604;CS8605;CS8606;CS8607;CS8608;CS8609;CS8610;CS8611;CS8612;CS8613;CS8614;CS8615;CS8616;CS8617;CS8618;CS8619;CS8620;CS8621;CS8622;CS8624;CS8625;CS8626;CS8629;CS8631;CS8632;CS8633;CS8634;CS8638;CS8643;CS8644;CS8645;CS8653;CS8654;CS8655;CS8667;CS8669;CS8670;CS8714;CS8717;CS8765
-
-
-
- DEBUG;TRACE;SERVER;WINDOWS;USE_STEAM
- x64
- ..\bin\$(Configuration)Windows\
-
-
-
- TRACE;DEBUG;SERVER;WINDOWS;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Windows\
- full
- true
-
-
-
- TRACE;SERVER;WINDOWS;USE_STEAM
- x64
- ..\bin\$(Configuration)Windows\
-
-
-
- TRACE;SERVER;WINDOWS;USE_STEAM
- x64
- ..\bin\$(Configuration)Windows\
- true
-
-
-
- TRACE;SERVER;WINDOWS;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Windows\
- full
- true
-
-
-
- TRACE;SERVER;WINDOWS;X64;USE_STEAM
- x64
- ..\bin\$(Configuration)Windows\
- full
- true
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(IntermediateOutputPath)gitver
- $(IntermediateOutputPath)gitbranch
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @(GitVersion)
-
-
-
-
-
-
-
-
- @(GitBranch)
-
-
-
-
-
-
- $(IntermediateOutputPath)CustomAssemblyInfo.cs
-
-
-
-
-
-
-
-
- <_Parameter1>GitRevision
- <_Parameter2>$(BuildHash)
-
-
- <_Parameter1>GitBranch
- <_Parameter2>$(BuildBranch)
-
-
- <_Parameter1>ProjectDir
- <_Parameter2>$(ProjectDir)
-
-
-
-
-
-
-
diff --git a/Barotrauma/BarotraumaShared/Data/Saves/TheColdsBelow.save b/Barotrauma/BarotraumaShared/Data/Saves/TheColdsBelow.save
new file mode 100644
index 000000000..f6a00dd10
Binary files /dev/null and b/Barotrauma/BarotraumaShared/Data/Saves/TheColdsBelow.save differ
diff --git a/Barotrauma/BarotraumaShared/Data/Saves/Zapisz_1.save b/Barotrauma/BarotraumaShared/Data/Saves/Zapisz_1.save
new file mode 100644
index 000000000..f892d0374
Binary files /dev/null and b/Barotrauma/BarotraumaShared/Data/Saves/Zapisz_1.save differ
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/EnemyAIController.cs
index 8bc57ffa0..779a6fb30 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/EnemyAIController.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/EnemyAIController.cs
@@ -275,7 +275,11 @@ namespace Barotrauma
switch (subElement.Name.ToString().ToLowerInvariant())
{
case "chooserandom":
- LoadSubElement(subElement.Elements().ToArray().GetRandom(random));
+ var subElements = subElement.Elements();
+ if (subElements.Any())
+ {
+ LoadSubElement(subElements.ToArray().GetRandom(random));
+ }
break;
default:
LoadSubElement(subElement);
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Wreck/WreckAIConfig.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Wreck/WreckAIConfig.cs
index 92634f40a..9bb81acc8 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Wreck/WreckAIConfig.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Wreck/WreckAIConfig.cs
@@ -85,7 +85,7 @@ namespace Barotrauma
public readonly Identifier[] ForbiddenAmmunition;
- public static WreckAIConfig GetRandom() => Prefabs.GetRandom(Rand.RandSync.ServerAndClient);
+ public static WreckAIConfig GetRandom() => Prefabs.OrderBy(p => p.UintIdentifier).GetRandom(Rand.RandSync.ServerAndClient);
protected override Identifier DetermineIdentifier(XElement element)
{
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/CharacterInfo.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/CharacterInfo.cs
index 7700016df..22f35f724 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Characters/CharacterInfo.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/CharacterInfo.cs
@@ -94,11 +94,67 @@ namespace Barotrauma
public Vector2 SheetIndex => Preset.SheetIndex;
- public ContentXElement HairElement => CharacterInfo.Hairs?.ElementAtOrDefault(HairIndex);
- public ContentXElement HairWithHatElement => CharacterInfo.Hairs?.ElementAtOrDefault(HairWithHatIndex);
- public ContentXElement BeardElement => CharacterInfo.Beards?.ElementAtOrDefault(BeardIndex);
- public ContentXElement MoustacheElement => CharacterInfo.Moustaches?.ElementAtOrDefault(MoustacheIndex);
- public ContentXElement FaceAttachment => CharacterInfo.FaceAttachments?.ElementAtOrDefault(FaceAttachmentIndex);
+ public ContentXElement HairElement
+ {
+ get
+ {
+ if (CharacterInfo.Hairs == null) { return null; }
+ if (hairIndex >= CharacterInfo.Hairs.Count)
+ {
+ DebugConsole.AddWarning($"Hair index out of range (character: {CharacterInfo?.Name ?? "null"}, index: {hairIndex})");
+ }
+ return CharacterInfo.Hairs.ElementAtOrDefault(hairIndex);
+ }
+ }
+ public ContentXElement HairWithHatElement
+ {
+ get
+ {
+ if (CharacterInfo.Hairs == null) { return null; }
+ if (HairWithHatIndex >= CharacterInfo.Hairs.Count)
+ {
+ DebugConsole.AddWarning($"Hair with hat index out of range (character: {CharacterInfo?.Name ?? "null"}, index: {HairWithHatIndex})");
+ }
+ return CharacterInfo.Hairs.ElementAtOrDefault(HairWithHatIndex);
+ }
+ }
+
+ public ContentXElement BeardElement
+ {
+ get
+ {
+ if (CharacterInfo.Beards == null) { return null; }
+ if (BeardIndex >= CharacterInfo.Beards.Count)
+ {
+ DebugConsole.AddWarning($"Beard index out of range (character: {CharacterInfo?.Name ?? "null"}, index: {BeardIndex})");
+ }
+ return CharacterInfo.Beards.ElementAtOrDefault(BeardIndex);
+ }
+ }
+ public ContentXElement MoustacheElement
+ {
+ get
+ {
+ if (CharacterInfo.Moustaches == null) { return null; }
+ if (MoustacheIndex >= CharacterInfo.Moustaches.Count)
+ {
+ DebugConsole.AddWarning($"Moustache index out of range (character: {CharacterInfo?.Name ?? "null"}, index: {MoustacheIndex})");
+ }
+ return CharacterInfo.Moustaches.ElementAtOrDefault(MoustacheIndex);
+ }
+ }
+ public ContentXElement FaceAttachment
+ {
+ get
+ {
+ if (CharacterInfo.FaceAttachments == null) { return null; }
+ if (FaceAttachmentIndex >= CharacterInfo.FaceAttachments.Count)
+ {
+ DebugConsole.AddWarning($"Face attachment index out of range (character: {CharacterInfo?.Name ?? "null"}, index: {FaceAttachmentIndex})");
+ }
+ return CharacterInfo.FaceAttachments.ElementAtOrDefault(FaceAttachmentIndex);
+ }
+ }
public HeadInfo(CharacterInfo characterInfo, HeadPreset headPreset, int hairIndex = 0, int beardIndex = 0, int moustacheIndex = 0, int faceAttachmentIndex = 0)
{
@@ -130,6 +186,10 @@ namespace Barotrauma
head = value;
HeadSprite = null;
AttachmentSprites = null;
+ hairs = null;
+ beards = null;
+ moustaches = null;
+ faceAttachments = null;
}
}
}
@@ -843,7 +903,14 @@ namespace Barotrauma
public void RecreateHead(ImmutableHashSet tags, int hairIndex, int beardIndex, int moustacheIndex, int faceAttachmentIndex)
{
HeadPreset headPreset = Prefab.Heads.FirstOrDefault(h => h.TagSet.SetEquals(tags));
- if (headPreset == null) { headPreset = Prefab.Heads.GetRandomUnsynced(); }
+ if (headPreset == null)
+ {
+ if (tags.Count == 1)
+ {
+ headPreset = Prefab.Heads.FirstOrDefault(h => h.TagSet.Contains(tags.First()));
+ }
+ headPreset ??= Prefab.Heads.GetRandomUnsynced();
+ }
head = new HeadInfo(this, headPreset, hairIndex, beardIndex, moustacheIndex, faceAttachmentIndex);
ReloadHeadAttachments();
}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/Limb.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/Limb.cs
index 98761b381..e958f391f 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Characters/Limb.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/Limb.cs
@@ -352,7 +352,7 @@ namespace Barotrauma
public Vector2 Position
{
- get { return ConvertUnits.ToDisplayUnits(body.SimPosition); }
+ get { return ConvertUnits.ToDisplayUnits(body?.SimPosition ?? Vector2.Zero); }
}
public Vector2 SimPosition
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/Params/CharacterParams.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/Params/CharacterParams.cs
index 967927105..5b45d8882 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Characters/Params/CharacterParams.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/Params/CharacterParams.cs
@@ -574,7 +574,7 @@ namespace Barotrauma
public float AggressionGreed { get; private set; }
[Serialize(0f, IsPropertySaveable.Yes, description: "If the health drops below this threshold, the character flees. In percentages."), Editable(minValue: 0f, maxValue: 100f)]
- public float FleeHealthThreshold { get; private set; }
+ public float FleeHealthThreshold { get; set; }
[Serialize(false, IsPropertySaveable.Yes, description: "Does the character attack when provoked? When enabled, overrides the predefined targeting state with Attack and increases the priority of it."), Editable()]
public bool AttackWhenProvoked { get; private set; }
diff --git a/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs b/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs
index 3369bb456..01084658f 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs
@@ -1122,7 +1122,7 @@ namespace Barotrauma
{
var gamesession = new GameSession(
SubmarineInfo.SavedSubmarines.GetRandomUnsynced(s => s.Type == SubmarineType.Player && !s.HasTag(SubmarineTag.HideInMenus)),
- GameModePreset.DevSandbox);
+ GameModePreset.DevSandbox ?? GameModePreset.Sandbox);
string seed = ToolBox.RandomSeed(16);
gamesession.StartRound(seed);
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Enums.cs b/Barotrauma/BarotraumaShared/SharedSource/Enums.cs
index 94123f36e..7e634941e 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Enums.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Enums.cs
@@ -33,13 +33,13 @@ namespace Barotrauma
public enum AbilityEffectType
{
Undefined,
- None,
+ None,
OnAttack,
OnAttackResult,
OnAttacked,
OnAttackedResult,
- OnGainSkillPoint,
- OnAllyGainSkillPoint,
+ OnGainSkillPoint,
+ OnAllyGainSkillPoint,
OnRepairComplete,
OnItemFabricationSkillGain,
OnItemFabricatedAmount,
@@ -155,4 +155,10 @@ namespace Barotrauma
Player = 0b10,
Both = Bot | Player
}
-}
+
+ public enum NumberType
+ {
+ Int,
+ Float
+ }
+}
\ No newline at end of file
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/ConversationAction.cs b/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/ConversationAction.cs
index c3b9fad93..27748f54d 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/ConversationAction.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/ConversationAction.cs
@@ -313,10 +313,14 @@ namespace Barotrauma
bool isValid = e is Character character && !character.Removed && !character.IsDead && !character.IsIncapacitated &&
(e == Character.Controlled || character.IsRemotePlayer);
#if SERVER
- UpdateIgnoredClients();
- isValid &= !ignoredClients.Keys.Any(c => c.Character == e);
+ if (!dialogOpened)
+ {
+ UpdateIgnoredClients();
+ isValid &= !ignoredClients.Keys.Any(c => c.Character == e);
+ }
#elif CLIENT
- isValid &= (e != Character.Controlled || !GUI.InputBlockingMenuOpen);
+ bool block = GUI.InputBlockingMenuOpen && !dialogOpened;
+ isValid &= (e != Character.Controlled || !block);
#endif
return isValid;
}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Events/Missions/MonsterMission.cs b/Barotrauma/BarotraumaShared/SharedSource/Events/Missions/MonsterMission.cs
index c51ad855c..f861c2d10 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Events/Missions/MonsterMission.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Events/Missions/MonsterMission.cs
@@ -135,8 +135,10 @@ namespace Barotrauma
monster.Enabled = false;
if (monster.Params.AI != null && monster.Params.AI.EnforceAggressiveBehaviorForMissions)
{
+ monster.Params.AI.FleeHealthThreshold = 0;
foreach (var targetParam in monster.Params.AI.Targets)
{
+ if (targetParam.Tag.Equals("engine", StringComparison.OrdinalIgnoreCase)) { continue; }
switch (targetParam.State)
{
case AIState.Avoid:
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Events/ScriptedEvent.cs b/Barotrauma/BarotraumaShared/SharedSource/Events/ScriptedEvent.cs
index 49631f810..8054a79ac 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Events/ScriptedEvent.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Events/ScriptedEvent.cs
@@ -12,6 +12,7 @@ namespace Barotrauma
private readonly Dictionary> cachedTargets = new Dictionary>();
private int prevEntityCount;
private int prevPlayerCount, prevBotCount;
+ private Character prevControlled;
private readonly string[] requiredDestinationTypes;
public readonly bool RequireBeaconStation;
@@ -163,12 +164,13 @@ namespace Barotrauma
botCount++;
}
}
- if (Entity.EntityCount != prevEntityCount || botCount != prevBotCount || playerCount != prevPlayerCount)
+ if (Entity.EntityCount != prevEntityCount || botCount != prevBotCount || playerCount != prevPlayerCount || prevControlled != Character.Controlled)
{
cachedTargets.Clear();
prevEntityCount = Entity.EntityCount;
prevBotCount = botCount;
prevPlayerCount = playerCount;
+ prevControlled = Character.Controlled;
}
if (!Actions.Any())
diff --git a/Barotrauma/BarotraumaShared/SharedSource/GameAnalytics/GameAnalyticsManager.cs b/Barotrauma/BarotraumaShared/SharedSource/GameAnalytics/GameAnalyticsManager.cs
index d79130b93..ac9e379a4 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/GameAnalytics/GameAnalyticsManager.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/GameAnalytics/GameAnalyticsManager.cs
@@ -339,11 +339,6 @@ namespace Barotrauma
loadContext = null;
assembly = null;
}
-
- ~Implementation()
- {
- OnQuit();
- }
}
private static Implementation? loadedImplementation;
diff --git a/Barotrauma/BarotraumaShared/SharedSource/GameSession/AutoItemPlacer.cs b/Barotrauma/BarotraumaShared/SharedSource/GameSession/AutoItemPlacer.cs
index a421a0be1..5d15cbed9 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/GameSession/AutoItemPlacer.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/GameSession/AutoItemPlacer.cs
@@ -1,9 +1,8 @@
-using Barotrauma.Items.Components;
+using Barotrauma.Extensions;
+using Barotrauma.Items.Components;
using System;
using System.Collections.Generic;
using System.Linq;
-using Barotrauma.Extensions;
-using Microsoft.Xna.Framework;
namespace Barotrauma
{
@@ -15,29 +14,29 @@ namespace Barotrauma
{
if (GameMain.NetworkMember != null && !GameMain.NetworkMember.IsServer) { return; }
- bool skipMainSubs = GameMain.GameSession.GameMode is CampaignMode { IsFirstRound: false };
- if (!skipMainSubs)
+ //player has more than one sub = we must have given the start items already
+ bool startItemsGiven = GameMain.GameSession?.OwnedSubmarines != null && GameMain.GameSession.OwnedSubmarines.Count > 1;
+ if (!startItemsGiven)
{
- if (Submarine.MainSub is Submarine mainSub && mainSub.Info.IsPlayer)
- {
- SpawnStartItems(mainSub);
- }
for (int i = 0; i < Submarine.MainSubs.Length; i++)
{
var sub = Submarine.MainSubs[i];
- if (sub == null || sub.Info.InitialSuppliesSpawned) { continue; }
+ if (sub == null || sub.Info.InitialSuppliesSpawned || !sub.Info.IsPlayer) { continue; }
+ //1st pass: items defined in the start item set, only spawned in the main sub (not drones/shuttles or other linked subs)
+ SpawnStartItems(sub);
+ //2nd pass: items defined using preferred containers, spawned in the main sub and all the linked subs (drones, shuttles etc)
var subs = sub.GetConnectedSubs().Where(s => s.TeamID == sub.TeamID);
CreateAndPlace(subs);
subs.ForEach(s => s.Info.InitialSuppliesSpawned = true);
}
}
+ //spawn items in wrecks, beacon stations and pirate subs
foreach (var sub in Submarine.Loaded)
{
if (sub.Info.Type == SubmarineType.Player ||
sub.Info.Type == SubmarineType.Outpost ||
- sub.Info.Type == SubmarineType.OutpostModule ||
- sub.Info.Type == SubmarineType.EnemySubmarine)
+ sub.Info.Type == SubmarineType.OutpostModule)
{
continue;
}
@@ -64,6 +63,10 @@ namespace Barotrauma
}
public static Identifier StartItemSet = new Identifier("normal");
+
+ ///
+ /// Spawns the items defined in the start item set in the specified sub.
+ ///
private static void SpawnStartItems(Submarine sub)
{
if (!Barotrauma.StartItemSet.Sets.TryGet(StartItemSet, out StartItemSet itemSet))
diff --git a/Barotrauma/BarotraumaShared/SharedSource/GameSession/GameSession.cs b/Barotrauma/BarotraumaShared/SharedSource/GameSession/GameSession.cs
index 9abdd2721..42a9dc8d0 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/GameSession/GameSession.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/GameSession/GameSession.cs
@@ -1081,15 +1081,10 @@ namespace Barotrauma
{
bool hasNewPendingSub = Campaign.PendingSubmarineSwitch != null &&
Campaign.PendingSubmarineSwitch.MD5Hash.StringRepresentation != Submarine.Info.MD5Hash.StringRepresentation;
-
if (hasNewPendingSub)
{
Campaign.SwitchSubs();
}
- else
- {
- SubmarineInfo = new SubmarineInfo(Submarine);
- }
}
rootElement.Add(new XAttribute("submarine", SubmarineInfo == null ? "" : SubmarineInfo.Name));
if (OwnedSubmarines != null)
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/DockingPort.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/DockingPort.cs
index d1371c9fb..405b6a22a 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/DockingPort.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/DockingPort.cs
@@ -621,7 +621,7 @@ namespace Barotrauma.Items.Components
hullRects[i].X -= expand;
hullRects[i].Width += expand * 2;
hullRects[i].Location -= MathUtils.ToPoint(subs[i].WorldPosition - subs[i].HiddenSubPosition);
- hulls[i] = new Hull(MapEntityPrefab.Find(null, "hull"), hullRects[i], subs[i]);
+ hulls[i] = new Hull(hullRects[i], subs[i]);
hulls[i].RoomName = IsHorizontal ? "entityname.dockingport" : "entityname.dockinghatch";
hulls[i].AddToGrid(subs[i]);
hulls[i].FreeID();
@@ -744,7 +744,7 @@ namespace Barotrauma.Items.Components
hullRects[i].Y += expand;
hullRects[i].Height += expand * 2;
hullRects[i].Location -= MathUtils.ToPoint(subs[i].WorldPosition - subs[i].HiddenSubPosition);
- hulls[i] = new Hull(MapEntityPrefab.Find(null, "hull"), hullRects[i], subs[i]);
+ hulls[i] = new Hull(hullRects[i], subs[i]);
hulls[i].RoomName = IsHorizontal ? "entityname.dockingport" : "entityname.dockinghatch";
hulls[i].AddToGrid(subs[i]);
hulls[i].FreeID();
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Holdable/LevelResource.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Holdable/LevelResource.cs
index 0467429ea..4ad251c17 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Holdable/LevelResource.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Holdable/LevelResource.cs
@@ -3,7 +3,6 @@ using FarseerPhysics;
using Microsoft.Xna.Framework;
using System;
using System.Linq;
-using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Holdable/RangedWeapon.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Holdable/RangedWeapon.cs
index 339d218aa..998d7d7c1 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Holdable/RangedWeapon.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Holdable/RangedWeapon.cs
@@ -79,7 +79,7 @@ namespace Barotrauma.Items.Components
{
get
{
- Matrix bodyTransform = Matrix.CreateRotationZ(item.body == null ? MathHelper.ToRadians(item.Rotation) : item.body.Rotation);
+ Matrix bodyTransform = Matrix.CreateRotationZ(item.body == null ? item.RotationRad : item.body.Rotation);
Vector2 flippedPos = barrelPos;
if (item.body != null && item.body.Dir < 0.0f) { flippedPos.X = -flippedPos.X; }
return Vector2.Transform(flippedPos, bodyTransform) * item.Scale;
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/ItemContainer.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/ItemContainer.cs
index 3d5f79b0f..903905ec6 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/ItemContainer.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/ItemContainer.cs
@@ -17,11 +17,13 @@ namespace Barotrauma.Items.Components
public readonly Item Item;
public readonly StatusEffect StatusEffect;
public readonly bool ExcludeBroken;
- public ActiveContainedItem(Item item, StatusEffect statusEffect, bool excludeBroken)
+ public readonly bool ExcludeFullCondition;
+ public ActiveContainedItem(Item item, StatusEffect statusEffect, bool excludeBroken, bool excludeFullCondition)
{
Item = item;
StatusEffect = statusEffect;
ExcludeBroken = excludeBroken;
+ ExcludeFullCondition = excludeFullCondition;
}
}
@@ -300,7 +302,7 @@ namespace Barotrauma.Items.Components
if (!containableItem.MatchesItem(containedItem)) { continue; }
foreach (StatusEffect effect in containableItem.statusEffects)
{
- activeContainedItems.Add(new ActiveContainedItem(containedItem, effect, containableItem.ExcludeBroken));
+ activeContainedItems.Add(new ActiveContainedItem(containedItem, effect, containableItem.ExcludeBroken, containableItem.ExcludeFullCondition));
}
}
}
@@ -408,6 +410,7 @@ namespace Barotrauma.Items.Components
Item contained = activeContainedItem.Item;
if (activeContainedItem.ExcludeBroken && contained.Condition <= 0.0f) { continue; }
+ if (activeContainedItem.ExcludeFullCondition && contained.IsFullCondition) { continue; }
StatusEffect effect = activeContainedItem.StatusEffect;
if (effect.HasTargetType(StatusEffect.TargetType.This))
@@ -569,7 +572,7 @@ namespace Barotrauma.Items.Components
transformedItemPos += new Vector2(item.Rect.X, item.Rect.Y);
if (Math.Abs(item.Rotation) > 0.01f)
{
- Matrix transform = Matrix.CreateRotationZ(MathHelper.ToRadians(-item.Rotation));
+ Matrix transform = Matrix.CreateRotationZ(-item.RotationRad);
transformedItemPos = Vector2.Transform(transformedItemPos - item.Position, transform) + item.Position;
transformedItemInterval = Vector2.Transform(transformedItemInterval, transform);
transformedItemIntervalHorizontal = Vector2.Transform(transformedItemIntervalHorizontal, transform);
@@ -600,7 +603,7 @@ namespace Barotrauma.Items.Components
}
else
{
- currentRotation += MathHelper.ToRadians(-item.Rotation);
+ currentRotation += -item.RotationRad;
}
int i = 0;
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/MiniMap.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/MiniMap.cs
index 889969115..a3588ac5c 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/MiniMap.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/MiniMap.cs
@@ -161,7 +161,7 @@ namespace Barotrauma.Items.Components
hullData.ReceivedWaterAmount = null;
if (fromWaterDetector)
{
- hullData.ReceivedWaterAmount = Math.Min(sourceHull.WaterVolume / sourceHull.Volume, 1.0f);
+ hullData.ReceivedWaterAmount = WaterDetector.GetWaterPercentage(sourceHull);
}
foreach (var linked in sourceHull.linkedTo)
{
@@ -174,7 +174,7 @@ namespace Barotrauma.Items.Components
linkedHullData.ReceivedWaterAmount = null;
if (fromWaterDetector)
{
- linkedHullData.ReceivedWaterAmount = Math.Min(linkedHull.WaterVolume / linkedHull.Volume, 1.0f);
+ linkedHullData.ReceivedWaterAmount = WaterDetector.GetWaterPercentage(linkedHull);
}
}
break;
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Steering.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Steering.cs
index 3a8095561..7e3e1da2e 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Steering.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Steering.cs
@@ -68,6 +68,8 @@ namespace Barotrauma.Items.Components
private const float ConnectedSubUpdateInterval = 1.0f;
float connectedSubUpdateTimer;
+ private double lastReceivedSteeringSignalTime;
+
public bool AutoPilot
{
get { return autoPilot; }
@@ -312,16 +314,20 @@ namespace Barotrauma.Items.Components
}
else if (AutoPilot)
{
- UpdateAutoPilot(deltaTime);
- float throttle = 1.0f;
- if (controlledSub != null)
+ //signals override autopilot for a duration of one second
+ if (lastReceivedSteeringSignalTime < Timing.TotalTime - 1)
{
- //if the sub is heading in the correct direction, throttle the speed according to the user's skill
- //if it's e.g. sinking due to extra water, don't throttle, but allow emptying up the ballast completely
- throttle = MathHelper.Clamp(Vector2.Dot(controlledSub.Velocity, TargetVelocity) / 100.0f, 0.0f, 1.0f);
+ UpdateAutoPilot(deltaTime);
+ float throttle = 1.0f;
+ if (controlledSub != null)
+ {
+ //if the sub is heading in the correct direction, throttle the speed according to the user's skill
+ //if it's e.g. sinking due to extra water, don't throttle, but allow emptying up the ballast completely
+ throttle = MathHelper.Clamp(Vector2.Dot(controlledSub.Velocity, TargetVelocity) / 100.0f, 0.0f, 1.0f);
+ }
+ float maxSpeed = MathHelper.Lerp(AutoPilotMaxSpeed, AIPilotMaxSpeed, userSkill) * 100.0f;
+ TargetVelocity = TargetVelocity.ClampLength(MathHelper.Lerp(100.0f, maxSpeed, throttle));
}
- float maxSpeed = MathHelper.Lerp(AutoPilotMaxSpeed, AIPilotMaxSpeed, userSkill) * 100.0f;
- TargetVelocity = TargetVelocity.ClampLength(MathHelper.Lerp(100.0f, maxSpeed, throttle));
}
else
{
@@ -821,6 +827,7 @@ namespace Barotrauma.Items.Components
steeringInput.X = MathHelper.Clamp(steeringInput.X, -100.0f, 100.0f);
steeringInput.Y = MathHelper.Clamp(-steeringInput.Y, -100.0f, 100.0f);
TargetVelocity = steeringInput;
+ lastReceivedSteeringSignalTime = Timing.TotalTime;
}
else
{
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs
index 977dda461..cae59479d 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs
@@ -150,7 +150,7 @@ namespace Barotrauma.Items.Components
{
if (powerOut?.Grid != null) { return powerOut.Grid.Voltage; }
}
- return currPowerConsumption <= 0.0f ? 1.0f : voltage;
+ return PowerConsumption <= 0.0f ? 1.0f : voltage;
}
set
{
@@ -158,21 +158,7 @@ namespace Barotrauma.Items.Components
}
}
- public bool PoweredByTinkering
- {
- get
- {
- if (this is PowerContainer) { return false; }
- foreach (Repairable repairable in Item.Repairables)
- {
- if (repairable.IsTinkering && repairable.TinkeringPowersDevices)
- {
- return true;
- }
- }
- return false;
- }
- }
+ public bool PoweredByTinkering { get; set; }
[Editable, Serialize(true, IsPropertySaveable.Yes, description: "Can the item be damaged by electomagnetic pulses.")]
public bool VulnerableToEMP
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Projectile.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Projectile.cs
index ee6516ef8..b72ea07b8 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Projectile.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Projectile.cs
@@ -965,7 +965,8 @@ namespace Barotrauma.Items.Components
{
item.body.LinearVelocity *= deflectedSpeedMultiplier;
}
- else if ( stickJoint == null && StickTarget == null &&
+ else if ( remainingHits <= 0 &&
+ stickJoint == null && StickTarget == null &&
StickToStructures && target.Body.UserData is Structure ||
((StickToLightTargets || target.Body.Mass > item.body.Mass * 0.5f) &&
(DoesStick ||
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Quality.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Quality.cs
index 0be5f9561..0d3dd454c 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Quality.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Quality.cs
@@ -56,7 +56,8 @@ namespace Barotrauma.Items.Components
if (value == qualityLevel) { return; }
bool wasInFullCondition = item.IsFullCondition;
- qualityLevel = MathHelper.Clamp(value, 0, MaxQuality);
+ qualityLevel = MathHelper.Clamp(value, 0, MaxQuality);
+ item.RecalculateConditionValues();
//set the condition to the new max condition
if (wasInFullCondition && statValues.ContainsKey(StatType.Condition))
{
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Repairable.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Repairable.cs
index 45d5d3ae4..edb4d6242 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Repairable.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Repairable.cs
@@ -106,7 +106,25 @@ namespace Barotrauma.Items.Components
}
}
- public bool IsTinkering { get; private set; } = false;
+ private bool isTinkering;
+ public bool IsTinkering
+ {
+ get { return isTinkering; }
+ private set
+ {
+ if (isTinkering == value) { return; }
+ isTinkering = value;
+
+ if (tinkeringPowersDevices)
+ {
+ foreach (Powered powered in item.GetComponents())
+ {
+ if (powered is PowerContainer) { continue; }
+ powered.PoweredByTinkering = isTinkering;
+ }
+ }
+ }
+ }
public Character CurrentFixer { get; private set; }
private Item currentRepairItem;
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Rope.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Rope.cs
index 6d1c899b3..7f0c5ca8e 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Rope.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Rope.cs
@@ -160,7 +160,8 @@ namespace Barotrauma.Items.Components
public override void Update(float deltaTime, Camera cam)
{
if (source == null || target == null || target.Removed ||
- (source is Entity sourceEntity && sourceEntity.Removed))
+ (source is Entity sourceEntity && sourceEntity.Removed) ||
+ (source is Limb limb && limb.Removed))
{
ResetSource();
target = null;
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/CustomInterface.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/CustomInterface.cs
index 92149904e..2cbdc98fa 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/CustomInterface.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/CustomInterface.cs
@@ -3,6 +3,7 @@ using Barotrauma.Networking;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
+using System.Globalization;
namespace Barotrauma.Items.Components
{
@@ -34,13 +35,17 @@ namespace Barotrauma.Items.Components
public Identifier PropertyName { get; }
public bool TargetOnlyParentProperty { get; }
- public int NumberInputMin { get; }
- public int NumberInputMax { get; }
+ public string NumberInputMin { get; }
+ public string NumberInputMax { get; }
+ public string NumberInputStep { get; }
+ public int NumberInputDecimalPlaces { get; }
public int MaxTextLength { get; }
- public const int DefaultNumberInputMin = 0, DefaultNumberInputMax = 99;
- public bool IsIntegerInput { get; }
+ public const string DefaultNumberInputMin = "0", DefaultNumberInputMax = "99", DefaultNumberInputStep = "1";
+ public const int DefaultNumberInputDecimalPlaces = 0;
+ public bool IsNumberInput { get; }
+ public NumberType? NumberType { get; }
public bool HasPropertyName { get; }
public bool ShouldSetProperty { get; set; }
@@ -60,11 +65,34 @@ namespace Barotrauma.Items.Components
ConnectionName = element.GetAttributeString("connection", "");
PropertyName = element.GetAttributeIdentifier("propertyname", "");
TargetOnlyParentProperty = element.GetAttributeBool("targetonlyparentproperty", false);
- NumberInputMin = element.GetAttributeInt("min", DefaultNumberInputMin);
- NumberInputMax = element.GetAttributeInt("max", DefaultNumberInputMax);
+ NumberInputMin = element.GetAttributeString("min", DefaultNumberInputMin);
+ NumberInputMax = element.GetAttributeString("max", DefaultNumberInputMax);
+ NumberInputStep = element.GetAttributeString("step", DefaultNumberInputStep);
+ NumberInputDecimalPlaces = element.GetAttributeInt("decimalplaces", DefaultNumberInputDecimalPlaces);
MaxTextLength = element.GetAttributeInt("maxtextlength", int.MaxValue);
+
HasPropertyName = !PropertyName.IsEmpty;
- IsIntegerInput = HasPropertyName && element.Name.ToString().ToLowerInvariant() == "integerinput";
+ if (HasPropertyName)
+ {
+ string elementName = element.Name.ToString().ToLowerInvariant();
+ IsNumberInput = elementName == "numberinput" || elementName == "integerinput"; // backwards compatibility
+ if (IsNumberInput)
+ {
+ string numberType = element.GetAttributeString("numbertype", string.Empty);
+ switch (numberType)
+ {
+ case "f":
+ case "float":
+ NumberType = Barotrauma.NumberType.Float;
+ break;
+ case "int":
+ case "integer":
+ default: // backwards compatibility
+ NumberType = Barotrauma.NumberType.Int;
+ break;
+ }
+ }
+ }
if (element.GetAttribute("signal") is XAttribute attribute)
{
@@ -152,7 +180,8 @@ namespace Barotrauma.Items.Components
{
case "button":
case "textbox":
- case "integerinput":
+ case "integerinput": // backwards compatibility
+ case "numberinput":
var button = new CustomInterfaceElement(item, subElement, this)
{
ContinuousSignal = false
@@ -317,6 +346,24 @@ namespace Barotrauma.Items.Components
}
}
+ private void ValueChanged(CustomInterfaceElement numberInputElement, float value)
+ {
+ if (numberInputElement == null) { return; }
+ numberInputElement.Signal = value.ToString();
+ if (!numberInputElement.TargetOnlyParentProperty)
+ {
+ foreach (ISerializableEntity e in item.AllPropertyObjects)
+ {
+ if (!e.SerializableProperties.ContainsKey(numberInputElement.PropertyName)) { continue; }
+ e.SerializableProperties[numberInputElement.PropertyName].TrySetValue(e, value);
+ }
+ }
+ else if (SerializableProperties.ContainsKey(numberInputElement.PropertyName))
+ {
+ SerializableProperties[numberInputElement.PropertyName].TrySetValue(this, value);
+ }
+ }
+
public override void Update(float deltaTime, Camera cam)
{
foreach (CustomInterfaceElement ciElement in customInterfaceElementList)
@@ -341,5 +388,10 @@ namespace Barotrauma.Items.Components
signals = customInterfaceElementList.Select(ci => ci.Signal).ToArray();
return base.Save(parentElement);
}
+
+ private static bool TryParseFloatInvariantCulture(string s, out float f)
+ {
+ return float.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out f);
+ }
}
}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/WaterDetector.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/WaterDetector.cs
index 7fc471035..5e70fcf9d 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/WaterDetector.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/WaterDetector.cs
@@ -64,6 +64,11 @@ namespace Barotrauma.Items.Components
IsActive = true;
}
+ public static int GetWaterPercentage(Hull hull)
+ {
+ return hull.WaterVolume > 1.0f ? MathHelper.Clamp((int)Math.Ceiling(hull.WaterPercentage), 0, 100) : 0;
+ }
+
public override void Update(float deltaTime, Camera cam)
{
if (stateSwitchDelay > 0.0f)
@@ -103,12 +108,7 @@ namespace Barotrauma.Items.Components
if (item.CurrentHull != null)
{
- int waterPercentage = 0;
- //ignore minuscule amounts of water
- if (item.CurrentHull.WaterVolume > 1.0f)
- {
- waterPercentage = MathHelper.Clamp((int)Math.Ceiling(item.CurrentHull.WaterPercentage), 0, 100);
- }
+ int waterPercentage = GetWaterPercentage(item.CurrentHull);
if (prevSentWaterPercentageValue != waterPercentage || waterPercentageSignal == null)
{
prevSentWaterPercentageValue = waterPercentage;
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Turret.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Turret.cs
index a6720fe49..32750626f 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Turret.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Turret.cs
@@ -350,7 +350,7 @@ namespace Barotrauma.Items.Components
if (lightComponent != null)
{
lightComponent.Parent = null;
- lightComponent.Rotation = Rotation - MathHelper.ToRadians(item.Rotation);
+ lightComponent.Rotation = Rotation - item.RotationRad;
lightComponent.Light.Rotation = -rotation;
}
#endif
@@ -516,7 +516,7 @@ namespace Barotrauma.Items.Components
{
if (lightComponent != null)
{
- lightComponent.Rotation = Rotation - MathHelper.ToRadians(item.Rotation);
+ lightComponent.Rotation = Rotation - item.RotationRad;
}
}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs
index 8df11b4de..8f7b0e4fd 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs
@@ -262,19 +262,19 @@ namespace Barotrauma
}
}
- private float rotationRad;
+ public float RotationRad { get; private set; }
[ConditionallyEditable(ConditionallyEditable.ConditionType.AllowRotating, MinValueFloat = 0.0f, MaxValueFloat = 360.0f, DecimalCount = 1, ValueStep = 1f), Serialize(0.0f, IsPropertySaveable.Yes)]
public float Rotation
{
get
{
- return MathHelper.ToDegrees(rotationRad);
+ return MathHelper.ToDegrees(RotationRad);
}
set
{
if (!Prefab.AllowRotatingInEditor) { return; }
- rotationRad = MathHelper.ToRadians(value);
+ RotationRad = MathHelper.ToRadians(value);
#if CLIENT
if (Screen.Selected == GameMain.SubEditorScreen)
{
@@ -472,9 +472,9 @@ namespace Barotrauma
get { return spriteColor; }
}
- public bool IsFullCondition => MathUtils.NearlyEqual(Condition, MaxCondition);
- public float MaxCondition => Prefab.Health * healthMultiplier * maxRepairConditionMultiplier * (1.0f + GetQualityModifier(Items.Components.Quality.StatType.Condition));
- public float ConditionPercentage => MathUtils.Percentage(Condition, MaxCondition);
+ public bool IsFullCondition { get; private set; }
+ public float MaxCondition { get; private set; }
+ public float ConditionPercentage { get; private set; }
private float offsetOnSelectedMultiplier = 1.0f;
@@ -495,7 +495,8 @@ namespace Barotrauma
{
float prevConditionPercentage = ConditionPercentage;
healthMultiplier = MathHelper.Clamp(value, 0.0f, float.PositiveInfinity);
- Condition = MaxCondition * prevConditionPercentage / 100.0f;
+ condition = MaxCondition * prevConditionPercentage / 100.0f;
+ RecalculateConditionValues();
}
}
@@ -505,7 +506,11 @@ namespace Barotrauma
public float MaxRepairConditionMultiplier
{
get => maxRepairConditionMultiplier;
- set { maxRepairConditionMultiplier = MathHelper.Clamp(value, 0.0f, float.PositiveInfinity); }
+ set
+ {
+ maxRepairConditionMultiplier = MathHelper.Clamp(value, 0.0f, float.PositiveInfinity);
+ RecalculateConditionValues();
+ }
}
//the default value should be Prefab.Health, but because we can't use it in the attribute,
@@ -806,7 +811,9 @@ namespace Barotrauma
defaultRect = newRect;
rect = newRect;
- condition = MaxCondition;
+ condition = MaxCondition = Prefab.Health;
+ ConditionPercentage = 100.0f;
+
lastSentCondition = condition;
AllowDeconstruct = itemPrefab.AllowDeconstruct;
@@ -1002,6 +1009,7 @@ namespace Barotrauma
ApplyStatusEffects(ActionType.OnSpawn, 1.0f);
Components.ForEach(c => c.ApplyStatusEffects(ActionType.OnSpawn, 1.0f));
+ RecalculateConditionValues();
}
partial void InitProjSpecific();
@@ -1184,7 +1192,6 @@ namespace Barotrauma
public void RemoveContained(Item contained)
{
ownInventory?.RemoveItem(contained);
-
contained.Container = null;
}
@@ -1611,6 +1618,10 @@ namespace Barotrauma
bool wasInFullCondition = IsFullCondition;
condition = MathHelper.Clamp(value, 0.0f, MaxCondition);
+ if (MathUtils.NearlyEqual(prev, condition, epsilon: 0.000001f)) { return; }
+
+ RecalculateConditionValues();
+
if (condition == 0.0f && prev > 0.0f)
{
//Flag connections to be updated as device is broken
@@ -1672,6 +1683,17 @@ namespace Barotrauma
}
}
+ ///
+ /// Recalculates the item's maximum condition, condition percentage and whether it's in full condition.
+ /// You generally never need to call this manually - done automatically when any of the factors that affect the values change.
+ ///
+ public void RecalculateConditionValues()
+ {
+ MaxCondition = Prefab.Health * healthMultiplier * maxRepairConditionMultiplier * (1.0f + GetQualityModifier(Items.Components.Quality.StatType.Condition));
+ IsFullCondition = MathUtils.NearlyEqual(Condition, MaxCondition);
+ ConditionPercentage = MathUtils.Percentage(Condition, MaxCondition);
+ }
+
private bool IsInWater()
{
if (CurrentHull == null) { return true; }
@@ -1999,7 +2021,7 @@ namespace Barotrauma
if (Prefab.AllowRotatingInEditor)
{
- rotationRad = MathUtils.WrapAngleTwoPi(-rotationRad);
+ RotationRad = MathUtils.WrapAngleTwoPi(-RotationRad);
}
#if CLIENT
if (Prefab.CanSpriteFlipX)
@@ -3153,12 +3175,12 @@ namespace Barotrauma
{
Vector2 oldRelativeOrigin = (oldPrefab.SwappableItem.SwapOrigin - oldPrefab.Size / 2) * element.GetAttributeFloat(item.scale, "scale", "Scale");
oldRelativeOrigin.Y = -oldRelativeOrigin.Y;
- oldRelativeOrigin = MathUtils.RotatePoint(oldRelativeOrigin, -item.rotationRad);
+ oldRelativeOrigin = MathUtils.RotatePoint(oldRelativeOrigin, -item.RotationRad);
Vector2 oldOrigin = centerPos + oldRelativeOrigin;
Vector2 relativeOrigin = (prefab.SwappableItem.SwapOrigin - prefab.Size / 2) * item.Scale;
relativeOrigin.Y = -relativeOrigin.Y;
- relativeOrigin = MathUtils.RotatePoint(relativeOrigin, -item.rotationRad);
+ relativeOrigin = MathUtils.RotatePoint(relativeOrigin, -item.RotationRad);
Vector2 origin = new Vector2(rect.X + rect.Width / 2, rect.Y - rect.Height / 2) + relativeOrigin;
item.rect.Location -= (origin - oldOrigin).ToPoint();
@@ -3194,6 +3216,7 @@ namespace Barotrauma
item.condition = MathHelper.Clamp(condition, 0, item.MaxCondition);
item.lastSentCondition = item.condition;
+ item.RecalculateConditionValues();
item.SetActiveSprite();
if (submarine?.Info.GameVersion != null)
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/RelatedItem.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/RelatedItem.cs
index 46ae8392c..a74a686d4 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Items/RelatedItem.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/RelatedItem.cs
@@ -36,6 +36,11 @@ namespace Barotrauma
///
public bool ExcludeBroken { get; private set; }
+ ///
+ /// Should full condition (100%) items be excluded
+ ///
+ public bool ExcludeFullCondition { get; private set; }
+
public bool AllowVariants { get; private set; } = true;
public RelationType Type
@@ -102,14 +107,14 @@ namespace Barotrauma
return CheckContained(parentItem);
case RelationType.Container:
if (parentItem == null || parentItem.Container == null) { return MatchOnEmpty; }
- return (!ExcludeBroken || parentItem.Container.Condition > 0.0f) && MatchesItem(parentItem.Container);
+ return (!ExcludeBroken || parentItem.Container.Condition > 0.0f) && (!ExcludeFullCondition || !parentItem.Container.IsFullCondition) && MatchesItem(parentItem.Container);
case RelationType.Equipped:
if (character == null) { return false; }
if (MatchOnEmpty && !character.HeldItems.Any()) { return true; }
foreach (Item equippedItem in character.HeldItems)
{
if (equippedItem == null) { continue; }
- if ((!ExcludeBroken || equippedItem.Condition > 0.0f) && MatchesItem(equippedItem)) { return true; }
+ if ((!ExcludeBroken || equippedItem.Condition > 0.0f) && (!ExcludeFullCondition || !equippedItem.IsFullCondition) && MatchesItem(equippedItem)) { return true; }
}
break;
case RelationType.Picked:
@@ -138,8 +143,7 @@ namespace Barotrauma
foreach (Item contained in parentItem.ContainedItems)
{
if (TargetSlot > -1 && parentItem.OwnInventory.FindIndex(contained) != TargetSlot) { continue; }
- if ((!ExcludeBroken || contained.Condition > 0.0f) && MatchesItem(contained)) { return true; }
-
+ if ((!ExcludeBroken || contained.Condition > 0.0f) && (!ExcludeFullCondition || !contained.IsFullCondition) && MatchesItem(contained)) { return true; }
if (CheckContained(contained)) { return true; }
}
return false;
@@ -153,6 +157,7 @@ namespace Barotrauma
new XAttribute("optional", IsOptional),
new XAttribute("ignoreineditor", IgnoreInEditor),
new XAttribute("excludebroken", ExcludeBroken),
+ new XAttribute("excludefullcondition", ExcludeFullCondition),
new XAttribute("targetslot", TargetSlot),
new XAttribute("allowvariants", AllowVariants));
@@ -212,12 +217,12 @@ namespace Barotrauma
}
}
-
if (identifiers.Length == 0 && excludedIdentifiers.Length == 0 && !returnEmpty) { return null; }
RelatedItem ri = new RelatedItem(identifiers, excludedIdentifiers)
{
ExcludeBroken = element.GetAttributeBool("excludebroken", true),
+ ExcludeFullCondition = element.GetAttributeBool("excludefullcondition", false),
AllowVariants = element.GetAttributeBool("allowvariants", true)
};
string typeStr = element.GetAttributeString("type", "");
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/StartItemSet.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/StartItemSet.cs
new file mode 100644
index 000000000..a93ea13c3
--- /dev/null
+++ b/Barotrauma/BarotraumaShared/SharedSource/Items/StartItemSet.cs
@@ -0,0 +1,36 @@
+#nullable enable
+using System.Collections.Immutable;
+using System.Linq;
+using System.Xml.Linq;
+
+namespace Barotrauma
+{
+ internal class StartItem
+ {
+ public Identifier Item;
+ public int Amount;
+
+ public StartItem(XElement element)
+ {
+ Item = element.GetAttributeIdentifier("identifier", Identifier.Empty);
+ Amount = element.GetAttributeInt("amount", 1);
+ }
+ }
+
+ ///
+ /// Additive sets of items spawned only at the start of the game.
+ ///
+ internal class StartItemSet : PrefabWithUintIdentifier
+ {
+ public readonly static PrefabCollection Sets = new PrefabCollection();
+
+ public readonly ImmutableArray Items;
+
+ public StartItemSet(ContentXElement element, StartItemsFile file) : base(file, element.GetAttributeIdentifier("identifier", Identifier.Empty))
+ {
+ Items = element.Elements().Select(e => new StartItem(e!)).ToImmutableArray();
+ }
+
+ public override void Dispose() { }
+ }
+}
\ No newline at end of file
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/CoreEntityPrefab.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/CoreEntityPrefab.cs
index b9fc28d5d..c5c646150 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/CoreEntityPrefab.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/CoreEntityPrefab.cs
@@ -25,6 +25,7 @@ namespace Barotrauma
IEnumerable aliases = null)
: base(identifier)
{
+ System.Diagnostics.Debug.Assert(constructor != null);
this.constructor = constructor;
this.Name = TextManager.Get($"EntityName.{identifier}");
this.Description = TextManager.Get($"EntityDescription.{identifier}");
@@ -35,40 +36,52 @@ namespace Barotrauma
this.Aliases = (aliases ?? Enumerable.Empty()).Concat(identifier.Value.ToEnumerable()).ToImmutableHashSet();
}
+ public static CoreEntityPrefab HullPrefab { get; private set; }
+ public static CoreEntityPrefab GapPrefab { get; private set; }
+ public static CoreEntityPrefab WayPointPrefab { get; private set; }
+ public static CoreEntityPrefab SpawnPointPrefab { get; private set; }
+
public static void InitCorePrefabs()
{
- CoreEntityPrefab ep = new CoreEntityPrefab(
+ HullPrefab = new CoreEntityPrefab(
"hull".ToIdentifier(),
- typeof(Hull).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }),
+ typeof(Hull).GetConstructor(new Type[] { typeof(Rectangle) }),
resizeHorizontal: true,
resizeVertical: true,
linkable: true,
allowedLinks: new Identifier[] { "hull".ToIdentifier() });
- Prefabs.Add(ep, false);
+ Prefabs.Add(HullPrefab, false);
- ep = new CoreEntityPrefab(
+ GapPrefab = new CoreEntityPrefab(
"gap".ToIdentifier(),
- typeof(Gap).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }),
+ typeof(Gap).GetConstructor(new Type[] { typeof(Rectangle) }),
resizeHorizontal: true,
resizeVertical: true);
- Prefabs.Add(ep, false);
+ Prefabs.Add(GapPrefab, false);
- ep = new CoreEntityPrefab(
+ WayPointPrefab = new CoreEntityPrefab(
"waypoint".ToIdentifier(),
typeof(WayPoint).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }));
- Prefabs.Add(ep, false);
+ Prefabs.Add(WayPointPrefab, false);
- ep = new CoreEntityPrefab(
+ SpawnPointPrefab = new CoreEntityPrefab(
"spawnpoint".ToIdentifier(),
typeof(WayPoint).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }));
- Prefabs.Add(ep, false);
+ Prefabs.Add(SpawnPointPrefab, false);
}
protected override void CreateInstance(Rectangle rect)
{
- if (constructor == null) return;
- object[] lobject = new object[] { this, rect };
- constructor.Invoke(lobject);
+ if (this == WayPointPrefab || this == SpawnPointPrefab)
+ {
+ object[] lobject = new object[] { this, rect };
+ constructor.Invoke(lobject);
+ }
+ else
+ {
+ object[] lobject = new object[] { rect };
+ constructor.Invoke(lobject);
+ }
}
private bool disposed = false;
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Gap.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Gap.cs
index 53c2a59eb..291737a4e 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/Gap.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Gap.cs
@@ -120,7 +120,7 @@ namespace Barotrauma
}
}
- public Gap(MapEntityPrefab prefab, Rectangle rectangle)
+ public Gap(Rectangle rectangle)
: this(rectangle, Submarine.MainSub)
{
#if CLIENT
@@ -136,7 +136,7 @@ namespace Barotrauma
{ }
public Gap(Rectangle rect, bool isHorizontal, Submarine submarine, ushort id = Entity.NullEntityID)
- : base(MapEntityPrefab.FindByIdentifier("gap".ToIdentifier()), submarine, id)
+ : base(CoreEntityPrefab.GapPrefab, submarine, id)
{
this.rect = rect;
flowForce = Vector2.Zero;
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Hull.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Hull.cs
index 88cfa4d2c..9702e90be 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/Hull.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Hull.cs
@@ -410,8 +410,8 @@ namespace Barotrauma
public BallastFloraBehavior BallastFlora { get; set; }
- public Hull(MapEntityPrefab prefab, Rectangle rectangle)
- : this (prefab, rectangle, Submarine.MainSub)
+ public Hull(Rectangle rectangle)
+ : this (rectangle, Submarine.MainSub)
{
#if CLIENT
if (SubEditorScreen.IsSubEditor())
@@ -421,8 +421,8 @@ namespace Barotrauma
#endif
}
- public Hull(MapEntityPrefab prefab, Rectangle rectangle, Submarine submarine, ushort id = Entity.NullEntityID)
- : base (prefab, submarine, id)
+ public Hull(Rectangle rectangle, Submarine submarine, ushort id = Entity.NullEntityID)
+ : base (CoreEntityPrefab.HullPrefab, submarine, id)
{
rect = rectangle;
@@ -500,7 +500,7 @@ namespace Barotrauma
public override MapEntity Clone()
{
- var clone = new Hull(MapEntityPrefab.FindByIdentifier("hull".ToIdentifier()), rect, Submarine);
+ var clone = new Hull(rect, Submarine);
foreach (KeyValuePair property in SerializableProperties)
{
if (!property.Value.Attributes.OfType().Any()) { continue; }
@@ -1543,7 +1543,7 @@ namespace Barotrauma
int.Parse(element.GetAttribute("height").Value));
}
- var hull = new Hull(MapEntityPrefab.Find(null, "hull"), rect, submarine, idRemap.GetOffsetId(element))
+ var hull = new Hull(rect, submarine, idRemap.GetOffsetId(element))
{
WaterVolume = element.GetAttributeFloat("pressure", 0.0f)
};
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Biome.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Biome.cs
index 1205fa136..298638c46 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Biome.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Biome.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
using System.Collections.Immutable;
-using System.Xml.Linq;
namespace Barotrauma
{
@@ -14,6 +11,8 @@ namespace Barotrauma
public readonly LocalizedString Description;
public readonly bool IsEndBiome;
+ public readonly float MinDifficulty;
+ public readonly float MaxDifficulty;
public readonly ImmutableHashSet AllowedZones;
@@ -30,8 +29,9 @@ namespace Barotrauma
element.GetAttributeString("description", ""));
IsEndBiome = element.GetAttributeBool("endbiome", false);
-
AllowedZones = element.GetAttributeIntArray("AllowedZones", new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }).ToImmutableHashSet();
+ MinDifficulty = element.GetAttributeFloat("MinDifficulty", 0);
+ MaxDifficulty = element.GetAttributeFloat("MaxDifficulty", 100);
}
public static Identifier ParseIdentifier(ContentXElement element)
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/CaveGenerationParams.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/CaveGenerationParams.cs
index 4adb2834f..b71326832 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/CaveGenerationParams.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/CaveGenerationParams.cs
@@ -96,24 +96,31 @@ namespace Barotrauma
public readonly Sprite WallSprite;
public readonly Sprite WallEdgeSprite;
- public static CaveGenerationParams GetRandom(LevelGenerationParams generationParams, bool abyss, Rand.RandSync rand)
+ public static CaveGenerationParams GetRandom(Level level, bool abyss, Rand.RandSync rand)
{
var caveParams = CaveParams.OrderBy(p => p.UintIdentifier).ToList();
- if (caveParams.All(p => p.GetCommonness(generationParams, abyss) <= 0.0f))
+ if (caveParams.All(p => p.GetCommonness(level.LevelData, abyss) <= 0.0f))
{
return caveParams.First();
}
- return ToolBox.SelectWeightedRandom(caveParams.ToList(), caveParams.Select(p => p.GetCommonness(generationParams, abyss)).ToList(), rand);
+ return ToolBox.SelectWeightedRandom(caveParams.ToList(), caveParams.Select(p => p.GetCommonness(level.LevelData, abyss)).ToList(), rand);
}
- public float GetCommonness(LevelGenerationParams generationParams, bool abyss)
+ public float GetCommonness(LevelData levelData, bool abyss)
{
- if (generationParams != null &&
- generationParams.Identifier != Identifier.Empty &&
- OverrideCommonness.TryGetValue(abyss ? "abyss".ToIdentifier() : generationParams.Identifier, out float commonness))
+ if (levelData.GenerationParams != null && levelData.GenerationParams.Identifier != Identifier.Empty &&
+ OverrideCommonness.TryGetValue(abyss ? "abyss".ToIdentifier() : levelData.GenerationParams.Identifier, out float commonness))
{
return commonness;
}
+ if (levelData?.Biome != null)
+ {
+ if (OverrideCommonness.TryGetValue(levelData.Biome.Identifier, out float biomeCommonness))
+ {
+ return biomeCommonness;
+ }
+ }
+
return Commonness;
}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs
index 8b1831507..61049099d 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs
@@ -442,6 +442,11 @@ namespace Barotrauma
Loaded?.Remove();
Loaded = this;
Generating = true;
+#if CLIENT
+ Debug.Assert(GenerationParams.Identifier != "coldcavernstutorial" || GameMain.GameSession?.GameMode == null || GameMain.GameSession.GameMode is TutorialMode);
+#endif
+ Debug.Assert(GenerationParams.AnyBiomeAllowed || GenerationParams.AllowedBiomeIdentifiers.Contains(LevelData.Biome.Identifier));
+ DebugConsole.NewMessage("Level identifier: " + GenerationParams.Identifier);
ClearEqualityCheckValues();
EntitiesBeforeGenerate = GetEntities().ToList();
@@ -1711,7 +1716,8 @@ namespace Barotrauma
else
{
//if the bottom of the abyss area is below crush depth, try to move it up to keep (most) of the abyss content above crush depth
- if (abyssEndY + CrushDepth < 0)
+ //but only if start of the abyss is above crush depth (no point in doing this if all of it is below crush depth)
+ if (abyssEndY + CrushDepth < 0 && abyssStartY > -CrushDepth)
{
abyssEndY += Math.Min(-(abyssEndY + (int)CrushDepth), abyssHeight / 2);
}
@@ -1820,7 +1826,7 @@ namespace Barotrauma
}
}
- var caveParams = CaveGenerationParams.GetRandom(GenerationParams, abyss: true, rand: Rand.RandSync.ServerAndClient);
+ var caveParams = CaveGenerationParams.GetRandom(this, abyss: true, rand: Rand.RandSync.ServerAndClient);
float caveScaleRelativeToIsland = 0.7f;
GenerateCave(
@@ -1889,7 +1895,7 @@ namespace Barotrauma
{
for (int i = 0; i < GenerationParams.CaveCount; i++)
{
- var caveParams = CaveGenerationParams.GetRandom(GenerationParams, abyss: false, rand: Rand.RandSync.ServerAndClient);
+ var caveParams = CaveGenerationParams.GetRandom(this, abyss: false, rand: Rand.RandSync.ServerAndClient);
Point caveSize = new Point(
Rand.Range(caveParams.MinWidth, caveParams.MaxWidth, Rand.RandSync.ServerAndClient),
Rand.Range(caveParams.MinHeight, caveParams.MaxHeight, Rand.RandSync.ServerAndClient));
@@ -2479,6 +2485,7 @@ namespace Barotrauma
foreach (ItemPrefab itemPrefab in ItemPrefab.Prefabs.OrderBy(p => p.UintIdentifier))
{
if (itemPrefab.LevelCommonness.TryGetValue(levelName, out float commonness) ||
+ itemPrefab.LevelCommonness.TryGetValue(LevelData.Biome.Identifier, out commonness) ||
itemPrefab.LevelCommonness.TryGetValue(Identifier.Empty, out commonness))
{
if (commonness <= 0.0f) { continue; }
@@ -3237,7 +3244,8 @@ namespace Barotrauma
if (index < 0 || index >= bottomPositions.Count - 1) { return new Vector2(xPosition, BottomPos); }
float t = (xPosition - bottomPositions[index].X) / (bottomPositions[index + 1].X - bottomPositions[index].X);
- Debug.Assert(t <= 1.0f);
+ //t can go slightly outside the 0-1 due to rounding, safe to ignore
+ Debug.Assert(t <= 1.001f && t >= -0.001f);
t = MathHelper.Clamp(t, 0.0f, 1.0f);
float yPos = MathHelper.Lerp(bottomPositions[index].Y, bottomPositions[index + 1].Y, t);
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelData.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelData.cs
index 7313759d5..10f625e3b 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelData.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelData.cs
@@ -20,7 +20,7 @@ namespace Barotrauma
public readonly string Seed;
- public readonly float Difficulty;
+ public float Difficulty;
public readonly Biome Biome;
@@ -90,10 +90,10 @@ namespace Barotrauma
(int)MathUtils.Round(generationParams.Height, Level.GridCellSize));
}
- public LevelData(XElement element)
+ public LevelData(XElement element, float? forceDifficulty = null)
{
Seed = element.GetAttributeString("seed", "");
- Difficulty = element.GetAttributeFloat("difficulty", 0.0f);
+ Difficulty = forceDifficulty ?? element.GetAttributeFloat("difficulty", 0.0f);
Size = element.GetAttributePoint("size", new Point(1000));
Enum.TryParse(element.GetAttributeString("type", "LocationConnection"), out Type);
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelGenerationParams.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelGenerationParams.cs
index bc380746d..3742ade58 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelGenerationParams.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelGenerationParams.cs
@@ -414,7 +414,7 @@ namespace Barotrauma
set;
}
- [Serialize(50, IsPropertySaveable.Yes, description: "Maximum number of resource clusters in the abyss (the actual number is picked between min and max according to the level difficulty)"), Editable(MinValueInt = 0, MaxValueInt = 1000)]
+ [Serialize(40, IsPropertySaveable.Yes, description: "Maximum number of resource clusters in the abyss (the actual number is picked between min and max according to the level difficulty)"), Editable(MinValueInt = 0, MaxValueInt = 1000)]
public int AbyssResourceClustersMax
{
get;
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelObjects/LevelObjectManager.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelObjects/LevelObjectManager.cs
index b07e2dd78..8e30125de 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelObjects/LevelObjectManager.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelObjects/LevelObjectManager.cs
@@ -170,7 +170,7 @@ namespace Barotrauma
for (int i = 0; i < amount; i++)
{
//get a random prefab and find a place to spawn it
- LevelObjectPrefab prefab = GetRandomPrefab(level.GenerationParams, availablePrefabs);
+ LevelObjectPrefab prefab = GetRandomPrefab(level, availablePrefabs);
if (prefab == null) { continue; }
if (!suitableSpawnPositions.ContainsKey(prefab))
{
@@ -595,12 +595,12 @@ namespace Barotrauma
}
}
- private LevelObjectPrefab GetRandomPrefab(LevelGenerationParams generationParams, IList availablePrefabs)
+ private LevelObjectPrefab GetRandomPrefab(Level level, IList availablePrefabs)
{
- if (availablePrefabs.Sum(p => p.GetCommonness(generationParams)) <= 0.0f) { return null; }
+ if (availablePrefabs.Sum(p => p.GetCommonness(level.LevelData)) <= 0.0f) { return null; }
return ToolBox.SelectWeightedRandom(
availablePrefabs,
- availablePrefabs.Select(p => p.GetCommonness(generationParams)).ToList(), Rand.RandSync.ServerAndClient);
+ availablePrefabs.Select(p => p.GetCommonness(level.LevelData)).ToList(), Rand.RandSync.ServerAndClient);
}
private LevelObjectPrefab GetRandomPrefab(CaveGenerationParams caveParams, IList availablePrefabs, bool requireCaveSpecificOverride)
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelObjects/LevelObjectPrefab.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelObjects/LevelObjectPrefab.cs
index 326b443ca..a2ad86140 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelObjects/LevelObjectPrefab.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelObjects/LevelObjectPrefab.cs
@@ -426,15 +426,21 @@ namespace Barotrauma
return requireCaveSpecificOverride ? 0.0f : Commonness;
}
- public float GetCommonness(LevelGenerationParams generationParams)
- {
- if (generationParams != null &&
- generationParams.Identifier != Identifier.Empty &&
- (OverrideCommonness.TryGetValue(generationParams.Identifier, out float commonness) ||
- (!generationParams.OldIdentifier.IsEmpty && OverrideCommonness.TryGetValue(generationParams.OldIdentifier, out commonness))))
+ public float GetCommonness(LevelData levelData)
+ {
+ if (levelData.GenerationParams != null && levelData.GenerationParams.Identifier != Identifier.Empty &&
+ OverrideCommonness.TryGetValue(levelData.GenerationParams.Identifier, out float commonness) ||
+ (!levelData.GenerationParams.OldIdentifier.IsEmpty && OverrideCommonness.TryGetValue(levelData.GenerationParams.OldIdentifier, out commonness)))
{
return commonness;
}
+ if (levelData?.Biome != null)
+ {
+ if (OverrideCommonness.TryGetValue(levelData.Biome.Identifier, out float biomeCommonness))
+ {
+ return biomeCommonness;
+ }
+ }
return Commonness;
}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelWall.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelWall.cs
index 67cb59004..8b3c2c297 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelWall.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/LevelWall.cs
@@ -152,12 +152,6 @@ namespace Barotrauma
public void Dispose()
{
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
#if CLIENT
VertexBuffer?.Dispose();
VertexBuffer = null;
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Map/Location.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Map/Location.cs
index e17f274bf..08ac7d07d 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/Map/Location.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Map/Location.cs
@@ -485,6 +485,19 @@ namespace Barotrauma
TurnsInRadiation = element.GetAttributeInt(nameof(TurnsInRadiation).ToLower(), 0);
StepsSinceSpecialsUpdated = element.GetAttributeInt("stepssincespecialsupdated", 0);
+ Identifier biomeId = element.GetAttributeIdentifier("biome", Identifier.Empty);
+ if (biomeId != Identifier.Empty)
+ {
+ if (Biome.Prefabs.TryGet(biomeId, out Biome biome))
+ {
+ Biome = biome;
+ }
+ else
+ {
+ DebugConsole.ThrowError($"Error while loading the campaign map: could not find a biome with the identifier \"{biomeId}\".");
+ }
+ }
+
if (!typeNotFound)
{
for (int i = 0; i < Type.CanChangeTo.Count; i++)
@@ -773,22 +786,41 @@ namespace Barotrauma
static float GetConnectionWeight(Location location, LocationConnection c)
{
- float weight = c.Passed ? 1.0f : 5.0f;
Location destination = c.OtherLocation(location);
- if (destination != null)
+ if (destination == null) { return 0; }
+ float minWeight = 0.0001f;
+ float lowWeight = 0.2f;
+ float normalWeight = 1.0f;
+ float maxWeight = 2.0f;
+ float weight = c.Passed ? lowWeight : normalWeight;
+ if (location.Biome.AllowedZones.Contains(1))
{
- if (destination.MapPosition.X > location.MapPosition.X) { weight *= 2.0f; }
- int missionCount = location.availableMissions.Count(m => m.Locations.Contains(destination));
- if (missionCount > 0)
- {
- weight /= missionCount * 2;
- }
- if (destination.IsRadiated())
+ // In the first biome, give a stronger preference for locations that are farther to the right)
+ float diff = destination.MapPosition.X - location.MapPosition.X;
+ if (diff < 0)
{
- weight *= 0.001f;
+ weight *= 0.1f;
+ }
+ else
+ {
+ float maxRelevantDiff = 300;
+ weight = MathHelper.Lerp(weight, maxWeight, MathUtils.InverseLerp(0, maxRelevantDiff, diff));
}
}
- return weight;
+ else if (destination.MapPosition.X > location.MapPosition.X)
+ {
+ weight *= 2.0f;
+ }
+ int missionCount = location.availableMissions.Count(m => m.Locations.Contains(destination));
+ if (missionCount > 0)
+ {
+ weight /= missionCount * 2;
+ }
+ if (destination.IsRadiated())
+ {
+ weight *= 0.001f;
+ }
+ return MathHelper.Clamp(weight, minWeight, maxWeight);
}
return InstantiateMission(prefab, connection);
@@ -1255,6 +1287,7 @@ namespace Barotrauma
new XAttribute("originaltype", (Type ?? OriginalType).Identifier),
new XAttribute("basename", BaseName),
new XAttribute("name", Name),
+ new XAttribute("biome", Biome?.Identifier.Value ?? string.Empty),
new XAttribute("discovered", Discovered),
new XAttribute("position", XMLExtensions.Vector2ToString(MapPosition)),
new XAttribute("pricemultiplier", PriceMultiplier),
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Map/Map.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Map/Map.cs
index 192065b94..af68c1464 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/Map/Map.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Map/Map.cs
@@ -131,18 +131,27 @@ namespace Barotrauma
};
Locations[locationIndices.X].Connections.Add(connection);
Locations[locationIndices.Y].Connections.Add(connection);
- connection.LevelData = new LevelData(subElement.Element("Level"));
string biomeId = subElement.GetAttributeString("biome", "");
connection.Biome =
Biome.Prefabs.FirstOrDefault(b => b.Identifier == biomeId) ??
Biome.Prefabs.FirstOrDefault(b => !b.OldIdentifier.IsEmpty && b.OldIdentifier == biomeId) ??
Biome.Prefabs.First();
+ connection.Difficulty = MathHelper.Clamp(connection.Difficulty, connection.Biome.MinDifficulty, connection.Biome.MaxDifficulty);
+ connection.LevelData = new LevelData(subElement.Element("Level"), connection.Difficulty);
Connections.Add(connection);
connectionElements.Add(subElement);
break;
}
}
+ //backwards compatibility: location biomes weren't saved (or used for anything) previously,
+ //assign them if they haven't been assigned
+ Random rand = new MTRandom(ToolBox.StringToInt(Seed));
+ if (Locations.First().Biome == null)
+ {
+ AssignBiomes(rand);
+ }
+
int startLocationindex = element.GetAttributeInt("startlocation", -1);
if (startLocationindex > 0 && startLocationindex < Locations.Count)
{
@@ -237,6 +246,10 @@ namespace Barotrauma
}
}
System.Diagnostics.Debug.Assert(StartLocation != null, "Start location not assigned after level generation.");
+ if (StartLocation?.LevelData != null)
+ {
+ StartLocation.LevelData.Difficulty = 0;
+ }
//ensure all paths from the starting location have 0 difficulty to make the 1st campaign round very easy
foreach (var locationConnection in StartLocation.Connections)
@@ -251,6 +264,11 @@ namespace Barotrauma
CurrentLocation.Discover(true);
CurrentLocation.CreateStores();
+ foreach (var location in Locations)
+ {
+ location.UnlockInitialMissions();
+ }
+
InitProjectSpecific();
}
@@ -505,22 +523,31 @@ namespace Barotrauma
//remove orphans
Locations.RemoveAll(l => !Connections.Any(c => c.Locations.Contains(l)));
+ AssignBiomes(new MTRandom(ToolBox.StringToInt(Seed)));
+
foreach (LocationConnection connection in Connections)
{
- //float difficulty = GetLevelDifficulty(connection.CenterPos.X / Width);
- //connection.Difficulty = MathHelper.Clamp(difficulty + Rand.Range(-10.0f, 0.0f, Rand.RandSync.ServerAndClient), 1.2f, 100.0f);
float difficulty = connection.CenterPos.X / Width * 100;
- float random = difficulty > 10 ? 5 : 0;
- connection.Difficulty = MathHelper.Clamp(difficulty + Rand.Range(-random, random, Rand.RandSync.ServerAndClient), 1.0f, 100.0f);
+ float minDifficulty = 0;
+ float maxDifficulty = 100;
+ var biome = connection.Biome;
+ if (biome != null)
+ {
+ minDifficulty = connection.Biome.MinDifficulty;
+ maxDifficulty = connection.Biome.MaxDifficulty;
+ if (connection.Locked)
+ {
+ connection.Difficulty = maxDifficulty;
+ }
+ }
+ connection.Difficulty = MathHelper.Clamp(difficulty, minDifficulty, maxDifficulty);
}
- AssignBiomes();
CreateEndLocation();
foreach (Location location in Locations)
{
location.LevelData = new LevelData(location, MathHelper.Clamp(location.MapPosition.X / Width * 100, 0.0f, 100.0f));
- location.UnlockInitialMissions();
}
foreach (LocationConnection connection in Connections)
{
@@ -549,7 +576,7 @@ namespace Barotrauma
return Biome.Prefabs.FirstOrDefault(b => b.AllowedZones.Contains(zoneIndex));
}
- private void AssignBiomes()
+ private void AssignBiomes(Random rand)
{
var biomes = Biome.Prefabs;
float zoneWidth = Width / generationParams.DifficultyZones;
@@ -565,7 +592,7 @@ namespace Barotrauma
{
if (location.MapPosition.X < zoneX)
{
- location.Biome = allowedBiomes[Rand.Range(0, allowedBiomes.Count, Rand.RandSync.ServerAndClient)];
+ location.Biome = allowedBiomes[rand.Next() % allowedBiomes.Count];
}
}
}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Outposts/NPCSet.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Outposts/NPCSet.cs
index 5397af405..48cce8bfc 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/Outposts/NPCSet.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Outposts/NPCSet.cs
@@ -34,23 +34,6 @@ namespace Barotrauma
return prefab;
}
- private void Dispose(bool disposing)
- {
- if (!Disposed)
- {
- if (disposing)
- {
- Humans.Clear();
- }
- }
-
- Disposed = true;
- }
-
- public override void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
+ public override void Dispose() { }
}
}
\ No newline at end of file
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/WayPoint.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/WayPoint.cs
index 23a7d0e1f..6972ac705 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Map/WayPoint.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Map/WayPoint.cs
@@ -109,14 +109,21 @@ namespace Barotrauma
#endif
}
-
+ public enum Type
+ {
+ WayPoint,
+ SpawnPoint
+ }
+
public WayPoint(Rectangle newRect, Submarine submarine)
- : this (MapEntityPrefab.FindByIdentifier("waypoint".ToIdentifier()), newRect, submarine)
+ : this (Type.WayPoint, newRect, submarine)
{
}
- public WayPoint(MapEntityPrefab prefab, Rectangle newRect, Submarine submarine, ushort id = Entity.NullEntityID)
- : base (prefab, submarine, id)
+ public WayPoint(Type type, Rectangle newRect, Submarine submarine, ushort id = Entity.NullEntityID)
+ : base (type is Type.WayPoint
+ ? CoreEntityPrefab.WayPointPrefab
+ : CoreEntityPrefab.SpawnPointPrefab, submarine, id)
{
rect = newRect;
idCardTags = Array.Empty();
@@ -1010,7 +1017,7 @@ namespace Barotrauma
Enum.TryParse(element.GetAttributeString("spawn", "Path"), out SpawnType spawnType);
- WayPoint w = new WayPoint(MapEntityPrefab.FindByIdentifier((spawnType == SpawnType.Path ? "waypoint" : "spawnpoint").ToIdentifier()), rect, submarine, idRemap.GetOffsetId(element))
+ WayPoint w = new WayPoint(spawnType == SpawnType.Path ? Type.WayPoint : Type.SpawnPoint, rect, submarine, idRemap.GetOffsetId(element))
{
spawnType = spawnType
};
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Networking/ChildServerRelay.cs b/Barotrauma/BarotraumaShared/SharedSource/Networking/ChildServerRelay.cs
index b269b2c76..b999e8e54 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Networking/ChildServerRelay.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Networking/ChildServerRelay.cs
@@ -107,7 +107,7 @@ namespace Barotrauma.Networking
return -1;
}
- //FIXME workaround for crash when closing the server under .NET 6.0, not sure if this is the proper way to fix it but it prevents it from crashing the client. - Markus
+ // BUG workaround for crash when closing the server under .NET 6.0, not sure if this is the proper way to fix it but it prevents it from crashing the client. - Markus
#if NET6_0
try
{
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Prefabs/IImplementsVariants.cs b/Barotrauma/BarotraumaShared/SharedSource/Prefabs/IImplementsVariants.cs
index 495b5fd86..e5bf41bca 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Prefabs/IImplementsVariants.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Prefabs/IImplementsVariants.cs
@@ -45,6 +45,12 @@ namespace Barotrauma
bool matchingElementFound = false;
foreach (var subElement in element.Elements())
{
+ if (replacementSubElement.Name.ToString().Equals("clear", StringComparison.OrdinalIgnoreCase))
+ {
+ matchingElementFound = true;
+ elementsToRemove.AddRange(element.Elements());
+ break;
+ }
if (!subElement.Name.ToString().Equals(replacementSubElement.Name.ToString(), StringComparison.OrdinalIgnoreCase)) { continue; }
if (i == index)
{
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Settings/GameSettings.cs b/Barotrauma/BarotraumaShared/SharedSource/Settings/GameSettings.cs
index 5c0e19cfd..368cb94ab 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Settings/GameSettings.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Settings/GameSettings.cs
@@ -161,6 +161,7 @@ namespace Barotrauma
RadialDistortion = true,
InventoryScale = 1.0f,
LightMapScale = 1.0f,
+ VisibleLightLimit = 50,
TextScale = 1.0f,
HUDScale = 1.0f,
Specularity = true,
@@ -200,6 +201,7 @@ namespace Barotrauma
public float HUDScale;
public float InventoryScale;
public float LightMapScale;
+ public int VisibleLightLimit;
public float TextScale;
public bool RadialDistortion;
}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Upgrades/Upgrade.cs b/Barotrauma/BarotraumaShared/SharedSource/Upgrades/Upgrade.cs
index f8d4a1d2d..c193ba8d7 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Upgrades/Upgrade.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Upgrades/Upgrade.cs
@@ -406,23 +406,14 @@ namespace Barotrauma
}
}
- private void Dispose(bool disposing)
+ public void Dispose()
{
if (!Disposed)
{
- if (disposing)
- {
- TargetComponents.Clear();
- }
+ TargetComponents.Clear();
}
Disposed = true;
}
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
}
}
\ No newline at end of file
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Upgrades/UpgradePrefab.cs b/Barotrauma/BarotraumaShared/SharedSource/Upgrades/UpgradePrefab.cs
index 027279c9d..bbb727d01 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Upgrades/UpgradePrefab.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Upgrades/UpgradePrefab.cs
@@ -396,29 +396,20 @@ namespace Barotrauma
return 1;
}
- private void Dispose(bool disposing)
+ public override void Dispose()
{
if (!disposed)
{
- if (disposing)
- {
- Prefabs.Remove(this);
+ Prefabs.Remove(this);
#if CLIENT
- Sprite?.Remove();
- Sprite = null;
- DecorativeSprites.ForEach(sprite => sprite.Remove());
- targetProperties.Clear();
+ Sprite?.Remove();
+ Sprite = null;
+ DecorativeSprites.ForEach(sprite => sprite.Remove());
+ targetProperties.Clear();
#endif
- }
}
disposed = true;
}
-
- public override void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
}
}
\ No newline at end of file
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Utils/NamedEvent.cs b/Barotrauma/BarotraumaShared/SharedSource/Utils/NamedEvent.cs
index 9f0a2f711..3f80b5500 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Utils/NamedEvent.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Utils/NamedEvent.cs
@@ -7,11 +7,6 @@ namespace Barotrauma
{
private readonly Dictionary> events = new Dictionary>();
- ~NamedEvent()
- {
- ReleaseUnmanagedResources();
- }
-
public void Register(Identifier identifier, Action action)
{
if (HasEvent(identifier))
@@ -53,15 +48,9 @@ namespace Barotrauma
}
}
- private void ReleaseUnmanagedResources()
+ public void Dispose()
{
events.Clear();
}
-
- public void Dispose()
- {
- ReleaseUnmanagedResources();
- GC.SuppressFinalize(this);
- }
}
}
\ No newline at end of file
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Utils/SafeIO.cs b/Barotrauma/BarotraumaShared/SharedSource/Utils/SafeIO.cs
index 573e248ab..ea2b7c2e8 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Utils/SafeIO.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Utils/SafeIO.cs
@@ -429,8 +429,8 @@ namespace Barotrauma.IO
public class FileStream : System.IO.Stream
{
- private System.IO.FileStream innerStream;
- private string fileName;
+ private readonly System.IO.FileStream innerStream;
+ private readonly string fileName;
public FileStream(string fn, System.IO.FileStream stream)
{
@@ -496,9 +496,9 @@ namespace Barotrauma.IO
innerStream.Flush();
}
- protected override void Dispose(bool disposing)
+ protected override void Dispose(bool notCalledByFinalizer)
{
- innerStream.Dispose();
+ if (notCalledByFinalizer) { innerStream.Dispose(); }
}
}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/Utils/SaveUtil.cs b/Barotrauma/BarotraumaShared/SharedSource/Utils/SaveUtil.cs
index 365924358..c73f40124 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/Utils/SaveUtil.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/Utils/SaveUtil.cs
@@ -479,7 +479,7 @@ namespace Barotrauma
{
int read = 0;
- // FIXME workaround for .NET6 causing save decompression to fail
+ // BUG workaround for .NET6 causing save decompression to fail
#if NET6_0
for (int i = 0; i < amount; i++)
{
diff --git a/Barotrauma/BarotraumaShared/changelog.txt b/Barotrauma/BarotraumaShared/changelog.txt
index adc356451..ce02ef8f7 100644
--- a/Barotrauma/BarotraumaShared/changelog.txt
+++ b/Barotrauma/BarotraumaShared/changelog.txt
@@ -1,3 +1,57 @@
+---------------------------------------------------------------------------------------------------------
+v0.18.2.0
+---------------------------------------------------------------------------------------------------------
+
+Unstable only:
+- Fixed "submarine equality check failed" errors in non-campaign multiplayer game modes.
+- Fixed occasional crashes when exiting the sub editor.
+- Fixed diving suit lights being on when not worn.
+- Fixed research stations not working.
+- Adjusted the layout of server settings gameplay tab to prevent overlaps on small resolutions.
+- Fixed ignore orders not being loaded correctly in singleplayer.
+
+Changes:
+- Lighting optimization: now some unimportant (dim and small) lights are hidden when there's lots of light sources visible on the screen at the same time. The maximum number of visible lights can be adjusted in the game settings.
+- Lighting optimization: the number of light recalculations per frame is limited, meaning that when there's lots of moving, shadow-casting lights visible, the game doesn't try to recalculate the shadows all at the same time.
+- Lighting optimization: simplify the light rendering when zoomed very far out (e.g. when looking through a periscope).
+- Optimized status effects that modify items' conditions every frame (for example, oxygen tank shelves that fill up oxygen tanks).
+- Hide AppData path from tooltips in the sub editor to prevent exposing the user's name.
+- Reduce nausea chance of energy drink to 25%.
+- Changes to the campaign progression in general.
+- Changes to the level generation parameters, especially in Cold Caverns and the Ridge.
+- Changes to the level resources distribution.
+- Changes to the event manager settings (that affect the monster spawns).
+- Adjusted and normalized the item loadouts for all the jobs.
+- Changes to the items that always spawn with the sub at the beginning of the game (start items).
+- Adjustments to the preferred containers (= where things are spawned and where they should be placed).
+- Changes to the existing missions and how they are distributed. Added new missions.
+- Reduced the costs for unlocking the biomes.
+- Minor adjustments to the monster spawns.
+- Changes to the item "gating". Some items don't appear early in the game anymore.
+- Adjustments to the mission specific variants of the monsters.
+- Added a large Crawler variant for some missions (removed the Swarmcrawler that was used for crawler missions).
+- Halved Mudraptors' priority for eating dead bodies.
+
+Fixes:
+- Fixed abyss area being very small in the Aphotic Plateau, preventing the abyss monster from reaching you if you go deep enough.
+- Fixed status monitor displaying small amounts of water as 1% even though water detectors output 0%.
+- Fixed autopilot conflicting with VELOCITY_IN inputs (now signals override the autopilot for 1 second).
+- Fixed ConversationAction getting interrupted when opening an input-blocking menu in single player.
+- Fixed sprite bleed in chaingun ammunition boxes.
+- Fixed appearance of specific named NPCs being inconsistent (e.g. Captain Hognose sometimes being a woman or not having an eyepatch).
+- Fixed certain scripted events getting stuck if you switch characters in single player (e.g. the events that require you to interact with fliers on the wall).
+- Fixed crashing when the source of a rope is removed (e.g. when a latcher despawns while latched on to the sub).
+- Fixed votes always going through if no-one votes.
+- Fixed energy drink giving x10 more haste when used via the health interface.
+- Fixed the monster spawns for the new game plus not working (currently a placeholder set).
+- Fixed monsters spawning from missions not avoiding the engines.
+
+Modding:
+- Level object, cave and mineral commonness can be defined based on the biome instead of the level generation parameters (= no need to define commonness for "coldcavernsbasic", "coldcavernsmaze" etc separately).
+- Option to define ConversationAction texts directly in the event xml (instead of having to always define them in a spearate text file).
+- Extended CustomInterface functionality with NumberInput elements that allow using float values ("numbertype") and defining the increment size ("step") the number of decimal places ("decimalplaces"). (Thanks, mLuby!)
+- Implemented element for removing all the child elements of an element in a variant file.
+
---------------------------------------------------------------------------------------------------------
v0.18.1.0
---------------------------------------------------------------------------------------------------------