Release v0.15.13.0

This commit is contained in:
Joonas Rikkonen
2021-11-02 13:19:48 +02:00
parent a52a23f8c2
commit 3a35dbfe6c
77 changed files with 509 additions and 224 deletions
@@ -338,15 +338,18 @@ namespace Barotrauma
previousOffset = offset;
}
//how much to zoom out (zoom completely out when offset is 1000)
float zoomOutAmount = GetZoomAmount(offset);
//scaled zoom amount
float scaledZoom = MathHelper.Lerp(DefaultZoom, MinZoom, zoomOutAmount) * globalZoomScale;
//zoom in further if zoomOutAmount is low and resolution is lower than reference
float newZoom = scaledZoom * (MathHelper.Lerp(0.3f * (1f - Math.Min(globalZoomScale, 1f)), 0f,
(GameMain.Config == null || GameMain.Config.EnableMouseLook) ? (float)Math.Sqrt(offsetUnscaledLen) : 0.3f) + 1f);
if (allowZoom)
{
//how much to zoom out (zoom completely out when offset is 1000)
float zoomOutAmount = GetZoomAmount(offset);
//scaled zoom amount
float scaledZoom = MathHelper.Lerp(DefaultZoom, MinZoom, zoomOutAmount) * globalZoomScale;
//zoom in further if zoomOutAmount is low and resolution is lower than reference
float newZoom = scaledZoom * (MathHelper.Lerp(0.3f * (1f - Math.Min(globalZoomScale, 1f)), 0f,
(GameMain.Config == null || GameMain.Config.EnableMouseLook) ? (float)Math.Sqrt(offsetUnscaledLen) : 0.3f) + 1f);
Zoom += (newZoom - zoom) / ZoomSmoothness;
Zoom += (newZoom - zoom) / ZoomSmoothness;
}
//force targetzoom to the current zoom value, so the camera stays at the same zoom when switching to freecam
targetZoom = Zoom;
@@ -332,7 +332,7 @@ namespace Barotrauma
{
cam.OffsetAmount = targetOffsetAmount = 0.0f;
cursorPosition =
SelectedConstruction.Position +
Position +
PlayerInput.MouseSpeed.ClampLength(10.0f); //apply a little bit of movement to the cursor pos to prevent AFK kicking
}
else if (!GameMain.Config.EnableMouseLook)
@@ -1096,6 +1096,7 @@ namespace Barotrauma
private SoundChannel soundChannel;
public void PlaySound(CharacterSound.SoundType soundType, float soundIntervalFactor = 1.0f, float maxInterval = 0)
{
if (Removed) { return; }
if (sounds == null || sounds.Count == 0) { return; }
if (soundChannel != null && soundChannel.IsPlaying) { return; }
if (GameMain.SoundManager?.Disabled ?? true) { return; }
@@ -452,11 +452,17 @@ namespace Barotrauma
ushort itemID = msg.ReadUInt16();
if (!(Entity.FindEntityByID(itemID) is Item item)) { continue; }
item.AllowStealing = true;
var wifiComponent = item.GetComponent<Items.Components.WifiComponent>();
var wifiComponent = item.GetComponent<WifiComponent>();
if (wifiComponent != null)
{
wifiComponent.TeamID = teamID;
}
var idCard = item.GetComponent<IdCard>();
if (idCard != null)
{
idCard.TeamID = teamID;
idCard.SubmarineSpecificID = 0;
}
}
break;
case 10: //NetEntityEvent.Type.UpdateExperience
@@ -83,7 +83,13 @@ namespace Barotrauma
var equipIdentifiers = Element.GetChildElements("ItemSet").Elements().Where(e => e.GetAttributeBool("outfit", false)).Select(e => e.GetAttributeString("identifier", ""));
var outfitPrefabs = ItemPrefab.Prefabs.Where(itemPrefab => equipIdentifiers.Contains(itemPrefab.Identifier)).ToList();
List<ItemPrefab> outfitPrefabs = new List<ItemPrefab>();
foreach (var equipIdentifier in equipIdentifiers)
{
var itemPrefab = ItemPrefab.Prefabs.Find(ip => ip.Identifier == equipIdentifier);
if (itemPrefab != null) { outfitPrefabs.Add(itemPrefab); }
}
if (!outfitPrefabs.Any()) { return null; }
for (int i = 0; i < outfitPrefabs.Count; i++)
@@ -256,6 +256,15 @@ namespace Barotrauma
/// </summary>
public bool CanInteractWhenUnfocusable { get; set; } = false;
public override Rectangle MouseRect
{
get
{
if (!CanBeFocused && !CanInteractWhenUnfocusable) { return Rectangle.Empty; }
return ClampMouseRectToParent ? ClampRect(Rect) : Rect;
}
}
/// <param name="isScrollBarOnDefaultSide">For horizontal listbox, default side is on the bottom. For vertical, it's on the right.</param>
public GUIListBox(RectTransform rectT, bool isHorizontal = false, Color? color = null, string style = "", bool isScrollBarOnDefaultSide = true, bool useMouseDownToSelect = false) : base(style, rectT)
{
@@ -770,8 +779,13 @@ namespace Barotrauma
BarScroll += speed * Math.Sign(diff) / TotalSize;
}
}
if (PlayerInput.ScrollWheelSpeed != 0 && AllowMouseWheelScroll && (FindScrollableParentListBox(GUI.MouseOn) == this || GUI.IsMouseOn(ScrollBar)))
bool IsMouseOn() =>
FindScrollableParentListBox(GUI.MouseOn) == this ||
GUI.IsMouseOn(ScrollBar) ||
(CanInteractWhenUnfocusable && Content.Rect.Contains(PlayerInput.MousePosition));
if (PlayerInput.ScrollWheelSpeed != 0 && AllowMouseWheelScroll && IsMouseOn())
{
if (SmoothScroll)
{
@@ -463,7 +463,6 @@ namespace Barotrauma
{
SubmarineInfo previousSub = GameMain.GameSession.SubmarineInfo;
GameMain.GameSession.SubmarineInfo = PendingSubmarineSwitch;
PendingSubmarineSwitch = null;
for (int i = 0; i < GameMain.GameSession.OwnedSubmarines.Count; i++)
{
@@ -476,6 +475,7 @@ namespace Barotrauma
}
SaveUtil.SaveGame(GameMain.GameSession.SavePath);
PendingSubmarineSwitch = null;
}
else
{
@@ -516,6 +516,9 @@ namespace Barotrauma
}
}
private readonly static List<SlotReference> hideSubInventories = new List<SlotReference>();
private readonly static List<SlotReference> tempHighlightedSubInventorySlots = new List<SlotReference>();
public override void Update(float deltaTime, Camera cam, bool isSubInventory = false)
{
if (!AccessibleWhenAlive && !character.IsDead)
@@ -579,15 +582,17 @@ namespace Barotrauma
}
}
}
List<SlotReference> hideSubInventories = new List<SlotReference>();
hideSubInventories.Clear();
//remove highlighted subinventory slots that can no longer be accessed
highlightedSubInventorySlots.RemoveWhere(s =>
s.ParentInventory == this &&
((s.SlotIndex < 0 || s.SlotIndex >= slots.Length || slots[s.SlotIndex] == null) || (Character.Controlled != null && !Character.Controlled.CanAccessInventory(s.Inventory))));
//remove highlighted subinventory slots that refer to items no longer in this inventory
highlightedSubInventorySlots.RemoveWhere(s => s.Item != null && s.ParentInventory == this && s.Item.ParentInventory != this);
foreach (var highlightedSubInventorySlot in highlightedSubInventorySlots)
tempHighlightedSubInventorySlots.Clear();
tempHighlightedSubInventorySlots.AddRange(highlightedSubInventorySlots);
foreach (var highlightedSubInventorySlot in tempHighlightedSubInventorySlots)
{
if (highlightedSubInventorySlot.ParentInventory == this)
{
@@ -300,6 +300,8 @@ namespace Barotrauma.Items.Components
{
requiresRecipeText.RectTransform.RepositionChildInHierarchy(itemList.Content.RectTransform.GetChildIndex(firstRequiresRecipe.RectTransform));
}
HideEmptyItemListCategories();
}
private void DrawInputOverLay(SpriteBatch spriteBatch, GUICustomComponent overlayComponent)
@@ -479,6 +481,13 @@ namespace Barotrauma.Items.Components
child.Visible = recipe.DisplayName.ToLower().Contains(filter);
}
HideEmptyItemListCategories();
return true;
}
private void HideEmptyItemListCategories()
{
//go through the elements backwards, and disable the labels ("insufficient skills to fabricate", "recipe required...") if there's no items below them
bool recipeVisible = false;
foreach (GUIComponent child in itemList.Content.Children.Reverse())
@@ -490,14 +499,12 @@ namespace Barotrauma.Items.Components
}
else
{
recipeVisible = child.Visible;
recipeVisible |= child.Visible;
}
}
itemList.UpdateScrollBarSize();
itemList.BarScroll = 0.0f;
return true;
}
public bool ClearFilter()
@@ -36,7 +36,7 @@ namespace Barotrauma.Items.Components
internal readonly struct MiniMapSprite
{
public readonly Sprite Sprite;
public readonly Sprite? Sprite;
public readonly Color Color;
public MiniMapSprite(JobPrefab prefab)
@@ -1302,6 +1302,8 @@ namespace Barotrauma.Items.Components
int i = 0;
foreach (MiniMapSprite info in cardsToDraw)
{
if (info.Sprite is null) { continue; }
float spriteSize = info.Sprite.size.X * (parentWidth / info.Sprite.size.X) + padding;
if (totalWidth + spriteSize > frame.Rect.Width) { break; }
@@ -1318,7 +1320,8 @@ namespace Barotrauma.Items.Components
foreach (MiniMapSprite info in cardsToDraw)
{
Sprite sprite = info.Sprite;
Sprite? sprite = info.Sprite;
if (sprite is null) { continue; }
float scale = parentWidth / sprite.size.X;
float spriteSize = sprite.size.X * scale;
float posX = adjustedCenterX + offset;
@@ -88,7 +88,7 @@ namespace Barotrauma.Items.Components
Vector2 startPos = GetSourcePos();
startPos.Y = -startPos.Y;
if (source is Item sourceItem)
if (source is Item sourceItem && !sourceItem.Removed)
{
var turret = sourceItem.GetComponent<Turret>();
var weapon = sourceItem.GetComponent<RangedWeapon>();
@@ -540,7 +540,7 @@ namespace Barotrauma
}
}*/
bool mouseOn = interactRect.Contains(PlayerInput.MousePosition) && !Locked && !mouseOnGUI && !slot.Disabled;
bool mouseOn = interactRect.Contains(PlayerInput.MousePosition) && !Locked && !mouseOnGUI && !slot.Disabled && IsMouseOnInventory;
// Delete item from container in sub editor
if (SubEditorScreen.IsSubEditor() && PlayerInput.IsCtrlDown())
@@ -863,6 +863,8 @@ namespace Barotrauma
{
return false;
}
if (GameSession.IsTabMenuOpen) { return false; }
if (CrewManager.IsCommandInterfaceOpen) { return false; }
if (Character.Controlled == null) { return false; }
@@ -1313,6 +1315,10 @@ namespace Barotrauma
private static bool CanSelectSlot(SlotReference selectedSlot)
{
if (!IsMouseOnInventory)
{
return false;
}
if (!selectedSlot.Slot.MouseOn())
{
return false;
@@ -1335,7 +1341,8 @@ namespace Barotrauma
if ((parentItem?.GetRootInventoryOwner() is Character ownerCharacter) &&
ownerCharacter == Character.Controlled &&
CharacterHealth.OpenHealthWindow?.Character != ownerCharacter &&
ownerCharacter.Inventory.IsInLimbSlot(parentItem, InvSlotType.HealthInterface))
ownerCharacter.Inventory.IsInLimbSlot(parentItem, InvSlotType.HealthInterface) &&
Screen.Selected != GameMain.SubEditorScreen)
{
highlightedSubInventorySlots.RemoveWhere(s => s.Item == parentItem);
return false;
@@ -543,6 +543,7 @@ namespace Barotrauma
partial void OnCollisionProjSpecific(float impact)
{
if (impact > 1.0f &&
Container == null &&
!string.IsNullOrEmpty(Prefab.ImpactSoundTag) &&
Timing.TotalTime > LastImpactSoundTime + ImpactSoundInterval)
{
@@ -98,12 +98,10 @@ namespace Barotrauma
private IEnumerable<object> DimLight(LightSource light)
{
float currBrightness = 1.0f;
float startRange = light.Range;
while (light.Color.A > 0.0f && flashDuration > 0.0f)
{
light.Color = new Color(light.Color.R, light.Color.G, light.Color.B, currBrightness);
currBrightness -= (1.0f / flashDuration) * CoroutineManager.DeltaTime;
light.Color = new Color(light.Color.R, light.Color.G, light.Color.B, (byte)(currBrightness * 255));
currBrightness -= 1.0f / flashDuration * CoroutineManager.DeltaTime;
yield return CoroutineStatus.Running;
}
@@ -529,7 +529,7 @@ namespace Barotrauma.Lights
graphics.Clear(Color.Black);
Vector2 diff = lookAtPosition - ViewTarget.WorldPosition;
diff.Y = -diff.Y;
if (diff.LengthSquared() > 30.0f) { losOffset = diff; }
if (diff.LengthSquared() > 20.0f * 20.0f) { losOffset = diff; }
float rotation = MathUtils.VectorToAngle(losOffset);
Vector2 scale = new Vector2(
@@ -64,7 +64,18 @@ namespace Barotrauma.Networking
string orderOption = orderMessageInfo.OrderOption;
orderOption ??= orderMessageInfo.OrderOptionIndex.HasValue && orderMessageInfo.OrderOptionIndex >= 0 && orderMessageInfo.OrderOptionIndex < orderPrefab.Options.Length ?
orderPrefab.Options[orderMessageInfo.OrderOptionIndex.Value] : "";
txt = orderPrefab.GetChatMessage(orderMessageInfo.TargetCharacter?.Name, senderCharacter?.CurrentHull?.DisplayName,
string targetRoom;
if (orderMessageInfo.TargetEntity is Hull targetHull)
{
targetRoom = targetHull.DisplayName;
}
else
{
targetRoom = senderCharacter?.CurrentHull?.DisplayName;
}
txt = orderPrefab.GetChatMessage(orderMessageInfo.TargetCharacter?.Name, targetRoom,
givingOrderToSelf: orderMessageInfo.TargetCharacter == senderCharacter,
orderOption: orderOption,
priority: orderMessageInfo.Priority);
@@ -1,6 +1,7 @@
#region Using Statements
using System;
using System.Collections.Generic;
using Barotrauma.IO;
using System.Linq;
using System.Text;
@@ -132,8 +133,11 @@ namespace Barotrauma
{
XElement newElement = new XElement(doc.Root.Name);
newElement.Add(doc.Root.Attributes());
newElement.Add(doc.Root.Elements().Where(e => !e.Name.LocalName.Equals("contentpackage", StringComparison.InvariantCultureIgnoreCase)));
newElement.Add(baseDoc.Root.Elements().Where(e => e.Name.LocalName.Equals("contentpackage", StringComparison.InvariantCultureIgnoreCase)));
string[] contentPackageTags = { "contentpackage", "contentpackages" };
bool elementNameMatches(XElement element)
=> contentPackageTags.Any(t => element.Name.LocalName.Equals(t, StringComparison.InvariantCultureIgnoreCase));
newElement.Add(doc.Root.Elements().Where(e => !elementNameMatches(e)));
newElement.Add(baseDoc.Root.Elements().Where(e => elementNameMatches(e)));
XDocument newDoc = new XDocument(newElement);
newDoc.Save(GameSettings.PlayerSavePath);
sb.AppendLine("To prevent further startup errors, installed mods will be disabled the next time you launch the game.");
@@ -866,6 +866,8 @@ namespace Barotrauma
return true;
}
CloseItem();
backedUpSubInfo = new SubmarineInfo(Submarine.MainSub);
GameMain.GameScreen.Select();
@@ -1328,6 +1330,8 @@ namespace Barotrauma
{
base.Deselect();
CloseItem();
autoSaveLabel?.Parent?.RemoveChild(autoSaveLabel);
autoSaveLabel = null;
@@ -3057,9 +3061,24 @@ namespace Barotrauma
new ContextMenuOption("SubEditor.PasteAssembly", isEnabled: true, () => PasteAssembly()),
new ContextMenuOption("Editor.SelectSame", isEnabled: targets.Count > 0, onSelected: delegate
{
bool doorGapSelected = targets.Any(t => t is Gap gap && gap.ConnectedDoor != null);
foreach (MapEntity match in MapEntity.mapEntityList.Where(e => e.prefab != null && targets.Any(t => t.prefab?.Identifier == e.prefab.Identifier) && !MapEntity.SelectedList.Contains(e)))
{
if (MapEntity.SelectedList.Contains(match)) { continue; }
if (match is Gap gap)
{
//don't add non-door gaps if we've selected a door gap (and vice versa)
if ((gap.ConnectedDoor == null) == doorGapSelected) { continue; }
}
else if (match is Item item)
{
//add door gaps too if we're selecting doors
var door = item.GetComponent<Door>();
if (door?.LinkedGap != null && !MapEntity.SelectedList.Contains(door.LinkedGap))
{
MapEntity.SelectedList.Add(door.LinkedGap);
}
}
MapEntity.SelectedList.Add(match);
}
}),
@@ -4171,6 +4190,11 @@ namespace Barotrauma
UpdateEntityList();
}
if (OpenedItem != null && OpenedItem.Removed)
{
OpenedItem = null;
}
if (WiringMode && dummyCharacter != null)
{
Wire equippedWire =
@@ -960,7 +960,7 @@ namespace Barotrauma
targetMusic[i] = null;
break;
}
musicChannel[i] = currentMusic[i].Play(0.0f, i == noiseLoopIndex ? "" : "music");
musicChannel[i] = currentMusic[i].Play(0.0f, i == noiseLoopIndex ? "default" : "music");
if (targetMusic[i].ContinueFromPreviousTime)
{
musicChannel[i].StreamSeekPos = targetMusic[i].PreviousTime;
@@ -974,7 +974,7 @@ namespace Barotrauma
if (musicChannel[i] == null || !musicChannel[i].IsPlaying)
{
musicChannel[i]?.Dispose();
musicChannel[i] = currentMusic[i].Play(0.0f, i == noiseLoopIndex ? "" : "music");
musicChannel[i] = currentMusic[i].Play(0.0f, i == noiseLoopIndex ? "default" : "music");
musicChannel[i].Looping = true;
}
float targetGain = targetMusic[i].Volume;