Namespace: GGG.Items

Provides stable lookup of item definitions by their serialized IDs.

[CreateAssetMenu(fileName = "ItemCatalog", menuName = "GGG/Items/Item Catalog")]
public sealed class ItemCatalog : ScriptableObject

Inheritance

object ← Object ← ScriptableObject ← ItemCatalog

Inherited Members

ScriptableObject.SetDirty(), ScriptableObject.CreateInstance(string), ScriptableObject.CreateInstance(Type), ScriptableObject.CreateInstance<T>(), Object.GetEntityId(), Object.GetInstanceID(), Object.GetHashCode(), Object.Equals(object), Object.InstantiateAsync<T>(T), Object.InstantiateAsync<T>(T, Transform), Object.InstantiateAsync<T>(T, Vector3, Quaternion), Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion), Object.InstantiateAsync<T>(T, int), Object.InstantiateAsync<T>(T, int, Transform), Object.InstantiateAsync<T>(T, int, Vector3, Quaternion), Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>), Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion), Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion, CancellationToken), Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>), Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, CancellationToken), Object.InstantiateAsync<T>(T, InstantiateParameters, CancellationToken), Object.InstantiateAsync<T>(T, int, InstantiateParameters, CancellationToken), Object.InstantiateAsync<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken), Object.InstantiateAsync<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken), Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, InstantiateParameters, CancellationToken), Object.Instantiate(Object, Vector3, Quaternion), Object.Instantiate(Object, Vector3, Quaternion, Transform), Object.Instantiate(Object), Object.Instantiate(Object, Scene), Object.Instantiate<T>(T, InstantiateParameters), Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters), Object.Instantiate(Object, Transform), Object.Instantiate(Object, Transform, bool), Object.Instantiate<T>(T), Object.Instantiate<T>(T, Vector3, Quaternion), Object.Instantiate<T>(T, Vector3, Quaternion, Transform), Object.Instantiate<T>(T, Transform), Object.Instantiate<T>(T, Transform, bool), Object.Destroy(Object, float), Object.Destroy(Object), Object.DestroyImmediate(Object, bool), Object.DestroyImmediate(Object), Object.FindObjectsOfType(Type), Object.FindObjectsOfType(Type, bool), Object.FindObjectsByType(Type, FindObjectsSortMode), Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode), Object.FindObjectsByType(Type), Object.FindObjectsByType(Type, FindObjectsInactive), Object.DontDestroyOnLoad(Object), Object.DestroyObject(Object, float), Object.DestroyObject(Object), Object.FindSceneObjectsOfType(Type), Object.FindObjectsOfTypeIncludingAssets(Type), Object.FindObjectsOfType<T>(), Object.FindObjectsByType<T>(FindObjectsSortMode), Object.FindObjectsOfType<T>(bool), Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode), Object.FindObjectOfType<T>(), Object.FindObjectOfType<T>(bool), Object.FindFirstObjectByType<T>(), Object.FindAnyObjectByType<T>(), Object.FindFirstObjectByType<T>(FindObjectsInactive), Object.FindAnyObjectByType<T>(FindObjectsInactive), Object.FindObjectsByType<T>(), Object.FindObjectsByType<T>(FindObjectsInactive), Object.FindObjectsOfTypeAll(Type), Object.FindObjectOfType(Type), Object.FindFirstObjectByType(Type), Object.FindAnyObjectByType(Type), Object.FindObjectOfType(Type, bool), Object.FindFirstObjectByType(Type, FindObjectsInactive), Object.FindAnyObjectByType(Type, FindObjectsInactive), Object.ToString(), Object.name, Object.hideFlags, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Properties

Count

Gets the number of entries in the collection.

public int Count { get; }

Property Value

int

Definitions

Gets the definitions registered in the catalog.

public IReadOnlyList<ItemDefinition> Definitions { get; }

Property Value

IReadOnlyList<ItemDefinition>

Methods

Contains(string)

Determines whether the collection contains the specified value.

public bool Contains(string id)

Parameters

id string

The stable identifier to look up.

Returns

bool

Whether the specified condition is satisfied.

Contains(ItemDefinition)

Determines whether the collection contains the specified value.

public bool Contains(ItemDefinition definition)

Parameters

definition ItemDefinition

The item or inventory definition to inspect or use.

Returns

bool

Whether the specified condition is satisfied.

GetRequired(string)

Gets the matching definition or throws if it is absent.

public ItemDefinition GetRequired(string id)

Parameters

id string

The stable identifier to look up.

Returns

ItemDefinition

The matching definition.

RebuildLookup()

Rebuilds the runtime lookup and throws when the catalog is invalid. Useful for startup validation and automated tests.

public void RebuildLookup()

TryGet(string, out ItemDefinition)

Attempts to retrieve a definition by its identifier.

public bool TryGet(string id, out ItemDefinition definition)

Parameters

id string

The stable identifier to look up.

definition ItemDefinition

Receives the resulting definition when successful.

Returns

bool

Whether the operation succeeded.