Skip to main content

Constructor

A class in Root.Township, Alta.PAGaC.

PAGaC's matcher: finds where rules fit in a 3D tag grid (in all four rotations) and either rewrites the tags or spawns prefabs for matching parts.

Constructors​

MemberWhat it is
Constructor(Generator generator)Creates a Constructor from tags.
Constructor(Tag[,,] tags)Creates a Constructor from tags.

Fields​

8 private and internal fields
MemberWhat it is
private Generator generatorThe generator whose cells are also updated by Apply. Null when built from a plain tag array, so Apply needs the generator constructor.
private OptionSet optionSetThe option set passed to the last Generate.
private int sizeXGrid width.
private int sizeYGrid height.
private int sizeZGrid depth.
private Tag[,,] tagsThe working tag grid.
private List<int>[,,] usedRuleRotationsPer cell, the rotation each placed rule used.
private List<RuleBase>[,,] usedRulesPer cell, the rules already placed there, used to stop duplicate overlaps.

Methods​

MemberWhat it is
int Apply(GenerationRule[] rules)Matches each GenerationRule against the grid and runs its Set, Remove and Clear steps at every match. Returns the number of matches.
GameObject Generate(OptionSet optionSet)Evaluates the option set into parts and instantiates each part's prefab wherever its rule matches, under a new "Result" object.
6 private and internal methods
MemberWhat it is
private void CheckPlace<T>(int x, int y, T part, RuleBase rule, int configuration, int xxMultiplier, int xzMultiplier, int zxMultiplier, int zzMultiplier, Constructor.PlaceFound<T> foundCallback)Tests a rule at each Z position for a given X, Y and rotation, honouring the rule's rotation overlap setting, and calls back on each fit.
private Constructor.PlacingData<T> CreateData<T>(T part, RuleBase rule, List<Tag> tags)Builds bitmask data for each rule configuration, so HandlePart can rule out positions quickly. Returns null if nothing can match.
private void GetCompressed(List<Tag> tags, out ulong[,] zCompressed, out ulong[] xzCompressed)Packs which tags appear in each X column and Y layer into 64-bit masks for fast rejection.
private List<Tag> GetUsedTags()Lists the distinct tags present in the grid.
private void HandlePart<T>(Constructor.PlacingData<T> data, RuleBase rule, ulong[,] zCompressed, ulong[] xzCompressed, Constructor.PlaceFound<T> foundCallback)Scans layers and rotations with the bitmasks and passes possible positions to CheckPlace.
private void PrepareUsedRules()Resets the per-cell lists of rules and rotations already placed.