Unstable 0.1500.2.0 (Rokvach's dog edition)

This commit is contained in:
Markus Isberg
2021-09-10 04:52:34 +09:00
parent e7b7c1a748
commit 1231170fce
126 changed files with 2424 additions and 1083 deletions
@@ -48,8 +48,13 @@ namespace Barotrauma
{
color = Color.CornflowerBlue;
}
else if (Entity is Item)
else if (Entity is Item i)
{
if (i.Submarine != null && i.GetComponent<Items.Components.Door>() == null)
{
// Don't show items that are inside the submarine, because monsters shouldn't target them when they are inside and the monsters are outside.
return;
}
color = Color.CadetBlue;
}
else
@@ -1,12 +1,12 @@
using Barotrauma.Extensions;
using Barotrauma.Networking;
using System;
using System;
using System.Linq;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Xml.Linq;
using System.IO;
using Barotrauma.IO;
using Barotrauma.Items.Components;
namespace Barotrauma
@@ -624,7 +624,7 @@ namespace Barotrauma
ch.ChangeSavedStatValue((StatTypes)statType, statValue, statIdentifier, removeOnDeath);
}
ch.ExperiencePoints = inc.ReadUInt16();
ch.AdditionalTalentPoints = inc.ReadUInt16();
return ch;
}
}
@@ -422,6 +422,8 @@ namespace Barotrauma
}
}
}
healthWindowVerticalLayout.Recalculate();
}
private void OnAttacked(Character attacker, AttackResult attackResult)
@@ -950,6 +952,16 @@ namespace Barotrauma
UpdateAlignment();
}
foreach (Affliction affliction in afflictions)
{
if (affliction.Prefab.AfflictionOverlay != null)
{
Sprite ScreenAfflictionOverlay = affliction.Prefab.AfflictionOverlay;
ScreenAfflictionOverlay?.Draw(spriteBatch, Vector2.Zero, Color.White * (affliction.GetAfflictionOverlayMultiplier()), Vector2.Zero, 0.0f,
new Vector2(GameMain.GraphicsWidth / DamageOverlay.size.X, GameMain.GraphicsHeight / DamageOverlay.size.Y));
}
}
float damageOverlayAlpha = DamageOverlayTimer;
if (Vitality < MaxVitality * 0.1f)
{
@@ -5,8 +5,8 @@ using System.Linq;
namespace Barotrauma
{
public class GUIFrame : GUIComponent
{
public int OutlineThickness { get; set; }
{
public float OutlineThickness { get; set; }
public GUIFrame(RectTransform rectT, string style = "", Color? color = null) : base(style, rectT)
{
@@ -49,7 +49,7 @@ namespace Barotrauma
public UISprite ButtonPulse { get; private set; }
public SpriteSheet FocusIndicator { get; private set; }
public UISprite IconOverflowIndicator { get; private set; }
/// <summary>
@@ -462,7 +462,7 @@ namespace Barotrauma
public void Apply(GUIComponent targetComponent, string styleName = "", GUIComponent parent = null)
{
GUIComponentStyle componentStyle = null;
GUIComponentStyle componentStyle = null;
if (parent != null)
{
GUIComponentStyle parentStyle = parent.Style;
@@ -477,7 +477,7 @@ namespace Barotrauma
return;
}
}
string childStyleName = string.IsNullOrEmpty(styleName) ? targetComponent.GetType().Name : styleName;
parentStyle.ChildStyles.TryGetValue(childStyleName.ToLowerInvariant(), out componentStyle);
}
@@ -493,8 +493,8 @@ namespace Barotrauma
return;
}
}
targetComponent.ApplyStyle(componentStyle);
targetComponent.ApplyStyle(componentStyle);
}
}
}
@@ -125,7 +125,7 @@ namespace Barotrauma
public TabMenu()
{
if (!initialized) Initialize();
if (!initialized) { Initialize(); }
CreateInfoFrame(selectedTab);
SelectInfoFrameTab(null, selectedTab);
@@ -260,6 +260,10 @@ namespace Barotrauma
}
var talentsButton = createTabButton(InfoFrameTab.Talents, "tabmenu.talents");
talentsButton.OnAddedToGUIUpdateList += (GUIComponent component) =>
{
talentsButton.Enabled = Character.Controlled?.Info != null && GameMain.GameSession?.Campaign != null;
};
}
private bool SelectInfoFrameTab(GUIButton button, object userData)
@@ -1177,8 +1181,6 @@ namespace Barotrauma
private GUITextBlock talentPointsText;
private GUITextBlock experienceText;
private Color experienceBackgroundColor = new Color(255, 255, 255, 155);
private GUIProgressBar experienceBar;
private void CreateTalentInfo(GUIFrame infoFrame)
@@ -1186,12 +1188,13 @@ namespace Barotrauma
infoFrame.ClearChildren();
talentButtons.Clear();
Character controlledCharacter = Character.Controlled;
if (controlledCharacter == null) { return; }
GUIFrame talentFrameBackground = new GUIFrame(new RectTransform(Vector2.One, infoFrame.RectTransform, Anchor.TopCenter), style: "GUIFrameListBox");
int padding = GUI.IntScale(15);
GUIFrame talentFrameContent = new GUIFrame(new RectTransform(new Point(talentFrameBackground.Rect.Width - padding, talentFrameBackground.Rect.Height - padding), infoFrame.RectTransform, Anchor.Center), style: null);
Character controlledCharacter = Character.Controlled;
if (controlledCharacter.Info == null)
{
DebugConsole.ThrowError("No character info found for talent UI");
@@ -51,7 +51,7 @@ namespace Barotrauma
{
keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length];
keyMapping[(int)InputType.Run] = new KeyOrMouse(Keys.LeftShift);
keyMapping[(int)InputType.Attack] = new KeyOrMouse(Keys.R);
keyMapping[(int)InputType.Attack] = new KeyOrMouse(Keys.F);
keyMapping[(int)InputType.Crouch] = new KeyOrMouse(Keys.LeftControl);
keyMapping[(int)InputType.Grab] = new KeyOrMouse(Keys.G);
keyMapping[(int)InputType.Health] = new KeyOrMouse(Keys.H);
@@ -688,6 +688,11 @@ namespace Barotrauma
{
break;
}
//if putting an item to a container with a max stack size of 1, only put one item from the stack
if (quickUseAction == QuickUseAction.PutToContainer && (character.SelectedConstruction?.GetComponent<ItemContainer>()?.MaxStackSize ?? 0) <= 1)
{
break;
}
}
}
@@ -31,11 +31,23 @@ namespace Barotrauma.Items.Components
name = TextManager.GetWithVariable("entityname.taintedgeneticmaterial", "[geneticmaterialname]", name);
}
if (TextManager.ContainsTag("entitydescription."+Item.prefab.Identifier))
if (TextManager.ContainsTag("entitydescription." + Item.prefab.Identifier))
{
int value = (int)MathHelper.Lerp(TooltipValueMin, TooltipValueMax, item.ConditionPercentage / 100.0f);
int value = (int)MathHelper.Lerp(TooltipValueMin, TooltipValueMax, item.ConditionPercentage / 100.0f);
description = TextManager.GetWithVariable("entitydescription." + Item.prefab.Identifier, "[value]", value.ToString());
}
foreach (Item containedItem in item.ContainedItems)
{
var containedGeneticMaterial = containedItem.GetComponent<GeneticMaterial>();
if (containedGeneticMaterial == null) { continue; }
string _ = string.Empty;
string containedDescription = containedItem.Description;
containedGeneticMaterial.AddTooltipInfo(ref _, ref containedDescription);
if (!string.IsNullOrEmpty(containedDescription))
{
description += '\n' + containedDescription;
}
}
}
public void ModifyDeconstructInfo(Deconstructor deconstructor, ref string buttonText, ref string infoText)
@@ -19,6 +19,8 @@ namespace Barotrauma.Items.Components
/// </summary>
private float[] containedSpriteDepths;
private Sprite[] slotIcons;
public Sprite InventoryTopSprite
{
get { return inventoryTopSprite; }
@@ -88,6 +90,7 @@ namespace Barotrauma.Items.Components
partial void InitProjSpecific(XElement element)
{
slotIcons = new Sprite[capacity];
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
@@ -107,6 +110,17 @@ namespace Barotrauma.Items.Components
case "containedstateindicatorempty":
ContainedStateIndicatorEmpty = new Sprite(subElement);
break;
case "sloticon":
int index = subElement.GetAttributeInt("slotindex", -1);
Sprite icon = new Sprite(subElement);
for (int i = 0; i < capacity; i++)
{
if (i == index || index == -1)
{
slotIcons[i] = icon;
}
}
break;
}
}
@@ -208,6 +222,12 @@ namespace Barotrauma.Items.Components
}
}
public Sprite GetSlotIcon(int slotIndex)
{
if (slotIndex < 0 || slotIndex >= slotIcons.Length) { return null; }
return slotIcons[slotIndex];
}
public bool KeepOpenWhenEquippedBy(Character character)
{
if (!character.CanAccessInventory(Inventory) ||
@@ -24,6 +24,9 @@ namespace Barotrauma.Items.Components
[Serialize("DeconstructorDeconstruct", true)]
public string ActivateButtonText { get; set; }
[Serialize("", true)]
public string InfoText { get; set; }
[Serialize(0.0f, true)]
public float InfoAreaWidth { get; set; }
@@ -102,8 +105,8 @@ namespace Barotrauma.Items.Components
var outputArea = new GUILayoutGroup(new RectTransform(new Vector2(1f, 1f), bottomFrame.RectTransform, Anchor.CenterLeft), childAnchor: Anchor.BottomLeft, isHorizontal: true) { Stretch = true, RelativeSpacing = 0.05f };
// === OUTPUT SLOTS === //
outputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(1f - InfoAreaWidth, 1f), outputArea.RectTransform, Anchor.CenterLeft), style: null);
// === OUTPUT SLOTS === //
outputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(1f - InfoAreaWidth, 1f), outputArea.RectTransform, Anchor.CenterLeft), style: null);
if (InfoAreaWidth >= 0.0f)
{
@@ -114,10 +117,18 @@ namespace Barotrauma.Items.Components
ActivateButton.OnAddedToGUIUpdateList += (GUIComponent component) =>
{
activateButton.Enabled = true;
infoArea.Text = string.Empty;
if (string.IsNullOrEmpty(InfoText))
{
infoArea.Text = string.Empty;
}
else
{
infoArea.Text = TextManager.Get(InfoText, returnNull: true) ?? InfoText;
}
if (IsActive)
{
activateButton.Text = TextManager.Get("DeconstructorCancel");
infoArea.Text = string.Empty;
return;
}
bool outputsFound = false;
@@ -12,24 +12,24 @@ namespace Barotrauma.Items.Components
{
internal readonly struct MiniMapGUIComponent
{
public readonly GUIComponent Component;
public readonly GUIComponent RectComponent;
public readonly GUIComponent BorderComponent;
public MiniMapGUIComponent(GUIComponent component)
public MiniMapGUIComponent(GUIComponent rectComponent)
{
Component = component;
BorderComponent = component;
RectComponent = rectComponent;
BorderComponent = rectComponent;
}
public MiniMapGUIComponent(GUIComponent frame, GUIComponent linkedHullComponent)
{
Component = frame;
RectComponent = frame;
BorderComponent = linkedHullComponent;
}
public void Deconstruct(out GUIComponent component, out GUIComponent borderComponent)
{
component = Component;
component = RectComponent;
borderComponent = BorderComponent;
}
}
@@ -183,6 +183,7 @@ namespace Barotrauma.Items.Components
private ImmutableDictionary<MapEntity, MiniMapGUIComponent> hullStatusComponents;
private ImmutableDictionary<MapEntity, MiniMapGUIComponent> electricalMapComponents;
private ImmutableDictionary<MiniMapGUIComponent, GUIComponent> electricalChildren;
private ImmutableDictionary<MiniMapGUIComponent, GUIComponent> doorChildren;
private ImmutableHashSet<ItemPrefab> itemsFoundOnSub;
@@ -190,7 +191,7 @@ namespace Barotrauma.Items.Components
private float blipState;
private const float maxBlipState = 1f;
private const float maxZoom = 2f,
private const float maxZoom = 10f,
minZoom = 0.5f,
defaultZoom = 1f;
@@ -209,13 +210,15 @@ namespace Barotrauma.Items.Components
private bool recalculate;
public static readonly Color MiniMapBaseColor = Color.DarkCyan;
public static readonly Color MiniMapBaseColor = new Color(15, 178, 107);
private static readonly Color WetHullColor = new Color(9, 80, 159),
private static readonly Color WetHullColor = new Color(11, 122, 205),
DoorIndicatorColor = GUI.Style.Green,
NoPowerDoorColor = DoorIndicatorColor * 0.1f,
DefaultNeutralColor = MiniMapBaseColor * 0.8f,
HoverColor = Color.White,
BlueprintBlue = new Color(48, 87, 255),
HullWaterColor = new Color(85, 136, 147),
BlueprintBlue = new Color(23, 38, 33),
HullWaterColor = new Color(17, 173, 179),
HullWaterLineColor = Color.LightBlue,
NoPowerColor = MiniMapBaseColor * 0.1f,
ElectricalBaseColor = GUI.Style.Orange,
@@ -323,7 +326,7 @@ namespace Barotrauma.Items.Components
CanBeFocused = false
};
SetTooltipPosition(searchAutoComplete, searchBar);
SetAutoCompletePosition(searchAutoComplete, searchBar);
GUIListBox listBox = new GUIListBox(new RectTransform(Vector2.One, searchAutoComplete.RectTransform))
{
@@ -403,16 +406,17 @@ namespace Barotrauma.Items.Components
scissorComponent = new GUIScissorComponent(new RectTransform(Vector2.One, submarineContainer.RectTransform, Anchor.Center));
miniMapContainer = new GUIFrame(new RectTransform(Vector2.One, scissorComponent.Content.RectTransform, Anchor.Center), style: null) { CanBeFocused = false };
miniMapFrame = CreateMiniMap(item.Submarine, submarineContainer, MiniMapSettings.Default, null, out hullStatusComponents);
ImmutableHashSet<Item> hullPointsOfInterest = Item.ItemList.Where(it => it.Submarine == item.Submarine && !it.HiddenInGame && !it.NonInteractable && it.Prefab.ShowInStatusMonitor && it.GetComponent<Door>() != null).ToImmutableHashSet();
miniMapFrame = CreateMiniMap(item.Submarine, submarineContainer, MiniMapSettings.Default, hullPointsOfInterest, out hullStatusComponents);
IEnumerable<Item> pointsOfInterest = Item.ItemList.Where(it => it.Submarine == item.Submarine && !it.HiddenInGame && !it.NonInteractable && it.GetComponent<Repairable>() != null);
electricalFrame = CreateMiniMap(item.Submarine, miniMapContainer, new MiniMapSettings(createHullElements: false), pointsOfInterest, out electricalMapComponents);
IEnumerable<Item> electrialPointsOfInterest = Item.ItemList.Where(it => it.Submarine == item.Submarine && !it.HiddenInGame && !it.NonInteractable && it.GetComponent<Repairable>() != null);
electricalFrame = CreateMiniMap(item.Submarine, miniMapContainer, new MiniMapSettings(createHullElements: false), electrialPointsOfInterest, out electricalMapComponents);
Dictionary<MiniMapGUIComponent, GUIComponent> electricChildren = new Dictionary<MiniMapGUIComponent, GUIComponent>();
foreach (var (entity, component) in electricalMapComponents)
{
GUIComponent parent = component.Component;
GUIComponent parent = component.RectComponent;
if (!(entity is Item it )) { continue; }
Sprite? sprite = it.Prefab.UpgradePreviewSprite;
if (sprite is null) { continue; }
@@ -430,6 +434,31 @@ namespace Barotrauma.Items.Components
electricalChildren = electricChildren.ToImmutableDictionary();
Dictionary<MiniMapGUIComponent, GUIComponent> doorChilds = new Dictionary<MiniMapGUIComponent, GUIComponent>();
foreach (var (entity, component) in hullStatusComponents)
{
if (!hullPointsOfInterest.Contains(entity)) { continue; }
const int minSize = 8;
const int borderMaxSize = 2;
Point size = component.BorderComponent.Rect.Size;
size.X = Math.Max(size.X, minSize);
size.Y = Math.Max(size.Y, minSize);
float width = Math.Min(borderMaxSize, Math.Min(size.X, size.Y) / 8f);
GUIFrame frame = new GUIFrame(new RectTransform(size, component.RectComponent.RectTransform, anchor: Anchor.Center), style: "ScanLines", color: DoorIndicatorColor)
{
OutlineColor = GUI.Style.Green,
OutlineThickness = width
};
doorChilds.Add(component, frame);
}
doorChildren = doorChilds.ToImmutableDictionary();
Rectangle parentRect = miniMapFrame.Rect;
displayedSubs.Clear();
@@ -466,7 +495,6 @@ namespace Barotrauma.Items.Components
}
}
if (currentMode != MiniMapMode.HullStatus && Math.Abs(PlayerInput.ScrollWheelSpeed) > 0 && (GUI.MouseOn == scissorComponent || scissorComponent.IsParentOf(GUI.MouseOn)))
{
float newZoom = Math.Clamp(Zoom + PlayerInput.ScrollWheelSpeed / 1000.0f * Zoom, minZoom, maxZoom);
@@ -501,10 +529,10 @@ namespace Barotrauma.Items.Components
miniMapContainer.RectTransform.AbsoluteOffset = mapOffset.ToPoint();
recalculate = false;
var (maxWidth, maxHeight) = miniMapContainer.Rect.Size.ToVector2() / 2f / Zoom;
mapOffset.X = Math.Clamp(mapOffset.X, -maxWidth, maxWidth);
mapOffset.Y = Math.Clamp(mapOffset.Y, -maxHeight, maxHeight);
// var (maxWidth, maxHeight) = miniMapContainer.Rect.Size.ToVector2() / 2f;
//
// mapOffset.X = Math.Clamp(mapOffset.X, -maxWidth, maxWidth);
// mapOffset.Y = Math.Clamp(mapOffset.Y, -maxHeight, maxHeight);
}
// is there a better way to do this?
@@ -610,7 +638,7 @@ namespace Barotrauma.Items.Components
{
if (!(entity is Hull hull)) { continue; }
if (!hullDatas.TryGetValue(hull, out HullData? hullData) || hullData is null) { continue; }
DrawHullCards(spriteBatch, hull, hullData, component.Component);
DrawHullCards(spriteBatch, hull, hullData, component.RectComponent);
}
spriteBatch.End();
@@ -645,7 +673,7 @@ namespace Barotrauma.Items.Components
MiniMapBlips = null;
searchedPrefab = null;
searchAutoComplete.Visible = true;
SetTooltipPosition(searchAutoComplete, box);
SetAutoCompletePosition(searchAutoComplete, box);
GUIListBox listBox = searchAutoComplete.GetChild<GUIListBox>();
if (listBox is null) { return false; }
@@ -677,7 +705,7 @@ namespace Barotrauma.Items.Components
return true;
}
private void SetTooltipPosition(GUIComponent tooltip, GUITextBox box)
private void SetAutoCompletePosition(GUIComponent tooltip, GUITextBox box)
{
int height = GuiFrame.Rect.Height / 2;
tooltip.RectTransform.NonScaledSize = new Point(box.Rect.Width, height);
@@ -707,7 +735,6 @@ namespace Barotrauma.Items.Components
{
if (searchedPrefab is null)
{
Console.WriteLine("Bruh");
ItemPrefab? first = ItemPrefab.Prefabs.FirstOrDefault(p => p.Name.ToLower().Equals(text.ToLower()));
if (first is null)
@@ -790,12 +817,39 @@ namespace Barotrauma.Items.Components
private void UpdateHullStatus()
{
bool canHoverOverHull = true;
foreach (var (entity, component) in hullStatusComponents)
{
// we are only interested in non-hull components
if (entity is Hull) { continue; }
GUIComponent rectComponent = component.RectComponent;
if (doorChildren.TryGetValue(component, out GUIComponent? child) && child != null)
{
if (item.Submarine == null || !hasPower)
{
child.Color = child.OutlineColor = NoPowerDoorColor;
}
if (Voltage < MinVoltage) { continue; }
child.Color = child.OutlineColor = DoorIndicatorColor;
if (GUI.MouseOn == child)
{
SetTooltip(rectComponent.Rect.Center, entity.Name, string.Empty, string.Empty, string.Empty);
canHoverOverHull = false;
child.Color = child.OutlineColor = HoverColor;
}
}
}
foreach (var (entity, (component, borderComponent)) in hullStatusComponents)
{
if (item.Submarine == null || !hasPower)
{
component.Color = NoPowerColor;
borderComponent.OutlineColor = NoPowerColor;
component.Color = borderComponent.OutlineColor = NoPowerColor;
}
if (Voltage < MinVoltage) { continue; }
@@ -848,7 +902,7 @@ namespace Barotrauma.Items.Components
borderColor = Color.Lerp(neutralColor, GUI.Style.Red, Math.Min(gapOpenSum, 1.0f));
}
bool isHoveringOver = GUI.MouseOn == component;
bool isHoveringOver = canHoverOverHull && GUI.MouseOn == component;
// When drawing tooltip we are only interested in the component we are hovering over
if (isHoveringOver)
@@ -888,7 +942,7 @@ namespace Barotrauma.Items.Components
{
if (!hullStatusComponents.ContainsKey(linkedHull)) { continue; }
isHoveringOver |= hullStatusComponents[linkedHull].Component == GUI.MouseOn;
isHoveringOver |= canHoverOverHull && hullStatusComponents[linkedHull].RectComponent == GUI.MouseOn;
if (isHoveringOver) { break; }
}
@@ -919,7 +973,7 @@ namespace Barotrauma.Items.Components
component.Color = component.OutlineColor = NoPowerElectricalColor;
}
if (Voltage < MinVoltage || !miniMapGuiComponent.Component.Visible) { continue; }
if (Voltage < MinVoltage || !miniMapGuiComponent.RectComponent.Visible) { continue; }
int durability = (int)(it.Condition / it.MaxCondition * 100f);
Color color = ToolBox.GradientLerp(durability / 100f, GUI.Style.Red, GUI.Style.Orange, GUI.Style.Green, GUI.Style.Green);
@@ -956,9 +1010,6 @@ namespace Barotrauma.Items.Components
{
if (item.Submarine != null)
{
Rectangle parentRect = container.Rect;
if (miniMapFrame is { } miniMap) { parentRect = miniMap.Rect; }
DrawSubmarine(spriteBatch);
}
@@ -995,7 +1046,7 @@ namespace Barotrauma.Items.Components
if (hullData.Distort) { continue; }
GUIComponent hullFrame = component.Component;
GUIComponent hullFrame = component.RectComponent;
if (hullsVisible && hullData.HullWaterAmount is { } waterAmount)
{
@@ -1197,10 +1248,12 @@ namespace Barotrauma.Items.Components
const float padding = 8f;
float totalWidth = 0f;
float parentWidth = submarineContainer.Rect.Width / 24f;
int i = 0;
foreach (MiniMapSprite info in cardsToDraw)
{
float spriteSize = info.Sprite.size.X * (frame.Rect.Height / info.Sprite.size.Y) + padding;
float spriteSize = info.Sprite.size.X * (parentWidth / info.Sprite.size.X) + padding;
if (totalWidth + spriteSize > frame.Rect.Width) { break; }
totalWidth += spriteSize;
@@ -1213,10 +1266,11 @@ namespace Barotrauma.Items.Components
float offset = 0;
int amount = 0;
foreach (MiniMapSprite info in cardsToDraw)
{
Sprite sprite = info.Sprite;
float scale = frame.Rect.Height / sprite.size.Y;
float scale = parentWidth / sprite.size.X;
float spriteSize = sprite.size.X * scale;
float posX = adjustedCenterX + offset;
@@ -1243,7 +1297,7 @@ namespace Barotrauma.Items.Components
float halfSize = spriteSize / 2f;
if (i > 0) { offset += halfSize; }
Vector2 pos = new Vector2(adjustedCenterX + offset, centerY);
sprite.Draw(spriteBatch, pos, info.Color, scale: scale, origin: sprite.size / 2f);
sprite.Draw(spriteBatch, pos, info.Color * 0.8f, scale: scale, origin: sprite.size / 2f);
offset += halfSize + padding;
amount++;
}
@@ -446,13 +446,8 @@ namespace Barotrauma.Items.Components
zoomSlider.BarScroll += PlayerInput.ScrollWheelSpeed / 1000.0f;
zoomSlider.OnMoved(zoomSlider, zoomSlider.BarScroll);
}
if (PlayerInput.KeyHit(InputType.Run))
{
SonarModeSwitch.OnClicked(SonarModeSwitch, null);
}
}
float distort = 1.0f - item.Condition / item.MaxCondition;
for (int i = sonarBlips.Count - 1; i >= 0; i--)
{
@@ -1634,7 +1629,7 @@ namespace Barotrauma.Items.Components
void CalculateDistance()
{
pathFinder ??= new PathFinder(WayPoint.WayPointList, indoorsSteering: false);
pathFinder ??= new PathFinder(WayPoint.WayPointList, false);
var path = pathFinder.FindPath(ConvertUnits.ToSimUnits(transducerPosition), ConvertUnits.ToSimUnits(worldPosition));
if (!path.Unreachable)
{
@@ -244,7 +244,7 @@ namespace Barotrauma.Items.Components
sabotageButtonText :
sabotagingText + new string('.', ((int)(Timing.TotalTime * 2.0f) % 3) + 1);
TinkerButton.Visible = CanTinker(character);
TinkerButton.Visible = IsTinkerable(character);
TinkerButton.IgnoreLayoutGroups = !TinkerButton.Visible;
TinkerButton.Enabled = (currentFixerAction == FixActions.None || (CurrentFixer == character && currentFixerAction != FixActions.Tinker)) && CanTinker(character);
TinkerButton.Text = (currentFixerAction == FixActions.None || CurrentFixer != character || currentFixerAction != FixActions.Tinker && CanTinker(character)) ?
@@ -303,6 +303,7 @@ namespace Barotrauma.Items.Components
deteriorationTimer = msg.ReadSingle();
deteriorateAlwaysResetTimer = msg.ReadSingle();
DeteriorateAlways = msg.ReadBoolean();
tinkeringDuration = msg.ReadSingle();
ushort currentFixerID = msg.ReadUInt16();
currentFixerAction = (FixActions)msg.ReadRangedInteger(0, 2);
CurrentFixer = currentFixerID != 0 ? Entity.FindEntityByID(currentFixerID) as Character : null;
@@ -1316,6 +1316,15 @@ namespace Barotrauma
{
selectedSlot = null;
}
var parentItem = (selectedSlot?.ParentInventory?.Owner as Item) ?? selectedSlot?.Item;
if ((parentItem?.GetRootInventoryOwner() is Character ownerCharacter) &&
ownerCharacter == Character.Controlled &&
CharacterHealth.OpenHealthWindow?.Character != ownerCharacter &&
ownerCharacter.Inventory.IsInLimbSlot(parentItem, InvSlotType.HealthInterface))
{
highlightedSubInventorySlots.RemoveWhere(s => s.Item == parentItem);
selectedSlot = null;
}
}
}
}
@@ -1394,7 +1403,7 @@ namespace Barotrauma
float scale = Math.Min(Math.Min(iconSize / sprite.size.X, iconSize / sprite.size.Y), 1.5f);
Vector2 itemPos = PlayerInput.MousePosition;
bool mouseOnHealthInterface = CharacterHealth.OpenHealthWindow != null && CharacterHealth.OpenHealthWindow.MouseOnElement;
bool mouseOnHealthInterface = CharacterHealth.OpenHealthWindow != null && CharacterHealth.OpenHealthWindow.MouseOnElement && DraggingItems.Any(it => it.UseInHealthInterface);
if ((GUI.MouseOn == null || mouseOnHealthInterface) && selectedSlot == null)
{
@@ -1453,7 +1462,8 @@ namespace Barotrauma
}
Color slotColor = Color.White;
if (inventory?.Owner is Item i && !i.IsPlayerTeamInteractable) { slotColor = Color.Gray; }
Item parentItem = inventory?.Owner as Item;
if (parentItem != null && !parentItem.IsPlayerTeamInteractable) { slotColor = Color.Gray; }
var itemContainer = item?.GetComponent<ItemContainer>();
if (itemContainer != null && (itemContainer.InventoryTopSprite != null || itemContainer.InventoryBottomSprite != null))
{
@@ -1576,6 +1586,14 @@ namespace Barotrauma
pulsate: !usingDefaultSprite && containedState >= 0.0f && containedState < 0.25f && inventory == Character.Controlled?.Inventory && Character.Controlled.HasEquippedItem(item));
}
}
else
{
var slotIcon = parentItem?.GetComponent<ItemContainer>()?.GetSlotIcon(slotIndex);
if (slotIcon != null)
{
slotIcon.Draw(spriteBatch, rect.Center.ToVector2(), GUI.Style.EquipmentSlotIconColor, scale: Math.Min(rect.Width / slotIcon.size.X, rect.Height / slotIcon.size.Y) * 0.8f);
}
}
}
if (GameMain.DebugDraw)
@@ -1609,7 +1627,7 @@ namespace Barotrauma
Color spriteColor = sprite == item.Sprite ? item.GetSpriteColor() : item.GetInventoryIconColor();
if (inventory != null && (inventory.Locked || inventory.slots[slotIndex].Items.All(it => it.NonInteractable || it.NonPlayerTeamInteractable))) { spriteColor *= 0.5f; }
if (CharacterHealth.OpenHealthWindow != null && !item.UseInHealthInterface)
if (CharacterHealth.OpenHealthWindow != null && !item.UseInHealthInterface && !item.AllowedSlots.Contains(InvSlotType.HealthInterface) && item.GetComponent<GeneticMaterial>() == null)
{
spriteColor = Color.Lerp(spriteColor, Color.TransparentBlack, 0.5f);
}
@@ -77,6 +77,13 @@ namespace Barotrauma
protected set;
}
[Serialize(true, false)]
public bool ShowInStatusMonitor
{
get;
private set;
}
[Serialize("", false)]
public string ImpactSoundTag { get; private set; }
@@ -84,13 +91,13 @@ namespace Barotrauma
public override void UpdatePlacing(Camera cam)
{
Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
if (PlayerInput.SecondaryMouseButtonClicked())
{
selected = null;
return;
}
var potentialContainer = MapEntity.GetPotentialContainer(position);
if (!ResizeHorizontal && !ResizeVertical)
@@ -155,7 +162,7 @@ namespace Barotrauma
{
potentialContainer.IsHighlighted = true;
}
//if (PlayerInput.GetMouseState.RightButton == ButtonState.Pressed) selected = null;
@@ -993,6 +993,10 @@ namespace Barotrauma
clone.Move(moveAmount);
clone.Submarine = Submarine.MainSub;
}
foreach (MapEntity clone in SelectedList)
{
(clone as Item)?.GetComponent<ItemContainer>()?.SetContainedItemPositions();
}
SubEditorScreen.StoreCommand(new AddOrDeleteCommand(clones, false, handleInventoryBehavior: false));
}
@@ -127,6 +127,13 @@ namespace Barotrauma
ID.ToString(),
new Vector2(DrawPosition.X - 10, -DrawPosition.Y - 30),
color);
if (Tunnel?.Type != null)
{
GUI.SmallFont.DrawString(spriteBatch,
Tunnel.Type.ToString(),
new Vector2(DrawPosition.X - 10, -DrawPosition.Y - 45),
color);
}
}
public override bool IsMouseOn(Vector2 position)
@@ -494,7 +494,26 @@ namespace Barotrauma.Networking
stream?.Close();
break;
case FileTransferType.CampaignSave:
//TODO: verify that the received file is a valid save file
try
{
var files = SaveUtil.EnumerateContainedFiles(fileTransfer.FilePath);
foreach (var file in files)
{
string extension = Path.GetExtension(file);
if ((!extension.Equals(".sub", StringComparison.OrdinalIgnoreCase)
&& !file.Equals("gamesession.xml"))
|| file.CleanUpPathCrossPlatform(correctFilenameCase: false).Contains('/'))
{
ErrorMessage = $"Found unexpected file in \"{fileTransfer.FileName}\"! ({file})";
return false;
}
}
}
catch (Exception e)
{
ErrorMessage = $"Loading received campaign save \"{fileTransfer.FileName}\" failed! {{{e.Message}}}";
return false;
}
break;
}
@@ -1,7 +1,7 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.IO;
using Barotrauma.IO;
using System.Linq;
using System.Xml.Linq;
using Microsoft.Xna.Framework;
@@ -56,11 +56,6 @@ namespace Barotrauma
MiniMap miniMap = miniMapItem.GetComponent<MiniMap>();
miniMap.PowerConsumption = 0;
foreach (var hull in Hull.hullList)
{
hull.WaterVolume = hull.Volume / 2f;
}
dummyCharacter = Character.Create(CharacterPrefab.HumanSpeciesName, Vector2.Zero, "", id: Entity.DummyID, hasAi: false);
dummyCharacter.Info.Name = "Galldren";
dummyCharacter.Inventory.CreateSlots();