Unstable 1.2.1.0
This commit is contained in:
@@ -76,6 +76,8 @@ namespace Barotrauma
|
||||
private GUITextBlock tutorialHeader, tutorialDescription;
|
||||
private GUIListBox tutorialList;
|
||||
|
||||
private GUIComponent versionMismatchWarning;
|
||||
|
||||
#region Creation
|
||||
public MainMenuScreen(GameMain game)
|
||||
{
|
||||
@@ -105,6 +107,28 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
versionMismatchWarning = new GUIFrame(new RectTransform(new Vector2(0.7f, 0.065f), Frame.RectTransform) { AbsoluteOffset = new Point(GUI.IntScale(15)) }, style: "InnerFrame", color: GUIStyle.Red)
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
Visible = false
|
||||
};
|
||||
var versionMismatchContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), versionMismatchWarning.RectTransform, Anchor.Center), isHorizontal: true)
|
||||
{
|
||||
RelativeSpacing = 0.05f,
|
||||
};
|
||||
new GUIImage(new RectTransform(new Vector2(1.0f), versionMismatchContent.RectTransform, scaleBasis: ScaleBasis.Smallest), style: "GUINotificationButton")
|
||||
{
|
||||
Color = GUIStyle.Orange
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.85f, 1.0f), versionMismatchContent.RectTransform),
|
||||
TextManager.GetWithVariables("versionmismatchwarning",
|
||||
("[gameversion]", GameMain.Version.ToString()),
|
||||
("[contentversion]", ContentPackageManager.VanillaCorePackage.GameVersion.ToString())),
|
||||
wrap: true)
|
||||
{
|
||||
TextColor = GUIStyle.Orange
|
||||
};
|
||||
|
||||
new GUIImage(new RectTransform(new Vector2(0.4f, 0.25f), Frame.RectTransform, Anchor.BottomRight)
|
||||
{ RelativeOffset = new Vector2(0.08f, 0.05f), AbsoluteOffset = new Point(-8, -8) },
|
||||
style: "TitleText")
|
||||
@@ -587,7 +611,9 @@ namespace Barotrauma
|
||||
|
||||
GameMain.SubEditorScreen?.ClearBackedUpSubInfo();
|
||||
Submarine.Unload();
|
||||
|
||||
|
||||
versionMismatchWarning.Visible = GameMain.Version < ContentPackageManager.VanillaCorePackage.GameVersion;
|
||||
|
||||
ResetButtonStates(null);
|
||||
}
|
||||
|
||||
@@ -663,7 +689,18 @@ namespace Barotrauma
|
||||
.ToArray();
|
||||
foreach (var newServerExe in newServerExes)
|
||||
{
|
||||
serverExecutableDropdown.AddItem($"{newServerExe.ContentPackage.Name} - {Path.GetFileNameWithoutExtension(newServerExe.Path.Value)}", userData: newServerExe);
|
||||
var serverExeEntry = serverExecutableDropdown.AddItem($"{newServerExe.ContentPackage.Name} - {Path.GetFileNameWithoutExtension(newServerExe.Path.Value)}", userData: newServerExe);
|
||||
if (newServerExe.ContentPackage.GameVersion < GameMain.VanillaContent.GameVersion)
|
||||
{
|
||||
serverExeEntry.ToolTip =
|
||||
TextManager.GetWithVariables("versionmismatchwarning",
|
||||
("[gameversion]", newServerExe.ContentPackage.GameVersion.ToString()),
|
||||
("[contentversion]", GameMain.VanillaContent.GameVersion.ToString()));
|
||||
if (serverExeEntry is GUITextBlock serverExeText)
|
||||
{
|
||||
serverExeText.TextColor = GUIStyle.Red;
|
||||
}
|
||||
}
|
||||
}
|
||||
serverExecutableDropdown.ListBox.Content.Children.ForEach(c =>
|
||||
{
|
||||
@@ -1472,34 +1509,58 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
string name = serverNameBox.Text;
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
serverNameBox.Flash();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPublicBox.Selected && ForbiddenWordFilter.IsForbidden(name, out string forbiddenWord))
|
||||
{
|
||||
var msgBox = new GUIMessageBox("",
|
||||
TextManager.GetWithVariables("forbiddenservernameverification", ("[forbiddenword]", forbiddenWord), ("[servername]", name)),
|
||||
new LocalizedString[] { TextManager.Get("yes"), TextManager.Get("no") });
|
||||
msgBox.Buttons[0].OnClicked += (_, __) =>
|
||||
{
|
||||
TryStartServer();
|
||||
msgBox.Close();
|
||||
return true;
|
||||
};
|
||||
msgBox.Buttons[1].OnClicked += msgBox.Close;
|
||||
}
|
||||
else
|
||||
{
|
||||
TryStartServer();
|
||||
}
|
||||
|
||||
CheckServerName();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void CheckServerName()
|
||||
{
|
||||
string name = serverNameBox.Text;
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
serverNameBox.Flash();
|
||||
return;
|
||||
}
|
||||
if (isPublicBox.Selected && ForbiddenWordFilter.IsForbidden(name, out string forbiddenWord))
|
||||
{
|
||||
var msgBox = new GUIMessageBox("",
|
||||
TextManager.GetWithVariables("forbiddenservernameverification", ("[forbiddenword]", forbiddenWord), ("[servername]", name)),
|
||||
new LocalizedString[] { TextManager.Get("yes"), TextManager.Get("no") });
|
||||
msgBox.Buttons[0].OnClicked += (_, __) =>
|
||||
{
|
||||
CheckServerExe();
|
||||
msgBox.Close();
|
||||
return true;
|
||||
};
|
||||
msgBox.Buttons[1].OnClicked += msgBox.Close;
|
||||
return;
|
||||
}
|
||||
CheckServerExe();
|
||||
}
|
||||
|
||||
void CheckServerExe()
|
||||
{
|
||||
if (serverExecutableDropdown?.SelectedData is ServerExecutableFile serverExe &&
|
||||
serverExe.ContentPackage.GameVersion < GameMain.VanillaContent.GameVersion)
|
||||
{
|
||||
var msgBox = new GUIMessageBox(string.Empty,
|
||||
TextManager.GetWithVariables("versionmismatchwarning",
|
||||
("[gameversion]", serverExe.ContentPackage.GameVersion.ToString()),
|
||||
("[contentversion]", GameMain.VanillaContent.GameVersion.ToString())) + "\n\n"+
|
||||
TextManager.GetWithVariable("versionmismatch.verifylaunch", "[exename]", serverExe.ContentPackage.Name),
|
||||
new LocalizedString[] { TextManager.Get("yes"), TextManager.Get("no") });
|
||||
msgBox.Buttons[0].OnClicked += (_, __) =>
|
||||
{
|
||||
TryStartServer();
|
||||
msgBox.Close();
|
||||
return true;
|
||||
};
|
||||
msgBox.Buttons[1].OnClicked += msgBox.Close;
|
||||
return;
|
||||
}
|
||||
TryStartServer();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetServerPlayStyle(PlayStyle playStyle)
|
||||
|
||||
@@ -2389,10 +2389,20 @@ namespace Barotrauma
|
||||
options.Add(kickOption);
|
||||
}
|
||||
|
||||
options.Add(new ContextMenuOption("Ban", isEnabled: canBan, onSelected: delegate
|
||||
if (GameMain.Client?.ServerSettings?.BanList?.BannedPlayers?.Any(bp => bp.MatchesClient(client)) ?? false)
|
||||
{
|
||||
GameMain.Client?.CreateKickReasonPrompt(client.Name, true);
|
||||
}));
|
||||
options.Add(new ContextMenuOption("clientpermission.unban", isEnabled: canBan, onSelected: delegate
|
||||
{
|
||||
GameMain.Client?.UnbanPlayer(client.Name);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
options.Add(new ContextMenuOption("Ban", isEnabled: canBan, onSelected: delegate
|
||||
{
|
||||
GameMain.Client?.CreateKickReasonPrompt(client.Name, true);
|
||||
}));
|
||||
}
|
||||
|
||||
GUIContextMenu.CreateContextMenu(null, client.Name, headerColor: clientColor, options.ToArray());
|
||||
}
|
||||
@@ -2591,11 +2601,11 @@ namespace Barotrauma
|
||||
foreach (DebugConsole.Command command in DebugConsole.Commands)
|
||||
{
|
||||
var commandTickBox = new GUITickBox(new RectTransform(new Vector2(0.15f, 0.15f), commandList.Content.RectTransform),
|
||||
command.names[0], font: GUIStyle.SmallFont)
|
||||
command.Names[0].Value, font: GUIStyle.SmallFont)
|
||||
{
|
||||
Selected = selectedClient.PermittedConsoleCommands.Contains(command),
|
||||
Enabled = !myClient,
|
||||
ToolTip = command.help,
|
||||
ToolTip = command.Help,
|
||||
UserData = command
|
||||
};
|
||||
commandTickBox.OnSelected += (GUITickBox tickBox) =>
|
||||
@@ -2630,12 +2640,25 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.Client.HasPermission(ClientPermissions.Ban))
|
||||
{
|
||||
var banButton = new GUIButton(new RectTransform(new Vector2(0.34f, 1.0f), buttonAreaTop.RectTransform),
|
||||
TextManager.Get("Ban"))
|
||||
GUIButton banButton;
|
||||
if (GameMain.Client?.ServerSettings?.BanList?.BannedPlayers?.Any(bp => bp.MatchesClient(selectedClient)) ?? false)
|
||||
{
|
||||
UserData = selectedClient
|
||||
};
|
||||
banButton.OnClicked = (bt, userdata) => { BanPlayer(selectedClient); return true; };
|
||||
banButton = new GUIButton(new RectTransform(new Vector2(0.34f, 1.0f), buttonAreaTop.RectTransform),
|
||||
TextManager.Get("clientpermission.unban"))
|
||||
{
|
||||
UserData = selectedClient
|
||||
};
|
||||
banButton.OnClicked = (bt, userdata) => { GameMain.Client?.UnbanPlayer(selectedClient.Name); return true; };
|
||||
}
|
||||
else
|
||||
{
|
||||
banButton = new GUIButton(new RectTransform(new Vector2(0.34f, 1.0f), buttonAreaTop.RectTransform),
|
||||
TextManager.Get("Ban"))
|
||||
{
|
||||
UserData = selectedClient
|
||||
};
|
||||
banButton.OnClicked = (bt, userdata) => { BanPlayer(selectedClient); return true; };
|
||||
}
|
||||
banButton.OnClicked += ClosePlayerFrame;
|
||||
}
|
||||
|
||||
@@ -3147,12 +3170,12 @@ namespace Barotrauma
|
||||
GUIButton jobButton = null;
|
||||
|
||||
var availableJobs = JobPrefab.Prefabs.Where(jobPrefab =>
|
||||
jobPrefab.MaxNumber > 0 && JobList.Content.Children.All(c => !(c.UserData is JobVariant prefab) || prefab.Prefab != jobPrefab)
|
||||
!jobPrefab.HiddenJob && jobPrefab.MaxNumber > 0 && JobList.Content.Children.All(c => c.UserData is not JobVariant prefab || prefab.Prefab != jobPrefab)
|
||||
).Select(j => new JobVariant(j, 0));
|
||||
|
||||
availableJobs = availableJobs.Concat(
|
||||
JobPrefab.Prefabs.Where(jobPrefab =>
|
||||
jobPrefab.MaxNumber > 0 && JobList.Content.Children.Any(c => (c.UserData is JobVariant prefab) && prefab.Prefab == jobPrefab)
|
||||
!jobPrefab.HiddenJob && jobPrefab.MaxNumber > 0 && JobList.Content.Children.Any(c => (c.UserData is JobVariant prefab) && prefab.Prefab == jobPrefab)
|
||||
).Select(j => (JobVariant)JobList.Content.FindChild(c => (c.UserData is JobVariant prefab) && prefab.Prefab == j).UserData));
|
||||
|
||||
availableJobs = availableJobs.ToList();
|
||||
|
||||
+1
-1
@@ -655,7 +655,7 @@ namespace Barotrauma
|
||||
ScrollBarVisible = true,
|
||||
OnSelected = (btn, obj) =>
|
||||
{
|
||||
if (!(obj is ServerInfo serverInfo)) { return false; }
|
||||
if (obj is not ServerInfo serverInfo) { return false; }
|
||||
|
||||
joinButton.Enabled = true;
|
||||
selectedServer = Option<ServerInfo>.Some(serverInfo);
|
||||
|
||||
@@ -1289,7 +1289,8 @@ namespace Barotrauma
|
||||
if (legacy) { textBlock.TextColor *= 0.6f; }
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
DebugConsole.AddWarning($"Entity \"{ep.Identifier.Value}\" has no name!");
|
||||
DebugConsole.AddWarning($"Entity \"{ep.Identifier.Value}\" has no name!",
|
||||
contentPackage: ep.ContentPackage);
|
||||
textBlock.Text = frame.ToolTip = ep.Identifier.Value;
|
||||
textBlock.TextColor = GUIStyle.Red;
|
||||
}
|
||||
@@ -2365,49 +2366,58 @@ namespace Barotrauma
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
var beaconSettingsContainer = new GUILayoutGroup(new RectTransform(Vector2.One, subTypeDependentSettingFrame.RectTransform))
|
||||
var extraSettingsContainer = new GUILayoutGroup(new RectTransform(new Vector2(1, 0.5f), subTypeDependentSettingFrame.RectTransform))
|
||||
{
|
||||
CanBeFocused = true,
|
||||
Visible = false,
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
// -------------------
|
||||
|
||||
var beaconMinDifficultyGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), beaconSettingsContainer.RectTransform), isHorizontal: true)
|
||||
var minDifficultyGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), extraSettingsContainer.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), beaconMinDifficultyGroup.RectTransform),
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), minDifficultyGroup.RectTransform),
|
||||
TextManager.Get("minleveldifficulty"), textAlignment: Alignment.CenterLeft, wrap: true);
|
||||
var numInput = new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), beaconMinDifficultyGroup.RectTransform), NumberType.Int)
|
||||
var numInput = new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), minDifficultyGroup.RectTransform), NumberType.Int)
|
||||
{
|
||||
IntValue = (int)(MainSub?.Info?.BeaconStationInfo?.MinLevelDifficulty ?? 0),
|
||||
IntValue = (int)(MainSub?.Info?.GetExtraSubmarineInfo?.MinLevelDifficulty ?? 0),
|
||||
MinValueInt = 0,
|
||||
MaxValueInt = 100,
|
||||
OnValueChanged = (numberInput) =>
|
||||
{
|
||||
MainSub.Info.BeaconStationInfo.MinLevelDifficulty = numberInput.IntValue;
|
||||
MainSub.Info.GetExtraSubmarineInfo.MinLevelDifficulty = numberInput.IntValue;
|
||||
}
|
||||
};
|
||||
beaconMinDifficultyGroup.RectTransform.MaxSize = numInput.TextBox.RectTransform.MaxSize;
|
||||
var beaconMaxDifficultyGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), beaconSettingsContainer.RectTransform), isHorizontal: true)
|
||||
minDifficultyGroup.RectTransform.MaxSize = numInput.TextBox.RectTransform.MaxSize;
|
||||
var maxDifficultyGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), extraSettingsContainer.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), beaconMaxDifficultyGroup.RectTransform),
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), maxDifficultyGroup.RectTransform),
|
||||
TextManager.Get("maxleveldifficulty"), textAlignment: Alignment.CenterLeft, wrap: true);
|
||||
numInput = new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), beaconMaxDifficultyGroup.RectTransform), NumberType.Int)
|
||||
numInput = new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), maxDifficultyGroup.RectTransform), NumberType.Int)
|
||||
{
|
||||
IntValue = (int)(MainSub?.Info?.BeaconStationInfo?.MaxLevelDifficulty ?? 100),
|
||||
IntValue = (int)(MainSub?.Info?.GetExtraSubmarineInfo?.MaxLevelDifficulty ?? 100),
|
||||
MinValueInt = 0,
|
||||
MaxValueInt = 100,
|
||||
OnValueChanged = (numberInput) =>
|
||||
{
|
||||
MainSub.Info.BeaconStationInfo.MaxLevelDifficulty = numberInput.IntValue;
|
||||
MainSub.Info.GetExtraSubmarineInfo.MaxLevelDifficulty = numberInput.IntValue;
|
||||
}
|
||||
};
|
||||
beaconMaxDifficultyGroup.RectTransform.MaxSize = numInput.TextBox.RectTransform.MaxSize;
|
||||
maxDifficultyGroup.RectTransform.MaxSize = numInput.TextBox.RectTransform.MaxSize;
|
||||
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
var beaconSettingsContainer = new GUILayoutGroup(new RectTransform(Vector2.One, extraSettingsContainer.RectTransform))
|
||||
{
|
||||
CanBeFocused = true,
|
||||
Visible = false,
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
new GUITickBox(new RectTransform(new Vector2(1.0f, 0.25f), beaconSettingsContainer.RectTransform), TextManager.Get("allowdamagedwalls"))
|
||||
{
|
||||
Selected = MainSub?.Info?.BeaconStationInfo?.AllowDamagedWalls ?? true,
|
||||
@@ -2669,8 +2679,13 @@ namespace Barotrauma
|
||||
{
|
||||
MainSub.Info.BeaconStationInfo ??= new BeaconStationInfo(MainSub.Info);
|
||||
}
|
||||
else if (type == SubmarineType.Wreck)
|
||||
{
|
||||
MainSub.Info.WreckInfo ??= new WreckInfo(MainSub.Info);
|
||||
}
|
||||
previewImageButtonHolder.Children.ForEach(c => c.Enabled = MainSub.Info.AllowPreviewImage);
|
||||
outpostSettingsContainer.Visible = type == SubmarineType.OutpostModule;
|
||||
extraSettingsContainer.Visible = type == SubmarineType.BeaconStation || type == SubmarineType.Wreck;
|
||||
beaconSettingsContainer.Visible = type == SubmarineType.BeaconStation;
|
||||
subSettingsContainer.Visible = type == SubmarineType.Player;
|
||||
return true;
|
||||
@@ -4439,6 +4454,7 @@ namespace Barotrauma
|
||||
MapEntity.SelectEntity(itemContainer);
|
||||
dummyCharacter.SelectedItem = itemContainer;
|
||||
FilterEntities(entityFilterBox.Text);
|
||||
MapEntity.StopSelection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -5556,11 +5572,32 @@ namespace Barotrauma
|
||||
dummyCharacter.Submarine = MainSub;
|
||||
}
|
||||
|
||||
// Deposit item from our "infinite stack" into inventory slots
|
||||
var inv = dummyCharacter?.SelectedItem?.OwnInventory;
|
||||
if (inv?.visualSlots != null && !PlayerInput.IsCtrlDown())
|
||||
if (dummyCharacter?.SelectedItem != null)
|
||||
{
|
||||
var dragginMouse = MouseDragStart != Vector2.Zero && Vector2.Distance(PlayerInput.MousePosition, MouseDragStart) >= GUI.Scale * 20;
|
||||
// Deposit item from our "infinite stack" into inventory slots
|
||||
TryDragItemsToItem(dummyCharacter.SelectedItem);
|
||||
foreach (Item linkedItem in dummyCharacter.SelectedItem.linkedTo.OfType<Item>())
|
||||
{
|
||||
if (linkedItem.OwnInventory?.visualSlots != null)
|
||||
{
|
||||
TryDragItemsToItem(linkedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TryDragItemsToItem(Item item)
|
||||
{
|
||||
foreach (ItemContainer ic in item.GetComponents<ItemContainer>())
|
||||
{
|
||||
TryDragItemsToInventory(ic.Inventory);
|
||||
}
|
||||
}
|
||||
|
||||
void TryDragItemsToInventory(Inventory inv)
|
||||
{
|
||||
if (PlayerInput.IsCtrlDown()) { return; }
|
||||
|
||||
var draggingMouse = MouseDragStart != Vector2.Zero && Vector2.Distance(PlayerInput.MousePosition, MouseDragStart) >= GUI.Scale * 20;
|
||||
|
||||
// So we don't accidentally drag inventory items while doing this
|
||||
if (DraggedItemPrefab != null) { Inventory.DraggingItems.Clear(); }
|
||||
@@ -5568,134 +5605,134 @@ namespace Barotrauma
|
||||
switch (DraggedItemPrefab)
|
||||
{
|
||||
// regular item prefabs
|
||||
case ItemPrefab itemPrefab when PlayerInput.PrimaryMouseButtonClicked() || dragginMouse:
|
||||
{
|
||||
bool spawnedItem = false;
|
||||
for (var i = 0; i < inv.Capacity; i++)
|
||||
case ItemPrefab itemPrefab when PlayerInput.PrimaryMouseButtonClicked() || draggingMouse:
|
||||
{
|
||||
var slot = inv.visualSlots[i];
|
||||
var itemContainer = inv.GetItemAt(i)?.GetComponent<ItemContainer>();
|
||||
|
||||
// check if the slot is empty or if we can place the item into a container, for example an oxygen tank into a diving suit
|
||||
if (Inventory.IsMouseOnSlot(slot))
|
||||
bool spawnedItem = false;
|
||||
for (var i = 0; i < inv.Capacity; i++)
|
||||
{
|
||||
var newItem = new Item(itemPrefab, Vector2.Zero, MainSub);
|
||||
var slot = inv.visualSlots[i];
|
||||
var itemContainer = inv.GetItemAt(i)?.GetComponent<ItemContainer>();
|
||||
|
||||
if (inv.CanBePutInSlot(itemPrefab, i, condition: null))
|
||||
// check if the slot is empty or if we can place the item into a container, for example an oxygen tank into a diving suit
|
||||
if (Inventory.IsMouseOnSlot(slot))
|
||||
{
|
||||
bool placedItem = inv.TryPutItem(newItem, i, false, true, dummyCharacter);
|
||||
spawnedItem |= placedItem;
|
||||
var newItem = new Item(itemPrefab, Vector2.Zero, MainSub);
|
||||
|
||||
if (!placedItem)
|
||||
if (inv.CanBePutInSlot(itemPrefab, i, condition: null))
|
||||
{
|
||||
newItem.Remove();
|
||||
bool placedItem = inv.TryPutItem(newItem, i, false, true, dummyCharacter);
|
||||
spawnedItem |= placedItem;
|
||||
|
||||
if (!placedItem)
|
||||
{
|
||||
newItem.Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (itemContainer != null && itemContainer.Inventory.CanBePut(itemPrefab))
|
||||
{
|
||||
bool placedItem = itemContainer.Inventory.TryPutItem(newItem, dummyCharacter);
|
||||
spawnedItem |= placedItem;
|
||||
|
||||
// try to place the item into the inventory of the item we are hovering over
|
||||
if (!placedItem)
|
||||
else if (itemContainer != null && itemContainer.Inventory.CanBePut(itemPrefab))
|
||||
{
|
||||
newItem.Remove();
|
||||
bool placedItem = itemContainer.Inventory.TryPutItem(newItem, dummyCharacter);
|
||||
spawnedItem |= placedItem;
|
||||
|
||||
// try to place the item into the inventory of the item we are hovering over
|
||||
if (!placedItem)
|
||||
{
|
||||
newItem.Remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.ShowBorderHighlight(GUIStyle.Green, 0.1f, 0.4f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.ShowBorderHighlight(GUIStyle.Green, 0.1f, 0.4f);
|
||||
newItem.Remove();
|
||||
slot.ShowBorderHighlight(GUIStyle.Red, 0.1f, 0.4f);
|
||||
}
|
||||
|
||||
if (!newItem.Removed)
|
||||
{
|
||||
BulkItemBufferInUse = ItemAddMutex;
|
||||
BulkItemBuffer.Add(new AddOrDeleteCommand(new List<MapEntity> { newItem }, false));
|
||||
}
|
||||
|
||||
if (!draggingMouse)
|
||||
{
|
||||
SoundPlayer.PlayUISound(spawnedItem ? GUISoundType.PickItem : GUISoundType.PickItemFail);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newItem.Remove();
|
||||
slot.ShowBorderHighlight(GUIStyle.Red, 0.1f, 0.4f);
|
||||
}
|
||||
|
||||
if (!newItem.Removed)
|
||||
{
|
||||
BulkItemBufferInUse = ItemAddMutex;
|
||||
BulkItemBuffer.Add(new AddOrDeleteCommand(new List<MapEntity> { newItem }, false));
|
||||
}
|
||||
|
||||
if (!dragginMouse)
|
||||
{
|
||||
SoundPlayer.PlayUISound(spawnedItem ? GUISoundType.PickItem : GUISoundType.PickItemFail);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// item assemblies
|
||||
case ItemAssemblyPrefab assemblyPrefab when PlayerInput.PrimaryMouseButtonClicked():
|
||||
{
|
||||
bool spawnedItems = false;
|
||||
for (var i = 0; i < inv.visualSlots.Length; i++)
|
||||
{
|
||||
var slot = inv.visualSlots[i];
|
||||
var item = inv?.GetItemAt(i);
|
||||
var itemContainer = item?.GetComponent<ItemContainer>();
|
||||
if (item == null && Inventory.IsMouseOnSlot(slot))
|
||||
bool spawnedItems = false;
|
||||
for (var i = 0; i < inv.visualSlots.Length; i++)
|
||||
{
|
||||
// load the items
|
||||
var itemInstance = LoadItemAssemblyInventorySafe(assemblyPrefab);
|
||||
|
||||
// counter for items that failed so we so we known that slot remained empty
|
||||
var failedCount = 0;
|
||||
|
||||
for (var j = 0; j < itemInstance.Count(); j++)
|
||||
var slot = inv.visualSlots[i];
|
||||
var item = inv?.GetItemAt(i);
|
||||
var itemContainer = item?.GetComponent<ItemContainer>();
|
||||
if (item == null && Inventory.IsMouseOnSlot(slot))
|
||||
{
|
||||
var newItem = itemInstance[j];
|
||||
var newSpot = i + j - failedCount;
|
||||
// load the items
|
||||
var itemInstance = LoadItemAssemblyInventorySafe(assemblyPrefab);
|
||||
|
||||
// try to find a valid slot to put the items
|
||||
while (inv.visualSlots.Length > newSpot)
|
||||
// counter for items that failed so we so we known that slot remained empty
|
||||
var failedCount = 0;
|
||||
|
||||
for (var j = 0; j < itemInstance.Count; j++)
|
||||
{
|
||||
if (inv.GetItemAt(newSpot) == null) { break; }
|
||||
newSpot++;
|
||||
}
|
||||
var newItem = itemInstance[j];
|
||||
var newSpot = i + j - failedCount;
|
||||
|
||||
// valid slot found
|
||||
if (inv.visualSlots.Length > newSpot)
|
||||
{
|
||||
var placedItem = inv.TryPutItem(newItem, newSpot, false, true, dummyCharacter);
|
||||
spawnedItems |= placedItem;
|
||||
|
||||
if (!placedItem)
|
||||
// try to find a valid slot to put the items
|
||||
while (inv.visualSlots.Length > newSpot)
|
||||
{
|
||||
failedCount++;
|
||||
// delete the included items too so we don't get a popup asking if we want to keep them
|
||||
newItem?.OwnInventory?.DeleteAllItems();
|
||||
newItem.Remove();
|
||||
if (inv.GetItemAt(newSpot) == null) { break; }
|
||||
newSpot++;
|
||||
}
|
||||
|
||||
// valid slot found
|
||||
if (inv.visualSlots.Length > newSpot)
|
||||
{
|
||||
var placedItem = inv.TryPutItem(newItem, newSpot, false, true, dummyCharacter);
|
||||
spawnedItems |= placedItem;
|
||||
|
||||
if (!placedItem)
|
||||
{
|
||||
failedCount++;
|
||||
// delete the included items too so we don't get a popup asking if we want to keep them
|
||||
newItem?.OwnInventory?.DeleteAllItems();
|
||||
newItem.Remove();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var placedItem = inv.TryPutItem(newItem, dummyCharacter);
|
||||
spawnedItems |= placedItem;
|
||||
|
||||
// if our while loop didn't find a valid slot then let the inventory decide where to put it as a last resort
|
||||
if (!placedItem)
|
||||
{
|
||||
// delete the included items too so we don't get a popup asking if we want to keep them
|
||||
newItem?.OwnInventory?.DeleteAllItems();
|
||||
newItem.Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
List<MapEntity> placedEntities = itemInstance.Where(it => !it.Removed).Cast<MapEntity>().ToList();
|
||||
if (placedEntities.Any())
|
||||
{
|
||||
var placedItem = inv.TryPutItem(newItem, dummyCharacter);
|
||||
spawnedItems |= placedItem;
|
||||
|
||||
// if our while loop didn't find a valid slot then let the inventory decide where to put it as a last resort
|
||||
if (!placedItem)
|
||||
{
|
||||
// delete the included items too so we don't get a popup asking if we want to keep them
|
||||
newItem?.OwnInventory?.DeleteAllItems();
|
||||
newItem.Remove();
|
||||
}
|
||||
BulkItemBufferInUse = ItemAddMutex;
|
||||
BulkItemBuffer.Add(new AddOrDeleteCommand(placedEntities, false));
|
||||
}
|
||||
}
|
||||
|
||||
List<MapEntity> placedEntities = itemInstance.Where(it => !it.Removed).Cast<MapEntity>().ToList();
|
||||
if (placedEntities.Any())
|
||||
{
|
||||
BulkItemBufferInUse = ItemAddMutex;
|
||||
BulkItemBuffer.Add(new AddOrDeleteCommand(placedEntities, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SoundPlayer.PlayUISound(spawnedItems ? GUISoundType.PickItem : GUISoundType.PickItemFail);
|
||||
break;
|
||||
}
|
||||
SoundPlayer.PlayUISound(spawnedItems ? GUISoundType.PickItem : GUISoundType.PickItemFail);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user