Files
bd2/plugins/GameSdk/samples/ExamplePlugin/Plugin.cs
T
Flechazo 992fa47fd5 feat(all): add game SDK and harden client login and game rules
- Add costume burst upgrades with durable replay and fix permanent SR equipment gacha.
- Add server game.json rules for optional collaboration UR weapons, with packaging and documentation.
- Add GameNames/GameSdk NuGet tooling, readable types, reobfuscation, complete source/PDB navigation and shared-runtime installation.
- Split plugin responsibilities, prefer typeof/nameof, centralize MSBuild settings and ignore local paths; remove the unused LoginUI test project.
- Fix login recovery and TLS through native platform HTTP and a private game relay; read device region directly from the OS time zone.

Validation: go test ./... -count=1, go vet ./..., plugin Release builds, SDK/runtime self-tests, Roslyn embedded-source navigation, gofmt check and git diff --check.
2026-10-03 23:04:32 +08:00

39 lines
1.4 KiB
C#

using System;
using System.Reflection;
using BD2.GameNames;
using BepInEx;
using HarmonyLib;
namespace ExamplePlugin;
[BepInPlugin("example.readable-names", "Readable Names Example", "1.0.0")]
public sealed class Plugin : BaseUnityPlugin
{
private Harmony harmony;
private void Awake()
{
try
{
// Fail before installing any game patches when binary/table/plugin versions differ.
Game.Validate(typeof(Plugin).Assembly, message => Logger.LogInfo(message));
MethodInfo target = Game.Method<IntroUI>(ui => ui.SendMaintenanceInfo(false));
harmony = new Harmony("example.readable-names");
harmony.Patch(target, prefix: new HarmonyMethod(typeof(Plugin), nameof(BeforeMaintenance)));
// Private members require the runtime string channel. The prefix expression above
// and the Unity callback name below belong to separate channels.
var awake = typeof(IntroUI).GetGameMethod("Awake",
BindingFlags.Instance | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
Logger.LogInfo("Resolved IntroUI.Awake: " + (awake != null));
}
catch (Exception exception)
{
Logger.LogError("Readable Names Example initialization failed: " + exception);
}
}
private static void BeforeMaintenance() { }
private void OnDestroy() => harmony?.UnpatchSelf();
}