You are viewing a potentially older version of this package. View all versions.
hyydsz-ShopUtils-1.0.7 icon

ShopUtils

A library for adding new items to ContentWarning

Date uploaded 7 months ago
Version 1.0.7
Download link hyydsz-ShopUtils-1.0.7.zip
Downloads 15526
Dependency string hyydsz-ShopUtils-1.0.7

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)
    };
}

Fork & Clone

Need Following DLL:

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

CHANGELOG

Changelog

1.0.8

Changed

  • Delete useless program
  • Add more network method

1.0.7

Changed

  • Remove Shops API
  • Fixed Language API errors

1.0.6

Changed

  • Modify spawn program

1.0.5

Added

  • ArtifactItem API

1.0.4

Fixed

  • Fix the issue error when language cannot be found

1.0.3

Added

  • Language API
  • Network API

Fixed

  • Fix issues caused by game updates

1.0.2

Added

  • Item Spawn API

1.0.1

Fixed

  • Fix item can't save

1.0.0

Added

  • Items API
  • ItemDataEntry API