Class ItemUtility
Helper functions for dropped items and inventory pages.
public static class ItemUtility
- Inheritance
-
ItemUtility
- Inherited Members
Properties
SupportsFastKits
If all the reflection succeeded needed for fast item distribution.
public static bool SupportsFastKits { get; }
Property Value
Methods
CanPerformMove(PlayerInventory, ItemJar, Page, byte, byte, byte)
Check if an item can be moved from one location to another.
public static bool CanPerformMove(PlayerInventory inventory, ItemJar item, Page page, byte x, byte y, byte rot)
Parameters
Returns
CanPerformSwap(PlayerInventory, ItemJar, Page, ItemJar, Page)
Check if an item can be swapped with another item.
public static bool CanPerformSwap(PlayerInventory inventory, ItemJar item1, Page item1Page, ItemJar item2, Page item2Page)
Parameters
Returns
ClearInventory(WarfarePlayer, bool)
Effeciently remove all items and clothes from a player's inventory.
public static void ClearInventory(WarfarePlayer player, bool clothes = true)
Parameters
playerWarfarePlayerclothesbool
ClearInventoryAndSlots(WarfarePlayer, bool)
Clear the playery's inventory and update their third-person model for other players.
public static void ClearInventoryAndSlots(WarfarePlayer player, bool clothes = true)
Parameters
playerWarfarePlayerclothesbool
CountItems(Player, Predicate<ItemJar>, int)
Count the number of items in the player's inventory that match a predicate.
public static int CountItems(Player player, Predicate<ItemJar> itemSelector, int max = -1)
Parameters
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
CountItems(Player, IAssetLink<ItemAsset>, int, bool)
Count the number of items in the player's inventory that have the given asset.
public static int CountItems(Player player, IAssetLink<ItemAsset> asset, int max = -1, bool includeAttachments = false)
Parameters
playerPlayerassetIAssetLink<ItemAsset>maxintincludeAttachmentsbool
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
CountItems(IAssetLink<ItemAsset>, int)
Count the number of items in the given radius matching an asset.
[Pure]
public static int CountItems(IAssetLink<ItemAsset> asset, int max = -1)
Parameters
assetIAssetLink<ItemAsset>maxint
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
CountItemsInRange(Vector3, float, int, bool)
Count the number of items in the given radius.
[Pure]
public static int CountItemsInRange(Vector3 position, float radius, int max = -1, bool horizontalDistanceOnly = false)
Parameters
Returns
Exceptions
- GameThreadException
Not on main thread.
CountItemsInRange(Vector3, float, IAssetLink<ItemAsset>, int, bool)
Count the number of items in the given radius matching an asset.
[Pure]
public static int CountItemsInRange(Vector3 position, float radius, IAssetLink<ItemAsset> asset, int max = -1, bool horizontalDistanceOnly = false)
Parameters
positionVector3radiusfloatassetIAssetLink<ItemAsset>maxinthorizontalDistanceOnlybool
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
CountItemsWhere(Predicate<ItemData>, int)
Count the number of items in the given radius matching a predicate.
[Pure]
public static int CountItemsWhere(Predicate<ItemData> itemSelector, int max = -1)
Parameters
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
CountItemsWhere(Vector3, float, Predicate<ItemData>, int, bool)
Count the number of items in the given radius matching a predicate.
[Pure]
public static int CountItemsWhere(Vector3 position, float radius, Predicate<ItemData> itemSelector, int max = -1, bool horizontalDistanceOnly = false)
Parameters
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
DestroyAllDroppedItems(bool)
Destroy all items on the map.
public static int DestroyAllDroppedItems(bool despawned)
Parameters
despawnedboolIf the item should be considered as having despawned, instead of destroyed.
Returns
- int
Number of items destroyed.
DestroyDroppedItem(Item, bool, bool)
Property clean up and replicate destroying (taking) a dropped item.
public static bool DestroyDroppedItem(Item item, bool despawned, bool playTakeItemSound = false)
Parameters
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
DestroyDroppedItem(Item, bool, WarfarePlayer, Page, byte, byte, byte, bool)
Property clean up and replicate destroying (taking) a dropped item that was picked up by a player.
public static bool DestroyDroppedItem(Item item, bool despawned, WarfarePlayer pickUpPlayer, Page pickupPage = (Page)255, byte pickupX = 0, byte pickupY = 0, byte pickupRot = 0, bool playTakeItemSound = false)
Parameters
itemItemdespawnedboolpickUpPlayerWarfarePlayerpickupPagePagepickupXbytepickupYbytepickupRotbyteplayTakeItemSoundbool
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
DestroyDroppedItem(ItemData, bool, bool)
Property clean up and replicate destroying (taking) a dropped item.
public static bool DestroyDroppedItem(ItemData item, bool despawned, bool playTakeItemSound = false)
Parameters
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
DestroyDroppedItem(ItemData, bool, WarfarePlayer, Page, byte, byte, byte, bool)
Property clean up and replicate destroying (taking) a dropped item that was picked up by a player.
public static bool DestroyDroppedItem(ItemData item, bool despawned, WarfarePlayer pickUpPlayer, Page pickupPage = (Page)255, byte pickupX = 0, byte pickupY = 0, byte pickupRot = 0, bool playTakeItemSound = false)
Parameters
itemItemDatadespawnedboolpickUpPlayerWarfarePlayerpickupPagePagepickupXbytepickupYbytepickupRotbyteplayTakeItemSoundbool
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
DestroyDroppedItem(byte, byte, int, bool, bool)
Property clean up and replicate destroying (taking) a dropped item.
public static void DestroyDroppedItem(byte x, byte y, int index, bool despawned, bool playTakeItemSound = false)
Parameters
Exceptions
- ArgumentOutOfRangeException
- GameThreadException
Not on main thread.
DestroyDroppedItem(byte, byte, int, bool, WarfarePlayer, bool, Page, byte, byte, byte)
Property clean up and replicate destroying (taking) a dropped item that was picked up by a player.
public static void DestroyDroppedItem(byte x, byte y, int index, bool despawned, WarfarePlayer pickUpPlayer, bool playTakeItemSound, Page pickupPage, byte pickupX, byte pickupY, byte pickupRot)
Parameters
xbyteybyteindexintdespawnedboolpickUpPlayerWarfarePlayerplayTakeItemSoundboolpickupPagePagepickupXbytepickupYbytepickupRotbyte
Exceptions
- ArgumentOutOfRangeException
- GameThreadException
Not on main thread.
DestroyDroppedItemsInRange(Vector3, float, bool, int, bool, CSteamID, Page, byte, byte, byte)
Destroy the number of items in the given radius.
public static int DestroyDroppedItemsInRange(Vector3 position, float radius, bool playTakeItemSound, int max = -1, bool horizontalDistanceOnly = false, CSteamID pickUpPlayer = default, Page pickupPage = (Page)255, byte pickupX = 0, byte pickupY = 0, byte pickupRot = 0)
Parameters
positionVector3radiusfloatplayTakeItemSoundboolmaxinthorizontalDistanceOnlyboolpickUpPlayerCSteamIDThe player that is picking up the items, if any.
pickupPagePagepickupXbytepickupYbytepickupRotbyte
Returns
- int
Number of items destroyed.
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
DestroyDroppedItemsInRange(Vector3, float, Predicate<ItemData>, bool, int, bool, CSteamID, Page, byte, byte, byte)
Destroy the number of items in the given radius matching a itemSelector.
public static int DestroyDroppedItemsInRange(Vector3 position, float radius, Predicate<ItemData> itemSelector, bool playTakeItemSound, int max = -1, bool horizontalDistanceOnly = false, CSteamID pickUpPlayer = default, Page pickupPage = (Page)255, byte pickupX = 0, byte pickupY = 0, byte pickupRot = 0)
Parameters
positionVector3radiusfloatitemSelectorPredicate<ItemData>playTakeItemSoundboolmaxinthorizontalDistanceOnlyboolpickUpPlayerCSteamIDThe player that is picking up the items, if any.
pickupPagePagepickupXbytepickupYbytepickupRotbyte
Returns
- int
Number of items destroyed.
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
DestroyDroppedItemsInRange(Vector3, float, IAssetLink<ItemAsset>, bool, int, bool, CSteamID, Page, byte, byte, byte)
Destroy the number of items in the given radius matching an asset.
public static int DestroyDroppedItemsInRange(Vector3 position, float radius, IAssetLink<ItemAsset> asset, bool playTakeItemSound, int max = -1, bool horizontalDistanceOnly = false, CSteamID pickUpPlayer = default, Page pickupPage = (Page)255, byte pickupX = 0, byte pickupY = 0, byte pickupRot = 0)
Parameters
positionVector3radiusfloatassetIAssetLink<ItemAsset>playTakeItemSoundboolmaxinthorizontalDistanceOnlyboolpickUpPlayerCSteamIDThe player that is picking up the items, if any.
pickupPagePagepickupXbytepickupYbytepickupRotbyte
Returns
- int
Number of items destroyed.
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
EnumerateAlongGrid(Items, bool)
Enumerate items along the grid instead of the order they were added.
public static ItemPageIterator EnumerateAlongGrid(Items items, bool reverse = false)
Parameters
itemsItemsreversebool
Returns
Exceptions
- GameThreadException
Not on main thread.
EnumerateClothingSlots(Player)
Enumerate through all of a player's clothing slots (filled or not).
[Pure]
public static EquippedClothingIterator EnumerateClothingSlots(Player player)
Parameters
playerPlayer
Returns
EnumerateClothingSlots(PlayerClothing)
Enumerate through all of a player's clothing slots (filled or not).
[Pure]
public static EquippedClothingIterator EnumerateClothingSlots(PlayerClothing clothing)
Parameters
clothingPlayerClothing
Returns
EnumerateClothingSlots(WarfarePlayer)
Enumerate through all of a player's clothing slots (filled or not).
[Pure]
public static EquippedClothingIterator EnumerateClothingSlots(WarfarePlayer player)
Parameters
playerWarfarePlayer
Returns
EnumerateDroppedItems()
Enumerate through all dropped items around the center of the level.
[Pure]
public static DroppedItemIterator EnumerateDroppedItems()
Returns
Exceptions
- GameThreadException
Not on main thread.
EnumerateDroppedItems(RegionCoord)
Enumerate through all dropped items around the given region.
[Pure]
public static DroppedItemIterator EnumerateDroppedItems(RegionCoord region)
Parameters
regionRegionCoord
Returns
Exceptions
- GameThreadException
Not on main thread.
EnumerateDroppedItems(RegionCoord, byte)
Enumerate through all dropped items around the given region.
[Pure]
public static DroppedItemIterator EnumerateDroppedItems(RegionCoord region, byte maxRegionDistance)
Parameters
regionRegionCoordmaxRegionDistancebyte
Returns
Remarks
The square enumerated will have a size of regions.maxRegionDistance * 2 + 1
Exceptions
- GameThreadException
Not on main thread.
EnumerateDroppedItems(byte, byte)
Enumerate through all dropped items around the region x, y.
[Pure]
public static DroppedItemIterator EnumerateDroppedItems(byte x, byte y)
Parameters
Returns
Exceptions
- GameThreadException
Not on main thread.
EnumerateDroppedItems(byte, byte, byte)
Enumerate through all dropped items around the region x, y.
[Pure]
public static DroppedItemIterator EnumerateDroppedItems(byte x, byte y, byte maxRegionDistance)
Parameters
Returns
Remarks
The square enumerated will have a size of regions.maxRegionDistance * 2 + 1
Exceptions
- GameThreadException
Not on main thread.
EnumerateDroppedItems(Vector3)
Enumerate through all dropped items around the center of the level.
[Pure]
public static DroppedItemIterator EnumerateDroppedItems(Vector3 center)
Parameters
centerVector3
Returns
Exceptions
- GameThreadException
Not on main thread.
EnumerateDroppedItems(Vector3, byte)
Enumerate through all dropped items around the center of the level.
[Pure]
public static DroppedItemIterator EnumerateDroppedItems(Vector3 center, byte maxRegionDistance)
Parameters
centerVector3maxRegionDistancebyte
Returns
Remarks
The square enumerated will have a size of regions.maxRegionDistance * 2 + 1
Exceptions
- GameThreadException
Not on main thread.
FindItem(Item)
Find a item by it's SDG.Unturned.Item instance.
[Pure]
public static ItemInfo FindItem(Item item)
Parameters
itemItem
Returns
Exceptions
- GameThreadException
Not on main thread.
FindItem(Item, byte, byte)
Find a item by it's SDG.Unturned.Item instance, with help from an expected region to prevent having to search every region.
[Pure]
public static ItemInfo FindItem(Item item, byte expectedRegionX, byte expectedRegionY)
Parameters
Returns
Remarks
All regions will be searched if it's not found in the expected region.
Exceptions
- GameThreadException
Not on main thread.
FindItem(Item, Vector3)
Find a item by it's SDG.Unturned.Item instance, with help from a position to prevent having to search every region.
[Pure]
public static ItemInfo FindItem(Item item, Vector3 expectedPosition)
Parameters
itemItemexpectedPositionVector3
Returns
Remarks
All regions will be searched if it's not found near the expected position.
Exceptions
- GameThreadException
Not on main thread.
FindItem(uint)
Find a item by it's instance ID.
[Pure]
public static ItemInfo FindItem(uint instanceId)
Parameters
instanceIduint
Returns
Exceptions
- GameThreadException
Not on main thread.
FindItem(uint, byte, byte)
Find a item by it's instance ID, with help from an expected region to prevent having to search every region.
[Pure]
public static ItemInfo FindItem(uint instanceId, byte expectedRegionX, byte expectedRegionY)
Parameters
Returns
Remarks
All regions will be searched if it's not found in the expected region.
Exceptions
- GameThreadException
Not on main thread.
FindItem(uint, IAssetLink<ItemAsset>, Vector3)
Find a item by it's instance ID, with help from an expected region to prevent having to search every region.
[Pure]
public static ItemInfo FindItem(uint instanceId, IAssetLink<ItemAsset> expectedAsset, Vector3 expectedPosition)
Parameters
instanceIduintexpectedAssetIAssetLink<ItemAsset>expectedPositionVector3
Returns
Remarks
All regions will be searched if it's not found in the expected region.
Exceptions
- GameThreadException
Not on main thread.
FindItem(uint, Vector3)
Find a item by it's instance ID, with help from a position to prevent having to search every region.
[Pure]
public static ItemInfo FindItem(uint instanceId, Vector3 expectedPosition)
Parameters
instanceIduintexpectedPositionVector3
Returns
Remarks
All regions will be searched if it's not found near the expected position.
Exceptions
- GameThreadException
Not on main thread.
FindMagazineAsset(ItemGunAsset, byte[]?)
Gets a default magazine for the gun, or falls back to the first asset that matches the caliber of the gun.
public static ItemMagazineAsset? FindMagazineAsset(ItemGunAsset gunAsset, byte[]? state = null)
Parameters
gunAssetItemGunAssetstatebyte[]Used to select the current magazine if supplied.
Returns
- ItemMagazineAsset
GetClosestItem(Vector3, bool)
Find the closest item to position.
[Pure]
public static ItemInfo GetClosestItem(Vector3 position, bool horizontalDistanceOnly = false)
Parameters
positionVector3horizontalDistanceOnlybool
Returns
Exceptions
- GameThreadException
Not on main thread.
GetClosestItem(Vector3, IAssetLink<ItemAsset>, bool)
Find the closest item with the given asset to position.
[Pure]
public static ItemInfo GetClosestItem(Vector3 position, IAssetLink<ItemAsset> asset, bool horizontalDistanceOnly = false)
Parameters
positionVector3assetIAssetLink<ItemAsset>horizontalDistanceOnlybool
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
GetClosestItemInRange(Vector3, float, bool)
Find the closest item to position within the given radius.
[Pure]
public static ItemInfo GetClosestItemInRange(Vector3 position, float radius, bool horizontalDistanceOnly = false)
Parameters
Returns
Exceptions
- GameThreadException
Not on main thread.
GetClosestItemInRange(Vector3, float, IAssetLink<ItemAsset>, bool)
Find the closest item with the given asset to position within the given radius.
[Pure]
public static ItemInfo GetClosestItemInRange(Vector3 position, float radius, IAssetLink<ItemAsset> asset, bool horizontalDistanceOnly = false)
Parameters
positionVector3radiusfloatassetIAssetLink<ItemAsset>horizontalDistanceOnlybool
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
GetClosestItemWhere(Vector3, Predicate<ItemData>, bool)
Find the closest item matching a predicate to position.
[Pure]
public static ItemInfo GetClosestItemWhere(Vector3 position, Predicate<ItemData> itemSelector, bool horizontalDistanceOnly = false)
Parameters
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
GetClosestItemWhere(Vector3, float, Predicate<ItemData>, bool)
Find the closest item matching a predicate to position within a given radius.
[Pure]
public static ItemInfo GetClosestItemWhere(Vector3 position, float radius, Predicate<ItemData> itemSelector, bool horizontalDistanceOnly = false)
Parameters
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
GetDefaultFireMode(ItemGunAsset)
Gets the default firemode for a certain gun asset.
public static EFiremode GetDefaultFireMode(ItemGunAsset gunAsset)
Parameters
gunAssetItemGunAsset
Returns
- EFiremode
GetFirearmClass(ItemGunAsset)
Guesses the type of weapon gun is based off it's ammo and size.
[Pure]
public static FirearmClass GetFirearmClass(ItemGunAsset gun)
Parameters
gunItemGunAsset
Returns
GetHeldItem(WarfarePlayer, out Page)
Get the SDG.Unturned.ItemJar that's actively held by the player.
public static ItemJar? GetHeldItem(this WarfarePlayer player, out Page page)
Parameters
playerWarfarePlayerpagePage
Returns
- ItemJar
GetItemAt(PlayerInventory, Page, byte, byte)
Get the SDG.Unturned.ItemJar that's at a specific position in the inventory.
public static ItemJar? GetItemAt(this PlayerInventory inventory, Page page, byte x, byte y)
Parameters
Returns
- ItemJar
GetItemAt(PlayerInventory, Page, byte, byte, out byte)
Get the SDG.Unturned.ItemJar that's at a specific position in the inventory.
public static ItemJar? GetItemAt(this PlayerInventory inventory, Page page, byte x, byte y, out byte index)
Parameters
Returns
- ItemJar
GetItemAt(WarfarePlayer, Page, byte, byte)
Get the SDG.Unturned.ItemJar that's at a specific position in the inventory.
public static ItemJar? GetItemAt(this WarfarePlayer player, Page page, byte x, byte y)
Parameters
playerWarfarePlayerpagePagexbyteybyte
Returns
- ItemJar
GetItemAt(WarfarePlayer, Page, byte, byte, out byte)
Get the SDG.Unturned.ItemJar that's at a specific position in the inventory.
public static ItemJar? GetItemAt(this WarfarePlayer player, Page page, byte x, byte y, out byte index)
Parameters
playerWarfarePlayerpagePagexbyteybyteindexbyte
Returns
- ItemJar
HasAnyItems(WarfarePlayer, bool)
Check if a player has any items or clothes equipped (if clothes is true).
public static bool HasAnyItems(WarfarePlayer player, bool clothes = true)
Parameters
playerWarfarePlayerclothesbool
Returns
HasItem(Player, Predicate<ItemJar>)
Check if there is at least one item in the player's inventory that matches a predicate.
public static bool HasItem(Player player, Predicate<ItemJar> itemSelector)
Parameters
playerPlayeritemSelectorPredicate<ItemJar>
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
HasItem(Player, IAssetLink<ItemAsset>, bool)
Check if there is at least one item in the player's inventory that has the given asset.
public static bool HasItem(Player player, IAssetLink<ItemAsset> asset, bool includeAttachments = false)
Parameters
playerPlayerassetIAssetLink<ItemAsset>includeAttachmentsbool
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
IsHeldItem(WarfarePlayer, Page, byte, byte)
Check if the given item is currently equipped.
public static bool IsHeldItem(WarfarePlayer player, Page page, byte x, byte y)
Parameters
playerWarfarePlayerpagePagexbyteybyte
Returns
IsItemInRange(Vector3, float, bool)
Check for a nearby item to position within the given radius.
[Pure]
public static bool IsItemInRange(Vector3 position, float radius, bool horizontalDistanceOnly = false)
Parameters
Returns
Exceptions
- GameThreadException
Not on main thread.
IsItemInRange(Vector3, float, Predicate<ItemData>, bool)
Check for a nearby item matching a predicate to position within the given radius.
[Pure]
public static bool IsItemInRange(Vector3 position, float radius, Predicate<ItemData> itemSelector, bool horizontalDistanceOnly = false)
Parameters
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
IsItemInRange(Vector3, float, IAssetLink<ItemAsset>, bool)
Check for a nearby item with the given asset to position within the given radius.
[Pure]
public static bool IsItemInRange(Vector3 position, float radius, IAssetLink<ItemAsset> asset, bool horizontalDistanceOnly = false)
Parameters
positionVector3radiusfloatassetIAssetLink<ItemAsset>horizontalDistanceOnlybool
Returns
Exceptions
- ArgumentNullException
- GameThreadException
Not on main thread.
IsOutOfBounds(Items, ItemJar)
Check if an item is out of bounds of the page.
public static bool IsOutOfBounds(Items page, ItemJar jar)
Parameters
pageItemsjarItemJar
Returns
IsOutOfBounds(Items, byte, byte, byte, byte, byte)
Check if an item is out of bounds of the page.
public static bool IsOutOfBounds(Items page, byte posX, byte posY, byte sizeX, byte sizeY, byte rotation)
Parameters
Returns
IsOutOfBounds(byte, byte, byte, byte, byte, byte, byte)
Check if an item is out of bounds of the page.
public static bool IsOutOfBounds(byte pageSizeX, byte pageSizeY, byte posX, byte posY, byte sizeX, byte sizeY, byte rotation)
Parameters
Returns
IsOverlapping(byte, byte, byte, byte, byte, byte, byte, byte, byte, byte)
Check if two items are overlapping that are in the same page.
public static bool IsOverlapping(byte posX1, byte posY1, byte sizeX1, byte sizeY1, byte posX2, byte posY2, byte sizeX2, byte sizeY2, byte rotation1, byte rotation2)
Parameters
posX1byteposY1bytesizeX1bytesizeY1byteposX2byteposY2bytesizeX2bytesizeY2byterotation1byterotation2byte
Returns
IsolateInventory(Player, out bool)
Prevents modifications to the inventory from being replicated. Only works if SupportsFastKits is true.
public static void IsolateInventory(Player player, out bool oldValue)
Parameters
playerPlayeroldValuebool
ItemsFromInventory(WarfarePlayer, bool, bool, bool, AssetRedirectService?)
Get an array of kit item abstractions from a player's inventory and clothing.
public static List<IItem> ItemsFromInventory(WarfarePlayer player, bool addClothes = true, bool addItems = true, bool refillItems = false, AssetRedirectService? assetRedirectService = null)
Parameters
playerWarfarePlayeraddClothesbooladdItemsboolrefillItemsboolIf items should be fully refilled (like guns, etc.)
assetRedirectServiceAssetRedirectService
Returns
OnClearingInventory(WarfarePlayer)
Handles logic that needs ran with a player's inventory is cleared.
public static void OnClearingInventory(WarfarePlayer player)
Parameters
playerWarfarePlayer
RefillState(ref byte[], ItemAsset)
Copy and refill a state array to it's ideal values for a given asset.
public static void RefillState(ref byte[] state, ItemAsset asset)
Parameters
statebyte[]assetItemAsset
RotationToDegrees(byte)
Convert an item rotation to an angle in degrees clockwise.
public static int RotationToDegrees(byte rotation)
Parameters
rotationbyteRotation value zero to three.
Returns
- int
An angle in degrees, either 0, 90, 180, or 270.
SendPages(WarfarePlayer)
Manually send the entire page via RPC to save on bandwidth.
public static void SendPages(WarfarePlayer player)
Parameters
playerWarfarePlayer
SendWearClothing(Player, ItemAsset?, ClothingType, byte, byte[], bool)
Sets and replicates the player's clothing at a given slot.
public static void SendWearClothing(Player player, ItemAsset? asset, ClothingType type, byte quality, byte[] state, bool playEffect)
Parameters
playerPlayerassetItemAssettypeClothingTypequalitybytestatebyte[]playEffectbool
Remarks
Requires SupportsFastKits to be true.
TryFindItem(PlayerInventory, Item, out byte, out byte, out Page, out byte)
Find an item in an inventory by it's SDG.Unturned.Item reference.
public static bool TryFindItem(PlayerInventory inventory, Item item, out byte x, out byte y, out Page page, out byte rot)
Parameters
Returns
TryFindJarPage(PlayerInventory, ItemJar, out Page)
Get the page of an SDG.Unturned.ItemJar.
public static bool TryFindJarPage(PlayerInventory inventory, ItemJar jar, out Page page)
Parameters
inventoryPlayerInventoryjarItemJarpagePage
Returns
UndoIsolateInventory(Player, bool)
Reverses IsolateInventory(Player, out bool) which prevents modifications to the inventory from being replicated. Only works if SupportsFastKits is true.
public static void UndoIsolateInventory(Player player, bool oldValue)
Parameters
playerPlayeroldValuebool
UpdateSlots(WarfarePlayer)
Update the player's third-person model for other players.
public static void UpdateSlots(WarfarePlayer player)
Parameters
playerWarfarePlayer