Show / Hide Table of Contents

Class ItemHelper

Helper class for working with items.

Inheritance
Object
ItemHelper
Namespace: DaggerfallWorkshop.Game.Items
Assembly: Assembly-CSharp.dll
Syntax
public class ItemHelper

Constructors

| Improve this Doc View Source

ItemHelper()

Declaration
public ItemHelper()

Fields

| Improve this Doc View Source

LastDFTemplate

Declaration
public const int LastDFTemplate = 287
Field Value
Type Description
Int32
| Improve this Doc View Source

WagonKgLimit

Declaration
public static int WagonKgLimit
Field Value
Type Description
Int32

Properties

| Improve this Doc View Source

ArtifactItemTemplates

Array of magic item templates filtered to just artifact data.

Declaration
public MagicItemTemplate[] ArtifactItemTemplates { get; }
Property Value
Type Description
MagicItemTemplate[]
| Improve this Doc View Source

MagicItemTemplates

Array of all magic item templates including artifact data. Data is loaded from MagicItemTemplates.txt, a JSON dump of fixed MAGIC.DEF.

Declaration
public MagicItemTemplate[] MagicItemTemplates { get; }
Property Value
Type Description
MagicItemTemplate[]

Methods

| Improve this Doc View Source

AddSpellbookItem(PlayerEntity)

Gives a new spellbook item to player entity (if they don't already have one).

Declaration
public bool AddSpellbookItem(PlayerEntity playerEntity)
Parameters
Type Name Description
PlayerEntity playerEntity

Player entity to receive spellbook item.

Returns
Type Description
Boolean

True if spellbook added, false is player already has a spellbook item.

| Improve this Doc View Source

AssignEnemyStartingEquipment(PlayerEntity, EnemyEntity, Int32)

Declaration
public void AssignEnemyStartingEquipment(PlayerEntity player, EnemyEntity enemyEntity, int variant)
Parameters
Type Name Description
PlayerEntity player
EnemyEntity enemyEntity
Int32 variant
| Improve this Doc View Source

AssignStartingGear(PlayerEntity, CharacterDocument)

Assigns basic starting gear to a new character.

Declaration
public void AssignStartingGear(PlayerEntity playerEntity, CharacterDocument characterDocument)
Parameters
Type Name Description
PlayerEntity playerEntity
CharacterDocument characterDocument
| Improve this Doc View Source

ChangeDye(ImageData, DyeColors, DyeTargets)

Assigns a new Texture2D based on dye colour.

Declaration
public ImageData ChangeDye(ImageData imageData, DyeColors dye, DyeTargets target)
Parameters
Type Name Description
ImageData imageData
DyeColors dye
DyeTargets target
Returns
Type Description
ImageData
| Improve this Doc View Source

ConvertItemMaterialToAPIMetalType(DaggerfallUnityItem)

Converts native Daggerfall weapon and armor material types to generic Daggerfall Unity MetalType. The old metal type enum may be retired as true materials become better integrated.

Declaration
public MetalTypes ConvertItemMaterialToAPIMetalType(DaggerfallUnityItem item)
Parameters
Type Name Description
DaggerfallUnityItem item

Item to convert material to metal type.

Returns
Type Description
MetalTypes

MetalTypes.

| Improve this Doc View Source

ConvertItemToAPIWeaponType(DaggerfallUnityItem)

Converts Daggerfall weapon to generic API WeaponType.

Declaration
public WeaponTypes ConvertItemToAPIWeaponType(DaggerfallUnityItem item)
Parameters
Type Name Description
DaggerfallUnityItem item

Weapon to convert.

Returns
Type Description
WeaponTypes

WeaponTypes.

| Improve this Doc View Source

GetArmorDyeColor(ArmorMaterialTypes)

Converts armor material to appropriate dye colour.

Declaration
public DyeColors GetArmorDyeColor(ArmorMaterialTypes material)
Parameters
Type Name Description
ArmorMaterialTypes material

ArmorMaterialTypes.

Returns
Type Description
DyeColors

DyeColors.

| Improve this Doc View Source

GetArtifactName(ArtifactsSubTypes)

Gets name of artifact.

Declaration
public string GetArtifactName(ArtifactsSubTypes type)
Parameters
Type Name Description
ArtifactsSubTypes type

Artifact subtype.

Returns
Type Description
String

Artifact name.

| Improve this Doc View Source

GetArtifactSubType(String)

Gets an artifact sub type from an items' short name. (throws exception if no match)

Declaration
public static ArtifactsSubTypes GetArtifactSubType(string itemShortName)
Parameters
Type Name Description
String itemShortName

Item short name

Returns
Type Description
ArtifactsSubTypes

Artifact sub type.

| Improve this Doc View Source

GetArtifactTemplate(Int32)

Gets artifact template from magic item template data.

Declaration
public MagicItemTemplate GetArtifactTemplate(int artifactIndex)
Parameters
Type Name Description
Int32 artifactIndex
Returns
Type Description
MagicItemTemplate
| Improve this Doc View Source

GetArtifactTextureIndices(ArtifactsSubTypes, out Int32, out Int32)

Gets artifact texture indices

Declaration
public void GetArtifactTextureIndices(ArtifactsSubTypes type, out int textureArchiveOut, out int textureRecordOut)
Parameters
Type Name Description
ArtifactsSubTypes type

Artifact subtype.

Int32 textureArchiveOut

Texture archive out.

Int32 textureRecordOut

Texture record out.

| Improve this Doc View Source

GetBookTitle(Int32, String)

Gets the title of a book from its ID.

Declaration
public string GetBookTitle(int id, string defaultBookTitle)
Parameters
Type Name Description
Int32 id

The book's ID

String defaultBookTitle

The name the book should default to if the lookup fails. (Usually the Item's LongName..."Book" or "Parchment")

Returns
Type Description
String

The title of the bookd or defaultBookName if no name was found.

| Improve this Doc View Source

GetCloakInteriorImage(DaggerfallUnityItem)

Helper to get interior parts of cloak. This is not cached as only seen on paper doll during refresh.

Declaration
public ImageData GetCloakInteriorImage(DaggerfallUnityItem item)
Parameters
Type Name Description
DaggerfallUnityItem item

Item - must be a formal or casual cloak.

Returns
Type Description
ImageData

ImageData.

| Improve this Doc View Source

GetContainerImage(InventoryContainerImages)

Gets icon for a container object, such as the wagon.

Declaration
public ImageData GetContainerImage(InventoryContainerImages type)
Parameters
Type Name Description
InventoryContainerImages type

Container type.

Returns
Type Description
ImageData

ImageData.

| Improve this Doc View Source

GetCustomItemClass(Int32, out Type)

Declaration
public bool GetCustomItemClass(int templateIndex, out Type itemClassType)
Parameters
Type Name Description
Int32 templateIndex
Type itemClassType
Returns
Type Description
Boolean
| Improve this Doc View Source

GetCustomItemsForGroup(ItemGroups)

Declaration
public int[] GetCustomItemsForGroup(ItemGroups itemGroup)
Parameters
Type Name Description
ItemGroups itemGroup
Returns
Type Description
Int32[]
| Improve this Doc View Source

GetDyeColor(DaggerfallUnityItem)

Gets dye color automatically from item data.

Declaration
public DyeColors GetDyeColor(DaggerfallUnityItem item)
Parameters
Type Name Description
DaggerfallUnityItem item

DaggerfallUnityItem.

Returns
Type Description
DyeColors

DyeColors.

| Improve this Doc View Source

GetEnumArray(ItemGroups)

Helps bridge classic item index pair back to item template index.

Declaration
public Array GetEnumArray(ItemGroups group)
Parameters
Type Name Description
ItemGroups group

Group enum to retrieve.

Returns
Type Description
Array
| Improve this Doc View Source

GetGroupIndex(ItemGroups, Int32)

Gets item group index from group and template index.

Declaration
public int GetGroupIndex(ItemGroups itemGroup, int templateIndex)
Parameters
Type Name Description
ItemGroups itemGroup
Int32 templateIndex
Returns
Type Description
Int32

Item group index, or -1 if not found.

| Improve this Doc View Source

GetInventoryImage(DaggerfallUnityItem)

Declaration
public ImageData GetInventoryImage(DaggerfallUnityItem item)
Parameters
Type Name Description
DaggerfallUnityItem item
Returns
Type Description
ImageData
| Improve this Doc View Source

GetItemImage(DaggerfallUnityItem, Boolean, Boolean, Boolean)

Gets inventory/equip image for specified item. Image will be cached based on material and hand for faster subsequent fetches. Animated item images do not support dyes.

Declaration
public ImageData GetItemImage(DaggerfallUnityItem item, bool removeMask = false, bool forPaperDoll = false, bool allowAnimation = false)
Parameters
Type Name Description
DaggerfallUnityItem item

Item to fetch image for.

Boolean removeMask

Removes mask index (e.g. around helmets) from final image.

Boolean forPaperDoll

Image is for paper doll.

Boolean allowAnimation

Read animated textures.

Returns
Type Description
ImageData

ImageData.

| Improve this Doc View Source

GetItemImage(DaggerfallUnityItem, Color, Boolean)

Gets item image with custom mask colour.

Declaration
public ImageData GetItemImage(DaggerfallUnityItem item, Color maskColor, bool forPaperDoll = false)
Parameters
Type Name Description
DaggerfallUnityItem item

Item to fetch image for.

Color maskColor

New mask colour.

Boolean forPaperDoll

Image is for paper doll.

Returns
Type Description
ImageData

ImageData.

| Improve this Doc View Source

GetItemInfo(DaggerfallUnityItem, ITextProvider)

Declaration
public static TextFile.Token[] GetItemInfo(DaggerfallUnityItem item, ITextProvider textProvider)
Parameters
Type Name Description
DaggerfallUnityItem item
ITextProvider textProvider
Returns
Type Description
TextFile.Token[]
| Improve this Doc View Source

GetItemTemplate(ItemGroups, Int32)

Gets item template data using group and index.

Declaration
public ItemTemplate GetItemTemplate(ItemGroups itemGroup, int groupIndex)
Parameters
Type Name Description
ItemGroups itemGroup
Int32 groupIndex
Returns
Type Description
ItemTemplate
| Improve this Doc View Source

GetItemTemplate(Int32)

Gets item template from direct template index.

Declaration
public ItemTemplate GetItemTemplate(int templateIndex)
Parameters
Type Name Description
Int32 templateIndex
Returns
Type Description
ItemTemplate
| Improve this Doc View Source

GetItemUseHandler(Int32, out ItemHelper.ItemUseHandler)

Declaration
public bool GetItemUseHandler(int templateIndex, out ItemHelper.ItemUseHandler itemUseHandler)
Parameters
Type Name Description
Int32 templateIndex
ItemHelper.ItemUseHandler itemUseHandler
Returns
Type Description
Boolean
| Improve this Doc View Source

GetRandomBookID()

Obtaining a random book ID is useful for generating books in loot drops, store inventories, etc. If custom books are available, they are chosen only if specified conditions are met.

Declaration
public int GetRandomBookID()
Returns
Type Description
Int32

A random book ID

| Improve this Doc View Source

GetWeaponDyeColor(WeaponMaterialTypes)

Converts weapon material to appropriate dye colour.

Declaration
public DyeColors GetWeaponDyeColor(WeaponMaterialTypes material)
Parameters
Type Name Description
WeaponMaterialTypes material

WeaponMaterialTypes.

Returns
Type Description
DyeColors

DyeColors.

| Improve this Doc View Source

IsCloak(DaggerfallUnityItem)

Checks if this item is a formal or casual cloak.

Declaration
public bool IsCloak(DaggerfallUnityItem item)
Parameters
Type Name Description
DaggerfallUnityItem item

Item to check.

Returns
Type Description
Boolean

True if formal or casual cloak.

| Improve this Doc View Source

RegisterCustomItem(Int32, ItemGroups, Type)

Registers a custom item defined by an item template entry for in-game generation and with a custom implementation class if required.

Declaration
public void RegisterCustomItem(int templateIndex, ItemGroups itemGroup = ItemGroups.None, Type itemClassType = null)
Parameters
Type Name Description
Int32 templateIndex

Template index to use for the item, must match entry in item templates

ItemGroups itemGroup

Set to assign the item to a group for purposes of loot generation and shop stocking

Type itemClassType

Provide the Type of a custom implementation class to be used, which must extend DaggerfallUnityItem

| Improve this Doc View Source

RegisterItemUseHandler(Int32, ItemHelper.ItemUseHandler)

Registers a custom usage handler for a given item template index. Not required for custom items with implementing classes, override UseItem() instead.

Declaration
public void RegisterItemUseHandler(int templateIndex, ItemHelper.ItemUseHandler itemUseHandler)
Parameters
Type Name Description
Int32 templateIndex

Template index of the item, can be either a classic or custom item

ItemHelper.ItemUseHandler itemUseHandler
| Improve this Doc View Source

ResolveItemLongName(DaggerfallUnityItem, Boolean)

Resolves full item name using parameters like %it and material type.

Declaration
public string ResolveItemLongName(DaggerfallUnityItem item, bool differentiatePlantIngredients = true)
Parameters
Type Name Description
DaggerfallUnityItem item
Boolean differentiatePlantIngredients
Returns
Type Description
String
| Improve this Doc View Source

ResolveItemName(DaggerfallUnityItem)

Resolves full item name using parameters like %it.

Declaration
public string ResolveItemName(DaggerfallUnityItem item)
Parameters
Type Name Description
DaggerfallUnityItem item
Returns
Type Description
String
| Improve this Doc View Source

ValidateSpellbookItem(PlayerEntity)

Ensures that a player has a valid spellbook item on load.

Declaration
public void ValidateSpellbookItem(PlayerEntity playerEntity)
Parameters
Type Name Description
PlayerEntity playerEntity
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX