OpenMod Docs OpenMod Docs
OpenMod Docs OpenMod Docs
OpenMod .NET Plugin Framework.

Interface IItemSpawner

The service for spawning items.

Namespace: OpenMod.Extensions.Games.Abstractions.Items
Assembly: OpenMod.Extensions.Games.Abstractions.dll
Syntax
public interface IItemSpawner

Methods

| Improve this Doc View Source

GiveItemAsync(IInventory, String, IItemState)

Adds an item to the given inventory. The item will be dropped if the inventory is full.

Declaration
Task<IItemInstance> GiveItemAsync(IInventory inventory, string itemAssetId, IItemState state = null)
Parameters
Type Name Description
IInventory inventory

The inventory to add the item to.

System.String itemAssetId

The ID of the item asset.

IItemState state

The optional state of the item.

Returns
Type Description
Task<IItemInstance>

IInventoryItem if the inventory was not full; otherwise, IItemDrop. If spawning was not successful, null.

| Improve this Doc View Source

SpawnItemAsync(Vector3, String, IItemState)

Spawns an item.

Declaration
Task<IItemDrop> SpawnItemAsync(Vector3 position, string itemAssetId, IItemState state = null)
Parameters
Type Name Description
Vector3 position

The position to spawn the item at.

System.String itemAssetId

The ID of the item asset.

IItemState state

The optional state of the item.

Returns
Type Description
Task<IItemDrop>

The dropped item if successful; otherwise, null.

Extension Methods

ItemSpawnerExtensions.GiveItemAsync(IItemSpawner, IInventory, IItemAsset, IItemState)
ItemSpawnerExtensions.SpawnItemAsync(IItemSpawner, Vector3, IItemAsset, IItemState)
DisposeHelper.DisposeSyncOrAsync(Object)