Code cleanup.
This commit is contained in:
@@ -496,6 +496,7 @@ namespace Cryville.Crtr {
|
||||
if (tbus != null) { tbus.Dispose(); tbus = null; }
|
||||
if (bbus != null) { bbus.Dispose(); bbus = null; }
|
||||
if (cbus != null) { cbus.Dispose(); cbus.DisposeAll(); cbus = null; }
|
||||
etor = null;
|
||||
Logger.Log("main", 1, "Game", "Stopped");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
@@ -104,10 +104,11 @@ namespace Cryville.Crtr.Components {
|
||||
void UpdateMeshes() {
|
||||
if (meshes.Count == 0) return;
|
||||
sum_x = 0;
|
||||
foreach (var t in meshes.Keys) {
|
||||
verts[t].Clear();
|
||||
uvs[t].Clear();
|
||||
tris[t].Clear();
|
||||
foreach (var t in meshes) {
|
||||
var key = t.Key;
|
||||
verts[key].Clear();
|
||||
uvs[key].Clear();
|
||||
tris[key].Clear();
|
||||
}
|
||||
foreach (var c in m_value) {
|
||||
var f = m_frames[c];
|
||||
@@ -123,11 +124,12 @@ namespace Cryville.Crtr.Components {
|
||||
uvs[t].Add(f.Frame.GetUV(new Vector2(0, 1)));
|
||||
sum_x += w + m_spacing;
|
||||
}
|
||||
foreach (var t in meshes.Keys) {
|
||||
var m = meshes[t].Mesh;
|
||||
foreach (var t in meshes) {
|
||||
var key = t.Key;
|
||||
var m = meshes[key].Mesh;
|
||||
m.Clear();
|
||||
int cc = verts[t].Count / 4;
|
||||
var _tris = tris[t];
|
||||
int cc = verts[key].Count / 4;
|
||||
var _tris = tris[key];
|
||||
for (int i = 0; i < cc; i++) {
|
||||
_tris.Add(i * 4);
|
||||
_tris.Add(i * 4 + 3);
|
||||
@@ -136,9 +138,9 @@ namespace Cryville.Crtr.Components {
|
||||
_tris.Add(i * 4 + 3);
|
||||
_tris.Add(i * 4 + 2);
|
||||
}
|
||||
m.SetVertices(verts[t]);
|
||||
m.SetUVs(0, uvs[t]);
|
||||
m.SetTriangles(tris[t], 0);
|
||||
m.SetVertices(verts[key]);
|
||||
m.SetUVs(0, uvs[key]);
|
||||
m.SetTriangles(tris[key], 0);
|
||||
m.RecalculateNormals();
|
||||
}
|
||||
sum_x -= m_spacing;
|
||||
@@ -166,10 +168,10 @@ namespace Cryville.Crtr.Components {
|
||||
}
|
||||
void UpdateOpacity() {
|
||||
if (!mesh.Initialized) return;
|
||||
foreach (var m in meshes.Values) {
|
||||
var c = m.Renderer.material.color;
|
||||
foreach (var m in meshes) {
|
||||
var c = m.Value.Renderer.material.color;
|
||||
c.a = _opacity;
|
||||
m.Renderer.material.color = c;
|
||||
m.Value.Renderer.material.color = c;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -200,8 +200,8 @@ namespace Cryville.Crtr.Event {
|
||||
#endregion
|
||||
#region Anchor
|
||||
public virtual void Anchor() {
|
||||
foreach (var p in PropSrcs.Values) p.Invalidate();
|
||||
foreach (var a in DynamicAnchors.Keys) DynamicAnchorSetTime[a] = double.NaN;
|
||||
foreach (var p in PropSrcs) p.Value.Invalidate();
|
||||
foreach (var a in DynamicAnchors) DynamicAnchorSetTime[a.Key] = double.NaN;
|
||||
atime_head = cs.StampedContainer.Time;
|
||||
atime_tail = atime_head + cs.StampedContainer.Duration;
|
||||
MatchDynamic(cs, 0);
|
||||
@@ -217,7 +217,7 @@ namespace Cryville.Crtr.Event {
|
||||
else forced = false;
|
||||
PushAnchorEvent(t.Value, DynamicAnchors[t.Key], priority, forced);
|
||||
}
|
||||
foreach (var anchors in Anchors.Values) foreach (var anchor in anchors) anchor.Transform.gameObject.SetActive(false);
|
||||
foreach (var anchors in Anchors) foreach (var anchor in anchors.Value) anchor.Transform.gameObject.SetActive(false);
|
||||
}
|
||||
static readonly SimpleObjectPool<StampedEvent.Anchor> anchorEvPool
|
||||
= new SimpleObjectPool<StampedEvent.Anchor>(1024);
|
||||
|
@@ -434,14 +434,14 @@ namespace Cryville.Crtr.Event {
|
||||
|
||||
public void BroadcastPreInit() {
|
||||
Handler.PreInit();
|
||||
foreach (var c in Children.Values) {
|
||||
c.BroadcastPreInit();
|
||||
foreach (var c in Children) {
|
||||
c.Value.BroadcastPreInit();
|
||||
}
|
||||
}
|
||||
public void BroadcastPostInit() {
|
||||
Handler.PostInit();
|
||||
foreach (var c in Children.Values) {
|
||||
c.BroadcastPostInit();
|
||||
foreach (var c in Children) {
|
||||
c.Value.BroadcastPostInit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,8 +461,8 @@ namespace Cryville.Crtr.Event {
|
||||
|
||||
public void Anchor() {
|
||||
Handler.Anchor();
|
||||
foreach (var ls in Children.Values) {
|
||||
if (ls.Handler.Alive) ls.Anchor();
|
||||
foreach (var ls in Children) {
|
||||
if (ls.Value.Handler.Alive) ls.Value.Anchor();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@@ -63,8 +63,8 @@ namespace Cryville.Crtr.Event {
|
||||
s = RootState;
|
||||
}
|
||||
AddState(s);
|
||||
foreach (var c in s.Children.Values)
|
||||
Expand(c);
|
||||
foreach (var c in s.Children)
|
||||
Expand(c.Value);
|
||||
}
|
||||
|
||||
public void AddState(ContainerState s) {
|
||||
@@ -73,13 +73,13 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
|
||||
void AttachBus() {
|
||||
foreach (var s in states.Values)
|
||||
s.Bus = this;
|
||||
foreach (var s in states)
|
||||
s.Value.Bus = this;
|
||||
}
|
||||
|
||||
public void AttachSystems(PdtSkin skin, Judge judge) {
|
||||
foreach (var s in states.Values)
|
||||
s.AttachSystems(skin, judge);
|
||||
foreach (var s in states)
|
||||
s.Value.AttachSystems(skin, judge);
|
||||
}
|
||||
|
||||
List<StampedEvent.Temporary> tempEvents = new List<StampedEvent.Temporary>();
|
||||
|
@@ -164,8 +164,8 @@ namespace Cryville.Crtr {
|
||||
protected void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
Deactivate();
|
||||
foreach (var proxy in _tproxies.Values) {
|
||||
proxy.Source.Value.Handler.OnInput -= OnInput;
|
||||
foreach (var proxy in _tproxies) {
|
||||
proxy.Value.Source.Value.Handler.OnInput -= OnInput;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,13 +236,14 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
public void SyncTime(double time) {
|
||||
foreach (var s in _sproxies.Keys) {
|
||||
var h = s.Handler;
|
||||
foreach (var s in _sproxies) {
|
||||
var h = s.Key.Handler;
|
||||
_timeOrigins[h] = h.GetCurrentTimestamp() - time;
|
||||
}
|
||||
}
|
||||
public void ForceTick() {
|
||||
foreach (var src in _sproxies.Keys) {
|
||||
foreach (var s in _sproxies) {
|
||||
var src = s.Key;
|
||||
if (_activeCounts[src] == 0) {
|
||||
OnInput(new InputIdentifier { Source = src, Id = 0 }, new InputVector(_lockTime != null ? _lockTime.Value : src.Handler.GetCurrentTimestamp()));
|
||||
}
|
||||
@@ -250,7 +251,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
public double GetTimestampAverage() {
|
||||
double result = 0;
|
||||
foreach (var src in _sproxies.Keys) {
|
||||
foreach (var s in _sproxies) {
|
||||
var src = s.Key;
|
||||
result += src.Handler.GetCurrentTimestamp() - _timeOrigins[src.Handler];
|
||||
}
|
||||
return result / _sproxies.Count;
|
||||
|
@@ -42,11 +42,12 @@ namespace Cryville.Crtr {
|
||||
_numsrc3 = new PropSrc.Float(() => _numbuf3);
|
||||
_numsrc4 = new PropSrc.Float(() => _numbuf4);
|
||||
_rs.judges.TryGetValue(new Identifier(_var_pause), out _judgePause);
|
||||
foreach (var i in rs.inputs.Keys) {
|
||||
foreach (var i in rs.inputs) {
|
||||
var id = i.Key;
|
||||
var l = new List<JudgeEvent>();
|
||||
evs.Add(i, l);
|
||||
activeEvs.Add(i, new List<JudgeEvent>());
|
||||
if (_judgePause != null && i.Key == _var_pause) {
|
||||
evs.Add(id, l);
|
||||
activeEvs.Add(id, new List<JudgeEvent>());
|
||||
if (_judgePause != null && id.Key == _var_pause) {
|
||||
l.Add(new JudgeEvent {
|
||||
StartTime = double.NegativeInfinity, EndTime = double.PositiveInfinity,
|
||||
StartClip = double.NegativeInfinity, EndClip = double.PositiveInfinity,
|
||||
@@ -82,8 +83,9 @@ namespace Cryville.Crtr {
|
||||
#region Judge
|
||||
internal readonly Dictionary<int, int> judgeMap = new Dictionary<int, int>();
|
||||
void InitJudges() {
|
||||
foreach (var i in _rs.judges.Keys) {
|
||||
judgeMap.Add(i.Key, IdentifierManager.SharedInstance.Request("judge_" + i.Name));
|
||||
foreach (var i in _rs.judges) {
|
||||
var id = i.Key;
|
||||
judgeMap.Add(id.Key, IdentifierManager.SharedInstance.Request("judge_" + id.Name));
|
||||
}
|
||||
}
|
||||
static bool _flag;
|
||||
@@ -247,9 +249,10 @@ namespace Cryville.Crtr {
|
||||
public TargetString GetFullFormattedScoreString() {
|
||||
bool flag = false;
|
||||
scoreFullBuf.Clear();
|
||||
foreach (var s in scores.Keys) {
|
||||
scoreFullBuf.AppendFormat(flag ? "\n{0}: " : "{0}: ", (string)IdentifierManager.SharedInstance.Retrieve(s));
|
||||
scoreFullBuf.AppendFormat(scoreFormatCache[s], scores[s]);
|
||||
foreach (var s in scores) {
|
||||
var id = s.Key;
|
||||
scoreFullBuf.AppendFormat(flag ? "\n{0}: " : "{0}: ", (string)IdentifierManager.SharedInstance.Retrieve(id));
|
||||
scoreFullBuf.AppendFormat(scoreFormatCache[id], scores[id]);
|
||||
flag = true;
|
||||
}
|
||||
scoreFullStr.Length = scoreFullBuf.Count;
|
||||
|
@@ -58,7 +58,7 @@ namespace Cryville.Crtr {
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
sgos = gogroup.GetComponentsInChildren<SectionalGameObject>();
|
||||
foreach (var judge in judges.Values) judge.InitPropSrcs();
|
||||
foreach (var judge in judges) judge.Value.InitPropSrcs();
|
||||
}
|
||||
|
||||
public override void StartPhysicalUpdate(ContainerState s) {
|
||||
|
@@ -34,23 +34,26 @@ namespace Cryville.Crtr {
|
||||
public Dictionary<Identifier, ScoreDefinition> scores;
|
||||
public Constraint constraints;
|
||||
public void Optimize(PdtEvaluatorBase etor) {
|
||||
foreach (var i in inputs.Values) {
|
||||
if (i.pass != null) foreach (var e in i.pass.Values) {
|
||||
etor.Optimize(e);
|
||||
foreach (var i in inputs) {
|
||||
var input = i.Value;
|
||||
if (input.pass != null) foreach (var e in input.pass) {
|
||||
etor.Optimize(e.Value);
|
||||
}
|
||||
}
|
||||
foreach (var j in judges.Values) {
|
||||
if (j.hit != null) etor.Optimize(j.hit);
|
||||
if (j.scores != null) {
|
||||
foreach (var s in j.scores) {
|
||||
foreach (var j in judges) {
|
||||
var judge = j.Value;
|
||||
if (judge.hit != null) etor.Optimize(judge.hit);
|
||||
if (judge.scores != null) {
|
||||
foreach (var s in judge.scores) {
|
||||
if (s.Key.op != default(Identifier))
|
||||
etor.PatchCompound(s.Key.name.Key, s.Key.op.Key, s.Value);
|
||||
etor.Optimize(s.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var s in scores.Values) {
|
||||
if (s.value != null) etor.Optimize(s.value);
|
||||
foreach (var s in scores) {
|
||||
var score = s.Value;
|
||||
if (score.value != null) etor.Optimize(score.value);
|
||||
}
|
||||
constraints.Optimize(etor);
|
||||
}
|
||||
@@ -65,8 +68,8 @@ namespace Cryville.Crtr {
|
||||
[PropertyList]
|
||||
public Dictionary<PropertyKey, PdtExpression> Properties = new Dictionary<PropertyKey, PdtExpression>();
|
||||
public void Optimize(PdtEvaluatorBase etor) {
|
||||
foreach (var e in Properties.Values) {
|
||||
etor.Optimize(e);
|
||||
foreach (var e in Properties) {
|
||||
etor.Optimize(e.Value);
|
||||
}
|
||||
foreach (var e in Elements) {
|
||||
e.Key.Optimize(etor);
|
||||
|
@@ -53,10 +53,11 @@ namespace Cryville.Crtr {
|
||||
public SkinElement elements;
|
||||
|
||||
public void Optimize(PdtEvaluator etor) {
|
||||
foreach (var animation in animations.Values) {
|
||||
animation.Optimize(etor);
|
||||
foreach (var a in animations) {
|
||||
a.Value.Optimize(etor);
|
||||
}
|
||||
foreach (var effect in effects.Values) {
|
||||
foreach (var e in effects) {
|
||||
var effect = e.Value;
|
||||
etor.ContextCascadeInsert();
|
||||
if (effect.args != null) foreach (var i in effect.args) {
|
||||
etor.ContextCascadeUpdate(i.Key, PropSrc.Error);
|
||||
@@ -85,9 +86,9 @@ namespace Cryville.Crtr {
|
||||
|
||||
public void Optimize(PdtEvaluatorBase etor) {
|
||||
IsDynamic = true;
|
||||
foreach (var e in properties.Values) {
|
||||
etor.Optimize(e);
|
||||
if (!e.IsConstant)
|
||||
foreach (var e in properties) {
|
||||
etor.Optimize(e.Value);
|
||||
if (!e.Value.IsConstant)
|
||||
IsDynamic = true;
|
||||
}
|
||||
foreach (var e in elements) {
|
||||
@@ -115,11 +116,11 @@ namespace Cryville.Crtr {
|
||||
= new Dictionary<SkinPropertyKey, PdtExpression>();
|
||||
|
||||
public void Optimize(PdtEvaluator etor) {
|
||||
foreach (var p in properties.Values) {
|
||||
etor.Optimize(p);
|
||||
foreach (var p in properties) {
|
||||
etor.Optimize(p.Value);
|
||||
}
|
||||
foreach (var e in spans.Values) {
|
||||
e.Optimize(etor);
|
||||
foreach (var e in spans) {
|
||||
e.Value.Optimize(etor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user