Skip to content

Extending the Kit

Every part of the kit can be replaced from your own code, in your own folder, without editing a kit file. That way updating the kit never overwrites your changes. Each part is an interface or a class whose members are virtual. The kit’s own tests include a project-style test assembly that replaces every one of them and plays matches.

To replace Implement or subclass Plug it in through
Network transport IHostTransport, IClientTransport MatchInstaller.CreateHost / CreateClient, or your own bootstrap
Wire format IMessageSerializer MatchInstaller.CreateSerializer
Registered commands and events WireRegistry MatchInstaller.CreateRegistry
The host MatchHost MatchInstaller.CreateHost
Turn order and phases TurnSystem MatchHost.CreateMatch (set Match.Turns)
Order abilities resolve in IResolutionPolicy MatchHost.CreateMatch (set Match.ResolutionPolicy)
Legal moves offered ILegalMoveGenerator / DefaultLegalMoveGenerator MatchHost.CreateMatch (set Match.LegalMoves)
Random numbers IRandom MatchHost.CreateMatch (Match.CreateInitialState)
What each player sees ViewBuilder MatchHost.Views
Deck checks at the host DeckValidator MatchHost.DeckValidator
Combat ICombatRules a CombatRulesDefinition asset
Rules in code IGameRule a GameRuleDefinition asset
Deck-building restrictions IDeckRule a DeckRuleDefinition asset
How definitions compile RulesCompiler GameDefinition.Compile callers, or your installer’s CompileRules
Computer player IPlayerAgent AIProfile.CreateAgent
How positions are scored IStateEvaluator AIProfile.CreateEvaluator
Save storage IProfileStore CollectionSettings.CreateStore
Economy and deck editing CollectionService CollectionSettings.CreateService
Pack contents IPackOpener CollectionService.Opener
Card lookup ICardDatabase MatchInstaller.Cards
Card visuals CardView a card prefab, per card type or as the board default
Zone layout ZoneLayout the ZoneView’s Layout
Animations EventAnimator<T> a component under the MatchPresenter
Controls MatchInput the MatchPresenter’s Input
Abilities TriggerNode, EffectNode, FlowNode, TargetNode, ValueNode appear in the graph editor by themselves
Player actions GameCommand registered in CreateRegistry, offered by your ILegalMoveGenerator
Things that happen GameEvent registered in CreateRegistry, emitted with ExecutionContext.Emit

MatchInstaller is a ScriptableObject. Subclass it, add [CreateAssetMenu], create an asset of your subclass and assign it to the bootstrap.

[CreateAssetMenu(menuName = "My Game/Installer")]
public class MyInstaller : MatchInstaller
{
public override WireRegistry CreateRegistry() =>
base.CreateRegistry().Register<ShuffleHandCommand>("mygame.shuffleHand");
public override MatchHost CreateHost(Ruleset rules, IHostTransport transport, IMessageSerializer serializer, ulong seed) =>
new MyHost(rules, transport, serializer, seed);
}
public class MyHost : MatchHost
{
public MyHost(Ruleset rules, IHostTransport transport, IMessageSerializer serializer, ulong seed)
: base(rules, transport, serializer, seed) { }
protected override Match CreateMatch(IReadOnlyList<PlayerSetup> players)
{
var match = base.CreateMatch(players);
match.Turns = new MyTurnSystem();
match.LegalMoves = new MyLegalMoves();
return match;
}
}
[Serializable]
[NodeMenu("My Game/Gain Resource", Tooltip = "The ability's controller gains some of a resource.")]
[InputPort(Ports.Amount, PortType.Number)]
public class GainResource : EffectNode
{
[StatId] public string ResourceId = "mana";
public int Amount = 1;
public override void Execute(AbilityContext context)
{
var amount = context.GetInt(this, Ports.Amount, Amount);
var player = context.State.GetPlayer(context.ControllerId);
context.Game.ModifyStat(player, ResourceId, amount);
}
}
  • The node appears in the graph editor’s menu with its ports and fields. No editor code.
  • [StatId], [ZoneId], [CardId], [CardTypeId], [KeywordId] and [PhaseId] make a string field a drop-down of ids, and let the validator check it.
  • Declare data inputs with [InputPort], extra flow outputs with [OutputPort], and read them with context.GetInt and context.GetTargets.
  • Change the game only through context.Game (an ExecutionContext), so every change emits the right events for animation, network and rules.
  • Return a different output name from Run in a FlowNode to branch. Call context.RequestChoice in a TargetNode to ask the player.
  • Nodes must keep no state between runs: all state lives in the match. Avoid UnityEngine types if you want your rules to run outside Unity, for example on a dedicated .NET server.
public class ShuffleHandCommand : GameCommand
{
public override string ActionKind => "shuffle"; // allowed in phases that list "shuffle"
public override ValidationResult Validate(GameState state, Ruleset rules) => ValidationResult.Ok;
public override void Execute(ExecutionContext context) =>
context.Shuffle(PlayerId, context.Rules.HandZoneId);
// Commands with fields write and read them here, in the same order.
public override void Write(WireWriter writer) { }
public override void Read(WireReader reader) { }
}

Register it in your installer’s CreateRegistry and offer it from your legal move generator so the computer and the controls can use it. A command that is not registered cannot be sent, and the error says so.

public class MyHostTransport : IHostTransport
{
public event Action<int> ClientConnected; // a player connected: give them an id
public event Action<int> ClientDisconnected;
public event Action<int, byte[]> DataReceived; // bytes from a player
public void Send(int connectionId, byte[] data) { /* bytes to a player */ }
}
public class MyClientTransport : IClientTransport
{
public event Action<byte[]> DataReceived; // bytes from the host
public void Send(byte[] data) { /* bytes to the host */ }
}

Messages must arrive complete and in order. Integrations/NetcodeForGameObjects is a full example.

Subclass CardView, ZoneLayout, MatchInput or EventAnimator<T> and use the subclass in your prefab or scene. Every part of the screen is optional: a screen without player panels, a HUD or a card preview still works, and one built for 3D or UI Toolkit can drive the same MatchClient.