Esempio n. 1
0
        internal static bool LoadFile(string path, Mod mod, bool fullPath = false)
        {
            TagCompound tag;

            if (!fullPath)
            {
                var stream = mod.GetFileStream(path);
                tag = TagIO.FromStream(stream);
                stream.Close();
            }

            else
            {
                tag = TagIO.FromFile(path);
            }

            if (tag is null)
            {
                StructureHelper.Instance.Logger.Warn("Structure was unable to be found. Are you passing the correct path?");
                return(false);
            }

            StructureDataCache.Add(path, tag);
            return(true);
        }
 public override void Load()
 {
     if (System.IO.File.Exists(ModLoader.ModPath.Replace("Mods", "SavedStructures") + "/TestWandCache"))
     {
         TagCompound tag = TagIO.FromFile(ModLoader.ModPath.Replace("Mods", "SavedStructures") + "/TestWandCache");
         PreviewWidth  = tag.GetInt("Width");
         PreviewHeight = tag.GetInt("Height");
     }
 }
Esempio n. 3
0
 private void CheckNull()
 {
     if (savable == null)
     {
         try
         {
             savable = TagIO.FromFile(Path.Combine(Main.PlayerPath, sscfile));
         }
         catch { }
         savable = savable ?? new TagCompound();
     }
 }
Esempio n. 4
0
        public override bool UseItem(Player player)
        {
            if (player.altFunctionUse == 2)
            {
                ignoreNull = !ignoreNull;
                if (ignoreNull)
                {
                    Main.NewText("Now ignoring null tiles and placing all variants. This will take up alot of horizontal space ;) (Edit Mode)");
                }
                else
                {
                    Main.NewText("Now respecting null tiles and placing random variant (Test Mode)");
                }
                return(true);
            }

            if (ignoreNull)
            {
                Point16 pos = (Main.MouseWorld / 16).ToPoint16();

                TagCompound tag = TagIO.FromFile(ModLoader.ModPath.Replace("Mods", "SavedStructures") + "/TestWandCacheMulti");

                if (tag == null)
                {
                    throw new Exception("Path to structure was unable to be found. Are you passing the correct path?");
                }

                List <TagCompound> structures = (List <TagCompound>)tag.GetList <TagCompound>("Structures");

                for (int k = 0; k < structures.Count; k++)
                {
                    StructureHelper.Generate(structures[k], pos);
                    pos = new Point16(pos.X + structures[k].GetInt("Width") + 2, pos.Y);
                }
            }

            else
            {
                StructureHelper.GenerateMultistructureRandom(ModLoader.ModPath.Replace("Mods", "SavedStructures") + "/TestWandCacheMulti", (Main.MouseWorld / 16).ToPoint16(), mod, true);
            }

            return(true);
        }
Esempio n. 5
0
 public override TagCompound GetTagCompound()
 {
     return(TagIO.FromFile(FileResourcePath));
 }
Esempio n. 6
0
        public override TDimension Load()
        {
            var tagCompound = TagIO.FromFile(FileResourcePath);

            return(TagIO.Deserialize <TDimension>(tagCompound));
        }