D:\ValheimDev\Dumps\Old\assembly_valheim\PieceTable.cs D:\ValheimDev\Dumps\Latest\assembly_valheim\PieceTable.cs
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
   
public class PieceTable : MonoBehaviour public class PieceTable : MonoBehaviour
{ {
    public void UpdateAvailable(HashSet<string> knownRecipies, Player player, bool hideUnavailable, bool noPlacementCost)     public void UpdateAvailable(HashSet<string> knownRecipies, Player player, bool hideUnavailable, bool noPlacementCost)
    {     {
        if (this.m_availablePieces.Count == 0)         if (this.m_availablePieces.Count == 0)
        {         {
.            for (int i = 0; i < 4; i++)             for (int i = 0; i < 5; i++)
            {             {
                this.m_availablePieces.Add(new List<Piece>());                 this.m_availablePieces.Add(new List<Piece>());
            }             }
        }         }
        foreach (List<Piece> list in this.m_availablePieces)         foreach (List<Piece> list in this.m_availablePieces)
        {         {
            list.Clear();             list.Clear();
        }         }
        foreach (GameObject gameObject in this.m_pieces)         foreach (GameObject gameObject in this.m_pieces)
        {         {
            Piece component = gameObject.GetComponent<Piece>();             Piece component = gameObject.GetComponent<Piece>();
            bool flag = player.CurrentSeason != null && player.CurrentSeason.Pieces.Contains(gameObject);             bool flag = player.CurrentSeason != null && player.CurrentSeason.Pieces.Contains(gameObject);
            if (noPlacementCost || (knownRecipies.Contains(component.m_name) && (component.m_enabled || flag) && (!hideUnavailable || player.HaveRequirements(component, Player.RequirementMode.CanAlmostBuild))))             if (noPlacementCost || (knownRecipies.Contains(component.m_name) && (component.m_enabled || flag) && (!hideUnavailable || player.HaveRequirements(component, Player.RequirementMode.CanAlmostBuild))))
            {             {
                if (component.m_category == Piece.PieceCategory.All)                 if (component.m_category == Piece.PieceCategory.All)
                {                 {
.                    for (int j = 0; j < 4; j++)                     for (int j = 0; j < 5; j++)
                    {                     {
                        this.m_availablePieces[j].Add(component);                         this.m_availablePieces[j].Add(component);
                    }                     }
                }                 }
                else                 else
                {                 {
                    this.m_availablePieces[(int)component.m_category].Add(component);                     this.m_availablePieces[(int)component.m_category].Add(component);
                }                 }
            }             }
        }         }
    }     }
   
    public GameObject GetSelectedPrefab()     public GameObject GetSelectedPrefab()
    {     {
        Piece selectedPiece = this.GetSelectedPiece();         Piece selectedPiece = this.GetSelectedPiece();
        if (selectedPiece)         if (selectedPiece)
        {         {
            return selectedPiece.gameObject;             return selectedPiece.gameObject;
        }         }
        return null;         return null;
    }     }
   
    public Piece GetPiece(int category, Vector2Int p)     public Piece GetPiece(int category, Vector2Int p)
    {     {
        if (this.m_availablePieces[category].Count == 0)         if (this.m_availablePieces[category].Count == 0)
        {         {
            return null;             return null;
        }         }
        int num = p.y * 15 + p.x;         int num = p.y * 15 + p.x;
        if (num < 0 || num >= this.m_availablePieces[category].Count)         if (num < 0 || num >= this.m_availablePieces[category].Count)
        {         {
            return null;             return null;
        }         }
        return this.m_availablePieces[category][num];         return this.m_availablePieces[category][num];
    }     }
   
    public Piece GetPiece(Vector2Int p)     public Piece GetPiece(Vector2Int p)
    {     {
        return this.GetPiece((int)this.m_selectedCategory, p);         return this.GetPiece((int)this.m_selectedCategory, p);
    }     }
   
    public bool IsPieceAvailable(Piece piece)     public bool IsPieceAvailable(Piece piece)
    {     {
        using (List<Piece>.Enumerator enumerator = this.m_availablePieces[(int)this.m_selectedCategory].GetEnumerator())         using (List<Piece>.Enumerator enumerator = this.m_availablePieces[(int)this.m_selectedCategory].GetEnumerator())
        {         {
            while (enumerator.MoveNext())             while (enumerator.MoveNext())
            {             {
                if (enumerator.Current == piece)                 if (enumerator.Current == piece)
                {                 {
                    return true;                     return true;
                }                 }
            }             }
        }         }
        return false;         return false;
    }     }
   
    public Piece GetSelectedPiece()     public Piece GetSelectedPiece()
    {     {
        Vector2Int selectedIndex = this.GetSelectedIndex();         Vector2Int selectedIndex = this.GetSelectedIndex();
        return this.GetPiece((int)this.m_selectedCategory, selectedIndex);         return this.GetPiece((int)this.m_selectedCategory, selectedIndex);
    }     }
   
    public int GetAvailablePiecesInCategory(Piece.PieceCategory cat)     public int GetAvailablePiecesInCategory(Piece.PieceCategory cat)
    {     {
        return this.m_availablePieces[(int)cat].Count;         return this.m_availablePieces[(int)cat].Count;
    }     }
   
    public List<Piece> GetPiecesInSelectedCategory()     public List<Piece> GetPiecesInSelectedCategory()
    {     {
        return this.m_availablePieces[(int)this.m_selectedCategory];         return this.m_availablePieces[(int)this.m_selectedCategory];
    }     }
   
    public int GetAvailablePiecesInSelectedCategory()     public int GetAvailablePiecesInSelectedCategory()
    {     {
        return this.GetAvailablePiecesInCategory(this.m_selectedCategory);         return this.GetAvailablePiecesInCategory(this.m_selectedCategory);
    }     }
   
    public Vector2Int GetSelectedIndex()     public Vector2Int GetSelectedIndex()
    {     {
        return this.m_selectedPiece[(int)this.m_selectedCategory];         return this.m_selectedPiece[(int)this.m_selectedCategory];
    }     }
   
    public bool GetPieceIndex(Piece p, out Vector2Int index, out int category)     public bool GetPieceIndex(Piece p, out Vector2Int index, out int category)
    {     {
        string prefabName = Utils.GetPrefabName(p.gameObject);         string prefabName = Utils.GetPrefabName(p.gameObject);
        for (int i = 0; i < this.m_availablePieces.Count; i++)         for (int i = 0; i < this.m_availablePieces.Count; i++)
        {         {
            for (int j = 0; j < this.m_availablePieces[i].Count; j++)             for (int j = 0; j < this.m_availablePieces[i].Count; j++)
            {             {
                if (Utils.GetPrefabName(this.m_availablePieces[i][j].gameObject) == prefabName)                 if (Utils.GetPrefabName(this.m_availablePieces[i][j].gameObject) == prefabName)
                {                 {
                    category = i;                     category = i;
                    index = new Vector2Int(j % 15, (j - j % 15) / 15);                     index = new Vector2Int(j % 15, (j - j % 15) / 15);
                    return true;                     return true;
                }                 }
            }             }
        }         }
        index = Vector2Int.zero;         index = Vector2Int.zero;
        category = -1;         category = -1;
        return false;         return false;
    }     }
   
    public void SetSelected(Vector2Int p)     public void SetSelected(Vector2Int p)
    {     {
        this.m_selectedPiece[(int)this.m_selectedCategory] = p;         this.m_selectedPiece[(int)this.m_selectedCategory] = p;
    }     }
   
    public void LeftPiece()     public void LeftPiece()
    {     {
        if (this.m_availablePieces[(int)this.m_selectedCategory].Count <= 1)         if (this.m_availablePieces[(int)this.m_selectedCategory].Count <= 1)
        {         {
            return;             return;
        }         }
        Vector2Int vector2Int = this.m_selectedPiece[(int)this.m_selectedCategory];         Vector2Int vector2Int = this.m_selectedPiece[(int)this.m_selectedCategory];
        int num = vector2Int.x - 1;         int num = vector2Int.x - 1;
        vector2Int.x = num;         vector2Int.x = num;
        if (vector2Int.x < 0)         if (vector2Int.x < 0)
        {         {
            vector2Int.x = 14;             vector2Int.x = 14;
        }         }
        this.m_selectedPiece[(int)this.m_selectedCategory] = vector2Int;         this.m_selectedPiece[(int)this.m_selectedCategory] = vector2Int;
    }     }
   
    public void RightPiece()     public void RightPiece()
    {     {
        if (this.m_availablePieces[(int)this.m_selectedCategory].Count <= 1)         if (this.m_availablePieces[(int)this.m_selectedCategory].Count <= 1)
        {         {
            return;             return;
        }         }
        Vector2Int vector2Int = this.m_selectedPiece[(int)this.m_selectedCategory];         Vector2Int vector2Int = this.m_selectedPiece[(int)this.m_selectedCategory];
        int num = vector2Int.x + 1;         int num = vector2Int.x + 1;
        vector2Int.x = num;         vector2Int.x = num;
        if (vector2Int.x >= 15)         if (vector2Int.x >= 15)
        {         {
            vector2Int.x = 0;             vector2Int.x = 0;
        }         }
        this.m_selectedPiece[(int)this.m_selectedCategory] = vector2Int;         this.m_selectedPiece[(int)this.m_selectedCategory] = vector2Int;
    }     }
   
    public void DownPiece()     public void DownPiece()
    {     {
        if (this.m_availablePieces[(int)this.m_selectedCategory].Count <= 1)         if (this.m_availablePieces[(int)this.m_selectedCategory].Count <= 1)
        {         {
            return;             return;
        }         }
        Vector2Int vector2Int = this.m_selectedPiece[(int)this.m_selectedCategory];         Vector2Int vector2Int = this.m_selectedPiece[(int)this.m_selectedCategory];
        int num = vector2Int.y + 1;         int num = vector2Int.y + 1;
        vector2Int.y = num;         vector2Int.y = num;
        if (vector2Int.y >= 6)         if (vector2Int.y >= 6)
        {         {
            vector2Int.y = 0;             vector2Int.y = 0;
        }         }
        this.m_selectedPiece[(int)this.m_selectedCategory] = vector2Int;         this.m_selectedPiece[(int)this.m_selectedCategory] = vector2Int;
    }     }
   
    public void UpPiece()     public void UpPiece()
    {     {
        if (this.m_availablePieces[(int)this.m_selectedCategory].Count <= 1)         if (this.m_availablePieces[(int)this.m_selectedCategory].Count <= 1)
        {         {
            return;             return;
        }         }
        Vector2Int vector2Int = this.m_selectedPiece[(int)this.m_selectedCategory];         Vector2Int vector2Int = this.m_selectedPiece[(int)this.m_selectedCategory];
        int num = vector2Int.y - 1;         int num = vector2Int.y - 1;
        vector2Int.y = num;         vector2Int.y = num;
        if (vector2Int.y < 0)         if (vector2Int.y < 0)
        {         {
            vector2Int.y = 5;             vector2Int.y = 5;
        }         }
        this.m_selectedPiece[(int)this.m_selectedCategory] = vector2Int;         this.m_selectedPiece[(int)this.m_selectedCategory] = vector2Int;
    }     }
   
    public void NextCategory()     public void NextCategory()
    {     {
        if (!this.m_useCategories)         if (!this.m_useCategories)
        {         {
            return;             return;
        }         }
        this.m_selectedCategory++;         this.m_selectedCategory++;
        if (this.m_selectedCategory == Piece.PieceCategory.Max)         if (this.m_selectedCategory == Piece.PieceCategory.Max)
        {         {
            this.m_selectedCategory = Piece.PieceCategory.Misc;             this.m_selectedCategory = Piece.PieceCategory.Misc;
        }         }
    }     }
   
    public void PrevCategory()     public void PrevCategory()
    {     {
        if (!this.m_useCategories)         if (!this.m_useCategories)
        {         {
            return;             return;
        }         }
        this.m_selectedCategory--;         this.m_selectedCategory--;
        if (this.m_selectedCategory < Piece.PieceCategory.Misc)         if (this.m_selectedCategory < Piece.PieceCategory.Misc)
        {         {
            this.m_selectedCategory = Piece.PieceCategory.Furniture;             this.m_selectedCategory = Piece.PieceCategory.Furniture;
        }         }
    }     }
   
    public void SetCategory(int index)     public void SetCategory(int index)
    {     {
        if (!this.m_useCategories)         if (!this.m_useCategories)
        {         {
            return;             return;
        }         }
        this.m_selectedCategory = (Piece.PieceCategory)index;         this.m_selectedCategory = (Piece.PieceCategory)index;
.        this.m_selectedCategory = (Piece.PieceCategory)Mathf.Clamp((int)this.m_selectedCategory, 0, 3);         this.m_selectedCategory = (Piece.PieceCategory)Mathf.Clamp((int)this.m_selectedCategory, 0, 4);
    }     }
   
    public const int m_gridWidth = 15;     public const int m_gridWidth = 15;
   
    public const int m_gridHeight = 6;     public const int m_gridHeight = 6;
   
    public List<GameObject> m_pieces = new List<GameObject>();     public List<GameObject> m_pieces = new List<GameObject>();
   
    public bool m_useCategories = true;     public bool m_useCategories = true;
   
    public bool m_canRemovePieces = true;     public bool m_canRemovePieces = true;
   
    [NonSerialized]     [NonSerialized]
    private List<List<Piece>> m_availablePieces = new List<List<Piece>>();     private List<List<Piece>> m_availablePieces = new List<List<Piece>>();
   
    [NonSerialized]     [NonSerialized]
    public Piece.PieceCategory m_selectedCategory;     public Piece.PieceCategory m_selectedCategory;
   
    [NonSerialized]     [NonSerialized]
    public Vector2Int[] m_selectedPiece = new Vector2Int[5];     public Vector2Int[] m_selectedPiece = new Vector2Int[5];
   
    [NonSerialized]     [NonSerialized]
    public Vector2Int[] m_lastSelectedPiece = new Vector2Int[5];     public Vector2Int[] m_lastSelectedPiece = new Vector2Int[5];
   
    [HideInInspector]     [HideInInspector]
    public List<Piece.PieceCategory> m_categoriesFolded = new List<Piece.PieceCategory>();     public List<Piece.PieceCategory> m_categoriesFolded = new List<Piece.PieceCategory>();
} }