Provides an API for checking player ownership of DLC items and skins by content or workshop ID
Workshop ID's are what you see on steam (ex. ), most skin plugins will use workshop IDs
Content ID's are Rusts own identifier for paid content
I am going to touch on the 2 parts of his statement that are relevant to this plugin.
The native CheckSkinOwnership method, requires you provide the the ID of the DLC you want to check. That is useless if you only have workshop IDs like most plugins do. But lets say you do have the DLC ID.
The first thing that function does is call the ItemSkinDirectory.FindByInventoryDefinitionId method to find the DLC info. That method makes 2 Linq calls both generating garbage for every ID that is checked, Where and FirstOrDefault. (See: )
This plugin has 2 API methods that produce the same result as the native function;
CheckContentOwnership which takes in a DLC ID, the same as the native method, but without the garbage allocations.
IsOwnedOrFreeSkin which takes in a workshop ID instead of a DLC ID, pretty useful for plugins storing workshop IDs, and also without garbage allocations
Both of these API methods are faster to call through Oxides hook API then running the native CheckSkinOwnership function.
Here is some benchmark results comparing the 3 methods 3 times back to back, testing against every approved skin
-------------------------------------------------
[API] IsOwnedOrFreeSkin: 5469 iterations
Totals: Time: 7.5846ms | Allocations: 0 bytes
Average: Time: 0.0014ms | Allocations: 0 bytes
-------------------------------------------------
[API] CheckContentOwnership: 5469 iterations
Totals: Time: 6.0259ms | Allocations: 0 bytes
Average: Time: 0.0011ms | Allocations: 0 bytes
-------------------------------------------------
[Native] CheckSkinOwnership: 5469 iterations
Totals: Time: 14.4965ms | Allocations: 143360 bytes
Average: Time: 0.0027ms | Allocations: 26 bytes
-------------------------------------------------
[API] IsOwnedOrFreeSkin: 5469 iterations
Totals: Time: 5.9590ms | Allocations: 0 bytes
Average: Time: 0.0011ms | Allocations: 0 bytes
-------------------------------------------------
[API] CheckContentOwnership: 5469 iterations
Totals: Time: 5.6988ms | Allocations: 0 bytes
Average: Time: 0.0010ms | Allocations: 0 bytes
-------------------------------------------------
[Native] CheckSkinOwnership: 5469 iterations
Totals: Time: 14.4887ms | Allocations: 139264 bytes
Average: Time: 0.0026ms | Allocations: 25 bytes
-------------------------------------------------
[API] IsOwnedOrFreeSkin: 5469 iterations
Totals: Time: 6.3950ms | Allocations: 0 bytes
Average: Time: 0.0012ms | Allocations: 0 bytes
-------------------------------------------------
[API] CheckContentOwnership: 5469 iterations
Totals: Time: 5.5006ms | Allocations: 0 bytes
Average: Time: 0.0010ms | Allocations: 0 bytes
-------------------------------------------------
[Native] CheckSkinOwnership: 5469 iterations
Totals: Time: 14.1449ms | Allocations: 135168 bytes
Average: Time: 0.0026ms | Allocations: 24 bytes
Not only does this plugin provides faster, non-allocating methods for both DLC IDs AND Workshop IDs, it also allows you to filter a entire list of dlc/workshop IDs for a player in a single call leaving you with a list containing only what the player is allowed to use.
The HasLicense function requires that you already have the item created. It then makes a call into the steam_api64.dll managed binary. We don't have access to the C source code from there but it is likely that it makes a API request to Steam to do the comparison.
At the end of the day, I dont care if other developers want to or don't want make use of this plugin. I will be using it for all my plugins to quickly and easily filter out content players can't use.
I can post the plugin used to benchmark if anyone wants to try it themselves
Workshop ID's are what you see on steam (ex. ), most skin plugins will use workshop IDs
Content ID's are Rusts own identifier for paid content
Why this plugin is useful
Its stupid that I have to do this, but Death from codefling has claimed this plugin is a overcomplication and has expensive API calls. Death does not know what he is talking about, and since I do not use codefling I will post my rebuttal to his claims hereI am going to touch on the 2 parts of his statement that are relevant to this plugin.
The native CheckSkinOwnership method, requires you provide the the ID of the DLC you want to check. That is useless if you only have workshop IDs like most plugins do. But lets say you do have the DLC ID.
The first thing that function does is call the ItemSkinDirectory.FindByInventoryDefinitionId method to find the DLC info. That method makes 2 Linq calls both generating garbage for every ID that is checked, Where and FirstOrDefault. (See: )
This plugin has 2 API methods that produce the same result as the native function;
CheckContentOwnership which takes in a DLC ID, the same as the native method, but without the garbage allocations.
IsOwnedOrFreeSkin which takes in a workshop ID instead of a DLC ID, pretty useful for plugins storing workshop IDs, and also without garbage allocations
Both of these API methods are faster to call through Oxides hook API then running the native CheckSkinOwnership function.
Here is some benchmark results comparing the 3 methods 3 times back to back, testing against every approved skin
-------------------------------------------------
[API] IsOwnedOrFreeSkin: 5469 iterations
Totals: Time: 7.5846ms | Allocations: 0 bytes
Average: Time: 0.0014ms | Allocations: 0 bytes
-------------------------------------------------
[API] CheckContentOwnership: 5469 iterations
Totals: Time: 6.0259ms | Allocations: 0 bytes
Average: Time: 0.0011ms | Allocations: 0 bytes
-------------------------------------------------
[Native] CheckSkinOwnership: 5469 iterations
Totals: Time: 14.4965ms | Allocations: 143360 bytes
Average: Time: 0.0027ms | Allocations: 26 bytes
-------------------------------------------------
[API] IsOwnedOrFreeSkin: 5469 iterations
Totals: Time: 5.9590ms | Allocations: 0 bytes
Average: Time: 0.0011ms | Allocations: 0 bytes
-------------------------------------------------
[API] CheckContentOwnership: 5469 iterations
Totals: Time: 5.6988ms | Allocations: 0 bytes
Average: Time: 0.0010ms | Allocations: 0 bytes
-------------------------------------------------
[Native] CheckSkinOwnership: 5469 iterations
Totals: Time: 14.4887ms | Allocations: 139264 bytes
Average: Time: 0.0026ms | Allocations: 25 bytes
-------------------------------------------------
[API] IsOwnedOrFreeSkin: 5469 iterations
Totals: Time: 6.3950ms | Allocations: 0 bytes
Average: Time: 0.0012ms | Allocations: 0 bytes
-------------------------------------------------
[API] CheckContentOwnership: 5469 iterations
Totals: Time: 5.5006ms | Allocations: 0 bytes
Average: Time: 0.0010ms | Allocations: 0 bytes
-------------------------------------------------
[Native] CheckSkinOwnership: 5469 iterations
Totals: Time: 14.1449ms | Allocations: 135168 bytes
Average: Time: 0.0026ms | Allocations: 24 bytes
Not only does this plugin provides faster, non-allocating methods for both DLC IDs AND Workshop IDs, it also allows you to filter a entire list of dlc/workshop IDs for a player in a single call leaving you with a list containing only what the player is allowed to use.
The HasLicense function requires that you already have the item created. It then makes a call into the steam_api64.dll managed binary. We don't have access to the C source code from there but it is likely that it makes a API request to Steam to do the comparison.
At the end of the day, I dont care if other developers want to or don't want make use of this plugin. I will be using it for all my plugins to quickly and easily filter out content players can't use.
I can post the plugin used to benchmark if anyone wants to try it themselves