hyydsz-ShopUtils icon

ShopUtils

A library for adding new items to ContentWarning

Last updated 2 months ago
Total downloads 165787
Total rating 2 
Categories Mods
Dependency string hyydsz-ShopUtils-1.0.8
Dependants 103 other packages depend on this package

This mod requires the following mods to function

BepInEx-BepInExPack-5.4.2100 icon
BepInEx-BepInExPack

BepInEx pack for Mono Unity games. Preconfigured and ready to use.

Preferred version: 5.4.2100

README

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<string, object>
    {
        {"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