You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- DLLs are now correctly versioned
- Added default value constructor to SynchronisedMetadata
- SynchronisedMetadata now implements IDisposable
- Disconnect() is now obsolete but calls Dispose()
- Added LobbyHosted event to SynchronisedMetadata
- `ShopItem` now correctly uses localised item names whenever available
- Items registered to the shop via the mod will now be considered when spawning random items in the Old World
Copy file name to clipboardExpand all lines: README.md
+34-10Lines changed: 34 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,10 +28,26 @@ If you are using BepInEx as your modloader, make sure to add the `[BepInDependen
28
28
29
29
Once added as a reference to your project, all classes are available under the `ContentWarningShop` namespace.
30
30
31
+
#### Creating items
32
+
33
+
Ideally `Item`s should be preconfigured and packed into an [`AssetBundle`](https://docs.unity3d.com/Manual/AssetBundlesIntro.html), but you can also construct them at runtime if its easier.
34
+
35
+
Custom `Item`s should have their `persistentID`, `price`, `purchasable`, `Category`, and `icon` properties set to work.
36
+
37
+
If you would like your item to have a chance to be randomly spawned in the Old World like other items, set `spawnable` to `true`, and `itemType` to `Item.ItemType.Tool`.
38
+
31
39
### Registering items
32
40
33
-
Use the `RegisterItem` method to register an `Item` to the shop. Ideally the item instance is preconfigured and loaded from an AssetBundle, but you can also construct it during runtime.
34
-
Make sure to set the `persistentID`, `price`, `purchasable`, `Category`, and `icon` properties at the very least to ensure the item will show up correctly in the store.
41
+
Items can be registered via the `RegisterItem` method:
> Item prices are automatically synchronised between players on lobby join. The price set by the lobby's host will be used for the entire lobby. Once a lobby has been created, the price of a registered item can be updated via `UpdateItemPrice`.
@@ -51,9 +67,9 @@ For example to synchronise a simple boolean setting with `false` as the initial
`SynchronisedMetadata` instances remain valid between different lobbies, so once bound to a key they can be safely kept in a static property and used for the entire duration of the game.
70
+
Instances will remain valid between different lobbies, so once bound to a key they can be safely kept in a static property and used for the entire duration of the game.
55
71
56
-
To update the value, call `SetValue(T value)`. Only the lobby's host may update the value of a key, so the method returns a boolean indicating if the set was allowed. If it was rejected, the instance's value isn't updated. Use the `CanSet` method to check if the current player has permission to update the setting.
72
+
To update the value, call `SetValue(T value)`. Only the lobby's host may update the value of a key, so the method returns a boolean indicating if the set was allowed. If it was rejected, the instance's value isn't updated. The `CanSet` method can be used to check if the current player has permission to update the setting.
57
73
58
74
> [!IMPORTANT]
59
75
> Values are converted to strings when passed on to the steam lobby, so make sure your type can be cast to string and back.
@@ -63,13 +79,21 @@ When a key is successfully updated either locally or remotely, the `ValueChanged
63
79
> [!NOTE]
64
80
> When not currently in a lobby, setting the value is permitted as if the current player was the host, and the `ValueChanged` event will still be raised.
65
81
82
+
In the scenario that you have separate player and lobby settings, and you want to apply the local player's settings when they host a new lobby, make sure to subscribe to the `LobbyHosted` event and overwrite the current value. This ensures that any values set by a previous lobby will be replaced with your player's settings:
The game's built-in localisation implementation is not extendable, so a custom solution is included with the mod under the `ContentWarningShop.Localisation` namespace. This patches `Item.GetLocalizedDisplayName` and `Item.GetTootipData`.
92
+
The game's built-in localisation implementation is not extendable, so a custom solution is included with the mod under the `ContentWarningShop.Localisation` namespace. This patches `Item.GetLocalizedDisplayName`, `Item.GetTootipData`, and the `ShopItem`'s constructor.
69
93
70
-
Use the `ShopLocalisation` class to add localised strings to your items. Each string is represented as a key-value pair assigned to a specific locale. For built in strings such as display name and tooltips, the item's unity object name (filename) is used or prefixed. For example, to localise the Item"Spookbox" the key would be simply also "Spookbox".
94
+
Use the `ShopLocalisation` class to add localised strings to your items. Each string is represented as a key-value pair assigned to a specific locale. For built in strings such as display name and tooltips, the item's unity object name (filename) is used or prefixed. For example, to localise an `Item` with the object name "Spookbox", the key would also be simply "Spookbox".
71
95
72
-
When adding locale strings, use the constants defined in the `LocaleKeys` static class to retrieve a locale used by the game via the `ShopLocalisation.TryGetLocale` method:
96
+
When adding locale strings, use the constants defined in the `LocaleKeys` static class to retrieve a locale used by the game via the `ShopLocalisation.TryGetLocale` method. These locales are guaranteed to be available:
@@ -81,7 +105,7 @@ The returned standard Unity Locale object can then be used via the `AddLocaleStr
81
105
locale?.AddLocaleString("Spookbox_ToolTips", $"{ShopLocalisation.UseGlyphString} Play;{ShopLocalisation.Use2GlyphString} Next Track");
82
106
```
83
107
84
-
Note that when localising item tooltips the key must be the item's name, suffixed with `_ToolTips` (`ShopLocalisation.TooltipsSuffix`), and the value must be a `;` separated list. To display action glyphs (such as right mouse button, etc) use the included constants in your strings, and the appropriate icon will be inserted into the tooltip by the game:
108
+
Note that when localising item tooltips, the key must be the item's name suffixed with `_ToolTips` (`ShopLocalisation.TooltipsSuffix`), and the value must be a `;` separated list. To display action glyphs (for example "[Left Click] Toggle", etc) use the glyph strings defined on the `ShopLocalisation` class in your strings, and the appropriate icon will be inserted into the tooltip by the game:
85
109
86
110
| Const | Glyph |
87
111
| -------- | ------- |
@@ -91,9 +115,9 @@ Note that when localising item tooltips the key must be the item's name, suffixe
91
115
| ZoomGlyph | Scroll wheel |
92
116
93
117
> [!IMPORTANT]
94
-
> If you don't want to add localisation ( :( ), use the `SetDefaultTooltips` extension method on your `Item` to set default tooltips.
118
+
> If you don't want to add full localisation ( :( ), use the `SetDefaultTooltips` extension method on your `Item` to set default tooltips.
95
119
> If you set tooltips in the editor, they won't work: this is a bug on Unity's end, not this mod. (those tooltips are serialised to null when you save them, even if they look right in the inspector)
96
-
> Setting a default is recommended in any case, but especially if you don't or only partially provide localisation.
120
+
> Setting a default is recommended in any case, but especially if you don't- or only partially provide localisation.
0 commit comments