private void SpawnBall() { if (Logger.IsInfoEnabled) { Logger.Info("Spawning soccer ball."); } Transform trans = SpawnStrategy.GetSpawnpoint(); if (trans == null) { throw new InvalidOperationException($"Cannot spawn a ball from the {nameof(SoccerLobbyBallFactory)} from a null transform. Initialize the {nameof(ISpawnPointStrategy)} field."); } //Just spawn the ball for now CurrentTrackedBall = GameObjectFactory.Create(SoccerrBallPrefab, trans.position, trans.rotation); OnBallSpawned?.Invoke(CurrentTrackedBall); //TODO: Handle this cleaner once we have more accurate beat time scheduling double beatsTime = TimeService.CurrentBeatsTime; //Every 1 beat we should spawn the ball BeatEventQueue.RegisterOnNextBeat(SpawnBall); BeatEventQueue.RegisterEvent(((long)beatsTime) + Beat.CentiBeats(90), DespawnBall); }
private void Start() { //In the soccer lobby the client expects that //the ball will be summoned every beat. //it also expects that the ball we be unsummoned //15/10 centibeats before a new one spawns //On the next beat we want to register a repeating ball spawning BeatEventQueue.RegisterOnNextBeat(SpawnBall); }