Skip to content

Game.Tools.BrushDefinition

Assembly: Assembly-CSharp
Namespace: Game.Tools

Type: struct

Base: System.ValueType, implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary:
BrushDefinition is a plain ECS component that encapsulates the parameters of a brush/tool action in the game's tool system (e.g., painting, terraforming or any cursor-based tool). It stores references to the tool entity, the geometric trace (line segment) for the brush, orientation, size and strength parameters, timing, and start/target positions. As an IComponentData, this struct is intended to be attached to Entities so systems can read/update brush state in a data-oriented manner.


Fields

  • public Entity m_Tool
    Entity reference to the tool instance that produced or owns this brush state. Used to associate the brush parameters with a specific tool entity.

  • public Line3.Segment m_Line
    Geometric line segment (from Colossal.Mathematics) representing the brush trace or ray/segment used for hit-testing and projection in world space.

  • public float m_Angle
    Orientation/rotation angle for the brush in radians (or degrees depending on consuming systems) — used to orient brush shape or directional effects.

  • public float m_Size
    Brush size (radius or extent). Determines the area of influence for the brush action.

  • public float m_Strength
    Brush strength/intensity (e.g., how strong a paint or terrain modification is). Typically normalized (0..1) but interpretation is up to consuming systems.

  • public float m_Time
    Timestamp or time accumulator for the brush action. Can be used for temporal interpolation, smoothing, or delta-time-based behavior.

  • public float3 m_Target
    Target world position (float3) where the brush is aimed/applied (e.g., hit point on terrain or object).

  • public float3 m_Start
    Start world position (float3) for the brush action (e.g., initial grab point for drag-based brushes).

Properties

  • This struct exposes no C# properties. It is a plain data container (public fields only) suitable for ECS usage.

Constructors

  • public BrushDefinition()
    No explicit constructors are defined in the source. The default parameterless constructor provided by C# is used; initialize instances using object initializers or by assigning fields directly. Because this is a value type (struct), it will be zero-initialized by default when created with default(BrushDefinition) or when added as a component.

Methods

  • This struct defines no methods. All behavior is expected to be implemented in systems that read/write this component.

Usage Example

using Unity.Entities;
using Unity.Mathematics;
using Colossal.Mathematics;
using Game.Tools;

// Example: create an Entity with BrushDefinition and initialize fields
var em = World.DefaultGameObjectInjectionWorld.EntityManager;

// Create an entity archetype containing BrushDefinition (or use an existing entity)
var archetype = em.CreateArchetype(typeof(BrushDefinition));
var e = em.CreateEntity(archetype);

// Initialize a Line3.Segment (use appropriate constructor/fields for your version)
Line3.Segment line = default; // placeholder — construct properly according to the game's Line3 API

var brush = new BrushDefinition
{
    m_Tool = Entity.Null,
    m_Line = line,
    m_Angle = 0f,
    m_Size = 5.0f,
    m_Strength = 1.0f,
    m_Time = (float)UnityEngine.Time.time,
    m_Target = new float3(10f, 0f, 20f),
    m_Start = new float3(10f, 0f, 15f)
};

em.SetComponentData(e, brush);

Additional notes: - All fields are blittable types (Entity, floats, float3, and Colossal's Line3.Segment), making this component suitable for high-performance ECS usage and jobs. - Consumers (systems/jobs) should agree on units/semantics for m_Angle and m_Time (e.g., radians vs degrees, absolute time vs delta).