@@ -30,9 +30,9 @@ composer require mistralys/cyberpunk-mod-db-php
3030
3131## Usage
3232
33- ### Creating the collection
33+ ### Accessing mods
3434
35- The collection class is the main entry point to the mod database.
35+ The mod collection class is the main entry point to the mod database.
3636It provides methods to access all mods, as well as the filtering
3737capabilities.
3838
@@ -61,9 +61,35 @@ if($catsuit->hasImage()) {
6161}
6262```
6363
64- ### Filtering
64+ ### Accessing items
6565
66- Use the filter to search for specific mods by search terms and/or tags.
66+ Each mod can contain multiple items, such as clothing items.
67+ While each mod has a collection of items, there is also a global
68+ item collection that contains all items from all mods.
69+
70+ ``` php
71+ use CPMDB\Mods\Collection\ModCollection;
72+
73+ // Create a collection instance
74+ $collection = ModCollection::create(
75+ __DIR__.'/vendor', // Absolute path to the composer vendor directory
76+ __DIR__.'/cache', // Path to a writable directory to store cache files
77+ 'http://127.0.0.1/your-app/vendor' // Absolute URL to the composer vendor directory
78+ );
79+
80+ // Get the item collection
81+ $itemsCollection = $collection->getItemCollection();
82+
83+ // Get an item by its CET code
84+ $dress = $itemsCollection->getByID('nd_michiko_dress_black');
85+
86+ // Get the CET command to add the item in-game
87+ $dress->getCETCommand();
88+ ```
89+
90+ ### Filtering mods
91+
92+ Use the mod filter to search for specific mods by search terms and/or tags.
6793
6894``` php
6995use CPMDB\Mods\Collection\ModCollection;
@@ -83,34 +109,31 @@ $mods = $collection->createFilter()
83109 ->getMods();
84110```
85111
86- ### Caching
112+ ### Filtering items
87113
88- By default, the collection will cache the mod data in the specified
89- cache directory. This is done for performance reasons, as the mod data
90- is read from my individual files in the filesystem.
91-
92- The cache is created and updated automatically following the version
93- of the mod database.
94-
95- #### Turning off caching
96-
97- The caching can be turned off if needed:
114+ Use the item filter to search for specific items by search terms and/or tags.
98115
99116``` php
100- use CPMDB\Mods\Collection\DataWriter\CacheDataWriter;
101-
102- CacheDataWriter::setCacheEnabled(false);
103- ```
104-
105- #### Performance tests
117+ use CPMDB\Mods\Collection\ModCollection;
118+ use CPMDB\Mods\Tags\Types\Jewelry;
106119
107- To check the performance of the caching on your system, you can run
108- the performance tests:
120+ // Create a collection instance
121+ $collection = ModCollection::create(
122+ __DIR__.'/vendor', // Absolute path to the composer vendor directory
123+ __DIR__.'/cache', // Path to a writable directory to store cache files
124+ 'http://127.0.0.1/your-app/vendor' // Absolute URL to the composer vendor directory
125+ );
109126
110- ``` bash
111- php tests/performance/performance-test.php
127+ // Search for the Jewelry tag to get all jewelry mod items
128+ $mods = $collection->createItemFilter()
129+ ->selectTag(Jewelry::TAG_NAME)
130+ ->getMods();
112131```
113132
133+ > NOTE: Items inherit their tags from the mod they belong to. Since a
134+ > mod can have items that belong to different tags, searching for
135+ > a specific tag may return unrelated items.
136+
114137## Tags
115138
116139Tags are used to categorize mods, using simple strings defined in the mod files
@@ -150,3 +173,31 @@ $cet = $collection->getByID(CyberEngineTweaks::TAG_NAME);
150173echo 'Full label: '.$cet->getLabel();
151174echo 'Tag category: '.$cet->getCategory();
152175```
176+
177+ ## Caching
178+
179+ By default, the collection will cache the mod data in the specified
180+ cache directory. This is done for performance reasons, as the mod data
181+ is read from my individual files in the filesystem.
182+
183+ The cache is created and updated automatically following the version
184+ of the mod database.
185+
186+ ### Turning off caching
187+
188+ The caching can be turned off if needed:
189+
190+ ``` php
191+ use CPMDB\Mods\Collection\DataWriter\CacheDataWriter;
192+
193+ CacheDataWriter::setCacheEnabled(false);
194+ ```
195+
196+ ### Performance tests
197+
198+ To check the performance of the caching on your system, you can run
199+ the performance tests:
200+
201+ ``` bash
202+ php tests/performance/performance-test.php
203+ ```
0 commit comments