refactor: Update Unity to 2022.3.62
This commit is contained in:
@@ -97,12 +97,12 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
void OnDestroy() {
|
||||
if (cbus != null) cbus.Dispose();
|
||||
if (bbus != null) bbus.Dispose();
|
||||
if (tbus != null) tbus.Dispose();
|
||||
if (nbus != null) nbus.Dispose();
|
||||
if (loadThread != null) loadThread.Abort();
|
||||
if (inputProxy != null) inputProxy.Dispose();
|
||||
cbus?.Dispose();
|
||||
bbus?.Dispose();
|
||||
tbus?.Dispose();
|
||||
nbus?.Dispose();
|
||||
loadThread?.Abort();
|
||||
inputProxy?.Dispose();
|
||||
if (texs != null) foreach (var t in texs) Texture.Destroy(t.Value);
|
||||
Game.MainLogger.RemoveListener(loggerListener);
|
||||
loggerListener.Dispose();
|
||||
@@ -200,24 +200,22 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
readonly TargetString statusstr = new TargetString();
|
||||
readonly StringBuffer statusbuf = new StringBuffer();
|
||||
readonly TargetString logsstr = new TargetString();
|
||||
readonly StringBuffer logsbuf = new StringBuffer();
|
||||
readonly List<string> logEntries = new List<string>();
|
||||
readonly StringBuffer statusbuf = new();
|
||||
readonly StringBuffer logsbuf = new();
|
||||
readonly List<string> logEntries = new();
|
||||
readonly ArrayPool<char> logBufferPool = new();
|
||||
int logsLength = 0;
|
||||
LogHandler d_addLogEntry;
|
||||
void AddLogEntry(int level, string module, string msg) {
|
||||
string color;
|
||||
switch (level) {
|
||||
case 0: color = "#888888"; break;
|
||||
case 1: color = "#bbbbbb"; break;
|
||||
case 2: color = "#0088ff"; break;
|
||||
case 3: color = "#ffff00"; break;
|
||||
case 4: color = "#ff0000"; break;
|
||||
case 5: color = "#bb0000"; break;
|
||||
default: color = "#ff00ff"; break;
|
||||
}
|
||||
string color = level switch {
|
||||
0 => "#888888",
|
||||
1 => "#bbbbbb",
|
||||
2 => "#0088ff",
|
||||
3 => "#ffff00",
|
||||
4 => "#ff0000",
|
||||
5 => "#bb0000",
|
||||
_ => "#ff00ff",
|
||||
};
|
||||
var l = string.Format(
|
||||
"\n<color={1}bb><{2}> {3}</color>",
|
||||
DateTime.UtcNow.ToString("s"), color, module, msg
|
||||
@@ -235,10 +233,10 @@ namespace Cryville.Crtr {
|
||||
foreach (var l in logEntries) {
|
||||
logsbuf.Append(l);
|
||||
}
|
||||
logsstr.Length = logsbuf.Count;
|
||||
var larr = logsstr.TrustedAsArray();
|
||||
logsbuf.CopyTo(0, larr, 0, logsbuf.Count);
|
||||
logs.SetText(larr, 0, logsbuf.Count);
|
||||
var lbuf = logBufferPool.Rent(logsbuf.Count);
|
||||
logsbuf.CopyTo(0, lbuf, 0, logsbuf.Count);
|
||||
logs.SetText(lbuf, 0, logsbuf.Count);
|
||||
logBufferPool.Return(lbuf);
|
||||
|
||||
statusbuf.Clear();
|
||||
statusbuf.AppendFormat(
|
||||
@@ -286,14 +284,15 @@ namespace Cryville.Crtr {
|
||||
);
|
||||
if (judge != null) {
|
||||
statusbuf.Append("\n== Scores ==\n");
|
||||
var fullScoreStr = judge.GetFullFormattedScoreString();
|
||||
statusbuf.Append(fullScoreStr.TrustedAsArray(), 0, fullScoreStr.Length);
|
||||
var fullScoreStrLen = judge.GetFullFormattedScoreString(logBufferPool, out char[] fullScoreStr);
|
||||
statusbuf.Append(fullScoreStr, 0, fullScoreStrLen);
|
||||
logBufferPool.Return(fullScoreStr);
|
||||
}
|
||||
}
|
||||
statusstr.Length = statusbuf.Count;
|
||||
var sarr = statusstr.TrustedAsArray();
|
||||
statusbuf.CopyTo(0, sarr, 0, statusbuf.Count);
|
||||
status.SetText(sarr, 0, statusbuf.Count);
|
||||
var buf = logBufferPool.Rent(statusbuf.Count);
|
||||
statusbuf.CopyTo(0, buf, 0, statusbuf.Count);
|
||||
status.SetText(buf, 0, statusbuf.Count);
|
||||
logBufferPool.Return(buf);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -386,8 +385,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
var hitPlane = new Plane(Vector3.forward, Vector3.zero);
|
||||
var r0 = Camera.main.ViewportPointToRay(new Vector3(0, 0, 1));
|
||||
float dist;
|
||||
hitPlane.Raycast(r0, out dist);
|
||||
hitPlane.Raycast(r0, out float dist);
|
||||
var p0 = r0.GetPoint(dist);
|
||||
var r1 = Camera.main.ViewportPointToRay(new Vector3(1, 1, 1));
|
||||
hitPlane.Raycast(r1, out dist);
|
||||
@@ -397,18 +395,18 @@ namespace Cryville.Crtr {
|
||||
screenSize = new Vector2(Screen.width, Screen.height);
|
||||
frustumPlanes = GeometryUtility.CalculateFrustumPlanes(Camera.main);
|
||||
|
||||
FileInfo chartFile = new FileInfo(Settings.Default.LoadChart);
|
||||
FileInfo chartFile = new(Settings.Default.LoadChart);
|
||||
|
||||
FileInfo rulesetFile = new FileInfo(Path.Combine(
|
||||
FileInfo rulesetFile = new(Path.Combine(
|
||||
Game.GameDataPath, "rulesets", Settings.Default.LoadRuleset
|
||||
));
|
||||
if (!rulesetFile.Exists) throw new FileNotFoundException("Ruleset for the chart not found\nMake sure you have imported the ruleset");
|
||||
|
||||
FileInfo rulesetConfigFile = new FileInfo(Path.Combine(
|
||||
FileInfo rulesetConfigFile = new(Path.Combine(
|
||||
Game.GameDataPath, "config", "rulesets", Settings.Default.LoadRulesetConfig
|
||||
));
|
||||
if (!rulesetConfigFile.Exists) throw new FileNotFoundException("Ruleset config not found\nPlease open the config to generate");
|
||||
using (StreamReader cfgreader = new StreamReader(rulesetConfigFile.FullName, Encoding.UTF8)) {
|
||||
using (StreamReader cfgreader = new(rulesetConfigFile.FullName, Encoding.UTF8)) {
|
||||
_rscfg = JsonConvert.DeserializeObject<RulesetConfig>(cfgreader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
});
|
||||
@@ -416,11 +414,11 @@ namespace Cryville.Crtr {
|
||||
sv = _rscfg.generic.ScrollVelocity;
|
||||
soundOffset += _rscfg.generic.SoundOffset;
|
||||
|
||||
FileInfo skinFile = new FileInfo(Path.Combine(
|
||||
FileInfo skinFile = new(Path.Combine(
|
||||
Game.GameDataPath, "skins", rulesetFile.Directory.Name, _rscfg.generic.Skin, ".umgs"
|
||||
));
|
||||
if (!skinFile.Exists) throw new FileNotFoundException("Skin not found\nPlease specify an available skin in the config");
|
||||
using (StreamReader reader = new StreamReader(skinFile.FullName, Encoding.UTF8)) {
|
||||
using (StreamReader reader = new(skinFile.FullName, Encoding.UTF8)) {
|
||||
skin = JsonConvert.DeserializeObject<SkinDefinition>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
});
|
||||
@@ -446,7 +444,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
IEnumerator<float> LoadTextures(List<string> queue) {
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
Stopwatch stopwatch = new();
|
||||
stopwatch.Start();
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
DownloadHandlerTexture texHandler = null;
|
||||
@@ -499,7 +497,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
IEnumerator<float> Prehandle() {
|
||||
Stopwatch timer = new Stopwatch();
|
||||
Stopwatch timer = new();
|
||||
timer.Reset(); timer.Start();
|
||||
Game.MainLogger.Log(0, "Load/Prehandle", "Prehandling (iteration 2)"); yield return 0;
|
||||
cbus.BroadcastPreInit();
|
||||
@@ -618,73 +616,72 @@ namespace Cryville.Crtr {
|
||||
{ new Identifier("track") , new MotionRegistry(typeof(Vec1)) },
|
||||
};
|
||||
|
||||
using (StreamReader reader = new StreamReader(info.chartFile.FullName, Encoding.UTF8)) {
|
||||
PdtEvaluator.Instance.Reset();
|
||||
using StreamReader reader = new(info.chartFile.FullName, Encoding.UTF8);
|
||||
PdtEvaluator.Instance.Reset();
|
||||
|
||||
LoadRuleset(info.rulesetFile); loadPregress = .05f;
|
||||
LoadRuleset(info.rulesetFile); loadPregress = .05f;
|
||||
|
||||
chart = JsonConvert.DeserializeObject<Chart>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
});
|
||||
chart = JsonConvert.DeserializeObject<Chart>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
});
|
||||
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Applying ruleset (iteration 1)"); loadPregress = .10f;
|
||||
pruleset.PrePatch(chart);
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Applying ruleset (iteration 1)"); loadPregress = .10f;
|
||||
pruleset.PrePatch(chart);
|
||||
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Batching events"); loadPregress = .20f;
|
||||
var batcher = new EventBatcher(chart);
|
||||
batcher.Forward();
|
||||
cbus = batcher.Batch(); loadPregress = .30f;
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Batching events"); loadPregress = .20f;
|
||||
var batcher = new EventBatcher(chart);
|
||||
batcher.Forward();
|
||||
cbus = batcher.Batch(); loadPregress = .30f;
|
||||
|
||||
LoadSkin(info.skinFile);
|
||||
LoadSkin(info.skinFile);
|
||||
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Initializing judge and input"); loadPregress = .35f;
|
||||
judge = new Judge(this, pruleset);
|
||||
PdtEvaluator.Instance.ContextJudge = judge;
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Initializing judge and input"); loadPregress = .35f;
|
||||
judge = new Judge(this, pruleset);
|
||||
PdtEvaluator.Instance.ContextJudge = judge;
|
||||
|
||||
inputProxy = new InputProxy(pruleset, judge, screenSize);
|
||||
inputProxy.LoadFrom(_rscfg.inputs);
|
||||
if (!inputProxy.IsCompleted()) {
|
||||
Game.MainLogger.Log(2, "Game", "Input config not completed. Input disabled");
|
||||
inputProxy.Clear();
|
||||
}
|
||||
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Attaching handlers"); loadPregress = .40f;
|
||||
var ch = new ChartHandler(chart);
|
||||
cbus.RootState.AttachHandler(ch);
|
||||
foreach (var gs in cbus.RootState.Children) {
|
||||
var gh = new GroupHandler((Chart.Group)gs.Key, ch);
|
||||
gs.Value.AttachHandler(gh);
|
||||
foreach (var ts in gs.Value.Children) {
|
||||
ContainerHandler th;
|
||||
if (ts.Key is Chart.Note) {
|
||||
th = new NoteHandler((Chart.Note)ts.Key, gh);
|
||||
}
|
||||
else {
|
||||
th = new TrackHandler((Chart.Track)ts.Key, gh);
|
||||
}
|
||||
ts.Value.AttachHandler(th);
|
||||
}
|
||||
}
|
||||
cbus.AttachSystems(pskin, judge);
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Prehandling (iteration 1)"); loadPregress = .60f;
|
||||
using (var pbus = cbus.Clone(16)) {
|
||||
pbus.Forward();
|
||||
}
|
||||
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Cloning states (type 1)"); loadPregress = .70f;
|
||||
bbus = cbus.Clone(1, -clippingDist);
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Cloning states (type 2)"); loadPregress = .80f;
|
||||
tbus = bbus.Clone(2);
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Cloning states (type 3)"); loadPregress = .90f;
|
||||
nbus = bbus.Clone(3);
|
||||
loadPregress = 1;
|
||||
inputProxy = new InputProxy(pruleset, judge, screenSize);
|
||||
inputProxy.LoadFrom(_rscfg.inputs);
|
||||
if (!inputProxy.IsCompleted()) {
|
||||
Game.MainLogger.Log(2, "Game", "Input config not completed. Input disabled");
|
||||
inputProxy.Clear();
|
||||
}
|
||||
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Attaching handlers"); loadPregress = .40f;
|
||||
var ch = new ChartHandler(chart);
|
||||
cbus.RootState.AttachHandler(ch);
|
||||
foreach (var gs in cbus.RootState.Children) {
|
||||
var gh = new GroupHandler((Chart.Group)gs.Key, ch);
|
||||
gs.Value.AttachHandler(gh);
|
||||
foreach (var ts in gs.Value.Children) {
|
||||
ContainerHandler th;
|
||||
if (ts.Key is Chart.Note) {
|
||||
th = new NoteHandler((Chart.Note)ts.Key, gh);
|
||||
}
|
||||
else {
|
||||
th = new TrackHandler((Chart.Track)ts.Key, gh);
|
||||
}
|
||||
ts.Value.AttachHandler(th);
|
||||
}
|
||||
}
|
||||
cbus.AttachSystems(pskin, judge);
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Prehandling (iteration 1)"); loadPregress = .60f;
|
||||
using (var pbus = cbus.Clone(16)) {
|
||||
pbus.Forward();
|
||||
}
|
||||
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Cloning states (type 1)"); loadPregress = .70f;
|
||||
bbus = cbus.Clone(1, -clippingDist);
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Cloning states (type 2)"); loadPregress = .80f;
|
||||
tbus = bbus.Clone(2);
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Cloning states (type 3)"); loadPregress = .90f;
|
||||
nbus = bbus.Clone(3);
|
||||
loadPregress = 1;
|
||||
}
|
||||
|
||||
void LoadRuleset(FileInfo file) {
|
||||
DirectoryInfo dir = file.Directory;
|
||||
Game.MainLogger.Log(0, "Load/WorkerThread", "Loading ruleset: {0}", file);
|
||||
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
||||
using (StreamReader reader = new(file.FullName, Encoding.UTF8)) {
|
||||
ruleset = JsonConvert.DeserializeObject<RulesetDefinition>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user