Table of Contents

Class ItemUtility

Namespace
Uncreated.Warfare.Util
Assembly
Uncreated.Warfare.dll

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

bool

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

inventory PlayerInventory
item ItemJar
page Page
x byte
y byte
rot byte

Returns

bool

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

inventory PlayerInventory
item1 ItemJar
item1Page Page
item2 ItemJar
item2Page Page

Returns

bool

ClearInventory(WarfarePlayer, bool)

Effeciently remove all items and clothes from a player's inventory.

public static void ClearInventory(WarfarePlayer player, bool clothes = true)

Parameters

player WarfarePlayer
clothes bool

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

player WarfarePlayer
clothes bool

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

player Player
itemSelector Predicate<ItemJar>
max int

Returns

int

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

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

player Player
asset IAssetLink<ItemAsset>
max int
includeAttachments bool

Returns

int

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

Count the number of items in the given radius matching an asset.

[Pure]
public static int CountItems(IAssetLink<ItemAsset> asset, int max = -1)

Parameters

asset IAssetLink<ItemAsset>
max int

Returns

int

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

position Vector3
radius float
max int
horizontalDistanceOnly bool

Returns

int

Exceptions

GameThreadException

Not on main thread.

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

position Vector3
radius float
asset IAssetLink<ItemAsset>
max int
horizontalDistanceOnly bool

Returns

int

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

itemSelector Predicate<ItemData>
max int

Returns

int

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

position Vector3
radius float
itemSelector Predicate<ItemData>
max int
horizontalDistanceOnly bool

Returns

int

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

DestroyAllDroppedItems(bool)

Destroy all items on the map.

public static int DestroyAllDroppedItems(bool despawned)

Parameters

despawned bool

If 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

item Item
despawned bool
playTakeItemSound bool

Returns

bool

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

item Item
despawned bool
pickUpPlayer WarfarePlayer
pickupPage Page
pickupX byte
pickupY byte
pickupRot byte
playTakeItemSound bool

Returns

bool

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

item ItemData
despawned bool
playTakeItemSound bool

Returns

bool

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

item ItemData
despawned bool
pickUpPlayer WarfarePlayer
pickupPage Page
pickupX byte
pickupY byte
pickupRot byte
playTakeItemSound bool

Returns

bool

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

x byte
y byte
index int
despawned bool
playTakeItemSound bool

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

x byte
y byte
index int
despawned bool
pickUpPlayer WarfarePlayer
playTakeItemSound bool
pickupPage Page
pickupX byte
pickupY byte
pickupRot byte

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

position Vector3
radius float
playTakeItemSound bool
max int
horizontalDistanceOnly bool
pickUpPlayer CSteamID

The player that is picking up the items, if any.

pickupPage Page
pickupX byte
pickupY byte
pickupRot byte

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

position Vector3
radius float
itemSelector Predicate<ItemData>
playTakeItemSound bool
max int
horizontalDistanceOnly bool
pickUpPlayer CSteamID

The player that is picking up the items, if any.

pickupPage Page
pickupX byte
pickupY byte
pickupRot byte

Returns

int

Number of items destroyed.

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

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

position Vector3
radius float
asset IAssetLink<ItemAsset>
playTakeItemSound bool
max int
horizontalDistanceOnly bool
pickUpPlayer CSteamID

The player that is picking up the items, if any.

pickupPage Page
pickupX byte
pickupY byte
pickupRot byte

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

items Items
reverse bool

Returns

ItemPageIterator

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

player Player

Returns

EquippedClothingIterator

EnumerateClothingSlots(PlayerClothing)

Enumerate through all of a player's clothing slots (filled or not).

[Pure]
public static EquippedClothingIterator EnumerateClothingSlots(PlayerClothing clothing)

Parameters

clothing PlayerClothing

Returns

EquippedClothingIterator

EnumerateClothingSlots(WarfarePlayer)

Enumerate through all of a player's clothing slots (filled or not).

[Pure]
public static EquippedClothingIterator EnumerateClothingSlots(WarfarePlayer player)

Parameters

player WarfarePlayer

Returns

EquippedClothingIterator

EnumerateDroppedItems()

Enumerate through all dropped items around the center of the level.

[Pure]
public static DroppedItemIterator EnumerateDroppedItems()

Returns

DroppedItemIterator

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

region RegionCoord

Returns

DroppedItemIterator

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

region RegionCoord
maxRegionDistance byte

Returns

DroppedItemIterator

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

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

x byte
y byte

Returns

DroppedItemIterator

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

x byte
y byte
maxRegionDistance byte

Returns

DroppedItemIterator

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

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

center Vector3

Returns

DroppedItemIterator

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

center Vector3
maxRegionDistance byte

Returns

DroppedItemIterator

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

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

item Item

Returns

ItemInfo

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

item Item
expectedRegionX byte
expectedRegionY byte

Returns

ItemInfo

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

item Item
expectedPosition Vector3

Returns

ItemInfo

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

instanceId uint

Returns

ItemInfo

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

instanceId uint
expectedRegionX byte
expectedRegionY byte

Returns

ItemInfo

Remarks

All regions will be searched if it's not found in the expected region.

Exceptions

GameThreadException

Not on main thread.

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

instanceId uint
expectedAsset IAssetLink<ItemAsset>
expectedPosition Vector3

Returns

ItemInfo

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

instanceId uint
expectedPosition Vector3

Returns

ItemInfo

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

gunAsset ItemGunAsset
state byte[]

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

position Vector3
horizontalDistanceOnly bool

Returns

ItemInfo

Exceptions

GameThreadException

Not on main thread.

Find the closest item with the given asset to position.

[Pure]
public static ItemInfo GetClosestItem(Vector3 position, IAssetLink<ItemAsset> asset, bool horizontalDistanceOnly = false)

Parameters

position Vector3
asset IAssetLink<ItemAsset>
horizontalDistanceOnly bool

Returns

ItemInfo

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

position Vector3
radius float
horizontalDistanceOnly bool

Returns

ItemInfo

Exceptions

GameThreadException

Not on main thread.

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

position Vector3
radius float
asset IAssetLink<ItemAsset>
horizontalDistanceOnly bool

Returns

ItemInfo

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

position Vector3
itemSelector Predicate<ItemData>
horizontalDistanceOnly bool

Returns

ItemInfo

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

position Vector3
radius float
itemSelector Predicate<ItemData>
horizontalDistanceOnly bool

Returns

ItemInfo

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

gunAsset ItemGunAsset

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

gun ItemGunAsset

Returns

FirearmClass

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

player WarfarePlayer
page Page

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

inventory PlayerInventory
page Page
x byte
y byte

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

inventory PlayerInventory
page Page
x byte
y byte
index byte

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

player WarfarePlayer
page Page
x byte
y byte

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

player WarfarePlayer
page Page
x byte
y byte
index byte

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

player WarfarePlayer
clothes bool

Returns

bool

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

player Player
itemSelector Predicate<ItemJar>

Returns

bool

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

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

player Player
asset IAssetLink<ItemAsset>
includeAttachments bool

Returns

bool

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

player WarfarePlayer
page Page
x byte
y byte

Returns

bool

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

position Vector3
radius float
horizontalDistanceOnly bool

Returns

bool

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

position Vector3
radius float
itemSelector Predicate<ItemData>
horizontalDistanceOnly bool

Returns

bool

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

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

position Vector3
radius float
asset IAssetLink<ItemAsset>
horizontalDistanceOnly bool

Returns

bool

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

page Items
jar ItemJar

Returns

bool

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

page Items
posX byte
posY byte
sizeX byte
sizeY byte
rotation byte

Returns

bool

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

pageSizeX byte
pageSizeY byte
posX byte
posY byte
sizeX byte
sizeY byte
rotation byte

Returns

bool

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

posX1 byte
posY1 byte
sizeX1 byte
sizeY1 byte
posX2 byte
posY2 byte
sizeX2 byte
sizeY2 byte
rotation1 byte
rotation2 byte

Returns

bool

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

player Player
oldValue bool

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

player WarfarePlayer
addClothes bool
addItems bool
refillItems bool

If items should be fully refilled (like guns, etc.)

assetRedirectService AssetRedirectService

Returns

List<IItem>

OnClearingInventory(WarfarePlayer)

Handles logic that needs ran with a player's inventory is cleared.

public static void OnClearingInventory(WarfarePlayer player)

Parameters

player WarfarePlayer

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

state byte[]
asset ItemAsset

RotationToDegrees(byte)

Convert an item rotation to an angle in degrees clockwise.

public static int RotationToDegrees(byte rotation)

Parameters

rotation byte

Rotation 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

player WarfarePlayer

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

player Player
asset ItemAsset
type ClothingType
quality byte
state byte[]
playEffect bool

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

inventory PlayerInventory
item Item
x byte
y byte
page Page
rot byte

Returns

bool

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

inventory PlayerInventory
jar ItemJar
page Page

Returns

bool

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

player Player
oldValue bool

UpdateSlots(WarfarePlayer)

Update the player's third-person model for other players.

public static void UpdateSlots(WarfarePlayer player)

Parameters

player WarfarePlayer