Refactor SkinPropertyKey.
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Crtr.Components;
|
||||
using Cryville.Crtr.Event;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
@@ -38,14 +35,10 @@ namespace Cryville.Crtr {
|
||||
ChartPlayer.etor.ContextTransform = rc.Transform;
|
||||
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeInsert(rc.PropSrcs);
|
||||
foreach (var p in rel.properties) {
|
||||
if (p.Key.Name == 0)
|
||||
rc.Transform.gameObject.AddComponent(p.Key.Component);
|
||||
else {
|
||||
ChartPlayer.etor.Evaluate(GetPropOp(ctx.WriteTransform, p.Key).Operator, p.Value);
|
||||
if (!p.Value.IsConstant) dynprops.Add(
|
||||
new DynamicProperty { Context = ctx, Key = p.Key, Value = p.Value }
|
||||
);
|
||||
}
|
||||
p.Key.ExecuteStatic(state, ctx, p.Value);
|
||||
if (p.Key.IsValueRequired && !p.Value.IsConstant) dynprops.Add(
|
||||
new DynamicProperty { Context = ctx, Key = p.Key, Value = p.Value }
|
||||
);
|
||||
}
|
||||
ChartPlayer.etor.ContextTransform = null;
|
||||
foreach (var r in rel.elements) {
|
||||
@@ -73,12 +66,7 @@ namespace Cryville.Crtr {
|
||||
ChartPlayer.etor.ContextEvent = state.Container;
|
||||
for (int i = 0; i < dynprops.Count; i++) {
|
||||
DynamicProperty p = dynprops[i];
|
||||
var psrcs = p.Context.ReadContext.PropSrcs;
|
||||
if (psrcs != null) ChartPlayer.etor.ContextCascadeInsert(psrcs);
|
||||
var prop = GetPropOp(p.Context.WriteTransform, p.Key);
|
||||
if (state.CloneType > prop.UpdateCloneType) continue;
|
||||
ChartPlayer.etor.Evaluate(prop.Operator, p.Value);
|
||||
if (psrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
||||
p.Key.ExecuteDynamic(state, p.Context, p.Value);
|
||||
}
|
||||
for (int i = 0; i < dynelems.Count; i++) {
|
||||
DynamicElement e = dynelems[i];
|
||||
@@ -99,11 +87,7 @@ namespace Cryville.Crtr {
|
||||
ChartPlayer.etor.ContextTransform = rc.Transform;
|
||||
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeInsert(rc.PropSrcs);
|
||||
foreach (var p in rel.properties) {
|
||||
if (p.Key.Name == 0)
|
||||
throw new InvalidOperationException("Component creation in dynamic context is not allowed");
|
||||
var prop = GetPropOp(ctx.WriteTransform, p.Key);
|
||||
if (state.CloneType > prop.UpdateCloneType) continue;
|
||||
ChartPlayer.etor.Evaluate(prop.Operator, p.Value);
|
||||
p.Key.ExecuteDynamic(state, ctx, p.Value);
|
||||
}
|
||||
ChartPlayer.etor.ContextTransform = null;
|
||||
foreach (var r in rel.elements) {
|
||||
@@ -115,21 +99,6 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
||||
}
|
||||
SkinProperty GetPropOp(Transform obj, SkinPropertyKey key) {
|
||||
var ctype = key.Component;
|
||||
var comp = (SkinComponent)obj.GetComponent(ctype);
|
||||
if (comp == null) throw new InvalidOperationException(string.Format(
|
||||
"Trying to set property {0} but the component is not found",
|
||||
IdentifierManager.SharedInstance.Retrieve(key.Name)
|
||||
));
|
||||
SkinProperty result;
|
||||
if (!comp.Properties.TryGetValue(key.Name, out result))
|
||||
throw new ArgumentException(string.Format(
|
||||
"Property {0} not found on component",
|
||||
IdentifierManager.SharedInstance.Retrieve(key.Name)
|
||||
));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class SkinContext {
|
||||
public Transform Transform { get; private set; }
|
||||
|
Reference in New Issue
Block a user