Beispiel #1
0
        public static void ReloadBlueprints(bool ingame)
        {
            BlueprintsState.LoadedBlueprints.Clear();
            string[] blueprintFiles = Directory.GetFiles(GetBlueprintDirectory());

            foreach (string blueprintFile in blueprintFiles)
            {
                if (blueprintFile.EndsWith(".blueprint") || blueprintFile.EndsWith(".json"))
                {
                    Blueprint blueprint = new Blueprint(blueprintFile);

                    if (blueprint.ReadBinary() && !blueprint.IsEmpty())
                    {
                        BlueprintsState.LoadedBlueprints.Add(blueprint);
                    }

                    else if (blueprint.ReadJSON() && !blueprint.IsEmpty())
                    {
                        BlueprintsState.LoadedBlueprints.Add(blueprint);
                    }
                }
            }

            if (ingame && BlueprintsState.LoadedBlueprints.Count > 0)
            {
                BlueprintsState.SelectedBlueprintIndex = 0;
                BlueprintsState.ClearVisuals();
                BlueprintsState.VisualizeBlueprint(Grid.PosToXY(PlayerController.GetCursorPos(KInputManager.GetMousePos())), BlueprintsState.SelectedBlueprint);
            }
        }
Beispiel #2
0
        public static bool LoadBlueprint(string blueprintLocation, out Blueprint blueprint)
        {
            blueprint = new Blueprint(blueprintLocation);
            if (!blueprint.ReadBinary())
            {
                blueprint.ReadJSON();
            }

            return(!blueprint.IsEmpty());
        }
Beispiel #3
0
        public static void LoadFolder(string folder)
        {
            string[] files      = Directory.GetFiles(folder);
            string[] subfolders = Directory.GetDirectories(folder);

            foreach (string file in files)
            {
                if (file.EndsWith(".blueprint") || file.EndsWith(".json"))
                {
                    Blueprint blueprint = new Blueprint(file);
                    bool      valid     = false;

                    if (blueprint.ReadBinary() && !blueprint.IsEmpty())
                    {
                        valid = true;
                    }

                    else
                    {
                        blueprint.ReadJSON();

                        if (!blueprint.IsEmpty())
                        {
                            valid = true;
                        }
                    }

                    if (valid)
                    {
                        PlaceIntoFolder(blueprint);
                    }
                }
            }

            foreach (string subfolder in subfolders)
            {
                LoadFolder(subfolder);
            }
        }