1.2 配置C#项目

一、新建项目

1.下载并安装visual studio

IDE选择visual studio的原因是不需要任何其他的处理和配置,如果用vscode的话,环境插件什么的配置起来比较麻烦。

2.新建类库(.NET Framework)项目

需要选择.NET Framework 4.7.2,如果不能选择,需要去官网下载一个开发者包。

3. 设置构建路径(输出路径)

1.右键项目选择属性 2.配置输出路径 输出路径设置为你的mod目录下(MyMoudle为你的mod目录) Modules/MyModule/bin/Win64_Shipping_Client 3.引用游戏目录(不是你自己的Modules目录)下的所有TaleWorlds.* DLLs 文件。并且引用每个官方模组的 TaleWorlds.* DLLs文件

PS: 不要引用TaleWorlds.native.dll,这个文件不是C#DLL文件,会引用失败

4.配置项目Debug

1.依然右键项目选择属性,切换到调试tab,选择启动外部程序,选择游戏目录下的bin/Win64_Shipping_Client文件夹下的TaleWorlds.MountAndBlade.Launcher.exe

2.设定工作目录为bin\Win64_Shipping_Client

3.添加命令行参数(替换MyModule为你的模组名称) /singleplayer MODULES Native SandBoxSandBoxCore StoryModeCustomBattle MyModule*MODULES

5.编写一个测试demo

1.返回并打开你新建的.Net项目并编写如下代码

c# 复制代码
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.Localization;
using TaleWorlds.MountAndBlade;

namespace Isauria
{
  public class Main : MBSubModuleBase
  {
    protected override void OnSubModuleLoad()
    {
      Module.CurrentModule.AddInitialStateOption(new InitialStateOption("Message", new TextObject("消息", null), 9990, () =>
      {
        InformationManager.DisplayMessage(new InformationMessage("Hello World"));
      }, () =>
      {
        return (false, null);
      }));
    }
  }
}

这段代码的用处是在主菜单添加一个叫消息的按钮,然后点击的时候左下角会出现一行字hello world。

2.重新编辑你的mod下的SubModule.xml文件

xml 复制代码
<Module>
  <Name value="Isauria"/>
  <Id value="Isauria"/>
  <Version value="v1.0.0"/>
  <SingleplayerModule value="true"/>
  <MultiplayerModule value="false"/>
  <DependedModules>
    <DependedModule Id="Native"/>
    <DependedModule Id="SandBoxCore"/>
    <DependedModule Id="Sandbox"/>
    <DependedModule Id="CustomBattle"/>
    <DependedModule Id="StoryMode" />
  </DependedModules>
  <SubModules>
    <SubModule>
      <Name value="Isauria"/>
      <DLLName value="Isauria.dll"/>
      <SubModuleClassType value="Isauria.Main"/>
      <Tags>
        <Tag key="DedicatedServerType" value="none" />
        <Tag key="IsNoRenderModeElement" value="false" />
      </Tags>
    </SubModule>
  </SubModules>
  <Xmls/>
</Module>

其中SubModuleClassType中的value需要设置为你mod中刚刚创建的那个类,因此我这里是Isauria.dll

3.接下来右键项目启动调试并勾选你的Mod,接着启动游戏 这样你的mod就算是创建成功了

相关推荐
Thomas游戏开发14 分钟前
Unity3D 自动化游戏框架设计
前端框架·unity3d·游戏开发
oyishyi1 小时前
从零开始独立游戏开发学习笔记(七十八)--绘画/像素画学习笔记(十五)--V大预科3.0(五)-第三,四周理论
游戏·游戏开发
LeeAt1 天前
《谁杀死了比尔?》:使用Trae完成的一个推理游戏项目!!
前端·游戏开发·trae
龙智DevSecOps解决方案1 天前
游戏开发中的CI/CD优化案例:知名游戏公司Gearbox使用TeamCity简化CI/CD流程
ci/cd·游戏开发·jetbrains·teamcity
一名用户2 天前
unity实现自定义粒子系统
c#·unity3d·游戏开发
技术小甜甜4 天前
【Blender Texture】【游戏开发】高质感 Blender 4K 材质资源推荐合集 —— 提升场景真实感与美术表现力
blender·游戏开发·材质·texture
Thomas游戏开发4 天前
Unity3D TextMeshPro终极使用指南
前端·unity3d·游戏开发
Thomas游戏开发5 天前
Unity3D 逻辑代码性能优化策略
前端框架·unity3d·游戏开发
Thomas游戏开发6 天前
Unity3D HUD高性能优化方案
前端框架·unity3d·游戏开发
陈哥聊测试7 天前
游戏公司如何同时管好上百个游戏项目?
游戏·程序员·游戏开发