Example #1
0
 public override bool DoSuccessfulCompletionLogic(GameEntity Target, GameEntity Hacker, ArcenSimContext Context)
 {
     if (Target.StoredDesign != null)
     {
         TechTypeData tech = Target.StoredDesign.TechPrereq;
         if (!Hacker.Side.WorldSide.UnlockedTechs.Contains(tech))
         {
             Hacker.Side.WorldSide.UnlockedTechs.Add(tech);
             return(true);
         }
     }
     else if (Target.TypeData.GrantsTemporarilyWhileOwned.Count > 0)
     {
         bool foundOne = false;
         for (int i = 0; i < Target.TypeData.GrantsTemporarilyWhileOwned.Count; i++)
         {
             TechTypeData tech = Target.TypeData.GrantsTemporarilyWhileOwned[i];
             if (Hacker.Side.WorldSide.UnlockedTechs.Contains(tech))
             {
                 continue;
             }
             Hacker.Side.WorldSide.UnlockedTechs.Add(tech);
             foundOne = true;
         }
         if (foundOne)
         {
             return(true);
         }
     }
     return(false);
 }
Example #2
0
 public override bool GetCanBeHacked(GameEntity Target, GameEntity Hacker)
 {
     if (!base.GetCanBeHacked(Target, Hacker))
     {
         return(false);
     }
     if (Target.StoredDesign != null)
     {
         TechTypeData tech = Target.StoredDesign.TechPrereq;
         if (Hacker.Side.WorldSide.UnlockedTechs.Contains(tech))
         {
             return(false);
         }
     }
     else if (Target.TypeData.GrantsTemporarilyWhileOwned.Count > 0)
     {
         bool foundOne = false;
         for (int i = 0; i < Target.TypeData.GrantsTemporarilyWhileOwned.Count; i++)
         {
             if (Hacker.Side.WorldSide.UnlockedTechs.Contains(Target.TypeData.GrantsTemporarilyWhileOwned[i]))
             {
                 continue;
             }
             foundOne = true;
             break;
         }
         if (!foundOne)
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
     return(true);
 }
Example #3
0
 public bool EqualsWith(TechTypeData techTypeData)
 {
     return(techTypeData.TechType == _techType);
 }
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalSide();

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

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

                    TechMenu menu = TechMenuTable.Instance.Rows[windowController.CurrentMenuIndex];
                    if (menu != null)
                    {
                        int shownColumnCount = 0;
                        for (int x = 0; x < menu.Columns.Count; x++)
                        {
                            bool haveShownAnythingInThisColumn = false;
                            List <TechTypeData> column         = menu.Columns[x];
                            for (int y = 0; y < column.Count; y++)
                            {
                                TechTypeData item = column[y];
                                if (item.NotOnMainTechMenu)
                                {
                                    continue;
                                }
                                if (item.Prerequisite != null)
                                {
                                    TechTypeData prereq   = item.Prerequisite;
                                    bool         foundOne = false;
                                    while (prereq != null)
                                    {
                                        if ((prereq.Prerequisite == null && !prereq.NotOnMainTechMenu) || localSide.GetHasResearched(prereq))
                                        {
                                            foundOne = true;
                                            break;
                                        }
                                        prereq = prereq.Prerequisite;
                                    }
                                    if (!foundOne)
                                    {
                                        continue;
                                    }
                                }
                                //if ( localSide.GetCanResearch( item ) != ArcenRejectionReason.Unknown &&
                                //     !localSide.UnlockedTechs.Contains( item ) )
                                //    continue;
                                haveShownAnythingInThisColumn = true;
                                bTechItem newButtonController = new bTechItem(item);
                                Vector2   offset;
                                offset.x = shownColumnCount * elementAsType.ButtonWidth;
                                offset.y = y * elementAsType.ButtonHeight;
                                Vector2 size;
                                size.x = elementAsType.ButtonWidth;
                                size.y = elementAsType.ButtonHeight;
                                elementAsType.AddButton(newButtonController, size, offset);
                            }
                            if (haveShownAnythingInThisColumn)
                            {
                                shownColumnCount++;
                            }
                        }
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();

                    windowController.MenuIndexChangedSinceLastButtonSetUpdate = false;
                }
            }
 public bTechItem(TechTypeData Item)
 {
     this.Item = Item;
 }
            public override void OnUpdate()
            {
                if (Instance.HeightPerRow <= 0)
                {
                    Instance.HeightPerRow = Element.ButtonHeight;
                }
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ImageButtonSet elementAsType = (ArcenUI_ImageButtonSet)Element;

                if (elementAsType != null)
                {
                }                                //prevent compiler warning
                Window_InGameTechTypeIconMenu windowController = (Window_InGameTechTypeIconMenu)Element.Window.Controller;

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

                if (Instance.LastMenuIndex != Window_InGameTechTabMenu.Instance.CurrentMenuIndex ||
                    Instance.LastTypeIndex != Instance.CurrentTypeIndex)
                {
                    Instance.LastMenuIndex = Window_InGameTechTabMenu.Instance.CurrentMenuIndex;
                    Instance.LastTypeIndex = Instance.CurrentTypeIndex;

                    for (int i = 0; i < Instance.LastShownItems.Count; i++)
                    {
                        Instance.LastShownItems[i].Clear();
                    }

                    int highestRowReached = 0;
                    if (Instance.LastMenuIndex >= TechMenuTable.Instance.Rows.Count)
                    {
                        Instance.LastMenuIndex = 0;
                        Window_InGameTechTabMenu.Instance.CurrentMenuIndex = 0;
                    }
                    TechMenu menu = TechMenuTable.Instance.Rows[Instance.LastMenuIndex];
                    if (menu != null)
                    {
                        float aspectRatioAdjustedButtonWidth  = this.Element.ButtonWidth;
                        float aspectRatioAdjustedButtonHeight = this.Element.ButtonHeight;
                        if (ArcenUI.Instance.PixelsPerPercent_X != ArcenUI.Instance.PixelsPerPercent_Y)
                        {
                            aspectRatioAdjustedButtonWidth *= ArcenUI.Instance.PixelsPerPercent_Y / ArcenUI.Instance.PixelsPerPercent_X;
                        }
                        //int totalColumns = Mathf.FloorToInt( this.Element.Width / aspectRatioAdjustedButtonWidth );
                        int currentImageListIndex = 0;

                        int shownColumnCount = 0;
                        for (int typeIndex = 0; typeIndex < menu.Columns.Count; typeIndex++)
                        {
                            List <TechTypeData> column = menu.Columns[typeIndex];
                            int buttonsInColumn        = 0;
                            for (int markIndex = 0; markIndex < column.Count; markIndex++)
                            {
                                TechTypeData menuItem = column[markIndex];
                                if (!localSide.CanSeeTechOnMenu(menuItem))
                                {
                                    continue;
                                }
                                buttonsInColumn = markIndex + 1;
                            }
                            highestRowReached = Math.Max(highestRowReached, buttonsInColumn);
                        }

                        for (int typeIndex = 0; typeIndex < menu.Columns.Count; typeIndex++)
                        {
                            if (Instance.LastShownItems.Count <= typeIndex)
                            {
                                Instance.LastShownItems.Add(new List <bItem>());
                            }
                            List <bItem> lastShownItemList = Instance.LastShownItems[typeIndex];

                            bool haveShownAnythingInThisColumn = false;
                            List <TechTypeData> column         = menu.Columns[typeIndex];
                            if (column.Count <= 0)
                            {
                                continue;
                            }
                            for (int markIndex = 0; markIndex < column.Count; markIndex++)
                            {
                                if (lastShownItemList.Count <= markIndex)
                                {
                                    lastShownItemList.Add(null);
                                }

                                TechTypeData menuItem = column[markIndex];
                                if (!localSide.CanSeeTechOnMenu(menuItem))
                                {
                                    continue;
                                }
                                haveShownAnythingInThisColumn = true;

                                bItem item = null;
                                if (currentImageListIndex < this.Element.Images.Count)
                                {
                                    item = Element.Images[currentImageListIndex].Controller as bItem;
                                    currentImageListIndex++;
                                }
                                else
                                {
                                    item = new bItem();
                                    Vector2 dummy = Mat.V2_Zero;
                                    Vector2 size;
                                    size.x = aspectRatioAdjustedButtonWidth;
                                    size.y = aspectRatioAdjustedButtonHeight;
                                    Element.AddImageButton(item, size, dummy);
                                    currentImageListIndex = Element.Images.Count;
                                }
                                item.ColumnIndex             = shownColumnCount;
                                lastShownItemList[markIndex] = item;

                                float effectiveX = shownColumnCount * aspectRatioAdjustedButtonWidth;
                                float effectiveY = ((highestRowReached - 1) - markIndex) * aspectRatioAdjustedButtonHeight;

                                if (menuItem.GameEntityTypesThatRequireThis.Count > 0)
                                {
                                    item.SetTypeToTech(menuItem.GameEntityTypesThatRequireThis[0]);
                                }
                                item.Element.Alignment.XAlignment.Offset = effectiveX;
                                item.Element.Alignment.YAlignment.Offset = effectiveY;
                                item.Element.UpdatePositionAndSize();
                            }
                            if (haveShownAnythingInThisColumn)
                            {
                                shownColumnCount++;
                            }
                        }

                        //hide any extras
                        for (int i = currentImageListIndex; i < this.Element.Images.Count; i++)
                        {
                            bItem item = this.Element.Images[i].Controller as bItem;
                            item.SetTypeToTech(null);
                        }
                    }
                    if (Instance.HeightPerRow > 0)
                    {
                        float currentExpansion = Instance.Window.SubContainer.Height - Instance.HeightPerRow;
                        float targetExpansion  = Instance.HeightPerRow * (highestRowReached - 1);
                        float deltaExpansion   = targetExpansion - currentExpansion;
                        if (deltaExpansion != 0)
                        {
                            Instance.Window.SubContainer.Height = Instance.HeightPerRow * highestRowReached;
                        }
                    }
                }
            }