Skip to content

API reference Obsidian.API.Inventory.DataComponents

SimpleDataComponent<TValue> record

A component whose payload is immutable, or isolated with a defensive copy function.

public record SimpleDataComponent<TValue> : DataComponent, IEquatable<SimpleDataComponent<TValue>>

In Obsidian.API.

Remarks

Mutable payload types require a copy function that isolates every mutable child on assignment and retrieval.

Constructors

public SimpleDataComponent(DataComponentType type, string identifier, Action<INetStreamWriter, TValue> writer, Func<INetStreamReader, TValue> reader, Func<TValue, TValue> copy = null);

Properties

public override string Identifier { get; }public override DataComponentType Type { get; }protected TValue value { get; set; }public TValue Value { get; init; }

Methods

public virtual bool Equals(SimpleDataComponent<TValue> other);public override int GetHashCode();protected override void ReadCore(INetStreamReader reader);

Write(INetStreamWriter)

public override void Write(INetStreamWriter writer);

Writes the stored value without allocating another defensive copy.

Remarks

The writer delegate and stream writer must neither mutate nor retain mutable payload arguments.

On this page