-
Notifications
You must be signed in to change notification settings - Fork 0
Runtime and Presentation
Custom opcodes need a runtime handler. Register all routes during initialization, before any generated operation executes.
using AutoAnthony;
ComponentRuntimeApi.RegisterPackage(
"my_watcher:autoanthony:runtime",
[
new ComponentRuntimeRoute(
"watcher_stance",
"enter_calm",
new EnterCalmHandler())
]);
sealed class EnterCalmHandler : IComponentRuntimeHandler
{
public async Task<bool> ExecuteAsync(ComponentRuntimeContext context)
{
await WatcherActions.EnterCalm(context.Card.Owner, context.Amount);
return true;
}
}WatcherActions above represents the owning mod's normal game-action implementation. A handler returning true
owns the operation completely. Returning false continues into AutoAnthony's legacy compatibility dispatcher.
ComponentRuntimeContext exposes:
-
Card,OperationIndex,Operation, and validatedRuntimeSpec - resolved
Amount, including supported X/dependency scaling -
Target,CardPlay,ChoiceContext,IsTriggered,EventCard, andEventAmount - read-only named
CardSlots -
RecordDamageDealt,ReplaceDrawnCards, andSetCardSlotfor sibling-operation state -
RequestEndTurn()for the same deferred, play-phase-safe end-turn path used by built-in effects
Handlers must await all game actions they create. Do not open an interactive choice from an enemy-only timing unless the owning mechanic has a safe noninteractive path. Do not resolve semantics from localized card text.
ComponentPresentationApi.RegisterPackage(
"my_watcher:autoanthony:presentation",
[new ComponentPresentationRoute(
"watcher_stance", "enter_calm", new CalmHoverTips())]);
sealed class CalmHoverTips : IComponentHoverTipProvider
{
public IEnumerable<IHoverTip> BuildHoverTips(ComponentPresentationContext context)
{
return [WatcherHoverTips.Calm()];
}
}Presentation routes are optional. Exact opcode/variant routes override an opcode-wide registration using an empty variant. Providers receive the generated card, operation index, operation, runtime spec, and upgrade state.
Avoid adding a tip that merely repeats the generated card's own same-name Power. Respect AutoAnthony's Surprise Mode: the host suppresses registered tips when the card should remain hidden.
Register a stable ASCII ID in ComponentPackageRegistration.Keywords, put that ID on source recipes, and register
its game projection with ComponentKeywordRuntimeApi.RegisterPackage. An IComponentKeywordRuntimeAdapter may
provide native CardKeyword values, semantic card tags, hover tips, and an upgrade callback. The keyword's actual
gameplay and balance still belong to a structured operation with runtime and valuation routes.
Runtime, presentation, and keyword package registration preflights the whole route set before committing it. Prefer the package APIs so one duplicate route cannot leave a partially registered integration.
Source · Steam Workshop · AutoAnthony 0.3.32 · API v3