renamed hooks (with compatibility), added new hook: character.giveJobItems (because of how often its used) and updated hook docs

This commit is contained in:
Evil Factory
2022-05-17 12:24:52 -03:00
parent fd6b833c98
commit cf500081d1
6 changed files with 51 additions and 16 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.Hook.Call("character.death", this,causeOfDeathAffliction);
if (HasAbilityFlag(AbilityFlags.RetainExperienceForNewCharacter))
{
@@ -293,7 +293,7 @@ namespace Barotrauma.Networking
SendConsoleMessage("Granted all permissions to " + newClient.Name + ".", newClient);
}
GameMain.LuaCs.Hook.Call("clientConnected", newClient);
GameMain.LuaCs.Hook.Call("client.connected", newClient);
SendChatMessage($"ServerMessage.JoinedServer~[client]={clName}", ChatMessageType.Server, null, changeType: PlayerConnectionChangeType.Joined);
@@ -2899,7 +2899,7 @@ namespace Barotrauma.Networking
{
if (client == null) return;
GameMain.LuaCs.Hook.Call("clientDisconnected", client);
GameMain.LuaCs.Hook.Call("client.disconnected", client);
if (gameStarted && client.Character != null)
{
@@ -76,4 +76,20 @@ end
compatibilityLib["Player"] = luaPlayer
Hook.Add("character.created", "compatibility.character.created", function (character)
Hook.Call("characterCreated", character)
end)
Hook.Add("character.death", "compatibility.character.death", function (character, causeOfDeathAffliction)
Hook.Call("characterDeath", character, causeOfDeathAffliction)
end)
Hook.Add("client.connected", "compatibility.client.connected", function (client)
Hook.Call("clientConnected", client)
end)
Hook.Add("client.disconnected", "compatibility.client.disconnected", function (client)
Hook.Call("clientDisconnected", client)
end)
return compatibilityLib
@@ -80,7 +80,7 @@ namespace Barotrauma
public void AddObjective<T>(T objective) where T : AIObjective
{
var result = GameMain.LuaCs.Hook.Call<bool?>("AI.AddObjective", this, objective);
var result = GameMain.LuaCs.Hook.Call<bool?>("AI.addObjective", this, objective);
if (result != null && result.Value) return;
@@ -1043,7 +1043,7 @@ namespace Barotrauma
}
#endif
GameMain.LuaCs.Hook.Call("characterCreated", new object[] { newCharacter });
GameMain.LuaCs.Hook.Call("character.created", new object[] { newCharacter });
return newCharacter;
}
@@ -1441,6 +1441,8 @@ namespace Barotrauma
{
if (info?.Job == null) { return; }
info.Job.GiveJobItems(this, spawnPoint);
GameMain.LuaCs.Hook.Call("character.giveJobItems", this, spawnPoint);
}
public void GiveIdCardTags(WayPoint spawnPoint, bool createNetworkEvent = false)