Reconstruct skin container. Add update clone type limit to skin property.
This commit is contained in:
@@ -4,6 +4,7 @@ using Cryville.Crtr.Event;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
@@ -34,7 +35,15 @@ namespace Cryville.Crtr {
|
||||
selectors[i].Optimize(etor);
|
||||
}
|
||||
}
|
||||
public Transform MatchStatic(ContainerState h, Transform anchor = null) {
|
||||
public bool IsStatic {
|
||||
get {
|
||||
foreach (var s in selectors) {
|
||||
if (!s.IsStatic) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public Transform MatchStatic(ContainerState h, Transform anchor) {
|
||||
foreach (var s in selectors) {
|
||||
anchor = s.Match(h, anchor);
|
||||
if (anchor == null) return null;
|
||||
@@ -46,10 +55,9 @@ namespace Cryville.Crtr {
|
||||
if (!s.IsUpdatable(h)) return false;
|
||||
return true;
|
||||
}
|
||||
public Transform MatchDynamic(ContainerState h, SkinElement e, Transform old_target, Transform anchor = null) {
|
||||
if (!e.IsDynamic) return null;
|
||||
public Transform MatchDynamic(ContainerState h, Transform anchor) {
|
||||
foreach (var s in selectors) {
|
||||
anchor = s.Match(h, anchor, old_target);
|
||||
anchor = s.Match(h, anchor, true);
|
||||
if (anchor == null) return null;
|
||||
}
|
||||
return anchor;
|
||||
@@ -62,7 +70,7 @@ namespace Cryville.Crtr {
|
||||
get;
|
||||
}
|
||||
public virtual void Optimize(PdtEvaluatorBase etor) { }
|
||||
public abstract Transform Match(ContainerState h, Transform a, Transform ot = null);
|
||||
public abstract Transform Match(ContainerState h, Transform a, bool dyn = false);
|
||||
public virtual bool IsUpdatable(ContainerState h) {
|
||||
return true;
|
||||
}
|
||||
@@ -71,12 +79,9 @@ namespace Cryville.Crtr {
|
||||
public override bool IsStatic {
|
||||
get { return true; }
|
||||
}
|
||||
public override Transform Match(ContainerState h, Transform a, Transform ot = null) {
|
||||
if (ot != null)
|
||||
return ot;
|
||||
var obj = new GameObject {
|
||||
name = "__obj__"
|
||||
};
|
||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
||||
if (dyn) throw new InvalidOperationException("Object creation in dynamic context is not allowed");
|
||||
var obj = new GameObject("__obj__");
|
||||
obj.transform.SetParent(a, false);
|
||||
obj.AddComponent<TransformInterface>();
|
||||
return obj.transform;
|
||||
@@ -91,7 +96,7 @@ namespace Cryville.Crtr {
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override Transform Match(ContainerState h, Transform a, Transform ot = null) {
|
||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
||||
return h.Handler.Anchors[Name].Transform;
|
||||
}
|
||||
public override bool IsUpdatable(ContainerState h) {
|
||||
@@ -110,13 +115,20 @@ namespace Cryville.Crtr {
|
||||
etor.Optimize(_exp);
|
||||
}
|
||||
public override bool IsStatic {
|
||||
get { throw new NotImplementedException(); }
|
||||
get { return _exp.IsConstant; }
|
||||
}
|
||||
public override Transform Match(ContainerState h, Transform a, Transform ot = null) {
|
||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
||||
ChartPlayer.etor.ContextTransform = a;
|
||||
ChartPlayer.etor.Evaluate(_op, _exp);
|
||||
ChartPlayer.etor.ContextTransform = null;
|
||||
return _flag ? a : null;
|
||||
try {
|
||||
ChartPlayer.etor.Evaluate(_op, _exp);
|
||||
return _flag ? a : null;
|
||||
}
|
||||
catch (Exception) {
|
||||
throw new SelectorNotStaticException();
|
||||
}
|
||||
finally {
|
||||
ChartPlayer.etor.ContextTransform = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class State : SkinSelector {
|
||||
@@ -124,7 +136,7 @@ namespace Cryville.Crtr {
|
||||
public override bool IsStatic {
|
||||
get { return false; }
|
||||
}
|
||||
public override Transform Match(ContainerState h, Transform a, Transform ot = null) {
|
||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
||||
return null; // TODO
|
||||
}
|
||||
}
|
||||
@@ -134,9 +146,15 @@ namespace Cryville.Crtr {
|
||||
public override bool IsStatic {
|
||||
get { return true; }
|
||||
}
|
||||
public override Transform Match(ContainerState h, Transform a, Transform ot = null) {
|
||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
||||
return h.Handler.TypeName == _type ? a : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class SelectorNotStaticException : Exception {
|
||||
public SelectorNotStaticException() : base("The selector is not static") { }
|
||||
public SelectorNotStaticException(string message) : base(message) { }
|
||||
public SelectorNotStaticException(string message, Exception innerException) : base(message, innerException) { }
|
||||
protected SelectorNotStaticException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user