Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,37 @@ on: [ "push", "pull_request" ]

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2
- uses: actions/cache@v4
with:
path: |
~/.nuget/packages
~/.cache/bepinex
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.x

- name: Run the Cake script
uses: cake-build/cake-action@v1
with:
verbosity: Diagnostic
- name: Build
run: dotnet build PeasAPI/PeasAPI.csproj --configuration Release

- uses: actions/upload-artifact@v2
- name: Upload PeasAPI
uses: actions/upload-artifact@v4
with:
name: PeasAPI.dll
path: PeasAPI/bin/Release/netstandard2.1/PeasAPI.dll

- uses: actions/upload-artifact@v2
path: PeasAPI/bin/Release/net6.0/PeasAPI.dll

- name: Upload PeasAPI.nupkg
uses: actions/upload-artifact@v4
with:
name: PeasAPI.nupkg
path: PeasAPI/bin/Release/PeasAPI.*.nupkg
path: PeasAPI/bin/Release/PeasAPI-R.*.nupkg
80 changes: 12 additions & 68 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

.idea/

# User-specific files
*.rsuser
*.suo
Expand All @@ -13,9 +15,6 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Mono auto generated files
mono_crash.*

# Build results
[Dd]ebug/
[Dd]ebugPublic/
Expand All @@ -29,7 +28,6 @@ bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand All @@ -43,10 +41,9 @@ Generated\ Files/
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUnit
# NUNIT
*.VisualState.xml
TestResult.xml
nunit-*.xml

# Build Results of an ATL Project
[Dd]ebugPS/
Expand Down Expand Up @@ -127,6 +124,9 @@ _ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

Expand Down Expand Up @@ -184,8 +184,6 @@ PublishScripts/

# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
Expand All @@ -210,8 +208,6 @@ BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload

# Visual Studio cache files
# files ending in .cache can be ignored
Expand Down Expand Up @@ -261,9 +257,7 @@ ServiceFabricBackup/
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
*- Backup*.rdl

# Microsoft Fakes
FakesAssemblies/
Expand Down Expand Up @@ -299,6 +293,10 @@ paket-files/
# FAKE - F# Make
.fake/

# JetBrains Rider
.idea/
*.sln.iml

# CodeRush personal settings
.cr/personal

Expand Down Expand Up @@ -341,58 +339,4 @@ ASALocalRun/
.localhistory/

# BeatPulse healthcheck temp database
healthchecksdb

# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/


# Jetbrains Resharper/Rider

# Common IntelliJ Platform excludes

# User specific
**/.idea/

# Sensitive or high-churn files
**/.idea/**/dataSources/
**/.idea/**/dataSources.ids
**/.idea/**/dataSources.xml
**/.idea/**/dataSources.local.xml
**/.idea/**/sqlDataSources.xml
**/.idea/**/dynamic.xml

# Rider
# Rider auto-generates .iml files, and contentModel.xml
**/.idea/**/*.iml
**/.idea/**/contentModel.xml
**/.idea/**/modules.xml

*.suo
*.user
.vs/
[Bb]in/
[Oo]bj/
_UpgradeReport_Files/
[Pp]ackages/

Thumbs.db
Desktop.ini
.DS_Store



# Visual Studio Code

.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/
healthchecksdb
8 changes: 2 additions & 6 deletions PeasAPI/Components/RegisterCustomGameModeAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.Reflection;
using BepInEx.IL2CPP;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using PeasAPI.GameModes;
using Reactor;

namespace PeasAPI.Components
{
Expand Down Expand Up @@ -38,10 +37,7 @@ public static void Register(Assembly assembly, BasePlugin plugin)

public static void Load()
{
ChainloaderHooks.PluginLoad += plugin =>
{
Register(plugin.GetType().Assembly, plugin);
};
IL2CPPChainloader.Instance.PluginLoad += (pluginInfo, assembly, plugin) => Register(assembly, plugin);
}
}
}
14 changes: 7 additions & 7 deletions PeasAPI/Components/RegisterCustomRoleAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.Reflection;
using BepInEx.IL2CPP;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using PeasAPI.Roles;
using Reactor;

namespace PeasAPI.Components
{
Expand All @@ -20,26 +19,27 @@ public static void Register(Assembly assembly, BasePlugin plugin)
{
foreach (var type in assembly.GetTypes())
{
var attribute = type.GetCustomAttribute<RegisterCustomRoleAttribute>();
var attribute = type.GetCustomAttribute<RegisterCustomRoleAttribute>();

if (attribute != null)
{
if (!type.IsSubclassOf(typeof(BaseRole)))
{
throw new InvalidOperationException($"Type {type.FullDescription()} must extend {nameof(BaseRole)}.");
throw new InvalidOperationException(
$"Type {type.FullDescription()} must extend {nameof(BaseRole)}.");
}

if (PeasAPI.Logging)
PeasAPI.Logger.LogInfo($"Registered role {type.Name} from {type.Assembly.GetName().Name}");

Activator.CreateInstance(type, plugin);
}
}
}

public static void Load()
{
ChainloaderHooks.PluginLoad += plugin => Register(plugin.GetType().Assembly, plugin);
IL2CPPChainloader.Instance.PluginLoad += (pluginInfo, assembly, plugin) => Register(assembly, plugin);
}
}
}
Loading