diff --git a/Barotrauma/BarotraumaClient/ClientCode.projitems b/Barotrauma/BarotraumaClient/ClientCode.projitems
index 489043880..ab5b8970a 100644
--- a/Barotrauma/BarotraumaClient/ClientCode.projitems
+++ b/Barotrauma/BarotraumaClient/ClientCode.projitems
@@ -79,8 +79,8 @@
+
-
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs
index c18e14dee..e112d338c 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs
@@ -16,13 +16,14 @@ namespace Barotrauma
if (SelectedAiTarget?.Entity != null)
{
- GUI.DrawLine(spriteBatch, pos, new Vector2(SelectedAiTarget.WorldPosition.X, -SelectedAiTarget.WorldPosition.Y), Color.Red * 0.3f, 0, 5);
+ GUI.DrawLine(spriteBatch, pos, new Vector2(SelectedAiTarget.WorldPosition.X, -SelectedAiTarget.WorldPosition.Y), Color.Red * 0.5f, 0, 4);
if (wallTarget != null)
{
Vector2 wallTargetPos = wallTarget.Position;
+ if (wallTarget.Structure.Submarine != null) { wallTargetPos += wallTarget.Structure.Submarine.Position; }
wallTargetPos.Y = -wallTargetPos.Y;
- GUI.DrawRectangle(spriteBatch, wallTargetPos - new Vector2(10.0f, 10.0f), new Vector2(20.0f, 20.0f), Color.Red, false);
+ GUI.DrawRectangle(spriteBatch, wallTargetPos - new Vector2(10.0f, 10.0f), new Vector2(20.0f, 20.0f), Color.Orange, false);
GUI.DrawLine(spriteBatch, pos, wallTargetPos, Color.Orange * 0.5f, 0, 5);
}
GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 60.0f, $"{SelectedAiTarget.Entity.ToString()} ({targetValue.FormatZeroDecimal()})", Color.Red, Color.Black);
@@ -56,18 +57,16 @@ namespace Barotrauma
{
GUI.DrawLine(spriteBatch,
ConvertUnits.ToDisplayUnits(new Vector2(attachJoint.WorldAnchorA.X, -attachJoint.WorldAnchorA.Y)),
- ConvertUnits.ToDisplayUnits(new Vector2(attachJoint.WorldAnchorB.X, -attachJoint.WorldAnchorB.Y)), Color.Orange * 0.6f, 0, 5);
+ ConvertUnits.ToDisplayUnits(new Vector2(attachJoint.WorldAnchorB.X, -attachJoint.WorldAnchorB.Y)), Color.Green, 0, 4);
}
if (latchOntoAI.WallAttachPos.HasValue)
{
GUI.DrawLine(spriteBatch, pos,
- ConvertUnits.ToDisplayUnits(new Vector2(latchOntoAI.WallAttachPos.Value.X, -latchOntoAI.WallAttachPos.Value.Y)), Color.Orange * 0.6f, 0, 3);
+ ConvertUnits.ToDisplayUnits(new Vector2(latchOntoAI.WallAttachPos.Value.X, -latchOntoAI.WallAttachPos.Value.Y)), Color.Green, 0, 3);
}
}
- GUI.DrawLine(spriteBatch, pos, pos + ConvertUnits.ToDisplayUnits(new Vector2(Steering.X, -Steering.Y)), Color.Blue, width: 3);
-
if (steeringManager is IndoorsSteeringManager pathSteering)
{
var path = pathSteering.CurrentPath;
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs
index d649f7b1a..04cb8c620 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs
@@ -68,14 +68,6 @@ namespace Barotrauma
private float dropItemAnimDuration = 0.5f;
private float dropItemAnimTimer;
-
- public Item DroppedItem
- {
- get
- {
- return droppedItem;
- }
- }
private Item droppedItem;
private GUIComponent draggingMed;
diff --git a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs
index 8bd4315ba..30a90bde2 100644
--- a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs
+++ b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs
@@ -1815,6 +1815,189 @@ namespace Barotrauma
NPCConversation.WriteToCSV();
}));
+ commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) =>
+ {
+ if (args.Length == 0) return;
+ LocalizationCSVtoXML.Convert(args[0]);
+ }));
+#endif
+
+ commands.Add(new Command("cleanbuild", "", (string[] args) =>
+ {
+ float defaultZoom = Screen.Selected.Cam.DefaultZoom;
+ if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom);
+
+ float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness;
+ if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness);
+ float moveSmoothness = Screen.Selected.Cam.MoveSmoothness;
+ if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness);
+
+ float minZoom = Screen.Selected.Cam.MinZoom;
+ if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom);
+ float maxZoom = Screen.Selected.Cam.MaxZoom;
+ if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom);
+
+ Screen.Selected.Cam.DefaultZoom = defaultZoom;
+ Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness;
+ Screen.Selected.Cam.MoveSmoothness = moveSmoothness;
+ Screen.Selected.Cam.MinZoom = minZoom;
+ Screen.Selected.Cam.MaxZoom = maxZoom;
+ }));
+
+ commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) =>
+ {
+ float distortScaleX = 0.5f, distortScaleY = 0.5f;
+ float distortStrengthX = 0.5f, distortStrengthY = 0.5f;
+ float blurAmount = 0.0f;
+ if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX);
+ if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY);
+ if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX);
+ if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY);
+ if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount);
+ WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY);
+ WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY);
+ WaterRenderer.BlurAmount = blurAmount;
+ }));
+
+
+ commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) =>
+ {
+ //TODO: maybe do this automatically during loading when possible?
+ if (Screen.Selected == GameMain.SubEditorScreen)
+ {
+ if (!MapEntity.SelectedAny)
+ {
+ ThrowError("You have to select item(s) first!");
+ }
+ else
+ {
+ foreach (var mapEntity in MapEntity.SelectedList)
+ {
+ if (mapEntity is Item item)
+ {
+ item.Rect = new Rectangle(item.Rect.X, item.Rect.Y,
+ (int)(item.Prefab.sprite.size.X * item.Prefab.Scale),
+ (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale));
+ }
+ else if (mapEntity is Structure structure)
+ {
+ if (!structure.ResizeHorizontal)
+ {
+ structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y,
+ (int)structure.Prefab.ScaledSize.X,
+ structure.Rect.Height);
+ }
+ if (!structure.ResizeVertical)
+ {
+ structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y,
+ structure.Rect.Width,
+ (int)structure.Prefab.ScaledSize.Y);
+ }
+ }
+ }
+ }
+ }
+ }, isCheat: false));
+#endif
+
+ GameMain.Config.SaveNewPlayerConfig();
+
+ commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) =>
+ {
+ string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt";
+ string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml";
+
+ string[] lines;
+ try
+ {
+ lines = File.ReadAllLines(sourcePath);
+ }
+ catch (Exception e)
+ {
+ ThrowError("Reading the file \"" + sourcePath + "\" failed.", e);
+ return;
+ }
+ var doc = XMLExtensions.TryLoadXml(destinationPath);
+ int i = 0;
+ foreach (XElement element in doc.Root.Elements())
+ {
+ if (i >= lines.Length)
+ {
+ ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file.");
+ return;
+ }
+ element.Value = lines[i];
+ i++;
+ }
+ doc.Save(destinationPath);
+ },
+ () =>
+ {
+ var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/"));
+ return new string[][]
+ {
+ files.Where(f => Path.GetExtension(f)==".txt").ToArray(),
+ files.Where(f => Path.GetExtension(f)==".xml").ToArray()
+ };
+ }));
+
+ commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) =>
+ {
+ if (args.Length < 2) return;
+ string sourcePath = args[0];
+ string destinationPath = args[1];
+
+ var sourceDoc = XMLExtensions.TryLoadXml(sourcePath);
+ var destinationDoc = XMLExtensions.TryLoadXml(destinationPath);
+
+ XElement destinationElement = destinationDoc.Root.Elements().First();
+ foreach (XElement element in sourceDoc.Root.Elements())
+ {
+ if (destinationDoc.Root.Element(element.Name) == null)
+ {
+ element.Value = "!!!!!!!!!!!!!" + element.Value;
+ destinationElement.AddAfterSelf(element);
+ }
+ XNode nextNode = destinationElement.NextNode;
+ while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode;
+ destinationElement = nextNode as XElement;
+ }
+ destinationDoc.Save(destinationPath);
+ },
+ () =>
+ {
+ var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray();
+ return new string[][]
+ {
+ files,
+ files
+ };
+ }));
+
+ commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) =>
+ {
+ string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt";
+ List lines = new List();
+ foreach (MapEntityPrefab me in MapEntityPrefab.List)
+ {
+ lines.Add("" + me.Name + "" + me.Identifier + ".Name>");
+ lines.Add("" + me.Description + "" + me.Identifier + ".Description>");
+ }
+ File.WriteAllLines(filePath, lines);
+ }));
+#if DEBUG
+ commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) =>
+ {
+ if (args.Length != 1) return;
+ TextManager.CheckForDuplicates(args[0]);
+ }));
+
+ commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) =>
+ {
+ TextManager.WriteToCSV();
+ NPCConversation.WriteToCSV();
+ }));
+
commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) =>
{
if (args.Length == 0) return;
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs
index dde267edf..cd8a792c0 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs
@@ -69,9 +69,6 @@ namespace Barotrauma
public static ScalableFont Font => Style?.Font;
public static ScalableFont SmallFont => Style?.SmallFont;
public static ScalableFont LargeFont => Style?.LargeFont;
- public static ScalableFont VideoTitleFont => Style?.VideoTitleFont;
- public static ScalableFont ObjectiveTitleFont => Style?.ObjectiveTitleFont;
- public static ScalableFont ObjectiveNameFont => Style?.ObjectiveNameFont;
public static UISprite UIGlow => Style.UIGlow;
@@ -533,19 +530,14 @@ namespace Barotrauma
if (list.Count == 0) { return; }
foreach (var item in list)
{
- int index = 0;
- if (updateList.Count > 0)
+ int i = updateList.Count - 1;
+ while (updateList[i].UpdateOrder > item.UpdateOrder)
{
- index = updateList.Count - 1;
- while (updateList[index].UpdateOrder > item.UpdateOrder)
- {
- index--;
- if (index == 0) { break; }
- }
+ i--;
}
if (!updateListSet.Contains(item))
{
- updateList.Insert(index, item);
+ updateList.Insert(Math.Max(i, 0), item);
updateListSet.Add(item);
}
}
@@ -656,21 +648,6 @@ namespace Barotrauma
msg.Timer -= deltaTime;
msg.Pos += msg.Velocity * deltaTime;
}
-
- foreach (GUIMessage msg in messages)
- {
- if (!msg.WorldSpace) continue;
- msg.Timer -= deltaTime;
- msg.Pos += msg.Velocity * deltaTime;
- }
-
- foreach (GUIMessage msg in messages)
- {
- if (!msg.WorldSpace) continue;
- msg.Timer -= deltaTime;
- msg.Pos += msg.Velocity * deltaTime;
- }
- }
messages.RemoveAll(m => m.Timer <= 0.0f);
}
@@ -744,10 +721,6 @@ namespace Barotrauma
Vector2 textSize = font.MeasureString(text);
DrawRectangle(sb, pos - Vector2.One * backgroundPadding, textSize + Vector2.One * 2.0f * backgroundPadding, (Color)backgroundColor, true);
}
- else
- {
- sb.Draw(t, new Rectangle(rect.X + thickness, rect.Y, rect.Width - thickness * 2, thickness), null, clr, 0.0f, Vector2.Zero, SpriteEffects.None, depth);
- sb.Draw(t, new Rectangle(rect.X + thickness, rect.Y + rect.Height - thickness, rect.Width - thickness * 2, thickness), null, clr, 0.0f, Vector2.Zero, SpriteEffects.None, depth);
font.DrawString(sb, text, pos, color);
}
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs
index 2b3317682..c7f947b4e 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs
@@ -12,9 +12,6 @@ namespace Barotrauma
public ScalableFont Font { get; private set; }
public ScalableFont SmallFont { get; private set; }
public ScalableFont LargeFont { get; private set; }
- public ScalableFont VideoTitleFont { get; private set; }
- public ScalableFont ObjectiveTitleFont { get; private set; }
- public ScalableFont ObjectiveNameFont { get; private set; }
public Sprite CursorSprite { get; private set; }
@@ -51,15 +48,6 @@ namespace Barotrauma
case "largefont":
LargeFont = new ScalableFont(subElement, graphicsDevice);
break;
- case "objectivetitle":
- ObjectiveTitleFont = new ScalableFont(subElement, graphicsDevice);
- break;
- case "objectivename":
- ObjectiveNameFont = new ScalableFont(subElement, graphicsDevice);
- break;
- case "videotitle":
- VideoTitleFont = new ScalableFont(subElement, graphicsDevice);
- break;
case "cursor":
CursorSprite = new Sprite(subElement);
break;
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/HUDLayoutSettings.cs b/Barotrauma/BarotraumaClient/Source/GUI/HUDLayoutSettings.cs
index e395f08c0..199cdb9d6 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/HUDLayoutSettings.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/HUDLayoutSettings.cs
@@ -50,11 +50,6 @@ namespace Barotrauma
get; private set;
}
- public static Rectangle ObjectiveAnchor
- {
- get; private set;
- }
-
public static Rectangle InventoryAreaLower
{
get; private set;
@@ -161,10 +156,6 @@ namespace Barotrauma
new Rectangle(Padding, CrewArea.Y, chatBoxWidth, chatBoxHeight) :
new Rectangle(GameMain.GraphicsWidth - Padding - chatBoxWidth, CrewArea.Y, chatBoxWidth, chatBoxHeight);
- int objectiveAnchorWidth = (int)(250 * GUI.Scale);
- int objectiveAnchorOffsetY = (int)(100 * GUI.Scale);
- ObjectiveAnchor = new Rectangle(GameMain.GraphicsWidth - Padding - objectiveAnchorWidth, CrewArea.Y + crewAreaHeight + objectiveAnchorOffsetY, objectiveAnchorWidth, 0);
-
int lowerAreaHeight = (int)Math.Min(GameMain.GraphicsHeight * 0.25f, 280);
InventoryAreaLower = new Rectangle(Padding, GameMain.GraphicsHeight - lowerAreaHeight, GameMain.GraphicsWidth - Padding * 2, lowerAreaHeight);
diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/SinglePlayerCampaign.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/SinglePlayerCampaign.cs
index b4a7414e3..01caedf9e 100644
--- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/SinglePlayerCampaign.cs
+++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/SinglePlayerCampaign.cs
@@ -44,7 +44,7 @@ namespace Barotrauma
ContextualTutorial = Tutorial.Tutorials.Find(t => t is ContextualTutorial) as ContextualTutorial;
- if (ContextualTutorial.Selected) // Selected when starting a new game -> initialize
+ if (ContextualTutorial.Selected && !ContextualTutorial.Initialized) // Selected when starting a new game -> initialize
{
ContextualTutorial.Initialize();
}
diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/ContextualTutorial.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/ContextualTutorial.cs
index cecb20c28..843b7566e 100644
--- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/ContextualTutorial.cs
+++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/ContextualTutorial.cs
@@ -1,10 +1,9 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Xml.Linq;
using System;
using Microsoft.Xna.Framework;
using Barotrauma.Items.Components;
using System.Linq;
-using Microsoft.Xna.Framework.Input;
namespace Barotrauma.Tutorials
{
@@ -14,60 +13,38 @@ namespace Barotrauma.Tutorials
public static bool ContentRunning = false;
public static bool Initialized = false;
- private enum ContentTypes { None = 0, Video = 1, TextOnly = 2 };
+ private enum ContentTypes { None = 0, Video = 1, Text = 2 };
private TutorialSegment activeSegment;
private List segments;
-
- private VideoPlayer videoPlayer;
+ private SpriteSheetPlayer spriteSheetPlayer;
private Steering navConsole;
private Reactor reactor;
private Sonar sonar;
private Vector2 subStartingPosition;
private List crew;
- private Character mechanic;
- private Character engineer;
- private Character injuredMember = null;
-
private List> characterTimeOnSonar;
private float requiredTimeOnSonar = 5f;
private bool started = false;
private string playableContentPath;
-
+
private float tutorialTimer;
+ private float degrading2ActivationCountdown;
private bool disableTutorialOnDeficiencyFound = true;
- private GUIFrame holderFrame, objectiveFrame;
- //private GUIButton toggleButton;
- //private bool objectivesOpen = false;
- //private float openState = 0f;
- private List activeObjectives = new List();
- private string objectiveTranslated;
- //private Point objectiveBaseOffset = Point.Zero;
-
- private float floodTutorialTimer = 0.0f;
- private const float floodTutorialDelay = 2.0f;
- private float medicalTutorialTimer = 0.0f;
- private const float medicalTutorialDelay = 2.0f;
-
private class TutorialSegment
{
- public string Id;
- public string Objective;
+ public string Name;
public ContentTypes ContentType;
- public XElement TextContent;
- public XElement VideoContent;
+ public XElement Content;
public bool IsTriggered;
- public GUIButton ReplayButton;
- public GUITextBlock LinkedTitle, LinkedText;
public TutorialSegment(XElement config)
{
- Id = config.GetAttributeString("id", "Missing ID");
- Objective = TextManager.Get(config.GetAttributeString("objective", string.Empty), true);
+ Name = config.GetAttributeString("name", "Missing Name");
Enum.TryParse(config.GetAttributeString("contenttype", "None"), true, out ContentType);
IsTriggered = config.GetAttributeBool("istriggered", false);
@@ -76,11 +53,10 @@ namespace Barotrauma.Tutorials
case ContentTypes.None:
break;
case ContentTypes.Video:
- VideoContent = config.Element("Video");
- TextContent = config.Element("Text");
+ Content = config.Element("Video");
break;
- case ContentTypes.TextOnly:
- TextContent = config.Element("Text");
+ case ContentTypes.Text:
+ Content = config.Element("Text");
break;
}
}
@@ -101,18 +77,17 @@ namespace Barotrauma.Tutorials
public override void Initialize()
{
- for (int i = 0; i < segments.Count; i++)
- {
- segments[i].IsTriggered = false;
- }
-
if (Initialized) return;
Initialized = true;
base.Initialize();
- videoPlayer = new VideoPlayer();
+ spriteSheetPlayer = new SpriteSheetPlayer();
characterTimeOnSonar = new List>();
- //objectivesOpen = true;
+
+ for (int i = 0; i < segments.Count; i++)
+ {
+ segments[i].IsTriggered = false;
+ }
}
public void LoadPartiallyComplete(XElement element)
@@ -136,13 +111,13 @@ namespace Barotrauma.Tutorials
}
}
- private void PreloadVideoContent() // Have to see if needed with videos
+ private void PreloadVideoContent()
{
- /*for (int i = 0; i < segments.Count; i++)
+ for (int i = 0; i < segments.Count; i++)
{
if (segments[i].ContentType != ContentTypes.Video || segments[i].IsTriggered) continue;
- spriteSheetPlayer.PreloadContent(playableContentPath, "tutorial", segments[i].Id, segments[i].VideoContent);
- }*/
+ spriteSheetPlayer.PreloadContent(playableContentPath, "tutorial", segments[i].Name, segments[i].Content);
+ }
}
public void SavePartiallyComplete(XElement element)
@@ -180,12 +155,9 @@ namespace Barotrauma.Tutorials
base.Start();
- injuredMember = null;
- activeObjectives.Clear();
- objectiveTranslated = TextManager.Get("Objective");
- CreateObjectiveFrame();
activeSegment = null;
- tutorialTimer = floodTutorialTimer = medicalTutorialTimer = 0.0f;
+ tutorialTimer = 0.0f;
+ degrading2ActivationCountdown = -1;
subStartingPosition = Vector2.Zero;
characterTimeOnSonar.Clear();
@@ -221,9 +193,6 @@ namespace Barotrauma.Tutorials
}
crew = GameMain.GameSession.CrewManager.GetCharacters().ToList();
- mechanic = CrewMemberWithJob("mechanic");
- engineer = CrewMemberWithJob("engineer");
-
Completed = true; // Trigger completed at start to prevent the contextual tutorial from automatically activating on starting new campaigns after this one
started = true;
}
@@ -239,196 +208,71 @@ namespace Barotrauma.Tutorials
public void Stop()
{
started = ContentRunning = Initialized = false;
- videoPlayer.Remove();
- videoPlayer = null;
+ spriteSheetPlayer.Remove();
+ spriteSheetPlayer = null;
characterTimeOnSonar = null;
}
- private void CreateObjectiveFrame()
- {
- holderFrame = new GUIFrame(new RectTransform(new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight), GUI.Canvas, Anchor.Center));
- objectiveFrame = new GUIFrame(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.ObjectiveAnchor, holderFrame.RectTransform), style: null);
-
- /*int toggleButtonWidth = (int)(30 * GUI.Scale);
- int toggleButtonHeight = (int)(40 * GUI.Scale);
- toggleButton = new GUIButton(new RectTransform(new Point(toggleButtonWidth, toggleButtonHeight), objectiveFrame.RectTransform, Anchor.CenterRight) { AbsoluteOffset = new Point(0, 20) }, style: "UIToggleButton");
- toggleButton.OnClicked += (GUIButton btn, object userdata) =>
- {
- objectivesOpen = !objectivesOpen;
- foreach (GUIComponent child in btn.Children)
- {
- child.SpriteEffects = objectivesOpen ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
- }
- return true;
- };
-
- objectiveBaseOffset = new Point((int)(-2.5f * toggleButton.Rect.Width), 0);*/
- }
-
public override void AddToGUIUpdateList()
{
- if (objectiveFrame != null && activeObjectives.Count > 0)
- {
- objectiveFrame.AddToGUIUpdateList(order: -1);
- }
base.AddToGUIUpdateList();
- if (videoPlayer != null)
+ if (spriteSheetPlayer != null)
{
- videoPlayer.AddToGUIUpdateList(order: 100);
+ spriteSheetPlayer.AddToGUIUpdateList();
}
}
public override void Update(float deltaTime)
{
- if (videoPlayer != null)
- {
- videoPlayer.Update();
- }
-
- if (infoBox != null)
- {
- if (PlayerInput.KeyHit(Keys.Enter) || PlayerInput.KeyHit(Keys.Escape))
- {
- CloseInfoFrame(null, null);
- }
- }
-
if (!started || ContentRunning) return;
deltaTime *= 0.5f;
-
+
for (int i = 0; i < segments.Count; i++)
{
- if (segments[i].IsTriggered || activeObjectives.Contains(segments[i])) continue;
+ if (segments[i].IsTriggered) continue;
if (CheckContextualTutorials(i, deltaTime)) // Found a relevant tutorial, halt finding new ones
{
break;
}
}
-
- for (int i = 0; i < activeObjectives.Count; i++)
- {
- CheckActiveObjectives(activeObjectives[i], deltaTime);
- }
-
- /*if (activeObjectives.Count > 0)
- {
- if (objectivesOpen)
- {
- openState -= deltaTime * 5.0f;
- }
- else
- {
- openState += deltaTime * 5.0f;
- }
-
- openState = MathHelper.Clamp(openState, 0.0f, 1.0f);
-
- float widestObjective = 0f;
- for (int i = 0; i < activeObjectives.Count; i++)
- {
- if (activeObjectives[i].ReplayButton.Rect.Width > widestObjective)
- {
- widestObjective = activeObjectives[i].ReplayButton.Rect.Width;
- }
- }
-
- float objectivesHiddenOffset = widestObjective + toggleButton.Rect.Width + 100f;
-
- for (int i = 0; i < activeObjectives.Count; i++)
- {
- activeObjectives[i].ReplayButton.RectTransform.AbsoluteOffset = objectiveBaseOffset + new Point((int)MathHelper.SmoothStep(0, objectivesHiddenOffset, openState), 0);
- }
- }*/
- }
-
- private void ClosePreTextAndTriggerVideoCallback()
- {
- if (!string.IsNullOrEmpty(activeSegment.Objective))
- {
- videoPlayer.LoadContentWithObjective(playableContentPath, new VideoPlayer.VideoSettings(activeSegment.VideoContent), new VideoPlayer.TextSettings(activeSegment.VideoContent), activeSegment.Id, true, activeSegment.Objective, CurrentSegmentStopCallback);
- }
- else
- {
- videoPlayer.LoadContent(playableContentPath, new VideoPlayer.VideoSettings(activeSegment.VideoContent), new VideoPlayer.TextSettings(activeSegment.VideoContent), activeSegment.Id, true, CurrentSegmentStopCallback);
- }
}
private void CurrentSegmentStopCallback()
{
- if (!string.IsNullOrEmpty(activeSegment.Objective))
- {
- AddNewObjective(activeSegment);
- }
-
activeSegment = null;
ContentRunning = false;
}
- private void AddNewObjective(TutorialSegment segment)
- {
- activeObjectives.Add(segment);
-
- Point replayButtonSize = new Point((int)GUI.ObjectiveNameFont.MeasureString(segment.Objective).X, (int)(GUI.ObjectiveNameFont.MeasureString(segment.Objective).Y * 1.45f));
-
- segment.ReplayButton = new GUIButton(new RectTransform(replayButtonSize, objectiveFrame.RectTransform, Anchor.TopRight, Pivot.TopRight) { AbsoluteOffset = new Point(/*(int)(-2.5f * toggleButton.Rect.Width)*/0, (replayButtonSize.Y + 20) * (activeObjectives.Count - 1)) }, style: null);
- segment.ReplayButton.OnClicked += (GUIButton btn, object userdata) =>
- {
- ReplaySegmentVideo(segment);
- return true;
- };
-
- int yOffset = (int)(GUI.ObjectiveNameFont.MeasureString(objectiveTranslated).Y / 2f) + 5;
- segment.LinkedTitle = new GUITextBlock(new RectTransform(new Point(replayButtonSize.X, yOffset), segment.ReplayButton.RectTransform, Anchor.Center, Pivot.BottomCenter) { AbsoluteOffset = new Point(10, 0) }, objectiveTranslated, textColor: Color.White, font: GUI.ObjectiveTitleFont, textAlignment: Alignment.CenterRight);
- segment.LinkedText = new GUITextBlock(new RectTransform(new Point(replayButtonSize.X, yOffset), segment.ReplayButton.RectTransform, Anchor.Center, Pivot.TopCenter) { AbsoluteOffset = new Point(10, 0) }, segment.Objective, textColor: new Color(4, 180, 108), font: GUI.ObjectiveNameFont, textAlignment: Alignment.CenterRight);
-
- segment.LinkedTitle.Color = segment.LinkedTitle.HoverColor = segment.LinkedTitle.PressedColor = segment.LinkedTitle.SelectedColor = Color.Transparent;
- segment.LinkedText.Color = segment.LinkedText.HoverColor = segment.LinkedText.PressedColor = segment.LinkedText.SelectedColor = Color.Transparent;
- segment.ReplayButton.Color = segment.ReplayButton.HoverColor = segment.ReplayButton.PressedColor = segment.ReplayButton.SelectedColor = Color.Transparent;
- }
-
- private void RemoveCompletedObjective(TutorialSegment objective)
- {
- objectiveFrame.RemoveChild(objective.ReplayButton);
- activeObjectives.Remove(objective);
- objective.IsTriggered = true;
-
- for (int i = 0; i < activeObjectives.Count; i++)
- {
- activeObjectives[i].ReplayButton.RectTransform.AbsoluteOffset = new Point(0, (activeObjectives[i].ReplayButton.Rect.Height + 20) * i);
- }
- }
-
private bool CheckContextualTutorials(int index, float deltaTime)
{
switch (index)
{
case 0: // Welcome: Game Start [Text]
- if (tutorialTimer < 1.0f)
+ if (tutorialTimer < 0.5f)
{
tutorialTimer += deltaTime;
return false;
}
break;
- case 1: // Command Reactor: 2 seconds after 'Welcome' dismissed and only if no command given to start reactor [Video]
- if (!segments[0].IsTriggered) return false;
- if (tutorialTimer < 3.0f)
+ case 1: // Command Reactor: 10 seconds after 'Welcome' dismissed and only if no command given to start reactor [Video]
+ if (tutorialTimer < 10.5f)
{
tutorialTimer += deltaTime;
if (HasOrder("operatereactor"))
{
segments[index].IsTriggered = true;
- tutorialTimer = 2.5f;
+ tutorialTimer = 10.5f;
}
return false;
}
break;
- case 2: // Nav Console: 2 seconds after 'Command Reactor' dismissed or if nav console is activated [Video]
- if (!IsReactorPoweredUp()) return false; // Do not advance tutorial based on this segment if reactor has not been powered up
+ case 2: // Nav Console: 20 seconds after 'Command Reactor' dismissed or if nav console is activated [Video]
if (Character.Controlled?.SelectedConstruction != navConsole.Item)
- {
- if (tutorialTimer < 4.5f)
+ {
+ if (!segments[1].IsTriggered) return false; // Do not advance tutorial timer based on this segment if reactor has not been powered up
+ if (tutorialTimer < 30.5f)
{
tutorialTimer += deltaTime;
return false;
@@ -436,13 +280,20 @@ namespace Barotrauma.Tutorials
}
else
{
- tutorialTimer = 4.5f;
- }
+ if (!segments[1].IsTriggered || !HasOrder("operatereactor")) // If reactor has not been powered up or ordered to be, default to that one first
+ {
+ if (tutorialTimer < 10.5f)
+ {
+ tutorialTimer = 10.5f;
+ }
+ return false;
+ }
- TriggerTutorialSegment(index, GameMain.GameSession.EndLocation.Name);
- return true;
+ tutorialTimer = 30.5f;
+ }
+ break;
case 3: // Objective: Travel ~150 meters and while sub is not flooding [Text]
- if (Vector2.Distance(subStartingPosition, Submarine.MainSub.WorldPosition) < 8000f || IsFlooding())
+ if (Vector2.Distance(subStartingPosition, Submarine.MainSub.WorldPosition) < 12000f || IsFlooding())
{
return false;
}
@@ -456,11 +307,6 @@ namespace Barotrauma.Tutorials
{
return false;
}
- else if (floodTutorialTimer < floodTutorialDelay)
- {
- floodTutorialTimer += deltaTime;
- return false;
- }
break;
case 5: // Reactor: Player uses reactor for the first time [Video]
if (Character.Controlled?.SelectedConstruction != reactor.Item)
@@ -475,23 +321,19 @@ namespace Barotrauma.Tutorials
}
break;
case 7: // Degrading1: Any equipment degrades to 50% health or less and player has not assigned any crew to perform maintenance [Text]
- if ((mechanic == null || mechanic.IsDead) && (engineer == null || engineer.IsDead)) // Both engineer and mechanic are dead or do not exist -> do not display
- {
- return false;
- }
-
bool degradedEquipmentFound = false;
foreach (Item item in Item.ItemList)
{
- if (!item.Repairables.Any() || item.Condition > 50.0f) continue;
+ if (!item.Repairables.Any() || item.ConditionPercentage > 50) continue;
degradedEquipmentFound = true;
break;
}
if (degradedEquipmentFound)
{
- if (HasOrder("repairsystems", "jobspecific"))
+ degrading2ActivationCountdown = 5f;
+ if (HasOrder("repairsystems"))
{
segments[index].IsTriggered = true;
return false;
@@ -502,44 +344,43 @@ namespace Barotrauma.Tutorials
return false;
}
break;
- case 8: // Medical: Crewmember is injured but not killed [Video]
-
- if (injuredMember == null)
+ case 8: // Degrading2: 5 seconds after 'Degrading1' dismissed, and only if player has not assigned any crew to perform maintenance [Video]
+ if (degrading2ActivationCountdown == -1f)
{
- for (int i = 0; i < crew.Count; i++)
+ return false;
+ }
+ else if (degrading2ActivationCountdown > 0.0f)
+ {
+ degrading2ActivationCountdown -= deltaTime;
+ if (HasOrder("repairsystems"))
{
- Character member = crew[i];
- if (member.Vitality < member.MaxVitality && !member.IsDead)
- {
- injuredMember = member;
- break;
- }
+ segments[index].IsTriggered = true;
}
return false;
}
- else if (medicalTutorialTimer < medicalTutorialDelay)
+ break;
+ case 9: // Medical: Crewmember is injured but not killed [Video]
+ bool injuredFound = false;
+ for (int i = 0; i < crew.Count; i++)
{
- medicalTutorialTimer += deltaTime;
- return false;
+ Character member = crew[i];
+ if (member.Vitality < member.MaxVitality && !member.IsDead)
+ {
+ injuredFound = true;
+ break;
+ }
}
- else
- {
- TriggerTutorialSegment(index, new string[] { injuredMember.Info.DisplayName,
- (injuredMember.Info.Gender == Gender.Male) ? TextManager.Get("PronounPossessiveMale").ToLower() : TextManager.Get("PronounPossessiveFemale").ToLower() });
- return true;
- }
- case 9: // Approach1: Destination is within ~100m [Video]
+
+ if (!injuredFound) return false;
+ break;
+ case 10: // Approach1: Destination is within ~100m [Video]
if (Vector2.Distance(Submarine.MainSub.WorldPosition, Level.Loaded.EndPosition) > 8000f)
{
return false;
}
- else
- {
- TriggerTutorialSegment(index, GameMain.GameSession.EndLocation.Name);
- return true;
- }
- case 10: // Approach2: Sub is docked [Text]
+ break;
+ case 11: // Approach2: Sub is docked [Text]
if (!Submarine.MainSub.AtEndPosition || Submarine.MainSub.DockedTo.Count == 0)
{
return false;
@@ -551,128 +392,11 @@ namespace Barotrauma.Tutorials
return true;
}
- private bool HasObjective(string objectiveName)
- {
- for (int i = 0; i < activeObjectives.Count; i++)
- {
- if (activeObjectives[i].Id == objectiveName) return true;
- }
-
- return false;
- }
-
- private void CheckActiveObjectives(TutorialSegment objective, float deltaTime)
- {
- switch(objective.Id)
- {
- case "ReactorCommand": // Reactor commanded
- if (!IsReactorPoweredUp())
- {
- if (!HasOrder("operatereactor")) return;
- }
- break;
- case "NavConsole": // traveled 50 meters
- if (Vector2.Distance(subStartingPosition, Submarine.MainSub.WorldPosition) < 4000f)
- {
- return;
- }
- break;
- case "Flood": // Hull breaches repaired
- if (IsFlooding()) return;
- break;
- case "Medical":
- if (injuredMember != null && !injuredMember.IsDead)
- {
- if (injuredMember.CharacterHealth.DroppedItem == null) return;
- }
- break;
- case "EnemyOnSonar": // Enemy dispatched
- if (HasEnemyOnSonarForDuration(deltaTime))
- {
- return;
- }
- break;
- case "Degrading": // Fixed
- if (mechanic != null && !mechanic.IsDead)
- {
- HumanAIController humanAI = mechanic.AIController as HumanAIController;
- if (mechanic.CurrentOrder?.AITag != "repairsystems" || humanAI.CurrentOrderOption != "jobspecific")
- {
- return;
- }
- }
-
- if (engineer != null && !engineer.IsDead)
- {
- HumanAIController humanAI = engineer.AIController as HumanAIController;
- if (engineer.CurrentOrder?.AITag != "repairsystems" || humanAI.CurrentOrderOption != "jobspecific")
- {
- return;
- }
- }
-
- break;
- case "Approach1": // Wait until docked
- if (!Submarine.MainSub.AtEndPosition || Submarine.MainSub.DockedTo.Count == 0)
- {
- return;
- }
- break;
- }
-
- RemoveCompletedObjective(objective);
- }
-
- private bool IsReactorPoweredUp()
- {
- float load = 0.0f;
- List connections = reactor.Item.Connections;
- if (connections != null && connections.Count > 0)
- {
- foreach (Connection connection in connections)
- {
- if (!connection.IsPower) continue;
- foreach (Connection recipient in connection.Recipients)
- {
- if (!(recipient.Item is Item it)) continue;
-
- PowerTransfer pt = it.GetComponent();
- if (pt == null) continue;
-
- load = Math.Max(load, pt.PowerLoad);
- }
- }
- }
-
- return Math.Abs(load + reactor.CurrPowerConsumption) < 10;
- }
-
- private Character CrewMemberWithJob(string job)
+ private bool HasOrder(string aiTag)
{
for (int i = 0; i < crew.Count; i++)
{
- if (crew[i].Info.Job.Name == job) return crew[i];
- }
-
- return null;
- }
-
- private bool HasOrder(string aiTag, string option = null)
- {
- for (int i = 0; i < crew.Count; i++)
- {
- if (crew[i].CurrentOrder?.AITag == aiTag)
- {
- if (option == null)
- {
- return true;
- }
- else
- {
- HumanAIController humanAI = crew[i].AIController as HumanAIController;
- return humanAI.CurrentOrderOption == option;
- }
- }
+ if (crew[i].CurrentOrder?.AITag == aiTag) return true;
}
return false;
@@ -723,51 +447,27 @@ namespace Barotrauma.Tutorials
}
}
- return characterTimeOnSonar.Find(ct => ct.Second >= requiredTimeOnSonar && !ct.First.IsDead) != null;
+ return characterTimeOnSonar.Find(ct => ct.Second >= requiredTimeOnSonar) != null;
}
private void TriggerTutorialSegment(int index, params object[] args)
{
- Inventory.draggingItem = null;
ContentRunning = true;
activeSegment = segments[index];
-
- string tutorialText = TextManager.GetFormatted(activeSegment.TextContent.GetAttributeString("tag", ""), true, args);
- string objectiveText = string.Empty;
-
- if (!string.IsNullOrEmpty(activeSegment.Objective))
- {
- if (args.Length == 0)
- {
- objectiveText = activeSegment.Objective;
- }
- else
- {
- objectiveText = string.Format(activeSegment.Objective, args);
- }
-
- activeSegment.Objective = objectiveText;
- }
- else
- {
- activeSegment.IsTriggered = true; // Complete at this stage only if no related objective
- }
+ activeSegment.IsTriggered = true;
switch (activeSegment.ContentType)
{
case ContentTypes.None:
break;
case ContentTypes.Video:
- infoBox = CreateInfoFrame(TextManager.Get(activeSegment.Id), tutorialText,
- activeSegment.TextContent.GetAttributeInt("width", 300),
- activeSegment.TextContent.GetAttributeInt("height", 80),
- activeSegment.TextContent.GetAttributeString("anchor", "Center"), true, ClosePreTextAndTriggerVideoCallback);
+ spriteSheetPlayer.LoadContent(playableContentPath, activeSegment.Content, activeSegment.Name, true, true, CurrentSegmentStopCallback);
break;
- case ContentTypes.TextOnly:
- infoBox = CreateInfoFrame(TextManager.Get(activeSegment.Id), tutorialText,
- activeSegment.TextContent.GetAttributeInt("width", 300),
- activeSegment.TextContent.GetAttributeInt("height", 80),
- activeSegment.TextContent.GetAttributeString("anchor", "Center"), true, CurrentSegmentStopCallback);
+ case ContentTypes.Text:
+ infoBox = CreateInfoFrame(TextManager.Get(activeSegment.Name), TextManager.GetFormatted(activeSegment.Content.GetAttributeString("tag", ""), false, args),
+ activeSegment.Content.GetAttributeInt("width", 300),
+ activeSegment.Content.GetAttributeInt("height", 80),
+ activeSegment.Content.GetAttributeString("anchor", "Center"), true, CurrentSegmentStopCallback);
break;
}
@@ -779,13 +479,6 @@ namespace Barotrauma.Tutorials
CoroutineManager.StartCoroutine(WaitToStop()); // Completed
}
- private void ReplaySegmentVideo(TutorialSegment segment)
- {
- if (ContentRunning) return;
- ContentRunning = true;
- videoPlayer.LoadContent(playableContentPath, new VideoPlayer.VideoSettings(segment.VideoContent), new VideoPlayer.TextSettings(segment.VideoContent), segment.Id, true, () => ContentRunning = false);
- }
-
private IEnumerable