diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs
index 3be451f56..9cfd58b0f 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs
@@ -211,23 +211,22 @@ namespace Barotrauma
Vector2 mouseSimPos = ConvertUnits.ToSimUnits(cursorPosition);
if (GUI.PauseMenuOpen)
{
- cam.OffsetAmount = targetOffsetAmount = 0.0f;
- }
- else if (Lights.LightManager.ViewTarget is Item item && item.Prefab.FocusOnSelected)
- {
- cam.OffsetAmount = targetOffsetAmount = item.Prefab.OffsetOnSelected;
+ targetOffsetAmount = 0.0f;
+ cam.OffsetAmount = 0.0f;
}
else if (SelectedConstruction != null && ViewTarget == null &&
SelectedConstruction.Components.Any(ic => ic?.GuiFrame != null && ic.ShouldDrawHUD(this)))
{
- cam.OffsetAmount = targetOffsetAmount = 0.0f;
+ targetOffsetAmount = 0.0f;
+ cam.OffsetAmount = 0.0f;
cursorPosition =
SelectedConstruction.Position +
new Vector2(cursorPosition.X % 10.0f, cursorPosition.Y % 10.0f); //apply a little bit of movement to the cursor pos to prevent AFK kicking
}
else if (!GameMain.Config.EnableMouseLook)
{
- cam.OffsetAmount = targetOffsetAmount = 0.0f;
+ targetOffsetAmount = 0.0f;
+ cam.OffsetAmount = 0.0f;
}
else if (Lights.LightManager.ViewTarget == this && Vector2.DistanceSquared(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f)
{
@@ -235,7 +234,8 @@ namespace Barotrauma
{
if (deltaTime > 0.0f)
{
- cam.OffsetAmount = targetOffsetAmount = 0.0f;
+ targetOffsetAmount = 0.0f;
+ cam.OffsetAmount = 0.0f;
}
}
else
diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs
index 4333dc5c4..91bb79c26 100644
--- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs
+++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs
@@ -66,6 +66,33 @@ namespace Barotrauma
CanBeFocused = false
};
+ Point scrollButtonSize = new Point((int)(200 * GUI.Scale), (int)(30 * GUI.Scale));
+
+ crewArea = new GUIFrame(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.CrewArea, guiFrame.RectTransform), "", Color.Transparent)
+ {
+ CanBeFocused = false
+ };
+ toggleCrewButton = new GUIButton(new RectTransform(new Point((int)(30 * GUI.Scale), HUDLayoutSettings.CrewArea.Height), guiFrame.RectTransform)
+ { AbsoluteOffset = HUDLayoutSettings.CrewArea.Location },
+ "", style: "UIToggleButton");
+ toggleCrewButton.OnClicked += (GUIButton btn, object userdata) =>
+ {
+ toggleCrewAreaOpen = !toggleCrewAreaOpen;
+ foreach (GUIComponent child in btn.Children)
+ {
+ child.SpriteEffects = toggleCrewAreaOpen ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
+ }
+ return true;
+ };
+
+ characterListBox = new GUIListBox(new RectTransform(new Point(100, (int)(crewArea.Rect.Height - scrollButtonSize.Y * 1.6f)), crewArea.RectTransform, Anchor.CenterLeft), false, Color.Transparent, null)
+ {
+ //Spacing = (int)(3 * GUI.Scale),
+ ScrollBarEnabled = false,
+ ScrollBarVisible = false,
+ CanBeFocused = false
+ };
+
var characterInfo = new CharacterInfo(subElement);
characterInfos.Add(characterInfo);
foreach (XElement invElement in subElement.Elements())
@@ -81,6 +108,16 @@ namespace Barotrauma
prevUIScale = GUI.Scale;
}
+
+ #endregion
+
+ #region Character list management
+
+ public Rectangle GetCharacterListArea()
+ {
+ return characterListBox.Rect;
+ }
+
partial void InitProjectSpecific()
{
guiFrame = new GUIFrame(new RectTransform(Vector2.One, GUICanvas.Instance), null, Color.Transparent)
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/ItemComponent.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/ItemComponent.cs
index 5cd9780b0..cc9829018 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Components/ItemComponent.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Components/ItemComponent.cs
@@ -175,142 +175,6 @@ namespace Barotrauma.Items.Components
}
}
}
-
- public void ApplyTo(RectTransform target)
- {
- if (RelativeOffset.HasValue)
- {
- target.RelativeOffset = RelativeOffset.Value;
- }
- else if (AbsoluteOffset.HasValue)
- {
- target.AbsoluteOffset = AbsoluteOffset.Value;
- }
- if (RelativeSize.HasValue)
- {
- target.RelativeSize = RelativeSize.Value;
- }
- else if (AbsoluteSize.HasValue)
- {
- target.NonScaledSize = AbsoluteSize.Value;
- }
- if (Anchor.HasValue)
- {
- target.Anchor = Anchor.Value;
- }
- if (Pivot.HasValue)
- {
- target.Pivot = Pivot.Value;
- }
- else
- {
- target.Pivot = RectTransform.MatchPivotToAnchor(target.Anchor);
- }
- target.RecalculateChildren(true, true);
- }
- }
-
- public GUIFrame GuiFrame { get; protected set; }
-
- [Serialize(false, false)]
- public bool AllowUIOverlap
- {
- get;
- set;
- }
-
- private ItemComponent linkToUIComponent;
- [Serialize("", false)]
- public string LinkUIToComponent
- {
- get;
- set;
- }
-
- [Serialize(0, false)]
- public int HudPriority
- {
- get;
- private set;
- }
-
- private bool useAlternativeLayout;
- public bool UseAlternativeLayout
- {
- get { return useAlternativeLayout; }
- set
- {
- if (AlternativeLayout != null)
- {
- if (value == useAlternativeLayout) { return; }
- useAlternativeLayout = value;
- if (useAlternativeLayout)
- {
- AlternativeLayout?.ApplyTo(GuiFrame.RectTransform);
- }
- else
- {
- DefaultLayout?.ApplyTo(GuiFrame.RectTransform);
- }
- }
- }
-
- public void ApplyTo(RectTransform target)
- {
- if (RelativeOffset.HasValue)
- {
- target.RelativeOffset = RelativeOffset.Value;
- }
- else if (AbsoluteOffset.HasValue)
- {
- target.AbsoluteOffset = AbsoluteOffset.Value;
- }
- if (RelativeSize.HasValue)
- {
- target.RelativeSize = RelativeSize.Value;
- }
- else if (AbsoluteSize.HasValue)
- {
- target.NonScaledSize = AbsoluteSize.Value;
- }
- if (Anchor.HasValue)
- {
- target.Anchor = Anchor.Value;
- }
- if (Pivot.HasValue)
- {
- target.Pivot = Pivot.Value;
- }
- else
- {
- target.Pivot = RectTransform.MatchPivotToAnchor(target.Anchor);
- }
- target.RecalculateChildren(true, true);
- }
- }
-
- public GUIFrame GuiFrame { get; protected set; }
-
- [Serialize(false, false)]
- public bool AllowUIOverlap
- {
- get;
- set;
- }
-
- private ItemComponent linkToUIComponent;
- [Serialize("", false)]
- public string LinkUIToComponent
- {
- get;
- set;
- }
-
- [Serialize(0, false)]
- public int HudPriority
- {
- get;
- private set;
}
private bool shouldMuffleLooping;
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Turret.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Turret.cs
index 479c724d4..6e42a2949 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Components/Turret.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Turret.cs
@@ -339,14 +339,11 @@ namespace Barotrauma.Items.Components
}
}
- float zoom = cam == null ? 1.0f : (float)Math.Sqrt(cam.Zoom);
-
- crosshairSprite?.Draw(spriteBatch, crosshairPos, readyToFire ? Color.White : Color.White * 0.2f, 0, zoom);
- crosshairPointerSprite?.Draw(spriteBatch, crosshairPointerPos, 0, zoom);
- }
-
- crosshairSprite?.Draw(spriteBatch, crosshairPos, readyToFire ? Color.White : Color.White * 0.2f, 0, zoom);
- crosshairPointerSprite?.Draw(spriteBatch, crosshairPointerPos, 0, zoom);
+ if (crosshairSprite != null)
+ {
+ crosshairSprite.Draw(spriteBatch, crosshairPos, readyToFire ? Color.White : Color.White * 0.2f, 0, (float)Math.Sqrt(cam.Zoom));
+ }
+ if (crosshairPointerSprite != null) crosshairPointerSprite.Draw(spriteBatch, crosshairPointerPos, 0, (float)Math.Sqrt(cam.Zoom));
}
public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime)
diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs
index 85a27e914..a2bf3adc1 100644
--- a/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs
+++ b/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs
@@ -44,9 +44,12 @@ namespace Barotrauma
public SteamWorkshopScreen()
{
+ int width = Math.Min(GameMain.GraphicsWidth - 160, 1000);
+ int height = Math.Min(GameMain.GraphicsHeight - 160, 700);
+
tabs = new GUIFrame[Enum.GetValues(typeof(Tab)).Length];
- menu = new GUIFrame(new RectTransform(new Vector2(0.6f, 0.8f), GUI.Canvas, Anchor.Center) { MinSize = new Point(GameMain.GraphicsHeight, 0) });
+ menu = new GUIFrame(new RectTransform(new Vector2(0.6f, 0.7f), GUI.Canvas, Anchor.Center) { MinSize = new Point(width, height) });
var container = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.85f), menu.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0.0f, 0.05f) }) { Stretch = true };
@@ -119,8 +122,7 @@ namespace Barotrauma
}
};
- var findModsButtonContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.03f), listContainer.RectTransform), style: null);
- new GUIButton(new RectTransform(new Vector2(0.8f, 0.8f), findModsButtonContainer.RectTransform, Anchor.Center), TextManager.Get("FindModsButton"), style: "GUIButtonLarge")
+ new GUIButton(new RectTransform(new Vector2(1.0f, 0.03f), listContainer.RectTransform), TextManager.Get("FindModsButton"))
{
OnClicked = (btn, userdata) =>
{
@@ -618,7 +620,7 @@ namespace Barotrauma
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), item.Title, textAlignment: Alignment.TopLeft, font: GUI.LargeFont, wrap: true);
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), TextManager.Get("WorkshopItemCreator") + ": " + item.OwnerName, textAlignment: Alignment.BottomLeft, wrap: true);
- var headerAreaBackground = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), content.RectTransform, maxSize: new Point(int.MaxValue, 235))) { Color = Color.Black };
+ var headerAreaBackground = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.59f), content.RectTransform, maxSize: new Point(int.MaxValue, 235))) { Color = Color.Black };
var headerArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 1.0f), headerAreaBackground.RectTransform), childAnchor: Anchor.Center);
@@ -691,9 +693,9 @@ namespace Barotrauma
//spacing
new GUIFrame(new RectTransform(new Vector2(0.0f, 0.015f), content.RectTransform), style: null);
- var steamButtonHolder = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), content.RectTransform), style: null);
+ var steamButtonHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), content.RectTransform));
- new GUIButton(new RectTransform(new Vector2(0.8f, 1.0f), steamButtonHolder.RectTransform, Anchor.Center), TextManager.Get("WorkshopShowItemInSteam"), style: "GUIButtonLarge")
+ new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), steamButtonHolder.RectTransform), TextManager.Get("WorkshopShowItemInSteam"))
{
OnClicked = (btn, userdata) =>
{
diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs
index 4bc964d71..62fd2aa30 100644
--- a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs
+++ b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs
@@ -143,16 +143,11 @@ namespace Barotrauma
private void CreateUI()
{
- TopPanel = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), GUI.Canvas) { MinSize = new Point(0, 35) }, "GUIFrameTop");
-
- GUIFrame paddedTopPanel = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.55f), TopPanel.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0.0f, -0.1f) }, style: null);
-
- var button = new GUIButton(new RectTransform(new Vector2(0.07f, 0.9f), paddedTopPanel.RectTransform, Anchor.CenterLeft), TextManager.Get("Back"))
- {
- OnClicked = GameMain.MainMenuScreen.ReturnToMainMenu
- };
-
- button = new GUIButton(new RectTransform(new Vector2(0.07f, 0.9f), paddedTopPanel.RectTransform, Anchor.CenterLeft) { RelativeOffset = new Vector2(0.07f, 0.0f) }, TextManager.Get("OpenSubButton"))
+ TopPanel = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.04f), GUI.Canvas) { MinSize = new Point(0, 35) }, "GUIFrameTop");
+ GUIFrame paddedTopPanel = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.55f), TopPanel.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0.0f, -0.1f) },
+ style: null);
+
+ var button = new GUIButton(new RectTransform(new Vector2(0.07f, 0.9f), paddedTopPanel.RectTransform, Anchor.CenterLeft), TextManager.Get("OpenSubButton"))
{
OnClicked = (GUIButton btn, object data) =>
{
@@ -163,7 +158,7 @@ namespace Barotrauma
}
};
- button = new GUIButton(new RectTransform(new Vector2(0.07f, 0.9f), paddedTopPanel.RectTransform, Anchor.CenterLeft) { RelativeOffset = new Vector2(0.14f, 0.0f) }, TextManager.Get("SaveSubButton"))
+ button = new GUIButton(new RectTransform(new Vector2(0.07f, 0.9f), paddedTopPanel.RectTransform, Anchor.CenterLeft) { RelativeOffset = new Vector2(0.08f, 0.0f) }, TextManager.Get("SaveSubButton"))
{
OnClicked = (GUIButton btn, object data) =>
{
@@ -174,13 +169,13 @@ namespace Barotrauma
}
};
- var nameLabel = new GUITextBlock(new RectTransform(new Vector2(0.1f, 0.9f), paddedTopPanel.RectTransform, Anchor.CenterLeft) { RelativeOffset = new Vector2(0.21f, 0.0f) },
+ var nameLabel = new GUITextBlock(new RectTransform(new Vector2(0.1f, 0.9f), paddedTopPanel.RectTransform, Anchor.CenterLeft) { RelativeOffset = new Vector2(0.15f, 0.0f) },
"", font: GUI.LargeFont, textAlignment: Alignment.CenterLeft)
{
TextGetter = GetSubName
};
- linkedSubBox = new GUIDropDown(new RectTransform(new Vector2(0.15f, 0.9f), paddedTopPanel.RectTransform) { RelativeOffset = new Vector2(0.385f, 0.0f) },
+ linkedSubBox = new GUIDropDown(new RectTransform(new Vector2(0.15f, 0.9f), paddedTopPanel.RectTransform) { RelativeOffset = new Vector2(0.4f, 0.0f) },
TextManager.Get("AddSubButton"), elementCount: 20)
{
ToolTip = TextManager.Get("AddSubToolTip")
@@ -284,13 +279,12 @@ namespace Barotrauma
var paddedTab = new GUIFrame(new RectTransform(new Vector2(1.0f, 1.0f), EntityMenu.RectTransform, Anchor.Center), style: null);
- var filterArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedTab.RectTransform) { AbsoluteOffset = new Point(0, 10) }, isHorizontal: true)
+ var filterArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedTab.RectTransform), isHorizontal: true)
{
Color = secondaryColor,
Stretch = true,
UserData = "filterarea"
};
-
new GUITextBlock(new RectTransform(new Vector2(0.05f, 1.0f), filterArea.RectTransform), TextManager.Get("FilterMapEntities"), font: GUI.Font);
entityFilterBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), font: GUI.Font);
entityFilterBox.OnTextChanged += (textBox, text) => { FilterEntities(text); return true; };
@@ -299,7 +293,7 @@ namespace Barotrauma
OnClicked = (btn, userdata) => { ClearFilter(); entityFilterBox.Flash(Color.White); return true; }
};
- var entityListHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.85f), paddedTab.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0.0f, 0.06f) });
+ var entityListHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.85f), paddedTab.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0.0f, 0.05f) });
var tabButtonHolder = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.1f), entityListHolder.RectTransform, Anchor.TopRight, Pivot.BottomRight),
isHorizontal: true)
@@ -359,24 +353,21 @@ namespace Barotrauma
}
};
- button = new GUIButton(new RectTransform(new Vector2(1.0f, 0.025f), paddedLeftPanel.RectTransform), TextManager.Get("GenerateWaypointsButton"), style: null, color: new Color(70, 100, 122, 255))
+ //empty guiframe as a separator
+ new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), paddedLeftPanel.RectTransform), style: null);
+
+ button = new GUIButton(new RectTransform(new Vector2(1.0f, 0.025f), paddedLeftPanel.RectTransform), TextManager.Get("GenerateWaypointsButton"))
{
- ForceUpperCase = true,
- HoverColor = new Color(33, 33, 33, 255),
- TextColor = Color.White,
ToolTip = TextManager.Get("GenerateWaypointsToolTip"),
OnClicked = GenerateWaypoints
};
- //spacing
- new GUIFrame(new RectTransform(new Vector2(1.0f, 0.01f), paddedLeftPanel.RectTransform), style: null);
+ // empty guiframe as a separator
+ new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), paddedLeftPanel.RectTransform), style: null);
var showEntitiesHolder = new GUILayoutGroup(new RectTransform(new Vector2(paddedLeftPanel.RectTransform.RelativeSize.X, 0.3f), paddedLeftPanel.RectTransform))
{ Color = secondaryColor, Stretch = true, RelativeSpacing = 0.05f };
- //spacing
- new GUIFrame(new RectTransform(new Vector2(1.0f, 0.0f), showEntitiesHolder.RectTransform) { MinSize = new Point(0, 3) }, style: null);
-
var tickBox = new GUITickBox(new RectTransform(new Point(32, 32), showEntitiesHolder.RectTransform) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("ShowLighting"))
{
Selected = lightingEnabled,
@@ -440,9 +431,6 @@ namespace Barotrauma
OnSelected = (GUITickBox obj) => { Gap.ShowGaps = obj.Selected; return true; },
};
- //spacing
- new GUIFrame(new RectTransform(new Vector2(1.0f, 0.0f), showEntitiesHolder.RectTransform) { MinSize = new Point(0, 3) }, style: null);
-
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.025f), paddedLeftPanel.RectTransform, Anchor.BottomCenter) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("PreviouslyUsedLabel"));
previouslyUsedList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.2f), paddedLeftPanel.RectTransform, Anchor.BottomCenter) { AbsoluteOffset = new Point(10, 0) })
{
@@ -861,8 +849,6 @@ namespace Barotrauma
GUI.AddMessage(TextManager.Get("SubSavedNotification").Replace("[filepath]", Submarine.MainSub.FilePath), Color.Green);
- Submarine.RefreshSavedSub(savePath);
-
linkedSubBox.ClearChildren();
foreach (Submarine sub in Submarine.SavedSubmarines)
{
@@ -2224,19 +2210,19 @@ namespace Barotrauma
Sprite backgroundSprite = LevelGenerationParams.LevelParams.Find(l => l.BackgroundTopSprite != null).BackgroundTopSprite;
- using (RenderTarget2D rt = new RenderTarget2D(
- GameMain.Instance.GraphicsDevice,
- width, height, false, SurfaceFormat.Color, DepthFormat.None))
- using (SpriteBatch spriteBatch = new SpriteBatch(GameMain.Instance.GraphicsDevice))
+ Sprite backgroundSprite = LevelGenerationParams.LevelParams.Find(l => l.BackgroundTopSprite != null).BackgroundTopSprite;
+ if (backgroundSprite != null)
{
- GameMain.Instance.GraphicsDevice.SetRenderTarget(rt);
-
- if (backgroundSprite != null)
- {
- spriteBatch.Begin();
- backgroundSprite.Draw(spriteBatch, Vector2.Zero, new Color(0.025f, 0.075f, 0.131f, 1.0f));
- spriteBatch.End();
- }
+ spriteBatch.Begin();
+ backgroundSprite.Draw(spriteBatch, Vector2.Zero, new Color(0.025f, 0.075f, 0.131f, 1.0f));
+ spriteBatch.End();
+ }
+
+ spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, transform);
+ Submarine.Draw(spriteBatch, false);
+ Submarine.DrawFront(spriteBatch);
+ Submarine.DrawDamageable(spriteBatch, null);
+ spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, transform);
Submarine.Draw(spriteBatch, false);
diff --git a/Barotrauma/BarotraumaShared/Data/ContentPackages/Vanilla 0.9.xml b/Barotrauma/BarotraumaShared/Data/ContentPackages/Vanilla 0.9.xml
index 7a10d5467..98144c0a5 100644
--- a/Barotrauma/BarotraumaShared/Data/ContentPackages/Vanilla 0.9.xml
+++ b/Barotrauma/BarotraumaShared/Data/ContentPackages/Vanilla 0.9.xml
@@ -75,6 +75,7 @@
+
diff --git a/Barotrauma/BarotraumaShared/SharedContent.projitems b/Barotrauma/BarotraumaShared/SharedContent.projitems
index 141ff1db9..0a05f74a7 100644
--- a/Barotrauma/BarotraumaShared/SharedContent.projitems
+++ b/Barotrauma/BarotraumaShared/SharedContent.projitems
@@ -1913,18 +1913,6 @@
PreserveNewest
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
PreserveNewest
@@ -2482,6 +2470,9 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest
@@ -3092,6 +3083,9 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest
diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs
index f62bc7629..f5821b46b 100644
--- a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs
+++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs
@@ -289,15 +289,17 @@ namespace Barotrauma
public override void OnAttacked(Character attacker, AttackResult attackResult)
{
- // Damage from falling etc.
- if (Character.LastDamageSource == null) { return; }
float damage = attackResult.Damage;
if (damage <= 0) { return; }
if (attacker == null || attacker.IsDead || attacker.Removed)
{
- AddCombatObjective(AIObjectiveCombat.CombatMode.Retreat, Rand.Range(0.5f, 1f, Rand.RandSync.Unsynced));
+ if (objectiveManager.CurrentOrder == null)
+ {
+ objectiveManager.GetObjective().Priority = 100;
+ }
+ return;
}
- else if (IsFriendly(attacker))
+ if (IsFriendly(attacker))
{
if (attacker.AnimController.Anim == Barotrauma.AnimController.Animation.CPR && attacker.SelectedCharacter == Character)
{
@@ -307,50 +309,51 @@ namespace Barotrauma
}
if (!attacker.IsRemotePlayer && Character.Controlled != attacker && attacker.AIController != null && attacker.AIController.Enabled)
{
- // Don't retaliate on damage done by friendly ai, because we know that it's accidental
- AddCombatObjective(AIObjectiveCombat.CombatMode.Retreat, Rand.Range(0.5f, 1f, Rand.RandSync.Unsynced));
+ // Don't react to damage done by friendly ai, because we know that it's accidental
+ if (objectiveManager.CurrentOrder == null)
+ {
+ objectiveManager.GetObjective().Priority = 100;
+ }
+ return;
+ }
+ float currentVitality = Character.CharacterHealth.Vitality;
+ float dmgPercentage = damage / currentVitality * 100;
+ if (dmgPercentage < currentVitality / 10)
+ {
+ // Don't react to a minor amount of (accidental) dmg done by friendly characters
+ if (objectiveManager.CurrentOrder == null)
+ {
+ objectiveManager.GetObjective().Priority = 100;
+ }
+ }
+ if (ObjectiveManager.CurrentObjective is AIObjectiveCombat combatObjective)
+ {
+ if (combatObjective.Enemy != attacker)
+ {
+ // Replace the old objective with the new.
+ ObjectiveManager.Objectives.Remove(combatObjective);
+ objectiveManager.AddObjective(new AIObjectiveCombat(Character, attacker));
+ }
}
else
{
- float currentVitality = Character.CharacterHealth.Vitality;
- float dmgPercentage = damage / currentVitality * 100;
- if (dmgPercentage < currentVitality / 10)
- {
- // Don't retaliate on minor (accidental) dmg done by friendly characters
- AddCombatObjective(AIObjectiveCombat.CombatMode.Retreat, Rand.Range(0.5f, 1f, Rand.RandSync.Unsynced));
- }
- else
- {
- AddCombatObjective(AIObjectiveCombat.CombatMode.Defensive, Rand.Range(0.5f, 1f, Rand.RandSync.Unsynced));
- }
+ objectiveManager.AddObjective(new AIObjectiveCombat(Character, attacker), Rand.Range(0.5f, 1f, Rand.RandSync.Unsynced));
}
}
else
- {
- AddCombatObjective(AIObjectiveCombat.CombatMode.Defensive);
- }
-
- void AddCombatObjective(AIObjectiveCombat.CombatMode mode, float delay = 0)
{
if (ObjectiveManager.CurrentObjective is AIObjectiveCombat combatObjective)
{
- if (combatObjective.Enemy != attacker || (combatObjective.Enemy == null && attacker == null))
+ if (combatObjective.Enemy != attacker)
{
// Replace the old objective with the new.
ObjectiveManager.Objectives.Remove(combatObjective);
- objectiveManager.AddObjective(new AIObjectiveCombat(Character, attacker, mode));
+ objectiveManager.AddObjective(new AIObjectiveCombat(Character, attacker));
}
}
else
{
- if (delay > 0)
- {
- objectiveManager.AddObjective(new AIObjectiveCombat(Character, attacker, mode), delay);
- }
- else
- {
- objectiveManager.AddObjective(new AIObjectiveCombat(Character, attacker, mode));
- }
+ objectiveManager.AddObjective(new AIObjectiveCombat(Character, attacker));
}
}
}
diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs
index 6c3d6ba8a..4d0cc72bc 100644
--- a/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs
+++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs
@@ -43,80 +43,11 @@ namespace Barotrauma
private set;
}
- ///
- /// Returns true if the current or the next node is in ladders.
- ///
- public bool InLadders =>
- currentPath != null &&
- currentPath.CurrentNode != null && (currentPath.CurrentNode.Ladders != null ||
- (currentPath.NextNode != null && currentPath.NextNode.Ladders != null));
+ public bool InLadders => currentPath != null && currentPath.CurrentNode != null && currentPath.CurrentNode.Ladders != null;
+ public bool IsNextNodeLadder => currentPath.NextNode != null && currentPath.CurrentNode.Ladders != null;
+ public bool IsNextLadderSameAsCurrent => IsNextNodeLadder && currentPath.CurrentNode.Ladders == currentPath.NextNode.Ladders;
- ///
- /// Returns true if the current or the next node is in stairs.
- ///
- public bool InStairs =>
- currentPath != null &&
- currentPath.CurrentNode != null && (currentPath.CurrentNode.Stairs != null ||
- (currentPath.NextNode != null && currentPath.NextNode.Stairs != null));
-
- public bool IsNextNodeLadder
- {
- get
- {
- if (currentPath == null) { return false; }
- if (currentPath.NextNode == null) { return false; }
- if (currentPath.NextNode.Ladders != null)
- {
- return true;
- }
- else
- {
- // Check if the node after the next node is ladder.
- int index = currentPath.CurrentIndex + 2;
- if (currentPath.Nodes.Count > index)
- {
- var node = currentPath.Nodes[index];
- if (node == null) { return false; }
- // Only applied if the node is close enough to the current node.
- if (Vector2.DistanceSquared(currentPath.CurrentNode.WorldPosition, node.WorldPosition) > 100) { return false; }
- return node.Ladders != null;
- }
- return false;
- }
- }
- }
-
- public bool IsNextLadderSameAsCurrent
- {
- get
- {
- if (currentPath == null) { return false; }
- if (currentPath.CurrentNode == null) { return false; }
- if (currentPath.NextNode == null) { return false; }
- var currentLadder = currentPath.CurrentNode.Ladders;
- if (currentLadder == null) { return false; }
- var nextLadder = currentPath.NextNode.Ladders;
- if (nextLadder != null)
- {
- return currentLadder == nextLadder;
- }
- else
- {
- // Check if the node after the next node is in the same ladder as the current.
- int index = currentPath.CurrentIndex + 2;
- if (currentPath.Nodes.Count > index)
- {
- var node = currentPath.Nodes[index];
- if (node == null) { return false; }
- // Only applied if the node is close enough to the current node.
- if (Vector2.DistanceSquared(currentPath.CurrentNode.WorldPosition, node.WorldPosition) > 100) { return false; }
- nextLadder = node.Ladders;
- return nextLadder != null && nextLadder == currentLadder;
- }
- return false;
- }
- }
- }
+ public bool InStairs => currentPath != null && currentPath.CurrentNode != null && currentPath.CurrentNode.Stairs != null;
public IndoorsSteeringManager(ISteerable host, bool canOpenDoors, bool canBreakDoors) : base(host)
{
@@ -242,7 +173,7 @@ namespace Barotrauma
Vector2 diff = currentPath.CurrentNode.SimPosition - pos;
bool nextLadderSamesCurrent = IsNextLadderSameAsCurrent;
- if (nextLadderSamesCurrent)
+ if (IsNextLadderSameAsCurrent)
{
//climbing ladders -> don't move horizontally
diff.X = 0.0f;
@@ -260,14 +191,14 @@ namespace Barotrauma
bool aboveFloor = heightFromFloor > 0.0f && heightFromFloor < collider.height * 1.5f;
if (aboveFloor || IsNextNodeLadder)
{
- if (!nextLadderSamesCurrent)
+ if (!IsNextLadderSameAsCurrent)
{
character.AnimController.Anim = AnimController.Animation.None;
}
currentPath.SkipToNextNode();
}
}
- else if (nextLadderSamesCurrent)
+ else if (IsNextLadderSameAsCurrent)
{
//if the current node is below the character and the next one is above (or vice versa)
//and both are on ladders, we can skip directly to the next one
diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs
index 6b7dda849..bebfe4ad5 100644
--- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs
+++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs
@@ -47,32 +47,25 @@ namespace Barotrauma
private float coolDownTimer;
- public enum CombatMode
- {
- Defensive,
- Offensive, // Not implemented
- Retreat
- }
-
- public CombatMode Mode { get; private set; }
-
- public AIObjectiveCombat(Character character, Character enemy, CombatMode mode) : base(character, "")
+ public AIObjectiveCombat(Character character, Character enemy) : base(character, "")
{
Enemy = enemy;
coolDownTimer = CoolDown;
HumanAIController.ObjectiveManager.GetObjective().Priority = 0;
- Mode = mode;
- if (Enemy == null)
- {
- Mode = CombatMode.Retreat;
- }
}
protected override void Act(float deltaTime)
{
coolDownTimer -= deltaTime;
- if (abandon) { return; }
- switch (Mode)
+ if (Weapon != null && character.Inventory.Items.Contains(_weapon))
+ {
+ Weapon = null;
+ }
+ if (Weapon == null)
+ {
+ Weapon = GetWeapon();
+ }
+ if (Weapon == null)
{
case CombatMode.Defensive:
if (Weapon != null && character.Inventory.Items.Contains(_weapon))
@@ -104,6 +97,17 @@ namespace Barotrauma
default:
throw new System.NotImplementedException();
}
+ else if (Equip(deltaTime))
+ {
+ if (Reload(deltaTime))
+ {
+ Attack(deltaTime);
+ }
+ }
+ if (!abandon)
+ {
+ Move(deltaTime);
+ }
}
private Item GetWeapon()
@@ -164,18 +168,20 @@ namespace Barotrauma
else
{
//couldn't equip the item, escape
- //Abandon(deltaTime);
+ Escape(deltaTime);
return false;
}
}
return true;
}
- private void Retreat(float deltaTime)
+ private void Move(float deltaTime)
{
+ // Retreat to safety
+ // TODO: aggressive behaviour, chasing?
if (retreatTarget == null || (retreatObjective != null && !retreatObjective.CanBeCompleted))
{
- retreatTarget = HumanAIController.ObjectiveManager.GetObjective().FindBestHull(new List() { character.CurrentHull });
+ retreatTarget = HumanAIController.ObjectiveManager.GetObjective().FindBestHull();
}
if (retreatTarget != null)
{
@@ -212,7 +218,7 @@ namespace Barotrauma
}
else if (!reloadWeaponObjective.CanBeCompleted)
{
- Mode = CombatMode.Retreat;
+ Escape(deltaTime);
}
else
{
@@ -271,16 +277,16 @@ namespace Barotrauma
}
}
- private void Abandon(float deltaTime)
+ private void Escape(float deltaTime)
{
abandon = true;
SteeringManager.Reset();
- //HumanAIController.ObjectiveManager.GetObjective().Priority = 100;
+ HumanAIController.ObjectiveManager.GetObjective().Priority = 100;
}
public override bool IsCompleted()
{
- bool completed = (Enemy != null && (Enemy.Removed || Enemy.IsDead)) || coolDownTimer <= 0;
+ bool completed = Enemy == null || Enemy.Removed || Enemy.IsDead || coolDownTimer <= 0;
if (completed)
{
if (Weapon != null)
@@ -292,7 +298,7 @@ namespace Barotrauma
}
public override bool CanBeCompleted => !abandon && (reloadWeaponObjective == null || reloadWeaponObjective.CanBeCompleted) && (retreatObjective == null || retreatObjective.CanBeCompleted);
- public override float GetPriority(AIObjectiveManager objectiveManager) => (Enemy != null && (Enemy.Removed || Enemy.IsDead)) ? 0 : 100;
+ public override float GetPriority(AIObjectiveManager objectiveManager) => Enemy == null || Enemy.Removed || Enemy.IsDead ? 0 : 100;
public override bool IsDuplicate(AIObjective otherObjective)
{
diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs
index f5965df98..d07b4019d 100644
--- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs
+++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs
@@ -86,10 +86,7 @@ namespace Barotrauma
character.AIController.SteeringManager.Reset();
character.CursorPosition = fs.Position;
- if (extinguisher.Item.RequireAimToUse)
- {
- character.SetInput(InputType.Aim, false, true);
- }
+ character.SetInput(InputType.Aim, false, true);
extinguisher.Use(deltaTime, character);
if (!targetHull.FireSources.Contains(fs))
diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs
index 0b5032321..12c490f57 100644
--- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs
+++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs
@@ -168,14 +168,13 @@ namespace Barotrauma
}
}
- public Hull FindBestHull(IEnumerable ignoredHulls = null)
+ public Hull FindBestHull()
{
- Hull bestHull = null;
- float bestValue = 0;
+ Hull bestHull = character.CurrentHull;
+ float bestValue = currenthullSafety;
foreach (Hull hull in Hull.hullList)
{
if (hull.Submarine == null) { continue; }
- if (ignoredHulls != null && ignoredHulls.Contains(hull)) { continue; }
float hullSafety = 0;
if (character.Submarine != null && SteeringManager == PathSteering)
{
diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs
index deb96d2a7..51668ae2a 100644
--- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs
+++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs
@@ -161,7 +161,7 @@ namespace Barotrauma
private void OperateRepairTool(float deltaTime)
{
character.CursorPosition = Item.Position;
- if (repairTool.Item.RequireAimToUse)
+ if (Item.RequireAimToUse)
{
character.SetInput(InputType.Aim, false, true);
}
diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/MeleeWeapon.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/MeleeWeapon.cs
index c9210a753..978fc07b4 100644
--- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/MeleeWeapon.cs
+++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/MeleeWeapon.cs
@@ -64,7 +64,6 @@ namespace Barotrauma.Items.Components
attack = new Attack(subElement, item.Name + ", MeleeWeapon");
}
item.IsShootable = true;
- // TODO: should define this in xml if we have melee weapons that don't require aim to use
item.RequireAimToUse = true;
}
diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RangedWeapon.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RangedWeapon.cs
index 966bd5761..0f6f5a0fc 100644
--- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RangedWeapon.cs
+++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RangedWeapon.cs
@@ -58,7 +58,6 @@ namespace Barotrauma.Items.Components
: base(item, element)
{
item.IsShootable = true;
- // TODO: should define this in xml if we have ranged weapons that don't require aim to use
item.RequireAimToUse = true;
}
diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs
index c4fcb94ec..e3f8896ee 100644
--- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs
+++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs
@@ -80,7 +80,6 @@ namespace Barotrauma.Items.Components
}
}
item.IsShootable = true;
- // TODO: should define this in xml if we have repair tools that don't require aim to use
item.RequireAimToUse = true;
InitProjSpecific(element);
}
diff --git a/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs b/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs
index 720e4bb23..bd72ea94c 100644
--- a/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs
+++ b/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs
@@ -533,6 +533,25 @@ namespace Barotrauma
{
maxX = Math.Min(maxX, ruin.Area.X - 100.0f);
}
+ else
+ {
+ maxX = Math.Min(maxX, ruin.Area.X - 100.0f);
+ }
+ }
+
+ if (minX < 0.0f && maxX > Level.Loaded.Size.X)
+ {
+ //no walls found at either side, just use the initial spawnpos and hope for the best
+ }
+ else if (minX < 0)
+ {
+ //no wall found at the left side, spawn to the left from the right-side wall
+ spawnPos.X = maxX - minWidth - 100.0f + subDockingPortOffset;
+ }
+ else if (maxX > Level.Loaded.Size.X)
+ {
+ //no wall found at right side, spawn to the right from the left-side wall
+ spawnPos.X = minX + minWidth + 100.0f + subDockingPortOffset;
}
if (minX < 0.0f && maxX > Level.Loaded.Size.X)