2023-01-12 01:42:12 +00:00
|
|
|
using System;
|
2022-01-03 22:42:43 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
2023-01-12 01:42:12 +00:00
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
using System.IO.Compression;
|
|
|
|
using System.Text;
|
|
|
|
|
2022-01-03 22:42:43 +00:00
|
|
|
using UnityEngine;
|
2022-02-05 04:40:33 +00:00
|
|
|
using UnityEngine.Audio;
|
2022-01-03 22:42:43 +00:00
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
using Jukebox;
|
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
namespace HeavenStudio
|
2022-01-03 22:42:43 +00:00
|
|
|
{
|
2023-05-07 20:33:15 +00:00
|
|
|
public class GameInitializer : MonoBehaviour
|
2022-01-03 22:42:43 +00:00
|
|
|
{
|
2023-03-11 04:51:22 +00:00
|
|
|
[SerializeField] RenderTexture gameRenderTexture;
|
|
|
|
[SerializeField] RenderTexture overlayRenderTexture;
|
|
|
|
|
2023-05-07 20:33:15 +00:00
|
|
|
[SerializeField] HeavenStudio.Editor.Editor editorGO;
|
|
|
|
[SerializeField] String debug_cmdFile;
|
|
|
|
|
|
|
|
[SerializeField] GameManager gameManager;
|
|
|
|
|
|
|
|
[SerializeField] GameObject MainCamera;
|
|
|
|
[SerializeField] GameObject CursorCamera;
|
|
|
|
[SerializeField] GameObject OverlayCamera;
|
|
|
|
[SerializeField] GameObject StaticCamera;
|
|
|
|
[SerializeField] GameObject Cursor;
|
|
|
|
|
|
|
|
[SerializeField] GameObject Profiler;
|
|
|
|
|
2022-01-06 00:11:33 +00:00
|
|
|
public bool debugUI;
|
|
|
|
|
|
|
|
public bool playOnStart = false;
|
2023-05-07 20:33:15 +00:00
|
|
|
public bool fromCmd = false;
|
2022-01-03 22:42:43 +00:00
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
2023-01-12 01:42:12 +00:00
|
|
|
string input = "";
|
2023-05-07 20:33:15 +00:00
|
|
|
if (debug_cmdFile != string.Empty)
|
|
|
|
{
|
|
|
|
if (debug_cmdFile.IndexOfAny(Path.GetInvalidPathChars()) == -1)
|
2023-01-12 01:42:12 +00:00
|
|
|
{
|
2023-05-07 20:33:15 +00:00
|
|
|
if (File.Exists(debug_cmdFile))
|
2023-01-12 01:42:12 +00:00
|
|
|
{
|
2023-05-07 20:33:15 +00:00
|
|
|
input = debug_cmdFile;
|
|
|
|
fromCmd = true;
|
2023-01-12 01:42:12 +00:00
|
|
|
playOnStart = true;
|
|
|
|
}
|
|
|
|
}
|
2023-05-07 20:33:15 +00:00
|
|
|
}
|
2023-12-26 05:22:51 +00:00
|
|
|
else if (GlobalGameManager.PlayOpenFile is not null or "")
|
2023-05-07 20:33:15 +00:00
|
|
|
{
|
2023-12-26 05:22:51 +00:00
|
|
|
if (editorGO == null && GlobalGameManager.PlayOpenFile.IndexOfAny(Path.GetInvalidPathChars()) == -1)
|
2023-01-12 01:42:12 +00:00
|
|
|
{
|
2023-12-26 05:22:51 +00:00
|
|
|
if (File.Exists(GlobalGameManager.PlayOpenFile) && Path.GetExtension(GlobalGameManager.PlayOpenFile) == ".riq")
|
2023-05-07 20:33:15 +00:00
|
|
|
{
|
2023-12-26 05:22:51 +00:00
|
|
|
input = GlobalGameManager.PlayOpenFile;
|
2023-05-07 20:33:15 +00:00
|
|
|
fromCmd = true;
|
|
|
|
playOnStart = true;
|
|
|
|
}
|
2023-01-12 01:42:12 +00:00
|
|
|
}
|
2023-12-26 05:22:51 +00:00
|
|
|
GlobalGameManager.PlayOpenFile = null;
|
2023-01-12 01:42:12 +00:00
|
|
|
}
|
|
|
|
|
2022-01-03 22:42:43 +00:00
|
|
|
GameObject Games = new GameObject();
|
|
|
|
Games.name = "Games";
|
|
|
|
|
2023-12-26 05:22:51 +00:00
|
|
|
gameManager.playMode = playOnStart;
|
2022-01-03 22:42:43 +00:00
|
|
|
|
|
|
|
gameManager.GamesHolder = Games;
|
|
|
|
gameManager.CircleCursor = Cursor.transform.GetChild(0).GetComponent<CircleCursor>();
|
|
|
|
gameManager.GameCamera = MainCamera.GetComponent<Camera>();
|
|
|
|
gameManager.CursorCam = CursorCamera.GetComponent<Camera>();
|
2022-06-04 03:15:05 +00:00
|
|
|
gameManager.OverlayCamera = OverlayCamera.GetComponent<Camera>();
|
2023-03-11 04:51:22 +00:00
|
|
|
gameManager.StaticCamera = StaticCamera.GetComponent<Camera>();
|
2022-01-03 22:42:43 +00:00
|
|
|
|
2023-05-07 20:33:15 +00:00
|
|
|
if (!debugUI && Profiler != null)
|
2022-01-06 00:11:33 +00:00
|
|
|
{
|
|
|
|
Profiler.GetComponent<DebugUI>().enabled = false;
|
|
|
|
Profiler.transform.GetChild(0).gameObject.SetActive(false);
|
|
|
|
}
|
2022-01-03 22:42:43 +00:00
|
|
|
|
|
|
|
GameObject Conductor = new GameObject();
|
|
|
|
Conductor.name = "Conductor";
|
2022-01-15 22:52:53 +00:00
|
|
|
AudioSource source = Conductor.AddComponent<AudioSource>();
|
2022-01-03 22:42:43 +00:00
|
|
|
Conductor.AddComponent<Conductor>();
|
2022-01-15 22:52:53 +00:00
|
|
|
Conductor.GetComponent<Conductor>().musicSource = source;
|
2023-09-11 22:28:04 +00:00
|
|
|
source.priority = 255;
|
2022-02-05 04:40:33 +00:00
|
|
|
source.outputAudioMixerGroup = Settings.GetMusicMixer();
|
2022-01-07 11:36:23 +00:00
|
|
|
// Conductor.AddComponent<AudioDspTimeKeeper>();
|
2022-01-06 00:11:33 +00:00
|
|
|
|
2023-03-11 04:51:22 +00:00
|
|
|
GlobalGameManager.GameRenderTexture = gameRenderTexture;
|
|
|
|
GlobalGameManager.OverlayRenderTexture = overlayRenderTexture;
|
|
|
|
GlobalGameManager.ResetGameRenderTexture();
|
|
|
|
|
2023-05-07 20:33:15 +00:00
|
|
|
if (editorGO == null)
|
2022-01-15 22:52:53 +00:00
|
|
|
{
|
2023-06-10 19:13:29 +00:00
|
|
|
bool success = OpenCmdRemix(input);
|
|
|
|
gameManager.Init(success);
|
2022-01-15 22:52:53 +00:00
|
|
|
}
|
2023-05-07 20:33:15 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
editorGO.Init();
|
|
|
|
}
|
2022-01-03 22:42:43 +00:00
|
|
|
}
|
2023-01-12 01:42:12 +00:00
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
public bool OpenCmdRemix(string path)
|
2023-01-12 01:42:12 +00:00
|
|
|
{
|
2023-06-10 19:13:29 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
string tmpDir = RiqFileHandler.ExtractRiq(path);
|
|
|
|
Debug.Log("Imported RIQ successfully!");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
catch (System.Exception e)
|
2023-01-12 01:42:12 +00:00
|
|
|
{
|
2023-06-10 19:13:29 +00:00
|
|
|
Debug.Log($"Error importing RIQ: {e.Message}");
|
|
|
|
return false;
|
2023-01-12 01:42:12 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-03 22:42:43 +00:00
|
|
|
}
|
|
|
|
}
|