Some initial CSharp scripting functionality
This commit is contained in:
@@ -3236,6 +3236,28 @@ namespace Barotrauma
|
||||
|
||||
GameMain.Lua.Initialize();
|
||||
}));
|
||||
|
||||
commands.Add(new Command("cl_net", "lua_net: runs a script on the client", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Client != null && !GameMain.Client.HasPermission(ClientPermissions.ConsoleCommands))
|
||||
{
|
||||
ThrowError("Command not permitted.");
|
||||
return;
|
||||
}
|
||||
|
||||
GameMain.Lua.DoString(string.Join(" ", args));
|
||||
}));
|
||||
|
||||
commands.Add(new Command("cl_reloadnet", "reloads lua on the client", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Client != null && !GameMain.Client.HasPermission(ClientPermissions.ConsoleCommands))
|
||||
{
|
||||
ThrowError("Command not permitted.");
|
||||
return;
|
||||
}
|
||||
|
||||
GameMain.Lua.Initialize();
|
||||
}));
|
||||
}
|
||||
|
||||
private static void ReloadWearables(Character character, int variant = 0)
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Barotrauma
|
||||
class GameMain : Game
|
||||
{
|
||||
public static LuaSetup Lua;
|
||||
public static NetSetup Net;
|
||||
|
||||
public static bool ShowFPS = false;
|
||||
public static bool ShowPerf = false;
|
||||
@@ -227,6 +228,8 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Lua = new LuaSetup();
|
||||
Net = new NetSetup();
|
||||
Net.Execute();
|
||||
|
||||
GameSettings.Init();
|
||||
|
||||
@@ -924,6 +927,7 @@ namespace Barotrauma
|
||||
|
||||
GameMain.Lua.Update();
|
||||
GameMain.Lua.hook.Call("think", new object[] { });
|
||||
GameMain.Net.Update();
|
||||
|
||||
Timing.Accumulator -= Timing.Step;
|
||||
|
||||
@@ -1090,6 +1094,7 @@ namespace Barotrauma
|
||||
GameSession = null;
|
||||
|
||||
GameMain.Lua.Stop();
|
||||
GameMain.Net.Stop();
|
||||
}
|
||||
|
||||
public void ShowCampaignDisclaimer(Action onContinue = null)
|
||||
|
||||
@@ -2705,6 +2705,7 @@ namespace Barotrauma.Networking
|
||||
public override void Disconnect()
|
||||
{
|
||||
GameMain.Lua.Stop();
|
||||
GameMain.Net.Stop();
|
||||
|
||||
allowReconnect = false;
|
||||
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.1.0" />
|
||||
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
||||
<PackageReference Include="NVorbis" Version="0.8.6" />
|
||||
<PackageReference Include="RestSharp" Version="106.13.0" />
|
||||
|
||||
@@ -137,6 +137,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.1.0" />
|
||||
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
||||
<PackageReference Include="NVorbis" Version="0.8.6" />
|
||||
<PackageReference Include="RestSharp" Version="106.13.0" />
|
||||
|
||||
Reference in New Issue
Block a user