Unstable 0.16.3.0

This commit is contained in:
Markus Isberg
2022-02-10 02:52:08 +09:00
parent 6814a11520
commit 2190fe08ef
115 changed files with 993 additions and 453 deletions
@@ -11,7 +11,7 @@ namespace Barotrauma
{
if (Character.IsUnconscious || !Character.Enabled || !Enabled) { return; }
Vector2 pos = Character.WorldPosition;
Vector2 pos = Character.DrawPosition;
pos.Y = -pos.Y;
if (State == AIState.Idle && PreviousState == AIState.Attack)
@@ -31,7 +31,7 @@ namespace Barotrauma
}
else if (SelectedAiTarget?.Entity != null)
{
Vector2 targetPos = SelectedAiTarget.WorldPosition;
Vector2 targetPos = SelectedAiTarget.Entity.DrawPosition;
if (State == AIState.Attack)
{
targetPos = attackWorldPos;
@@ -72,7 +72,7 @@ namespace Barotrauma
}
GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 80.0f, State.ToString(), stateColor, Color.Black);
if (LatchOntoAI != null)
if (LatchOntoAI != null && (State == AIState.Idle || LatchOntoAI.IsAttachedToSub))
{
foreach (Joint attachJoint in LatchOntoAI.AttachJoints)
{
@@ -312,11 +312,7 @@ namespace Barotrauma
}
}
cursorPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
if (AnimController.CurrentHull?.Submarine != null)
{
cursorPosition -= AnimController.CurrentHull.Submarine.Position;
}
UpdateLocalCursor(cam);
Vector2 mouseSimPos = ConvertUnits.ToSimUnits(cursorPosition);
if (GUI.PauseMenuOpen)
@@ -393,6 +389,15 @@ namespace Barotrauma
DisableControls = false;
}
public void UpdateLocalCursor(Camera cam)
{
cursorPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
if (AnimController.CurrentHull?.Submarine != null)
{
cursorPosition -= AnimController.CurrentHull.Submarine.DrawPosition;
}
}
partial void UpdateControlled(float deltaTime, Camera cam)
{
if (controlled != this) return;
@@ -431,7 +431,7 @@ namespace Barotrauma
foreach (Item item in Item.ItemList)
{
if (item.IconStyle is null || item.Submarine != character.Submarine) { continue; }
if (Vector2.DistanceSquared(character.Position, item.Position) > 500f*500f) { continue; }
if (Vector2.DistanceSquared(character.Position, item.Position) > 500f * 500f) { continue; }
var body = Submarine.CheckVisibility(character.SimPosition, item.SimPosition, ignoreLevel: true);
if (body != null && body.UserData as Item != item) { continue; }
GUI.DrawIndicator(spriteBatch, item.WorldPosition + new Vector2(0f, item.RectHeight * 0.65f), cam, new Range<float>(-100f, 500.0f), item.IconStyle.GetDefaultSprite(), item.IconStyle.Color, createOffset: false);
@@ -5,6 +5,7 @@
private InfectionState? prevDisplayedMessage;
partial void UpdateMessages()
{
if (character != Character.Controlled) { return; }
if (Prefab is AfflictionPrefabHusk { SendMessages: false }) { return; }
if (prevDisplayedMessage.HasValue && prevDisplayedMessage.Value == State) { return; }
@@ -896,13 +896,20 @@ namespace Barotrauma
{
if (wearable.Type == WearableType.Husk) { continue; }
if (wearableTypesToHide.Contains(wearable.Type))
{
if (wearable.Type == WearableType.Hair && HairWithHatSprite != null)
{
if (wearable.Type == WearableType.Hair)
{
DrawWearable(HairWithHatSprite, depthStep, spriteBatch, blankColor, alpha: color.A / 255f, spriteEffect);
depthStep += step;
if (HairWithHatSprite != null)
{
DrawWearable(HairWithHatSprite, depthStep, spriteBatch, blankColor, alpha: color.A / 255f, spriteEffect);
depthStep += step;
continue;
}
}
else
{
continue;
}
continue;
}
DrawWearable(wearable, depthStep, spriteBatch, blankColor, alpha: color.A / 255f, spriteEffect);
//if there are multiple sprites on this limb, make the successive ones be drawn in front
@@ -1,3 +1,4 @@
using Barotrauma.Extensions;
using Barotrauma.Networking;
namespace Barotrauma
@@ -20,6 +21,9 @@ namespace Barotrauma
}
}
public override bool IsAtCompletionState => State > 0 && requireRescue.None();
public override bool IsAtFailureState => State == HostagesKilledState;
public override void ClientReadInitial(IReadMessage msg)
{
base.ClientReadInitial(msg);
@@ -4,6 +4,9 @@ namespace Barotrauma
{
partial class AlienRuinMission : Mission
{
public override bool IsAtCompletionState => State > 0;
public override bool IsAtFailureState => false;
public override void ClientReadInitial(IReadMessage msg)
{
base.ClientReadInitial(msg);
@@ -0,0 +1,8 @@
namespace Barotrauma
{
partial class BeaconMission : Mission
{
public override bool IsAtCompletionState => false;
public override bool IsAtFailureState => false;
}
}
@@ -5,6 +5,9 @@ namespace Barotrauma
{
partial class CargoMission : Mission
{
public override bool IsAtCompletionState => false;
public override bool IsAtFailureState => false;
public override string GetMissionRewardText(Submarine sub)
{
string rewardText = TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", GetReward(sub)));
@@ -20,5 +20,8 @@ namespace Barotrauma
return descriptions[GameMain.Client.Character.TeamID == CharacterTeamType.Team1 ? 1 : 2];
}
}
public override bool IsAtCompletionState => false;
public override bool IsAtFailureState => false;
}
}
@@ -4,6 +4,9 @@ namespace Barotrauma
{
partial class EscortMission : Mission
{
public override bool IsAtCompletionState => false;
public override bool IsAtFailureState => State == 1;
public override void ClientReadInitial(IReadMessage msg)
{
base.ClientReadInitial(msg);
@@ -0,0 +1,8 @@
namespace Barotrauma
{
partial class GoToMission : Mission
{
public override bool IsAtCompletionState => false;
public override bool IsAtFailureState => false;
}
}
@@ -1,15 +1,14 @@
using Barotrauma.Extensions;
using Barotrauma.Items.Components;
using Barotrauma.Items.Components;
using Barotrauma.Networking;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma
{
partial class MineralMission : Mission
{
public override bool IsAtCompletionState => false;
public override bool IsAtFailureState => false;
public override void ClientReadInitial(IReadMessage msg)
{
base.ClientReadInitial(msg);
@@ -19,6 +19,15 @@ namespace Barotrauma
public virtual IEnumerable<Entity> HudIconTargets => Enumerable.Empty<Entity>();
/// <summary>
/// State at which the only thing left to do is to reach the end of the level. Use for UI references.
/// </summary>
public abstract bool IsAtCompletionState { get; }
/// <summary>
/// State at which the mission cannot be completed anymore. Use for UI references.
/// </summary>
public abstract bool IsAtFailureState { get; }
public Color GetDifficultyColor()
{
int v = Difficulty ?? MissionPrefab.MinDifficulty;
@@ -4,6 +4,9 @@ namespace Barotrauma
{
partial class MonsterMission : Mission
{
public override bool IsAtCompletionState => State > 0;
public override bool IsAtFailureState => false;
public override void ClientReadInitial(IReadMessage msg)
{
base.ClientReadInitial(msg);
@@ -6,6 +6,9 @@ namespace Barotrauma
{
partial class NestMission : Mission
{
public override bool IsAtCompletionState => State > 0 && !requireDelivery;
public override bool IsAtFailureState => false;
public override void ClientReadInitial(IReadMessage msg)
{
base.ClientReadInitial(msg);
@@ -4,6 +4,9 @@ namespace Barotrauma
{
partial class PirateMission : Mission
{
public override bool IsAtCompletionState => State > 1;
public override bool IsAtFailureState => false;
public override void ClientReadInitial(IReadMessage msg)
{
base.ClientReadInitial(msg);
@@ -5,6 +5,9 @@ namespace Barotrauma
{
partial class SalvageMission : Mission
{
public override bool IsAtCompletionState => false;
public override bool IsAtFailureState => false;
public override void ClientReadInitial(IReadMessage msg)
{
base.ClientReadInitial(msg);
@@ -1,5 +1,4 @@
using Barotrauma.Networking;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -23,6 +22,9 @@ namespace Barotrauma
}
}
public override bool IsAtCompletionState => false;
public override bool IsAtFailureState => false;
public override void ClientReadInitial(IReadMessage msg)
{
base.ClientReadInitial(msg);
@@ -1356,7 +1356,7 @@ namespace Barotrauma
#region Element drawing
private static List<float> usedIndicatorAngles = new List<float>();
private static readonly List<float> usedIndicatorAngles = new List<float>();
/// <param name="createOffset">Should the indicator move based on the camera position?</param>
/// <param name="overrideAlpha">Override the distance-based alpha value with the specified alpha value</param>
@@ -1019,8 +1019,10 @@ namespace Barotrauma
case "gridtext":
LoadGridText(element, parent);
return null;
case "conditional":
break;
default:
throw new NotImplementedException("Loading GUI component \""+element.Name+"\" from XML is not implemented.");
throw new NotImplementedException("Loading GUI component \"" + element.Name + "\" from XML is not implemented.");
}
if (component != null)
@@ -1683,8 +1683,9 @@ namespace Barotrauma
private void SetItemFrameStatus(GUIComponent itemFrame, bool enabled)
{
if (itemFrame == null || !(itemFrame.UserData is PurchasedItem pi)) { return; }
if (!(itemFrame?.UserData is PurchasedItem pi)) { return; }
bool refreshFrameStatus = !pi.IsStoreComponentEnabled.HasValue || pi.IsStoreComponentEnabled.Value != enabled;
if (!refreshFrameStatus) { return; }
if (itemFrame.FindChild("icon", recursive: true) is GUIImage icon)
{
if (pi.ItemPrefab?.InventoryIcon != null)
@@ -1696,14 +1697,11 @@ namespace Barotrauma
icon.Color = pi.ItemPrefab.SpriteColor * (enabled ? 1.0f : 0.5f);
}
};
var color = Color.White * (enabled ? 1.0f : 0.5f);
if (itemFrame.FindChild("name", recursive: true) is GUITextBlock name)
{
name.TextColor = color;
}
if (itemFrame.FindChild("quantitylabel", recursive: true) is GUITextBlock qty)
{
qty.TextColor = color;
@@ -1712,25 +1710,21 @@ namespace Barotrauma
{
numberInput.Enabled = enabled;
}
if (itemFrame.FindChild("owned", recursive: true) is GUITextBlock ownedBlock)
{
ownedBlock.TextColor = color;
}
var isDiscounted = false;
bool isDiscounted = false;
if (itemFrame.FindChild("undiscountedprice", recursive: true) is GUITextBlock undiscountedPriceBlock)
{
undiscountedPriceBlock.TextColor = color;
undiscountedPriceBlock.Strikethrough.Color = color;
isDiscounted = true;
}
if (itemFrame.FindChild("price", recursive: true) is GUITextBlock priceBlock)
{
priceBlock.TextColor = isDiscounted ? storeSpecialColor * (enabled ? 1.0f : 0.5f) : color;
}
if (itemFrame.FindChild("addbutton", recursive: true) is GUIButton addButton)
{
addButton.Enabled = enabled;
@@ -1739,6 +1733,8 @@ namespace Barotrauma
{
removeButton.Enabled = enabled;
}
pi.IsStoreComponentEnabled = enabled;
itemFrame.UserData = pi;
}
private void SetQuantityLabelText(StoreTab mode, GUIComponent itemFrame)
@@ -129,7 +129,6 @@ namespace Barotrauma
public TabMenu()
{
if (!initialized) { Initialize(); }
CreateInfoFrame(SelectedTab);
SelectInfoFrameTab(SelectedTab);
}
@@ -300,7 +299,7 @@ namespace Barotrauma
CreateMissionInfo(infoFrameHolder);
break;
case InfoFrameTab.Reputation:
if (GameMain.GameSession.RoundSummary != null && GameMain.GameSession.GameMode is CampaignMode campaignMode)
if (GameMain.GameSession?.RoundSummary != null && GameMain.GameSession?.GameMode is CampaignMode campaignMode)
{
infoFrameHolder.ClearChildren();
GUIFrame reputationFrame = new GUIFrame(new RectTransform(Vector2.One, infoFrameHolder.RectTransform, Anchor.TopCenter), style: "GUIFrameListBox");
@@ -308,8 +307,8 @@ namespace Barotrauma
}
break;
case InfoFrameTab.Traitor:
TraitorMissionPrefab traitorMission = GameMain.Client.TraitorMission;
Character traitor = GameMain.Client.Character;
TraitorMissionPrefab traitorMission = GameMain.Client?.TraitorMission;
Character traitor = GameMain.Client?.Character;
if (traitor == null || traitorMission == null) { return; }
CreateTraitorInfo(infoFrameHolder, traitorMission, traitor);
break;
@@ -753,7 +752,7 @@ namespace Barotrauma
if (character != null)
{
if (GameMain.NetworkMember == null)
if (GameMain.Client == null)
{
GUIComponent preview = character.Info.CreateInfoFrame(background, false, null);
}
@@ -1021,13 +1020,15 @@ namespace Barotrauma
int iconHeight = Math.Max(missionTextGroup.RectTransform.NonScaledSize.Y, (int)(iconWidth * iconAspectRatio));
Point iconSize = new Point(iconWidth, iconHeight);*/
new GUIImage(new RectTransform(new Point(iconSize), missionDescriptionHolder.RectTransform), mission.Prefab.Icon, null, true)
var icon = new GUIImage(new RectTransform(new Point(iconSize), missionDescriptionHolder.RectTransform), mission.Prefab.Icon, null, true)
{
Color = mission.Prefab.IconColor,
HoverColor = mission.Prefab.IconColor,
SelectedColor = mission.Prefab.IconColor,
CanBeFocused = false
};
UpdateMissionStateIcon(mission, icon);
mission.OnMissionStateChanged += (mission) => UpdateMissionStateIcon(mission, icon);
}
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextGroup.RectTransform), missionNameRichTextData, missionNameString, font: GUI.LargeFont);
GUILayoutGroup difficultyIndicatorGroup = null;
@@ -1064,6 +1065,33 @@ namespace Barotrauma
}
}
private void UpdateMissionStateIcon(Mission mission, GUIImage missionIcon)
{
if (mission == null || missionIcon == null) { return; }
string style = string.Empty;
if (mission.IsAtFailureState)
{
style = "MissionFailedIcon";
}
else if (mission.IsAtCompletionState)
{
style = "MissionCompletedIcon";
}
GUIImage stateIcon = missionIcon.GetChild<GUIImage>();
if (string.IsNullOrEmpty(style))
{
if (stateIcon != null)
{
stateIcon.Visible = false;
}
}
else
{
stateIcon ??= new GUIImage(new RectTransform(Vector2.One, missionIcon.RectTransform), style, scaleToFit: true);
stateIcon.Visible = true;
}
}
private void CreateTraitorInfo(GUIFrame infoFrame, TraitorMissionPrefab traitorMission, Character traitor)
{
GUIFrame missionFrame = new GUIFrame(new RectTransform(Vector2.One, infoFrame.RectTransform, Anchor.TopCenter), style: "GUIFrameListBox");
@@ -1441,7 +1469,7 @@ namespace Barotrauma
selectedTalents.Remove(talentIdentifier);
}
UpdateTalentButtons();
UpdateTalentInfo();
return true;
},
};
@@ -1506,7 +1534,7 @@ namespace Barotrauma
};
GUITextBlock.AutoScaleAndNormalize(talentResetButton.TextBlock, talentApplyButton.TextBlock);
UpdateTalentButtons();
UpdateTalentInfo();
}
private void CreateTalentSkillList(Character character, GUIListBox parent)
@@ -1541,11 +1569,13 @@ namespace Barotrauma
GUITextBlock.AutoScaleAndNormalize(skillNames);
}
private void UpdateTalentButtons()
private void UpdateTalentInfo()
{
Character controlledCharacter = Character.Controlled;
if (controlledCharacter?.Info == null) { return; }
if (SelectedTab != InfoFrameTab.Talents) { return; }
bool unlockedAllTalents = controlledCharacter.HasUnlockedAllTalents();
if (unlockedAllTalents)
@@ -1626,7 +1656,7 @@ namespace Barotrauma
}
}
selectedTalents = controlledCharacter.Info.GetUnlockedTalentsInTree().ToList();
UpdateTalentButtons();
UpdateTalentInfo();
}
private bool ApplyTalentSelection(GUIButton guiButton, object userData)
@@ -1640,63 +1670,14 @@ namespace Barotrauma
{
Character controlledCharacter = Character.Controlled;
selectedTalents = controlledCharacter.Info.GetUnlockedTalentsInTree().ToList();
UpdateTalentButtons();
UpdateTalentInfo();
return true;
}
public void OnExperienceChanged(Character character)
{
if (character != Character.Controlled) { return; }
UpdateTalentButtons();
}
private readonly StatTypes[] basicStats = new StatTypes[]
{
StatTypes.MaximumHealthMultiplier,
StatTypes.MovementSpeed,
StatTypes.SwimmingSpeed,
StatTypes.RepairSpeed,
};
private readonly StatTypes[] combatStats = new StatTypes[]
{
StatTypes.MeleeAttackMultiplier,
StatTypes.MeleeAttackSpeed,
StatTypes.RangedAttackSpeed,
StatTypes.TurretAttackSpeed,
};
private readonly StatTypes[] miscStats = new StatTypes[]
{
StatTypes.ReputationGainMultiplier,
StatTypes.MissionMoneyGainMultiplier,
StatTypes.ExperienceGainMultiplier,
StatTypes.MissionExperienceGainMultiplier,
};
private void CreateCharacterSheet(GUILayoutGroup characterInfoColumn)
{
Character controlledCharacter = Character.Controlled;
CreateRow(basicStats);
CreateRow(combatStats);
CreateRow(miscStats);
void CreateRow(StatTypes[] statTypes)
{
GUILayoutGroup characterInfoRow = new GUILayoutGroup(new RectTransform(new Vector2(0.33f, 1.0f), characterInfoColumn.RectTransform, anchor: Anchor.TopLeft), childAnchor: Anchor.TopCenter);
foreach (StatTypes statType in statTypes)
{
ShowStat(statType, characterInfoRow);
}
}
void ShowStat(StatTypes statType, GUILayoutGroup characterInfoRow)
{
GUIFrame textInfoFrame = new GUIFrame(new RectTransform(new Vector2(1f, 0.33f), characterInfoRow.RectTransform, Anchor.TopCenter), style: null);
new GUITextBlock(new RectTransform(new Vector2(1f, 1f), textInfoFrame.RectTransform, Anchor.TopLeft), statType.ToString(), font: GUI.SmallFont, textAlignment: Alignment.TopLeft);
new GUITextBlock(new RectTransform(new Vector2(1f, 1f), textInfoFrame.RectTransform, Anchor.TopLeft), (int)(100f * (1 + controlledCharacter.GetStatValue(statType))) + "%", font: GUI.Font, textAlignment: Alignment.TopRight);
}
UpdateTalentInfo();
}
}
}
@@ -12,6 +12,8 @@ namespace Barotrauma
static class HintManager
{
private const string HintManagerFile = "hintmanager.xml";
public static bool Enabled => GameMain.Config != null && !GameMain.Config.DisableInGameHints;
private static HashSet<string> HintIdentifiers { get; set; }
private static Dictionary<string, HashSet<string>> HintTags { get; } = new Dictionary<string, HashSet<string>>();
private static Dictionary<string, (string identifier, string option)> HintOrders { get; } = new Dictionary<string, (string orderIdentifier, string orderOption)>();
@@ -666,6 +668,8 @@ namespace Barotrauma
ActiveHintMessageBox.InnerFrame.Flash(color: iconColor ?? Color.Orange, flashDuration: 0.75f);
onDisplay?.Invoke();
GameAnalyticsManager.AddDesignEvent($"HintManager:{GameMain.GameSession?.GameMode?.Preset?.Identifier ?? "none"}:HintDisplayed:{hintIdentifier}");
return true;
}
@@ -565,6 +565,13 @@ namespace Barotrauma
});
#endif
foreach (var child in leftPanel.Children)
{
if (child is GUITextBlock textBlock)
{
textBlock.RectTransform.MinSize = new Point(textBlock.RectTransform.MinSize.X, (int)Math.Max(textBlock.RectTransform.MinSize.Y, textBlock.TextSize.Y));
}
}
// right panel --------------------------------------
@@ -1693,13 +1693,12 @@ namespace Barotrauma.Items.Components
}
}
if (iconIdentifier == null || !targetIcons.ContainsKey(iconIdentifier))
if (iconIdentifier == null || !targetIcons.TryGetValue(iconIdentifier, out var iconInfo) || iconInfo.Item1 == null)
{
GUI.DrawRectangle(spriteBatch, new Rectangle((int)markerPos.X - 3, (int)markerPos.Y - 3, 6, 6), markerColor, thickness: 2);
}
else
{
var iconInfo = targetIcons[iconIdentifier];
iconInfo.Item1.Draw(spriteBatch, markerPos, iconInfo.Item2);
}
@@ -1712,7 +1711,10 @@ namespace Barotrauma.Items.Components
Vector2 textSize = GUI.SmallFont.MeasureString(wrappedLabel);
//flip the text to left side when the marker is on the left side or goes outside the right edge of the interface
if ((dir.X < 0.0f || labelPos.X + textSize.X + 10 > GuiFrame.Rect.X) && labelPos.X - textSize.X > 0) labelPos.X -= textSize.X + 10;
if (GuiFrame != null && (dir.X < 0.0f || labelPos.X + textSize.X + 10 > GuiFrame.Rect.X) && labelPos.X - textSize.X > 0)
{
labelPos.X -= textSize.X + 10;
}
GUI.DrawString(spriteBatch,
new Vector2(labelPos.X + 10, labelPos.Y),
@@ -381,17 +381,17 @@ namespace Barotrauma.Items.Components
if (deteriorationTimer > 0.0f)
{
GUI.DrawString(spriteBatch,
new Vector2(item.WorldPosition.X, -item.WorldPosition.Y), "Deterioration delay " + ((int)deteriorationTimer) + (paused ? " [PAUSED]" : ""),
new Vector2(item.DrawPosition.X, -item.DrawPosition.Y), "Deterioration delay " + ((int)deteriorationTimer) + (paused ? " [PAUSED]" : ""),
paused ? Color.Cyan : Color.Lime, Color.Black * 0.5f);
}
else
{
GUI.DrawString(spriteBatch,
new Vector2(item.WorldPosition.X, -item.WorldPosition.Y), "Deteriorating at " + (int)(DeteriorationSpeed * 60.0f) + " units/min" + (paused ? " [PAUSED]" : ""),
new Vector2(item.DrawPosition.X, -item.DrawPosition.Y), "Deteriorating at " + (int)(DeteriorationSpeed * 60.0f) + " units/min" + (paused ? " [PAUSED]" : ""),
paused ? Color.Cyan : GUI.Style.Red, Color.Black * 0.5f);
}
GUI.DrawString(spriteBatch,
new Vector2(item.WorldPosition.X, -item.WorldPosition.Y + 20), "Condition: " + (int)item.Condition + "/" + (int)item.MaxCondition,
new Vector2(item.DrawPosition.X, -item.DrawPosition.Y + 20), "Condition: " + (int)item.Condition + "/" + (int)item.MaxCondition,
GUI.Style.Orange);
}
}
@@ -23,7 +23,7 @@ namespace Barotrauma.Items.Components
public static void DrawConnections(SpriteBatch spriteBatch, ConnectionPanel panel, Character character)
{
if (DraggingConnected?.Item.Removed ?? false)
if (DraggingConnected?.Item?.Removed ?? true)
{
DraggingConnected = null;
}
@@ -580,14 +580,20 @@ namespace Barotrauma.Items.Components
private void GetAvailablePower(out float availableCharge, out float availableCapacity)
{
var batteries = item.GetConnectedComponents<PowerContainer>();
availableCharge = 0.0f;
availableCapacity = 0.0f;
foreach (PowerContainer battery in batteries)
if (item.Connections == null) { return; }
foreach (Connection c in item.Connections)
{
availableCharge += battery.Charge;
availableCapacity += battery.Capacity;
var recipients = c.Recipients;
foreach (Connection recipient in recipients)
{
if (!recipient.IsPower || !recipient.IsOutput) { continue; }
var battery = recipient.Item?.GetComponent<PowerContainer>();
if (battery == null) { continue; }
availableCharge += battery.Charge;
availableCapacity += battery.Capacity;
}
}
}
@@ -647,7 +653,9 @@ namespace Barotrauma.Items.Components
bool readyToFire = reload <= 0.0f && charged && availableAmmo.Any(p => p != null);
if (ShowChargeIndicator && PowerConsumption > 0.0f)
{
powerIndicator.Color = charged ? GUI.Style.Green : GUI.Style.Red;
powerIndicator.Color = charged ?
(HasPowerToShoot() ? GUI.Style.Green : GUI.Style.Orange) :
GUI.Style.Red;
if (flashLowPower)
{
powerIndicator.BarSize = 1;
@@ -10,7 +10,13 @@ namespace Barotrauma.Items.Components
int roundedValue = (int)Math.Round((1 - damageModifier.DamageMultiplier * damageModifier.ProbabilityMultiplier) * 100);
if (roundedValue == 0) { return; }
string colorStr = XMLExtensions.ColorToString(GUI.Style.Green);
description += $"\n ‖color:{colorStr}‖{roundedValue.ToString("-0;+#")}%‖color:end‖ {AfflictionPrefab.List.FirstOrDefault(ap => ap.Identifier.Equals(afflictionIdentifier, StringComparison.OrdinalIgnoreCase))?.Name ?? afflictionIdentifier}";
string afflictionName =
AfflictionPrefab.List.FirstOrDefault(ap => ap.Identifier.Equals(afflictionIdentifier, StringComparison.OrdinalIgnoreCase))?.Name ??
TextManager.Get($"afflictiontype.{afflictionIdentifier}", returnNull: true) ??
afflictionIdentifier;
description += $"\n ‖color:{colorStr}‖{roundedValue.ToString("-0;+#")}%‖color:end‖ {afflictionName}";
}
public override void AddTooltipInfo(ref string name, ref string description)
@@ -33,9 +39,9 @@ namespace Barotrauma.Items.Components
{
GetDamageModifierText(ref description, damageModifier, afflictionIdentifier);
}
foreach (string afflictionIdentifier in damageModifier.ParsedAfflictionTypes)
foreach (string afflictionType in damageModifier.ParsedAfflictionTypes)
{
GetDamageModifierText(ref description, damageModifier, afflictionIdentifier);
GetDamageModifierText(ref description, damageModifier, afflictionType);
}
}
}
@@ -1181,7 +1181,7 @@ namespace Barotrauma
}
texts.Add(new ColoredText(nameText, GUI.Style.TextColor, false, false));
if (CampaignInteractionType != CampaignMode.InteractionType.None)
if (CampaignMode.BlocksInteraction(CampaignInteractionType))
{
texts.Add(new ColoredText(TextManager.GetWithVariable($"CampaignInteraction.{CampaignInteractionType}", "[key]", GameMain.Config.KeyBindText(InputType.Use)), Color.Cyan, false, false));
}
@@ -1550,6 +1550,7 @@ namespace Barotrauma
Vector2 pos = Vector2.Zero;
Submarine sub = null;
float rotation = 0.0f;
int itemContainerIndex = -1;
int inventorySlotIndex = -1;
@@ -1561,7 +1562,7 @@ namespace Barotrauma
else
{
pos = new Vector2(msg.ReadSingle(), msg.ReadSingle());
rotation = msg.ReadRangedSingle(0, MathHelper.TwoPi, 8);
ushort subID = msg.ReadUInt16();
if (subID > 0)
{
@@ -130,18 +130,31 @@ namespace Barotrauma
int tilesY = (int)Math.Ceiling(Height / tileSize.Y);
mapTiles = new Sprite[tilesX, tilesY];
tileDiscovered = new bool[tilesX, tilesY];
HashSet<Biome> missingBiomes = new HashSet<Biome>();
for (int x = 0; x < tilesX; x++)
{
for (int y = 0; y < tilesY; y++)
{
var biome = GetBiome(x * tileSize.X);
var tileList = generationParams.MapTiles.ContainsKey(biome.Identifier) ?
generationParams.MapTiles[biome.Identifier] :
generationParams.MapTiles.Values.First();
List<Sprite> tileList = null;
if (generationParams.MapTiles.ContainsKey(biome.Identifier))
{
tileList = generationParams.MapTiles[biome.Identifier];
}
else
{
tileList = generationParams.MapTiles.Values.First();
missingBiomes.Add(biome);
}
mapTiles[x, y] = tileList[x % tileList.Count];
}
}
foreach (var missingBiome in missingBiomes)
{
DebugConsole.ThrowError($"Could not find campaign map sprites for the biome \"{missingBiome.Identifier}\". Using the sprites of the first biome instead...");
}
RemoveFogOfWar(StartLocation);
GenerateLocationConnectionVisuals();
@@ -772,7 +772,7 @@ namespace Barotrauma
if (item.FlippedX && item.Prefab.CanSpriteFlipX) { spriteEffects ^= SpriteEffects.FlipHorizontally; }
if (item.flippedY && item.Prefab.CanSpriteFlipY) { spriteEffects ^= SpriteEffects.FlipVertically; }
var wire = item.GetComponent<Wire>();
if (wire != null && !wire.Item.body.Enabled)
if (wire != null && wire.Item.body != null && !wire.Item.body.Enabled)
{
wire.Draw(spriteBatch, editing: false, new Vector2(moveAmount.X, -moveAmount.Y));
continue;
@@ -55,9 +55,9 @@ namespace Barotrauma
if (closestSub != null && subsToMove.Contains(closestSub))
{
GameMain.GameScreen.Cam.Position += moveAmount;
if (GameMain.GameScreen.Cam.TargetPos != Vector2.Zero) GameMain.GameScreen.Cam.TargetPos += moveAmount;
if (GameMain.GameScreen.Cam.TargetPos != Vector2.Zero) { GameMain.GameScreen.Cam.TargetPos += moveAmount; }
if (Character.Controlled != null) Character.Controlled.CursorPosition += moveAmount;
if (Character.Controlled != null) { Character.Controlled.CursorPosition += moveAmount; }
}
}
@@ -316,11 +316,11 @@ namespace Barotrauma
var srcRect = prefab.sprite.SourceRect;
SpriteEffects spriteEffects = SpriteEffects.None;
if (flippedX)
if (flippedX && ((prefab as ItemPrefab)?.CanSpriteFlipX ?? true))
{
spriteEffects |= SpriteEffects.FlipHorizontally;
}
if (flippedY)
if (flippedY && ((prefab as ItemPrefab)?.CanSpriteFlipY ?? true))
{
spriteEffects |= SpriteEffects.FlipVertically;
}
@@ -90,14 +90,14 @@ namespace Barotrauma
{
GUI.DrawLine(spriteBatch,
drawPos,
new Vector2(ConnectedGap.WorldPosition.X, -ConnectedGap.WorldPosition.Y),
new Vector2(ConnectedGap.DrawPosition.X, -ConnectedGap.DrawPosition.Y),
GUI.Style.Green * 0.5f, width: 1);
}
if (Ladders != null)
{
GUI.DrawLine(spriteBatch,
drawPos,
new Vector2(Ladders.Item.WorldPosition.X, -Ladders.Item.WorldPosition.Y),
new Vector2(Ladders.Item.DrawPosition.X, -Ladders.Item.DrawPosition.Y),
GUI.Style.Green * 0.5f, width: 1);
}
@@ -1,4 +1,5 @@
using Barotrauma.Networking;
using Barotrauma.Items.Components;
using Barotrauma.Networking;
namespace Barotrauma
{
@@ -15,7 +16,11 @@ namespace Barotrauma
var entity = FindEntityByID(entityId);
if (entity != null)
{
DebugConsole.Log("Received entity removal message for \"" + entity.ToString() + "\".");
DebugConsole.Log($"Received entity removal message for \"{entity}\".");
if (entity is Item item && item.Container?.GetComponent<Deconstructor>() != null)
{
GameAnalyticsManager.AddDesignEvent("ItemDeconstructed:" + (GameMain.GameSession?.GameMode?.Preset.Identifier ?? "none") + ":" + item.prefab.Identifier);
}
entity.Remove();
}
else
@@ -28,7 +33,11 @@ namespace Barotrauma
switch (message.ReadByte())
{
case (byte)SpawnableType.Item:
Item.ReadSpawnData(message, true);
var newItem = Item.ReadSpawnData(message, true);
if (newItem is Item item && item.Container?.GetComponent<Fabricator>() != null)
{
GameAnalyticsManager.AddDesignEvent("ItemFabricated:" + (GameMain.GameSession?.GameMode?.Preset.Identifier ?? "none") + ":" + item.prefab.Identifier);
}
break;
case (byte)SpawnableType.Character:
Character.ReadSpawnData(message);
@@ -251,7 +251,7 @@ namespace Barotrauma.CharacterEditor
GUI.ForceMouseOn(null);
if (isEndlessRunner)
{
Submarine.MainSub.Remove();
Submarine.MainSub?.Remove();
GameMain.World.ProcessChanges();
isEndlessRunner = false;
Reset();
@@ -115,7 +115,7 @@ namespace Barotrauma
#if TEST_REMOTE_CONTENT
var doc = XMLExtensions.TryLoadXml("Content/UI/MenuTextTest.xml");
var doc = XMLExtensions.TryLoadXml("Content/UI/MenuContent.xml");
if (doc?.Root != null)
{
foreach (XElement subElement in doc?.Root.Elements())
@@ -144,7 +144,7 @@ namespace Barotrauma
private GUIDropDown linkedSubBox;
private static GUIComponent autoSaveLabel;
private static int maxAutoSaves = GameSettings.MaximumAutoSaves;
private readonly static int maxAutoSaves = GameSettings.MaximumAutoSaves;
public static readonly object ItemAddMutex = new object(), ItemRemoveMutex = new object();
@@ -541,7 +541,7 @@ namespace Barotrauma
//-----------------------------------------------
layerPanel = new GUIFrame(new RectTransform(new Vector2(0.2f, 0.4f), GUI.Canvas))
layerPanel = new GUIFrame(new RectTransform(new Vector2(0.25f, 0.4f), GUI.Canvas, minSize: new Point(300, 320)))
{
Visible = false
};
@@ -604,11 +604,13 @@ namespace Barotrauma
RenameLayer(layer, newName);
});
}
return true;
}
};
GUITextBlock.AutoScaleAndNormalize(layerAddButton.TextBlock, layerDeleteButton.TextBlock, layerRenameButton.TextBlock);
Vector2 subPanelSize = new Vector2(0.925f, 0.9f);
undoBufferPanel = new GUIFrame(new RectTransform(new Vector2(0.15f, 0.2f), GUI.Canvas) { MinSize = new Point(200, 200) })
@@ -4433,9 +4435,9 @@ namespace Barotrauma
layerList.Deselect();
GUILayoutGroup buttonHeaders = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.075f), layerList.Content.RectTransform), isHorizontal: true, childAnchor: Anchor.BottomLeft);
new GUIButton(new RectTransform(new Vector2(0.25f, 1f), buttonHeaders.RectTransform), TextManager.Get("editor.layer.headervisible"), style: "GUIButtonSmallFreeScale") { CanBeFocused = false, ForceUpperCase = true };
new GUIButton(new RectTransform(new Vector2(0.15f, 1f), buttonHeaders.RectTransform), TextManager.Get("editor.layer.headerlink"), style: "GUIButtonSmallFreeScale") { CanBeFocused = false, ForceUpperCase = true };
new GUIButton(new RectTransform(new Vector2(0.65f, 1f), buttonHeaders.RectTransform), TextManager.Get("name"), style: "GUIButtonSmallFreeScale") { CanBeFocused = false, ForceUpperCase = true };
new GUIButton(new RectTransform(new Vector2(0.25f, 1f), buttonHeaders.RectTransform), TextManager.Get("editor.layer.headervisible"), style: "GUIButtonSmallFreeScale") { ForceUpperCase = true };
new GUIButton(new RectTransform(new Vector2(0.15f, 1f), buttonHeaders.RectTransform), TextManager.Get("editor.layer.headerlink"), style: "GUIButtonSmallFreeScale") { ForceUpperCase = true };
new GUIButton(new RectTransform(new Vector2(0.6f, 1f), buttonHeaders.RectTransform), TextManager.Get("name"), style: "GUIButtonSmallFreeScale") { ForceUpperCase = true };
foreach (var (layer, (visibility, linkage)) in Layers)
{
@@ -4494,6 +4496,17 @@ namespace Barotrauma
layerList.RecalculateChildren();
buttonHeaders.Recalculate();
foreach (var child in buttonHeaders.Children)
{
var btn = child as GUIButton;
string originalBtnText = btn.Text;
btn.Text = ToolBox.LimitString(btn.Text, btn.Font, btn.Rect.Width);
if (originalBtnText != btn.Text)
{
btn.ToolTip = originalBtnText;
}
}
}
public void UpdateUndoHistoryPanel()
@@ -1178,7 +1178,7 @@ namespace Barotrauma
if ((s.damageRange == Vector2.Zero ||
(damage >= s.damageRange.X && damage <= s.damageRange.Y)) &&
string.Equals(s.damageType, damageType, StringComparison.OrdinalIgnoreCase) &&
(tags == null ? string.IsNullOrEmpty(s.requiredTag) : tags.Contains(s.requiredTag)))
(string.IsNullOrEmpty(s.requiredTag) || (tags == null ? string.IsNullOrEmpty(s.requiredTag) : tags.Contains(s.requiredTag))))
{
tempList.Add(s);
}