#if GRAPH_DESIGNER /// --------------------------------------------- /// Graph Designer /// Copyright (c) Opsive. All Rights Reserved. /// https://www.opsive.com /// --------------------------------------------- namespace Opsive.GraphDesigner.Runtime.Variables.ECS { using Unity.Entities; /// /// Lightweight typed index into a SharedVariableElement buffer. /// Store this in your IBufferElementData component instead of a raw int field to get type-safe access to a shared variable value from within a Burst job. /// public readonly struct ECSSharedVariableIndex where T : unmanaged { /// /// The index of the shared variable within the shared variable buffer. /// public readonly int Index; /// /// Initializes a new instance of the struct. /// /// The index of the shared variable within the shared variable buffer. public ECSSharedVariableIndex(int index) => Index = index; /// /// Reads the current value from the shared variable buffer at this index. /// /// The buffer that stores the shared variable values. /// The value stored at this shared variable index. public T Get(DynamicBuffer buffer) => buffer.Get(Index); /// /// Writes a value into the shared variable buffer at this index. /// /// The buffer that stores the shared variable values. /// The value that should be written to the shared variable buffer. public void Set(DynamicBuffer buffer, T value) => buffer.Set(Index, value); } } #endif