Game.Net.ResourceAvailability
Assembly: Game (namespace defined in the game's runtime assemblies, e.g., Assembly-CSharp.dll)
Namespace: Game.Net
Type: struct
Base: System.ValueType
Implements: Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.ISerializable
Summary: ResourceAvailability is a lightweight buffer element used to store availability information as a float2 value. It is marked with InternalBufferCapacity(0) so it is intended to be used as a dynamic buffer element on entities. The struct provides serialization support via the ISerializable interface so instances can be written to and read from the game's custom serialization system.
Fields
-
public Unity.Mathematics.float2 m_Availability
Holds the availability values (two-component vector). The semantic meaning of each component depends on the caller (for example different resource axes or availability metrics). Defaults to float2.zero for a default-initialized struct. -
[InternalBufferCapacity(0)]
(applies to the struct) Indicates this buffer element has an internal buffer capacity of 0. In Unity's ECS this means no inline storage is reserved on the entity; the buffer will be stored as a dynamic buffer heap allocation.
Properties
- None declared. This struct does not expose properties. It is a plain data container intended for use as a dynamic buffer element (IBufferElementData).
Constructors
- Implicit default constructor (value type) No explicit constructors are defined. The default/implicit constructor will initialize m_Availability to float2.zero.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_Availability field to the provided writer. Used by Colossal.Serialization to serialize the buffer element. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads m_Availability from the provided reader. Used by Colossal.Serialization to deserialize the buffer element.
Usage Example
// Example: add a dynamic buffer of ResourceAvailability to an entity and set a value
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = entityManager.CreateArchetype(typeof(Unity.Entities.DynamicBuffer<ResourceAvailability>));
var entity = entityManager.CreateEntity(archetype);
// Add an element to the buffer
var buffer = entityManager.GetBuffer<ResourceAvailability>(entity);
buffer.Add(new ResourceAvailability { m_Availability = new Unity.Mathematics.float2(0.75f, 0.25f) });
// Serialization/deserialization is handled by the game's Colossal.Serialization system
// via the Serialize/Deserialize methods when components/buffers are saved/loaded.
Notes:
- Use this struct as elements of DynamicBuffer