All Downloads are FREE. Search and download functionalities are using the official Maven repository.

walkmc.shape.Cube.kt Maven / Gradle / Ivy

There is a newer version: 2.4.0
Show newest version
@file:UseContextualSerialization(Location::class)

package walkmc.shape

import kotlinx.serialization.*
import org.bukkit.*
import walkmc.extensions.*

/**
 * Represents a cube util class. This can be used to draw/display particles in a cube.
 */
@Serializable
data class Cube(
	var center: Location,
	var width: Double,
	var length: Double,
	var heigth: Double,
	var pointsWidth: Int,
	var pointsLength: Int,
	var pointsHeigth: Int,
) : Shape {
	
	/**
	 * Returns the path of this shape.
	 */
	@Transient
	override lateinit var path: List
	
	/**
	 * Generates the [path] and updates their property.
	 */
	override fun generatePath(): List {
		val path = center.generateCubePath(width, length, heigth, pointsWidth, pointsLength, pointsHeigth)
		this.path = path
		return path
	}
}

/**
 * Creates a cube representation with this location as center.
 */
fun Location.cube(
	width: Double,
	length: Double,
	heigth: Double,
	pointsWidth: Int,
	pointsLength: Int,
	pointsHeigth: Int,
) = Cube(this, width, length, heigth, pointsWidth, pointsLength, pointsHeigth)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy