-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from Next-Fast/develop
Develop 重构
- Loading branch information
Showing
286 changed files
with
5,221 additions
and
4,911 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Build-Release | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
if: ${{ github.repository_owner == 'TheIdealShipAU' }} | ||
steps: | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.nuget/packages | ||
~/.cache/bepinex | ||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuget- | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
|
||
- name: Collect build info | ||
id: info | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
let version = "1.0.0"; | ||
core.setOutput(ReleaseVersion, version); | ||
- name: install wget | ||
run: sudo apt install wget | ||
|
||
- name: download BepInEx | ||
run: wget https://builds.bepinex.dev/projects/bepinex_be/672/BepInEx-Unity.IL2CPP-win-x86-6.0.0-be.672%2B472e950.zip | ||
|
||
- name: BepInEx | ||
run: unzip BepInEx-Unity.IL2CPP-win-x86-6.0.0-be.672+422e950.zip -d ./NextShipRelease/ | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 8.x | ||
|
||
- name: build | ||
run: dotnet build NextShip/NextShip.csproj --configuration Release | ||
|
||
- name: path | ||
run: sudo chmod -R 777 ./NextShipRelease | ||
|
||
- name: upload NextShip | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: NextShip.dll | ||
path: NextShip/bin/Release/net8.0/NextShip.dll | ||
|
||
- name: upload TheIdealShip | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: NextShip | ||
path: ./NextShipRelease |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
global using static NSLangAnalyzer.Constants; | ||
|
||
namespace NSLangAnalyzer; | ||
|
||
public static class Constants | ||
{ | ||
public const string FileSuffix = "NS"; | ||
|
||
public const string FileSuffix2 = "NSL"; | ||
|
||
public const string FileSuffix3 = "ns"; | ||
|
||
public const string FileSuffix4 = "nsl"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
namespace NSLangAnalyzer; | ||
|
||
internal class FileFinder | ||
{ | ||
private static readonly string[] Extensions = [FileSuffix, FileSuffix2, FileSuffix3, FileSuffix4]; | ||
private readonly List<FileInfo> _fileInfos = []; | ||
private readonly List<ReadInfo> _readInfos = []; | ||
|
||
public FileFinder ReadFiles() | ||
{ | ||
if (_fileInfos.Count == 0) throw new NSLException("FileInfo = 0"); | ||
|
||
foreach (var info in _fileInfos) | ||
{ | ||
using var readStream = info.OpenRead(); | ||
using var reader = new StreamReader(readStream); | ||
var strings = string.Empty; | ||
|
||
var OneLine = reader.ReadLine(); | ||
if (OneLine == null || !OneLine.StartsWith('[') || !OneLine.EndsWith(']')) continue; | ||
|
||
var texts = OneLine | ||
.Replace("[", string.Empty) | ||
.Replace("]", string.Empty) | ||
.Split(":"); | ||
|
||
var name = texts[0]; | ||
var author = texts[1]; | ||
|
||
var line = reader.ReadLine(); | ||
while (line != null) | ||
{ | ||
strings += line; | ||
line = reader.ReadLine(); | ||
} | ||
|
||
_readInfos.Add(new ReadInfo | ||
{ | ||
Info = info, | ||
ReadStrings = strings, | ||
name = name, | ||
author = author | ||
}); | ||
} | ||
|
||
return this; | ||
} | ||
|
||
public FileFinder Get(DirectoryInfo directory) | ||
{ | ||
_readInfos.Clear(); | ||
_fileInfos.AddRange(directory.GetFiles().Where(isFile)); | ||
return this; | ||
} | ||
|
||
private static bool isFile(FileInfo fileInfo) | ||
{ | ||
return Extensions.Any(varExtension => fileInfo.Extension == "." + varExtension); | ||
} | ||
|
||
private class ReadInfo | ||
{ | ||
public string? ReadStrings { get; set; } | ||
|
||
public FileInfo? Info { get; set; } | ||
|
||
public string? name { get; set; } | ||
|
||
public string? author { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace NSLangAnalyzer; | ||
|
||
public class MainAnalyzer | ||
{ | ||
private readonly FileFinder _Finder = new(); | ||
|
||
public void Find(string path) | ||
{ | ||
if (!Directory.Exists(path)) | ||
throw new NSLException("不存在指定文件夹"); | ||
|
||
var finder = _Finder.Get(new DirectoryInfo(path)).ReadFiles(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace NSLangAnalyzer; | ||
|
||
public class NSLException : Exception | ||
{ | ||
public NSLException() | ||
{ | ||
} | ||
|
||
public NSLException(string message) : base(message) | ||
{ | ||
} | ||
|
||
public NSLException(string message, Exception exception) : base(message, exception) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using HarmonyLib; | ||
|
||
namespace NextShip.Api; | ||
|
||
internal static class APIHarmony | ||
{ | ||
static APIHarmony() | ||
{ | ||
_Harmony = new Harmony("net.NextShip.Api"); | ||
} | ||
|
||
internal static Harmony _Harmony { get; set; } | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Reflection; | ||
using NextShip.Api.Interfaces; | ||
|
||
namespace NextShip.Api.Attributes; | ||
|
||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor)] | ||
[MeansImplicitUse] | ||
public class FastAddRole : Attribute | ||
{ | ||
public static void Registration(IRoleManager _roleManager, Assembly assembly) | ||
{ | ||
var Types = assembly.GetTypes(); | ||
|
||
foreach (var VarType in Types.Where(n => n.Is<FastAddRole>() && n.GetInterface(nameof(IRole)) != null)) | ||
{ | ||
var constructorInfos = VarType.GetConstructors().Where(n => n.Is<FastAddRole>()); | ||
foreach (var variableConstructorInfo in constructorInfos) | ||
_roleManager.Register(variableConstructorInfo.Invoke(null, null) as IRole); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace NextShip.Api.Attributes; | ||
|
||
[MeansImplicitUse] | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] | ||
public class FastReadAdd(byte callId) : Attribute | ||
{ | ||
public readonly byte CallId = callId; | ||
} |
31 changes: 15 additions & 16 deletions
31
...ies/Attributes/Il2CppRegisterAttribute.cs → ...Api/Attributes/Il2CppRegisterAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System.Collections; | ||
using System.Reflection; | ||
|
||
namespace NextShip.Api.Attributes; | ||
|
||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Constructor)] | ||
public sealed class LoadAttribute(LoadMode mode = LoadMode.Load) : Attribute | ||
{ | ||
public static readonly List<LoadAttribute> Loads = []; | ||
|
||
public static string[] MethodNames = EnumHelper.GetAllNames<LoadMode>(); | ||
|
||
public IEnumerator Enumerator; | ||
public LoadMode Mode = mode; | ||
|
||
public static void Registration(Type type) | ||
{ | ||
Info("Start Registration", filename: MethodUtils.GetClassName()); | ||
|
||
if (type.GetCustomAttribute<LoadAttribute>() == null) return; | ||
|
||
ConstructorInfo constructor; | ||
if ( | ||
( | ||
constructor = type.GetConstructor | ||
( | ||
BindingFlags.Public | | ||
BindingFlags.Static | | ||
BindingFlags.NonPublic, | ||
Array.Empty<Type>() | ||
) | ||
) | ||
!= null && constructor.Is<LoadAttribute>()) | ||
constructor.Invoke(null, null); | ||
|
||
foreach (var MethodInfo in type.GetMethods(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public)) | ||
{ | ||
if (MethodInfo.ReturnType != typeof(IEnumerator)) | ||
continue; | ||
|
||
var load = MethodInfo.GetCustomAttribute<LoadAttribute>(); | ||
LoadMode? mode = null; | ||
if (Enum.TryParse(MethodInfo.Name, out LoadMode OutMode)) | ||
mode = OutMode; | ||
|
||
if (load != null) | ||
{ | ||
load.Enumerator = MethodInfo.Invoke(null, null) as IEnumerator; | ||
Loads.Add(load); | ||
continue; | ||
} | ||
|
||
if (mode != null) | ||
Loads.Add(new LoadAttribute | ||
{ | ||
Mode = (LoadMode)mode, | ||
Enumerator = MethodInfo.Invoke(null, null) as IEnumerator | ||
}); | ||
} | ||
|
||
Info($"Statically Initialized Class {type}", "LoadAttribute"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Reflection; | ||
using NextShip.Api.Interfaces; | ||
|
||
namespace NextShip.Api.Attributes; | ||
|
||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)] | ||
public sealed class NextEventListener : Attribute | ||
{ | ||
public static void RegisterFormAssembly(Assembly assembly, IEventManager manager) | ||
{ | ||
} | ||
|
||
public static void RegisterFormService(IServiceProvider provider, IEventManager manager) | ||
{ | ||
} | ||
} |
Oops, something went wrong.