IItemFactory

Marker interface for item factories, constraining the generic parameters to Item and ItemData (or their subclasses). Used by ItemDatabase as the factory type for registration and lookup.

Definition

Namespace: Paragon.Townskeep.ItemSystem Assembly: Townskeep.dll

public interface IItemFactory<out TItem, out TData> : INetworkScriptableFactory<TItem, TData>
    where TItem : Item, IFactorable<TData>
    where TData : ItemData

Extends: INetworkScriptableFactory<TItem, TData>

Remarks

IItemFactory is a marker interface — it adds no new members beyond what INetworkScriptableFactory<TItem, TData> already provides. Its purpose is to:

  1. Constrain types — ensures that only factories producing Item subclasses with ItemData can be registered in the ItemDatabase.

  2. Enable covariant lookup — the out keywords on TItem and TData allow IItemFactory<Weapon, WeaponData> to be used where IItemFactory<Item, ItemData> is expected.

All members are inherited from the parent interfaces in the Scriptable Factory and Network systems.

Quick Lookup

Goal
How

Spawn an item

factory.NetworkSpawn(variantId) (inherited from INetworkScriptableFactory)

Get factory from database

ItemDatabase.GetFactory(itemId) returns IItemFactory<Item, ItemData>

Type-check a factory

if (factory is IItemFactory<Item, ItemData>)

Inherited Members (key methods)

These are inherited from INetworkScriptableFactory<TItem, TData> and IScriptableFactory<TItem, TData>:

Method
Source
Description

NetworkSpawn(int, ulong?, bool)

INetworkScriptableFactory

Spawn a networked item with variant ID

NetworkSpawn(ulong?, bool)

INetworkScriptableFactory

Spawn base variant networked

NetworkSpawnAsync(...)

INetworkScriptableFactory

Async network spawn

Spawn()

IScriptableFactory

Local (non-networked) spawn

Despawn(TItem)

IScriptableFactory

Return item to pool

GetData()

IScriptableFactory

Get the factory's TData

GetHashCode()

object

Returns ItemData.ItemID (overridden by ItemFactory)

Common Pitfalls

circle-exclamation

Examples

Retrieving and Using a Factory

Type-Safe Downcasting

See Also

  • ItemFactory — abstract class implementing this interface

  • ItemDatabase — registry using this interface for factory lookup

  • Item — the TItem constraint base type

  • ItemData — the TData constraint base type

Last updated