Skip to content

Commit 1c15188

Browse files
committed
Release 1.0
0 parents  commit 1c15188

File tree

7 files changed

+240
-0
lines changed

7 files changed

+240
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Logless Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
env:
9+
LIB_NAME: Logless
10+
11+
jobs:
12+
build-and-release:
13+
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
22+
- name: Setup .NET
23+
uses: actions/setup-dotnet@v3
24+
with:
25+
dotnet-version: 7.0.102
26+
27+
- name: Restore NuGet Packages
28+
run: dotnet restore
29+
30+
- name: Build Library
31+
run: dotnet build --configuration Release
32+
33+
- name: Zip Artifact
34+
run: zip -rjD ${{ env.LIB_NAME }}_${{ github.ref_name }}.zip ${{ github.workspace }}/bin/Release/**/${{ env.LIB_NAME }}.dll
35+
36+
- name: Create Release
37+
uses: ncipollo/release-action@v1
38+
with:
39+
name: ${{ env.LIB_NAME }} ${{ github.ref_name }}
40+
artifacts: ${{ env.LIB_NAME }}_${{ github.ref_name }}.zip
41+
body: |
42+
Release of ${{ env.LIB_NAME }} ${{ github.ref_name }}
43+
generateReleaseNotes: true
44+
makeLatest: true

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.*
2+
bin/*
3+
obj/*
4+
libs/*.dll
5+
*.user

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Alexandre Poumaroux
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Logless.cs

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
4+
using System.Linq;
5+
using System.Reflection;
6+
using BepInEx;
7+
using BepInEx.Logging;
8+
using HarmonyLib;
9+
10+
namespace Logless
11+
{
12+
using P = Plugin;
13+
14+
[BepInProcess("Legion TD 2.exe")]
15+
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
16+
public class Plugin : BaseUnityPlugin
17+
{
18+
// Using GUID for the Harmony instance, so that we can unpatch just this plugin if needed
19+
private readonly Assembly _assembly = Assembly.GetExecutingAssembly();
20+
private readonly Harmony _harmony = new(PluginInfo.PLUGIN_GUID);
21+
22+
internal new static ManualLogSource Logger;
23+
24+
// When the plugin is loaded
25+
public void Awake() {
26+
// Create masking Logger as internal to use more easily in code
27+
Logger = base.Logger;
28+
29+
// Inject custom js and patch c#
30+
try {
31+
Patch();
32+
}
33+
catch (Exception e) {
34+
Logger.LogError($"Error while injecting or patching: {e}");
35+
throw;
36+
}
37+
38+
// All done!
39+
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
40+
}
41+
42+
// Unpatch if plugin is destroyed to handle in-game plugin reloads
43+
// Remove files we created
44+
public void OnDestroy() {
45+
UnPatch();
46+
}
47+
48+
private void Patch() {
49+
_harmony.PatchAll(_assembly);
50+
}
51+
52+
// Undoes what Patch() did
53+
private void UnPatch() {
54+
_harmony.UnpatchSelf();
55+
}
56+
}
57+
58+
[SuppressMessage("ReSharper", "InconsistentNaming")]
59+
[SuppressMessage("ReSharper", "UnusedMember.Local")]
60+
[HarmonyPatch]
61+
internal static class PatchDeveloperApiHtmlLogger
62+
{
63+
private static Type _typeDeveloperApi;
64+
65+
[HarmonyPrepare]
66+
private static void Prepare() {
67+
_typeDeveloperApi = AccessTools.TypeByName("aag.Natives.Api.DeveloperApi");
68+
}
69+
70+
[HarmonyTargetMethods]
71+
private static IEnumerable<MethodBase> TargetMethods()
72+
{
73+
return AccessTools.Inner(_typeDeveloperApi, "HtmlLogger")
74+
.GetMethods()
75+
.Where(method => method.ReturnType == typeof(void));
76+
}
77+
78+
[HarmonyPrefix]
79+
private static bool Prefix(MethodBase __originalMethod) {
80+
return false;
81+
}
82+
}
83+
84+
[SuppressMessage("ReSharper", "InconsistentNaming")]
85+
[SuppressMessage("ReSharper", "UnusedMember.Local")]
86+
[HarmonyPatch]
87+
internal static class PatchDeveloperApi
88+
{
89+
private static Type _typeDeveloperApi;
90+
91+
[HarmonyPrepare]
92+
private static void Prepare() {
93+
_typeDeveloperApi = AccessTools.TypeByName("aag.Natives.Api.DeveloperApi");
94+
}
95+
96+
[HarmonyTargetMethods]
97+
private static IEnumerable<MethodBase> TargetMethods()
98+
{
99+
return _typeDeveloperApi
100+
.GetMethods()
101+
.Where(method => method.ReturnType == typeof(void));
102+
}
103+
104+
[HarmonyPrefix]
105+
private static bool Prefix(MethodBase __originalMethod) {
106+
return false;
107+
}
108+
}
109+
110+
[SuppressMessage("ReSharper", "InconsistentNaming")]
111+
[SuppressMessage("ReSharper", "UnusedMember.Local")]
112+
[HarmonyPatch]
113+
internal static class PatchLogSaver
114+
{
115+
private static Type _typeLogSaver;
116+
117+
[HarmonyPrepare]
118+
private static void Prepare() {
119+
_typeLogSaver = AccessTools.TypeByName("Assets.Features.Dev.LogSaver");
120+
}
121+
122+
[HarmonyTargetMethods]
123+
private static IEnumerable<MethodBase> TargetMethods()
124+
{
125+
return _typeLogSaver
126+
.GetMethods()
127+
.Where(method => method.ReturnType == typeof(void));
128+
}
129+
130+
[HarmonyPrefix]
131+
private static bool Prefix() {
132+
return false;
133+
}
134+
}
135+
}

Logless.csproj

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>netstandard2.0</TargetFramework>
4+
<AssemblyName>Logless</AssemblyName>
5+
<Description>This Logless mod</Description>
6+
<Version>1.0.0</Version>
7+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
8+
<LangVersion>latest</LangVersion>
9+
<PackageId>ltd2.mods.Kidev.Logless</PackageId>
10+
<Title>Logless</Title>
11+
<Authors>Kidev</Authors>
12+
<NoWarn>$(NoWarn);CS0436</NoWarn>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
17+
<PackageReference Include="BepInEx.Core" Version="5.*" />
18+
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
19+
<PackageReference Include="UnityEngine.Modules" Version="2020.3.16" IncludeAssets="compile" />
20+
</ItemGroup>
21+
22+
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
23+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
24+
</ItemGroup>
25+
26+
</Project>

NuGet.Config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" />
5+
</packageSources>
6+
</configuration>

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Logless
2+
3+
Bye bye logs

0 commit comments

Comments
 (0)