package ecs

import (
	
	
)

// Resources manage a world's resources. Access it using [World.Resources].
//
// Although this type provides an ID-based API, the recommended usage is via [Resource].
type Resources struct {
	registry  registry
	resources []any
}

// newResources creates a new Resources manager.
func newResources() Resources {
	return Resources{
		registry:  newRegistry(),
		resources: make([]any, maskTotalBits),
	}
}

// Add a resource to the world.
// The resource should always be a pointer.
//
// Panics if there is already a resource of the given type.
//
// See [Resource.Add] for the recommended type-safe way.
func ( *Resources) ( ResID,  any) {
	if .resources[.id] != nil {
		panic(fmt.Sprintf("Resource of ID %d was already added (type %v)", .id, reflect.TypeOf()))
	}
	.resources[.id] = 
}

// Remove a resource from the world.
//
// Panics if there is no resource of the given type.
//
// See [Resource.Remove] for the recommended type-safe way.
func ( *Resources) ( ResID) {
	if .resources[.id] == nil {
		panic(fmt.Sprintf("Resource of ID %d is not present", .id))
	}
	.resources[.id] = nil
}

// Get returns a pointer to the resource of the given type.
//
// Returns nil if there is no such resource.
//
// See [Resource.Get] for the recommended type-safe way.
func ( *Resources) ( ResID) any {
	return .resources[.id]
}

// Has returns whether the world has the given resource.
//
// See [Resource.Has] for the recommended type-safe way.
func ( *Resources) ( ResID) bool {
	return .resources[.id] != nil
}

// reset removes all resources.
func ( *Resources) () {
	for  := range .resources {
		.resources[] = nil
	}
}