Exemplo n.º 1
0
        static MyConveyorSorter()
        {
            drainAll        = new MyTerminalControlOnOffSwitch <MyConveyorSorter>("DrainAll", MySpaceTexts.Terminal_DrainAll);
            drainAll.Getter = (block) => block.DrainAll;
            drainAll.Setter = (block, val) => block.DrainAll = val;
            drainAll.EnableToggleAction();
            MyTerminalControlFactory.AddControl(drainAll);

            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyConveyorSorter>());

            blacklistWhitelist = new MyTerminalControlCombobox <MyConveyorSorter>("blacklistWhitelist", MySpaceTexts.BlockPropertyTitle_ConveyorSorterFilterMode, MySpaceTexts.Blank);
            blacklistWhitelist.ComboBoxContent = (block) => FillBlWlCombo(block);
            blacklistWhitelist.Getter          = (block) => (long)(block.IsWhitelist ? 1 : 0);
            blacklistWhitelist.Setter          = (block, val) => block.ChangeBlWl(val == 1);
            blacklistWhitelist.SetSerializerBit();
            blacklistWhitelist.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(blacklistWhitelist);

            currentList                        = new MyTerminalControlListbox <MyConveyorSorter>("CurrentList", MySpaceTexts.BlockPropertyTitle_ConveyorSorterFilterItemsList, MySpaceTexts.Blank, true);
            currentList.ListContent            = (block, list1, list2) => block.FillCurrentList(list1, list2);
            currentList.ItemSelected           = (block, val) => block.SelectFromCurrentList(val);
            currentList.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(currentList);

            removeFromSelectionButton = new MyTerminalControlButton <MyConveyorSorter>("removeFromSelectionButton",
                                                                                       MySpaceTexts.BlockPropertyTitle_ConveyorSorterRemove,
                                                                                       MySpaceTexts.Blank,
                                                                                       (block) => block.RemoveFromCurrentList());
            removeFromSelectionButton.Enabled = (x) => x.m_selectedForDelete != null && x.m_selectedForDelete.Count > 0;;
            removeFromSelectionButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(removeFromSelectionButton);

            candidates                        = new MyTerminalControlListbox <MyConveyorSorter>("candidatesList", MySpaceTexts.BlockPropertyTitle_ConveyorSorterCandidatesList, MySpaceTexts.Blank, true);
            candidates.ListContent            = (block, list1, list2) => block.FillCandidatesList(list1, list2);
            candidates.ItemSelected           = (block, val) => block.SelectCandidate(val);
            candidates.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(candidates);

            addToSelectionButton = new MyTerminalControlButton <MyConveyorSorter>("addToSelectionButton",
                                                                                  MySpaceTexts.BlockPropertyTitle_ConveyorSorterAdd,
                                                                                  MySpaceTexts.Blank,
                                                                                  (x) => x.AddToCurrentList());
            addToSelectionButton.SupportsMultipleBlocks = false;
            addToSelectionButton.Enabled = (x) => x.m_selectedForAdd != null && x.m_selectedForAdd.Count > 0;
            MyTerminalControlFactory.AddControl(addToSelectionButton);

            byte index = 0;//warning: if you shuffle indexes, you will shuffle data in saved games

            CandidateTypes.Add(++index, new Tuple <MyObjectBuilderType, StringBuilder>(typeof(MyObjectBuilder_AmmoMagazine), MyTexts.Get(MySpaceTexts.DisplayName_ConvSorterTypes_Ammo)));
            CandidateTypes.Add(++index, new Tuple <MyObjectBuilderType, StringBuilder>(typeof(MyObjectBuilder_Component), MyTexts.Get(MySpaceTexts.DisplayName_ConvSorterTypes_Component)));
            CandidateTypes.Add(++index, new Tuple <MyObjectBuilderType, StringBuilder>(typeof(MyObjectBuilder_PhysicalGunObject), MyTexts.Get(MySpaceTexts.DisplayName_ConvSorterTypes_HandTool)));
            CandidateTypes.Add(++index, new Tuple <MyObjectBuilderType, StringBuilder>(typeof(MyObjectBuilder_Ingot), MyTexts.Get(MySpaceTexts.DisplayName_ConvSorterTypes_Ingot)));
            CandidateTypes.Add(++index, new Tuple <MyObjectBuilderType, StringBuilder>(typeof(MyObjectBuilder_Ore), MyTexts.Get(MySpaceTexts.DisplayName_ConvSorterTypes_Ore)));
            foreach (var val in CandidateTypes)
            {
                CandidateTypesToId.Add(val.Value.Item1, val.Key);
            }
        }
Exemplo n.º 2
0
 static MyConveyorSorter()
 {
     byte index = 0;//warning: if you shuffle indexes, you will shuffle data in saved games
     CandidateTypes.Add(++index, new Tuple<MyObjectBuilderType, StringBuilder>(typeof(MyObjectBuilder_AmmoMagazine), MyTexts.Get(MySpaceTexts.DisplayName_ConvSorterTypes_Ammo)));
     CandidateTypes.Add(++index, new Tuple<MyObjectBuilderType, StringBuilder>(typeof(MyObjectBuilder_Component), MyTexts.Get(MySpaceTexts.DisplayName_ConvSorterTypes_Component)));
     CandidateTypes.Add(++index, new Tuple<MyObjectBuilderType, StringBuilder>(typeof(MyObjectBuilder_PhysicalGunObject), MyTexts.Get(MySpaceTexts.DisplayName_ConvSorterTypes_HandTool)));
     CandidateTypes.Add(++index, new Tuple<MyObjectBuilderType, StringBuilder>(typeof(MyObjectBuilder_Ingot), MyTexts.Get(MySpaceTexts.DisplayName_ConvSorterTypes_Ingot)));
     CandidateTypes.Add(++index, new Tuple<MyObjectBuilderType, StringBuilder>(typeof(MyObjectBuilder_Ore), MyTexts.Get(MySpaceTexts.DisplayName_ConvSorterTypes_Ore)));
     foreach (var val in CandidateTypes)
     {
         CandidateTypesToId.Add(val.Value.Item1, val.Key);
     }
 }
        private void ResolveTypes()
        {
            if (_lookupAssemblies == null)
            {
                throw new ArgumentNullException(nameof(_lookupAssemblies));
            }

            var cachedTypeList = new List <Type>();

            foreach (var item in _lookupAssemblies)
            {
                cachedTypeList.AddRange(item.GetTypes()
                                        .Where(x => TypeHelper.IsCompositeType(x) || TypeHelper.IsViewModel(x)).ToList());
            }

            foreach (var type in cachedTypeList)
            {
                CandidateTypes.Add(type.FullName, type);
            }
        }