MoCore

版本 v2.0.3·更新於 2025-08-21

Common plugin across MoSadie's plugins

模組介紹 作者原文

MoCore

A common plugin used across my other BepInEx plugins.

Setup

Add the dll

Download the latest version from the release page and place it into a lib folder with your code. Add the following to your.csProj file:...

lib/com.mosadie.mocore.dll

In your main Plugin class

Have the plugin class implement IMoPlugin and call MoCore.RegisterPlugin and pass itself. The plugin should also make use of the BepInDependency attribute to make sure it loads after MoCore.

Example of the attribute:

[BepInDependency("com.mosadie.mocore", BepInDependency.DependencyFlags.HardDependency)]

Example of version checking in Awake:

if (!MoCore.MoCore.RegisterPlugin(this))

{

Log.LogError("Failed to register plugin with MoCore. Please check the logs for more information.");

return;

}

Make sure to mark as dependencies as well

If using the tcli here is how it looks.yml

[package.dependencies]

BepInEx-BepInExPack= "5.4.2100"

MoSadie-MoCore= "2.0.0"

Features

Game Version Checking

Return a url to a json file from GetVersionCheckUrl and you can use the return value of RegisterPlugin to determine if the game version supports your plugin.

Pass null for the GetVersionCheckUrl to disable online version checking. Pass null for the GetCompatibleGameVersion to disable local version checking. In addition there is a configuration option in MoCore to skip version checking entirely.

Here is a example of what the version json file looks like:

{

"1.2.3": [ // Plugin version

"4.1579" // Application.version value (printed in console by MoCore on launch for easy access)

]

}

Centralized HTTP server

This allows plugins to listen for HTTP requests without having to worry about port conflicts. To use this, return an object that implements IMoHttpHandler from the new GetHttpHandler method in your plugin. The server will call this object when a request comes in, and your code can modify the response from there.

If you don't want to use this system, just have GetHttpHandler return null.

To prevent path conflicts, paths are prefixed with an identifier of your choice, for example: With the prefix mocore a valid url would be

Variable System

This allows strings with variables in them to be parsed and replaced with their values. This is also available via the HTTP server, for those feeling fancy. (Path is /mocore/variable/parse with the query parameter string set to the string you want to parse)

To use this, call VariableHandler.ParseVariables with the string you want to parse. The variables are in the format $variable and can be replaced with their values. For example, if you have a variable called name, you can use $name in your string and it will be replaced with the value of the variable.

Crew Variables:

  • $captain: The display name of the Captain
  • $randomCrew[id]: A random crew member's name, replace [id] to keep it consistent in the message (ex $randomCrew1)
  • $crew[id]: The crew member with that numeric id, replace [id] with a number (ex $crew0)

Fight Variables:

(These will be blank if no fight is occurring)

  • $enemyName: The name of the enemy ship
  • $enemyIntel: The intel of the enemy ship
  • $enemyInvaders: The invaders from the enemy ship
  • $enemyThreat: The threat level of the enemy ship
  • $enemySpeed: The speed of the enemy ship
  • $enemyCargo: The cargo of the enemy ship

Run Variables:

  • $campaignName: The name of the campaign (ex Pluto)
  • $sectorName: The name of the sector (ex Pluto Outskirts)

Misc Variables:

  • $version: The version of MoCore (mainly for debugging purposes, no real purpose)

安裝與使用 安裝:按包內說明操作

  1. 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
  2. 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
  3. 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
  4. 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。

不同模組的安裝位置差異較大,包內說明是最可靠的依據。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

BepInEx-BepInExPack

檔案與校驗

檔案名稱
MoCore-2.0.3.zip
檔案大小
13.9 KiB