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

                if (localSide == null)
                {
                    return;
                }
                Planet                    planet           = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed();
                ArcenUI_ButtonSet         elementAsType    = (ArcenUI_ButtonSet)Element;
                Window_InGameBuildTabMenu windowController = (Window_InGameBuildTabMenu)Element.Window.Controller;

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

                if (windowController.EntityChangedSinceLastButtonSetUpdate_Menu)
                {
                    elementAsType.ClearButtons();

                    GameEntity entity = World_AIW2.Instance.GetEntityByID(windowController.EntityID);
                    if (entity != null)
                    {
                        List <BuildMenu> menus = entity.TypeData.BuildMenus;
                        int x = 0;
                        for (int i = 0; i < menus.Count; i++)
                        {
                            BuildMenu item = menus[i];
                            if (item.RequiresPresenceOf != null)
                            {
                                bool foundIt = false;
                                planet.Combat.DoForEntities(EntityRollupType.SpecialBuildMenuEnablers, delegate(GameEntity enabler)
                                {
                                    if (enabler.TypeData != item.RequiresPresenceOf)
                                    {
                                        return(DelReturn.Continue);
                                    }
                                    foundIt = true;
                                    return(DelReturn.Break);
                                });
                                if (!foundIt)
                                {
                                    continue;
                                }
                            }
                            bool foundPatternItem = false;
                            for (int j = 0; j < item.Columns.Count; j++)
                            {
                                List <BuildMenuItem> itemList = item.Columns[j];
                                for (int k = 0; k < itemList.Count; k++)
                                {
                                    if (itemList[k].PatternController != null)
                                    {
                                        foundPatternItem = true;
                                        break;
                                    }
                                }
                            }
                            bItem   newButtonController = new bItem(entity.TypeData, i, foundPatternItem);
                            Vector2 offset;
                            offset.x = x * elementAsType.ButtonWidth;
                            offset.y = 0;
                            Vector2 size;
                            size.x = elementAsType.ButtonWidth;
                            size.y = elementAsType.ButtonHeight;
                            elementAsType.AddButton(newButtonController, size, offset);
                            x++;
                        }
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();

                    windowController.EntityChangedSinceLastButtonSetUpdate_Menu = false;
                    windowController.MenuIndexChangedSinceLastButtonSetUpdate   = true;
                }
            }
 public Window_InGameBuildTabMenu()
 {
     Instance                    = this;
     this.OnlyShowInGame         = true;
     this.SupportsMasterMenuKeys = true;
 }