Unstable v0.10.600.0

This commit is contained in:
Juan Pablo Arce
2020-10-01 12:19:24 -03:00
parent 20a69375ca
commit ebe1ce1427
217 changed files with 4284 additions and 1547 deletions
@@ -51,6 +51,7 @@ namespace Barotrauma
limbSlotIcons.Add(InvSlotType.LeftHand, new Sprite("Content/UI/InventoryUIAtlas.png", new Rectangle(634, 0, 128, 128)));
limbSlotIcons.Add(InvSlotType.RightHand, new Sprite("Content/UI/InventoryUIAtlas.png", new Rectangle(762, 0, 128, 128)));
limbSlotIcons.Add(InvSlotType.OuterClothes, new Sprite("Content/UI/MainIconsAtlas.png", new Rectangle(256 + margin, 128 + margin, 128 - margin * 2, 128 - margin * 2)));
limbSlotIcons.Add(InvSlotType.Bag, new Sprite("Content/UI/MainIconsAtlas.png", new Rectangle(256 + margin, 128 + margin, 128 - margin * 2, 128 - margin * 2)));
}
return limbSlotIcons;
}
@@ -922,12 +923,14 @@ namespace Barotrauma
if (slotItem == item)
{
slot.ShowBorderHighlight(GUI.Style.Red, 0.1f, 0.4f);
GUI.PlayUISound(GUISoundType.PickItem);
SoundPlayer.PlayUISound(GUISoundType.PickItem);
break;
}
}
}
SubEditorScreen.StoreCommand(new AddOrDeleteCommand(new List<MapEntity> { item }, true));
item.Remove();
return;
}
@@ -1065,7 +1068,7 @@ namespace Barotrauma
}
draggingItem = null;
GUI.PlayUISound(success ? GUISoundType.PickItem : GUISoundType.PickItemFail);
SoundPlayer.PlayUISound(success ? GUISoundType.PickItem : GUISoundType.PickItemFail);
}
public void DrawOwn(SpriteBatch spriteBatch)
@@ -261,7 +261,23 @@ namespace Barotrauma.Items.Components
if (!isNetworkMessage || open != PredictedState)
{
StopPicking(null);
PlaySound(forcedOpen ? ActionType.OnPicked : ActionType.OnUse);
ActionType actionType = ActionType.OnUse;
if (forcedOpen)
{
actionType = ActionType.OnPicked;
}
else
{
if (open && HasSoundsOfType[(int)ActionType.OnOpen])
{
actionType = ActionType.OnOpen;
}
else if (!open && HasSoundsOfType[(int)ActionType.OnClose])
{
actionType = ActionType.OnClose;
}
}
PlaySound(actionType);
if (isOpen) { stuck = MathHelper.Clamp(stuck - StuckReductionOnOpen, 0.0f, 100.0f); }
}
}
@@ -263,7 +263,7 @@ namespace Barotrauma.Items.Components
{
for (int i = 0; i < targetSections.Count; i++)
{
targetHull.SetSectionColorOrStrength(targetSections[i], color, sizeAdjustedSprayStrength * deltaTime, true, false);
targetHull.IncreaseSectionColorOrStrength(targetSections[i], color, sizeAdjustedSprayStrength * deltaTime, true, false);
}
}
else
@@ -52,6 +52,8 @@ namespace Barotrauma.Items.Components
get { return sounds.Count > 0; }
}
public bool[] HasSoundsOfType { get { return hasSoundsOfType; } }
private readonly bool[] hasSoundsOfType;
private readonly Dictionary<ActionType, List<ItemSound>> sounds;
private Dictionary<ActionType, SoundSelectionMode> soundSelectionModes;
@@ -191,6 +193,12 @@ namespace Barotrauma.Items.Components
private ItemSound loopingSound;
private SoundChannel loopingSoundChannel;
private List<SoundChannel> playingOneshotSoundChannels = new List<SoundChannel>();
public ItemComponent ReplacedBy;
public ItemComponent GetReplacementOrThis()
{
return ReplacedBy?.GetReplacementOrThis() ?? this;
}
public void UpdateSounds()
{
@@ -26,29 +26,17 @@ namespace Barotrauma.Items.Components
if (isHUDsHidden == value) { return; }
if (value == true)
{
ToggleCrewArea(false, storeOriginalState: true);
GameMain.GameSession?.CrewManager?.AutoHideCrewList();
ToggleChatBox(false, storeOriginalState: true);
}
else
{
ToggleCrewArea(crewAreaOriginalState, storeOriginalState: false);
GameMain.GameSession?.CrewManager?.ResetCrewList();
ToggleChatBox(chatBoxOriginalState, storeOriginalState: false);
}
isHUDsHidden = value;
}
private void ToggleCrewArea(bool value, bool storeOriginalState)
{
var crewManager = GameMain.GameSession?.CrewManager;
if (crewManager == null) { return; }
if (storeOriginalState)
{
crewAreaOriginalState = crewManager.ToggleCrewListOpen;
}
crewManager.ToggleCrewListOpen = value;
}
private void ToggleChatBox(bool value, bool storeOriginalState)
{
var crewManager = GameMain.GameSession?.CrewManager;
@@ -17,7 +17,16 @@ namespace Barotrauma.Items.Components
private GUITickBox autoControlIndicator;
private List<Pair<Vector2, ParticleEmitter>> pumpOutEmitters = new List<Pair<Vector2, ParticleEmitter>>();
private List<Pair<Vector2, ParticleEmitter>> pumpInEmitters = new List<Pair<Vector2, ParticleEmitter>>();
private List<Pair<Vector2, ParticleEmitter>> pumpInEmitters = new List<Pair<Vector2, ParticleEmitter>>();
public float CurrentBrokenVolume
{
get
{
if (item.ConditionPercentage > 10.0f || !IsActive) { return 0.0f; }
return (1.0f - item.ConditionPercentage / 10.0f) * 100.0f;
}
}
partial void InitProjSpecific(XElement element)
{
@@ -284,6 +284,7 @@ namespace Barotrauma.Items.Components
{
Enabled = false,
Selected = AutoTemp,
ClickSound = GUISoundType.UISwitch,
OnClicked = (button, data) =>
{
AutoTemp = !AutoTemp;
@@ -181,6 +181,7 @@ namespace Barotrauma.Items.Components
{
Selected = false,
Enabled = true,
ClickSound = GUISoundType.UISwitch,
OnClicked = (button, data) =>
{
button.Selected = !button.Selected;
@@ -123,6 +123,7 @@ namespace Barotrauma.Items.Components
{
Selected = autoPilot,
Enabled = true,
ClickSound = GUISoundType.UISwitch,
OnClicked = (button, data) =>
{
button.Selected = !button.Selected;
@@ -535,6 +535,9 @@ namespace Barotrauma.Items.Components
nodes = nodePositions.ToList();
UpdateSections();
Drawable = nodes.Any();
IsActive =
(connections[0] == null ^ connections[1] == null) &&
(item.ParentInventory is CharacterInventory characterInventory && ((characterInventory.Owner as Character)?.HasEquippedItem(item) ?? false));
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
@@ -35,6 +35,7 @@ namespace Barotrauma.Items.Components
private RoundSound startMoveSound, endMoveSound, moveSound;
private SoundChannel moveSoundChannel;
private Vector2 oldRotation = Vector2.Zero;
private Vector2 crosshairPos, crosshairPointerPos;
@@ -307,7 +308,11 @@ namespace Barotrauma.Items.Components
if (!item.IsSelected) { return; }
Widget minRotationWidget = GetWidget("minrotation", spriteBatch, size: 10, initMethod: (widget) =>
{
{
widget.Selected += () =>
{
oldRotation = RotationLimits;
};
widget.MouseDown += () =>
{
widget.color = GUI.Style.Green;
@@ -317,6 +322,10 @@ namespace Barotrauma.Items.Components
{
widget.color = Color.Yellow;
item.CreateEditingHUD();
if (SubEditorScreen.IsSubEditor())
{
SubEditorScreen.StoreCommand(new PropertyCommand(this, "RotationLimits", RotationLimits, oldRotation));
}
};
widget.MouseHeld += (deltaTime) =>
{
@@ -345,10 +354,14 @@ namespace Barotrauma.Items.Components
widget.DrawPos = GetDrawPos() + new Vector2((float)Math.Cos(minRotation), (float)Math.Sin(minRotation)) * widgetRadius;
widget.Update(deltaTime);
};
});
});
Widget maxRotationWidget = GetWidget("maxrotation", spriteBatch, size: 10, initMethod: (widget) =>
{
widget.Selected += () =>
{
oldRotation = RotationLimits;
};
widget.MouseDown += () =>
{
widget.color = GUI.Style.Green;
@@ -358,6 +371,10 @@ namespace Barotrauma.Items.Components
{
widget.color = Color.Yellow;
item.CreateEditingHUD();
if (SubEditorScreen.IsSubEditor())
{
SubEditorScreen.StoreCommand(new PropertyCommand(this, "RotationLimits", RotationLimits, oldRotation));
}
};
widget.MouseHeld += (deltaTime) =>
{
@@ -3,7 +3,6 @@ using Barotrauma.Items.Components;
using Barotrauma.Networking;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -163,6 +162,8 @@ namespace Barotrauma
public static Inventory DraggingInventory;
public Inventory ReplacedBy;
public Rectangle BackgroundFrame { get; protected set; }
private ushort[] receivedItemIDs;
@@ -317,6 +318,11 @@ namespace Barotrauma
}
}
public Inventory GetReplacementOrThiS()
{
return ReplacedBy?.GetReplacementOrThiS() ?? this;
}
public virtual void CreateSlots()
{
slots = new InventorySlot[capacity];
@@ -465,12 +471,15 @@ namespace Barotrauma
{
if (item != null)
{
if (mouseDrag) { item.OwnInventory?.DeleteAllItems(); }
slot.ShowBorderHighlight(GUI.Style.Red, 0.1f, 0.4f);
if (!mouseDrag)
{
GUI.PlayUISound(GUISoundType.PickItem);
SoundPlayer.PlayUISound(GUISoundType.PickItem);
}
SubEditorScreen.BulkItemBufferInUse = true;
SubEditorScreen.BulkItemBuffer.Add(new AddOrDeleteCommand(new List<MapEntity> { item }, true));
item.OwnInventory?.DeleteAllItems();
item.Remove();
}
}
@@ -996,10 +1005,19 @@ namespace Barotrauma
Character.Controlled.FocusedItem.OwnInventory.CanBePut(draggingItem) &&
Character.Controlled.FocusedItem.OwnInventory.TryPutItem(draggingItem, Character.Controlled))
{
GUI.PlayUISound(GUISoundType.PickItem);
SoundPlayer.PlayUISound(GUISoundType.PickItem);
}
else
{
if (Screen.Selected is SubEditorScreen)
{
if (draggingItem?.ParentInventory != null)
{
SubEditorScreen.StoreCommand(new InventoryPlaceCommand(draggingItem.ParentInventory, new List<Item> { draggingItem }, true));
}
}
SoundPlayer.PlayUISound(GUISoundType.DropItem);
bool removed = false;
if (Screen.Selected is SubEditorScreen editor)
{
@@ -1025,14 +1043,16 @@ namespace Barotrauma
{
draggingItem.Drop(Character.Controlled);
}
GUI.PlayUISound(removed ? GUISoundType.PickItem : GUISoundType.DropItem);
SoundPlayer.PlayUISound(removed ? GUISoundType.PickItem : GUISoundType.DropItem);
}
}
else if (selectedSlot.ParentInventory.Items[selectedSlot.SlotIndex] != draggingItem)
{
Inventory oldInventory = draggingItem.ParentInventory;
Inventory selectedInventory = selectedSlot.ParentInventory;
int slotIndex = selectedSlot.SlotIndex;
int oldSlot = oldInventory == null ? 0 : Array.IndexOf(oldInventory.Items, draggingItem);
//if attempting to drop into an invalid slot in the same inventory, try to move to the correct slot
if (selectedInventory.Items[slotIndex] == null &&
@@ -1051,17 +1071,21 @@ namespace Barotrauma
}
selectedInventory.slots[slotIndex].ShowBorderHighlight(GUI.Style.Red, 0.1f, 0.9f);
}
GUI.PlayUISound(GUISoundType.PickItem);
SoundPlayer.PlayUISound(GUISoundType.PickItem);
}
else if (selectedInventory.TryPutItem(draggingItem, slotIndex, true, true, Character.Controlled))
{
if (SubEditorScreen.IsSubEditor())
{
SubEditorScreen.StoreCommand(new InventoryMoveCommand(oldInventory, selectedInventory, draggingItem, oldSlot, slotIndex));
}
if (selectedInventory.slots != null) { selectedInventory.slots[slotIndex].ShowBorderHighlight(Color.White, 0.1f, 0.4f); }
GUI.PlayUISound(GUISoundType.PickItem);
SoundPlayer.PlayUISound(GUISoundType.PickItem);
}
else
{
if (selectedInventory.slots != null){ selectedInventory.slots[slotIndex].ShowBorderHighlight(GUI.Style.Red, 0.1f, 0.9f); }
GUI.PlayUISound(GUISoundType.PickItemFail);
SoundPlayer.PlayUISound(GUISoundType.PickItemFail);
}
selectedInventory.HideTimer = 2.0f;
if (selectedSlot.ParentInventory?.Owner is Item parentItem && parentItem.ParentInventory != null)
@@ -542,7 +542,7 @@ namespace Barotrauma
Spacing = (int)(25 * GUI.Scale)
};
var itemEditor = new SerializableEntityEditor(listBox.Content.RectTransform, this, inGame, showName: true, titleFont: GUI.LargeFont);
var itemEditor = new SerializableEntityEditor(listBox.Content.RectTransform, this, inGame, showName: true, titleFont: GUI.LargeFont) { UserData = this };
itemEditor.Children.First().Color = Color.Black * 0.7f;
if (!inGame)
{
@@ -663,7 +663,7 @@ namespace Barotrauma
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), listBox.Content.RectTransform), style: "HorizontalLine");
var componentEditor = new SerializableEntityEditor(listBox.Content.RectTransform, ic, inGame, showName: !inGame, titleFont: GUI.SubHeadingFont);
var componentEditor = new SerializableEntityEditor(listBox.Content.RectTransform, ic, inGame, showName: !inGame, titleFont: GUI.SubHeadingFont) { UserData = ic };
componentEditor.Children.First().Color = Color.Black * 0.7f;
if (inGame)
@@ -97,10 +97,12 @@ namespace Barotrauma
{
if (potentialContainer?.OwnInventory?.TryPutItem(item, Character.Controlled) ?? false)
{
GUI.PlayUISound(GUISoundType.PickItem);
SoundPlayer.PlayUISound(GUISoundType.PickItem);
}
}
SubEditorScreen.StoreCommand(new AddOrDeleteCommand(new List<MapEntity> {item}, false));
placePosition = Vector2.Zero;
return;
}