Skip to content

Commit 50d60db

Browse files
authored
Merge pull request #25 from Misfiy/docs-and-examples
Docs and examples
2 parents afbad56 + bae270c commit 50d60db

File tree

6 files changed

+125
-9
lines changed

6 files changed

+125
-9
lines changed

.github/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
* SecretAPI is a plugin that extends [LabAPI](https://github.com/northwood-studios/LabAPI) by providing extra features to help devs.
33

44
# Features
5-
- RoleExtensions: Extensions to help with RoleTypeId
6-
- RoomExtensions: Extensions related to rooms
7-
- CustomPlayerEffect: Create new status effects
5+
- CollectionExtensions: Extensions to provide utility for collections
6+
- RoleExtensions: Extensions to help with handling roles
7+
- RoomExtensions: Extensions to help with rooms
8+
- HarmonyExtensions: Extensions to provide more utility to Harmony
9+
- CustomPlayerEffect: Create custom status effects using the base-game system
810
- IRegister: Handle auto registering certain plugin features
11+
- CustomSetting: SSSS wrappers in an abstract way, providing utility with permission based settings
912

1013
# Support
1114
* For any issues create an [Issue](https://github.com/Misfiy/SecretAPI/issues/new) or contact me on [Discord](https://discord.gg/RYzahv3vfC).

SecretAPI.Examples/ExampleEntry.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
namespace SecretAPI.Examples
2+
{
3+
using System;
4+
using HarmonyLib;
5+
using LabApi.Loader.Features.Plugins;
6+
using SecretAPI.Examples.Settings;
7+
using SecretAPI.Extensions;
8+
using SecretAPI.Features.UserSettings;
9+
10+
/// <summary>
11+
/// Defines the entry for the plugin.
12+
/// </summary>
13+
public class ExampleEntry : Plugin
14+
{
15+
private Harmony? harmony;
16+
17+
/// <inheritdoc/>
18+
public override string Name { get; } = "SecretAPI.Example";
19+
20+
/// <inheritdoc/>
21+
public override string Description { get; } = "An example plugin";
22+
23+
/// <inheritdoc/>
24+
public override string Author { get; } = "@misfiy";
25+
26+
/// <inheritdoc/>
27+
public override Version Version { get; } = typeof(SecretApi).Assembly.GetName().Version;
28+
29+
/// <inheritdoc/>
30+
public override Version RequiredApiVersion { get; } = new(LabApi.Features.LabApiProperties.CompiledVersion);
31+
32+
/// <inheritdoc/>
33+
public override void Enable()
34+
{
35+
CustomSetting.Register(new ExampleKeybindSetting());
36+
harmony = new Harmony(nameof(ExampleEntry) + DateTime.Now.Ticks);
37+
harmony.PatchAllNoCategory();
38+
harmony.PatchCategory(nameof(ExampleEntry));
39+
}
40+
41+
/// <inheritdoc/>
42+
public override void Disable()
43+
{
44+
}
45+
}
46+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace SecretAPI.Examples.Patches
2+
{
3+
using HarmonyLib;
4+
using SecretAPI.Attribute;
5+
6+
/// <summary>
7+
/// An example harmony patch.
8+
/// </summary>
9+
[HarmonyPatchCategory(nameof(ExampleEntry))]
10+
[HarmonyPatch]
11+
public static class ExamplePatch
12+
{
13+
private static bool Prefix()
14+
{
15+
return false;
16+
}
17+
18+
private static void Postfix()
19+
{
20+
}
21+
}
22+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net48</TargetFramework>
4+
<LangVersion>latest</LangVersion>
5+
<Nullable>enable</Nullable>
6+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.2" PrivateAssets="all" />
11+
<PackageReference Include="Lib.Harmony" Version="2.2.2" />
12+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" IncludeAssets="All" PrivateAssets="All" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\SecretAPI\SecretAPI.csproj" />
17+
<Reference Include="Assembly-CSharp" HintPath="$(SL_REFERENCES)\Assembly-CSharp.dll" Publicize="true" />
18+
<Reference Include="CommandSystem.Core" HintPath="$(SL_REFERENCES)\CommandSystem.Core.dll" />
19+
<Reference Include="LabApi" HintPath="$(SL_REFERENCES)\LabApi.dll" />
20+
<Reference Include="NorthwoodLib" HintPath="$(SL_REFERENCES)\NorthwoodLib.dll" />
21+
<Reference Include="Assembly-CSharp-firstpass" HintPath="$(SL_REFERENCES)\Assembly-CSharp-firstpass.dll" />
22+
<Reference Include="Pooling" HintPath="$(SL_REFERENCES)\Pooling.dll" />
23+
<Reference Include="Mirror" HintPath="$(SL_REFERENCES)\Mirror.dll" />
24+
<Reference Include="mscorlib" HintPath="$(SL_REFERENCES)\mscorlib.dll" />
25+
<Reference Include="UnityEngine" HintPath="$(SL_REFERENCES)\UnityEngine.dll" />
26+
<Reference Include="UnityEngine.CoreModule" HintPath="$(SL_REFERENCES)\UnityEngine.CoreModule.dll" />
27+
<Reference Include="UnityEngine.PhysicsModule" HintPath="$(SL_REFERENCES)\UnityEngine.PhysicsModule.dll" />
28+
<Reference Include="Unity.TextMeshPro" HintPath="$(SL_REFERENCES)\Unity.TextMeshPro.dll" />
29+
</ItemGroup>
30+
31+
<PropertyGroup>
32+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
33+
<AnalysisMode>recommended</AnalysisMode>
34+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
35+
<CodeAnalysisRuleSet>../stylecop.ruleset</CodeAnalysisRuleSet>
36+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
37+
</PropertyGroup>
38+
</Project>

SecretAPI/Features/UserSettings/ExampleSetting.cs renamed to SecretAPI.Examples/Settings/ExampleKeybindSetting.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
namespace SecretAPI.Features.UserSettings
1+
namespace SecretAPI.Examples.Settings
22
{
33
using LabApi.Features.Wrappers;
4+
using SecretAPI.Features.UserSettings;
45
using UnityEngine;
56

67
/// <summary>
7-
/// Example setting to use during testing.
8+
/// Example setting for keybinds.
89
/// </summary>
9-
internal class ExampleSetting : CustomKeybindSetting
10+
public class ExampleKeybindSetting : CustomKeybindSetting
1011
{
1112
/// <summary>
12-
/// Initializes a new instance of the <see cref="ExampleSetting"/> class.
13+
/// Initializes a new instance of the <see cref="ExampleKeybindSetting"/> class.
1314
/// </summary>
14-
public ExampleSetting()
15+
public ExampleKeybindSetting()
1516
: base(900, "Example Kill Button", KeyCode.G)
1617
{
1718
}
@@ -20,7 +21,7 @@ public ExampleSetting()
2021
public override CustomHeader Header { get; } = CustomHeader.Examples;
2122

2223
/// <inheritdoc />
23-
protected override CustomSetting CreateDuplicate() => new ExampleSetting();
24+
protected override CustomSetting CreateDuplicate() => new ExampleKeybindSetting();
2425

2526
/// <inheritdoc />
2627
protected override void HandleSettingUpdate(Player player)

SecretAPI.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Microsoft Visual Studio Solution File, Format Version 12.00
33
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecretAPI", "SecretAPI\SecretAPI.csproj", "{7B4B7EEF-17DE-40AD-B3F2-53117CAA5B9C}"
44
EndProject
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecretAPI.Examples", "SecretAPI.Examples\SecretAPI.Examples.csproj", "{0064C982-5FE1-4B65-82F9-2EEF85651188}"
6+
EndProject
57
Global
68
GlobalSection(SolutionConfigurationPlatforms) = preSolution
79
Debug|Any CPU = Debug|Any CPU
@@ -12,5 +14,9 @@ Global
1214
{7B4B7EEF-17DE-40AD-B3F2-53117CAA5B9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
1315
{7B4B7EEF-17DE-40AD-B3F2-53117CAA5B9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
1416
{7B4B7EEF-17DE-40AD-B3F2-53117CAA5B9C}.Release|Any CPU.Build.0 = Release|Any CPU
17+
{0064C982-5FE1-4B65-82F9-2EEF85651188}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{0064C982-5FE1-4B65-82F9-2EEF85651188}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{0064C982-5FE1-4B65-82F9-2EEF85651188}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{0064C982-5FE1-4B65-82F9-2EEF85651188}.Release|Any CPU.Build.0 = Release|Any CPU
1521
EndGlobalSection
1622
EndGlobal

0 commit comments

Comments
 (0)