Exemplo n.º 1
0
        internal bool UpdateState(Menu oldMenu, Item item, Update update, bool reset = true)
        {
            if (reset)
            {
                oldMenu.CleanUp();
                GroupNames.Clear();

                foreach (var group in BlockGroups)
                {
                    group.Clear();
                    MembersPool.Return(group);
                }

                BlockGroups.Clear();

                foreach (var group in Ai.BlockGroups)
                {
                    var groupName = group.Key;
                    GroupNames.Add(groupName);
                    var membersList = MembersPool.Get();

                    foreach (var comp in group.Value.Comps)
                    {
                        var groupMember = new GroupMember {
                            Comp = comp, Name = groupName
                        };
                        membersList.Add(groupMember);
                    }
                    BlockGroups.Add(membersList);
                }
            }

            var groupReady = BlockGroups.Count > 0;

            if (groupReady)
            {
                switch (update)
                {
                case Update.Parent:
                    _currentMenu = item.ParentName;
                    break;

                case Update.Sub:
                    _currentMenu = item.SubName;
                    break;

                default:
                    break;
                }
                var menu = Menus[_currentMenu];
                if (menu.ItemCount <= 1)
                {
                    menu.LoadInfo(reset);
                }
            }

            return(groupReady);
        }
Exemplo n.º 2
0
 internal void CleanUp()
 {
     RegisterMyGridEvents(false);
     foreach (var grid in SubGrids)
     {
         if (grid == MyGrid)
         {
             continue;
         }
         RemSubGrids.Add(grid);
     }
     AddSubGrids.Clear();
     SubGridChanges();
     SubGrids.Clear();
     Obstructions.Clear();
     TargetAis.Clear();
     EntitiesInRange.Clear();
     Batteries.Clear();
     Targets.Clear();
     SortedTargets.Clear();
     BlockGroups.Clear();
     Weapons.Clear();
     WeaponsIdx.Clear();
     WeaponBase.Clear();
     AmmoInventories.Clear();
     Inventories.Clear();
     LiveProjectile.Clear();
     DeadProjectiles.Clear();
     ControllingPlayers.Clear();
     SourceCount           = 0;
     BlockCount            = 0;
     MyOwner               = 0;
     PointDefense          = false;
     FadeOut               = false;
     SupressMouseShoot     = false;
     OverPowered           = false;
     UpdatePowerSources    = false;
     AvailablePowerChanged = false;
     PowerIncrease         = false;
     RequestedPowerChanged = false;
     RequestIncrease       = false;
     DbReady               = false;
     Focus.Clean();
     MyShieldTmp        = null;
     MyShield           = null;
     MyPlanetTmp        = null;
     MyPlanet           = null;
     TerminalSystem     = null;
     LastWeaponTerminal = null;
     LastTerminal       = null;
     PowerDistributor   = null;
 }