hook merge + hook wrappers

This commit is contained in:
Oiltanker
2022-04-13 01:34:38 +03:00
parent 1e6ac68e86
commit 5d06df437e
40 changed files with 539 additions and 284 deletions
@@ -25,7 +25,7 @@ namespace Barotrauma
GameServer.Log(GameServer.CharacterLogName(this) + " has died (Cause of death: " + causeOfDeath + ")", ServerLog.MessageType.Attack);
}
}
GameMain.LuaCs.hook.Call("characterDeath", this,causeOfDeathAffliction);
GameMain.LuaCs.HookBase.Call("characterDeath", this,causeOfDeathAffliction);
if (HasAbilityFlag(AbilityFlags.RetainExperienceForNewCharacter))
{
@@ -1293,7 +1293,7 @@ namespace Barotrauma
}
catch (Exception e)
{
GameMain.LuaCs.HandleLuaException(e);
GameMain.LuaCs.HandleException(e);
return;
}
@@ -348,7 +348,7 @@ namespace Barotrauma
CoroutineManager.Update((float)Timing.Step, (float)Timing.Step);
GameMain.LuaCs.Update();
GameMain.LuaCs.hook.Call("think", new object[] { });
GameMain.LuaCs.HookBase.Call("think", new object[] { });
performanceCounterTimer.Stop();
LuaTimer.LastUpdateTime = performanceCounterTimer.ElapsedMilliseconds;
performanceCounterTimer.Reset();
@@ -133,7 +133,7 @@ namespace Barotrauma.Networking
return;
}
var should = new LuaResult(GameMain.LuaCs.hook.Call("chatMessage", txt, c, type));
var should = new LuaResult(GameMain.LuaCs.HookBase.Call("chatMessage", txt, c, type));
if (should.Bool())
{
@@ -290,7 +290,7 @@ namespace Barotrauma.Networking
SendConsoleMessage("Granted all permissions to " + newClient.Name + ".", newClient);
}
GameMain.LuaCs.hook.Call("clientConnected", newClient);
GameMain.LuaCs.HookBase.Call("clientConnected", newClient);
SendChatMessage($"ServerMessage.JoinedServer~[client]={clName}", ChatMessageType.Server, null, changeType: PlayerConnectionChangeType.Joined);
@@ -1804,7 +1804,7 @@ namespace Barotrauma.Networking
outmsg.Write((byte)ServerNetObject.CLIENT_LIST);
outmsg.Write(LastClientListUpdateID);
GameMain.LuaCs.hook.Call("writeClientList", c, outmsg);
GameMain.LuaCs.HookBase.Call("writeClientList", c, outmsg);
outmsg.Write((byte)connectedClients.Count);
foreach (Client client in connectedClients)
@@ -2251,7 +2251,7 @@ namespace Barotrauma.Networking
AssignJobs(teamClients);
var result = new LuaResult(GameMain.LuaCs.hook.Call("jobsAssigned"));
var result = new LuaResult(GameMain.LuaCs.HookBase.Call("jobsAssigned"));
List<CharacterInfo> characterInfos = new List<CharacterInfo>();
foreach (Client client in teamClients)
@@ -2455,7 +2455,7 @@ namespace Barotrauma.Networking
roundStartTime = DateTime.Now;
GameMain.LuaCs.hook.Call("roundStart");
GameMain.LuaCs.HookBase.Call("roundStart");
startGameCoroutine = null;
yield return CoroutineStatus.Success;
@@ -2586,7 +2586,7 @@ namespace Barotrauma.Networking
Log("Ending the round...", ServerLog.MessageType.ServerMessage);
}
GameMain.LuaCs.hook.Call("roundEnd");
GameMain.LuaCs.HookBase.Call("roundEnd");
string endMessage = TextManager.FormatServerMessage("RoundSummaryRoundHasEnded");
@@ -2697,7 +2697,7 @@ namespace Barotrauma.Networking
newName = Client.SanitizeName(newName);
if (newName == c.Name && newJob == c.PreferredJob && newTeam == c.PreferredTeam) { return false; }
var result = new LuaResult(GameMain.LuaCs.hook.Call("tryChangeClientName", c, newName, newJob, newTeam));
var result = new LuaResult(GameMain.LuaCs.HookBase.Call("tryChangeClientName", c, newName, newJob, newTeam));
if (!result.IsNull())
{
@@ -2892,7 +2892,7 @@ namespace Barotrauma.Networking
{
if (client == null) return;
GameMain.LuaCs.hook.Call("clientDisconnected", client);
GameMain.LuaCs.HookBase.Call("clientDisconnected", client);
if (gameStarted && client.Character != null)
{
@@ -3142,7 +3142,7 @@ namespace Barotrauma.Networking
var hookChatMsg = ChatMessage.Create(senderName, message, (ChatMessageType)type, senderCharacter, senderClient, changeType);
var should = new LuaResult(GameMain.LuaCs.hook.Call("modifyChatMessage", hookChatMsg, senderRadio));
var should = new LuaResult(GameMain.LuaCs.HookBase.Call("modifyChatMessage", hookChatMsg, senderRadio));
if (should.Bool())
return;
@@ -3874,7 +3874,7 @@ namespace Barotrauma.Networking
{
if (GameMain.Server == null || !GameMain.Server.ServerSettings.SaveServerLogs) { return; }
GameMain.LuaCs?.hook?.Call("serverLog", line, messageType);
GameMain.LuaCs?.HookBase?.Call("serverLog", line, messageType);
GameMain.Server.ServerSettings.ServerLog.WriteLine(line, messageType);
@@ -184,7 +184,7 @@ namespace Barotrauma.Networking
var skipDeny = false;
{
var result = new LuaResult(GameMain.LuaCs.hook.Call("lidgren.handleConnection", inc));
var result = new LuaResult(GameMain.LuaCs.HookBase.Call("lidgren.handleConnection", inc));
if (!result.IsNull()) {
if (result.Bool()) skipDeny = true;
else return;
@@ -206,7 +206,7 @@ namespace Barotrauma.Networking
protected void UpdatePendingClient(PendingClient pendingClient)
{
var result = new LuaResult(GameMain.LuaCs.hook.Call("handlePendingClient", pendingClient));
var result = new LuaResult(GameMain.LuaCs.HookBase.Call("handlePendingClient", pendingClient));
if (result.Bool())
goto ignore;
@@ -94,7 +94,7 @@ namespace Barotrauma.Networking
ChatMessage.CanUseRadio(sender.Character, out WifiComponent senderRadio) &&
ChatMessage.CanUseRadio(recipient.Character, out WifiComponent recipientRadio))
{
var should = new LuaResult(GameMain.LuaCs.hook.Call("canUseVoiceRadio", new object[] { sender, recipient }));
var should = new LuaResult(GameMain.LuaCs.HookBase.Call("canUseVoiceRadio", new object[] { sender, recipient }));
if (!should.IsNull())
return should.Bool();
@@ -102,7 +102,7 @@ namespace Barotrauma.Networking
if (recipientRadio.CanReceive(senderRadio)) { return true; }
}
var should2 = new LuaResult(GameMain.LuaCs.hook.Call("changeLocalVoiceRange", new object[] { sender, recipient }));
var should2 = new LuaResult(GameMain.LuaCs.HookBase.Call("changeLocalVoiceRange", new object[] { sender, recipient }));
float range = 1.0f;
if (!should2.IsNull())
@@ -92,7 +92,7 @@ namespace Barotrauma
var traitorCandidates = new List<Tuple<Client, Character>>();
foreach (Client c in server.ConnectedClients)
{
var result = new LuaResult(GameMain.LuaCs.hook.Call("traitor.findTraitorCandidate", new object[] { c, team }));
var result = new LuaResult(GameMain.LuaCs.HookBase.Call("traitor.findTraitorCandidate", new object[] { c, team }));
if (result.Bool())
{
traitorCandidates.Add(Tuple.Create(c, c.Character));
@@ -234,7 +234,7 @@ namespace Barotrauma
foreach (var traitor in Traitors.Values)
{
traitor.Greet(server, CodeWords, CodeResponse, message => pendingMessages[traitor].Add(message));
GameMain.LuaCs.hook.Call("traitor.traitorAssigned", new object[] { traitor });
GameMain.LuaCs.HookBase.Call("traitor.traitorAssigned", new object[] { traitor });
}
pendingMessages.ForEach(traitor => traitor.Value.ForEach(message => traitor.Key.SendChatMessage(message, Identifier)));
pendingMessages.ForEach(traitor => traitor.Value.ForEach(message => traitor.Key.SendChatMessageBox(message, Identifier)));