(7765c6989) Only show a bunch of pathfinder errors and warnings in debug builds.

This commit is contained in:
Joonas Rikkonen
2019-05-16 05:57:22 +03:00
parent 18a58a313b
commit f8ca1444fd
30 changed files with 529 additions and 357 deletions
@@ -152,6 +152,32 @@ namespace Barotrauma
} }
if (character.MemLocalState.Count > 120) character.MemLocalState.RemoveRange(0, character.MemLocalState.Count - 120);
character.MemState.Clear();
}
}
partial void ImpactProjSpecific(float impact, Body body)
{
float volume = MathHelper.Clamp(impact - 3.0f, 0.5f, 1.0f);
if (body.UserData is Limb limb && character.Stun <= 0f)
{
if (impact > 3.0f) { PlayImpactSound(limb); }
}
else if (body.UserData is Limb || body == Collider.FarseerBody)
{
if (!character.IsRemotePlayer && impact > ImpactTolerance)
{
SoundPlayer.PlayDamageSound("LimbBlunt", strongestImpact, Collider);
}
}
if (Character.Controlled == character)
{
GameMain.GameScreen.Cam.Shake = Math.Min(Math.Max(strongestImpact, GameMain.GameScreen.Cam.Shake), 3.0f);
}
}
if (character.MemState.Count < 1) return; if (character.MemState.Count < 1) return;
overrideTargetMovement = Vector2.Zero; overrideTargetMovement = Vector2.Zero;
@@ -9,11 +9,9 @@ namespace Barotrauma
public class GUIMessageBox : GUIFrame public class GUIMessageBox : GUIFrame
{ {
public static List<GUIComponent> MessageBoxes = new List<GUIComponent>(); public static List<GUIComponent> MessageBoxes = new List<GUIComponent>();
private static int DefaultWidth
{
get { return Math.Max(400, 400 * (GameMain.GraphicsWidth / 1920)); }
}
public const int DefaultWidth = 400, DefaultHeight = 250;
public List<GUIButton> Buttons { get; private set; } = new List<GUIButton>(); public List<GUIButton> Buttons { get; private set; } = new List<GUIButton>();
//public GUIFrame BackgroundFrame { get; private set; } //public GUIFrame BackgroundFrame { get; private set; }
public GUILayoutGroup Content { get; private set; } public GUILayoutGroup Content { get; private set; }
@@ -23,31 +21,23 @@ namespace Barotrauma
public string Tag { get; private set; } public string Tag { get; private set; }
public static GUIComponent VisibleBox => MessageBoxes.LastOrDefault(); public static GUIComponent VisibleBox => MessageBoxes.LastOrDefault();
public GUIMessageBox(string headerText, string text, Vector2? relativeSize = null, Point? minSize = null) public GUIMessageBox(string headerText, string text)
: this(headerText, text, new string[] { "OK" }, relativeSize, minSize) : this(headerText, text, new string[] {"OK"}, DefaultWidth, 0)
{ {
this.Buttons[0].OnClicked = Close; this.Buttons[0].OnClicked = Close;
} }
public GUIMessageBox(string headerText, string text, string[] buttons, Vector2? relativeSize = null, Point? minSize = null, Alignment textAlignment = Alignment.TopLeft, string tag = "") public GUIMessageBox(string headerText, string text, int width, int height)
: this(headerText, text, new string[] { "OK" }, width, height)
{
this.Buttons[0].OnClicked = Close;
}
// TODO: allow to use a relative size.
public GUIMessageBox(string headerText, string text, string[] buttons, int width = DefaultWidth, int height = 0, Alignment textAlignment = Alignment.TopLeft, string tag = "")
: base(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: "") : base(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: "")
{ {
int width = DefaultWidth, height = 0;
if (relativeSize.HasValue)
{
width = (int)(GameMain.GraphicsWidth * relativeSize.Value.X);
height = (int)(GameMain.GraphicsHeight * relativeSize.Value.Y);
}
if (minSize.HasValue)
{
width = Math.Max(width, minSize.Value.X);
if (height > 0)
{
height = Math.Max(height, minSize.Value.Y);
}
}
InnerFrame = new GUIFrame(new RectTransform(new Point(width, height), RectTransform, Anchor.Center) { IsFixedSize = false }, style: null); InnerFrame = new GUIFrame(new RectTransform(new Point(width, height), RectTransform, Anchor.Center) { IsFixedSize = false }, style: null);
GUI.Style.Apply(InnerFrame, "", this); GUI.Style.Apply(InnerFrame, "", this);
@@ -59,7 +49,7 @@ namespace Barotrauma
GUI.Style.Apply(Header, "", this); GUI.Style.Apply(Header, "", this);
Header.RectTransform.MinSize = new Point(0, Header.Rect.Height); Header.RectTransform.MinSize = new Point(0, Header.Rect.Height);
if (height == 0) if (!string.IsNullOrWhiteSpace(text))
{ {
Text = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), Content.RectTransform), Text = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), Content.RectTransform),
text, textAlignment: textAlignment, wrap: true); text, textAlignment: textAlignment, wrap: true);
@@ -84,11 +74,7 @@ namespace Barotrauma
height += Header.Rect.Height + Content.AbsoluteSpacing; height += Header.Rect.Height + Content.AbsoluteSpacing;
height += (Text == null ? 0 : Text.Rect.Height) + Content.AbsoluteSpacing; height += (Text == null ? 0 : Text.Rect.Height) + Content.AbsoluteSpacing;
height += buttonContainer.Rect.Height; height += buttonContainer.Rect.Height;
if (minSize.HasValue)
{
height = Math.Max(height, minSize.Value.Y);
}
InnerFrame.RectTransform.NonScaledSize = InnerFrame.RectTransform.NonScaledSize =
new Point(InnerFrame.Rect.Width, (int)Math.Max(height / Content.RectTransform.RelativeSize.Y, height + 50)); new Point(InnerFrame.Rect.Width, (int)Math.Max(height / Content.RectTransform.RelativeSize.Y, height + 50));
Content.RectTransform.NonScaledSize = Content.RectTransform.NonScaledSize =
@@ -18,38 +18,21 @@ namespace Barotrauma
private Sprite languageSelectionCursor; private Sprite languageSelectionCursor;
private ScalableFont languageSelectionFont; private ScalableFont languageSelectionFont;
private Video currSplashScreen; private Video splashScreen;
private DateTime videoStartTime; public Video SplashScreen
private Queue<Pair<string, Point>> pendingSplashScreens = new Queue<Pair<string, Point>>();
/// <summary>
/// Pair.first = filepath, Pair.second = resolution
/// </summary>
public Queue<Pair<string, Point>> PendingSplashScreens
{ {
get get
{ {
lock (loadMutex) lock (loadMutex)
{ {
return pendingSplashScreens; return splashScreen;
} }
} }
set set
{ {
lock (loadMutex) lock (loadMutex)
{ {
pendingSplashScreens = value; splashScreen = value;
}
}
}
public bool PlayingSplashScreen
{
get
{
lock (loadMutex)
{
return currSplashScreen != null;
} }
} }
} }
@@ -117,8 +100,8 @@ namespace Barotrauma
{ {
try try
{ {
DrawSplashScreen(spriteBatch, graphics); DrawSplashScreen(spriteBatch);
if (currSplashScreen != null || PendingSplashScreens.Count > 0) { return; } if (SplashScreen != null && SplashScreen.IsPlaying) return;
} }
catch (Exception e) catch (Exception e)
{ {
@@ -218,77 +201,46 @@ namespace Barotrauma
{ {
if (languageSelectionFont == null) if (languageSelectionFont == null)
{ {
languageSelectionFont = new ScalableFont("Content/Fonts/BebasNeue-Regular.otf", (uint)(30 * (GameMain.GraphicsHeight / 1080.0f)), graphicsDevice); languageSelectionFont = new ScalableFont("Content/Fonts/BebasNeue-Regular.otf", 28, graphicsDevice);
} }
if (languageSelectionCursor == null) if (languageSelectionCursor == null)
{ {
languageSelectionCursor = new Sprite("Content/UI/cursor.png", Vector2.Zero); languageSelectionCursor = new Sprite("Content/UI/cursor.png", Vector2.Zero);
} }
Vector2 textPos = new Vector2(GameMain.GraphicsWidth / 2, GameMain.GraphicsHeight * 0.3f); Vector2 textPos = new Vector2(GameMain.GraphicsWidth / 2, GameMain.GraphicsHeight * 0.25f);
Vector2 textSpacing = new Vector2(0.0f, (GameMain.GraphicsHeight * 0.5f) / TextManager.AvailableLanguages.Count()); Vector2 textSpacing = new Vector2(0.0f, (GameMain.GraphicsHeight * 0.5f) / TextManager.AvailableLanguages.Count());
foreach (string language in TextManager.AvailableLanguages) foreach (string language in TextManager.AvailableLanguages)
{ {
Vector2 textSize = languageSelectionFont.MeasureString(language); languageSelectionFont.DrawString(spriteBatch, language, textPos - languageSelectionFont.MeasureString(language) / 2, Color.White * 0.8f);
bool hover =
Math.Abs(PlayerInput.MousePosition.X - textPos.X) < textSize.X / 2 &&
Math.Abs(PlayerInput.MousePosition.Y - textPos.Y) < textSpacing.Y / 2;
//TODO: display the name of the language in the target language?
languageSelectionFont.DrawString(spriteBatch, language, textPos - textSize / 2,
hover ? Color.White : Color.White * 0.6f);
if (hover && PlayerInput.LeftButtonClicked())
{
GameMain.Config.Language = language;
WaitForLanguageSelection = false;
}
textPos += textSpacing; textPos += textSpacing;
} }
languageSelectionCursor.Draw(spriteBatch, PlayerInput.LatestMousePosition); languageSelectionCursor.Draw(spriteBatch, PlayerInput.LatestMousePosition);
} }
private void DrawSplashScreen(SpriteBatch spriteBatch, GraphicsDevice graphics) private void DrawSplashScreen(SpriteBatch spriteBatch)
{ {
if (currSplashScreen == null && PendingSplashScreens.Count == 0) { return; } if (SplashScreen != null)
if (currSplashScreen == null)
{ {
var newSplashScreen = PendingSplashScreens.Dequeue(); if (SplashScreen.IsPlaying)
string fileName = newSplashScreen.First;
Point resolution = newSplashScreen.Second;
try
{ {
currSplashScreen = new Video(graphics, GameMain.SoundManager, fileName, (uint)resolution.X, (uint)resolution.Y); spriteBatch.Begin();
videoStartTime = DateTime.Now; spriteBatch.Draw(SplashScreen.GetTexture(), new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
} spriteBatch.End();
catch (Exception e)
{
GameMain.Config.EnableSplashScreen = false;
DebugConsole.ThrowError("Playing the splash screen \"" + fileName + "\" failed.", e);
PendingSplashScreens.Clear();
currSplashScreen = null;
}
}
if (currSplashScreen.IsPlaying) if (PlayerInput.KeyHit(Keys.Space) || PlayerInput.KeyHit(Keys.Enter) || PlayerInput.LeftButtonDown())
{ {
spriteBatch.Begin(); SplashScreen.Dispose(); SplashScreen = null;
spriteBatch.Draw(currSplashScreen.GetTexture(), new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White); }
spriteBatch.End();
if (PlayerInput.KeyHit(Keys.Space) || PlayerInput.KeyHit(Keys.Enter) || PlayerInput.LeftButtonDown())
{
currSplashScreen.Dispose(); currSplashScreen = null;
} }
} else
else if (DateTime.Now > videoStartTime + new TimeSpan(0, 0, 0, 0, milliseconds: 500)) {
{ SplashScreen.Dispose(); SplashScreen = null;
currSplashScreen.Dispose(); currSplashScreen = null; }
} }
} }
bool drawn; bool drawn;
public IEnumerable<object> DoLoading(IEnumerable<object> loader) public IEnumerable<object> DoLoading(IEnumerable<object> loader)
{ {
+11 -18
View File
@@ -270,17 +270,15 @@ namespace Barotrauma
WaterRenderer.Instance = new WaterRenderer(base.GraphicsDevice, Content); WaterRenderer.Instance = new WaterRenderer(base.GraphicsDevice, Content);
loadingScreenOpen = true; loadingScreenOpen = true;
TitleScreen = new LoadingScreen(GraphicsDevice) TitleScreen = new LoadingScreen(GraphicsDevice);
{ TitleScreen.WaitForLanguageSelection = Config.ShowLanguageSelectionPrompt;
WaitForLanguageSelection = Config.ShowLanguageSelectionPrompt
};
bool canLoadInSeparateThread = false; bool canLoadInSeparateThread = false;
#if WINDOWS #if WINDOWS
canLoadInSeparateThread = true; canLoadInSeparateThread = true;
#endif #endif
loadingCoroutine = CoroutineManager.StartCoroutine(Load(canLoadInSeparateThread), "", canLoadInSeparateThread); loadingCoroutine = CoroutineManager.StartCoroutine(Load(), "", canLoadInSeparateThread);
} }
private void InitUserStats() private void InitUserStats()
@@ -337,21 +335,16 @@ namespace Barotrauma
SoundManager.SetCategoryGainMultiplier("voip", Config.VoiceChatVolume); SoundManager.SetCategoryGainMultiplier("voip", Config.VoiceChatVolume);
if (Config.EnableSplashScreen) if (Config.EnableSplashScreen)
{ {
var pendingSplashScreens = TitleScreen.PendingSplashScreens; try
pendingSplashScreens?.Enqueue(new Pair<string, Point>("Content/Splash_UTG.mp4", new Point(1280, 720)));
pendingSplashScreens?.Enqueue(new Pair<string, Point>("Content/Splash_FF.mp4", new Point(1280, 720)));
pendingSplashScreens?.Enqueue(new Pair<string, Point>("Content/Splash_Daedalic.mp4", new Point(1920, 1080)));
}
//if not loading in a separate thread, wait for the splash screens to finish before continuing the loading
//otherwise the videos will look extremely choppy
if (!isSeparateThread)
{
while (TitleScreen.PlayingSplashScreen || TitleScreen.PendingSplashScreens.Count > 0)
{ {
yield return CoroutineStatus.Running; (TitleScreen as LoadingScreen).SplashScreen = new Video(base.GraphicsDevice, SoundManager, "Content/splashscreen.mp4", 1280, 720);
} }
} catch (Exception e)
{
Config.EnableSplashScreen = false;
DebugConsole.ThrowError("Playing the splash screen failed.", e);
}
}
GUI.Init(Window, Config.SelectedContentPackages, GraphicsDevice); GUI.Init(Window, Config.SelectedContentPackages, GraphicsDevice);
DebugConsole.Init(); DebugConsole.Init();
@@ -74,12 +74,17 @@ namespace Barotrauma
public CrewManager(XElement element, bool isSinglePlayer) public CrewManager(XElement element, bool isSinglePlayer)
: this(isSinglePlayer) : this(isSinglePlayer)
{ {
if (!isSinglePlayer) if (GameMain.Client != null)
{ {
DebugConsole.ThrowError("Cannot add messages to single player chat box in multiplayer mode!\n" + Environment.StackTrace); //let the server create random conversations in MP
return; return;
} }
if (string.IsNullOrEmpty(text)) { return; } List<Character> availableSpeakers = Character.CharacterList.FindAll(c =>
c.AIController is HumanAIController &&
!c.IsDead &&
c.SpeechImpediment <= 100.0f);
pendingConversationLines.AddRange(NPCConversation.CreateRandom(availableSpeakers));
}
var characterInfo = new CharacterInfo(subElement); var characterInfo = new CharacterInfo(subElement);
characterInfos.Add(characterInfo); characterInfos.Add(characterInfo);
@@ -90,7 +95,6 @@ namespace Barotrauma
break; break;
} }
} }
ChatBox.AddMessage(ChatMessage.Create(senderName, text, messageType, sender));
} }
partial void InitProjectSpecific() partial void InitProjectSpecific()
@@ -239,27 +243,24 @@ namespace Barotrauma
public IEnumerable<Character> GetCharacters() public IEnumerable<Character> GetCharacters()
{ {
if (character?.Inventory == null) return null; if (characterInfos.Contains(characterInfo))
{
DebugConsole.ThrowError("Tried to add the same character info to CrewManager twice.\n" + Environment.StackTrace);
return;
}
var radioItem = character.Inventory.Items.FirstOrDefault(it => it != null && it.GetComponent<WifiComponent>() != null); characterInfos.Add(characterInfo);
if (radioItem == null) return null;
if (requireEquipped && !character.HasEquippedItem(radioItem)) return null;
return radioItem.GetComponent<WifiComponent>();
} }
public IEnumerable<CharacterInfo> GetCharacterInfos() public IEnumerable<CharacterInfo> GetCharacterInfos()
{ {
if (GameMain.Client != null) if (character == null)
{ {
//let the server create random conversations in MP DebugConsole.ThrowError("Tried to remove a null character from CrewManager.\n" + Environment.StackTrace);
return; return;
} }
List<Character> availableSpeakers = Character.CharacterList.FindAll(c => characters.Remove(character);
c.AIController is HumanAIController && if (removeInfo) characterInfos.Remove(character.Info);
!c.IsDead &&
c.SpeechImpediment <= 100.0f);
pendingConversationLines.AddRange(NPCConversation.CreateRandom(availableSpeakers));
} }
public void AddCharacter(Character character) public void AddCharacter(Character character)
@@ -633,9 +634,183 @@ namespace Barotrauma
{ {
characterListBox.BarScroll = roundedPos; characterListBox.BarScroll = roundedPos;
} }
soundIcon.Visible = !muted && !mutedLocally; var characterArea = new GUIButton(new RectTransform(new Point(characterInfoWidth, frame.Rect.Height), frame.RectTransform, Anchor.CenterLeft), style: "GUITextBox")
soundIconDisabled.Visible = muted || mutedLocally; {
soundIconDisabled.ToolTip = TextManager.Get(mutedLocally ? "MutedLocally" : "MutedGlobally"); UserData = character,
Color = frame.Color,
SelectedColor = frame.SelectedColor,
HoverColor = frame.HoverColor,
ToolTip = characterToolTip
};
var soundIcon = new GUIImage(new RectTransform(new Point((int)(characterArea.Rect.Height * 0.5f)), characterArea.RectTransform, Anchor.CenterRight) { AbsoluteOffset = new Point(5, 0) },
"GUISoundIcon")
{
UserData = "soundicon",
CanBeFocused = false,
Visible = true
};
soundIcon.Color = new Color(soundIcon.Color, 0.0f);
new GUIImage(new RectTransform(new Point((int)(characterArea.Rect.Height * 0.5f)), characterArea.RectTransform, Anchor.CenterRight) { AbsoluteOffset = new Point(5, 0) },
"GUISoundIconDisabled")
{
UserData = "soundicondisabled",
CanBeFocused = true,
Visible = false
};
if (isSinglePlayer)
{
characterArea.OnClicked = CharacterClicked;
}
else
{
characterArea.CanBeFocused = false;
characterArea.CanBeSelected = false;
}
var characterImage = new GUICustomComponent(new RectTransform(new Point(characterArea.Rect.Height), characterArea.RectTransform, Anchor.CenterLeft),
onDraw: (sb, component) => character.Info.DrawIcon(sb, component.Rect.Center.ToVector2(), targetAreaSize: component.Rect.Size.ToVector2()))
{
CanBeFocused = false,
HoverColor = Color.White,
SelectedColor = Color.White,
ToolTip = characterToolTip
};
var characterName = new GUITextBlock(new RectTransform(new Point(characterArea.Rect.Width - characterImage.Rect.Width - soundIcon.Rect.Width - 10, characterArea.Rect.Height),
characterArea.RectTransform, Anchor.CenterRight) { AbsoluteOffset = new Point(soundIcon.Rect.Width + 10, 0) },
character.Name, textColor: frame.Color, font: GUI.SmallFont, wrap: true)
{
Color = frame.Color,
HoverColor = Color.Transparent,
SelectedColor = Color.Transparent,
CanBeFocused = false,
ToolTip = characterToolTip,
AutoScale = true
};
//---------------- order buttons ----------------
var orderButtonFrame = new GUILayoutGroup(new RectTransform(new Point(100, frame.Rect.Height), frame.RectTransform)
{ AbsoluteOffset = new Point(characterInfoWidth + spacing, 0) },
isHorizontal: true, childAnchor: Anchor.CenterLeft)
{
AbsoluteSpacing = (int)(10 * GUI.Scale),
UserData = "orderbuttons",
CanBeFocused = false
};
//listbox for holding the orders inappropriate for this character
//(so we can easily toggle their visibility)
var wrongOrderList = new GUIListBox(new RectTransform(new Point(50, orderButtonFrame.Rect.Height), orderButtonFrame.RectTransform), isHorizontal: true, style: null)
{
ScrollBarEnabled = false,
ScrollBarVisible = false,
Enabled = false,
Spacing = spacing,
ClampMouseRectToParent = false
};
wrongOrderList.Content.ClampMouseRectToParent = false;
for (int i = 0; i < orders.Count; i++)
{
var order = orders[i];
if (order.TargetAllCharacters) continue;
RectTransform btnParent = (i >= correctOrderCount + neutralOrderCount) ?
wrongOrderList.Content.RectTransform :
orderButtonFrame.RectTransform;
var btn = new GUIButton(new RectTransform(new Point(iconSize, iconSize), btnParent, Anchor.CenterLeft),
style: null)
{
UserData = order
};
new GUIFrame(new RectTransform(new Vector2(1.5f), btn.RectTransform, Anchor.Center), "OuterGlow")
{
Color = Color.Lerp(order.Color, frame.Color, 0.5f) * 0.8f,
HoverColor = Color.Lerp(order.Color, frame.Color, 0.5f) * 1.0f,
PressedColor = Color.Lerp(order.Color, frame.Color, 0.5f) * 0.6f,
UserData = "selected",
CanBeFocused = false,
Visible = false
};
var img = new GUIImage(new RectTransform(Vector2.One, btn.RectTransform), order.Prefab.SymbolSprite);
img.Scale = iconSize / (float)img.SourceRect.Width;
img.Color = Color.Lerp(order.Color, frame.Color, 0.5f);
img.ToolTip = order.Name;
img.HoverColor = Color.Lerp(img.Color, Color.White, 0.5f);
btn.OnClicked += (GUIButton button, object userData) =>
{
if (Character.Controlled == null || Character.Controlled.SpeechImpediment >= 100.0f) return false;
if (btn.GetChildByUserData("selected").Visible)
{
SetCharacterOrder(character, Order.PrefabList.Find(o => o.AITag == "dismissed"), null, Character.Controlled);
}
else
{
if (order.ItemComponentType != null || order.ItemIdentifiers.Length > 0 || order.Options.Length > 1)
{
CreateOrderTargetFrame(button, character, order);
}
else
{
SetCharacterOrder(character, order, null, Character.Controlled);
}
}
return true;
};
btn.UserData = order;
btn.ToolTip = order.Name;
//divider between different groups of orders
if (i == correctOrderCount - 1 || i == correctOrderCount + neutralOrderCount - 1)
{
//TODO: divider sprite
new GUIFrame(new RectTransform(new Point(8, iconSize), orderButtonFrame.RectTransform), style: "GUIButton");
}
}
var toggleWrongOrderBtn = new GUIButton(new RectTransform(new Point((int)(30 * GUI.Scale), wrongOrderList.Rect.Height), wrongOrderList.Content.RectTransform),
"", style: "UIToggleButton")
{
UserData = "togglewrongorder",
CanBeFocused = false
};
wrongOrderList.RectTransform.NonScaledSize = new Point(
wrongOrderList.Content.Children.Sum(c => c.Rect.Width + wrongOrderList.Spacing),
wrongOrderList.RectTransform.NonScaledSize.Y);
wrongOrderList.RectTransform.SetAsLastChild();
new GUIFrame(new RectTransform(new Point(
wrongOrderList.Rect.Width - toggleWrongOrderBtn.Rect.Width - wrongOrderList.Spacing * 2,
wrongOrderList.Rect.Height), wrongOrderList.Content.RectTransform),
style: null)
{
CanBeFocused = false
};
//scale to fit the content
orderButtonFrame.RectTransform.NonScaledSize = new Point(
orderButtonFrame.Children.Sum(c => c.Rect.Width + orderButtonFrame.AbsoluteSpacing),
orderButtonFrame.RectTransform.NonScaledSize.Y);
frame.RectTransform.NonScaledSize = new Point(
characterInfoWidth + spacing + (orderButtonFrame.Rect.Width - wrongOrderList.Rect.Width),
frame.RectTransform.NonScaledSize.Y);
characterListBox.RectTransform.NonScaledSize = new Point(
characterListBox.Content.Children.Max(c => c.Rect.Width) + wrongOrderList.Rect.Width,
characterListBox.RectTransform.NonScaledSize.Y);
characterListBox.Content.RectTransform.NonScaledSize = characterListBox.RectTransform.NonScaledSize;
characterListBox.UpdateScrollBarSize();
return frame;
} }
private IEnumerable<object> KillCharacterAnim(GUIComponent component) private IEnumerable<object> KillCharacterAnim(GUIComponent component)
@@ -779,6 +954,12 @@ namespace Barotrauma
} }
return; return;
} }
List<Character> availableSpeakers = Character.CharacterList.FindAll(c =>
c.AIController is HumanAIController &&
!c.IsDead &&
c.SpeechImpediment <= 100.0f);
pendingConversationLines.AddRange(NPCConversation.CreateRandom(availableSpeakers));
}
character.SetOrder(order, option, orderGiver, speak: orderGiver != character); character.SetOrder(order, option, orderGiver, speak: orderGiver != character);
if (IsSinglePlayer) if (IsSinglePlayer)
@@ -836,19 +1017,23 @@ namespace Barotrauma
} }
} }
} }
//only one target (or an order with no particular targets), just show options
else character.SetOrder(order, option, orderGiver, speak: orderGiver != character);
if (IsSinglePlayer)
{ {
orderTargetFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.2f + order.Options.Length * 0.1f, 0.18f), GUI.Canvas) orderGiver?.Speak(
{ AbsoluteOffset = new Point(orderButton.Rect.Center.X, orderButton.Rect.Bottom) }, order.GetChatMessage(character.Name, orderGiver.CurrentHull?.DisplayName, givingOrderToSelf: character == orderGiver, orderOption: option), null);
isHorizontal: true, childAnchor: Anchor.BottomLeft) }
else if (orderGiver != null)
{
OrderChatMessage msg = new OrderChatMessage(order, option, order.TargetItemComponent?.Item, character, orderGiver);
if (GameMain.Client != null)
{ {
UserData = character, GameMain.Client.SendChatMessage(msg);
Stretch = true }
}; }
//line connecting the order button to the option buttons DisplayCharacterOrder(character, order);
//TODO: sprite }
new GUIFrame(new RectTransform(new Vector2(0.5f, 1.0f), orderTargetFrame.RectTransform), style: null);
/// <summary> /// <summary>
/// Create the UI panel that's used to select the target and options for a given order /// Create the UI panel that's used to select the target and options for a given order
@@ -201,7 +201,7 @@ namespace Barotrauma.Tutorials
SetHighlight(captain_statusMonitor, true); SetHighlight(captain_statusMonitor, true);
do do
{ {
//captain_navConsoleCustomInterface.HighlightElement(0, uiHighlightColor, duration: 1.0f, pulsateAmount: 0.0f); captain_navConsoleCustomInterface.HighlightElement(0, uiHighlightColor, duration: 1.0f, pulsateAmount: 0.0f);
yield return new WaitForSeconds(1.0f); yield return new WaitForSeconds(1.0f);
} while (Submarine.MainSub.DockedTo.Count > 0); } while (Submarine.MainSub.DockedTo.Count > 0);
RemoveCompletedObjective(segments[4]); RemoveCompletedObjective(segments[4]);
@@ -225,7 +225,7 @@ namespace Barotrauma.Tutorials
TriggerTutorialSegment(6); // Docking TriggerTutorialSegment(6); // Docking
do do
{ {
//captain_navConsoleCustomInterface.HighlightElement(0, uiHighlightColor, duration: 1.0f, pulsateAmount: 0.0f); captain_navConsoleCustomInterface.HighlightElement(0, uiHighlightColor, duration: 1.0f, pulsateAmount: 0.0f);
yield return new WaitForSeconds(1.0f); yield return new WaitForSeconds(1.0f);
} while (!Submarine.MainSub.AtEndPosition || Submarine.MainSub.DockedTo.Count == 0); } while (!Submarine.MainSub.AtEndPosition || Submarine.MainSub.DockedTo.Count == 0);
RemoveCompletedObjective(segments[6]); RemoveCompletedObjective(segments[6]);
@@ -491,6 +491,18 @@ namespace Barotrauma
} }
} }
foreach (MapEntity e in MapEntity.mapEntityList)
{
if (Vector2.Distance(e.Position, HiddenSubPosition) > 20000)
{
//move disabled items (wires, items inside containers) inside the sub
if (e is Item item && item.body != null && !item.body.Enabled)
{
item.SetTransform(ConvertUnits.ToSimUnits(HiddenSubPosition), 0.0f);
}
}
}
foreach (MapEntity e in MapEntity.mapEntityList) foreach (MapEntity e in MapEntity.mapEntityList)
{ {
if (Vector2.Distance(e.Position, HiddenSubPosition) > 20000) if (Vector2.Distance(e.Position, HiddenSubPosition) > 20000)
@@ -1012,7 +1012,7 @@ namespace Barotrauma.Networking
} }
} }
GUIMessageBox msgBox = new GUIMessageBox(TextManager.Get("PermissionsChanged"), msg) GUIMessageBox msgBox = new GUIMessageBox(TextManager.Get("PermissionsChanged"), msg, GUIMessageBox.DefaultWidth, 0)
{ {
UserData = "permissions" UserData = "permissions"
}; };
@@ -1707,7 +1707,7 @@ namespace Barotrauma.Networking
infoButton.UserData = newSub; infoButton.UserData = newSub;
infoButton.OnClicked = (component, userdata) => infoButton.OnClicked = (component, userdata) =>
{ {
((Submarine)userdata).CreatePreviewWindow(new GUIMessageBox("", "", new Vector2(0.25f, 0.25f), new Point(500, 400))); ((Submarine)userdata).CreatePreviewWindow(new GUIMessageBox("", "", 550, 400));
return true; return true;
}; };
} }
@@ -2401,7 +2401,7 @@ namespace Barotrauma.Networking
{ {
var banReasonPrompt = new GUIMessageBox( var banReasonPrompt = new GUIMessageBox(
TextManager.Get(ban ? "BanReasonPrompt" : "KickReasonPrompt"), TextManager.Get(ban ? "BanReasonPrompt" : "KickReasonPrompt"),
"", new string[] { TextManager.Get("OK"), TextManager.Get("Cancel") }, new Vector2(0.25f, 0.2f), new Point(400, 200)); "", new string[] { TextManager.Get("OK"), TextManager.Get("Cancel") }, 400, 300);
var content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.6f), banReasonPrompt.InnerFrame.RectTransform, Anchor.Center)); var content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.6f), banReasonPrompt.InnerFrame.RectTransform, Anchor.Center));
var banReasonBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.3f), content.RectTransform)) var banReasonBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.3f), content.RectTransform))
@@ -324,6 +324,8 @@ namespace Barotrauma
private GUILayoutGroup subPreviewContainer; private GUILayoutGroup subPreviewContainer;
private GUILayoutGroup subPreviewContainer;
private GUIButton loadGameButton; private GUIButton loadGameButton;
public Action<Submarine, string, string> StartNewGame; public Action<Submarine, string, string> StartNewGame;
@@ -2043,13 +2043,12 @@ namespace Barotrauma
GUI.AddMessage(GetCharacterEditorTranslation("RagdollReset"), Color.WhiteSmoke, font: GUI.Font); GUI.AddMessage(GetCharacterEditorTranslation("RagdollReset"), Color.WhiteSmoke, font: GUI.Font);
return true; return true;
}; };
Vector2 messageBoxRelSize = new Vector2(0.5f, 0.5f);
int messageBoxWidth = GameMain.GraphicsWidth / 2; int messageBoxWidth = GameMain.GraphicsWidth / 2;
int messageBoxHeight = GameMain.GraphicsHeight / 2; int messageBoxHeight = GameMain.GraphicsHeight / 2;
var saveRagdollButton = new GUIButton(new RectTransform(buttonSize, layoutGroup.RectTransform), GetCharacterEditorTranslation("SaveRagdoll")); var saveRagdollButton = new GUIButton(new RectTransform(buttonSize, layoutGroup.RectTransform), GetCharacterEditorTranslation("SaveRagdoll"));
saveRagdollButton.OnClicked += (button, userData) => saveRagdollButton.OnClicked += (button, userData) =>
{ {
var box = new GUIMessageBox(GetCharacterEditorTranslation("SaveRagdoll"), $"{GetCharacterEditorTranslation("ProvideFileName")}: ", new string[] { TextManager.Get("Cancel"), TextManager.Get("Save") }, messageBoxRelSize); var box = new GUIMessageBox(GetCharacterEditorTranslation("SaveRagdoll"), $"{GetCharacterEditorTranslation("ProvideFileName")}: ", new string[] { TextManager.Get("Cancel"), TextManager.Get("Save") }, messageBoxWidth, messageBoxHeight);
var inputField = new GUITextBox(new RectTransform(new Point(box.Content.Rect.Width, 30), box.Content.RectTransform, Anchor.Center), RagdollParams.Name); var inputField = new GUITextBox(new RectTransform(new Point(box.Content.Rect.Width, 30), box.Content.RectTransform, Anchor.Center), RagdollParams.Name);
box.Buttons[0].OnClicked += (b, d) => box.Buttons[0].OnClicked += (b, d) =>
{ {
@@ -2077,7 +2076,7 @@ namespace Barotrauma
var loadRagdollButton = new GUIButton(new RectTransform(buttonSize, layoutGroup.RectTransform), GetCharacterEditorTranslation("LoadRagdoll")); var loadRagdollButton = new GUIButton(new RectTransform(buttonSize, layoutGroup.RectTransform), GetCharacterEditorTranslation("LoadRagdoll"));
loadRagdollButton.OnClicked += (button, userData) => loadRagdollButton.OnClicked += (button, userData) =>
{ {
var loadBox = new GUIMessageBox(GetCharacterEditorTranslation("LoadRagdoll"), "", new string[] { TextManager.Get("Cancel"), TextManager.Get("Load"), TextManager.Get("Delete") }, messageBoxRelSize); var loadBox = new GUIMessageBox(GetCharacterEditorTranslation("LoadRagdoll"), "", new string[] { TextManager.Get("Cancel"), TextManager.Get("Load"), TextManager.Get("Delete") }, messageBoxWidth, messageBoxHeight);
loadBox.Buttons[0].OnClicked += loadBox.Close; loadBox.Buttons[0].OnClicked += loadBox.Close;
var listBox = new GUIListBox(new RectTransform(new Vector2(0.9f, 0.6f), loadBox.Content.RectTransform, Anchor.TopCenter)); var listBox = new GUIListBox(new RectTransform(new Vector2(0.9f, 0.6f), loadBox.Content.RectTransform, Anchor.TopCenter));
var deleteButton = loadBox.Buttons[2]; var deleteButton = loadBox.Buttons[2];
@@ -2123,7 +2122,7 @@ namespace Barotrauma
var msgBox = new GUIMessageBox( var msgBox = new GUIMessageBox(
TextManager.Get("DeleteDialogLabel"), TextManager.Get("DeleteDialogLabel"),
TextManager.Get("DeleteDialogQuestion").Replace("[file]", selectedFile), TextManager.Get("DeleteDialogQuestion").Replace("[file]", selectedFile),
new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") }); new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") }, messageBoxWidth - 100, messageBoxHeight - 100);
msgBox.Buttons[0].OnClicked += (b, d) => msgBox.Buttons[0].OnClicked += (b, d) =>
{ {
try try
@@ -2164,7 +2163,7 @@ namespace Barotrauma
var saveAnimationButton = new GUIButton(new RectTransform(buttonSize, layoutGroup.RectTransform), GetCharacterEditorTranslation("SaveAnimation")); var saveAnimationButton = new GUIButton(new RectTransform(buttonSize, layoutGroup.RectTransform), GetCharacterEditorTranslation("SaveAnimation"));
saveAnimationButton.OnClicked += (button, userData) => saveAnimationButton.OnClicked += (button, userData) =>
{ {
var box = new GUIMessageBox(GetCharacterEditorTranslation("SaveAnimation"), string.Empty, new string[] { TextManager.Get("Cancel"), TextManager.Get("Save") }, messageBoxRelSize); var box = new GUIMessageBox(GetCharacterEditorTranslation("SaveAnimation"), string.Empty, new string[] { TextManager.Get("Cancel"), TextManager.Get("Save") }, messageBoxWidth, messageBoxHeight);
var textArea = new GUIFrame(new RectTransform(new Vector2(1, 0.1f), box.Content.RectTransform) { MinSize = new Point(350, 30) }, style: null); var textArea = new GUIFrame(new RectTransform(new Vector2(1, 0.1f), box.Content.RectTransform) { MinSize = new Point(350, 30) }, style: null);
var inputLabel = new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), textArea.RectTransform) { MinSize = new Point(250, 30) }, $"{GetCharacterEditorTranslation("ProvideFileName")}: "); var inputLabel = new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), textArea.RectTransform) { MinSize = new Point(250, 30) }, $"{GetCharacterEditorTranslation("ProvideFileName")}: ");
var inputField = new GUITextBox(new RectTransform(new Vector2(0.5f, 1), textArea.RectTransform, Anchor.TopRight) { MinSize = new Point(100, 30) }, CurrentAnimation.Name); var inputField = new GUITextBox(new RectTransform(new Vector2(0.5f, 1), textArea.RectTransform, Anchor.TopRight) { MinSize = new Point(100, 30) }, CurrentAnimation.Name);
@@ -2212,7 +2211,7 @@ namespace Barotrauma
var loadAnimationButton = new GUIButton(new RectTransform(buttonSize, layoutGroup.RectTransform), GetCharacterEditorTranslation("LoadAnimation")); var loadAnimationButton = new GUIButton(new RectTransform(buttonSize, layoutGroup.RectTransform), GetCharacterEditorTranslation("LoadAnimation"));
loadAnimationButton.OnClicked += (button, userData) => loadAnimationButton.OnClicked += (button, userData) =>
{ {
var loadBox = new GUIMessageBox(GetCharacterEditorTranslation("LoadAnimation"), "", new string[] { TextManager.Get("Cancel"), TextManager.Get("Load"), TextManager.Get("Delete") }, messageBoxRelSize); var loadBox = new GUIMessageBox(GetCharacterEditorTranslation("LoadAnimation"), "", new string[] { TextManager.Get("Cancel"), TextManager.Get("Load"), TextManager.Get("Delete") }, messageBoxWidth, messageBoxHeight);
loadBox.Buttons[0].OnClicked += loadBox.Close; loadBox.Buttons[0].OnClicked += loadBox.Close;
var listBox = new GUIListBox(new RectTransform(new Vector2(0.9f, 0.6f), loadBox.Content.RectTransform)); var listBox = new GUIListBox(new RectTransform(new Vector2(0.9f, 0.6f), loadBox.Content.RectTransform));
var deleteButton = loadBox.Buttons[2]; var deleteButton = loadBox.Buttons[2];
@@ -2274,7 +2273,7 @@ namespace Barotrauma
var msgBox = new GUIMessageBox( var msgBox = new GUIMessageBox(
TextManager.Get("DeleteDialogLabel"), TextManager.Get("DeleteDialogLabel"),
TextManager.Get("DeleteDialogQuestion").Replace("[file]", selectedFile), TextManager.Get("DeleteDialogQuestion").Replace("[file]", selectedFile),
new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") }); new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") }, messageBoxWidth - 100, messageBoxHeight - 100);
msgBox.Buttons[0].OnClicked += (b, d) => msgBox.Buttons[0].OnClicked += (b, d) =>
{ {
try try
@@ -4426,7 +4425,7 @@ namespace Barotrauma
protected override GUIMessageBox Create() protected override GUIMessageBox Create()
{ {
var box = new GUIMessageBox(GetCharacterEditorTranslation("CreateNewCharacter"), string.Empty, new string[] { TextManager.Get("Cancel"), TextManager.Get("Next") }, new Vector2(0.5f, 1.0f)); var box = new GUIMessageBox(GetCharacterEditorTranslation("CreateNewCharacter"), string.Empty, new string[] { TextManager.Get("Cancel"), TextManager.Get("Next") }, GameMain.GraphicsWidth / 2, GameMain.GraphicsHeight);
box.Content.ChildAnchor = Anchor.TopCenter; box.Content.ChildAnchor = Anchor.TopCenter;
box.Content.AbsoluteSpacing = 20; box.Content.AbsoluteSpacing = 20;
int elementSize = 30; int elementSize = 30;
@@ -4542,7 +4541,7 @@ namespace Barotrauma
protected override GUIMessageBox Create() protected override GUIMessageBox Create()
{ {
var box = new GUIMessageBox(GetCharacterEditorTranslation("DefineRagdoll"), string.Empty, new string[] { TextManager.Get("Previous"), TextManager.Get("Create") }, new Vector2(0.5f, 1.0f)); var box = new GUIMessageBox(GetCharacterEditorTranslation("DefineRagdoll"), string.Empty, new string[] { TextManager.Get("Previous"), TextManager.Get("Create") }, GameMain.GraphicsWidth / 2, GameMain.GraphicsHeight);
box.Content.ChildAnchor = Anchor.TopCenter; box.Content.ChildAnchor = Anchor.TopCenter;
box.Content.AbsoluteSpacing = 20; box.Content.AbsoluteSpacing = 20;
int elementSize = 30; int elementSize = 30;
@@ -4622,7 +4621,7 @@ namespace Barotrauma
{ {
if (htmlBox == null) if (htmlBox == null)
{ {
htmlBox = new GUIMessageBox(GetCharacterEditorTranslation("LoadHTML"), string.Empty, new string[] { TextManager.Get("Close"), TextManager.Get("Load") }, new Vector2(0.5f, 1.0f)); htmlBox = new GUIMessageBox(GetCharacterEditorTranslation("LoadHTML"), string.Empty, new string[] { TextManager.Get("Close"), TextManager.Get("Load") }, GameMain.GraphicsWidth / 2, GameMain.GraphicsHeight);
var element = new GUIFrame(new RectTransform(new Vector2(0.8f, 0.05f), htmlBox.Content.RectTransform), style: null, color: Color.Gray * 0.25f); var element = new GUIFrame(new RectTransform(new Vector2(0.8f, 0.05f), htmlBox.Content.RectTransform), style: null, color: Color.Gray * 0.25f);
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1), element.RectTransform), GetCharacterEditorTranslation("HTMLPath")); new GUITextBlock(new RectTransform(new Vector2(0.5f, 1), element.RectTransform), GetCharacterEditorTranslation("HTMLPath"));
var htmlPathElement = new GUITextBox(new RectTransform(new Vector2(0.5f, 1), element.RectTransform, Anchor.TopRight), $"Content/Characters/{Name}/{Name}.html"); var htmlPathElement = new GUITextBox(new RectTransform(new Vector2(0.5f, 1), element.RectTransform, Anchor.TopRight), $"Content/Characters/{Name}/{Name}.html");
@@ -1,5 +1,8 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Barotrauma namespace Barotrauma
@@ -8,7 +11,7 @@ namespace Barotrauma
{ {
private GUIListBox listBox; private GUIListBox listBox;
private readonly float scrollSpeed; private float scrollSpeed;
public CreditsPlayer(RectTransform rectT, string configFile) : base(null, rectT) public CreditsPlayer(RectTransform rectT, string configFile) : base(null, rectT)
{ {
@@ -297,6 +297,7 @@ namespace Barotrauma
{ {
OnClicked = (btn, userdata) => OnClicked = (btn, userdata) =>
{ {
GameMain.SpriteEditorScreen.RefreshLists();
editingSprite = sprite; editingSprite = sprite;
GameMain.SpriteEditorScreen.SelectSprite(editingSprite); GameMain.SpriteEditorScreen.SelectSprite(editingSprite);
return true; return true;
@@ -601,7 +602,7 @@ namespace Barotrauma
public GUIMessageBox Create() public GUIMessageBox Create()
{ {
var box = new GUIMessageBox(TextManager.Get("LevelEditorCreateLevelObj"), string.Empty, var box = new GUIMessageBox(TextManager.Get("LevelEditorCreateLevelObj"), string.Empty,
new string[] { TextManager.Get("Cancel"), TextManager.Get("Done") }, new Vector2(0.5f, 0.8f)); new string[] { TextManager.Get("Cancel"), TextManager.Get("Done") }, GameMain.GraphicsWidth / 2, (int)(GameMain.GraphicsHeight * 0.8f));
box.Content.ChildAnchor = Anchor.TopCenter; box.Content.ChildAnchor = Anchor.TopCenter;
box.Content.AbsoluteSpacing = 20; box.Content.AbsoluteSpacing = 20;
@@ -675,8 +676,6 @@ namespace Barotrauma
doc.WriteTo(writer); doc.WriteTo(writer);
writer.Flush(); writer.Flush();
} }
// Recreate the prefab so that the sprite loads correctly: TODO: consider a better way to do this
newPrefab = new LevelObjectPrefab(newElement);
break; break;
} }
@@ -44,15 +44,15 @@ namespace Barotrauma
{ {
backgroundVignette = new Sprite("Content/UI/MainMenuVignette.png", Vector2.Zero); backgroundVignette = new Sprite("Content/UI/MainMenuVignette.png", Vector2.Zero);
new GUIImage(new RectTransform(new Vector2(0.4f, 0.25f), Frame.RectTransform, Anchor.BottomRight) new GUIImage(new RectTransform(new Vector2(0.35f, 0.2f), Frame.RectTransform, Anchor.BottomRight)
{ RelativeOffset = new Vector2(0.08f, 0.05f), AbsoluteOffset = new Point(-8, -8) }, { RelativeOffset = new Vector2(0.05f, 0.1f), AbsoluteOffset = new Point(-8, -8) },
style: "TitleText") style: "TitleText")
{ {
Color = Color.Black * 0.5f, Color = Color.Black * 0.5f,
CanBeFocused = false CanBeFocused = false
}; };
titleText = new GUIImage(new RectTransform(new Vector2(0.4f, 0.25f), Frame.RectTransform, Anchor.BottomRight) titleText = new GUIImage(new RectTransform(new Vector2(0.35f, 0.2f), Frame.RectTransform, Anchor.BottomRight)
{ RelativeOffset = new Vector2(0.08f, 0.05f) }, { RelativeOffset = new Vector2(0.05f, 0.1f) },
style: "TitleText"); style: "TitleText");
buttonsParent = new GUILayoutGroup(new RectTransform(new Vector2(0.3f, 0.85f), parent: Frame.RectTransform, anchor: Anchor.CenterLeft) buttonsParent = new GUILayoutGroup(new RectTransform(new Vector2(0.3f, 0.85f), parent: Frame.RectTransform, anchor: Anchor.CenterLeft)
@@ -354,12 +354,6 @@ namespace Barotrauma
}; };
var creditsContainer = new GUIFrame(new RectTransform(new Vector2(0.75f, 1.5f), menuTabs[(int)Tab.Credits].RectTransform, Anchor.CenterRight), style: "OuterGlow", color: Color.Black * 0.8f); var creditsContainer = new GUIFrame(new RectTransform(new Vector2(0.75f, 1.5f), menuTabs[(int)Tab.Credits].RectTransform, Anchor.CenterRight), style: "OuterGlow", color: Color.Black * 0.8f);
creditsPlayer = new CreditsPlayer(new RectTransform(Vector2.One, creditsContainer.RectTransform), "Content/Texts/Credits.xml"); creditsPlayer = new CreditsPlayer(new RectTransform(Vector2.One, creditsContainer.RectTransform), "Content/Texts/Credits.xml");
new GUIButton(new RectTransform(new Vector2(0.1f, 0.05f), menuTabs[(int)Tab.Credits].RectTransform, Anchor.BottomLeft) { RelativeOffset = new Vector2(0.25f, 0.02f) },
TextManager.Get("Back"), style: "GUIButtonLarge")
{
OnClicked = SelectTab
};
} }
#endregion #endregion
@@ -389,9 +383,10 @@ namespace Barotrauma
private bool SelectTab(GUIButton button, object obj) private bool SelectTab(GUIButton button, object obj)
{ {
titleText.Visible = true;
if (obj is Tab) if (obj is Tab)
{ {
titleText.Visible = true;
if (GameMain.Config.UnsavedSettings) if (GameMain.Config.UnsavedSettings)
{ {
var applyBox = new GUIMessageBox( var applyBox = new GUIMessageBox(
@@ -789,10 +784,6 @@ namespace Barotrauma
GUI.Draw(Cam, spriteBatch); GUI.Draw(Cam, spriteBatch);
spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, GameMain.ScissorTestEnable);
GUI.Draw(Cam, spriteBatch);
GUI.Draw(Cam, spriteBatch); GUI.Draw(Cam, spriteBatch);
#if DEBUG #if DEBUG
@@ -1212,7 +1212,7 @@ namespace Barotrauma
}; };
infoButton.OnClicked += (component, userdata) => infoButton.OnClicked += (component, userdata) =>
{ {
((Submarine)userdata).CreatePreviewWindow(new GUIMessageBox("", "", new Vector2(0.25f, 0.25f), new Point(500, 400))); ((Submarine)userdata).CreatePreviewWindow(new GUIMessageBox("", "", 550, 600));
return true; return true;
}; };
} }
@@ -2005,8 +2005,7 @@ namespace Barotrauma
return false; return false;
} }
var requestFileBox = new GUIMessageBox(TextManager.Get("DownloadSubLabel"), errorMsg, var requestFileBox = new GUIMessageBox(TextManager.Get("DownloadSubLabel"), errorMsg, new string[] { TextManager.Get("Yes"), TextManager.Get("No") }, 400, 300)
new string[] { TextManager.Get("Yes"), TextManager.Get("No") })
{ {
UserData = "request" + subName UserData = "request" + subName
}; };
@@ -193,7 +193,50 @@ namespace Barotrauma
{ {
Sprite sprite = userData as Sprite; Sprite sprite = userData as Sprite;
if (sprite == null) return false; if (sprite == null) return false;
SelectSprite(sprite); if (selectedSprites.Any(s => s.Texture != selectedTexture))
{
ResetWidgets();
}
if (Widget.EnableMultiSelect)
{
if (selectedSprites.Contains(sprite))
{
selectedSprites.Remove(sprite);
}
else
{
selectedSprites.Add(sprite);
dirtySprites.Add(sprite);
lastSelected = sprite;
}
}
else
{
selectedSprites.Clear();
selectedSprites.Add(sprite);
dirtySprites.Add(sprite);
lastSelected = sprite;
}
if (selectedTexture != sprite.Texture)
{
textureList.Select(sprite.Texture, autoScroll: false);
UpdateScrollBar(textureList);
}
xmlPathText.Text = string.Empty;
foreach (var s in selectedSprites)
{
texturePathText.Text = s.FilePath;
var element = s.SourceElement;
if (element != null)
{
string xmlPath = element.ParseContentPathFromUri();
if (!xmlPathText.Text.Contains(xmlPath))
{
xmlPathText.Text += "\n" + xmlPath;
}
}
}
xmlPathText.TextColor = Color.LightGray;
return true; return true;
} }
}; };
@@ -567,56 +610,11 @@ namespace Barotrauma
public void SelectSprite(Sprite sprite) public void SelectSprite(Sprite sprite)
{ {
if (!loadedSprites.Contains(sprite)) ResetWidgets();
{ textureList.Select(sprite.Texture);
loadedSprites.Add(sprite); ResetZoom();
RefreshLists(); selectedSprites.Clear();
} selectedSprites.Add(sprite);
if (selectedSprites.Any(s => s.Texture != selectedTexture))
{
ResetWidgets();
}
if (Widget.EnableMultiSelect)
{
if (selectedSprites.Contains(sprite))
{
selectedSprites.Remove(sprite);
}
else
{
selectedSprites.Add(sprite);
dirtySprites.Add(sprite);
lastSelected = sprite;
}
}
else
{
selectedSprites.Clear();
selectedSprites.Add(sprite);
dirtySprites.Add(sprite);
lastSelected = sprite;
}
if (selectedTexture != sprite.Texture)
{
textureList.Select(sprite.Texture, autoScroll: false);
UpdateScrollBar(textureList);
}
xmlPathText.Text = string.Empty;
foreach (var s in selectedSprites)
{
texturePathText.Text = s.FilePath;
var element = s.SourceElement;
if (element != null)
{
string xmlPath = element.ParseContentPathFromUri();
if (!xmlPathText.Text.Contains(xmlPath))
{
xmlPathText.Text += "\n" + xmlPath;
}
}
}
xmlPathText.TextColor = Color.LightGray;
} }
public void RefreshLists() public void RefreshLists()
@@ -661,7 +659,6 @@ namespace Barotrauma
public void ResetZoom() public void ResetZoom()
{ {
if (selectedTexture == null) { return; }
var viewArea = GetViewArea; var viewArea = GetViewArea;
float width = viewArea.Width / (float)selectedTexture.Width; float width = viewArea.Width / (float)selectedTexture.Width;
float height = viewArea.Height / (float)selectedTexture.Height; float height = viewArea.Height / (float)selectedTexture.Height;
@@ -906,7 +906,7 @@ namespace Barotrauma
public void CreateTextPicker(string textTag, ISerializableEntity entity, SerializableProperty property, GUITextBox textBox) public void CreateTextPicker(string textTag, ISerializableEntity entity, SerializableProperty property, GUITextBox textBox)
{ {
var msgBox = new GUIMessageBox("", "", new string[] { TextManager.Get("Cancel") }, new Vector2(0.2f, 0.5f), new Point(300, 400)); var msgBox = new GUIMessageBox("", "", new string[] { TextManager.Get("Cancel") }, width: 300, height: 400);
msgBox.Buttons[0].OnClicked = msgBox.Close; msgBox.Buttons[0].OnClicked = msgBox.Close;
var textList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.8f), msgBox.Content.RectTransform, Anchor.TopCenter)) var textList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.8f), msgBox.Content.RectTransform, Anchor.TopCenter))
@@ -454,12 +454,24 @@
<Content Include="$(MSBuildThisFileDirectory)Content\Items\Jobgear\Watchman\watchman_gear.xml"> <Content Include="$(MSBuildThisFileDirectory)Content\Items\Jobgear\Watchman\watchman_gear.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Items\Jobgear\Watchman\watchman_legs_female_2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Items\Jobgear\Watchman\watchman_legs_male_2.png"> <Content Include="$(MSBuildThisFileDirectory)Content\Items\Jobgear\Watchman\watchman_legs_male_2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Items\Jobgear\Watchman\watchman_legs_male_3.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Items\Jobgear\Watchman\watchman_torso_female_2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Items\Jobgear\Watchman\watchman_torso_male_2.png"> <Content Include="$(MSBuildThisFileDirectory)Content\Items\Jobgear\Watchman\watchman_torso_male_2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Items\Jobgear\Watchman\watchman_torso_male_3.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\BackgroundWalls.png"> <Content Include="$(MSBuildThisFileDirectory)Content\Map\BackgroundWalls.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -493,66 +505,6 @@
<Content Include="$(MSBuildThisFileDirectory)Content\Map\OutpostWall_C.png"> <Content Include="$(MSBuildThisFileDirectory)Content\Map\OutpostWall_C.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Ice\Zone4BaseTexture.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Ice\Zone4BaseTextureEdge.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Ice\Zone4Plants.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Ice\Zone4SurfaceCluster.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Ice\Zone4SurfaceDetail.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\ThermalReefs\Zone2BaseTexture.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\ThermalReefs\Zone2BaseTextureEdge.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\ThermalReefs\Zone2Plants.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\ThermalReefs\Zone2SurfaceCluster.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\ThermalReefs\Zone2SurfaceDetail.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Tundra\Zone3BaseTexture.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Tundra\Zone3BaseTextureEdge.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Tundra\Zone3Plants.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Tundra\Zone3SurfaceCluster.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Tundra\Zone3SurfaceDetail.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Volcanic\Zone1BaseTexture.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Volcanic\Zone1BaseTextureEdge.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Volcanic\Zone1Plants.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Volcanic\Zone1SurfaceCluster.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Map\Zones\Volcanic\Zone1SurfaceDetail.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\NPCConversations\NpcConversations_BrazilianPortuguese.xml"> <Content Include="$(MSBuildThisFileDirectory)Content\NPCConversations\NpcConversations_BrazilianPortuguese.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -575,15 +527,6 @@
<Content Include="$(MSBuildThisFileDirectory)Content\NPCConversations\NpcConversations_TraditionalChinese.xml"> <Content Include="$(MSBuildThisFileDirectory)Content\NPCConversations\NpcConversations_TraditionalChinese.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Splash_Daedalic.mp4">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Splash_FF.mp4">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Splash_UTG.mp4">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Texts\BrazilianPortugueseVanilla.xml"> <Content Include="$(MSBuildThisFileDirectory)Content\Texts\BrazilianPortugueseVanilla.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -614,9 +557,6 @@
<Content Include="$(MSBuildThisFileDirectory)Content\Tutorials\TutorialVideos\tutorial_deconstruct.mp4"> <Content Include="$(MSBuildThisFileDirectory)Content\Tutorials\TutorialVideos\tutorial_deconstruct.mp4">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Tutorials\TutorialVideos\tutorial_docking.mp4">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Tutorials\TutorialVideos\tutorial_equip.mp4"> <Content Include="$(MSBuildThisFileDirectory)Content\Tutorials\TutorialVideos\tutorial_equip.mp4">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -1691,6 +1631,9 @@
<Content Include="$(MSBuildThisFileDirectory)Content\Particles\UnderwaterExplosionSheet.png"> <Content Include="$(MSBuildThisFileDirectory)Content\Particles\UnderwaterExplosionSheet.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="$(MSBuildThisFileDirectory)Content\splashscreen.mp4">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Texts\EnglishVanilla.xml"> <Content Include="$(MSBuildThisFileDirectory)Content\Texts\EnglishVanilla.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -3203,6 +3146,9 @@
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\PickItemFail.ogg"> <None Include="$(MSBuildThisFileDirectory)Content\Sounds\PickItemFail.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\StartDrone.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\UI\ChatMsg.ogg"> <None Include="$(MSBuildThisFileDirectory)Content\Sounds\UI\ChatMsg.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
@@ -13,7 +13,7 @@ namespace Barotrauma
public override string DebugTag => "combat"; public override string DebugTag => "combat";
public bool useCoolDown = true; public bool useCoolDown = true;
const float CoolDown = 10.0f; const float coolDown = 10.0f;
public Character Enemy { get; private set; } public Character Enemy { get; private set; }
@@ -40,6 +40,7 @@ namespace Barotrauma
{ {
get get
{ {
if (Weapon == null) { return null; }
if (_weaponComponent == null) if (_weaponComponent == null)
{ {
_weaponComponent = _weaponComponent =
@@ -64,6 +65,8 @@ namespace Barotrauma
private Hull retreatTarget; private Hull retreatTarget;
private float coolDownTimer; private float coolDownTimer;
private IEnumerable<FarseerPhysics.Dynamics.Body> myBodies;
private float aimTimer;
public enum CombatMode public enum CombatMode
{ {
@@ -78,7 +81,7 @@ namespace Barotrauma
: base(character, objectiveManager, priorityModifier) : base(character, objectiveManager, priorityModifier)
{ {
Enemy = enemy; Enemy = enemy;
coolDownTimer = CoolDown; coolDownTimer = coolDown;
findSafety = objectiveManager.GetObjective<AIObjectiveFindSafety>(); findSafety = objectiveManager.GetObjective<AIObjectiveFindSafety>();
if (findSafety != null) if (findSafety != null)
{ {
@@ -127,7 +130,7 @@ namespace Barotrauma
} }
if (abandon) { return; } if (abandon) { return; }
Arm(deltaTime); Arm(deltaTime);
Move(deltaTime); Move();
} }
private void Arm(float deltaTime) private void Arm(float deltaTime)
@@ -148,9 +151,9 @@ namespace Barotrauma
{ {
Mode = CombatMode.Retreat; Mode = CombatMode.Retreat;
} }
if (Equip()) else if (Equip())
{ {
if (Reload(deltaTime)) if (Reload())
{ {
Attack(deltaTime); Attack(deltaTime);
} }
@@ -163,16 +166,16 @@ namespace Barotrauma
} }
} }
private void Move(float deltaTime) private void Move()
{ {
switch (Mode) switch (Mode)
{ {
case CombatMode.Offensive: case CombatMode.Offensive:
Engage(deltaTime); Engage();
break; break;
case CombatMode.Defensive: case CombatMode.Defensive:
case CombatMode.Retreat: case CombatMode.Retreat:
Retreat(deltaTime); Retreat();
break; break;
default: default:
throw new NotImplementedException(); throw new NotImplementedException();
@@ -263,6 +266,7 @@ namespace Barotrauma
if (character.Inventory.TryPutItem(Weapon, character, slots)) if (character.Inventory.TryPutItem(Weapon, character, slots))
{ {
Weapon.Equip(character); Weapon.Equip(character);
aimTimer = Rand.Range(1f, 2f);
} }
else else
{ {
@@ -273,7 +277,7 @@ namespace Barotrauma
return true; return true;
} }
private void Retreat(float deltaTime) private void Retreat()
{ {
if (followTargetObjective != null) if (followTargetObjective != null)
{ {
@@ -294,7 +298,7 @@ namespace Barotrauma
TryAddSubObjective(ref retreatObjective, () => new AIObjectiveGoTo(retreatTarget, character, objectiveManager, false, true)); TryAddSubObjective(ref retreatObjective, () => new AIObjectiveGoTo(retreatTarget, character, objectiveManager, false, true));
} }
private void Engage(float deltaTime) private void Engage()
{ {
retreatTarget = null; retreatTarget = null;
if (retreatObjective != null) if (retreatObjective != null)
@@ -323,7 +327,7 @@ namespace Barotrauma
}); });
} }
private bool Reload(float deltaTime) private bool Reload()
{ {
if (WeaponComponent != null && WeaponComponent.requiredItems.ContainsKey(RelatedItem.RelationType.Contained)) if (WeaponComponent != null && WeaponComponent.requiredItems.ContainsKey(RelatedItem.RelationType.Contained))
{ {
@@ -346,7 +350,6 @@ namespace Barotrauma
return reloadWeaponObjective == null || reloadWeaponObjective.IsCompleted(); return reloadWeaponObjective == null || reloadWeaponObjective.IsCompleted();
} }
private IEnumerable<FarseerPhysics.Dynamics.Body> myBodies;
private void Attack(float deltaTime) private void Attack(float deltaTime)
{ {
float squaredDistance = Vector2.DistanceSquared(character.Position, Enemy.Position); float squaredDistance = Vector2.DistanceSquared(character.Position, Enemy.Position);
@@ -371,6 +374,16 @@ namespace Barotrauma
character.SetInput(InputType.Aim, false, true); character.SetInput(InputType.Aim, false, true);
} }
} }
bool isFacing = character.AnimController.Dir > 0 && Enemy.WorldPosition.X > character.WorldPosition.X || character.AnimController.Dir < 0 && Enemy.WorldPosition.X < character.WorldPosition.X;
if (!isFacing)
{
aimTimer = Rand.Range(1f, 2f);
}
if (aimTimer > 0)
{
aimTimer -= deltaTime;
return;
}
if (WeaponComponent is MeleeWeapon meleeWeapon) if (WeaponComponent is MeleeWeapon meleeWeapon)
{ {
if (squaredDistance <= meleeWeapon.Range * meleeWeapon.Range) if (squaredDistance <= meleeWeapon.Range * meleeWeapon.Range)
@@ -385,14 +398,14 @@ namespace Barotrauma
{ {
if (squaredDistance > repairTool.Range * repairTool.Range) { return; } if (squaredDistance > repairTool.Range * repairTool.Range) { return; }
} }
if (VectorExtensions.Angle(VectorExtensions.Forward(Weapon.body.TransformedRotation), Enemy.Position - character.Position) < MathHelper.PiOver4) if (VectorExtensions.Angle(VectorExtensions.Forward(Weapon.body.TransformedRotation), Enemy.Position - Weapon.Position) < MathHelper.PiOver4)
{ {
if (myBodies == null) if (myBodies == null)
{ {
myBodies = character.AnimController.Limbs.Select(l => l.body.FarseerBody); myBodies = character.AnimController.Limbs.Select(l => l.body.FarseerBody);
} }
var collisionCategories = Physics.CollisionCharacter | Physics.CollisionWall; var collisionCategories = Physics.CollisionCharacter | Physics.CollisionWall;
var pickedBody = Submarine.PickBody(character.SimPosition, Enemy.SimPosition, myBodies, collisionCategories); var pickedBody = Submarine.PickBody(Weapon.SimPosition, Enemy.SimPosition, myBodies, collisionCategories);
if (pickedBody != null) if (pickedBody != null)
{ {
Character target = null; Character target = null;
@@ -404,10 +417,11 @@ namespace Barotrauma
{ {
target = limb.character; target = limb.character;
} }
if (target != null && target == Enemy) if (target != null && (target == Enemy || !HumanAIController.IsFriendly(target)))
{ {
character.SetInput(InputType.Shoot, false, true); character.SetInput(InputType.Shoot, false, true);
Weapon.Use(deltaTime, character); Weapon.Use(deltaTime, character);
aimTimer = Rand.Range(0.5f, 1f);
} }
} }
} }
@@ -650,6 +650,31 @@ namespace Barotrauma
{ {
#if DEBUG #if DEBUG
DebugConsole.ThrowError("AIObjectiveFixLeak failed - the item \"" + weldingTool + "\" has no RepairTool component but is tagged as a welding tool"); DebugConsole.ThrowError("AIObjectiveFixLeak failed - the item \"" + weldingTool + "\" has no RepairTool component but is tagged as a welding tool");
#endif
abandon = true;
return;
}
Vector2 gapDiff = Leak.WorldPosition - character.WorldPosition;
// TODO: use the collider size/reach?
if (!character.AnimController.InWater && Math.Abs(gapDiff.X) < 100 && gapDiff.Y < 0.0f && gapDiff.Y > -150)
{
HumanAIController.AnimController.Crouching = true;
}
float reach = ConvertUnits.ToSimUnits(repairTool.Range);
bool canOperate = ConvertUnits.ToSimUnits(gapDiff.Length()) < reach;
if (canOperate)
{
TryAddSubObjective(ref operateObjective, () => new AIObjectiveOperateItem(repairTool, character, objectiveManager, option: "", requireEquip: true, operateTarget: Leak));
}
else
{
TryAddSubObjective(ref gotoObjective, () => new AIObjectiveGoTo(ConvertUnits.ToSimUnits(GetStandPosition()), character, objectiveManager) { CloseEnough = reach * 0.75f });
}
var repairTool = weldingTool.GetComponent<RepairTool>();
if (repairTool == null)
{
#if DEBUG
DebugConsole.ThrowError("AIObjectiveFixLeak failed - the item \"" + weldingTool + "\" has no RepairTool component but is tagged as a welding tool");
#endif #endif
abandon = true; abandon = true;
return; return;
@@ -73,6 +73,21 @@ namespace Barotrauma
} }
} }
public override void Update(float deltaTime)
{
if (objectiveManager.CurrentObjective == this)
{
if (randomTimer > 0)
{
randomTimer -= deltaTime;
}
else
{
SetRandom();
}
}
}
public override bool IsCompleted() => false; public override bool IsCompleted() => false;
public override bool CanBeCompleted => true; public override bool CanBeCompleted => true;
@@ -162,6 +162,10 @@ namespace Barotrauma
{ {
isCompleted = true; isCompleted = true;
} }
if (component.AIOperate(deltaTime, character, this))
{
isCompleted = true;
}
} }
else else
{ {
@@ -49,7 +49,9 @@ namespace Barotrauma
if (wayPoint == null) continue; if (wayPoint == null) continue;
if (nodes.ContainsKey(wayPoint.ID)) if (nodes.ContainsKey(wayPoint.ID))
{ {
#if DEBUG
DebugConsole.ThrowError("Error in PathFinder.GenerateNodes (duplicate ID \"" + wayPoint.ID + "\")"); DebugConsole.ThrowError("Error in PathFinder.GenerateNodes (duplicate ID \"" + wayPoint.ID + "\")");
#endif
continue; continue;
} }
nodes.Add(wayPoint.ID, new PathNode(wayPoint)); nodes.Add(wayPoint.ID, new PathNode(wayPoint));
@@ -201,7 +203,9 @@ namespace Barotrauma
if (startNode == null) if (startNode == null)
{ {
#if DEBUG
DebugConsole.NewMessage("Pathfinding error, couldn't find a start node. "+ errorMsgStr, Color.DarkRed); DebugConsole.NewMessage("Pathfinding error, couldn't find a start node. "+ errorMsgStr, Color.DarkRed);
#endif
return new SteeringPath(true); return new SteeringPath(true);
} }
@@ -251,7 +255,9 @@ namespace Barotrauma
if (endNode == null) if (endNode == null)
{ {
#if DEBUG
DebugConsole.NewMessage("Pathfinding error, couldn't find an end node. " + errorMsgStr, Color.DarkRed); DebugConsole.NewMessage("Pathfinding error, couldn't find an end node. " + errorMsgStr, Color.DarkRed);
#endif
return new SteeringPath(true); return new SteeringPath(true);
} }
@@ -279,7 +285,9 @@ namespace Barotrauma
if (startNode == null || endNode == null) if (startNode == null || endNode == null)
{ {
#if DEBUG
DebugConsole.NewMessage("Pathfinding error, couldn't find matching pathnodes to waypoints.", Color.DarkRed); DebugConsole.NewMessage("Pathfinding error, couldn't find matching pathnodes to waypoints.", Color.DarkRed);
#endif
return new SteeringPath(true); return new SteeringPath(true);
} }
@@ -395,7 +403,9 @@ namespace Barotrauma
//should be fixed now, was most likely caused by the parent fields of the nodes not being cleared before starting the pathfinding //should be fixed now, was most likely caused by the parent fields of the nodes not being cleared before starting the pathfinding
if (finalPath.Count > nodes.Count) if (finalPath.Count > nodes.Count)
{ {
#if DEBUG
DebugConsole.ThrowError("Pathfinding error: constructing final path failed"); DebugConsole.ThrowError("Pathfinding error: constructing final path failed");
#endif
return new SteeringPath(true); return new SteeringPath(true);
} }
@@ -867,6 +867,25 @@ namespace Barotrauma.Items.Components
} }
} }
if (targetItem.Prefab.DeconstructItems.Any())
{
inputContainer.Inventory.RemoveItem(targetItem);
Entity.Spawner.AddToRemoveQueue(targetItem);
MoveInputQueue();
PutItemsToLinkedContainer();
}
else
{
if (outputContainer.Inventory.Items.All(i => i != null))
{
targetItem.Drop(dropper: null);
}
else
{
outputContainer.Inventory.TryPutItem(targetItem, user: null, createNetworkEvent: true);
}
}
if (targetItem.Prefab.DeconstructItems.Any()) if (targetItem.Prefab.DeconstructItems.Any())
{ {
inputContainer.Inventory.RemoveItem(targetItem); inputContainer.Inventory.RemoveItem(targetItem);
@@ -212,33 +212,6 @@ namespace Barotrauma.Items.Components
} }
} }
public Vector2? PosToMaintain
{
get { return posToMaintain; }
set { posToMaintain = value; }
}
struct ObstacleDebugInfo
{
public Vector2 Point1;
public Vector2 Point2;
public Vector2? Intersection;
public float Dot;
public Vector2 AvoidStrength;
public ObstacleDebugInfo(GraphEdge edge, Vector2? intersection, float dot, Vector2 avoidStrength)
{
Point1 = edge.Point1;
Point2 = edge.Point2;
Intersection = intersection;
Dot = dot;
AvoidStrength = avoidStrength;
}
}
//edge point 1, edge point 2, avoid strength //edge point 1, edge point 2, avoid strength
private List<ObstacleDebugInfo> debugDrawObstacles = new List<ObstacleDebugInfo>(); private List<ObstacleDebugInfo> debugDrawObstacles = new List<ObstacleDebugInfo>();
@@ -152,8 +152,7 @@ namespace Barotrauma.Items.Components
ParentSub = item.CurrentHull?.Submarine, ParentSub = item.CurrentHull?.Submarine,
Position = item.Position, Position = item.Position,
CastShadows = castShadows, CastShadows = castShadows,
IsBackground = drawBehindSubs, IsBackground = drawBehindSubs
SpriteScale = Vector2.One * item.Scale
}; };
#endif #endif
@@ -1808,6 +1808,10 @@ namespace Barotrauma
{ {
ApplyStatusEffects(!waterProof && inWater ? ActionType.InWater : ActionType.NotInWater, deltaTime); ApplyStatusEffects(!waterProof && inWater ? ActionType.InWater : ActionType.NotInWater, deltaTime);
} }
if (!broken)
{
ApplyStatusEffects(!waterProof && inWater ? ActionType.InWater : ActionType.NotInWater, deltaTime);
}
ApplyStatusEffects(!waterProof && inWater ? ActionType.InWater : ActionType.NotInWater, deltaTime); ApplyStatusEffects(!waterProof && inWater ? ActionType.InWater : ActionType.NotInWater, deltaTime);
if (body == null || !body.Enabled || !inWater || ParentInventory != null || Removed) { return; } if (body == null || !body.Enabled || !inWater || ParentInventory != null || Removed) { return; }
@@ -398,6 +398,25 @@ namespace Barotrauma
} }
} }
public string DisplayName
{
get;
private set;
}
private string roomName;
[Editable, Serialize("", true, translationTextTag: "RoomName.")]
public string RoomName
{
get { return roomName; }
set
{
if (roomName == value) { return; }
roomName = value;
DisplayName = TextManager.Get(roomName, returnNull: true) ?? roomName;
}
}
public override Rectangle Rect public override Rectangle Rect
{ {
get get
Binary file not shown.
Binary file not shown.
Binary file not shown.