Skip to content

Getting Started

Michael Yarichuk edited this page Oct 18, 2026 · 1 revision

Getting Started

1. Install

dotnet add package RoguelikeToolkit.Entities

Depends only on DefaultEcs and YamlDotNet. Unity users: see the Unity Guide.

2. Write a component

Components are plain classes or structs with settable properties. Mark them with [Component].

using RoguelikeToolkit.Entities;

[Component]
public class Health
{
    public int Max { get; set; }
    public int Current { get; set; }
}

[Component]
public class Speed
{
    public int Value { get; set; }
}

The component's name in templates is the type name unless you set [Component(Name = "...")]. Matching is case-insensitive.

3. Write templates

templates.yaml:

EnemyBase:
  Tags: [AI, CanMove]
  Components:
    Health: { Max: 10, Current: 10 }
    Speed:  { Value: 5 }

Goblin:
  Inherits: [EnemyBase]
  Tags: [Goblin]
  Components:
    Health: { Max: 15, Current: 15 }

4. Load and spawn

using DefaultEcs;
using RoguelikeToolkit.Entities.Repository;
using RoguelikeToolkit.Entities.Factory;

var world = new World();
var repository = new EntityTemplateRepository();
repository.LoadTemplateFolder("path/to/templates");   // .yaml and .json

var factory = new EntityFactory(repository, world);
if (factory.TryCreate("Goblin", out Entity goblin))
{
    var hp = goblin.Get<Health>();
}

Inheritance replaces whole components, not single fields. Goblin's Health above fully replaces EnemyBase's Health, so set every field you care about.

Next steps

Clone this wiki locally