LuaGame legacy service
This commit is contained in:
@@ -49,6 +49,7 @@ namespace Barotrauma
|
|||||||
_servicesProvider.RegisterServiceType<IPackageManagementService, PackageManagementService>(ServiceLifetime.Singleton);
|
_servicesProvider.RegisterServiceType<IPackageManagementService, PackageManagementService>(ServiceLifetime.Singleton);
|
||||||
_servicesProvider.RegisterServiceType<IPluginManagementService, PluginManagementService>(ServiceLifetime.Singleton);
|
_servicesProvider.RegisterServiceType<IPluginManagementService, PluginManagementService>(ServiceLifetime.Singleton);
|
||||||
_servicesProvider.RegisterServiceType<ILuaScriptManagementService, LuaScriptManagementService>(ServiceLifetime.Singleton);
|
_servicesProvider.RegisterServiceType<ILuaScriptManagementService, LuaScriptManagementService>(ServiceLifetime.Singleton);
|
||||||
|
_servicesProvider.RegisterServiceType<LuaGame, LuaGame>(ServiceLifetime.Singleton);
|
||||||
// TODO: ILocalizationService
|
// TODO: ILocalizationService
|
||||||
// TODO: IConfigService
|
// TODO: IConfigService
|
||||||
// TODO: INetworkingService
|
// TODO: INetworkingService
|
||||||
@@ -109,6 +110,8 @@ namespace Barotrauma
|
|||||||
? svc : throw new NullReferenceException("Networking Manager service not found!");
|
? svc : throw new NullReferenceException("Networking Manager service not found!");
|
||||||
public IEventService EventService => _servicesProvider.TryGetService<IEventService>(out var svc)
|
public IEventService EventService => _servicesProvider.TryGetService<IEventService>(out var svc)
|
||||||
? svc : throw new NullReferenceException("Networking Manager service not found!");
|
? svc : throw new NullReferenceException("Networking Manager service not found!");
|
||||||
|
public LuaGame Game => _servicesProvider.TryGetService<LuaGame>(out var svc)
|
||||||
|
? svc : throw new NullReferenceException("LuaGame service not found!");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* === Config Vars
|
* === Config Vars
|
||||||
@@ -177,7 +180,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public ILuaCsHook Hook => this.EventService;
|
public ILuaCsHook Hook => this.EventService;
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static bool IsRunningInsideWorkshop
|
public static bool IsRunningInsideWorkshop
|
||||||
|
|||||||
+17
-3
@@ -3,14 +3,15 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Barotrauma.Items.Components;
|
using Barotrauma.Items.Components;
|
||||||
|
using Barotrauma.LuaCs.Services;
|
||||||
using Barotrauma.Networking;
|
using Barotrauma.Networking;
|
||||||
using FarseerPhysics.Dynamics;
|
using FarseerPhysics.Dynamics;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using MoonSharp.Interpreter;
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma.LuaCs.Services
|
||||||
{
|
{
|
||||||
partial class LuaGame
|
partial class LuaGame : IReusableService
|
||||||
{
|
{
|
||||||
public bool IsSingleplayer => GameMain.IsSingleplayer;
|
public bool IsSingleplayer => GameMain.IsSingleplayer;
|
||||||
public bool IsMultiplayer => GameMain.IsMultiplayer;
|
public bool IsMultiplayer => GameMain.IsMultiplayer;
|
||||||
@@ -463,6 +464,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public List<DebugConsole.Command> Commands => DebugConsole.Commands;
|
public List<DebugConsole.Command> Commands => DebugConsole.Commands;
|
||||||
|
|
||||||
|
public bool IsDisposed => throw new NotImplementedException();
|
||||||
|
|
||||||
public void AssignOnExecute(string names, object onExecute) => DebugConsole.AssignOnExecute(names,
|
public void AssignOnExecute(string names, object onExecute) => DebugConsole.AssignOnExecute(names,
|
||||||
(string[] a) =>
|
(string[] a) =>
|
||||||
{
|
{
|
||||||
@@ -529,7 +532,7 @@ namespace Barotrauma
|
|||||||
GameMain.Server.EndGame();
|
GameMain.Server.EndGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AssignOnClientRequestExecute(string names, object onExecute) => DebugConsole.AssignOnClientRequestExecute(names, (Client a, Vector2 b, string[] c) => { GameMain.LuaCs.CallLuaFunction(onExecute, new object[] { a, b, c }); });
|
//public void AssignOnClientRequestExecute(string names, object onExecute) => DebugConsole.AssignOnClientRequestExecute(names, (Client a, Vector2 b, string[] c) => { GameMain.LuaCs.CallLuaFunction(onExecute, new object[] { a, b, c }); });
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -543,6 +546,17 @@ namespace Barotrauma
|
|||||||
DebugConsole.Commands.Remove(cmd);
|
DebugConsole.Commands.Remove(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FluentResults.Result Reset()
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
return FluentResults.Result.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user