add hook for changing local voice range

This commit is contained in:
Evil Factory
2021-08-29 17:30:29 -03:00
parent dd5ea6e4f8
commit c98c37743f
2 changed files with 40 additions and 1 deletions

View File

@@ -403,6 +403,34 @@ namespace Barotrauma
{
return File.Exists(path);
}
public static string[] DirSearch(string sDir)
{
List<string> files = new List<string>();
try
{
foreach (string f in Directory.GetFiles(sDir))
{
files.Add(f);
}
foreach (string d in Directory.GetDirectories(sDir))
{
foreach (string f in Directory.GetFiles(d))
{
files.Add(f);
}
DirSearch(d);
}
}
catch (System.Exception excpt)
{
Console.WriteLine(excpt.Message);
}
return files.ToArray();
}
}
private class LuaNetworking

View File

@@ -107,8 +107,19 @@ namespace Barotrauma.Networking
if (recipientRadio.CanReceive(senderRadio)) { return true; }
}
var should2 = GameMain.Lua.hook.Call("changeLocalVoiceRange", new object[] { sender, recipient });
float range = 1.0f;
if (should2 != null)
{
if (should2 is DynValue dyn)
{
range = (float)dyn.CastToNumber();
}
}
//otherwise do a distance check
return ChatMessage.GetGarbleAmount(recipient.Character, sender.Character, ChatMessage.SpeakRange) < 1.0f;
return ChatMessage.GetGarbleAmount(recipient.Character, sender.Character, ChatMessage.SpeakRange) < range;
}
}
}