import { World } from "@rbxts/matter"
import Roact from "@rbxts/roact"
import { useContext } from "@rbxts/roact-hooked"
import { clientState } from "ReplicatedStorage/ecs/state"

interface worldContextProps {
	world: World
	clientState: clientState
}

export const WorldContext = Roact.createContext<worldContextProps | undefined>(undefined)

export function useWorldContext(): worldContextProps {
	const context = useContext(WorldContext)
	if (!context) {
		error("useContext must be called within a Provider")
	}
	return context
}