v0.19.0.0 (unstable)

This commit is contained in:
Regalis11
2022-07-20 18:47:07 +03:00
parent 2e2663a175
commit 6b55adcdd9
170 changed files with 2769 additions and 1634 deletions
@@ -27,8 +27,6 @@ namespace Barotrauma
private bool hasMaxMissions;
private GUIButton repairHullsButton, replaceShuttlesButton, repairItemsButton;
private SubmarineSelection submarineSelection;
private Location selectedLocation;
@@ -101,170 +99,6 @@ namespace Barotrauma
tabs[(int)CampaignMode.InteractionType.Store] = storeTab;
Store = new Store(this, storeTab);
// repair tab -------------------------------------------------------------------------
tabs[(int)CampaignMode.InteractionType.Repair] = CreateDefaultTabContainer(container, new Vector2(0.7f));
var repairFrame = new GUIFrame(new RectTransform(Vector2.One, GetTabContainer(CampaignMode.InteractionType.Repair).RectTransform, Anchor.TopLeft), color: Color.Black * 0.9f);
new GUIFrame(new RectTransform(new Vector2(1.25f, 1.25f), repairFrame.RectTransform, Anchor.Center), style: "OuterGlow", color: Color.Black * 0.7f)
{
UserData = "outerglow",
CanBeFocused = false
};
var repairContent = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), repairFrame.RectTransform, Anchor.Center))
{
RelativeSpacing = 0.05f,
Stretch = true
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), repairContent.RectTransform), "", font: GUIStyle.LargeFont)
{
TextGetter = GetMoney
};
// repair hulls -----------------------------------------------
var repairHullsHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), repairContent.RectTransform), childAnchor: Anchor.TopRight)
{
RelativeSpacing = 0.05f,
Stretch = true
};
new GUIImage(new RectTransform(new Vector2(0.3f, 1.0f), repairHullsHolder.RectTransform, Anchor.CenterLeft), "RepairHullButton")
{
IgnoreLayoutGroups = true,
CanBeFocused = false
};
var repairHullsLabel = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.3f), repairHullsHolder.RectTransform), TextManager.Get("RepairAllWalls"), textAlignment: Alignment.Right, font: GUIStyle.SubHeadingFont)
{
ForceUpperCase = ForceUpperCase.Yes
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), repairHullsHolder.RectTransform), CampaignMode.HullRepairCost.ToString(), textAlignment: Alignment.Right, font: GUIStyle.SubHeadingFont);
repairHullsButton = new GUIButton(new RectTransform(new Vector2(0.4f, 0.3f), repairHullsHolder.RectTransform) { MinSize = new Point(140, 0) }, TextManager.Get("Repair"))
{
OnClicked = (btn, userdata) =>
{
if (Campaign.PurchasedHullRepairs)
{
Campaign.Wallet.Refund(CampaignMode.HullRepairCost);
Campaign.PurchasedHullRepairs = false;
}
else
{
if (Campaign.TryPurchase(null, CampaignMode.HullRepairCost))
{
GameAnalyticsManager.AddMoneySpentEvent(CampaignMode.HullRepairCost, GameAnalyticsManager.MoneySink.Service, "hullrepairs");
Campaign.PurchasedHullRepairs = true;
}
}
GameMain.Client?.SendCampaignState();
btn.GetChild<GUITickBox>().Selected = Campaign.PurchasedHullRepairs;
return true;
}
};
new GUITickBox(new RectTransform(new Vector2(0.65f), repairHullsButton.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point(10, 0) }, "")
{
CanBeFocused = false
};
// repair items -------------------------------------------
var repairItemsHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), repairContent.RectTransform), childAnchor: Anchor.TopRight)
{
RelativeSpacing = 0.05f,
Stretch = true
};
new GUIImage(new RectTransform(new Vector2(0.3f, 1.0f), repairItemsHolder.RectTransform, Anchor.CenterLeft), "RepairItemsButton")
{
IgnoreLayoutGroups = true,
CanBeFocused = false
};
var repairItemsLabel = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.3f), repairItemsHolder.RectTransform), TextManager.Get("RepairAllItems"), textAlignment: Alignment.Right, font: GUIStyle.SubHeadingFont)
{
ForceUpperCase = ForceUpperCase.Yes
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), repairItemsHolder.RectTransform), CampaignMode.ItemRepairCost.ToString(), textAlignment: Alignment.Right, font: GUIStyle.SubHeadingFont);
repairItemsButton = new GUIButton(new RectTransform(new Vector2(0.4f, 0.3f), repairItemsHolder.RectTransform) { MinSize = new Point(140, 0) }, TextManager.Get("Repair"))
{
OnClicked = (btn, userdata) =>
{
if (Campaign.PurchasedItemRepairs)
{
Campaign.Wallet.Refund(CampaignMode.ItemRepairCost);
Campaign.PurchasedItemRepairs = false;
}
else
{
if (Campaign.TryPurchase(null, CampaignMode.ItemRepairCost))
{
GameAnalyticsManager.AddMoneySpentEvent(CampaignMode.ItemRepairCost, GameAnalyticsManager.MoneySink.Service, "devicerepairs");
Campaign.PurchasedItemRepairs = true;
}
}
GameMain.Client?.SendCampaignState();
btn.GetChild<GUITickBox>().Selected = Campaign.PurchasedItemRepairs;
return true;
}
};
new GUITickBox(new RectTransform(new Vector2(0.65f), repairItemsButton.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point(10, 0) }, "")
{
CanBeFocused = false
};
// replace lost shuttles -------------------------------------------
var replaceShuttlesHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), repairContent.RectTransform), childAnchor: Anchor.TopRight)
{
RelativeSpacing = 0.05f,
Stretch = true
};
new GUIImage(new RectTransform(new Vector2(0.3f, 1.0f), replaceShuttlesHolder.RectTransform, Anchor.CenterLeft), "ReplaceShuttlesButton")
{
IgnoreLayoutGroups = true,
CanBeFocused = false
};
var replaceShuttlesLabel = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.3f), replaceShuttlesHolder.RectTransform), TextManager.Get("ReplaceLostShuttles"), textAlignment: Alignment.Right, font: GUIStyle.SubHeadingFont)
{
ForceUpperCase = ForceUpperCase.Yes
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), replaceShuttlesHolder.RectTransform), CampaignMode.ShuttleReplaceCost.ToString(), textAlignment: Alignment.Right, font: GUIStyle.SubHeadingFont);
replaceShuttlesButton = new GUIButton(new RectTransform(new Vector2(0.4f, 0.3f), replaceShuttlesHolder.RectTransform) { MinSize = new Point(140, 0) }, TextManager.Get("ReplaceShuttles"))
{
OnClicked = (btn, userdata) =>
{
if (GameMain.GameSession?.SubmarineInfo != null &&
GameMain.GameSession.SubmarineInfo.LeftBehindSubDockingPortOccupied)
{
new GUIMessageBox("", TextManager.Get("ReplaceShuttleDockingPortOccupied"));
return true;
}
if (Campaign.PurchasedLostShuttles)
{
Campaign.Wallet.Refund(CampaignMode.ShuttleReplaceCost);
Campaign.PurchasedLostShuttles = false;
}
else
{
if (Campaign.TryPurchase(null, CampaignMode.ShuttleReplaceCost))
{
GameAnalyticsManager.AddMoneySpentEvent(CampaignMode.ShuttleReplaceCost, GameAnalyticsManager.MoneySink.Service, "retrieveshuttle");
Campaign.PurchasedLostShuttles = true;
}
}
GameMain.Client?.SendCampaignState();
btn.GetChild<GUITickBox>().Selected = Campaign.PurchasedLostShuttles;
return true;
}
};
new GUITickBox(new RectTransform(new Vector2(0.65f), replaceShuttlesButton.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point(10, 0) }, "")
{
CanBeFocused = false
};
GUITextBlock.AutoScaleAndNormalize(repairHullsLabel, repairItemsLabel, replaceShuttlesLabel);
GUITextBlock.AutoScaleAndNormalize(repairHullsButton.GetChild<GUITickBox>().TextBlock, repairItemsButton.GetChild<GUITickBox>().TextBlock, replaceShuttlesButton.GetChild<GUITickBox>().TextBlock);
// upgrade tab -------------------------------------------------------------------------
tabs[(int)CampaignMode.InteractionType.Upgrade] = new GUIFrame(new RectTransform(Vector2.One, container.RectTransform), color: Color.Black * 0.9f);
@@ -701,26 +535,6 @@ namespace Barotrauma
switch (selectedTab)
{
case CampaignMode.InteractionType.Repair:
repairHullsButton.Enabled =
(Campaign.PurchasedHullRepairs || Campaign.Wallet.CanAfford(CampaignMode.HullRepairCost));
repairHullsButton.GetChild<GUITickBox>().Selected = Campaign.PurchasedHullRepairs;
repairItemsButton.Enabled =
(Campaign.PurchasedItemRepairs || Campaign.Wallet.CanAfford(CampaignMode.ItemRepairCost));
repairItemsButton.GetChild<GUITickBox>().Selected = Campaign.PurchasedItemRepairs;
if (GameMain.GameSession?.SubmarineInfo == null || !GameMain.GameSession.SubmarineInfo.SubsLeftBehind)
{
replaceShuttlesButton.Enabled = false;
replaceShuttlesButton.GetChild<GUITickBox>().Selected = false;
}
else
{
replaceShuttlesButton.Enabled =
(Campaign.PurchasedLostShuttles || Campaign.Wallet.CanAfford(CampaignMode.ShuttleReplaceCost));
replaceShuttlesButton.GetChild<GUITickBox>().Selected = Campaign.PurchasedLostShuttles;
}
break;
case CampaignMode.InteractionType.Store:
Store.SelectStore(storeIdentifier);
break;
@@ -2606,8 +2606,8 @@ namespace Barotrauma.CharacterEditor
animationControls = new GUIFrame(new RectTransform(Vector2.One, centerArea.RectTransform), style: null) { CanBeFocused = false };
var layoutGroupAnimation = new GUILayoutGroup(new RectTransform(Vector2.One, animationControls.RectTransform), childAnchor: Anchor.TopLeft) { CanBeFocused = false };
var animationSelectionElement = new GUIFrame(new RectTransform(new Point(elementSize.X * 2 - (int)(5 * GUI.xScale), elementSize.Y), layoutGroupAnimation.RectTransform), style: null);
var animationSelectionText = new GUITextBlock(new RectTransform(new Point(elementSize.X, elementSize.Y), animationSelectionElement.RectTransform), GetCharacterEditorTranslation("SelectedAnimation") + ": ", Color.WhiteSmoke, textAlignment: Alignment.Center);
animSelection = new GUIDropDown(new RectTransform(new Point((int)(100 * GUI.xScale), elementSize.Y), animationSelectionElement.RectTransform, Anchor.TopRight), elementCount: 5);
var animationSelectionText = new GUITextBlock(new RectTransform(new Point(elementSize.X, elementSize.Y), animationSelectionElement.RectTransform), GetCharacterEditorTranslation("SelectedAnimation"), Color.WhiteSmoke, textAlignment: Alignment.CenterRight);
animSelection = new GUIDropDown(new RectTransform(new Point((int)(150 * GUI.xScale), elementSize.Y), animationSelectionElement.RectTransform, Anchor.Center, Pivot.CenterLeft), elementCount: 5);
if (character.AnimController.CanWalk)
{
animSelection.AddItem(AnimationType.Walk.ToString(), AnimationType.Walk);
@@ -1,11 +1,10 @@
using Barotrauma.Extensions;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using FarseerPhysics;
using System.Diagnostics;
using System.Linq;
using Barotrauma.Extensions;
namespace Barotrauma
{
@@ -79,21 +78,27 @@ namespace Barotrauma
public override void AddToGUIUpdateList()
{
if (Character.Controlled != null && Character.Controlled.SelectedConstruction != null && Character.Controlled.CanInteractWith(Character.Controlled.SelectedConstruction))
if (Character.Controlled != null)
{
Character.Controlled.SelectedConstruction.AddToGUIUpdateList();
}
if (Character.Controlled?.Inventory != null)
{
foreach (Item item in Character.Controlled.Inventory.AllItems)
if (Character.Controlled.SelectedItem is { } selectedItem && Character.Controlled.CanInteractWith(selectedItem))
{
if (Character.Controlled.HasEquippedItem(item))
selectedItem.AddToGUIUpdateList();
}
if (Character.Controlled.SelectedSecondaryItem is { } selectedSecondaryItem && Character.Controlled.CanInteractWith(selectedSecondaryItem))
{
selectedSecondaryItem.AddToGUIUpdateList();
}
if (Character.Controlled.Inventory != null)
{
foreach (Item item in Character.Controlled.Inventory.AllItems)
{
item.AddToGUIUpdateList();
if (Character.Controlled.HasEquippedItem(item))
{
item.AddToGUIUpdateList();
}
}
}
}
GameMain.GameSession?.AddToGUIUpdateList();
Character.AddAllToGUIUpdateList();
}
@@ -260,11 +265,7 @@ namespace Barotrauma
//Draw the rest of the structures, characters and front structures
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
Submarine.DrawBack(spriteBatch, false, e => !(e is Structure) || e.SpriteDepth < 0.9f);
foreach (Character c in Character.CharacterList)
{
if (!c.IsVisible || c.AnimController.Limbs.Any(l => l.DeformSprite != null)) { continue; }
c.Draw(spriteBatch, Cam);
}
DrawCharacters(deformed: false, firstPass: true);
spriteBatch.End();
sw.Stop();
@@ -272,11 +273,12 @@ namespace Barotrauma
sw.Restart();
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
DrawDeformed(firstPass: true);
DrawDeformed(firstPass: false);
DrawCharacters(deformed: true, firstPass: true);
DrawCharacters(deformed: true, firstPass: false);
DrawCharacters(deformed: false, firstPass: false);
spriteBatch.End();
void DrawDeformed(bool firstPass)
void DrawCharacters(bool deformed, bool firstPass)
{
//backwards order to render the most recently spawned characters in front (characters spawned later have a larger sprite depth)
for (int i = Character.CharacterList.Count - 1; i >= 0; i--)
@@ -284,7 +286,14 @@ namespace Barotrauma
Character c = Character.CharacterList[i];
if (!c.IsVisible) { continue; }
if (c.Params.DrawLast == firstPass) { continue; }
if (c.AnimController.Limbs.All(l => l.DeformSprite == null)) { continue; }
if (deformed)
{
if (c.AnimController.Limbs.All(l => l.DeformSprite == null)) { continue; }
}
else
{
if (c.AnimController.Limbs.Any(l => l.DeformSprite != null)) { continue; }
}
c.Draw(spriteBatch, Cam);
}
}
@@ -695,8 +695,13 @@ namespace Barotrauma
gamesession.StartRound(fixedSeed ? "abcd" : ToolBox.RandomSeed(8), difficulty, levelGenerationParams);
GameMain.GameScreen.Select();
// TODO: modding support
string[] jobIdentifiers = new string[] { "captain", "engineer", "mechanic", "securityofficer", "medicaldoctor" };
foreach (string job in jobIdentifiers)
Identifier[] jobIdentifiers = new Identifier[] {
"captain".ToIdentifier(),
"engineer".ToIdentifier(),
"mechanic".ToIdentifier(),
"securityofficer".ToIdentifier(),
"medicaldoctor".ToIdentifier() };
foreach (Identifier job in jobIdentifiers)
{
var jobPrefab = JobPrefab.Get(job);
var variant = Rand.Range(0, jobPrefab.Variants);
@@ -55,9 +55,7 @@ namespace Barotrauma
while (timer < duration)
{
GUI.ScreenOverlayColor = Color.Lerp(from, to, Math.Min(timer / duration, 1.0f));
timer += CoroutineManager.UnscaledDeltaTime;
timer += CoroutineManager.DeltaTime;
yield return CoroutineStatus.Running;
}
@@ -813,8 +813,13 @@ namespace Barotrauma
var itemCount = new GUITextBlock(new RectTransform(new Vector2(0.33f, 1.0f), itemCountText.RectTransform, Anchor.TopRight, Pivot.TopLeft), "", textAlignment: Alignment.CenterRight);
itemCount.TextGetter = () =>
{
itemCount.TextColor = Item.ItemList.Count > MaxItems ? GUIStyle.Red : Color.Lerp(GUIStyle.Green, GUIStyle.Orange, Item.ItemList.Count / (float)MaxItems);
return Item.ItemList.Count.ToString();
int count = Item.ItemList.Count;
if (dummyCharacter?.Inventory != null)
{
count -= dummyCharacter.Inventory.AllItems.Count();
}
itemCount.TextColor = count > MaxItems ? GUIStyle.Red : Color.Lerp(GUIStyle.Green, GUIStyle.Orange, count / (float)MaxItems);
return count.ToString();
};
var structureCountText = new GUITextBlock(new RectTransform(new Vector2(0.75f, 0.0f), paddedEntityCountPanel.RectTransform), TextManager.Get("Structures"),
@@ -1497,7 +1502,7 @@ namespace Barotrauma
/// <returns></returns>
private static IEnumerable<CoroutineStatus> AutoSaveCoroutine()
{
DateTime target = DateTime.Now.AddMinutes(GameSettings.CurrentConfig.AutoSaveIntervalSeconds);
DateTime target = DateTime.Now.AddSeconds(GameSettings.CurrentConfig.AutoSaveIntervalSeconds);
DateTime tempTarget = DateTime.Now;
bool wasPaused = false;
@@ -1549,7 +1554,9 @@ namespace Barotrauma
MapEntity.DeselectAll();
ClearUndoBuffer();
#if !DEBUG
DebugConsole.DeactivateCheats();
#endif
SetMode(Mode.Default);
@@ -3337,23 +3344,21 @@ namespace Barotrauma
{
if (!(userData is XElement element)) { return; }
#warning TODO: revise
#warning TODO: revise
string filePath = element.GetAttributeStringUnrestricted("file", "");
if (string.IsNullOrWhiteSpace(filePath)) { return; }
var loadedSub = Submarine.Load(new SubmarineInfo(filePath), true);
// set the submarine file path to the "default" value
var unspecifiedFileName = TextManager.Get("UnspecifiedSubFileName");
loadedSub.Info.FilePath = Path.Combine(ContentPackage.LocalModsDir, unspecifiedFileName.Value, $"{unspecifiedFileName}.sub");
loadedSub.Info.Name = unspecifiedFileName.Value;
try
{
loadedSub.Info.Name = loadedSub.Info.SubmarineElement.GetAttributeString("name", loadedSub.Info.Name);
loadedSub.Info.Name = loadedSub.Info.SubmarineElement.GetAttributeString("name", loadedSub.Info.Name);
}
catch (Exception e)
{
DebugConsole.ThrowError("Failed to find a name for the submarine.", e);
var unspecifiedFileName = TextManager.Get("UnspecifiedSubFileName");
loadedSub.Info.Name = unspecifiedFileName.Value;
}
MainSub = loadedSub;
MainSub.SetPrevTransform(MainSub.Position);
@@ -3726,7 +3731,6 @@ namespace Barotrauma
}
else
{
List<ContextMenuOption> availableLayerOptions = new List<ContextMenuOption>
{
new ContextMenuOption("editor.layer.nolayer", true, onSelected: () => { MoveToLayer(null, targets); })
@@ -3769,7 +3773,8 @@ namespace Barotrauma
{
if (!me.Removed) { me.Remove(); }
}
}));
}),
new ContextMenuOption(TextManager.Get("editortip.shiftforextraoptions") + '\n' + TextManager.Get("editortip.altforruler"), isEnabled: false, onSelected: null));
}
}
@@ -4257,7 +4262,7 @@ namespace Barotrauma
MapEntity.SelectedList.Clear();
MapEntity.FilteredSelectedList.Clear();
MapEntity.SelectEntity(itemContainer);
dummyCharacter.SelectedConstruction = itemContainer;
dummyCharacter.SelectedItem = itemContainer;
FilterEntities(entityFilterBox.Text);
}
@@ -4268,9 +4273,9 @@ namespace Barotrauma
{
if (dummyCharacter == null) { return; }
//nothing to close -> return
if (DraggedItemPrefab == null && dummyCharacter?.SelectedConstruction == null && OpenedItem == null) { return; }
if (DraggedItemPrefab == null && dummyCharacter?.SelectedItem == null && OpenedItem == null) { return; }
DraggedItemPrefab = null;
dummyCharacter.SelectedConstruction = null;
dummyCharacter.SelectedItem = null;
OpenedItem?.Drop(dummyCharacter);
OpenedItem?.SetTransform(oldItemPosition, 0f);
OpenedItem = null;
@@ -4347,9 +4352,9 @@ namespace Barotrauma
}
}
if (dummyCharacter?.SelectedConstruction != null)
if (dummyCharacter?.SelectedItem != null)
{
var inv = dummyCharacter?.SelectedConstruction?.OwnInventory;
var inv = dummyCharacter?.SelectedItem?.OwnInventory;
if (inv != null)
{
switch (obj)
@@ -4779,9 +4784,9 @@ namespace Barotrauma
if (dummyCharacter != null)
{
CharacterHUD.AddToGUIUpdateList(dummyCharacter);
if (dummyCharacter.SelectedConstruction != null)
if (dummyCharacter.SelectedItem != null)
{
dummyCharacter.SelectedConstruction.AddToGUIUpdateList();
dummyCharacter.SelectedItem.AddToGUIUpdateList();
}
else if (WiringMode && MapEntity.SelectedList.FirstOrDefault() is Item item && item.GetComponent<Wire>() != null)
{
@@ -4801,7 +4806,7 @@ namespace Barotrauma
/// <summary>
/// GUI.MouseOn doesn't get updated while holding primary mouse and we need it to
/// </summary>
private bool IsMouseOnEditorGUI()
public bool IsMouseOnEditorGUI()
{
if (GUI.MouseOn == null) { return false; }
@@ -5143,7 +5148,7 @@ namespace Barotrauma
{
if (dummyCharacter != null)
{
if (dummyCharacter.SelectedConstruction == null)
if (dummyCharacter.SelectedItem == null)
{
foreach (var entity in MapEntity.mapEntityList)
{
@@ -5285,7 +5290,7 @@ namespace Barotrauma
me.IsHighlighted = false;
}
if (dummyCharacter.SelectedConstruction == null)
if (dummyCharacter.SelectedItem == null)
{
List<Wire> wires = new List<Wire>();
foreach (Item item in Item.ItemList)
@@ -5308,8 +5313,8 @@ namespace Barotrauma
});
}
if (dummyCharacter.SelectedConstruction == null ||
dummyCharacter.SelectedConstruction.GetComponent<Pickable>() != null)
if (dummyCharacter.SelectedItem == null ||
dummyCharacter.SelectedItem.GetComponent<Pickable>() != null)
{
if (WiringMode && PlayerInput.IsShiftDown())
{
@@ -5341,7 +5346,7 @@ namespace Barotrauma
TeleportDummyCharacter(oldItemPosition);
}
if (WiringMode && dummyCharacter?.SelectedConstruction == null)
if (WiringMode && dummyCharacter?.SelectedItem == null)
{
TeleportDummyCharacter(FarseerPhysics.ConvertUnits.ToSimUnits(dummyCharacter.CursorPosition));
}
@@ -5358,7 +5363,7 @@ namespace Barotrauma
}
// Deposit item from our "infinite stack" into inventory slots
var inv = dummyCharacter?.SelectedConstruction?.OwnInventory;
var inv = dummyCharacter?.SelectedItem?.OwnInventory;
if (inv?.visualSlots != null && !PlayerInput.IsCtrlDown())
{
var dragginMouse = MouseDragStart != Vector2.Zero && Vector2.Distance(PlayerInput.MousePosition, MouseDragStart) >= GUI.Scale * 20;
@@ -5524,7 +5529,7 @@ namespace Barotrauma
}
if (!saveAssemblyFrame.Rect.Contains(PlayerInput.MousePosition) && !snapToGridFrame.Rect.Contains(PlayerInput.MousePosition) &&
dummyCharacter?.SelectedConstruction == null && !WiringMode && GUI.MouseOn == null)
dummyCharacter?.SelectedItem == null && !WiringMode && GUI.MouseOn == null)
{
if (layerList is { Visible: true } && GUI.KeyboardDispatcher.Subscriber == layerList)
{
@@ -5549,7 +5554,7 @@ namespace Barotrauma
if (!WiringMode)
{
bool shouldCloseHud = dummyCharacter?.SelectedConstruction != null && HUD.CloseHUD(dummyCharacter.SelectedConstruction.Rect) && DraggedItemPrefab == null;
bool shouldCloseHud = dummyCharacter?.SelectedItem != null && HUD.CloseHUD(dummyCharacter.SelectedItem.Rect) && DraggedItemPrefab == null;
if (MapEntityPrefab.Selected != null && GUI.MouseOn == null)
{
@@ -5565,7 +5570,7 @@ namespace Barotrauma
}
else
{
if (dummyCharacter?.SelectedConstruction == null)
if (dummyCharacter?.SelectedItem == null)
{
CreateContextMenu();
}
@@ -5622,11 +5627,11 @@ namespace Barotrauma
wire?.Update((float)deltaTime, cam);
}
if (dummyCharacter.SelectedConstruction != null)
if (dummyCharacter.SelectedItem != null)
{
if (MapEntity.SelectedList.Contains(dummyCharacter.SelectedConstruction) || WiringMode)
if (MapEntity.SelectedList.Contains(dummyCharacter.SelectedItem) || WiringMode)
{
dummyCharacter.SelectedConstruction?.UpdateHUD(cam, dummyCharacter, (float)deltaTime);
dummyCharacter.SelectedItem?.UpdateHUD(cam, dummyCharacter, (float)deltaTime);
}
else
{
@@ -1,5 +1,4 @@
#nullable enable
using System;
using System.Linq;
using Barotrauma.Extensions;
using Barotrauma.Items.Components;
@@ -14,18 +13,14 @@ using Microsoft.Xna.Framework.Graphics;
*/
namespace Barotrauma
{
class TestScreen : EditorScreen
internal sealed class TestScreen : EditorScreen
{
public override Camera Cam { get; }
private Item? miniMapItem;
private Submarine? submarine;
public static Character? dummyCharacter;
public static Effect? BlueprintEffect;
private GUIFrame? container;
private TabMenu? tabMenu;
public TestScreen()
{
@@ -43,14 +38,11 @@ namespace Barotrauma
return true;
}
};
}
public override void Select()
{
base.Select();
container = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: "InnerGlow", color: Color.Black);
var tab = new GUIFrame(new RectTransform(Vector2.One, container.RectTransform), color: Color.Black * 0.9f);
if (dummyCharacter is { Removed: false })
{
dummyCharacter?.Remove();
@@ -61,30 +53,50 @@ namespace Barotrauma
dummyCharacter.Info.Name = "Galldren";
dummyCharacter.Inventory.CreateSlots();
miniMapItem = new Item(ItemPrefab.Find(null, "deconstructor".ToIdentifier()), Vector2.Zero, null, 1337, false);
foreach (ItemComponent component in miniMapItem.Components)
{
component.OnItemLoaded();
}
Character.Controlled = dummyCharacter;
GameMain.World.ProcessChanges();
tabMenu = new TabMenu();
}
public override void AddToGUIUpdateList()
{
Frame.AddToGUIUpdateList();
container?.AddToGUIUpdateList();
tabMenu?.AddToGUIUpdateList();
// CharacterHUD.AddToGUIUpdateList(dummyCharacter);
// dummyCharacter?.SelectedConstruction?.AddToGUIUpdateList();
CharacterHUD.AddToGUIUpdateList(dummyCharacter);
dummyCharacter?.SelectedItem?.AddToGUIUpdateList();
}
public override void Update(double deltaTime)
{
base.Update(deltaTime);
if (dummyCharacter is { } dummy)
if (dummyCharacter is { } dummy && miniMapItem is { } item)
{
if (dummy.SelectedItem != item)
{
dummy.SelectedItem = item;
}
dummy.SelectedItem?.UpdateHUD(Cam, dummy, (float)deltaTime);
Vector2 pos = FarseerPhysics.ConvertUnits.ToSimUnits(item.Position);
foreach (Limb limb in dummy.AnimController.Limbs)
{
limb.body.SetTransform(pos, 0.0f);
}
if (dummy.AnimController?.Collider is { } collider)
{
collider.SetTransform(pos, 0);
}
dummy.ControlLocalPlayer((float)deltaTime, Cam, false);
dummy.Control((float)deltaTime, Cam);
}
tabMenu?.Update((float)deltaTime);
}
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
@@ -93,12 +105,13 @@ namespace Barotrauma
graphics.Clear(BackgroundColor);
spriteBatch.Begin(SpriteSortMode.BackToFront, transformMatrix: Cam.Transform);
// miniMapItem?.Draw(spriteBatch, false);
// if (dummyCharacter is { } dummy)
// {
// dummyCharacter.DrawFront(spriteBatch, Cam);
// dummyCharacter.Draw(spriteBatch, Cam);
// }
miniMapItem?.Draw(spriteBatch, false);
if (dummyCharacter is { } dummy)
{
dummyCharacter.DrawFront(spriteBatch, Cam);
dummyCharacter.Draw(spriteBatch, Cam);
}
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState);