Angry-Squirrels / RadEngine

A Haxe game engine
2 stars 0 forks source link

Assets refactoring #50

Open Tomobodo opened 10 years ago

Tomobodo commented 10 years ago

Level should be assets, prefab as well, not be composed of an asset. The way assets are saved and loaded complexifies serialisation.

We should have an interface IRadAsset :

interface IRadAsset {
    function serialize() : Dynamic;
    function deSerialize(object : Dynamic) : IRadAsset;
    function save(path : String) : Void;
    function load(path : String) : IRadAsset;
    function getPath() : String;
}

Something like this. When saved, the RadAsset stringify its field with json and save it If a component containing an RadAsset field is stringified, it use the serialize method of that asset to replace it in the json. On load it use the deSerialize method to create the instance.

Tomobodo commented 10 years ago

Or, in a simpler way, just have a ISerialize interface with the two serialisation method.