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
55 changes: 29 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
# Home
# 骑马与砍杀2 领主 Mod 制作文档

## Introduction to Modding
原文档: [Bannerlord Documentation](https://docs.bannerlordmodding.com/)
作者: [Bannerlord Modding](https://github.com/Bannerlord-Modding)
译者: [衣谷作坊-Oliver](mailto:munoliver007@gmail.com), [世俗骑士](mailto:843750340@qq.com),[上官云泽](mailto:1143232792@qq.com).

* [Getting Started](_intro/getting-started.md)
* [Folder Structure](_intro/folder-structure.md)
* [Advanced](_intro/advanced.md)
## Mod 制作简介

## Tutorials
* [开始](_intro/getting-started.md)
* [文件结构](_intro/folder-structure.md)
* [高级用法](_intro/advanced.md)

* [Basic C# Mod](_tutorials/basic-csharp-mod.md) (Requires a basic understanding of C#)
* [Modding Gauntlet UIs Without C#](_tutorials/modding-gauntlet-without-csharp.md) (Easy)
* [Packing your Mods for Vortex](_tutorials/packing_mods_for_vortex.md) (Easy)
* [Modifying/Adding Settlements](_tutorials/new_settlements.md) (Easy)
## 教程

* [基本C\# Mod 入门](_tutorials/basic-csharp-mod.md) \(需要一定基础的 C\#\)
* [不需要C\#的UI系统 Mod 入门](_tutorials/modding-gauntlet-without-csharp.md) \(简单\)
* [将你的mod打包上传至Vortex](_tutorials/packing_mods_for_vortex.md) \(简单\)
* [修改/增加 定居点](_tutorials/new_settlements.md) (简单)

## [C# API Documentation](_csharp-api/)

* [CampaignSystem](_csharp-api/campaignsystem/)
* [Core](_csharp-api/core/)
* [Engine](_csharp-api/engine/)
* [InputSystem](_csharp-api/inputsystem/)
* [Library](_csharp-api/library/)
* [Localization](_csharp-api/localization/)
* [战役系统](_csharp-api/campaignsystem/)
* [核心](_csharp-api/core/)
* [引擎](_csharp-api/engine/)
* [输入系统](_csharp-api/inputsystem/)
* [](_csharp-api/library/)
* [本地化](_csharp-api/localization/)
* [MountAndBlade](_csharp-api/mountandblade/)
* [Network](_csharp-api/network/)
* [PlatformService](_csharp-api/platformservice/)
* [SaveSystem](_csharp-api/savesystem/)
* [网络](_csharp-api/network/)
* [平台服务](_csharp-api/platformservice/)
* [保存系统](_csharp-api/savesystem/)
* [TwoDimension](_csharp-api/twodimension/)

## [Gauntlet Documentation](_gauntlet/)
Expand All @@ -41,10 +45,9 @@

## [XML Documentation](_xmldocs)

* [Atmosphere](_xmldocs/atmosphere.md) (.xml)
* [Cultures](_xmldocs/cultures.md) (.xml)
* [Items](_xmldocs/items.md) (.xml)
* [NPCCharacters](_xmldocs/npccharacters.md) (.xml)
* [Scene](_xmldocs/scene.md) (.xml)
* [SubModule](_xmldocs/submodule.md) (.xml)

* [环境](_xmldocs/atmosphere.md) (.xml)
* [文化](_xmldocs/cultures.md) (.xml)
* [物品](_xmldocs/items.md) (.xml)
* [NPC角色](_xmldocs/npccharacters.md) (.xml)
* [场景](_xmldocs/scene.md) (.xml)
* [子模块](_xmldocs/submodule.md) (.xml)
23 changes: 12 additions & 11 deletions _csharp-api/campaignsystem/gamemenu.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
# GameMenu

All the menus in the campaign are handled by the `GameMenuManager`. To add new menus however you must use the provided methods by the `Campaign` class.

To add a new menu use:
战役中所有的菜单选项都由`GameMenuManager`管理。你必须通过提供`Campaign`类中的方法,来加入新菜单。

加入新的菜单:
```csharp
CampaignGameStarter.AddGameMenu(string menuId, string menuText, OnInitDelegate initDelegate, MenuOverlayType overlay = MenuOverlayType.None, MenuFlags menuFlags = GameMenu.MenuFlags.none, object relatedObject = null)

delegate void OnInitDelegate(MenuCallbackArgs args);
```

The overlay defines if for example the upper right characters list is visible or not.
覆盖层(overlay)定义了例子中右上角字符列表是否可见。


To add a new option to a menu use:
为菜单加入新的选项:
```csharp
CampaignGameStarter.AddGameMenuOption(string menuId, string optionId, string optionText, OnConditionDelegate condition, OnConsequenceDelegate consequence, bool isLeave = false, int index = -1)

bool OnConditionDelegate(MenuCallbackArgs args);
void OnConsequenceDelegate(MenuCallbackArgs args);
```

You can add options to existing menus and for this the index comes in handy to insert it before other options (by default it insert at the end).

The provided condition method does double-duty as it:
* enables / disables the option (via it's return value)
* sets the icon (via the provided args)
您可以在现有菜单中添加选项。使用这个index参数时,可以方便地插入在其它选项之前(默认情况下,它会在末尾插入)。

The icon can be changed by setting `optionLeaveType` to something appropriate. The used images are found under `Mount & Blade II Bannerlord\GUI\GauntletUI\SpriteParts\ui_group1\GameMenu` and the correspondence can be viewed in `Mount & Blade II Bannerlord\Modules\Native\GUI\Brushes\GameMenu.xml`. This can of course be overrides in your own module, but additional `LeaveTypes` are not possible.
提供的条件方法(condition method)具有双重职责:
* 启用/禁用选项(通过返回值)
* 设置图标(通过提供的参数)

图标可以通过将 `optionLeaveType` 设置为恰当的值来改变。 可使用的图标在 `Mount & Blade II Bannerlord\GUI\GauntletUI\SpriteParts\ui_group1\GameMenu`目录下,相关的信息可在 `Mount & Blade II Bannerlord\Modules\Native\GUI\Brushes\GameMenu.xml`查看。 当然,你自己的模组可以重写这些东西,但是不能额外添加更多的`LeaveTypes`。
| Type | Image |
| ------------------- | ----- |
| Default | |
Expand All @@ -51,4 +52,4 @@ The icon can be changed by setting `optionLeaveType` to something appropriate. T
| WaitQuest | |
| Surrender | |
| Conversation | |
| DefendAction | |
| DefendAction | |
28 changes: 28 additions & 0 deletions _csharp-api/campaignsystem/tournamentgame.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 竞技大赛 - TournamentGame

此类用于处理比赛的参与者和固有设置,如果要修改某些行为,可能需要一个`Harmony补丁`

注意:此页面不完整,因此,如果您发现有关此主题的更多信息,请创建请求请求并添加到此不断增长的Modding文档中!

## 可访问的方法

> `protected TournamentGame(Town town, ItemObject prize = null)`

在`AddTournament`和`CreateTournament`方法之后被调用的内部方法,用来设置奖品

## 可访问的属性

|属性名|描述|
|--|--|
|public const int `ParticipantNumber`|参加人数,目前已硬编码为16,但可以修补|
|public Town `Town`|比赛所在地|
|public CampaignTime `CreationTime`|比赛的创建时间|
|public QualificationMode `Mode`|资格模式“TeamScore(团体得分)”或“ IndividualScore(个体得分)”均可更改|
|public virtual int `MaxTeamSize`|比赛每个阶段的团队人数上限|
|public virtual int `MaxTeamNumberPerMatch`|在比赛的每个阶段中,每场比赛的最大团队数|
|public ItemObject `Prize`|比赛的奖金|
|public virtual float `TournamentWinRenown`|赢得比赛赢得了声誉|
|public static List\<CharacterObject\> GetParticipantCharacters(Settlement `settlement`, int `maxParticipantCount`, bool `includePlayer` = true, bool `includeHeroes` = true )|此方法定义比赛开始时的参与者,在玩家参加比赛或模拟比赛时调用|
|public abstract TextObject GetMenuText()|加入比赛时,此方法定义菜单上的文本|
|public abstract void OpenMission(Settlement `settlement`, bool `isPlayerParticipating`)|在开始比赛/模拟时有玩家参与时调用此方法|
|public void PrepareForTournamentGame(bool `isPlayerParticipating`)|在开始比赛/模拟时有玩家参与时调用此方法|
7 changes: 3 additions & 4 deletions _csharp-api/core/basiccharacterobject.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# BasicCharacterObject

BasicCharacterObjects contain the deserialized information from the `npccharacters` XML file. This includes the BodyProperties, Equipment, Level, Skills, and Culture for each defined character.
`BasicCharacterObjects` 包含了 `npccharacters` XML 文件中的反序列化信息。每个被定义的角色有 `BodyProperties`, `Equipment`, `Level`, `Skills`, 和 `Culture` 信息。

BasicCharacterObjects are used as the building blocks for [Agents](../mountandblade/agent.md).
`BasicCharacterObjects` 一般用来构建 [Agents](../mountandblade/agent.md) 的区块。

You can use the [MBObjectManager](mbobjectmanager.md) to get a loaded BasicCharacterObject by using the following:
你可以用 [MBObjectManager](mbobjectmanager.md) 来获取一个加载后的 `BasicCharacterObject` ,代码如下:

```csharp
MBObjectManager.Instance.GetObject<BasicCharacterObject>("example_troop_id");
```

6 changes: 3 additions & 3 deletions _csharp-api/core/informationmanager.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# InformationManager

The information manager is a high-level way to print text to the chat log (e.g. damage) or to display an inquiry to the player (e.g. yes/no confirmation).
InformationManager是一种向提示信息(例如:伤害)输出文本,或者向玩家显示提问(例如:是/否 确认)的的高级手段。

## Outputting to Chat Log
## 输出至提示信息

```csharp
InformationManager.DisplayMessage()
```

## Displaying an Inquiry
## 显示提问

```csharp
InformationManager.ShowInquiry()
Expand Down
12 changes: 6 additions & 6 deletions _csharp-api/engine/gameentity.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# GameEntity

GameEntities are objects (entities) in the game. Examples include characters, buildings, trees, and horses to name a few. Every prop in the game is a GameEntity.
游戏实体 `GameEntity` 指的是游戏里的对象\(或称之为实体\)。举几个例子:角色,建筑,树木,马匹……等等等等。凡是游戏里出现的每个物件都是一个游戏实体。

GameEntities contain Meshes, Skeletons, PhysicsBodies, and ScriptComponents along with a variety of other things for each object in the game.
每一个游戏实体,包含了:网格\(`Mesh`\),骨架\(`Skeleton`\),刚体\(`PhysicsBody`\),脚本组件\(`ScriptComponent`\)以及各种游戏里的对象附带的其他内容。

You can add a GameEntity to a scene by editing the [Scene](../../_xmldocs/scene.md)'s `scene.xscene` file or spawn (instantiate) one directly using the following static method from the GameEntity class:
要向场景里添加一个游戏实体,除了通过编辑场景\([Scene](../../_xmldocs/scene.md)\)文件`scene.xscene`外,也可以直接通过`GameEntity`类的静态方法`Instantiate`“刷出”\(实例化出\)一个,比如:

```csharp
GameEntity.Instantiate(Scene scene, string prefabName, MatrixFrame frame)
```

Example Usage (spawning at main [Agent](../mountandblade/agent.md)):
另一个例子,往`main [Agent]`(../mountandblade/agent.md)里生成一个物体。\(注:`Agent`负责处理活物\)

```csharp
GameEntity.Instantiate(Mission.Current.Scene, "ship_a", Agent.Main.Frame)
```

## Multiplayer GameEntities
## 多人模式中的游戏实体

Some GameEntities will not be synced between Clients, unless a SynchedMissionObject ScriptComponent is added.
某些游戏实体无法在玩家的客户端之间同步,因此你需要自己往脚本组件\(`ScriptComponent`\)里添加 `SynchedMissionObject`。

8 changes: 4 additions & 4 deletions _csharp-api/inputsystem/input.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Input

This static type provides you with input functionality, the base input system has no events to bind to and supports polling only. It's largely self explanatory with a few possible gotchas.
`Input`这个静态类型用来提供输入功能。基本的输入系统并不是基于事件绑定的,而是采用轮询的方式。这部分内容比较直观,一般来说看函数名就知道用法,但也会有几个坑。

## Key Polling
## 按键轮询

`GetKeyDown(KeyCode)` | `GetKeyPressed(KeyCode)` | `GetKeyReleased(KeyCode)` - These are likely to be the most commonly used methods, `GetKeyDown` will return true on any number of frames so long as a key is down, this can cause undesired behaviour. If you only want to read an input once, use `GetKeyPressed` or `GetKeyReleased`.
`GetKeyDown(KeyCode)` | `GetKeyPressed(KeyCode)` | `GetKeyReleased(KeyCode)` - 这几个貌似是最常用的方法了。 关于 `GetKeyDown` 请注意:只要键盘按键处于按下状态,程序就会在每一帧持续不断地返回`true`,显然这会导致运行一些不必要的方法\(造成资源浪费\)。假如你只想触发一次按键操作,可以用`GetKeyPressed` 或者 `GetKeyReleased`

You can also use the extension methods `IsDown`/`IsPressed`/`IsReleased` like so `KeyCode.A.IsPressed()`
还有几个扩展方法也可以达到按键的效果:`IsDown`/`IsPressed`/`IsReleased`。用法如: `KeyCode.A.IsPressed()`
8 changes: 3 additions & 5 deletions _csharp-api/library/moduleinfo.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# ModuleInfo

The ModuleInfo class contains information about each module.
`ModuleInfo`类里放的是Mod的详细资料。


You can get a list of all **loaded** mods with detailed information about them (their ModuleInfo) by doing something like this:
我们可以把所有**已加载**的Mod的详细资料\(它们各自的`ModuleInfo`\)读取到一个列表`List`里面如:

```csharp
var loadedMods = new List<ModuleInfo>();
Expand All @@ -14,6 +13,5 @@ foreach(var moduleName in Utilities.GetModulesNames())
loadedMods.Add(moduleInfo);
}
```
The Utilities class is part of the Talewords.Engine namespace, and the GetModulesNames() function returns a list of all the names of loaded modules.

This could be used to determine whether a module has been loaded or not, which is useful for mods that have optional dependencies.
通过这个方法,我们随后可以用来判断某个Mod加载了没有。当Mod之间存在依赖关系,但又是非必须的依赖关系时会很有用。
9 changes: 4 additions & 5 deletions _csharp-api/mountandblade/agent.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Agent

You can think of an agent as any **living** entity in the game.
你可以把媒介(`agent`)想象成游戏里任何**能走动**的实体。

This might be the player, an NPC character, or even a horse.
比方说可以是玩家,NPC,甚至是一匹马。

## Tips

* You can get the player agent through the `Agent.Main` property (assuming they are alive).
## 小贴士

* 你可以通过`Agent`下的`Agent.Main` 属性调用玩家媒介\(前提是玩家还活着\)。
7 changes: 3 additions & 4 deletions _csharp-api/mountandblade/mbinitialscreenbase.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# MBInitialScreenBase

You can create a custom title screen by inheriting from MBInitialScreenBase and then applying the GameStateScreen attribute to your class.
想要创建一个自定义的开场画面,你可以写一个MBInitialScreenBase的派生类,然后让这个类采用`GameStateScreen`属性。

Here is a skeleton of what your inherited class should look like:
这个派生类的写法,可以参考以下例子:

```csharp
[GameStateScreen(typeof(InitialState))]
Expand All @@ -28,5 +28,4 @@ public class MyInitialScreen : MBInitialScreenBase
}
```

Replace the string `InitialScreen` with the name of your [Movie](../../_gauntlet/movie.md)'s XML file.

然后把类名中的 `InitialScreen` 替换成相应的[影片](../../_gauntlet/movie.md)XML文件的文件名。
Loading