Forging the core 3/?? - Assets management
Hey :)
Before we start: I'm not an English native speaker, I'm not a professor, I'm just an indie developer that learned how to develop on his free-time, so don't take this post for a tutorial, this is more a "blog" where I wrote to talk about what I've worked on, why and kinda how, no more, no less :)
So, last time I talked about the Serializer, now we will talk about another part that is at least or even more important than it, the AssetsManager!
To make it simple, what is an Assets Manager?
The assets manager is what will.. manage your asset. It will create it, store it, remove it, update it, etc... Really, it will itteraly manage it.
But why?
Well, you need to have a way to know where your asset is, to know if the asset has been loaded or created, or if it's going to be deleted (if you delete an image, but the engine / game still try to use it, you will get an "Huho" then poof, CTD (Crash To Desktop)), you could create an event for each "type" of object you have in game (item, character, image, sounds, etc...) but well, it really not good, you need to be able to regroup it, and do more with less, so here come the "Assets Manager"!
How is it made?
Well, this will be the main part of this post, because I passed by 2 "major" versions, each with their bonus and malus.
First version : The monolith
I call it like that, because it will litteraly be a big block that will store any thing that you gave it, the main bonus of this is that you just have to write one(1) class, then poof, you have your own assets manager. It's kinda good for a "small" project (no insult if you use it, if you find yours good, it's fine), but when you start to work on a more bigger project, you will get a lots of problem with it:
How your code know what asset it will get? Yes, because, as I said, this type can store ANY asset that you give it, but it can't really pin-point what it is once stored, it just know that this is an asset, but it's maybe an image? Maybe a text? Maybe a very complex script that control a quest? He don't know, and ngl, he doesn't care about that, you just asked him to store it, and he stored it and is ready to give it back to you.
Second version : Registries and Factories
Ok, now you will say "Ok, but before you said that the assets manager need to be able to create, remove or update your asset, but you didn't talk about it for the monolith type??" - Well, yes, simply because at this point, I just couldn't take it anymore, so I decided to completely erase it and rewrite it from the ground, and this is the actual version: Registries and Factories.
To make it simpler to explain, imagine:
You go on a website to buy 10 photos of your dogs, you will make your order on the site, and this site will create a "document" that will explain what the factory need to create, once it's done, the factory will send your photo back to you. Ok, it's really a quickly explained, but it really explain what are "Registries" and "Factories".
Registries will store all (or most of) your object, you can have a "MapRegistry" that will store some "MapDefinition", a "MapDefinition" will describe what map need to be created.
Factories on his side will create an "instance" of your object via a "definition" that you gave. So you got a "MapFactory" that will ask for a "MapDefinition" object, and we give you back an "MapInstance" ready to use and be shown in your game.
Now if you want to remove a map, you go inside the registry and ask for his MapDefinition to be removed, and tada, this map will be removed, you need to update it? No problem, just edit his MapDefinition. You want to be able to store item? Then you create a "ItemRegistry" and an "ItemFactory" and you can now edit, store, remove, and create new item!
This is more "complex" than the monolith because you have more cogs in the machines, but at least you can use it more freely with way more security (or at least for me).
I will not talk about a lots of other bonus (Able to do a ObjectPool and/or cache system) but yeah, this is way better, or at least I found it way better :)
Anyway.. Have a good day/night!
Ward.
Get RPG Creator
RPG Creator
An open-source, free, and modular RPG Maker alternative
Status | In development |
Category | Tool |
Author | Ward727 |
Genre | Role Playing |
Tags | 2D, 3D, Game engine, Indie, Open Source, Royalty Free, RPG Maker, software |
Languages | English, French |
More posts
- Forging the core 2/??44 days ago
- Forging the Core 1/??May 01, 2025
- Save file, and layerApr 09, 2025
- First (pre-)view of the new versionApr 03, 2025
- Explanation for the wait and why there was no newsMar 10, 2025
- Assets manager - Assets previewer & more!Dec 01, 2024
- WIP - Assets ManagerNov 19, 2024
- Assets Manager V1Nov 09, 2024
- Status Editor V1Nov 06, 2024
Comments
Log in with itch.io to leave a comment.
Loud excitement
Thanks =)