public static bool BlockFilterFunction(BlockTypes blockType)
        {
            if (filter == "")
            {
                return(true);
            }
            var blockName = StringLookup.GetItemName(ObjectTypes.Block, (int)blockType).ToLower();

            return(blockName.Contains(filter.ToLower()));
        }
예제 #2
0
 static void GetRecipe(JObject BLOCK, int Id, ObjectTypes type = ObjectTypes.Block)
 {
     try
     {
         var DATA = new JArray();
         foreach (var thing in RecipeManager.inst.GetRecipeByOutputType(new ItemTypeInfo(type, Id)).m_InputItems)
         {
             var ITEM = new JObject
             {
                 { "name", StringLookup.GetItemName(ObjectTypes.Chunk, thing.m_Item.ItemType) },
                 { "id", thing.m_Item.ItemType },
                 { "count", thing.m_Quantity }
             };
             DATA.Add(ITEM);
         }
         BLOCK.Add("recipe", DATA);
     }
     catch { }
 }
        private void DoWindow(int id)
        {
            if (selectedGroup != null && changeKey)
            {
                Event current = Event.current;
                if (current.isKey)
                {
                    selectedGroup.keyCode = current.keyCode;
                    changeKey             = false;
                } /*else if (current.isMouse) {
                   * Console.WriteLine(current.button + " " + current.keyCode);
                   * }*/
            }

            GUILayout.BeginVertical();
            scroll = GUILayout.BeginScrollView(scroll);
            {
                //Groups
                for (int i = 0; i < module.groups.Count; i++)
                {
                    var group = module.groups[i];

                    var tempgroup    = selectedGroup;
                    var tempExpanded = expanded;

                    GUILayout.BeginHorizontal(GUI.skin.button, GUILayout.Height(25));
                    {
                        GUILayout.BeginVertical();
                        {
                            GUILayout.FlexibleSpace();
                            GUILayout.BeginHorizontal();
                            {
                                //Renaming
                                if (renaming && group == selectedGroup)
                                {
                                    group.name = GUILayout.TextField(group.name, textField, GUILayout.Width(250), GUILayout.Height(icon_size));
                                }
                                else
                                {
                                    GUILayout.Label(group.name, bigText, GUILayout.Width(250));
                                }

                                GUILayout.FlexibleSpace();

                                //Rename button
                                if (GUILayout.Button(renaming && group == selectedGroup ? icon_cancel : icon_rename, GUILayout.Width(icon_size), GUILayout.Height(icon_size)))
                                {
                                    renaming  = !renaming;
                                    changeKey = false;
                                }

                                //Key button
                                if (GUILayout.Button(changeKey && group == selectedGroup ? "Press a key" : group.keyCode.ToString(), GUILayout.MinWidth(icon_size)))
                                {
                                    changeKey = true;
                                }

                                //Remove button
                                if (GUILayout.Button(icon_remove, GUILayout.Width(icon_size), GUILayout.Height(icon_size)))
                                {
                                    groupToRemove = i;
                                    if (selectedGroup == group)
                                    {
                                        CleanGroup();
                                    }
                                }

                                //Expand button
                                if (GUILayout.Button(selectedGroup == group && expanded ? "V" : ">", GUILayout.Width(icon_size), GUILayout.Height(icon_size)))
                                {
                                    if (group != selectedGroup)
                                    {
                                        CleanGroup();
                                        expanded = true;

                                        selectedGroup = group;

                                        foreach (var w in selectedGroup.weapons)
                                        {
                                            w.block.visible.EnableOutlineGlow(true, cakeslice.Outline.OutlineEnableReason.ScriptHighlight);
                                        }
                                    }
                                    else
                                    {
                                        expanded = !expanded;
                                    }
                                }
                            }
                            GUILayout.EndHorizontal();
                            GUILayout.FlexibleSpace();
                        }
                        GUILayout.EndVertical();
                    }
                    GUILayout.EndHorizontal();


                    if (Event.current.type == EventType.Repaint)
                    {
                        //Scroll to added group
                        var lastrect = GUILayoutUtility.GetLastRect();
                        if (groupAdded && i == module.groups.Count - 1)
                        {
                            groupAdded = false;
                            scroll.y   = lastrect.y + lastrect.height / 2;
                        }
                    }

                    if (tempgroup != null && selectedGroup == tempgroup)
                    {
                        if (group == selectedGroup && tempExpanded)
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.Space(25f);
                            {
                                GUILayout.BeginVertical();
                                //Group weapons
                                for (int j = 0; j < displayWeapons.Count; j++)
                                {
                                    var weapon = displayWeapons[j];
                                    GUILayout.BeginHorizontal(GUI.skin.button);
                                    {
                                        GUILayout.Label(StringLookup.GetItemName(ObjectTypes.Block, (int)weapon.block.BlockType), middledText, GUILayout.Width(250));

                                        GUILayout.FlexibleSpace();

                                        if (GUILayout.Button(icon_remove, GUILayout.Width(icon_size), GUILayout.Height(icon_size)))
                                        {
                                            weapon.block.visible.EnableOutlineGlow(false, cakeslice.Outline.OutlineEnableReason.ScriptHighlight);
                                            group.weapons.RemoveAt(j);
                                            if (weapon.hammer)
                                            {
                                                ModuleWeaponGroupController.RemoveGroupForHammer(weapon.hammer, group);
                                            }
                                        }
                                    }
                                    GUILayout.EndHorizontal();

                                    if (Event.current.type == EventType.Repaint && weaponSelected && j == displayWeapons.Count - 1)
                                    {
                                        weaponSelected = false;
                                        var rect = GUILayoutUtility.GetLastRect();
                                        scroll.y = rect.y + rect.height / 2;
                                    }
                                }
                                if (GUILayout.Button(selectingWeapon ? "Selecting weapon..." : "Add weapon to group"))
                                {
                                    selectingWeapon = true;
                                }
                                GUILayout.EndVertical();
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                }
            }
            GUILayout.EndScrollView();
            //Add group button
            if (GUILayout.Button("Add group"))
            {
                CleanGroup();
                selectedGroup = new ModuleWeaponGroupController.WeaponGroup();
                module.groups.Add(selectedGroup);
                groupAdded = true;
            }
            GUILayout.EndVertical();

            GUI.DragWindow();
        }
예제 #4
0
        public static int Dump()
        {
            bool RemoveSecret = !Input.GetKey((UnityEngine.KeyCode) 308);

            Console.WriteLine("Starting block dump...");

            var DUMP = new JObject
            {
                { "game_version", SKU.DisplayVersion }, // Display Version
                { "date", DateTime.Now.ToString() }     // Date of dump
            };                                          // Create DUMP, which will be outputted to a file

            var CHUNKS = new JArray();                  // Create CHUNKS array

            // Populate CHUNKS array with resource chunks
            foreach (ChunkTypes id in Enum.GetValues(typeof(ChunkTypes)))
            {
                var ITEM = new JObject()
                {
                    { "name", StringLookup.GetItemName(ObjectTypes.Chunk, (int)id) },
                    { "id", (int)id },
                    { "price", RecipeManager.inst.GetChunkPrice(id) }
                };
                GetRecipe(ITEM, (int)id, ObjectTypes.Chunk);
                CHUNKS.Add(ITEM);
            }

            DUMP.Add("data_chunks", CHUNKS); // Add CHUNKS array to DUMP

            var DATA = new JArray();         // Create DATA array
                                             // Populate DATA array with all blocks

            int NumExported = 0;

            foreach (BlockTypes id in Enum.GetValues(typeof(BlockTypes)))
            {
                var       ITEM  = new JObject(); // Create DATA entry
                TankBlock Block = ManSpawn.inst.GetBlockPrefab(id);
                if (Block == null)
                {
                    continue;                // Escape if block is empty
                }
                GameObject Base = Block.gameObject;
                if (Base == null)
                {
                    continue;               // Escape if object is empty. Redundant
                }
                int grade = ManLicenses.inst.GetBlockTier(id, true);
                if (RemoveSecret && grade > 127)
                {
                    continue;
                }
                FactionSubTypes corp     = ManSpawn.inst.GetCorporation(id);
                BlockCategories category = ManSpawn.inst.GetCategory(id);

                // Block name
                ITEM.Add("block", StringLookup.GetItemName(ObjectTypes.Block, (int)id));
                // Resource name
                ITEM.Add("resource_name", Base.name);
                // Description
                ITEM.Add("description", StringLookup.GetItemDescription(ObjectTypes.Block, (int)id));
                // ID
                ITEM.Add("id", (int)id);
                // Enum
                ITEM.Add("enum", id.ToString());
                // Mass
                ITEM.Add("mass", Block.m_DefaultMass);
                // Corp int
                ITEM.Add("corp_int", (int)corp);
                // Corp
                ITEM.Add("corp", StringLookup.GetCorporationName(corp));
                // Category int
                ITEM.Add("category_int", (int)category);
                // Category
                ITEM.Add("category", StringLookup.GetBlockCategoryName(category));
                // Grade
                ITEM.Add("grade", grade);
                // Price
                ITEM.Add("price", RecipeManager.inst.GetBlockBuyPrice(id, true));
                // Rarity
                ITEM.Add("rarity", Block.BlockRarity.ToString());
                // Rarity
                ITEM.Add("blocklimit_cost", ManBlockLimiter.inst.GetBlockCost(id));
                // Health
                var mdmg = Base.GetComponent <ModuleDamage>();
                if (mdmg) // Redundant check
                {
                    ITEM.Add("health", mdmg.maxHealth);
                    ITEM.Add("fragility", mdmg.m_DamageDetachFragility);

                    // Death Explosion
                    GetExplosionData(ITEM, mdmg.deathExplosion, "DeathExplosion");
                }
                // Damageability
                var dmgb = Block.GetComponent <Damageable>();
                if (dmgb) // Redundant check
                {
                    ITEM.Add("damageable_type", dmgb.DamageableType.ToString());
                    ITEM.Add("damageable_type_int", (int)dmgb.DamageableType);
                }
                try
                {
                    // Cells
                    ITEM.Add("cell_count", Block.filledCells.Length);
                    // APs
                    ITEM.Add("ap_count", Block.attachPoints.Length);
                }
                catch { }

                // Recipe
                GetRecipe(ITEM, (int)id);
                // FireData
                GetFireData(ITEM, Base);
                // ModuleWeapon
                GetWeaponData(ITEM, Base);
                // ModuleDrill
                GetDrillData(ITEM, Base);
                // ModuleHammer
                GetHammerData(ITEM, Base);
                // ModuleEnergyStore
                GetEnergyData(ITEM, Base);
                // ModuleFuelTank
                GetFuelData(ITEM, Base);
                // ModuleShieldGenerator
                GetShieldData(ITEM, Base);
                // ModuleHover
                GetHoverData(ITEM, Base);
                // ModuleBooster
                GetBoosterData(ITEM, Base);
                // ModuleWheels
                GetWheelData(ITEM, Base);

                // Add to DATA
                DATA.Add(ITEM);
                NumExported++;
            }

            DUMP.Add("data_blocks", DATA); // Add DATA array to DUMPwww

            System.IO.File.WriteAllText("_Export/BlockInfoDump.json", DUMP.ToString(Newtonsoft.Json.Formatting.Indented));
            return(NumExported);
        }