Skip to content

Commit

Permalink
#588 Fixed ball spawn delay.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shynixn committed Dec 19, 2024
1 parent 297ae95 commit b40049e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class SoccerBallSettings {
val soundEffects: MutableMap<BallActionType, SoundMeta> = HashMap()

/** Spawning delay. */
var delayInTicks: Int = 0
var delayInTicks: Int = 60

/** Spawnpoint of the ball. */
var spawnpoint: Vector3d? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,14 +796,13 @@ abstract class SoccerGameImpl(
* Teleports all players and ball back to their spawnpoint if [game] has got back teleport enabled.
*/
private fun relocatePlayersAndBall() {
respawnBall()

if (!arena.meta.customizingMeta.backTeleport) {
respawnBall()
return
}

val tickDelay = 20 * arena.meta.customizingMeta.backTeleportDelay

respawnBall(tickDelay)
plugin.launch {
delay(tickDelay.ticks)
var redTeamSpawnpoint = arena.meta.redTeamMeta.spawnpoint
Expand Down Expand Up @@ -934,8 +933,13 @@ abstract class SoccerGameImpl(
return
}

if (ball != null) {
ball!!.remove()
ball = null
}

ballSpawning = true
ballSpawnCounter = delayInTicks / 20
ballSpawnCounter = delayInTicks
}

fun getTeamMetaFromTeam(team: Team): TeamMeta {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ class SoccerHubGameImpl(

// Handle SoccerBall.
this.fixBallPositionSpawn()
if (ticks >= 20) {
this.handleBallSpawning()
}

this.handleBallSpawning()
// TODO: Minigame essentials. Update signs and protections.
super.handleMiniGameEssentials(ticks)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,7 @@ open class SoccerMiniGameImpl constructor(

// Handle SoccerBall.
this.fixBallPositionSpawn()
if (ticks >= 20) {
this.handleBallSpawning()
}

this.handleBallSpawning()
// Update signs and protections.
super.handleMiniGameEssentials(ticks)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,7 @@ class SoccerRefereeGameImpl constructor(

// Handle SoccerBall.
this.fixBallPositionSpawn()
if (ticks >= 20) {
this.handleBallSpawning()
}

this.handleBallSpawning()
// Update signs and protections.
super.handleMiniGameEssentials(ticks)
}
Expand Down

0 comments on commit b40049e

Please sign in to comment.