Skip to content

Commit

Permalink
sync 04-22
Browse files Browse the repository at this point in the history
  • Loading branch information
WuZhuoran committed Apr 22, 2020
1 parent ca84e53 commit a8da0c3
Show file tree
Hide file tree
Showing 38 changed files with 1,021 additions and 1,038 deletions.
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 | |
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文件的文件名。
59 changes: 29 additions & 30 deletions _csharp-api/mountandblade/mbsubmodulebase.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
# MBSubModuleBase

You can inherit from the MBSubModuleBase class to handle the loading of your module, it is essentially the entry point to your code. There are several useful overrides, such as `OnSubModuleLoad()` and `OnApplicationTick()` that you can make use of.
你可以通过继承 `MBSubModuleBase ` 来处理MOD的加载,可以说这是你MOD的入口。这个类中有一些很有用的重载,比如 `OnSubModuleLoad()` `OnApplicationTick()`

**It is important to note that you must reference the class' fully qualified name in the module's `SubModule.xml` for this to work properly.**
**一定注意在 `SubModule.xml` 里写上正确完整的类名,不然运行时会出问题。**

Example `SubModule.xml` where `ExampleMod.MySubModule` is the fully qualified name for the class inheriting MBSubModuleBase: [SubModule.xml](../../_xmldocs/submodule.md)
这是一个例子([SubModule.xml](../../_xmldocs/submodule.md)):例中的 `ExampleMod.MySubModule` 就是一个正确的类名。

## Overrides
## 可重载的函数

This is the full list of available overrides, in (generally) the order in which they are called. This is a rough guide and is not a substitute for debugging when you're having order-of-execution issues.
下面列出了所有可以重载的函数,并且一般情况下它们就是以这个顺序被调用。这只是一个大概的指南,当你遇到运行顺序导致的问题时,这不能取代Debug。

- `OnSubModuleLoad()` - Called during the first loading screen of the game, always the first override to be called, this is where you should be doing the bulk of your initial setup.
- `OnApplicationTick(float)` - This is called once every frame, you should avoid expensive operations being called directly here and instead do as little work as possible for performance reasons.
- `float` - The time in milliseconds the frame took to complete.
- `OnBeforeInitialModuleScreenSetAsRoot()` - Called just before the main menu first appears, helpful if your mod depends on other things being set up during the initial load.
- `OnGameStart(Game, IGameStarter)` - Called immediately upon loading after selecting a game mode (submodule) from the main menu.
- `Game` - [See: Game](../core/game.md)
- `OnSubModuleLoad()` - 游戏处于加载界面时最先被调用的函数,你应该在这个函数中完成初始化的主要部分
- `OnApplicationTick(float)` - 这个函数每一帧都会被调用一次,为了性能考虑,在这个函数中要尽量避免加入一些复杂且费时的操作
- `float` - 完成当前帧耗费的时间(毫秒)
- `OnBeforeInitialModuleScreenSetAsRoot()` - 在主菜单出现前一刻被调用的函数,当你的MOD需要加载一些别的东西的时候挺有用的
- `OnGameStart(Game, IGameStarter)` - 当用户在主菜单选择一个游戏模式(submodule)后会立刻被调用
- `Game` - [详情: Game](../core/game.md)
- `IGameStarter` - N/A
- `BeginGameStart(Game)` - Called immediately after loading the selected game mode (submodule) has completed.
- `Game` - [See: Game](../core/game.md)
- `OnGameLoaded(Game, object)` - Called only after loading a save.
- `Game` - [See: Game](../core/game.md)
- `BeginGameStart(Game)` - 当所选的游戏模式加载完成后立刻被调用
- `Game` - [详情: Game](../core/game.md)
- `OnGameLoaded(Game, object)` - 当加载了一个存档后被调用
- `Game` - [详情: Game](../core/game.md)
- `object` - N/A
- `OnCampaignStart(Game, object)` - Called once any game mode is started.
- `Game` - [See: Game](../core/game.md)
- `OnCampaignStart(Game, object)` - 当任意游戏模式启动后被调用
- `Game` - [详情: Game](../core/game.md)
- `object` - N/A
- `OnGameInitializationFinished(Game)` - Called once the initialisation for a game mode has finished.
- `Game` - [See: Game](../core/game.md)
- `DoLoading(Game)` - Called seemingly as loading is ending, not entirely sure of this one.
- `Game` - [See: Game](../core/game.md)
- `OnNewGameCreated(Game, object)` - Called when starting a new save in the campaign mode specifically.
- `Game` - [See: Game](../core/game.md)
- `OnGameInitializationFinished(Game)` - 当某个游戏模式初始化完成后被调用
- `Game` - [详情: Game](../core/game.md)
- `DoLoading(Game)` - 当加载结束时被调用,这个不是很确定
- `Game` - [详情: Game](../core/game.md)
- `OnNewGameCreated(Game, object)` - 当战役模式中开始一个新游戏时被调用
- `Game` - [详情: Game](../core/game.md)
- `object` - N/A
- `OnMissionBehaviourInitialize(Mission)` - Called once a mission is started and behaviours are to be initialized.
- `Mission` - [See: Mission](mission.md)
- `OnGameEnd(Game)` - Called on exiting out of a mission/campaign.
- `Game` - [See: Game](../core/game.md)
- `OnSubModuleUnloaded()` - Called when exiting Bannerlord entirely.

- `OnMissionBehaviourInitialize(Mission)` - 当一个任务(mission)开始后,行为(behaviours)初始化前被调用
- `Mission` - [详情: Mission](mission.md)
- `OnGameEnd(Game)` - 当退出一个任务或战役时被调用
- `Game` - [详情: Game](../core/game.md)
- `OnSubModuleUnloaded()` - 当退出游戏时被调用


- `OnMultiplayerGameStart(Game, object)` - Multiplayer related, haven't tested.
- `OnMultiplayerGameStart(Game, object)` - 多人游戏相关,未测试
- `Game` - [See: Game](../core/game.md)
- `object` - N/A
9 changes: 4 additions & 5 deletions _csharp-api/mountandblade/mission.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Mission

You can think of Missions as GameModes(Battles/TeamDeathMatch) etc. Missions are instantiated with a [Scene](../engine/scene.md), [MissionViews](missionbehaviour/missionview.md), and [MissionBehaviours](missionbehaviour/README.md).
所谓任务\(`Mission`\),可以理解成游戏模式`GameMode`(如战场`Battle`,死斗`TeamDeathMatch`之类)。当任务实例化的时候,同时还会生成的实例有:场景[Scene](../engine/scene.md),任务视图[MissionViews](missionbehaviour/missionview.md),还有任务行为[MissionBehaviours](missionbehaviour/README.md)

More information on missions will be available once we gain access to the `CampaignSystem` DLLs.
更多关于任务的相关信息,要等我们\(文档原作者\)获得`CampaignSystem`的DLL的访问权。

## Tips

* You can get the current mission instance (if any) by using `Mission.Current` property.
## 小贴士

* 你可以通过 `Mission.Current` 属性获取当前任务下的实例\(假如有任何实例的话\)
Loading

0 comments on commit a8da0c3

Please sign in to comment.