public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet          elementAsType    = (ArcenUI_ButtonSet)Element;
                Window_InGameBuildTypeMenu windowController = (Window_InGameBuildTypeMenu)Element.Window.Controller;

                if (windowController != null)
                {
                }                                   //prevent compiler warning

                if (Window_InGameBuildTypeMenu.Instance.LastMenuIndex != Window_InGameBuildTabMenu.Instance.CurrentMenuIndex)
                {
                    Window_InGameBuildTypeMenu.Instance.LastMenuIndex = Window_InGameBuildTabMenu.Instance.CurrentMenuIndex;
                    elementAsType.ClearButtons();

                    GameEntity entity = World_AIW2.Instance.GetEntityByID(Window_InGameBuildTabMenu.Instance.EntityID);
                    if (entity != null && entity.TypeData.BuildMenus.Count > 0)
                    {
                        if (Window_InGameBuildTypeMenu.Instance.LastMenuIndex >= entity.TypeData.BuildMenus.Count)
                        {
                            Window_InGameBuildTypeMenu.Instance.LastMenuIndex   = 0;
                            Window_InGameBuildTabMenu.Instance.CurrentMenuIndex = 0;
                        }
                        BuildMenu menu = entity.TypeData.BuildMenus[Window_InGameBuildTypeMenu.Instance.LastMenuIndex];
                        if (menu != null)
                        {
                            int shownColumnCount = 0;
                            for (int x = 0; x < menu.Columns.Count; x++)
                            {
                                bool haveShownAnythingInThisColumn = false;
                                List <BuildMenuItem> column        = menu.Columns[x];
                                if (column.Count <= 0)
                                {
                                    continue;
                                }
                                for (int y = 0; y < column.Count; y++)
                                {
                                    BuildMenuItem item = column[y];
                                    haveShownAnythingInThisColumn = true;
                                    bItem newButtonController = new bItem(entity.TypeData, item);
                                    newButtonController.ItemMenuIndex = Window_InGameBuildTypeMenu.Instance.LastMenuIndex;
                                    newButtonController.ItemTypeIndex = x;
                                    newButtonController.ItemIndex     = y;
                                    Vector2 offset;
                                    offset.x = shownColumnCount * elementAsType.ButtonWidth;
                                    offset.y = 0;
                                    Vector2 size;
                                    size.x = elementAsType.ButtonWidth;
                                    size.y = elementAsType.ButtonHeight;
                                    elementAsType.AddButton(newButtonController, size, offset);
                                }
                                if (haveShownAnythingInThisColumn)
                                {
                                    shownColumnCount++;
                                }
                            }
                        }
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();
                }
            }
 public Window_InGameBuildTypeMenu()
 {
     Instance                    = this;
     this.OnlyShowInGame         = true;
     this.SupportsMasterMenuKeys = true;
 }