Code cleanup.
This commit is contained in:
@@ -107,8 +107,14 @@ namespace Cryville.Crtr {
|
||||
bool firstFrame;
|
||||
double atime0;
|
||||
void Update() {
|
||||
// if (Input.GetKeyDown(KeyCode.Return)) TogglePlay();
|
||||
if (started) {
|
||||
if (started) GameUpdate();
|
||||
#if !NO_THREAD
|
||||
else if (loadThread != null) LoadUpdate();
|
||||
#endif
|
||||
if (logEnabled) LogUpdate();
|
||||
else Game.MainLogger.Enumerate((level, module, msg) => { });
|
||||
}
|
||||
void GameUpdate() {
|
||||
try {
|
||||
if (Screen.width != screenSize.x || Screen.height != screenSize.y)
|
||||
throw new InvalidOperationException("Window resized while playing");
|
||||
@@ -144,8 +150,7 @@ namespace Cryville.Crtr {
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
#if !NO_THREAD
|
||||
else if (loadThread != null) {
|
||||
void LoadUpdate() {
|
||||
if (texLoader != null) {
|
||||
string url = texLoader.url;
|
||||
string name = StringUtils.TrimExt(url.Substring(url.LastIndexOfAny(new char[] {'/', '\\'}) + 1));
|
||||
@@ -203,8 +208,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (logEnabled) {
|
||||
string timetext = string.Empty;
|
||||
void LogUpdate() {
|
||||
string _logs = logs.text;
|
||||
Game.MainLogger.Enumerate((level, module, msg) => {
|
||||
string color;
|
||||
@@ -239,19 +244,19 @@ namespace Cryville.Crtr {
|
||||
UnityEngine.Profiling.Profiler.GetTotalReservedMemory()
|
||||
#endif
|
||||
);
|
||||
if (started) sttext += string.Format(
|
||||
sttext += timetext;
|
||||
if (judge != null) sttext += "\n== Scores ==\n" + judge.GetFullFormattedScoreString();
|
||||
status.text = sttext;
|
||||
}
|
||||
void OnCameraPostRender(Camera cam) {
|
||||
if (started) timetext = string.Format(
|
||||
"\nSTime: {0:R}\nATime: {1:R}\nITime: {2:R}",
|
||||
cbus.Time,
|
||||
Game.AudioClient.Position - atime0,
|
||||
inputProxy.GetTimestampAverage()
|
||||
);
|
||||
if (judge != null) sttext += "\n== Scores ==\n" + judge.GetFullFormattedScoreString();
|
||||
status.text = sttext;
|
||||
else timetext = string.Empty;
|
||||
}
|
||||
else {
|
||||
Game.MainLogger.Enumerate((level, module, msg) => { });
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Triggers
|
||||
@@ -309,6 +314,8 @@ namespace Cryville.Crtr {
|
||||
Game.NetworkTaskWorker.SuspendBackgroundTasks();
|
||||
Game.AudioSession = Game.AudioSequencer.NewSession();
|
||||
|
||||
Camera.onPostRender += OnCameraPostRender;
|
||||
|
||||
var hitPlane = new Plane(Vector3.forward, Vector3.zero);
|
||||
var r0 = Camera.main.ViewportPointToRay(new Vector3(0, 0, 1));
|
||||
float dist;
|
||||
@@ -430,6 +437,7 @@ namespace Cryville.Crtr {
|
||||
if (nbus != null) nbus.Dispose();
|
||||
inputProxy.Deactivate();
|
||||
foreach (var t in texs) Texture.Destroy(t.Value);
|
||||
Camera.onPostRender -= OnCameraPostRender;
|
||||
Logger.Log("main", 1, "Game", "Stopped");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
Reference in New Issue
Block a user