Skip to content

Quick start

using ZazuLabs.Arcana;

// 1. Declare tags and attributes once.
var tags = GameplayTagRegistry.Build(new[] { "State.Debuff.Burning", "Data.Damage" });
var attributes = GameplayAttributeRegistry.Build(new[]
{
    new AttributeDefinition("MaxHealth", 100f) { MinValue = 1f },
    new AttributeDefinition("Health", 100f) { MinValue = 0f, MaxAttributeName = "MaxHealth" },
});
var health = attributes.Get("Health");

// 2. One world per game, ticked every frame.
var world = new ArcanaWorld(tags, attributes);

// 3. One ability system per actor.
var hero = world.CreateAbilitySystem();
hero.AddAttribute(attributes.Get("MaxHealth"));
hero.AddAttribute(health);

// 4. A burn: -5 Health per second for 3 seconds, and the Burning tag while it lasts.
var burn = new GameplayEffectDefinition("Burn", DurationPolicy.HasDuration)
{
    Duration = new ConstantMagnitude(3f),
    Period = 1f,
    GrantedTags = tags.CreateSet("State.Debuff.Burning"),
};
burn.Modifiers.Add(new ModifierDefinition(health, ModifierOp.Add, -5f));

hero.ApplyGameplayEffectToSelf(hero.MakeOutgoingSpec(burn));

// Every frame:
world.Tick(deltaTime);