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.
- Listed in World generation
- Nested types
PlaceFound<T>,PlacingData<T>
Constructors
| Member | What it is |
|---|---|
Constructor(Generator generator) | Creates a Constructor from tags. |
Constructor(Tag[,,] tags) | Creates a Constructor from tags. |
Fields
8 private and internal fields
| Member | What it is |
|---|---|
private Generator generator | The generator whose cells are also updated by Apply. Null when built from a plain tag array, so Apply needs the generator constructor. |
private OptionSet optionSet | The option set passed to the last Generate. |
private int sizeX | Grid width. |
private int sizeY | Grid height. |
private int sizeZ | Grid depth. |
private Tag[,,] tags | The working tag grid. |
private List<int>[,,] usedRuleRotations | Per cell, the rotation each placed rule used. |
private List<RuleBase>[,,] usedRules | Per cell, the rules already placed there, used to stop duplicate overlaps. |
Methods
| Member | What 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
| Member | What 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. |