arcana-engine / goods Goto Github PK
View Code? Open in Web Editor NEWAsset manger for good assets only
License: Other
Asset manger for good assets only
License: Other
Hel lo
@zakarumych Please do not call yourself an "Engineer", you are not an engineer.
There is no such thing as engineering in software. Engineering is much more serious and complex and real. Engineering means building real things like turbines and buildings. It is not about sitting behind a keyboard and writing code. Engineering is real, it is not fake and petty like software development.
Similar concept to Asset
, but each time Prefab
is requested a new instance must be created.
In some cases it can be simply cloned, but oftentimes Prefab
should be built again from its data representation.
For example this is the case for entities in ECS. Each time given Prefab
is requested a new entity should be created with all required components. As an Asset
it would be cached and the same entity id will be returned in the Handle
.
This example will unexpectedly panic at this unwrap when obtaining the second handle:
use futures_executor::ThreadPool;
use goods::{AssetDefaultFormat, Cache, FileSource, Registry, RonFormat, SyncAsset};
use serde::Deserialize;
use std::{error, fmt, path::Path};
#[derive(Clone, Deserialize)]
struct StringAsset(String);
#[derive(Debug)]
struct Error;
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}
impl error::Error for Error {}
impl SyncAsset for StringAsset {
type Error = Error;
type Context = ();
type Repr = StringAsset;
fn build(repr: Self::Repr, _: &mut Self::Context) -> Result<Self, Self::Error> {
Ok(repr)
}
}
impl AssetDefaultFormat<&'static str> for StringAsset {
type DefaultFormat = RonFormat;
}
fn main() {
let registry = Registry::<&'static str>::builder()
.with(FileSource::new(
Path::new(env!("CARGO_MANIFEST_DIR")).to_path_buf(),
))
.build();
let cache = Cache::new(registry, ThreadPool::new().unwrap());
let handle_1 = cache.load::<StringAsset>("string1.txt");
let handle_2 = cache.load::<StringAsset>("string2.txt");
}
"string1.txt":
("string 1")
"string2.txt":
("string 2")
From what I was able to gather, there is currently no way to drop an asset without dropping the whole Cache
it's in. Is it possible to implement this functionality in some way?
It would enable manual reloading of assets (alleviating somewhat the need for full-on hot reloading) and freeing of resources taken up by assets no longer needed by the application (e.g., unloading old level on level change in a game).
It might be possible to do this by having the cache hold onto weak references to assets, meaning that if there are no Handle
s to an asset it should be unloaded.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.