-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
482 additions
and
435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/kotlin/io/github/addoncommunity/galactifun/api/objects/CelestialObject.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.github.addoncommunity.galactifun.api.objects | ||
|
||
import io.github.addoncommunity.galactifun.api.objects.properties.Orbit | ||
import io.github.addoncommunity.galactifun.units.Angle.Companion.degrees | ||
import io.github.addoncommunity.galactifun.units.Distance | ||
import io.github.addoncommunity.galactifun.units.Mass | ||
import io.github.addoncommunity.galactifun.util.Constants | ||
import io.github.addoncommunity.galactifun.util.LazyDouble | ||
import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack | ||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils | ||
import kotlinx.datetime.Instant | ||
import org.bukkit.inventory.ItemStack | ||
import kotlin.math.sqrt | ||
|
||
sealed class CelestialObject(name: String, baseItem: ItemStack) { | ||
|
||
val name = ChatUtils.removeColorCodes(name) | ||
val id = this.name.lowercase().replace(' ', '_') | ||
|
||
val item = CustomItemStack(baseItem, name) | ||
|
||
abstract fun distanceTo(other: CelestialObject, time: Instant): Distance | ||
|
||
|
||
|
||
abstract val mass: Mass | ||
abstract val radius: Distance | ||
|
||
val gravitationalParameter by LazyDouble { Constants.GRAVITATIONAL_CONSTANT * mass.kilograms } | ||
val escapeVelocity by LazyDouble { sqrt(2 * Constants.GRAVITATIONAL_CONSTANT * mass.kilograms / radius.kilometers) } | ||
val parkingOrbit: Orbit by lazy { | ||
Orbit( | ||
parent = this, | ||
semimajorAxis = radius * 1.1, | ||
eccentricity = 0.0, | ||
argumentOfPeriapsis = 0.0.degrees, | ||
timeOfPeriapsis = Instant.fromEpochMilliseconds(0) | ||
) | ||
} | ||
|
||
private val _orbiters = mutableListOf<CelestialObject>() | ||
val orbiters: List<CelestialObject> = _orbiters | ||
|
||
fun addOrbiter(orbiter: CelestialObject) { | ||
_orbiters.add(orbiter) | ||
} | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (other !is CelestialObject) return false | ||
return id == other.id | ||
} | ||
|
||
override fun hashCode(): Int = id.hashCode() | ||
} |
15 changes: 0 additions & 15 deletions
15
src/main/kotlin/io/github/addoncommunity/galactifun/api/objects/Galaxy.kt
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/io/github/addoncommunity/galactifun/api/objects/MilkyWay.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.github.addoncommunity.galactifun.api.objects | ||
|
||
object MilkyWay { | ||
|
||
private val _stars = mutableListOf<Star>() | ||
val stars: List<Star> get() = _stars | ||
|
||
fun addStar(star: Star) { | ||
_stars.add(star) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.