content: /*
      Copyright(C) 2025 Altom Consulting
  
      This program is free software: you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.
  
      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      GNU General Public License for more details.
  
      You should have received a copy of the GNU General Public License
      along with this program. If not, see <https://www.gnu.org/licenses/>.
  */
  
  package com.alttester.Commands.UnityCommand;
  
  import com.alttester.Utils;
  import com.alttester.IMessageHandler;
  import com.alttester.Commands.AltBaseCommand;
  import com.alttester.altTesterExceptions.WaitTimeOutException;
  
  public class AltWaitForCurrentSceneToBe extends AltBaseCommand {
      private AltWaitForCurrentSceneToBeParams params;
  
      public AltWaitForCurrentSceneToBe(IMessageHandler messageHandler,
              AltWaitForCurrentSceneToBeParams params) {
          super(messageHandler);
          this.params = params;
      }
  
      public void Execute() {
          double time = 0;
          String currentScene = "";
          while (time < params.getTimeout()) {
              logger.debug("Waiting for scene to be " + params.getSceneName() + "...");
              currentScene = new AltGetCurrentScene(messageHandler).Execute();
              if (currentScene != null && currentScene.equals(params.getSceneName())) {
                  return;
              }
              Utils.sleepFor(params.getInterval());
              time += params.getInterval();
          }
          throw new WaitTimeOutException("Scene [" + params.getSceneName()
                  + "] not loaded after " + params.getTimeout() + " seconds");
      }
  }
  