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
@@ -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;