Api Sandbox Resources ResourceGenerator
class

ResourceGenerator

public abstract class ResourceGenerator

Creates a resource from a json definition

Properties

Name Type Description
CacheToDisk virtual Boolean If true then the generation will create a real resource and store it on disk. Use this if creating the resource takes a while, or you won't be shipping the generator with the game, or if it relies on data that won't be available in the shipped game.

Methods

static ResourceGenerator<T> Create(String generatorName)

Create a ResourceGenerator by name

static ResourceGenerator<T> Create(EmbeddedResource serialized)

Create a ResourceGenerator by name and deserialize it

static T CreateResource(EmbeddedResource obj, Options options)
static Resource CreateResource(EmbeddedResource obj, Options options, Type type)

Create a resource from an embedded resource with a given Type

obj
options
type
virtual Void Deserialize(JsonObject obj)

Copy properties from obj to us

virtual UInt64 GetHash()

Returns a hash to be used when loading/saving. We use this to determine if the resource has changed. By default we serialize the generator to a json string and return the CRC64 of that value. You can override this in your generator if you need to make it faster, or ignore some stuff.

virtual ValueTask<Resource> FindOrCreateObjectAsync(Options options, CancellationToken token)

If we generated this before, then find the current cache'd value. If not, then generate a new one.

virtual Resource FindOrCreateObject(Options options)

Find or create the resource (blocking)

options
Assembly: Sandbox.Engine Namespace: Sandbox.Resources Full Name: Sandbox.Resources.ResourceGenerator