(965c31410a) Unstable v0.10.4.0

This commit is contained in:
Juan Pablo Arce
2020-07-21 08:57:50 -03:00
parent 4f8bd39789
commit 33d3a41104
546 changed files with 45952 additions and 25762 deletions
@@ -1,5 +1,6 @@
using Barotrauma.Networking;
using Microsoft.Xna.Framework.Graphics;
using System.ComponentModel;
namespace Barotrauma.Items.Components
{
@@ -74,6 +75,21 @@ namespace Barotrauma.Items.Components
}
}
#if DEBUG
public override void CreateEditingHUD(SerializableEntityEditor editor)
{
base.CreateEditingHUD(editor);
foreach (LimbPos limbPos in limbPositions)
{
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(limbPos);
PropertyDescriptor limbPosProperty = properties.Find("Position", false);
editor.CreateVector2Field(limbPos, new SerializableProperty(limbPosProperty), limbPos.Position, limbPos.LimbType.ToString(), "");
}
}
#endif
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
{
State = msg.ReadBoolean();
@@ -23,17 +23,15 @@ namespace Barotrauma.Items.Components
partial void InitProjSpecific(XElement element)
{
CreateGUI();
GameMain.Instance.OnResolutionChanged += RecreateGUI;
}
private void RecreateGUI()
protected override void OnResolutionChanged()
{
GuiFrame.ClearChildren();
CreateGUI();
base.OnResolutionChanged();
OnItemLoadedProjSpecific();
}
private void CreateGUI()
protected override void CreateGUI()
{
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.90f, 0.80f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
{
@@ -170,10 +168,5 @@ namespace Barotrauma.Items.Components
SetActive(msg.ReadBoolean());
progressTimer = msg.ReadSingle();
}
protected override void RemoveComponentSpecific()
{
GameMain.Instance.OnResolutionChanged -= RecreateGUI;
}
}
}
@@ -42,17 +42,15 @@ namespace Barotrauma.Items.Components
partial void InitProjSpecific()
{
CreateGUI();
GameMain.Instance.OnResolutionChanged += RecreateGUI;
}
private void RecreateGUI()
protected override void OnResolutionChanged()
{
GuiFrame.ClearChildren();
CreateGUI();
base.OnResolutionChanged();
OnItemLoadedProjSpecific();
}
private void CreateGUI()
protected override void CreateGUI()
{
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter);
@@ -242,8 +240,8 @@ namespace Barotrauma.Items.Components
var item1 = c1.GUIComponent.UserData as FabricationRecipe;
var item2 = c2.GUIComponent.UserData as FabricationRecipe;
bool hasSkills1 = DegreeOfSuccess(character, item1.RequiredSkills) >= 0.5f;
bool hasSkills2 = DegreeOfSuccess(character, item2.RequiredSkills) >= 0.5f;
bool hasSkills1 = FabricationDegreeOfSuccess(character, item1.RequiredSkills) >= 0.5f;
bool hasSkills2 = FabricationDegreeOfSuccess(character, item2.RequiredSkills) >= 0.5f;
if (hasSkills1 != hasSkills2)
{
@@ -267,7 +265,7 @@ namespace Barotrauma.Items.Components
AutoScaleHorizontal = true,
CanBeFocused = false
};
var firstinSufficient = itemList.Content.Children.FirstOrDefault(c => c.UserData is FabricationRecipe fabricableItem && DegreeOfSuccess(character, fabricableItem.RequiredSkills) < 0.5f);
var firstinSufficient = itemList.Content.Children.FirstOrDefault(c => c.UserData is FabricationRecipe fabricableItem && FabricationDegreeOfSuccess(character, fabricableItem.RequiredSkills) < 0.5f);
if (firstinSufficient != null)
{
insufficientSkillsText.RectTransform.RepositionChildInHierarchy(itemList.Content.RectTransform.GetChildIndex(firstinSufficient.RectTransform));
@@ -476,7 +474,7 @@ namespace Barotrauma.Items.Components
List<Skill> inadequateSkills = new List<Skill>();
if (user != null)
{
inadequateSkills = selectedItem.RequiredSkills.FindAll(skill => user.GetSkillLevel(skill.Identifier) < skill.Level);
inadequateSkills = selectedItem.RequiredSkills.FindAll(skill => user.GetSkillLevel(skill.Identifier) < Math.Round(skill.Level * SkillRequirementMultiplier));
}
if (selectedItem.RequiredSkills.Any())
@@ -489,13 +487,13 @@ namespace Barotrauma.Items.Components
};
foreach (Skill skill in selectedItem.RequiredSkills)
{
text += TextManager.Get("SkillName." + skill.Identifier) + " " + TextManager.Get("Lvl").ToLower() + " " + skill.Level;
text += TextManager.Get("SkillName." + skill.Identifier) + " " + TextManager.Get("Lvl").ToLower() + " " + Math.Round(skill.Level * SkillRequirementMultiplier);
if (skill != selectedItem.RequiredSkills.Last()) { text += "\n"; }
}
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedReqFrame.RectTransform), text, font: GUI.SmallFont);
}
float degreeOfSuccess = user == null ? 0.0f : DegreeOfSuccess(user, selectedItem.RequiredSkills);
float degreeOfSuccess = user == null ? 0.0f : FabricationDegreeOfSuccess(user, selectedItem.RequiredSkills);
if (degreeOfSuccess > 0.5f) { degreeOfSuccess = 1.0f; }
float requiredTime = user == null ? selectedItem.RequiredTime : GetRequiredTime(selectedItem, user);
@@ -621,10 +619,5 @@ namespace Barotrauma.Items.Components
StartFabricating(fabricationRecipes[itemIndex], user);
}
}
protected override void RemoveComponentSpecific()
{
GameMain.Instance.OnResolutionChanged -= RecreateGUI;
}
}
}
@@ -24,7 +24,17 @@ namespace Barotrauma.Items.Components
partial void InitProjSpecific(XElement element)
{
noPowerTip = TextManager.Get("SteeringNoPowerTip");
CreateGUI();
}
protected override void OnResolutionChanged()
{
base.OnResolutionChanged();
CreateHUD();
}
protected override void CreateGUI()
{
GuiFrame.RectTransform.RelativeOffset = new Vector2(0.05f, 0.0f);
GuiFrame.CanBeFocused = true;
new GUICustomComponent(new RectTransform(GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin, GuiFrame.RectTransform, Anchor.Center) { AbsoluteOffset = GUIStyle.ItemFrameOffset },
@@ -53,7 +63,11 @@ namespace Barotrauma.Items.Components
hullAirQualityText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), hullInfoContainer.RectTransform), "") { Wrap = true };
hullWaterText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), hullInfoContainer.RectTransform), "") { Wrap = true };
hullInfoFrame.Children.ForEach(c => { c.CanBeFocused = false; c.Children.ForEach(c2 => c2.CanBeFocused = false); });
hullInfoFrame.Children.ForEach(c =>
{
c.CanBeFocused = false;
c.Children.ForEach(c2 => c2.CanBeFocused = false);
});
}
public override void AddToGUIUpdateList()
@@ -72,7 +86,7 @@ namespace Barotrauma.Items.Components
{
submarineContainer.ClearChildren();
if (item.Submarine == null) return;
if (item.Submarine == null) { return; }
item.Submarine.CreateMiniMap(submarineContainer);
displayedSubs.Clear();
@@ -125,10 +139,8 @@ namespace Barotrauma.Items.Components
GUI.Style.Orange * (float)Math.Abs(Math.Sin(Timing.TotalTime)), Color.Black * 0.8f, font: GUI.SubHeadingFont);
return;
}
if (!submarineContainer.Children.Any()) { return; }
foreach (GUIComponent child in submarineContainer.Children.First().Children)
foreach (GUIComponent child in submarineContainer.Children.FirstOrDefault()?.Children)
{
if (child.UserData is Hull hull)
{
@@ -177,9 +189,19 @@ namespace Barotrauma.Items.Components
HashSet<Submarine> subs = new HashSet<Submarine>();
foreach (Hull hull in Hull.hullList)
{
if (hull.Submarine == null) continue;
if (hull.Submarine == null) { continue; }
var hullFrame = submarineContainer.Children.FirstOrDefault()?.FindChild(hull);
if (hullFrame == null) continue;
if (hullFrame == null) { continue; }
hullFrame.Visible = true;
if (!submarineContainer.Rect.Contains(hullFrame.Rect))
{
if (hull.Submarine.Info.Type != SubmarineType.Player)
{
hullFrame.Visible = false;
continue;
}
}
hullDatas.TryGetValue(hull, out HullData hullData);
if (hullData == null)
@@ -294,7 +316,7 @@ namespace Barotrauma.Items.Components
foreach (Submarine sub in subs)
{
if (sub.HullVertices == null) { continue; }
if (sub.HullVertices == null || sub.Info.IsOutpost) { continue; }
Rectangle worldBorders = sub.GetDockedBorders();
worldBorders.Location += sub.WorldPosition.ToPoint();
@@ -0,0 +1,42 @@
namespace Barotrauma.Items.Components
{
partial class OutpostTerminal : ItemComponent
{
private SubmarineSelection selectionUI;
public override bool Select(Character character)
{
if (GameMain.GameSession?.Campaign == null)
{
return false;
}
if (selectionUI == null)
{
selectionUI = new SubmarineSelection(true, null, GUICanvas.Instance.ItemComponentHolder);
}
GuiFrame = selectionUI.GuiFrame;
selectionUI.RefreshSubmarineDisplay(true);
IsActive = true;
return base.Select(character);
}
public override void Update(float deltaTime, Camera cam)
{
if (Character.Controlled?.SelectedConstruction != item)
{
IsActive = false;
return;
}
base.Update(deltaTime, cam);
if (selectionUI != null)
{
selectionUI.Update();
}
}
}
}
@@ -157,16 +157,15 @@ namespace Barotrauma.Items.Components
}
}
CreateGUI();
GameMain.Instance.OnResolutionChanged += RecreateGUI;
}
private void RecreateGUI()
protected override void OnResolutionChanged()
{
GuiFrame.ClearChildren();
CreateGUI();
base.OnResolutionChanged();
UpdateGUIElements();
}
private void CreateGUI()
protected override void CreateGUI()
{
bool isConnectedToSteering = item.GetComponent<Steering>() != null;
Vector2 size = isConnectedToSteering ? controlBoxSize : new Vector2(controlBoxSize.X * 2.0f, controlBoxSize.Y);
@@ -667,23 +666,27 @@ namespace Barotrauma.Items.Components
signalWarningText.Visible = false;
}
if (GameMain.GameSession == null) { return; }
if (GameMain.GameSession == null || Level.Loaded == null) { return; }
if (Level.Loaded == null) { return; }
if (Level.Loaded.StartLocation != null)
{
DrawMarker(spriteBatch,
Level.Loaded.StartLocation.Name,
"outpost",
Level.Loaded.StartLocation.Name,
Level.Loaded.StartPosition, transducerCenter,
displayScale, center, DisplayRadius);
}
DrawMarker(spriteBatch,
GameMain.GameSession.StartLocation.Name,
"outpost",
GameMain.GameSession.StartLocation.Name,
Level.Loaded.StartPosition, transducerCenter,
displayScale, center, DisplayRadius);
DrawMarker(spriteBatch,
GameMain.GameSession.EndLocation.Name,
"outpost",
GameMain.GameSession.EndLocation.Name,
Level.Loaded.EndPosition, transducerCenter,
displayScale, center, DisplayRadius);
if (Level.Loaded.EndLocation != null && Level.Loaded.Type == LevelData.LevelType.LocationConnection)
{
DrawMarker(spriteBatch,
Level.Loaded.EndLocation.Name,
"outpost",
Level.Loaded.EndLocation.Name,
Level.Loaded.EndPosition, transducerCenter,
displayScale, center, DisplayRadius);
}
foreach (AITarget aiTarget in AITarget.List)
{
@@ -1444,8 +1447,6 @@ namespace Barotrauma.Items.Components
sprite.Remove();
}
targetIcons.Clear();
GameMain.Instance.OnResolutionChanged -= RecreateGUI;
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
@@ -53,6 +53,8 @@ namespace Barotrauma.Items.Components
private bool? swapDestinationOrder;
private GUIMessageBox enterOutpostPrompt;
private bool levelStartSelected;
public bool LevelStartSelected
{
@@ -105,10 +107,9 @@ namespace Barotrauma.Items.Components
}
}
CreateGUI();
GameMain.Instance.OnResolutionChanged += RecreateGUI;
}
private void CreateGUI()
protected override void CreateGUI()
{
controlContainer = new GUIFrame(new RectTransform(new Vector2(Sonar.controlBoxSize.X, 1 - Sonar.controlBoxSize.Y * 2), GuiFrame.RectTransform, Anchor.CenterLeft), "ItemUI");
var paddedControlContainer = new GUIFrame(new RectTransform(controlContainer.Rect.Size - GUIStyle.ItemFrameMargin, controlContainer.RectTransform, Anchor.Center)
@@ -220,11 +221,12 @@ namespace Barotrauma.Items.Components
};
levelEndTickBox = new GUITickBox(new RectTransform(new Vector2(1, 0.333f), paddedAutoPilotControls.RectTransform, Anchor.BottomCenter),
GameMain.GameSession?.EndLocation == null ? "" : ToolBox.LimitString(GameMain.GameSession.EndLocation.Name, textLimit),
(GameMain.GameSession?.EndLocation == null || Level.IsLoadedOutpost) ? "" : ToolBox.LimitString(GameMain.GameSession.EndLocation.Name, textLimit),
font: GUI.SmallFont, style: "GUIRadioButton")
{
Enabled = autoPilot,
Selected = levelEndSelected,
Visible = GameMain.GameSession?.EndLocation != null,
OnSelected = tickBox =>
{
if (levelEndSelected != tickBox.Selected)
@@ -321,7 +323,7 @@ namespace Barotrauma.Items.Components
};
break;
}
new GUITextBlock(new RectTransform(Vector2.One, left.RectTransform), leftText, font: GUI.SubHeadingFont, wrap: true, textAlignment: Alignment.CenterRight);
new GUITextBlock(new RectTransform(Vector2.One, left.RectTransform), leftText, font: GUI.SubHeadingFont, wrap: leftText.Contains(' '), textAlignment: Alignment.CenterRight);
new GUITextBlock(new RectTransform(Vector2.One, center.RectTransform), centerText, font: GUI.Font, textAlignment: Alignment.Center) { Padding = Vector4.Zero };
var digitalFrame = new GUIFrame(new RectTransform(Vector2.One, right.RectTransform), style: "DigitalFrameDark");
new GUITextBlock(new RectTransform(Vector2.One * 0.85f, digitalFrame.RectTransform, Anchor.Center), "12345", GUI.Style.TextColorDark, GUI.DigitalFont, Alignment.CenterRight)
@@ -347,18 +349,47 @@ namespace Barotrauma.Items.Components
{
OnClicked = (btn, userdata) =>
{
if (GameMain.Client == null)
if (GameMain.GameSession?.Campaign != null)
{
item.SendSignal(0, "1", "toggle_docking", sender: null);
}
else
{
dockingNetworkMessagePending = true;
item.CreateClientEvent(this);
if (Level.IsLoadedOutpost &&
DockingSources.Any(d => d.Docked && (d.DockingTarget?.Item.Submarine?.Info?.IsOutpost ?? false)))
{
GameMain.GameSession.Campaign.CampaignUI.SelectTab(CampaignMode.InteractionType.Map);
GameMain.GameSession.Campaign.ShowCampaignUI = true;
return false;
}
else if (!Level.IsLoadedOutpost && DockingModeEnabled && ActiveDockingSource != null &&
!ActiveDockingSource.Docked && (DockingTarget?.Item?.Submarine?.Info.IsOutpost ?? false))
{
enterOutpostPrompt = new GUIMessageBox("", TextManager.GetWithVariable("campaignenteroutpostprompt", "[locationname]", DockingTarget.Item.Submarine.Info.Name), new string[] { TextManager.Get("yes"), TextManager.Get("no") });
enterOutpostPrompt.Buttons[0].OnClicked += (btn, userdata) =>
{
SendDockingSignal();
enterOutpostPrompt.Close();
return true;
};
enterOutpostPrompt.Buttons[1].OnClicked += enterOutpostPrompt.Close;
return false;
}
}
SendDockingSignal();
return true;
}
};
void SendDockingSignal()
{
if (GameMain.Client == null)
{
item.SendSignal(0, "1", "toggle_docking", sender: null);
}
else
{
dockingNetworkMessagePending = true;
item.CreateClientEvent(this);
}
}
dockingButton.Font = GUI.SubHeadingFont;
dockingButton.TextBlock.RectTransform.MaxSize = new Point((int)(dockingButton.Rect.Width * 0.7f), int.MaxValue);
dockingButton.TextBlock.AutoScaleHorizontal = true;
@@ -413,10 +444,9 @@ namespace Barotrauma.Items.Components
GameMain.GameSession?.EndLocation == null ? "End" : GameMain.GameSession.EndLocation.Name);
}
private void RecreateGUI()
protected override void OnResolutionChanged()
{
GuiFrame.ClearChildren();
CreateGUI();
base.OnResolutionChanged();
UpdateGUIElements();
}
@@ -600,6 +630,10 @@ namespace Barotrauma.Items.Components
dockingContainer.Visible = DockingModeEnabled;
statusContainer.Visible = !DockingModeEnabled;
if (!DockingModeEnabled)
{
enterOutpostPrompt?.Close();
}
if (DockingModeEnabled && ActiveDockingSource != null)
{
@@ -613,6 +647,10 @@ namespace Barotrauma.Items.Components
dockingButton.Pulsate(Vector2.One, Vector2.One * 1.2f, dockingButton.FlashTimer);
}
}
else
{
enterOutpostPrompt?.Close();
}
}
else if (DockingSources.Any(d => d.Docked))
{
@@ -663,7 +701,8 @@ namespace Barotrauma.Items.Components
if (Vector2.DistanceSquared(PlayerInput.MousePosition, steerArea.Rect.Center.ToVector2()) < steerRadius * steerRadius)
{
if (PlayerInput.PrimaryMouseButtonHeld() && !CrewManager.IsCommandInterfaceOpen && !GameSession.IsTabMenuOpen)
if (PlayerInput.PrimaryMouseButtonHeld() && !CrewManager.IsCommandInterfaceOpen && !GameSession.IsTabMenuOpen &&
(!GameMain.GameSession?.Campaign?.ShowCampaignUI ?? true) && !GUIMessageBox.MessageBoxes.Any())
{
Vector2 inputPos = PlayerInput.MousePosition - steerArea.Rect.Center.ToVector2();
inputPos.Y = -inputPos.Y;
@@ -800,8 +839,7 @@ namespace Barotrauma.Items.Components
maintainPosIndicator?.Remove();
maintainPosOriginIndicator?.Remove();
steeringIndicator?.Remove();
GameMain.Instance.OnResolutionChanged -= RecreateGUI;
enterOutpostPrompt?.Close();
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)