1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-02-04 18:22:18 +08:00

work in progress

This commit is contained in:
2025-12-18 19:39:33 +08:00
parent 0d7941387f
commit 9a35dea701
21 changed files with 453 additions and 83 deletions

View File

@@ -20,10 +20,6 @@
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Assembly-CSharp"> <Reference Include="Assembly-CSharp">
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath> <HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
@@ -33,11 +29,16 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\UXAssist\UXAssist.csproj" /> <ProjectReference Include="..\UXAssist\UXAssist.csproj" />
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip&#xA;powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md, CHANGELOG.md" /> <Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md, CHANGELOG.md" />
</Target> </Target>
</Project> </Project>

View File

@@ -19,19 +19,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OverclockEverything", "Over
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MechaDronesTweaks", "MechaDronesTweaks\MechaDronesTweaks.csproj", "{15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MechaDronesTweaks", "MechaDronesTweaks\MechaDronesTweaks.csproj", "{15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LabOpt", "LabOpt\LabOpt.csproj", "{DD76B77C-68D8-4A4C-B98E-CBEECEDC49FB}"
ProjectSection(ProjectDependencies) = postProject
{F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F} = {F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LabOptPreloader", "LabOptPreloader\LabOptPreloader.csproj", "{F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DustbinPreloader", "DustbinPreloader\DustbinPreloader.csproj", "{B8EB3D8D-5613-42F0-9040-EAA11A38C6AC}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DustbinPreloader", "DustbinPreloader\DustbinPreloader.csproj", "{B8EB3D8D-5613-42F0-9040-EAA11A38C6AC}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PoolOpt", "PoolOpt\PoolOpt.csproj", "{8BE61246-2C9D-4088-AA33-5AFF22C5046E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PoolOpt", "PoolOpt\PoolOpt.csproj", "{8BE61246-2C9D-4088-AA33-5AFF22C5046E}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserCloak", "UserCloak\UserCloak.csproj", "{096D2E4B-D1CE-424D-9954-C36A23E9E279}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserCloak", "UserCloak\UserCloak.csproj", "{096D2E4B-D1CE-424D-9954-C36A23E9E279}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaScriptEngine", "LuaScriptEngine\LuaScriptEngine.csproj", "{E9375F0E-26DC-4CEC-80DC-9C48F23340BC}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -70,14 +65,6 @@ Global
{15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}.Debug|Any CPU.Build.0 = Debug|Any CPU {15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}.Release|Any CPU.ActiveCfg = Release|Any CPU {15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}.Release|Any CPU.Build.0 = Release|Any CPU {15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}.Release|Any CPU.Build.0 = Release|Any CPU
{DD76B77C-68D8-4A4C-B98E-CBEECEDC49FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD76B77C-68D8-4A4C-B98E-CBEECEDC49FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD76B77C-68D8-4A4C-B98E-CBEECEDC49FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD76B77C-68D8-4A4C-B98E-CBEECEDC49FB}.Release|Any CPU.Build.0 = Release|Any CPU
{F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F}.Release|Any CPU.Build.0 = Release|Any CPU
{B8EB3D8D-5613-42F0-9040-EAA11A38C6AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B8EB3D8D-5613-42F0-9040-EAA11A38C6AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8EB3D8D-5613-42F0-9040-EAA11A38C6AC}.Debug|Any CPU.Build.0 = Debug|Any CPU {B8EB3D8D-5613-42F0-9040-EAA11A38C6AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8EB3D8D-5613-42F0-9040-EAA11A38C6AC}.Release|Any CPU.ActiveCfg = Release|Any CPU {B8EB3D8D-5613-42F0-9040-EAA11A38C6AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -90,5 +77,9 @@ Global
{096D2E4B-D1CE-424D-9954-C36A23E9E279}.Debug|Any CPU.Build.0 = Debug|Any CPU {096D2E4B-D1CE-424D-9954-C36A23E9E279}.Debug|Any CPU.Build.0 = Debug|Any CPU
{096D2E4B-D1CE-424D-9954-C36A23E9E279}.Release|Any CPU.ActiveCfg = Release|Any CPU {096D2E4B-D1CE-424D-9954-C36A23E9E279}.Release|Any CPU.ActiveCfg = Release|Any CPU
{096D2E4B-D1CE-424D-9954-C36A23E9E279}.Release|Any CPU.Build.0 = Release|Any CPU {096D2E4B-D1CE-424D-9954-C36A23E9E279}.Release|Any CPU.Build.0 = Release|Any CPU
{E9375F0E-26DC-4CEC-80DC-9C48F23340BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9375F0E-26DC-4CEC-80DC-9C48F23340BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9375F0E-26DC-4CEC-80DC-9C48F23340BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9375F0E-26DC-4CEC-80DC-9C48F23340BC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@@ -16,11 +16,21 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" /> <PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" />
<PackageReference Include="DysonSphereProgram.Modding.NebulaMultiplayerModApi" Version="2.0.0" /> <PackageReference Include="DysonSphereProgram.Modding.NebulaMultiplayerModApi" Version="2.0.0" />
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="assets/icon/signal-410.png" /> <EmbeddedResource Include="assets/icon/signal-410.png" />
</ItemGroup> </ItemGroup>
@@ -29,13 +39,8 @@
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" /> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>GameAssembly\Assembly-CSharp.dll</HintPath>
</Reference>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'"> <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip&#xA;IF NOT EXIST package\plugins (mkdir package\plugins)&#xA;copy /y $(TargetPath) package\plugins\&#xA;cd package&#xA;powershell Compress-Archive -Force -DestinationPath '$(ProjectName)-$(Version).zip' -Path patchers, plugins, icon.png, manifest.json, ../README.md, ../CHANGELOG.md" /> <Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
IF NOT EXIST package\plugins (mkdir package\plugins)&#xA;copy /y $(TargetPath) package\plugins\&#xA;cd package&#xA;powershell Compress-Archive -Force -DestinationPath '$(ProjectName)-$(Version).zip' -Path patchers, plugins, icon.png, manifest.json, ../README.md, ../CHANGELOG.md" />
</Target> </Target>
</Project> </Project>

View File

@@ -14,8 +14,17 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'"> <ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">

View File

@@ -15,8 +15,17 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'"> <ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
@@ -24,6 +33,6 @@
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'"> <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip&#xA;powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" /> <Exec Command="powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" />
</Target> </Target>
</Project> </Project>

View File

@@ -15,8 +15,17 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'"> <ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
@@ -24,6 +33,6 @@
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'"> <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip&#xA;IF NOT EXIST package\plugins (mkdir package\plugins)&#xA;copy /y $(TargetPath) package\plugins\&#xA;cd package&#xA;powershell Compress-Archive -Force -DestinationPath '$(ProjectName)-$(Version).zip' -Path patchers, plugins, icon.png, manifest.json, ../README.md" /> <Exec Command="IF NOT EXIST package\plugins (mkdir package\plugins)&#xA;copy /y $(TargetPath) package\plugins\&#xA;cd package&#xA;powershell Compress-Archive -Force -DestinationPath '$(ProjectName)-$(Version).zip' -Path patchers, plugins, icon.png, manifest.json, ../README.md" />
</Target> </Target>
</Project> </Project>

View File

@@ -14,8 +14,17 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'"> <ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">

View File

@@ -16,7 +16,7 @@
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -0,0 +1,7 @@
## Changlog
* 1.0.0
+ Initial release
## 更新日志
* 1.0.0
+ 初始版本

View File

@@ -0,0 +1,232 @@
using System;
using System.Collections.Generic;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using NLua;
namespace LuaScriptEngine;
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class LuaScriptEngine : BaseUnityPlugin
{
private class Timer(LuaFunction func, long startInterval, long repeatInterval = 0L)
{
public bool Check(long gameTick)
{
if (gameTick < _nextTick) return false;
try
{
_func.Call();
}
catch (Exception e)
{
Logger.LogError($"Error in Lua script: {e}");
}
if (_repeatInterval <= 0L) return true;
_nextTick += _repeatInterval;
if (_nextTick < gameTick)
_nextTick = gameTick + 1;
return false;
}
public bool Reset(long gameTick)
{
if (_repeatInterval <= 0L) return true;
_nextTick = gameTick + _repeatInterval;
return false;
}
private readonly LuaFunction _func = func;
private readonly long _repeatInterval = repeatInterval;
private long _nextTick = GameMain.gameTick + startInterval;
}
public new static readonly ManualLogSource Logger =
BepInEx.Logging.Logger.CreateLogSource(PluginInfo.PLUGIN_NAME);
private Harmony _harmony;
private static readonly Lua LuaState = new();
private static readonly List<LuaFunction> PostDataLoadedFuncs = [];
private static readonly List<LuaFunction> PreUpdateFuncs = [];
private static readonly List<LuaFunction> PostUpdateFuncs = [];
private static readonly List<LuaFunction> PreGameBeginFuncs = [];
private static readonly List<LuaFunction> PostGameBeginFuncs = [];
private static readonly List<LuaFunction> PreGameEndFuncs = [];
private static readonly List<LuaFunction> PostGameEndFuncs = [];
private static readonly HashSet<Timer> Timers = [];
private static readonly List<Timer> TimersToRemove = [];
private void Awake()
{
LuaState.State.Encoding = Encoding.UTF8;
LuaState.LoadCLRPackage();
LuaState.DoString("import('Assembly-CSharp')");
LuaState["register_callback"] = (string tp, LuaFunction action) =>
{
switch (tp)
{
case "data_loaded":
PostDataLoadedFuncs.Add(action);
break;
case "pre_update":
PreUpdateFuncs.Add(action);
break;
case "post_update":
PostUpdateFuncs.Add(action);
break;
case "pre_game_begin":
PreGameBeginFuncs.Add(action);
break;
case "post_game_begin":
PostGameBeginFuncs.Add(action);
break;
case "pre_game_end":
PreGameEndFuncs.Add(action);
break;
case "post_game_end":
PostGameEndFuncs.Add(action);
break;
}
};
LuaState["add_timer"] = Timer(LuaFunction func, long firstInterval, long repeatInterval) =>
{
var timer = new Timer(func, firstInterval, repeatInterval);
Timers.Add(timer);
return timer;
};
LuaState["remove_timer"] = void (Timer timer) =>
{
Timers.Remove(timer);
};
var assemblyPath = System.IO.Path.Combine(
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)!,
"scripts"
);
LuaState.DoString($"package.path = '{assemblyPath.Replace('\\', '/')}/?.lua'");
foreach (var file in System.IO.Directory.GetFiles(assemblyPath, "*.lua"))
{
Logger.LogInfo($"Loading Lua script: {file}");
LuaState.DoFile(file);
}
_harmony = Harmony.CreateAndPatchAll(typeof(Patches));
}
private void OnDestroy()
{
Timers.Clear();
PreUpdateFuncs.Clear();
PostUpdateFuncs.Clear();
PreGameBeginFuncs.Clear();
PostGameBeginFuncs.Clear();
PreGameEndFuncs.Clear();
PostGameEndFuncs.Clear();
_harmony?.UnpatchSelf();
LuaState.Dispose();
}
private static class Patches
{
private static void LoopCall(List<LuaFunction> funcs)
{
foreach (var func in funcs)
{
try
{
func.Call();
}
catch (Exception e)
{
Logger.LogError($"Error in Lua script: {e}");
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(VFPreload), nameof(VFPreload.InvokeOnLoadWorkEnded))]
private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
{
LoopCall(PostDataLoadedFuncs);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameMain), nameof(GameMain.FixedUpdate))]
private static void GameMain_FixedUpdate_Prefix()
{
if (Timers.Count > 0)
{
var gameTick = GameMain.gameTick;
foreach (var timer in Timers)
{
if (timer == null || !timer.Check(gameTick)) continue;
TimersToRemove.Add(timer);
}
if (TimersToRemove.Count > 0)
{
foreach (var timer in TimersToRemove)
{
Timers.Remove(timer);
}
TimersToRemove.Clear();
}
}
LoopCall(PreUpdateFuncs);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameMain), nameof(GameMain.FixedUpdate))]
private static void GameMain_FixedUpdate_Postfix()
{
LoopCall(PostUpdateFuncs);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
private static void GameMain_Begin_Prefix()
{
var tick = GameMain.gameTick;
foreach (var timer in Timers)
{
if (timer.Reset(tick))
{
TimersToRemove.Add(timer);
}
}
if (TimersToRemove.Count > 0)
{
foreach (var timer in TimersToRemove)
{
Timers.Remove(timer);
}
TimersToRemove.Clear();
}
LoopCall(PreGameBeginFuncs);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
private static void GameMain_Begin_Postfix()
{
LoopCall(PostGameBeginFuncs);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameMain), nameof(GameMain.End))]
private static void GameMain_End_Prefix()
{
LoopCall(PreGameEndFuncs);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameMain), nameof(GameMain.End))]
private static void GameMain_End_Postfix()
{
LoopCall(PostGameEndFuncs);
}
}
}

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<AssemblyName>LuaScriptEngine</AssemblyName>
<BepInExPluginGuid>org.soardev.luascriptengine</BepInExPluginGuid>
<Description>DSP MOD - LuaScriptEngine</Description>
<Version>1.0.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources>https://nuget.bepinex.dev/v3/index.json</RestoreAdditionalProjectSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLua" Version="1.*" />
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', '$(TargetDir)/KeraLua.dll', '$(TargetDir)/lua54.dll', '$(TargetDir)/NLua.dll', package/icon.png, package/manifest.json, README.md" />
</Target>
</Project>

View File

@@ -0,0 +1,8 @@
# LuaScriptEngine
#### Write mod functions in lua scripts
#### 用lua脚本编写mod功能
## Usage
## 使用说明

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@@ -0,0 +1,9 @@
{
"name": "LuaScriptEngine",
"version_number": "1.0.0",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/LuaScriptEngine",
"description": "Write mod functions in lua scripts / 用lua脚本编写mod功能",
"dependencies": [
"xiaoye97-BepInEx-5.4.17"
]
}

View File

@@ -15,8 +15,17 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'"> <ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
@@ -24,6 +33,6 @@
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'"> <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip&#xA;powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" /> <Exec Command="powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" />
</Target> </Target>
</Project> </Project>

View File

@@ -16,9 +16,18 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" /> <PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" />
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'"> <ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
@@ -26,6 +35,6 @@
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'"> <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip&#xA;powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" /> <Exec Command="powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" />
</Target> </Target>
</Project> </Project>

View File

@@ -15,8 +15,17 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'"> <ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
@@ -24,6 +33,6 @@
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'"> <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip&#xA;powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" /> <Exec Command="powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" />
</Target> </Target>
</Project> </Project>

View File

@@ -9,35 +9,15 @@ Add various cheat functions while disabling abnormal determinants
Moved [to another repo](https://github.com/soarqin/DSP_Mods_TO/tree/master/CompressSave) Moved [to another repo](https://github.com/soarqin/DSP_Mods_TO/tree/master/CompressSave)
## [LogisticMiner](LogisticMiner)
Logistic Storages can mine all ores/water on current planet
物流塔可以采集当前星球的全部矿产(以及水)
## [HideTips](HideTips)
Hide/Disable various tutorial tips/messages
隐藏/屏蔽各种引导提示/消息
## [Dustbin](Dustbin) ## [Dustbin](Dustbin)
Can turn Storages and Tanks into Dustbin(Destroy incoming items) Can turn Storages and Tanks into Dustbin(Destroy incoming items)
储物仓和储液罐可以转变为垃圾桶(销毁送进的物品) 储物仓和储液罐可以转变为垃圾桶(销毁送进的物品)
## [OverclockEverything](OverclockEverything) ## [HideTips](HideTips)
Boost nearly all structures Hide/Disable various tutorial tips/messages
加速几乎所有建筑功能 隐藏/屏蔽各种引导提示/消息
## [UniverseGenTweaks](UniverseGenTweaks)
Universe Generator Tweak
宇宙生成参数调节
## [MechaDronesTweaks](MechaDronesTweaks)
Some tweaks for mecha drones and build functions(Successor to FastDrones MOD)
机甲建设机和建设功能调整(FastDrones MOD的后继者)
## [LabOpt](LabOpt) ## [LabOpt](LabOpt)
@@ -46,11 +26,35 @@ Marked as obsoleted temporarily, needs more investigation about LabComponent's m
优化研究站性能 优化研究站性能
暂时标识为过期需要更多关于LabComponent机制的研究 暂时标识为过期需要更多关于LabComponent机制的研究
## [LogisticMiner](LogisticMiner)
Logistic Storages can mine all ores/water on current planet
物流塔可以采集当前星球的全部矿产(以及水)
## [LuaScriptEngine](LuaScriptEngine)
Write mod functions in lua scripts
用lua脚本编写mod功能
## [MechaDronesTweaks](MechaDronesTweaks)
Some tweaks for mecha drones and build functions(Successor to FastDrones MOD)
机甲建设机和建设功能调整(FastDrones MOD的后继者)
## [OverclockEverything](OverclockEverything)
Boost nearly all structures
加速几乎所有建筑功能
## [PoolOpt](PoolOpt) ## [PoolOpt](PoolOpt)
Optimize memory pools on loading gamesaves Optimize memory pools on loading gamesaves
加载游戏存档时优化内存池的使用 加载游戏存档时优化内存池的使用
## [UniverseGenTweaks](UniverseGenTweaks)
Universe Generator Tweak
宇宙生成参数调节
## [UserCloak](UserCloak) ## [UserCloak](UserCloak)
Cloak(Fake) user account info Cloak(Fake) user account info

View File

@@ -61,7 +61,8 @@
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" /> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip&#xA;powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path &quot;$(TargetPath)&quot;, package/icon.png, package/manifest.json, README.md, CHANGELOG.md" /> <Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path &quot;$(TargetPath)&quot;, package/icon.png, package/manifest.json, README.md, CHANGELOG.md" />
</Target> </Target>
</Project> </Project>

View File

@@ -20,10 +20,6 @@
<PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" /> <PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Assembly-CSharp"> <Reference Include="Assembly-CSharp">
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath> <HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
@@ -33,11 +29,15 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\UXAssist\UXAssist.csproj" /> <ProjectReference Include="..\UXAssist\UXAssist.csproj" />
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'"> <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip&#xA;powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md, CHANGELOG.md" /> <Exec Command="powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md, CHANGELOG.md" />
</Target> </Target>
</Project> </Project>

View File

@@ -15,8 +15,17 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'"> <ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
@@ -24,6 +33,6 @@
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'"> <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip&#xA;powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" /> <Exec Command="powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" />
</Target> </Target>
</Project> </Project>