Pull up ISkinnableGroup.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Crtr.Components;
|
||||
using Cryville.Crtr.Event;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -37,21 +36,21 @@ namespace Cryville.Crtr {
|
||||
selectors[i].Optimize(etor);
|
||||
}
|
||||
}
|
||||
public IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext ctx) {
|
||||
public IEnumerable<SkinContext> MatchStatic(ISkinnableGroup g, SkinContext ctx) {
|
||||
IEnumerable<SkinContext> result = new SkinContext[] { ctx };
|
||||
foreach (var s in selectors) {
|
||||
result = result.SelectMany(l => s.MatchStatic(h, l));
|
||||
result = result.SelectMany(l => s.MatchStatic(g, l));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public bool IsUpdatable(ContainerState h) {
|
||||
public bool IsUpdatable(ISkinnableGroup g) {
|
||||
foreach (var s in selectors)
|
||||
if (!s.IsUpdatable(h)) return false;
|
||||
if (!s.IsUpdatable(g)) return false;
|
||||
return true;
|
||||
}
|
||||
public SkinContext MatchDynamic(ContainerState h, SkinContext ctx) {
|
||||
public SkinContext MatchDynamic(ISkinnableGroup g, SkinContext ctx) {
|
||||
foreach (var s in selectors) {
|
||||
ctx = s.MatchDynamic(h, ctx);
|
||||
ctx = s.MatchDynamic(g, ctx);
|
||||
if (ctx == null) return null;
|
||||
}
|
||||
return ctx;
|
||||
@@ -63,16 +62,16 @@ namespace Cryville.Crtr {
|
||||
public abstract override string ToString();
|
||||
|
||||
public virtual void Optimize(PdtEvaluatorBase etor) { }
|
||||
public virtual IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) { throw new SelectorNotAvailableException(); }
|
||||
public virtual SkinContext MatchDynamic(ContainerState h, SkinContext c) { throw new SelectorNotAvailableException(); }
|
||||
public virtual bool IsUpdatable(ContainerState h) {
|
||||
public virtual IEnumerable<SkinContext> MatchStatic(ISkinnableGroup g, SkinContext c) { throw new SelectorNotAvailableException(); }
|
||||
public virtual SkinContext MatchDynamic(ISkinnableGroup g, SkinContext c) { throw new SelectorNotAvailableException(); }
|
||||
public virtual bool IsUpdatable(ISkinnableGroup g) {
|
||||
return true;
|
||||
}
|
||||
public class CreateObject : SkinSelector {
|
||||
public CreateObject() { }
|
||||
public override string ToString() { return "$"; }
|
||||
|
||||
public override IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) {
|
||||
public override IEnumerable<SkinContext> MatchStatic(ISkinnableGroup g, SkinContext c) {
|
||||
var obj = new GameObject("__obj__");
|
||||
obj.transform.SetParent(c.Transform, false);
|
||||
obj.AddComponent<TransformInterface>();
|
||||
@@ -86,9 +85,9 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
public override string ToString() { return string.Format(".{0}", IdentifierManager.SharedInstance.Retrieve(Name)); }
|
||||
|
||||
public override IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) {
|
||||
List<CAnchor> anchors;
|
||||
if (h.Handler.Anchors.TryGetValue(Name, out anchors)) {
|
||||
public override IEnumerable<SkinContext> MatchStatic(ISkinnableGroup g, SkinContext c) {
|
||||
IReadOnlyCollection<CAnchor> anchors;
|
||||
if (g.TryGetAnchorsByName(Name, out anchors)) {
|
||||
return anchors.Select(a => a.SkinContext);
|
||||
}
|
||||
else return Enumerable.Empty<SkinContext>();
|
||||
@@ -101,11 +100,11 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
public override string ToString() { return string.Format("..{0}", IdentifierManager.SharedInstance.Retrieve(Name)); }
|
||||
|
||||
public override SkinContext MatchDynamic(ContainerState h, SkinContext c) {
|
||||
return h.Handler.OpenedAnchor != null && h.Handler.OpenedAnchor.Name == Name ? c : null;
|
||||
public override SkinContext MatchDynamic(ISkinnableGroup g, SkinContext c) {
|
||||
return g.OpenedAnchor != null && g.OpenedAnchor.Name == Name ? c : null;
|
||||
}
|
||||
public override bool IsUpdatable(ContainerState h) {
|
||||
return h.CloneType >= 2;
|
||||
public override bool IsUpdatable(ISkinnableGroup g) {
|
||||
return g.DynamicLevel >= 1;
|
||||
}
|
||||
}
|
||||
public class Property : SkinSelector {
|
||||
@@ -121,12 +120,12 @@ namespace Cryville.Crtr {
|
||||
public override void Optimize(PdtEvaluatorBase etor) {
|
||||
etor.Optimize(_exp);
|
||||
}
|
||||
public override IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) {
|
||||
public override IEnumerable<SkinContext> MatchStatic(ISkinnableGroup g, SkinContext c) {
|
||||
var result = Match(c);
|
||||
if (result != null) return new SkinContext[] { result };
|
||||
else return Enumerable.Empty<SkinContext>();
|
||||
}
|
||||
public override SkinContext MatchDynamic(ContainerState h, SkinContext c) {
|
||||
public override SkinContext MatchDynamic(ISkinnableGroup g, SkinContext c) {
|
||||
return Match(c);
|
||||
}
|
||||
public SkinContext Match(SkinContext a) {
|
||||
@@ -148,8 +147,8 @@ namespace Cryville.Crtr {
|
||||
public ElementType(string type) { _type = type; }
|
||||
public override string ToString() { return _type; }
|
||||
|
||||
public override IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) {
|
||||
return h.Handler.TypeName == _type ? new SkinContext[] { c } : Enumerable.Empty<SkinContext>();
|
||||
public override IEnumerable<SkinContext> MatchStatic(ISkinnableGroup g, SkinContext c) {
|
||||
return g.TypeName == _type ? new SkinContext[] { c } : Enumerable.Empty<SkinContext>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user