ShopUtils

版本 v1.0.8·更新於 2024-04-14

A library for adding new items to ContentWarning

模組介紹 作者原文

ShopUtils

A library for adding new items to ContentWarning

Start

Before use, you need to download ContentWarningUnityTemplate

Features API

  • Items API
  • ItemSpawn API
  • ItemDataEntry API
  • Language API
  • Network API

How To Use

Plugin

[BepInPlugin(ModGUID, ModName, ModVersion)]

[BepInDependency("hyydsz-ShopUtils")]

public class Example: BaseUnityPlugin {

}

Items API

void Awake() {

// RegisterShopItem(Item item, ShopItemCategory category = ShopItemCategory.Invalid, int price = -1)

Items.RegisterShopItem(Item: item);

}

ItemSpawn API

If you want your item to random in the map:

void Awake() {

// RegisterSpawnableItem(Item item, float Rarity = 1, int BudgetCost = 1)

Items.RegisterSpawnableItem(Item: item);

}

ItemDataEntry API

if your item need to save some data

Example:

public class ExampleEntry: ItemDataEntry, IHaveUIData

{

public int example = 0;

public override void Deserialize(BinaryDeserializer binaryDeserializer)

{

example = binaryDeserializer.ReadInt();

}

public override void Serialize(BinarySerializer binarySerializer)

{

binarySerializer.WriteInt(example);

}

public string GetString()

{

return "UI String";

}

}

In Awake:

void Awake() {

Entries.RegisterAll();

// or

Entries.RegisterEntry(typeof(ExampleEntry));

}

Language API

Available Languages:

  • Chinese (Simplified) (zh-Hans)
  • Chinese (Traditional) (zh-Hant)
  • English (en)
  • French (fr)
  • German (de)
  • Italian (it)
  • Japanese (ja)
  • Portuguese (Brazil) (pt-BR)
  • Russian (ru)
  • Spanish (es)
  • Ukrainian (uk)
  • Korean (ko)
  • Swedish (sv)

Example:

void Awake() {

// If your item name is Test

// Splite by ';'

Locale English = Languages.GetLanguage(LanguageEnum.English);

English.AddLanguage("Test-ToolTips", "[LMB] Use;[RMB] Aim"); // ToolTips

English.AddLanguage("Test", "Name is Test"); // Item DisplayName

// or

Locale English = Languages.GetLanguage(LanguageEnum.English);

English.AddLanguage(

new LanguageInstance("Test-ToolTips", "[LMB] Use;[RMB] Aim"), // ToolTips

new LanguageInstance("Test", "Name is Test"), // Item DisplayName

);

// You can get current Language

if (Languages.TryGetLanguage("Test", out string language)) {

}

}

Network API

You can use MyceliumNetworking instead

Example:

void Awake() {

// Everyone can synchronize price

Networks.RegisterItemPrice(Item: item);

Networks.OnLobbyCreated += () => {

// If you are host. you can set lobby data here

Networks.SetLobbyData(string: key, string: data)

};

Networks.OnLobbyEnter += () => {

// If you are client. you can get lobby data here

string data = Networks.GetLobbyData(string: key)

};

// or

Networks.SetNetworkSync(new Dictionary

{

{"test", false},

{"test2", 2f}

},

(dic) =>

{

try

{

bool test = bool.Parse(dic["test"]);

float test2 = float.Parse(dic["test2"]);

} catch { }

});

}

Fork & Clone

Need Following DLL:

  • Assembly-CSharp-nstrip.dll NStrip
  • Zorro.Core.Runtime.dll
  • Sirenix.Serialization.dll
  • com.rlabrecque.steamworks.net.dll

安裝與使用 安裝:BepInEx 外掛

  1. 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
  2. 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
  3. 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
  4. 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。

帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

BepInEx-BepInExPack

檔案與校驗

檔案名稱
ShopUtils-1.0.8.zip
檔案大小
23.3 KiB