Game.BufferedEntity
Assembly:
Assembly-CSharp (or the game's runtime assembly where Game.Common is compiled)
Namespace: Game.Common
Type: struct
Base: System.ValueType
Summary: A lightweight value-type wrapper that holds a Unity.Entities.Entity and a boolean flag indicating whether that entity is considered "stored" in a buffer. Useful for simple frame-to-frame buffering or bookkeeping of entity references in game systems or mod code. Because it is a plain struct with public fields it is inexpensive to copy and can be stored in arrays or lists. Note: it does not perform any validity checks on the Entity value (e.g., Entity.Null).
Fields
-
public Unity.Entities.Entity m_Value
Holds the DOTS Entity value referenced by this buffered entry. This is the primary identifier for the buffered object. The field is public and mutable; the code using this struct is responsible for ensuring the Entity is valid when needed. -
public bool m_Stored
Boolean flag indicating whether the corresponding entry is currently "stored" or active in the buffer. Typically used to mark whether m_Value contains meaningful data.
Properties
- This type defines no properties. It exposes its data via public fields (m_Value and m_Stored).
Constructors
public BufferedEntity(Unity.Entities.Entity value, bool stored)
Initializes a new BufferedEntity with the provided Entity and stored flag. Use this to create entries with an explicit stored state.
Methods
public override string ToString() : System.String
Returns a formatted string representing the struct in the form "m_Value:, m_Stored: ". Useful for logging and debugging. No other methods (Equals/GetHashCode) are overridden.
Usage Example
using Unity.Entities;
using Game.Common;
using UnityEngine;
public class BufferedEntityExample : MonoBehaviour
{
void Start()
{
// Example entity (in real use you'd get this from an EntityManager or system)
Entity someEntity = Entity.Null;
// Create a buffered entry
BufferedEntity entry = new BufferedEntity(someEntity, false);
// Update it
entry.m_Value = someEntity;
entry.m_Stored = true;
// Debug output
Debug.Log(entry.ToString()); // prints: "m_Value: 0, m_Stored: True" (Entity formatting depends on runtime)
}
}
Additional notes: - Because this is a simple struct, it is cheap to copy; use arrays or NativeArray-like containers if you need large buffers. - When using in Unity Jobs or Native containers, ensure the layout and types are compatible with your chosen container; Entity is DOTS-friendly, and the struct contains only blittable types.