Beispiel #1
0
        protected void RefreshCategories()
        {
            //get all available blueprints
            //then check each and put revealed blueprints in their categories
            mCategories = new Dictionary <string, List <string> >();
            mAllCategory.Clear();
            mEditorBlueprints.Clear();
            mBlueprintAssociations.Clear();

            for (int i = 0; i < LoadedBlueprints.Count; i++)
            {
                WIBlueprint blueprint = LoadedBlueprints[i];
                if (blueprint.IsEmpty)
                {
                    Debug.Log("Empty blueprint, adding temporary result");
                    blueprint.UseGenericResult = true;
                    blueprint.GenericResult    = new GenericWorldItem("Edibles", "Bacon");
                }

                if (!mBlueprintAssociations.ContainsKey(blueprint.GenericResult))
                {
                    mBlueprintAssociations.Add(blueprint.GenericResult, blueprint);
                }
                mAllCategory.Add(blueprint.Name);
                List <string> blueprintNameList = null;
                if (!mCategories.TryGetValue(blueprint.RequiredSkill.ToLower(), out blueprintNameList))
                {
                    blueprintNameList = new List <string>();
                    mCategories.Add(blueprint.RequiredSkill.ToLower(), blueprintNameList);
                }
                blueprintNameList.Add(blueprint.Name);
            }
        }
Beispiel #2
0
        protected void RefreshCategoriesEditor()
        {
            //get all available blueprints
            //then check each and put revealed blueprints in their categories
            mCategories = new Dictionary <string, List <string> >();
            mBlueprintAssociations.Clear();
            mAllCategory.Clear();
            mEditorBlueprints.Clear();
            List <string> blueprintNames = Mods.Get.Available("Blueprint", DataType.World);

            foreach (string blueprintName in blueprintNames)                                            //Debug.Log ("refreshing blueprint " + blueprintName);
            {
                WIBlueprint blueprint = null;
                if (Mods.Get.Editor.LoadMod <WIBlueprint>(ref blueprint, "Blueprint", blueprintName))
                {
                    if (blueprint.Revealed)
                    {
                        if (!mBlueprintAssociations.ContainsKey(blueprint.GenericResult))
                        {
                            mBlueprintAssociations.Add(blueprint.GenericResult, blueprint);
                        }
                        mAllCategory.Add(blueprint.Name);
                        List <string> blueprintNameList = null;
                        if (!mCategories.TryGetValue(blueprint.RequiredSkill.ToLower(), out blueprintNameList))
                        {
                            blueprintNameList = new List <string>();
                            mCategories.Add(blueprint.RequiredSkill.ToLower(), blueprintNameList);
                        }
                        blueprintNameList.Add(blueprint.Name);
                    }
                }
            }
        }
Beispiel #3
0
 public void NewBlueprint()
 {
     CreatingNewBlueprint = true;
     selectedRowIndex     = -1;
     selectedItemIndex    = -1;
     Blueprint            = new WIBlueprint();
     Blueprint.Clear(true);
     Blueprint.Name = "EmptyBlueprint";
 }
Beispiel #4
0
        public WIBlueprint EditorCreateBlueprint(string blueprintName, string requiredSkillName)
        {
            WIBlueprint newBlueprint = new WIBlueprint();

            newBlueprint.Name          = blueprintName;
            newBlueprint.RequiredSkill = requiredSkillName;
            mEditorBlueprints.Add(newBlueprint);
            return(newBlueprint);
        }
Beispiel #5
0
        public bool Blueprint(string blueprintName, out WIBlueprint blueprint)
        {
            blueprint = null;
            if (mLoadedBlueprints.TryGetValue(blueprintName, out blueprint))
            {
                return(true);
            }
            //we're loading all blueprints on startup now so this is unnecessary

            /*else if (Mods.Get.Runtime.LoadMod(ref blueprint, "Blueprint", blueprintName)) {
             *              mLoadedBlueprints.Add(blueprintName, blueprint);
             *              return true;
             * }*/
            return(false);
        }
Beispiel #6
0
        public void Reveal(string blueprintName, BlueprintRevealMethod method, string source)
        {
            WIBlueprint blueprint = null;

            if (Mods.Get.Runtime.LoadMod(ref blueprint, "Blueprint", blueprintName))
            {
                if (!blueprint.Revealed)
                {
                    blueprint.Revealed     = true;
                    blueprint.RevealMethod = method;
                    blueprint.RevealSource = source;
                    GUI.GUIManager.PostGainedItem(blueprint);
                }
                blueprint.Instances++;
                Mods.Get.Runtime.SaveMod(blueprint, "Blueprint", blueprintName);
            }
        }
Beispiel #7
0
 public bool BlueprintExistsForItem(WorldItem worlditem, out WIBlueprint blueprint)
 {
     blueprint = null;
     mAssociationWorldItem.CopyFrom(worlditem);
     //Debug.Log ("Checking if blueprint exists for " + mAssociationWorldItem.PrefabName);
     foreach (KeyValuePair <GenericWorldItem, WIBlueprint> keyValue in mBlueprintAssociations)
     {
         if (string.Equals(keyValue.Key.PackName, mAssociationWorldItem.PackName) &&
             string.Equals(keyValue.Key.PrefabName, mAssociationWorldItem.PrefabName))
         {
             blueprint = keyValue.Value;
             break;
         }
     }
     return(blueprint != null);
     //return mBlueprintAssociations.TryGetValue (mAssociationWorldItem, out blueprint);
 }
Beispiel #8
0
        //protected string mContentsList = string.Empty;
        protected static string GetContentsList(WIBlueprint blueprint)
        {
            Dictionary <string, int> contents = new Dictionary <string, int>();

            AddContentsToList(blueprint.Row1, contents);
            AddContentsToList(blueprint.Row2, contents);
            AddContentsToList(blueprint.Row3, contents);

            List <string> contentsList = new List <string>();

            foreach (KeyValuePair <string, int> contentsKey in contents)
            {
                contentsList.Add(" - " + contentsKey.Value.ToString() + " " + contentsKey.Key);
            }
            string contentsListString = contentsList.JoinToString("\n");

            contentsList.Clear();
            contents.Clear();
            return(contentsListString);
        }
Beispiel #9
0
        public int GeneratePattern(WIBlueprint blueprint)
        {
            //generates a bitmask that can be used to look up blueprints more quickly
            int pattern = 0;

            //i try to avoid actually naming the number of columns in a blueprint
            //this is to leave the door open for more than 3 columns
            blueprint.Rows = new List <GenericWorldItem>();
            blueprint.Rows.AddRange(blueprint.Row1);
            blueprint.Rows.AddRange(blueprint.Row2);
            blueprint.Rows.AddRange(blueprint.Row3);
            for (int i = 0; i < blueprint.Rows.Count; i++)
            {
                if (!blueprint.Rows[i].IsEmpty)
                {
                    pattern |= 1 << i;
                }
            }
            //set the pattern in case we want to use it later (?)
            blueprint.Pattern = pattern;
            return(pattern);
        }
Beispiel #10
0
        public List <WIBlueprint> BlueprintsByCategory(string categoryName)
        {
            if (categoryName == "(Unsaved)")
            {
                return(mEditorBlueprints);
            }

            List <WIBlueprint> blueprints     = new List <WIBlueprint>();
            List <string>      blueprintNames = new List <string>();

            if (Category(categoryName.ToLower().Trim(), out blueprintNames))
            {
                foreach (string blueprintName in blueprintNames)
                {
                    WIBlueprint blueprint = null;
                    if (Blueprint(blueprintName, out blueprint, true) && blueprint.Revealed)
                    {
                        blueprints.Add(blueprint);
                    }
                }
            }
            return(blueprints);
        }
Beispiel #11
0
        public bool Blueprint(string blueprintName, out WIBlueprint blueprint, bool onlyIfRevealed)
        {
            //Temp TODO remove this
            onlyIfRevealed = false;
            blueprint      = null;
            if (mLoadedBlueprints.TryGetValue(blueprintName, out blueprint))
            {
                if (onlyIfRevealed)
                {
                    return(blueprint.Revealed);
                }
                else
                {
                    return(true);
                }
            }
            //we're loading all blueprints on startup now so this is unnecessary

            /* else if (Mods.Get.Runtime.LoadMod(ref blueprint, "Blueprint", blueprintName)) {
             *              //get the description for the blueprint
             *              WorldItem prefab = null;
             *              if (WorldItems.Get.PackPrefab(blueprint.GenericResult.PackName, blueprint.GenericResult.PrefabName, out prefab)) {
             *                              //blueprint.Description = prefab.DisplayName;
             *                              if (!string.IsNullOrEmpty(prefab.Props.Global.ExamineInfo.StaticExamineMessage)) {
             *                                              blueprint.Description = prefab.Props.Global.ExamineInfo.StaticExamineMessage;
             *                              }
             *              }
             *              mLoadedBlueprints.Add(blueprintName, blueprint);
             *              if (onlyIfRevealed) {
             *                              return blueprint.Revealed;
             *              } else {
             *                              return true;
             *              }
             * }*/
            return(false);
        }
Beispiel #12
0
        public void DrawEditor()
        {
            if (WorldItems.Get == null)
            {
                Manager.WakeUp <WorldItems>("Frontiers_WorldItems");
                WorldItems.Get.Initialize();
            }

            GUILayout.Label("Blueprint categories:");

            if (openWindow)
            {
                SelectWorldItem();
            }

            UnityEngine.GUI.color = Color.cyan;
            if (!string.IsNullOrEmpty(selectedCategory))
            {
                GUILayout.Label("Selected category: " + selectedCategory);
                List <WIBlueprint> blueprintList = BlueprintsByCategory(selectedCategory);
                foreach (WIBlueprint blueprint in blueprintList)
                {
                    //				GUILayout.BeginHorizontal ( );
                    UnityEngine.GUI.color = Color.yellow;
                    if (blueprint == selectedBlueprint)
                    {
                        UnityEngine.GUI.color = Color.cyan;
                        GUILayout.Label("Selected blueprint:");
                        GUILayout.BeginHorizontal();
                        if (blueprint.GenericResult != null && !string.IsNullOrEmpty(blueprint.GenericResult.PrefabName))
                        {
                            if (GUILayout.Button(blueprint.GenericResult.PrefabName))
                            {
                                rowSelection = null;
                                rowIndex     = 100;
                                openWindow   = true;
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("(Choose result)"))
                            {
                                rowSelection = null;
                                rowIndex     = 100;
                                openWindow   = true;
                            }
                        }
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Name:");
                        blueprint.Name = GUILayout.TextField(blueprint.Name);
                        if (string.IsNullOrEmpty(blueprint.Name))
                        {
                            if (!blueprint.GenericResult.IsEmpty)
                            {
                                blueprint.Name = blueprint.GenericResult.PrefabName;
                            }
                        }
                        GUILayout.Label("Required Skill:");
                        blueprint.RequiredSkill = GUILayout.TextField(blueprint.RequiredSkill);
                        GUILayout.Label("Title:");
                        blueprint.Title = GUILayout.TextField(blueprint.Title);
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        blueprint.Revealed         = GUILayout.Toggle(blueprint.Revealed, "Revealed");
                        blueprint.UseGenericResult = GUILayout.Toggle(blueprint.UseGenericResult, "Generic Result");
                        blueprint.BaseCraftTime    = UnityEditor.EditorGUILayout.FloatField(blueprint.BaseCraftTime);
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Row 1:");
                        for (int i = 0; i < selectedBlueprint.Row1.Count; i++)
                        {
                            if (i == rowIndex && selectedBlueprint.Row1 == rowSelection)
                            {
                                UnityEngine.GUI.color = Color.yellow;
                            }
                            else
                            {
                                UnityEngine.GUI.color = Color.white;
                            }

                            if (selectedBlueprint.Row1[i] == null || selectedBlueprint.Row1[i].StackName == string.Empty)
                            {
                                UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.gray, 0.5f);
                                if (GUILayout.Button("\n\n -(Empty)= \n\n"))
                                {
                                    rowSelection = selectedBlueprint.Row1;
                                    rowIndex     = i;
                                    openWindow   = true;
                                }
                            }
                            else
                            {
                                UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.gray, 0.5f);
                                if (GUILayout.Button("\n\n" + selectedBlueprint.Row1[i].StackName + "\n\n"))
                                {
                                    rowSelection = selectedBlueprint.Row1;
                                    rowIndex     = i;
                                    openWindow   = true;
                                }
                            }
                        }
                        GUILayout.EndHorizontal();
                        UnityEngine.GUI.color = Color.cyan;
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Row 2:");
                        for (int i = 0; i < selectedBlueprint.Row2.Count; i++)
                        {
                            if (i == rowIndex && selectedBlueprint.Row2 == rowSelection)
                            {
                                UnityEngine.GUI.color = Color.yellow;
                            }
                            else
                            {
                                UnityEngine.GUI.color = Color.white;
                            }

                            if (selectedBlueprint.Row2[i] == null || selectedBlueprint.Row2[i].StackName == string.Empty)
                            {
                                UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.gray, 0.5f);
                                if (GUILayout.Button("\n\n -(Empty)= \n\n"))
                                {
                                    rowSelection = selectedBlueprint.Row2;
                                    rowIndex     = i;
                                    openWindow   = true;
                                }
                            }
                            else
                            {
                                UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.white, 0.5f);
                                if (GUILayout.Button("\n\n" + selectedBlueprint.Row2[i].StackName + "\n\n"))
                                {
                                    rowSelection = selectedBlueprint.Row2;
                                    rowIndex     = i;
                                    openWindow   = true;
                                }
                            }
                        }
                        GUILayout.EndHorizontal();
                        UnityEngine.GUI.color = Color.cyan;
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Row 3:");
                        for (int i = 0; i < selectedBlueprint.Row3.Count; i++)
                        {
                            if (i == rowIndex && selectedBlueprint.Row3 == rowSelection)
                            {
                                UnityEngine.GUI.color = Color.yellow;
                            }
                            else
                            {
                                UnityEngine.GUI.color = Color.white;
                            }

                            if (selectedBlueprint.Row3[i] == null || selectedBlueprint.Row3[i].StackName == string.Empty)
                            {
                                UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.gray, 0.5f);
                                if (GUILayout.Button("\n\n -(Empty)= \n\n"))
                                {
                                    rowSelection = selectedBlueprint.Row3;
                                    rowIndex     = i;
                                    openWindow   = true;
                                }
                            }
                            else
                            {
                                UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.white, 0.5f);
                                if (GUILayout.Button("\n\n" + selectedBlueprint.Row3[i].StackName + "\n\n"))
                                {
                                    rowSelection = selectedBlueprint.Row3;
                                    rowIndex     = i;
                                    openWindow   = true;
                                }
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        if (blueprint.GenericResult != null)
                        {
                            if (GUILayout.Button(blueprint.GenericResult.StackName))
                            {
                                selectedBlueprint = blueprint;
                            }
                        }
                        else
                        {
                            if (GUILayout.Button(" (empty blueprint) "))
                            {
                                selectedBlueprint = blueprint;
                            }
                        }
                    }
                }
                UnityEngine.GUI.color = Color.cyan;
                GUILayout.BeginHorizontal();
                GUILayout.Label("     ");
                if (GUILayout.Button("Create blueprint"))
                {
                    EditorCreateBlueprint("New blueprint", selectedCategory);
                }
                GUILayout.Label("     ");
                GUILayout.EndHorizontal();

                if (GUILayout.Button("\nTOP\n"))
                {
                    selectedCategory = null;
                }
            }
            else
            {
                UnityEngine.GUI.color = Color.cyan;
                if (GUILayout.Button("\nTOP\n"))
                {
                    selectedCategory = null;
                }
                else
                {
                    UnityEngine.GUI.color = Color.cyan;
                    foreach (string category in Categories)
                    {
                        if (GUILayout.Button(category))
                        {
                            selectedCategory = category;
                            return;
                        }
                    }
                }
            }

            UnityEngine.GUI.color = Color.yellow;
            if (GUILayout.Button("\n SAVE TO DISK \n"))
            {
                SaveBlueprintsEditor();
            }
            if (GUILayout.Button("\n LOAD FROM DISK \n"))
            {
                LoadBlueprintsEditor();
            }
        }
Beispiel #13
0
        public bool HasBlueprint(string blueprintName)
        {
            WIBlueprint blueprint = null;

            return(Blueprint(blueprintName, out blueprint, true));
        }