Stardew Valley(星露谷物语)Mod开发之路 1环境配置
首先來(lái)說(shuō)明一下,我寫(xiě)這個(gè)章節(jié)本身也是對(duì)學(xué)習(xí)過(guò)程的記錄,主要參考了http://canimod.com/guides/creating-a-smapi-mod中的內(nèi)容。也推薦大家看看。
*這些是我的開(kāi)發(fā)環(huán)境*
操作系統(tǒng):
macOS
SDK:
? ? ?1?MonoFramework-MDK-4.6.2.16.macos10.xamarin.universal.pkg?(貌似是.net平臺(tái))
? 2?XamarinStudio-6.1.2.44.dmg?(這個(gè)應(yīng)該是IDE)
ps:具體的版本依照實(shí)際的操作系統(tǒng)來(lái)定,或者安裝vs。同時(shí)你也可以向上面那個(gè)英文教程學(xué)習(xí)~?
*正式*
然而在正式配置環(huán)境之前,是的,你得保證游戲正常運(yùn)行。然后依次安裝上面兩個(gè)軟件(我相信這是一個(gè)很容易的過(guò)程,謝謝)。
*創(chuàng)建一個(gè)項(xiàng)目*
&恩,詳細(xì)過(guò)程我還是直接借用過(guò)來(lái)翻譯一下算了~
?
- 在 Visual Studio中, 選擇?Visual C# ? Class Library. (確保你選擇的是 “Class Library”,?而不是 “Class Library (.NET Core)” 或者 “Class Library (Portable)”.)
- 在 MonoDevelop中, 選擇?Other ? .NET ? Library.
- 在 Visual Studio中: 右鍵 project, 選擇?Properties, 單擊Application?標(biāo)簽, 并且將?Target framework?dropdown 選成?.NET Framework 4.5.
- 在 MonoDevelop中: 右鍵 project, 選擇?Options, 單擊 the?Build ? General?標(biāo)簽, 并且將Target framework?dropdown 選成?Mono / .NET 4.5.
ps:按照上面步驟,我這里新建了一個(gè)solution和project名稱都為firstMod的項(xiàng)目。需要注意后面的一些配置信息要與這里對(duì)應(yīng)
?
*配置項(xiàng)目*
項(xiàng)目需要引用這個(gè)包?Pathoschild.Stardew.ModBuildConfig?NuGet package. 它能夠自動(dòng)配置你的項(xiàng)目,針對(duì)當(dāng)前的平臺(tái),正確加載合適的依賴庫(kù)。
1.雙擊下圖畫(huà)圈的部分
2.彈出了如下界面,然后在搜索框中“Pathoschild.Stardew.ModBuildConfig”,安裝并等待完成。
? ? ? 3.添加一個(gè)cs文件,名稱 “ModEntry”
4.將如下內(nèi)容復(fù)制進(jìn)ModEntry.cs
1 using System; 2 using Microsoft.Xna.Framework; 3 using StardewModdingAPI; 4 using StardewModdingAPI.Events; 5 using StardewValley; 6 7 namespace firstMod 8 { 9 /// <summary>The mod entry point.</summary> 10 public class ModEntry : Mod 11 { 12 /// <summary>Initialise the mod.</summary> 13 /// <param name="helper">Provides methods for interacting with the mod directory, such as read/writing a config file or custom JSON files.</param> 14 public override void Entry(IModHelper helper) 15 { 16 ControlEvents.KeyPressed += this.ReceiveKeyPress; 17 } 18 19 /********* 20 ** Private methods 21 *********/ 22 /// <summary>The method invoked when the player presses a keyboard button.</summary> 23 /// <param name="sender">The event sender.</param> 24 /// <param name="e">The event data.</param> 25 private void ReceiveKeyPress(object sender, EventArgsKeyPressed e) 26 { 27 this.Monitor.Log($"Player pressed {e.KeyPressed}."); 28 } 29 } 30 } View Code? 5.創(chuàng)建manifest.json文件,內(nèi)容如下,存放至工程目錄下,其實(shí)位置無(wú)所謂,主要是最終應(yīng)該放在游戲mod的目錄下
{"Name": "firstMod","Author": "iamfine","Version": {"MajorVersion": 1,"MinorVersion": 0,"PatchVersion": 0,"Build": ""},"Description": "獲取按鍵消息","UniqueID": "iamfine.firstMod","EntryDll": "firstMod.dll" }6.編譯整個(gè)工程后得到如下文件
7.將firstMod.dll 和 manifest.json兩個(gè)文件復(fù)制到游戲的Mods目錄下,如下圖所示。
? ps:安裝smapi后,在macOS下,mod的目錄是
/Users/huqian/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/Mods?
8.運(yùn)行游戲后,這個(gè)mod會(huì)記錄玩家在游戲界面中的按鍵信息,如下圖。
?
轉(zhuǎn)載于:https://www.cnblogs.com/Dream-Chaser/p/6377946.html
總結(jié)
以上是生活随笔為你收集整理的Stardew Valley(星露谷物语)Mod开发之路 1环境配置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Mycloud 安装 SVN 折腾笔记1
- 下一篇: Mac电脑怎么使用ping命令?