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

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

@file:UseContextualSerialization(Location::class)

package walkmc.shape

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

/**
 * Represents a quadrilateral util class. This can be used to draw/display particles in a quadrilateral.
 */
@Serializable
data class Quadrilateral(
	var center: Location,
	var width: Double,
	var length: Double,
	var pointsWidth: Int,
	var pointsLength: 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.generateQuadPath(width, length, pointsWidth, pointsLength)
		this.path = path
		return path
	}
}

/**
 * Creates a quadrilateral representation with this location as center.
 */
fun Location.quad(
	width: Double,
	length: Double,
	pointsWidth: Int,
	pointsLength: Int,
) = Quadrilateral(this, width, length, pointsWidth, pointsLength)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy