Пример #1
0
 public List <ModelInfo._Enum.Element> GetElement(BlockCollection blockCollection, ResourceList res = null)
 {
     return(BlockInfo.GetModelInfo().GetElements(BlockInfo, blockCollection, GetCoordinate(), res));
 }
Пример #2
0
            public List <JsonModel.SimpleElement> GetSimpleElements(string directoryPath, BlockCollection blockCollection, ResourceList res = null)
            {
                var infoElements = GetElement(blockCollection, res);
                var elements     = new List <JsonModel.SimpleElement>();

                foreach (var e in infoElements)
                {
                    var g = e.GetElement(BlockInfo, GetCoordinate(), directoryPath);
                    elements.Add(e.GetElement(BlockInfo, GetCoordinate(), directoryPath));
                }
                return(elements);
            }
Пример #3
0
        static public float temp; static public float rain;                                                                                        //Biome
        #endregion
        static void Main(string[] args)
        {
            Current.Write("Reading Resources ...");
            res = new ResourceList(Application.StartupPath);
            Current.Write("");
            #region File & Options
            string file;
            //Current Version = 1.12.2
            version = 1.122;
            #region Get File
            if (args.Length > 0)
            {
                file = args[0];
            }
            else
            {
                Current.WriteLine("Input: <file> <mode & filter & biome>");
                args = Current.ReadLine().Split(' ');
                file = args[0];
            }

            if (file == null || !File.Exists(file))
            {
                Current.Error("File Not Found", true, true);
            }
            else if (new FileInfo(file).Extension == ".schematic" || new FileInfo(file).Extension == ".nbt")
            {
                target = new FileInfo(file).Extension;
            }
            else
            {
                Current.Error("File Not Supported", true, true);
            }
            #endregion
            #region GetOptions
            //Set Output Mode
            #region mode
            unlimit = args.Contains("unlimit");
            smooth  = args.Contains("smooth");
            nopause = args.Contains("nopause");
            log     = args.Contains("log");
            #endregion
            //Set Target Version
            #region version
            foreach (string reg in args)
            {
                if (Regex.Match(reg, "version=.*$").Success)
                {
                    if (Regex.Match(Regex.Matches(reg, "version=.*$")[0].Value, @"\d*\.\d*").Success)
                    {
                        List <double> v1st = new List <double>();
                        foreach (Match r in Regex.Matches(Regex.Matches(reg, "version=.*$")[0].Value, @"\d*\.\d*"))
                        {
                            v1st.Add(double.Parse(r.Value));
                        }
                        v1st.Sort(delegate(double x, double y)
                        {
                            return(y.CompareTo(x));
                        });
                        version = v1st[0];
                    }
                }
            }
            #endregion
            //Set Target Biome;
            #region biome
            temp = 0.8f; rain = 0.4f; var biome = "TheVoid";
            foreach (string reg in args)
            {
                if (Regex.Match(reg, "(?<=biome=).*$").Success)
                {
                    var biomeName = Regex.Match(reg, "(?<=biome=).*$").Value;
                    BiomeList.UpdateList(Application.StartupPath + "\\BiomeList");
                    var cbiome = BiomeList.GetBiome(biomeName);
                    if (cbiome != null)
                    {
                        temp = cbiome.Temperature; rain = cbiome.Rainfall; biome = biomeName;
                    }
                }
            }
            #endregion
            //Set Process;
            #region Process
            var nocompress = false;
            var hollow = false;
            var surface = false;
            var fillflow = false;  var fillflow_xyz = new Vector3()
            {
                X = 0.0, Y = 0.0, Z = 0.0
            }; var fillflow_block = new SimpleBlockInfo(""); var reverse_fillflow = false;
            nocompress = args.Contains("nocompress");
            hollow     = args.Contains("hollow");
            surface    = args.Contains("surface");
            foreach (string reg in args)
            {
                if (Regex.Match(reg, "(?<=fillflow=).*$").Success)
                {
                    try
                    {
                        var o = Regex.Match(reg, "(?<=fillflow=).*$").Value;
                        reverse_fillflow = Regex.Match(o, "(reverse|r)(?=\\()").Success;
                        var os = Regex.Match(o, "(?<=\\().*(?=\\))").Value.Split(',');
                        var ob = Regex.Match(o, "(?<=\\)).*$").Value.Trim();
                        if (os != null && os.Length == 3)
                        {
                            fillflow_xyz.X = double.Parse(Regex.Match(os[0].Trim(), "\\d+(.\\d+)?").Value);
                            fillflow_xyz.Y = double.Parse(Regex.Match(os[1].Trim(), "\\d+(.\\d+)?").Value);
                            fillflow_xyz.Z = double.Parse(Regex.Match(os[2].Trim(), "\\d+(.\\d+)?").Value);
                        }
                        if (ob != null)
                        {
                            fillflow_block = new SimpleBlockInfo(ob);
                        }
                        fillflow = true;
                    }
                    catch
                    {
                        Current.Error("FillFlow Format Error.", true, true);
                    }
                }
            }
            #endregion
            #endregion
            #region Filter
            #region For Classes
            var filterClasses = new List <string>();
            //get filter_classes
            foreach (string reg in args)
            {
                if (Regex.Match(reg, "(?<=filter_classes=).*$").Success)
                {
                    filterClasses = new List <string>(Regex.Match(reg, "(?<=filter_classes=).*$").Value.Split(';'));
                }
            }
            //remove form list
            foreach (var c in filterClasses)
            {
                res.DelectBlockInfoClass(c);
            }
            #endregion
            #region For Blocks
            var filterBlocks = "";
            var fbs          = new List <SimpleBlockInfo>();
            //Get filter_blocks
            foreach (string reg in args)
            {
                if (Regex.Match(reg, "(?<=filter_blocks=).*$").Success)
                {
                    filterBlocks = Regex.Match(reg, "(?<=filter_blocks=).*$").Value;
                    fbs          = res.SimpleBlockInfoCollection(Regex.Match(reg, "(?<=filter_blocks=).*$").Value, Application.StartupPath);
                }
            }
            //Remove from List
            foreach (var b in fbs)
            {
                res.DelectBlockInfo(b.Id, b.Data);
            }
            #endregion
            #endregion
            #endregion
            #region Set BlockCollection
            if (target == ".schematic")
            {
                Schematic2BlockCollection(file);
            }
            if (target == ".nbt")
            {
                NBT2BlockCollection(file);
            }
            bcl.blocks.RemoveAll(block => block == null);
            #endregion
            #region Output Info
            Current.WriteLine("");
            Current.WriteLine("- Info:");
            //-output target
            Current.WriteLine("Target = " + target.Replace(".", "").ToUpper());
            //-output size
            Current.WriteLine("Width = " + bcl.GetWidth() + " ,Height = " + bcl.GetHeight() + " ,Length = " + bcl.GetLength() + ";");
            //-output filter
            var ig_b = String.Join(";", filterBlocks);
            Current.WriteLine(ig_b == "" ? "Filter Blocks = none;" : "Filter Blocks = " + ig_b + ";");
            var ig_m = String.Join(";", filterClasses);
            Current.WriteLine(ig_m == "" ? "Filter Models = none;" : "Filter Models = " + ig_m + ";");
            //-output biome
            Current.WriteLine(biome == "" ? "Biome = none" : "Biome = " + biome + ";");
            //-output mode
            Current.WriteLine("Unlimit = " + unlimit.ToString() + " ,Smooth = " + smooth.ToString() + ";");
            //-output compress
            Current.WriteLine("Nocompress = " + nocompress.ToString() + " ,Hollow = " + hollow.ToString() + " ,Surface = " + surface.ToString());
            #endregion
            if (hollow)
            {
                bcl = Hollow(bcl);
            }
            if (fillflow)
            {
                bcl = FillFlow(bcl, fillflow_xyz, fillflow_block, reverse_fillflow);
            }
            var jsonModel = JsonModel(Application.StartupPath);
            if (!nocompress)
            {
                jsonModel = DuplicateOverlap(jsonModel);
            }
            if (surface)
            {
                jsonModel.KeepSurface();
            }
            jsonModel = ScaleModel(RemoveEmptyElement(jsonModel));
            #region Generating File
            Current.WriteLine("");
            Current.WriteLine("- Generating File:");

            var extension = Path.GetExtension(file);
            var newFile   = file.Replace(extension, ".json");
            File.WriteAllText(newFile, JsonConvert.SerializeObject(jsonModel, Formatting.Indented));

            Current.WriteLine(newFile + " has been Created");
            #endregion
            if (log)
            {
                File.WriteAllText("Log -" + DateTime.Now.ToFileTime() + ".txt", Current.Log.ToString());
            }
            if (nopause)
            {
                return;
            }
            Current.WriteLine("[ Press any key to continue... ]");
            Console.ReadKey(true);
        }
Пример #4
0
 public bool ConditionsMet(BlockInfo blockInfo, BlockCollection blockCollection, Vector3 pos, ResourceList res = null)
 {
     foreach (var condition in Conditions)
     {
         if (!condition.ConditionMet(blockInfo, blockCollection, pos, res))
         {
             return(false);
         }
     }
     return(true);
 }
Пример #5
0
                }                                                                                                                                         //RelativeBlocks (Tags | Ids, Relative Coordinate)

                public bool ConditionMet(BlockInfo blockInfo, BlockCollection blockCollection, Vector3 pos, ResourceList res = null)
                {
                    SetParamList();
                    if (_paramslist != null && blockInfo.Model.Params != null) //Match Params
                    {
                        if (!Universal.Match(blockInfo.Model.Params.Split(',').ToList(), _paramslist))
                        {
                            return(false);                                                                           //When Params of BlockInfo Not Include Params of ModelInfoCondition
                        }
                    }
                    if (_relativeBlocks != null) //Match RelativeBlocks
                    {
                        foreach (var info in _relativeBlocks.Keys)
                        {
                            if (res != null)
                            {
                                var _b = res.SimpleBlockInfoCollection(info);
                                var b  = blockCollection.GetBlock((int)(_relativeBlocks[info].X + pos.X), (int)(_relativeBlocks[info].Y + pos.Y), (int)(_relativeBlocks[info].Z + pos.Z));
                                if (b != null && _b != null)
                                {
                                    var success = _b.Find((SimpleBlockInfo __b) => Universal.MatchBlock(b.GetBlockInfo(), __b));
                                    if (success == null)
                                    {
                                        return(false);                //When Blocks Not Match
                                    }
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    return(true);
                }
Пример #6
0
        public List <_Enum> Enums = new List <_Enum>(); //Enums of the Model Collection
        public List <_Enum.Element> GetElements(BlockInfo blockInfo, BlockCollection blockCollection, Vector3 pos, ResourceList res = null)
        {
            var e  = Enums.FindAll((_Enum _enum) => _enum.ConditionsMet(blockInfo, blockCollection, pos, res));
            var el = new List <_Enum.Element>();

            foreach (var l in e)
            {
                el.AddRange(l.Elements);
            }
            return(el);
        }