initial cs-lua merge work

This commit is contained in:
Oiltanker
2022-04-11 22:44:53 +03:00
parent ae2b84cceb
commit 1e6ac68e86
44 changed files with 786 additions and 1046 deletions
@@ -3223,7 +3223,7 @@ namespace Barotrauma
return;
}
GameMain.Lua.DoString(string.Join(" ", args));
GameMain.LuaCs.DoString(string.Join(" ", args));
}));
commands.Add(new Command("cl_reloadlua", "reloads lua on the client", (string[] args) =>
@@ -3234,7 +3234,7 @@ namespace Barotrauma
return;
}
GameMain.Lua.Initialize();
GameMain.LuaCs.Initialize();
}));
commands.Add(new Command("cl_net", "lua_net: runs a script on the client", (string[] args) =>
@@ -3245,7 +3245,7 @@ namespace Barotrauma
return;
}
GameMain.Lua.DoString(string.Join(" ", args));
GameMain.LuaCs.DoString(string.Join(" ", args));
}));
commands.Add(new Command("cl_reloadnet", "reloads lua on the client", (string[] args) =>
@@ -3256,7 +3256,7 @@ namespace Barotrauma
return;
}
GameMain.Lua.Initialize();
GameMain.LuaCs.Initialize();
}));
}
@@ -20,8 +20,7 @@ namespace Barotrauma
{
class GameMain : Game
{
public static LuaSetup Lua;
public static NetSetup Net;
public static LuaCsSetup LuaCs;
public static bool ShowFPS = false;
public static bool ShowPerf = false;
@@ -227,9 +226,7 @@ namespace Barotrauma
throw new Exception("Content folder not found. If you are trying to compile the game from the source code and own a legal copy of the game, you can copy the Content folder from the game's files to BarotraumaShared/Content.");
}
Lua = new LuaSetup();
Net = new NetSetup();
Net.Execute();
LuaCs = new LuaCsSetup();
GameSettings.Init();
@@ -925,9 +922,8 @@ namespace Barotrauma
SoundManager?.Update();
GameMain.Lua.Update();
GameMain.Lua.hook.Call("think", new object[] { });
GameMain.Net.Update();
GameMain.LuaCs.Update();
GameMain.LuaCs.hook.Call("think");
Timing.Accumulator -= Timing.Step;
@@ -1093,8 +1089,7 @@ namespace Barotrauma
MainMenuScreen.Select();
GameSession = null;
GameMain.Lua.Stop();
GameMain.Net.Stop();
GameMain.LuaCs.Stop();
}
public void ShowCampaignDisclaimer(Action onContinue = null)
@@ -690,7 +690,7 @@ namespace Barotrauma.Networking
{
ServerPacketHeader header = (ServerPacketHeader)inc.ReadByte();
GameMain.Lua.networking.NetMessageReceived(inc, header);
GameMain.LuaCs.networking.NetMessageReceived(inc, header);
if (roundInitStatus != RoundInitStatus.Started &&
roundInitStatus != RoundInitStatus.NotStarted &&
@@ -2704,8 +2704,7 @@ namespace Barotrauma.Networking
public override void Disconnect()
{
GameMain.Lua.Stop();
GameMain.Net.Stop();
GameMain.LuaCs.Stop();
allowReconnect = false;
@@ -2831,7 +2830,7 @@ namespace Barotrauma.Networking
public override void AddChatMessage(ChatMessage message)
{
var should = new LuaResult(GameMain.Lua.hook.Call("chatMessage", new object[] { message.Text, message.SenderClient, message.Type, message }));
var should = new LuaResult(GameMain.LuaCs.hook.Call("chatMessage", message.Text, message.SenderClient, message.Type, message));
if (should.Bool()) return;
@@ -562,7 +562,7 @@ namespace Barotrauma
allowInput = true;
}
GameMain.Lua.hook.Call("keyUpdate", new object[] { deltaTime });
GameMain.LuaCs.hook.Call("keyUpdate", deltaTime);
oldMouseState = mouseState;
mouseState = latestMouseState;
@@ -386,11 +386,11 @@ namespace Barotrauma
#endif
new GUIButton(new RectTransform(new Point(300, 30), Frame.RectTransform, Anchor.TopLeft) { AbsoluteOffset = new Point(20, 50) },
"Remove Client-Side Lua", style: "MainMenuGUIButton", color: GUIStyle.Red)
"Remove Client-Side LuaCs", style: "MainMenuGUIButton", color: GUIStyle.Red)
{
IgnoreLayoutGroups = true,
UserData = Tab.Empty,
ToolTip = "Remove Client-Side Lua.",
ToolTip = "Remove Client-Side LuaCs.",
OnClicked = (tb, userdata) =>
{
if (!File.Exists("Barotrauma.dll.old"))
@@ -407,7 +407,7 @@ namespace Barotrauma
return false;
}
var msg = new GUIMessageBox("Confirm", "Are you sure you want to remove Client-Side Lua?", new LocalizedString[2] { TextManager.Get("Yes"), TextManager.Get("Cancel") });
var msg = new GUIMessageBox("Confirm", "Are you sure you want to remove Client-Side LuaCs?", new LocalizedString[2] { TextManager.Get("Yes"), TextManager.Get("Cancel") });
msg.Buttons[0].OnClicked = (GUIButton button, object obj) =>
{
@@ -1118,7 +1118,7 @@ namespace Barotrauma
}
((SinglePlayerCampaign)GameMain.GameSession.GameMode).LoadNewLevel();
GameMain.Lua.Initialize();
GameMain.LuaCs.Initialize();
}
private void LoadGame(string saveFile)
@@ -1138,7 +1138,7 @@ namespace Barotrauma
//TODO
//GameMain.LobbyScreen.Select();
GameMain.Lua.Initialize();
GameMain.LuaCs.Initialize();
}
#region UI Methods