diff --git a/Barotrauma/BarotraumaClient/Source/GameSettings.cs b/Barotrauma/BarotraumaClient/Source/GameSettings.cs index 710d858e7..361a2ccc4 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSettings.cs @@ -438,6 +438,17 @@ namespace Barotrauma DebugConsole.NewMessage(name + " " + name.Length.ToString(), Color.Lime); } + GUITickBox directionalVoiceChat = new GUITickBox(new RectTransform(new Point(32, 32), audioSliders.RectTransform), TextManager.Get("DirectionalVoiceChat")); + directionalVoiceChat.Selected = UseDirectionalVoiceChat; + directionalVoiceChat.ToolTip = TextManager.Get("DirectionalVoiceChatToolTip"); + directionalVoiceChat.OnSelected = (tickBox) => + { + UseDirectionalVoiceChat = tickBox.Selected; + UnsavedSettings = true; + return true; + }; + + if (string.IsNullOrWhiteSpace(VoiceCaptureDevice)) VoiceCaptureDevice = deviceNames[0]; #if (!OSX) var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), VoiceCaptureDevice, deviceNames.Count); diff --git a/Barotrauma/BarotraumaClient/Source/Networking/Client.cs b/Barotrauma/BarotraumaClient/Source/Networking/Client.cs index 9d69ff7ce..55bc409f0 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/Client.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/Client.cs @@ -39,25 +39,33 @@ namespace Barotrauma.Networking public void UpdateSoundPosition() { - if (VoipSound != null) + if (VoipSound == null) { return; } + + if (!VoipSound.IsPlaying) { - if (!VoipSound.IsPlaying) - { - DebugConsole.Log("Destroying voipsound"); - VoipSound.Dispose(); - VoipSound = null; - return; - } + DebugConsole.Log("Destroying voipsound"); + VoipSound.Dispose(); + VoipSound = null; + return; + } - if (character != null) + if (character != null) + { + if (GameMain.Config.UseDirectionalVoiceChat) { VoipSound.SetPosition(new Vector3(character.WorldPosition.X, character.WorldPosition.Y, 0.0f)); } else { VoipSound.SetPosition(null); + float dist = Vector3.Distance(new Vector3(character.WorldPosition, 0.0f), GameMain.SoundManager.ListenerPosition); + VoipSound.Gain = 1.0f - MathUtils.InverseLerp(VoipSound.Near, VoipSound.Far, dist); } } + else + { + VoipSound.SetPosition(null); + } } partial void InitProjSpecific() diff --git a/Barotrauma/BarotraumaClient/Source/Sounds/VoipSound.cs b/Barotrauma/BarotraumaClient/Source/Sounds/VoipSound.cs index 3e86fcc2c..18126a8ba 100644 --- a/Barotrauma/BarotraumaClient/Source/Sounds/VoipSound.cs +++ b/Barotrauma/BarotraumaClient/Source/Sounds/VoipSound.cs @@ -32,6 +32,9 @@ namespace Barotrauma.Sounds public bool UseRadioFilter; public bool UseMuffleFilter; + public float Near { get; private set; } + public float Far { get; private set; } + private static BiQuad[] muffleFilters = new BiQuad[] { new LowpassFilter(VoipConfig.FREQUENCY, 800) @@ -41,6 +44,16 @@ namespace Barotrauma.Sounds new BandpassFilter(VoipConfig.FREQUENCY, 2000) }; + public float Gain + { + get { return soundChannel == null ? 0.0f : soundChannel.Gain; } + set + { + if (soundChannel == null) { return; } + soundChannel.Gain = value; + } + } + public VoipSound(SoundManager owner, VoipQueue q) : base(owner, "voip", true, true) { VoipConfig.SetupEncoding(); @@ -64,8 +77,8 @@ namespace Barotrauma.Sounds public void SetRange(float near, float far) { - soundChannel.Near = near; - soundChannel.Far = far; + soundChannel.Near = Near = near; + soundChannel.Far = Far = far; } public void ApplyFilters(short[] buffer, int readSamples) diff --git a/Barotrauma/BarotraumaShared/Source/GameSettings.cs b/Barotrauma/BarotraumaShared/Source/GameSettings.cs index 53d1d1ead..2a40edb8a 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSettings.cs @@ -44,6 +44,7 @@ namespace Barotrauma public bool ChromaticAberrationEnabled { get; set; } public bool MuteOnFocusLost { get; set; } + public bool UseDirectionalVoiceChat { get; set; } public enum VoiceMode { @@ -826,6 +827,8 @@ namespace Barotrauma SoundVolume = audioSettings.GetAttributeFloat("soundvolume", SoundVolume); MusicVolume = audioSettings.GetAttributeFloat("musicvolume", MusicVolume); VoiceChatVolume = audioSettings.GetAttributeFloat("voicechatvolume", VoiceChatVolume); + MuteOnFocusLost = audioSettings.GetAttributeBool("muteonfocuslost", false); + UseDirectionalVoiceChat = audioSettings.GetAttributeBool("usedirectionalvoicechat", true); string voiceSettingStr = audioSettings.GetAttributeString("voicesetting", "Disabled"); VoiceCaptureDevice = audioSettings.GetAttributeString("voicecapturedevice", ""); NoiseGateThreshold = audioSettings.GetAttributeFloat("noisegatethreshold", -45); @@ -1055,6 +1058,8 @@ namespace Barotrauma audio.ReplaceAttributes( new XAttribute("musicvolume", musicVolume), new XAttribute("soundvolume", soundVolume), + new XAttribute("muteonfocuslost", MuteOnFocusLost), + new XAttribute("usedirectionalvoicechat", UseDirectionalVoiceChat), new XAttribute("voicesetting", VoiceSetting), new XAttribute("voicecapturedevice", VoiceCaptureDevice ?? ""), new XAttribute("noisegatethreshold", NoiseGateThreshold)); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs index 9e95085aa..43c08904d 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs @@ -211,32 +211,24 @@ namespace Barotrauma.Items.Components #endif } - private string accessDeniedTxt = TextManager.Get("AccessDenied"); - private bool hasIdCard; + private string text = TextManager.Get("DoorMsgCannotOpen"); public override bool HasRequiredItems(Character character, bool addMessage, string msg = null) { if (item.Condition <= RepairThreshold) return true; //For repairing - var idCard = character.Inventory.FindItemByIdentifier("idcard"); - hasIdCard = requiredItems.Any(ri => ri.Value.Any(r => r.MatchesItem(idCard))); - Msg = hasIdCard ? "ItemMsgOpen" : "ItemMsgForceOpenCrowbar"; - ParseMsg(); - //this is a bit pointless atm because if canBePicked is false it won't allow you to do Pick() anyway, however it's still good for future-proofing. - return requiredItems.Any() ? base.HasRequiredItems(character, addMessage, msg ?? accessDeniedTxt) : canBePicked; + return requiredItems.Any() ? base.HasRequiredItems(character, addMessage, msg ?? text) : canBePicked; } public override bool Pick(Character picker) { - if (item.Condition <= RepairThreshold) { return true; } - if (HasRequiredItems(picker, false) && hasIdCard) { return false; } - return base.Pick(picker); + return item.Condition <= RepairThreshold ? true : base.Pick(picker); } public override bool OnPicked(Character picker) { if (item.Condition <= RepairThreshold) return true; //repairs - if (requiredItems.Any() && !hasIdCard) + if (requiredItems.Any()) { ForceOpen(ActionType.OnPicked); } @@ -255,19 +247,9 @@ namespace Barotrauma.Items.Components { //can only be selected if the item is broken if (item.Condition <= RepairThreshold) return true; //repairs - bool hasRequiredItems = HasRequiredItems(character, false); - if (requiredItems.None() || hasRequiredItems && hasIdCard) + if (requiredItems.None()) { - float originalPickingTime = PickingTime; - PickingTime = 0; ForceOpen(ActionType.OnUse); - PickingTime = originalPickingTime; - } - else if (hasRequiredItems) - { -#if CLIENT - GUI.AddMessage(accessDeniedTxt, Color.Red); -#endif } return false; } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs index 7a0027a89..00a376485 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs @@ -538,6 +538,7 @@ namespace Barotrauma.Items.Components GameAnalyticsManager.AddErrorEventOnce("ItemComponent.DegreeOfSuccess:CharacterNull", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg); return 0.0f; } + float average = skillSuccessSum / requiredSkills.Count; float skillSuccessSum = 0.0f; for (int i = 0; i < requiredSkills.Count; i++) @@ -581,52 +582,38 @@ namespace Barotrauma.Items.Components { if (!requiredItems.Any()) return true; if (character.Inventory == null) return false; - bool hasRequiredItems = false; - bool canContinue = true; + if (requiredItems.ContainsKey(RelatedItem.RelationType.Equipped)) { foreach (RelatedItem ri in requiredItems[RelatedItem.RelationType.Equipped]) { - canContinue = CheckItems(ri, character.SelectedItems); - if (!canContinue) { break; } - } - } - if (canContinue) - { - if (requiredItems.ContainsKey(RelatedItem.RelationType.Picked)) - { - foreach (RelatedItem ri in requiredItems[RelatedItem.RelationType.Picked]) + if (character.SelectedItems.FirstOrDefault(it => it != null && it.Condition > 0.0f && ri.MatchesItem(it)) == null) { - if (!CheckItems(ri, character.Inventory.Items)) { break; } - } - } - } - #if CLIENT - if (!hasRequiredItems && addMessage && !string.IsNullOrEmpty(msg)) - { - GUI.AddMessage(msg, Color.Red); - } + msg = msg ?? ri.Msg; + if (addMessage && !string.IsNullOrEmpty(msg)) + { + GUI.AddMessage(msg, Color.Red); + } #endif - return hasRequiredItems; - - bool CheckItems(RelatedItem relatedItem, IEnumerable itemList) - { - bool Predicate(Item it) => it != null && it.Condition > 0.0f && relatedItem.MatchesItem(it); - bool shouldBreak = false; - if (relatedItem.IsOptional) - { - if (!hasRequiredItems) - { - hasRequiredItems = itemList.Any(Predicate); + return false; } } - else + } + if (requiredItems.ContainsKey(RelatedItem.RelationType.Picked)) + { + foreach (RelatedItem ri in requiredItems[RelatedItem.RelationType.Picked]) { - hasRequiredItems = itemList.Any(Predicate); - if (!hasRequiredItems) + if (character.Inventory.Items.FirstOrDefault(it => it != null && it.Condition > 0.0f && ri.MatchesItem(it)) == null) { - shouldBreak = true; +#if CLIENT + msg = msg ?? ri.Msg; + if (addMessage && !string.IsNullOrEmpty(msg)) + { + GUI.AddMessage(msg, Color.Red); + } +#endif + return false; } } if (!hasRequiredItems) @@ -638,6 +625,8 @@ namespace Barotrauma.Items.Components } return !shouldBreak; } + + return true; } public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null, Limb targetLimb = null, Character user = null) @@ -782,7 +771,6 @@ namespace Barotrauma.Items.Components { newRequiredItem.statusEffects = prevRequiredItem.statusEffects; newRequiredItem.Msg = prevRequiredItem.Msg; - newRequiredItem.IsOptional = prevRequiredItem.IsOptional; } if (!requiredItems.ContainsKey(newRequiredItem.Type)) diff --git a/Barotrauma/BarotraumaShared/Source/Items/RelatedItem.cs b/Barotrauma/BarotraumaShared/Source/Items/RelatedItem.cs index bbbfc6705..c2f13f46d 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/RelatedItem.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/RelatedItem.cs @@ -16,8 +16,6 @@ namespace Barotrauma Container } - public bool IsOptional { get; set; } - private string[] identifiers; private string[] excludedIdentifiers; @@ -140,8 +138,7 @@ namespace Barotrauma { element.Add( new XAttribute("identifiers", JoinedIdentifiers), - new XAttribute("type", type.ToString()), - new XAttribute("optional", IsOptional)); + new XAttribute("type", type.ToString())); if (excludedIdentifiers.Length > 0) { diff --git a/Barotrauma/BarotraumaShared/Submarines/Dugong.sub b/Barotrauma/BarotraumaShared/Submarines/Dugong.sub index 7c0a77b8f..f8cfca265 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Dugong.sub and b/Barotrauma/BarotraumaShared/Submarines/Dugong.sub differ diff --git a/Barotrauma/BarotraumaShared/Submarines/Humpback.sub b/Barotrauma/BarotraumaShared/Submarines/Humpback.sub index 6bc4c9ba1..8490b95a4 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Humpback.sub and b/Barotrauma/BarotraumaShared/Submarines/Humpback.sub differ diff --git a/Barotrauma/BarotraumaShared/Submarines/Orca.sub b/Barotrauma/BarotraumaShared/Submarines/Orca.sub index 780a762fe..02d8316c3 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Orca.sub and b/Barotrauma/BarotraumaShared/Submarines/Orca.sub differ diff --git a/Barotrauma/BarotraumaShared/Submarines/Typhon.sub b/Barotrauma/BarotraumaShared/Submarines/Typhon.sub index dcdc67b6d..da894c6e9 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Typhon.sub and b/Barotrauma/BarotraumaShared/Submarines/Typhon.sub differ