unloadDroppedAssets

View sourceunloadDroppedAssets<T, U extends AssetDropped<T>>(dropEvent: Constructor<U>): SystemFunc

Creates a cleanup system that removes dropped-asset metadata from the world’s AssetServer.

The factory captures the constructor for one typed AssetDropped payload. The returned SystemFunc receives only world, then looks up Events<U> under typeidGeneric(Events, [dropEvent]) and the AssetServer resource. It visits the events currently readable by Events#each; each callback exposes the dropped asset ID, and the system calls AssetServer#dropAssetInfo for that ID.

This system removes server metadata only. It does not clear the event buffer, remove an asset from Assets, or release a handle. The AssetPlugin stages the typed event resource through EventPlugin and registers this returned system in the repeating AppSchedule.Update schedule’s CoreSystems.End group when events.dropped is provided.

Examples

import { World } from '@wimaengine/ecs'
import { AssetDropped, AssetServer, Events, unloadDroppedAssets } from '@wimaengine/asset'
import { typeidGeneric } from '@wimaengine/type'

class Texture {}
const world = new World()
const dropped = new Events()
world.setResource(new AssetServer())
world.setResourceByTypeId(typeidGeneric(Events, [AssetDropped]), dropped)
dropped.write(new AssetDropped(Texture, 0))
dropped.clear()
unloadDroppedAssets(AssetDropped)(world)
// AssetPlugin schedules this cleanup in Update/CoreSystems.End.

Type Parameters

T

U extends AssetDropped<T>

Parameters

NameDescriptionDefault
dropEvent

Constructor identifying the typed dropped-event resource to read.

—

Returns

Cleanup system that removes metadata for each readable dropped event.