Game.Zones.ValidArea
Assembly:
Game (Assembly-CSharp.dll)
Namespace:
Game.Zones
Type:
struct
Base:
IComponentData, IQueryTypeParameter, ISerializable
Summary:
ValidArea is an ECS component used to store a rectangular integer area using Unity.Mathematics.int4 and supports custom serialization. It implements IComponentData so it can be attached to Entities, IQueryTypeParameter so it can be used in entity queries, and ISerializable so its data is written/read during save/load (or other writer/reader flows used by the game). The int4 holds four integer components — commonly used to represent rectangular bounds (for example: minX, minY, maxX, maxY), though the exact semantic ordering depends on how callers in the game interpret the components.
Fields
public Unity.Mathematics.int4 m_Area
Stores four integer values that define the valid area. In practice this int4 is used as a rectangle/bounds container. Use the int4 components (x, y, z, w) according to the calling code's convention (e.g., minX, minY, maxX, maxY).
Properties
- None
Constructors
public ValidArea()
No explicit constructor is defined in the source; the struct uses the default parameterless constructor. Create and initialize an instance with object initializer syntax, for example:
var area = new ValidArea { m_Area = new int4(minX, minY, maxX, maxY) };
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_Area int4 to the provided writer using writer.Write(m_Area). This method is invoked by the game's serialization system to persist the component state. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the m_Area int4 from the provided reader using reader.Read(out m_Area). This method is invoked by the game's deserialization system to restore the component state.
Notes: - The generic writer/reader types are constrained to IWriter/IReader used by the game's (de)serialization framework. - Because the component directly serializes a Unity.Mathematics.int4, ensure any versioning or layout changes are compatible with save/load expectations.
Usage Example
using Unity.Entities;
using Unity.Mathematics;
using Game.Zones;
// Create an entity and attach a ValidArea component
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = entityManager.CreateArchetype(typeof(ValidArea));
Entity e = entityManager.CreateEntity(archetype);
// Assign bounds to the component (example: minX, minY, maxX, maxY)
entityManager.SetComponentData(e, new ValidArea { m_Area = new int4(0, 0, 127, 127) });
// Later, read it back
ValidArea va = entityManager.GetComponentData<ValidArea>(e);
int4 bounds = va.m_Area;
{{ Additional pointers for modders: - Use ValidArea when you need to tag entities with an integer rectangle in ECS code (e.g., zoning/region checks). - Because it implements ISerializable, ValidArea will participate in the game's save/load pipeline automatically if the containing entity/component set is serialized by the game's systems. - When querying entities by this component in SystemBase or JobComponentSystem, use the normal ECS patterns (EntityQuery, GetComponentData, etc.). }}