Пример #1
0
    public static int[] RepackTableForNCell(Packer packer, int[] table, int n)
    {
        var stateCount = packer.stateCountPacked;
        var cellCount  = (2 + n) + n;

        Debug.Assert(cellCount <= packer.cellsPerPack, "Table index exceeds 1 pack");
        var sizePower = Mathf.RoundToInt(Mathf.Pow(stateCount, cellCount));
        var t2        = new int[sizePower];

        for (var stc = 0; stc < t2.Length; stc++)
        {
            var st = 0;
            for (var i = 0; i < n; i++)
            {
                var pc    = packer.GetFromPack(stc, n + 2 + i);
                var n1cn2 = packer.GetFromPack(stc, i, 3);
                var stci  = Rule.GetCombinedStatePacked(n1cn2, pc, stateCount);
                var sti   = table[stci];
                packer.SetIntoPackDirty(ref st, i, sti);
            }
            t2[stc] = st;
        }
        return(t2);
    }