ShopUtils

v1.0.8·Updated 2024-04-14

A library for adding new items to ContentWarning

About this mod Author’s original text

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

Install & use Install: BepInEx plugin

  1. The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
  2. Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
  3. Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
  4. Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.

Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.

Dependencies

Install these first, or the mod will not work:

BepInEx-BepInExPack

File & checksum

Filename
ShopUtils-1.0.8.zip
File size
23.3 KiB