-
Notifications
You must be signed in to change notification settings - Fork 0
Atomic File Syntax
Yaroslav Sarchuk edited this page Aug 29, 2025
·
2 revisions
Complete syntax reference for .atomic configuration files using YAML-style format.
An atomic file consists of:
- Configuration properties (required & optional)
- Imports section (optional) - list format
- Tags section (optional) - list format
- Values section (optional) - list format with type mappings
# Configuration Properties
namespace: Game.Components
className: EntityExtensions
entityType: IEntity
# Optional Properties
directory: Generated
aggressiveInlining: true
unsafe: false
# Sections
imports:
- Atomic.Entities
- UnityEngine
- System.Collections.Generic
tags:
- Player
- Enemy
- Dead
values:
- Health: int
- Position: Vector3
- Inventory: List<Item>
| Property | Type | Description | Example |
|---|---|---|---|
namespace |
string | Target C# namespace | Game.Components |
className |
string | Generated class name | EntityExtensions |
entityType |
string | Base entity type |
IEntity, GameObject
|
| Property | Type | Default | Description | Example |
|---|---|---|---|---|
directory |
string | same as source | Output directory |
Generated, Assets/Scripts
|
solution |
string | current | Target solution | MyGame.sln |
aggressiveInlining |
bool | false | Enable aggressive inlining |
true, false
|
unsafe |
bool | false | Enable unsafe code |
true, false
|
Note: The header property was removed in v0.1.4. Generated files now include a standard header automatically.
# String values - quotes optional for single words
namespace: MyGame.Components
namespace: "MyGame.Components"
namespace: 'Complex Name With Spaces'
# Boolean values
aggressiveInlining: true
unsafe: false
# Paths - relative or absolute
directory: Generated
directory: "Assets/Scripts/Generated"
directory: "../Shared/Generated"
Defines C# namespaces to import in the generated file.
imports:
- System
- System.Collections.Generic
- UnityEngine
- MyGame.Core
- Atomic.Entities # Always included by default
- List format with
-prefix - One namespace per line
- Proper indentation required (2 spaces recommended)
- No semicolons or import keywords needed
-
Atomic.Entitiesis always included automatically -
using static Atomic.Entities.EntityNamesis always added
Defines boolean flags for entities.
tags:
- Player
- Enemy
- Projectile
- Dead
- Invincible
- List format with
-prefix - One tag per line
- PascalCase recommended
- No spaces in tag names
- Generates methods:
Has{Tag}Tag(),Add{Tag}Tag(),Del{Tag}Tag()
public static readonly int Player;
static ClassName()
{
Player = NameToId(nameof(Player));
}
public static bool HasPlayerTag(this IEntity entity) => entity.HasTag(Player);
public static bool AddPlayerTag(this IEntity entity) => entity.AddTag(Player);
public static bool DelPlayerTag(this IEntity entity) => entity.DelTag(Player);Defines typed properties for entities.
values:
- Health: int
- MaxHealth: int
- Position: Vector3
- Velocity: Vector3
- Name: string
- Items: List<Item>
- Attributes: Dictionary<string, float>
- List format with
-prefix - Format:
- PropertyName: Type - PascalCase for property names
- Any C# type can be used
- Generic types supported
values:
# Primitive types
- Count: int
- Price: float
- IsActive: bool
- Name: string
# Unity types
- Position: Vector3
- Rotation: Quaternion
- Transform: Transform
- Sprite: Sprite
# Collections
- Items: List<Item>
- Waypoints: Vector3[]
- Stats: Dictionary<string, int>
- UniqueIds: HashSet<Guid>
# Custom types
- Player: PlayerData
- Config: GameConfiguration
public static readonly int Health; // int
static ClassName()
{
Health = NameToId(nameof(Health));
}
public static int GetHealth(this IEntity entity) => entity.GetValue<int>(Health);
public static void SetHealth(this IEntity entity, int value) => entity.SetValue(Health, value);
public static bool HasHealth(this IEntity entity) => entity.HasValue(Health);
public static void AddHealth(this IEntity entity, int value) => entity.AddValue(Health, value);
public static bool DelHealth(this IEntity entity) => entity.DelValue(Health);
public static bool TryGetHealth(this IEntity entity, out int value) => entity.TryGetValue(Health, out value);
// If unsafe: true
public static ref int RefHealth(this IEntity entity) => ref entity.GetRef<int>(Health);namespace: Game
className: BasicExtensions
entityType: IEntity
tags:
- Active
values:
- Health: int
namespace: Game.Components
className: EntityComponents
entityType: IEntity
directory: "Generated/Components"
aggressiveInlining: true
unsafe: true
imports:
- System
- System.Collections.Generic
- UnityEngine
- Game.Core
- Game.Items
tags:
# Flags
- Player
- Enemy
- Dead
- Invincible
# States
- Moving
- Attacking
- Defending
values:
# Basic stats
- Health: int
- MaxHealth: int
- Mana: float
- MaxMana: float
# Movement
- Position: Vector3
- Velocity: Vector3
- Speed: float
# Combat
- Damage: float
- Defense: float
- CritChance: float
# Inventory
- Items: List<Item>
- Equipment: Dictionary<SlotType, Item>
# References
- Transform: Transform
- Animator: Animator
Comments are supported using #:
# This is a comment
namespace: Game # Inline comment
# Section comments
tags:
- Player # Player tag
- Enemy # Enemy tag
values:
# Health system
- Health: int
- MaxHealth: int
# Movement system
- Position: Vector3
- Velocity: Vector3
The plugin validates:
-
namespacemust be present -
classNamemust be present -
entityTypemust be present
- Tag/value names must be valid C# identifiers
- No duplicate tag names
- No duplicate value names
- Tags and values cannot share names
- Value types must be valid C# types
- Types must be resolvable from imports
- Generic types must have type arguments
# ERROR: Missing required field
className: Test
# Missing namespace and entityType
# ERROR: Duplicate names
tags:
- Player
- Player # Duplicate!
# ERROR: Invalid type
values:
- Health: NotAType # Type not found
# ERROR: Invalid identifier
tags:
- 123Invalid # Cannot start with number
- Has-Dash # Invalid character
-
Organization
- Group related tags and values with comments
- Use consistent naming conventions
- Keep files focused on one system
-
Performance
- Enable
aggressiveInliningfor hot paths - Use
unsafeonly when profiling shows benefit - Keep imports minimal
- Enable
-
Naming
- Use PascalCase for tags and values
- Use descriptive names
- Avoid abbreviations
-
Types
- Prefer simple types when possible
- Use Unity types for Unity projects
- Document complex types with comments
entityType: Entity
namespace: Game
className: Extensions
tags:
Player
Enemy
values:
Health: int
Position: Vector3
namespace: Game
className: Extensions
entityType: IEntity
tags:
- Player
- Enemy
values:
- Health: int
- Position: Vector3
- Properties can be in any order
-
imports,tags, andvaluesuse list format with- -
entityTypetypically usesIEntityinterface - Consistent YAML-style formatting
Note: The syntax follows YAML conventions for better readability and consistency.