Update formatting
This commit is contained in:
@@ -10,6 +10,7 @@ import org.bukkit.entity.EntityType
|
||||
|
||||
private fun circleEdgeLocations(radius: Number) = HashSet<SimpleLocation2D>().apply {
|
||||
val currentRadius = radius.toDouble()
|
||||
|
||||
var d = -currentRadius
|
||||
var x = currentRadius
|
||||
var y = 0
|
||||
@@ -40,6 +41,7 @@ private fun MutableSet<SimpleLocation2D>.addSimpleLoc2D(first: Number, second: N
|
||||
|
||||
abstract class Circle(val radius: Number) {
|
||||
protected abstract val data: StructureData
|
||||
|
||||
val fillLocations by lazy {
|
||||
var currentRadius = radius.toDouble()
|
||||
|
||||
@@ -66,8 +68,10 @@ abstract class Circle(val radius: Number) {
|
||||
val edgeLocations by lazy {
|
||||
circleEdgeLocations(radius)
|
||||
}
|
||||
|
||||
val filledStructure by lazy { structure(true) }
|
||||
val edgeStructure by lazy { structure(false) }
|
||||
|
||||
fun structure(filled: Boolean) = Structure(
|
||||
HashSet<SingleStructureData>().apply {
|
||||
val locations = if (filled) fillLocations else edgeLocations
|
||||
@@ -87,4 +91,4 @@ class ParticleCircle(radius: Number, particle: KSpigotParticle) : Circle(radius)
|
||||
|
||||
class EntityCircle(radius: Number, entityType: EntityType) : Circle(radius) {
|
||||
override val data = StructureDataEntity(entityType)
|
||||
}
|
||||
}
|
||||
|
@@ -28,9 +28,6 @@ data class Structure(
|
||||
constructor(vararg structureDataSets: Set<SingleStructureData>)
|
||||
: this(structureDataSets.flatMapTo(HashSet()) { it })
|
||||
}
|
||||
/*
|
||||
* Structure data implementations.
|
||||
*/
|
||||
|
||||
data class StructureDataMaterial(
|
||||
val material: Material,
|
||||
@@ -73,4 +70,4 @@ data class StructureDataParticle(
|
||||
override fun createAt(loc: Location) {
|
||||
particle.spawnAt(loc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -33,4 +33,4 @@ inline fun Structure.rotate(angle: Number, vectorRotation: (Vector, Double) -> V
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
|
@@ -30,8 +30,7 @@ fun LocationArea.loadStructure(includeBlocks: Boolean = true, includeEntities: B
|
||||
* Sorted by their coordinates.
|
||||
*/
|
||||
val LocationArea.fillBlocks: Set<Block>
|
||||
get()
|
||||
= LinkedHashSet<Block>().apply {
|
||||
get() = LinkedHashSet<Block>().apply {
|
||||
(minLoc.blockX until maxLoc.blockX + 1).forEach { x ->
|
||||
(minLoc.blockY until maxLoc.blockY + 1).forEach { y ->
|
||||
(minLoc.blockZ until maxLoc.blockZ + 1).forEach { z ->
|
||||
@@ -45,12 +44,11 @@ val LocationArea.fillBlocks: Set<Block>
|
||||
* @return All entities in the given [LocationArea].
|
||||
*/
|
||||
val LocationArea.entities: Set<Entity>
|
||||
get()
|
||||
= HashSet<Entity>().apply {
|
||||
get() = HashSet<Entity>().apply {
|
||||
touchedChunks.forEach {
|
||||
it.entities.forEach { en ->
|
||||
if (simpleLocationPair.isInArea(en.location))
|
||||
this += en
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user