internal ExceptionManager(string author, string mod, string modVersion, string errorEmail = null)
 {
     _errorsDir  = new DirectoryManager().FetchDirectoryNoParent("modErrors").FetchDirectoryNoParent(mod);
     _modVersion = modVersion;
     _errorEmail = errorEmail;
     _author     = author;
     _mod        = mod;
 }
        internal DirectoryManager FetchDirectoryNoParent(string name)
        {
            var dir = new DirectoryManager {
                _localContentLocation = Path.Combine(_localContentLocation, name),
                _root         = _root,
                _parent       = null,
                Folder        = name,
                ContentFolder = ContentFolder
            };

            CreateDirectory(name);

            return(dir);
        }
Exemple #3
0
        internal static void CreateItem(Dictionary <Color, Color> replaceColorsWith, string kind, string newVariantTileCode, string source, DirectoryManager directory, Blob overrides)
        {
            if (!File.Exists(Path.GetFullPath(Path.Combine(GameContext.ContentLoader.RootDirectory, source))))
            {
                return;
            }

            if (GameContext.ItemDatabase.GetConfigsByKind(kind).Any(x =>
                                                                    string.Equals(x.Value.Code, newVariantTileCode, StringComparison.CurrentCultureIgnoreCase)))
            {
                return;
            }

            var file = Regex.Replace(source, @"\/|\\", Path.DirectorySeparatorChar.ToString());

            var stream = GameContext.ContentLoader.ReadStream(file).ReadAllText();

            var blob = BlobAllocator.AcquireAllocator().NewBlob(false);

            blob.ReadJson(stream);

            var voxelIconFile   = Regex.Replace(blob.GetString("icon"), @"\/|\\", Path.DirectorySeparatorChar.ToString());
            var voxelInHandFile =
                Regex.Replace(blob.GetString("inHand"), @"\/|\\", Path.DirectorySeparatorChar.ToString());

            var iconOutput   = ChangeColor(voxelIconFile, replaceColorsWith);
            var inHandOutput = ChangeColor(voxelInHandFile, replaceColorsWith);

            directory.WriteQBFile(newVariantTileCode + ".icon", iconOutput);
            directory.WriteQBFile(newVariantTileCode + ".inHand", inHandOutput);

            blob.SetString("code", newVariantTileCode);
            blob.SetString("icon", directory.GetPath('/') + newVariantTileCode + ".icon.qb");
            blob.SetString("inHand", directory.GetPath('/') + newVariantTileCode + ".inHand.qb");

            blob.MergeFrom(overrides);

            var wait = true;

            directory.WriteFile(newVariantTileCode + ".item", blob, () => { wait = false; }, true);

            while (wait)
            {
            }
        }
Exemple #4
0
        internal static void CreateTile(Tile baseTile, Dictionary <Color, Color> replaceColorsWith, string newVariantTileCode, DirectoryManager directory, Blob overrides)
        {
            if (GameContext.TileDatabase.AllMaterials().Any(x =>
                                                            string.Equals(x.Code, newVariantTileCode, StringComparison.CurrentCultureIgnoreCase)))
            {
                return;
            }

            var file = Regex.Replace(baseTile.Configuration.Source, @"\/|\\", Path.DirectorySeparatorChar.ToString());

            var stream = GameContext.ContentLoader.ReadStream(file).ReadAllText();

            var blob = BlobAllocator.AcquireAllocator().NewBlob(false);

            blob.ReadJson(stream);

            var voxelFile = Regex.Replace(blob.GetString("voxels"), @"\/|\\", Path.DirectorySeparatorChar.ToString());

            var output = ChangeColor(voxelFile, replaceColorsWith);

            directory.WriteQBFile(newVariantTileCode, output);

            blob.SetString("code", newVariantTileCode);
            blob.SetString("voxels", directory.GetPath('/') + newVariantTileCode + ".qb");

            blob.MergeFrom(overrides);

            var wait = true;

            directory.WriteFile(newVariantTileCode + ".tile", blob, () => { wait = false; }, true);

            while (wait)
            {
            }
        }