43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using Simulator.Config;
|
|
using Simulator.Data;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UVC.Data;
|
|
using UVC.Network;
|
|
using UVC.UI.Commands;
|
|
|
|
namespace Simulator.Command
|
|
{
|
|
public class SimulatorStopCommand : ICommand
|
|
{
|
|
private object? _parameter;
|
|
|
|
public SimulatorStopCommand(object? parameter = null)
|
|
{
|
|
_parameter = parameter;
|
|
}
|
|
|
|
public void Execute(object? parameter = null)
|
|
{
|
|
ExecuteAsync().Forget();
|
|
}
|
|
|
|
private async UniTask ExecuteAsync()
|
|
{
|
|
try
|
|
{
|
|
var cdata = await HttpRequester.RequestPost<SimulatorCodeDataClass>($"{Constants.HTTP_DOMAIN}/simulation/histories/{SimulationConfig.insertedId}/stop", "", null, true);
|
|
PlayMenu.Instance.StopFunc();
|
|
PlayerPropertyDataBase.isPlaying = false;
|
|
DataRepository.Instance.MqttReceiver.Dispose();
|
|
SceneManager.LoadScene(0);
|
|
}
|
|
catch (System.Exception e)
|
|
{
|
|
Debug.LogError($"[SimulatorStopCommand] 시뮬레이션 정지 실패: {e.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|