FTKAPI
Provides common logic for other plugins
模組介紹 作者原文
For The King API (FTKAPI) - Modding Library
FTKAPI is a work-in-progress modding framework to aid developers in creating For The King mods, by providing centralized and simplified APIs for the game.
Documentation
There is a provided example plugin(s) made with the use of the library located in the Examples folder.
Features
Objects
- CustomItem
Can create an item with full custom functionality or inherit functionality from existing items (herbs, orbs, armor, weapons).
- CustomClass
Can create a character class with full custom functionality or inherit functionality from existing classes (blacksmith, hunter, etc.).
- CustomLocalizedString
Can create a string/text that supports additional languages.
Managers
- AssetManager
Allows importing custom assets such as models and images, to be used with custom or existing GameObjects.
- ItemManager
Allows the modification and addition of items. As simple as.AddItem(new CustomItem());!
- ClassManager
Allows the modification and addition of classes. As simple as.AddClass(new CustomClass());!
- NetworkManager
Allows registering custom objects with network connectivity. Example below.
- PluginConfigManager
Allows plugins to add configuration entry directly into game menu. Example below.
Networking
When using NetworkManager, you can register object that can be instantiated on your and other clients side and have working communication between users. Simplest way to do that is to use RPC-commands through your custom inheritor of PunBehavior class. Here is example of such implementation:
// MyPluginRpc.cs
class MyPluginRpc: PunBehavior
{
public void Start()
{
if (PhotonNetwork.IsMasterClient)
{
SendMessage("Hello from master client");
}
}
public void SendMessage(string message)
{
this.photonView.RPC("SendMessagePRC", PhotonTargets.Others, message);
}
[PunRPC]
public void SendMessagePRC(string message)
{
Logger.LogInfo($"Received '{message}'!");
}
}
Then, you can register GameObject that would have this Component. Empty GameObject is created by default, so you just have to add necessary components. This function will be called on both sides during creation.
NOTE: you can modify this GameObject in any way you want, but in order for RPC component to work, it's parent GameObject should have PhotonView which is populated by default.
NOTE: you shouldn't create a lot of there objects. Ideally it should be one per plugin.
// during plugin initialization
NetworkManager.RegisterNetObject("MyPluginGuid.SyncObject",
gameObject => gameObject.AddComponent(),
new () { SpawnOnRoomCreation = false }
);
Then you can just call NetworkManager.SpawnNetworkObject with same id you provided, and this object would be instantiated and "network-enabled"!
// somewhere in-room
var networkGameObject = NetworkManager.SpawnNetworkObject("MyPluginGuid.SyncObject");
// other clients will log "Received 'Hello from master client!'" when object will be created."
Note that in example above SpawnOnRoomCreation is set to false during registration, but it is true by default. So if you don't provide options, you don't have to create it manually.
You can read more about network synchronization FTK uses in the official Photon reference:
In-Game configuration
Allows plugins to add configuration entry directly into game menu.
// create BepInEx config entry
var entry = Config.Bind("MySection", "MyConfigKey", "MyDescription", defaultValue: 42);
// add entry to conifguration screen
PluginConfigManager.RegisterBinding(entry);
NOTE: In order for options to be saved automatically, you'll need to set Config.SaveOnConfigSet = true; somewhere in your code.
You can also create your custom configuration entries that aren't explicitly tied to BepInEx configurations by implementing IConfigurableEntry interface or use CustomConfigurableEntry.
PluginConfigManager.Instance.RegisterSingleBinding(new CustomConfigurableEntry() {
Key = "MyConf
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。
下面這些內容需要先安裝,否則該模組不會生效: