(df9b1966f) Added an option to disable directional voice chat. Closes #1414
This commit is contained in:
@@ -438,6 +438,17 @@ namespace Barotrauma
|
|||||||
DebugConsole.NewMessage(name + " " + name.Length.ToString(), Color.Lime);
|
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 (string.IsNullOrWhiteSpace(VoiceCaptureDevice)) VoiceCaptureDevice = deviceNames[0];
|
||||||
#if (!OSX)
|
#if (!OSX)
|
||||||
var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), VoiceCaptureDevice, deviceNames.Count);
|
var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), VoiceCaptureDevice, deviceNames.Count);
|
||||||
|
|||||||
@@ -39,25 +39,33 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public void UpdateSoundPosition()
|
public void UpdateSoundPosition()
|
||||||
{
|
{
|
||||||
if (VoipSound != null)
|
if (VoipSound == null) { return; }
|
||||||
|
|
||||||
|
if (!VoipSound.IsPlaying)
|
||||||
{
|
{
|
||||||
if (!VoipSound.IsPlaying)
|
DebugConsole.Log("Destroying voipsound");
|
||||||
{
|
VoipSound.Dispose();
|
||||||
DebugConsole.Log("Destroying voipsound");
|
VoipSound = null;
|
||||||
VoipSound.Dispose();
|
return;
|
||||||
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));
|
VoipSound.SetPosition(new Vector3(character.WorldPosition.X, character.WorldPosition.Y, 0.0f));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VoipSound.SetPosition(null);
|
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()
|
partial void InitProjSpecific()
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ namespace Barotrauma.Sounds
|
|||||||
public bool UseRadioFilter;
|
public bool UseRadioFilter;
|
||||||
public bool UseMuffleFilter;
|
public bool UseMuffleFilter;
|
||||||
|
|
||||||
|
public float Near { get; private set; }
|
||||||
|
public float Far { get; private set; }
|
||||||
|
|
||||||
private static BiQuad[] muffleFilters = new BiQuad[]
|
private static BiQuad[] muffleFilters = new BiQuad[]
|
||||||
{
|
{
|
||||||
new LowpassFilter(VoipConfig.FREQUENCY, 800)
|
new LowpassFilter(VoipConfig.FREQUENCY, 800)
|
||||||
@@ -41,6 +44,16 @@ namespace Barotrauma.Sounds
|
|||||||
new BandpassFilter(VoipConfig.FREQUENCY, 2000)
|
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)
|
public VoipSound(SoundManager owner, VoipQueue q) : base(owner, "voip", true, true)
|
||||||
{
|
{
|
||||||
VoipConfig.SetupEncoding();
|
VoipConfig.SetupEncoding();
|
||||||
@@ -64,8 +77,8 @@ namespace Barotrauma.Sounds
|
|||||||
|
|
||||||
public void SetRange(float near, float far)
|
public void SetRange(float near, float far)
|
||||||
{
|
{
|
||||||
soundChannel.Near = near;
|
soundChannel.Near = Near = near;
|
||||||
soundChannel.Far = far;
|
soundChannel.Far = Far = far;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ApplyFilters(short[] buffer, int readSamples)
|
public void ApplyFilters(short[] buffer, int readSamples)
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ namespace Barotrauma
|
|||||||
public bool ChromaticAberrationEnabled { get; set; }
|
public bool ChromaticAberrationEnabled { get; set; }
|
||||||
|
|
||||||
public bool MuteOnFocusLost { get; set; }
|
public bool MuteOnFocusLost { get; set; }
|
||||||
|
public bool UseDirectionalVoiceChat { get; set; }
|
||||||
|
|
||||||
public enum VoiceMode
|
public enum VoiceMode
|
||||||
{
|
{
|
||||||
@@ -826,6 +827,8 @@ namespace Barotrauma
|
|||||||
SoundVolume = audioSettings.GetAttributeFloat("soundvolume", SoundVolume);
|
SoundVolume = audioSettings.GetAttributeFloat("soundvolume", SoundVolume);
|
||||||
MusicVolume = audioSettings.GetAttributeFloat("musicvolume", MusicVolume);
|
MusicVolume = audioSettings.GetAttributeFloat("musicvolume", MusicVolume);
|
||||||
VoiceChatVolume = audioSettings.GetAttributeFloat("voicechatvolume", VoiceChatVolume);
|
VoiceChatVolume = audioSettings.GetAttributeFloat("voicechatvolume", VoiceChatVolume);
|
||||||
|
MuteOnFocusLost = audioSettings.GetAttributeBool("muteonfocuslost", false);
|
||||||
|
UseDirectionalVoiceChat = audioSettings.GetAttributeBool("usedirectionalvoicechat", true);
|
||||||
string voiceSettingStr = audioSettings.GetAttributeString("voicesetting", "Disabled");
|
string voiceSettingStr = audioSettings.GetAttributeString("voicesetting", "Disabled");
|
||||||
VoiceCaptureDevice = audioSettings.GetAttributeString("voicecapturedevice", "");
|
VoiceCaptureDevice = audioSettings.GetAttributeString("voicecapturedevice", "");
|
||||||
NoiseGateThreshold = audioSettings.GetAttributeFloat("noisegatethreshold", -45);
|
NoiseGateThreshold = audioSettings.GetAttributeFloat("noisegatethreshold", -45);
|
||||||
@@ -1055,6 +1058,8 @@ namespace Barotrauma
|
|||||||
audio.ReplaceAttributes(
|
audio.ReplaceAttributes(
|
||||||
new XAttribute("musicvolume", musicVolume),
|
new XAttribute("musicvolume", musicVolume),
|
||||||
new XAttribute("soundvolume", soundVolume),
|
new XAttribute("soundvolume", soundVolume),
|
||||||
|
new XAttribute("muteonfocuslost", MuteOnFocusLost),
|
||||||
|
new XAttribute("usedirectionalvoicechat", UseDirectionalVoiceChat),
|
||||||
new XAttribute("voicesetting", VoiceSetting),
|
new XAttribute("voicesetting", VoiceSetting),
|
||||||
new XAttribute("voicecapturedevice", VoiceCaptureDevice ?? ""),
|
new XAttribute("voicecapturedevice", VoiceCaptureDevice ?? ""),
|
||||||
new XAttribute("noisegatethreshold", NoiseGateThreshold));
|
new XAttribute("noisegatethreshold", NoiseGateThreshold));
|
||||||
|
|||||||
@@ -211,32 +211,24 @@ namespace Barotrauma.Items.Components
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private string accessDeniedTxt = TextManager.Get("AccessDenied");
|
private string text = TextManager.Get("DoorMsgCannotOpen");
|
||||||
private bool hasIdCard;
|
|
||||||
public override bool HasRequiredItems(Character character, bool addMessage, string msg = null)
|
public override bool HasRequiredItems(Character character, bool addMessage, string msg = null)
|
||||||
{
|
{
|
||||||
if (item.Condition <= RepairThreshold) return true; //For repairing
|
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.
|
//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)
|
public override bool Pick(Character picker)
|
||||||
{
|
{
|
||||||
if (item.Condition <= RepairThreshold) { return true; }
|
return item.Condition <= RepairThreshold ? true : base.Pick(picker);
|
||||||
if (HasRequiredItems(picker, false) && hasIdCard) { return false; }
|
|
||||||
return base.Pick(picker);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnPicked(Character picker)
|
public override bool OnPicked(Character picker)
|
||||||
{
|
{
|
||||||
if (item.Condition <= RepairThreshold) return true; //repairs
|
if (item.Condition <= RepairThreshold) return true; //repairs
|
||||||
if (requiredItems.Any() && !hasIdCard)
|
if (requiredItems.Any())
|
||||||
{
|
{
|
||||||
ForceOpen(ActionType.OnPicked);
|
ForceOpen(ActionType.OnPicked);
|
||||||
}
|
}
|
||||||
@@ -255,19 +247,9 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
//can only be selected if the item is broken
|
//can only be selected if the item is broken
|
||||||
if (item.Condition <= RepairThreshold) return true; //repairs
|
if (item.Condition <= RepairThreshold) return true; //repairs
|
||||||
bool hasRequiredItems = HasRequiredItems(character, false);
|
if (requiredItems.None())
|
||||||
if (requiredItems.None() || hasRequiredItems && hasIdCard)
|
|
||||||
{
|
{
|
||||||
float originalPickingTime = PickingTime;
|
|
||||||
PickingTime = 0;
|
|
||||||
ForceOpen(ActionType.OnUse);
|
ForceOpen(ActionType.OnUse);
|
||||||
PickingTime = originalPickingTime;
|
|
||||||
}
|
|
||||||
else if (hasRequiredItems)
|
|
||||||
{
|
|
||||||
#if CLIENT
|
|
||||||
GUI.AddMessage(accessDeniedTxt, Color.Red);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -538,6 +538,7 @@ namespace Barotrauma.Items.Components
|
|||||||
GameAnalyticsManager.AddErrorEventOnce("ItemComponent.DegreeOfSuccess:CharacterNull", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
GameAnalyticsManager.AddErrorEventOnce("ItemComponent.DegreeOfSuccess:CharacterNull", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
float average = skillSuccessSum / requiredSkills.Count;
|
||||||
|
|
||||||
float skillSuccessSum = 0.0f;
|
float skillSuccessSum = 0.0f;
|
||||||
for (int i = 0; i < requiredSkills.Count; i++)
|
for (int i = 0; i < requiredSkills.Count; i++)
|
||||||
@@ -581,52 +582,38 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
if (!requiredItems.Any()) return true;
|
if (!requiredItems.Any()) return true;
|
||||||
if (character.Inventory == null) return false;
|
if (character.Inventory == null) return false;
|
||||||
bool hasRequiredItems = false;
|
|
||||||
bool canContinue = true;
|
|
||||||
if (requiredItems.ContainsKey(RelatedItem.RelationType.Equipped))
|
if (requiredItems.ContainsKey(RelatedItem.RelationType.Equipped))
|
||||||
{
|
{
|
||||||
foreach (RelatedItem ri in requiredItems[RelatedItem.RelationType.Equipped])
|
foreach (RelatedItem ri in requiredItems[RelatedItem.RelationType.Equipped])
|
||||||
{
|
{
|
||||||
canContinue = CheckItems(ri, character.SelectedItems);
|
if (character.SelectedItems.FirstOrDefault(it => it != null && it.Condition > 0.0f && ri.MatchesItem(it)) == null)
|
||||||
if (!canContinue) { break; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (canContinue)
|
|
||||||
{
|
|
||||||
if (requiredItems.ContainsKey(RelatedItem.RelationType.Picked))
|
|
||||||
{
|
|
||||||
foreach (RelatedItem ri in requiredItems[RelatedItem.RelationType.Picked])
|
|
||||||
{
|
{
|
||||||
if (!CheckItems(ri, character.Inventory.Items)) { break; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
if (!hasRequiredItems && addMessage && !string.IsNullOrEmpty(msg))
|
msg = msg ?? ri.Msg;
|
||||||
{
|
if (addMessage && !string.IsNullOrEmpty(msg))
|
||||||
GUI.AddMessage(msg, Color.Red);
|
{
|
||||||
}
|
GUI.AddMessage(msg, Color.Red);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return hasRequiredItems;
|
return false;
|
||||||
|
|
||||||
bool CheckItems(RelatedItem relatedItem, IEnumerable<Item> 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
if (requiredItems.ContainsKey(RelatedItem.RelationType.Picked))
|
||||||
|
{
|
||||||
|
foreach (RelatedItem ri in requiredItems[RelatedItem.RelationType.Picked])
|
||||||
{
|
{
|
||||||
hasRequiredItems = itemList.Any(Predicate);
|
if (character.Inventory.Items.FirstOrDefault(it => it != null && it.Condition > 0.0f && ri.MatchesItem(it)) == null)
|
||||||
if (!hasRequiredItems)
|
|
||||||
{
|
{
|
||||||
shouldBreak = true;
|
#if CLIENT
|
||||||
|
msg = msg ?? ri.Msg;
|
||||||
|
if (addMessage && !string.IsNullOrEmpty(msg))
|
||||||
|
{
|
||||||
|
GUI.AddMessage(msg, Color.Red);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasRequiredItems)
|
if (!hasRequiredItems)
|
||||||
@@ -638,6 +625,8 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
return !shouldBreak;
|
return !shouldBreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null, Limb targetLimb = null, Character user = null)
|
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.statusEffects = prevRequiredItem.statusEffects;
|
||||||
newRequiredItem.Msg = prevRequiredItem.Msg;
|
newRequiredItem.Msg = prevRequiredItem.Msg;
|
||||||
newRequiredItem.IsOptional = prevRequiredItem.IsOptional;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!requiredItems.ContainsKey(newRequiredItem.Type))
|
if (!requiredItems.ContainsKey(newRequiredItem.Type))
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ namespace Barotrauma
|
|||||||
Container
|
Container
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsOptional { get; set; }
|
|
||||||
|
|
||||||
private string[] identifiers;
|
private string[] identifiers;
|
||||||
|
|
||||||
private string[] excludedIdentifiers;
|
private string[] excludedIdentifiers;
|
||||||
@@ -140,8 +138,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
element.Add(
|
element.Add(
|
||||||
new XAttribute("identifiers", JoinedIdentifiers),
|
new XAttribute("identifiers", JoinedIdentifiers),
|
||||||
new XAttribute("type", type.ToString()),
|
new XAttribute("type", type.ToString()));
|
||||||
new XAttribute("optional", IsOptional));
|
|
||||||
|
|
||||||
if (excludedIdentifiers.Length > 0)
|
if (excludedIdentifiers.Length > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user