class World( Entity ):
	drawable = collidable = updatable = True
	server_sendable = True
	client_sendable = batchable = False
	def __init__( self ):
		self.bstate = BlockWorldState()
		self.bstate.random( 10 )
		self.batch = None
		self.coll = CollGeometry()

	def update( self, dt ):
		if not self.bstate.dirty:
			return

		self.coll = CollGeometry()
		self.bstate.dirty = False

		self.ground = Block( -50., -100., -50., 100. )
		self.ground.set_color( (100, 0, 0, 0) )
		self.coll.add_geometry( CollAABB(
			Vector3f( -50., -100., -50. ), Vector3f( 50., 0., 50. ) ) )

		self.blocks = [ self.ground ]
		for b in self.bstate.blocks:
			minx, minz, c = b
			b = Block( minx, 0., minz, 5. )
			b.set_color( (0, 100, c, 0) )

			self.coll.add_geometry( CollAABB(
				Vector3f( minx, 0., minz ), Vector3f( minx+5., 5, minz+5. ) ) )
			self.blocks.append( b )

		self.batch = Batch( self.blocks )

	def collision_geometry( self ):
		return self.coll

	def resolve( self, other, coll ):
		return other.resolve( self, coll )

	def state( self ):
		return self.bstate

	def draw( self ):
		if self.batch:
			self.batch.draw()
	def update( self, dt ):
		if not self.bstate.dirty:
			return

		self.coll = CollGeometry()
		self.bstate.dirty = False

		self.ground = Block( -50., -100., -50., 100. )
		self.ground.set_color( (100, 0, 0, 0) )
		self.coll.add_geometry( CollAABB(
			Vector3f( -50., -100., -50. ), Vector3f( 50., 0., 50. ) ) )

		self.blocks = [ self.ground ]
		for b in self.bstate.blocks:
			minx, minz, c = b
			b = Block( minx, 0., minz, 5. )
			b.set_color( (0, 100, c, 0) )

			self.coll.add_geometry( CollAABB(
				Vector3f( minx, 0., minz ), Vector3f( minx+5., 5, minz+5. ) ) )
			self.blocks.append( b )

		self.batch = Batch( self.blocks )