internal void Initialize(Backpack backpack, InventoryItem item)
        {
            Backpack = backpack;
            Clear();

            item.OccupiedGridPositions_Matrix.GetConnectionMatrix(out bool[,] connectionMatrix, out GridPos offset);
            foreach (GridPos gp in item.OccupiedGridPositions_Matrix)
            {
                gp.GetConnection(connectionMatrix, offset, out GridPosR.OrientationFlag adjacentConnection, out GridPosR.OrientationFlag diagonalConnection);
                GridPos          localGP = gp - item.BoundingRect.position;
                BackpackItemGrid grid    = Backpack.CreateBackpackItemGrid(BackpackItemGridContainer);
                grid.Initialize(localGP, new GridRect(localGP.x, -localGP.z, Backpack.GridSize, Backpack.GridSize), adjacentConnection, diagonalConnection);
                BackpackItemGrids.Add(grid);
            }
        }
Ejemplo n.º 2
0
        public BackpackItemGrid CreateBackpackItemGrid(Transform transform)
        {
            if (InstantiateBackpackItemGridHandler != null)
            {
                MonoBehaviour mono = InstantiateBackpackItemGridHandler?.Invoke(transform);
                if (mono != null)
                {
                    try
                    {
                        BackpackItemGrid res = (BackpackItemGrid)mono;
                        return(res);
                    }
                    catch (Exception e)
                    {
                        LogError(e.ToString());
                    }
                }
            }

            return(null);
        }