Optimize performance for skin component properties.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Pdt;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -7,21 +8,21 @@ namespace Cryville.Crtr.Components {
|
||||
/// <summary>
|
||||
/// The property operators of the component.
|
||||
/// </summary>
|
||||
public Dictionary<string, SkinProperty> Properties { get; private set; }
|
||||
public Dictionary<int, SkinProperty> Properties { get; private set; }
|
||||
/// <summary>
|
||||
/// Submits a property.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the property.</param>
|
||||
/// <param name="property">The property.</param>
|
||||
protected void SubmitProperty(string name, PdtOperator property, int uct = 1) {
|
||||
Properties.Add(name, new SkinProperty(property, uct));
|
||||
Properties.Add(IdentifierManager.SharedInstance.Request(name), new SkinProperty(property, uct));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a skin component.
|
||||
/// </summary>
|
||||
protected SkinComponent() {
|
||||
Properties = new Dictionary<string, SkinProperty>();
|
||||
Properties = new Dictionary<int, SkinProperty>();
|
||||
}
|
||||
|
||||
public virtual void Init() { }
|
||||
|
@@ -69,7 +69,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
public struct SkinPropertyKey {
|
||||
public Type Component;
|
||||
public string Name;
|
||||
public int Name;
|
||||
}
|
||||
public class SkinElementBinder : EmptyBinder {
|
||||
public override object ChangeType(object value, Type type, CultureInfo culture) {
|
||||
@@ -81,9 +81,9 @@ namespace Cryville.Crtr {
|
||||
if (key[0] == '*')
|
||||
return new SkinPropertyKey { Component = GetComponentByName(key.Substring(1)) };
|
||||
else
|
||||
return new SkinPropertyKey { Component = typeof(TransformInterface), Name = key };
|
||||
return new SkinPropertyKey { Component = typeof(TransformInterface), Name = IdentifierManager.SharedInstance.Request(key) };
|
||||
case 2:
|
||||
return new SkinPropertyKey { Component = GetComponentByName(cp[0]), Name = cp[1] };
|
||||
return new SkinPropertyKey { Component = GetComponentByName(cp[0]), Name = IdentifierManager.SharedInstance.Request(cp[1]) };
|
||||
}
|
||||
}
|
||||
return base.ChangeType(value, type, culture);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Crtr.Components;
|
||||
using Cryville.Crtr.Event;
|
||||
using System;
|
||||
@@ -35,7 +35,7 @@ namespace Cryville.Crtr {
|
||||
void MatchStatic(SkinElement rel, ContainerState context, Transform anchor = null) {
|
||||
ChartPlayer.etor.ContextTransform = anchor;
|
||||
foreach (var p in rel.properties) {
|
||||
if (p.Key.Name == null)
|
||||
if (p.Key.Name == 0)
|
||||
anchor.gameObject.AddComponent(p.Key.Component);
|
||||
else {
|
||||
ChartPlayer.etor.Evaluate(GetPropOp(anchor, p.Key).Operator, p.Value);
|
||||
@@ -82,7 +82,7 @@ namespace Cryville.Crtr {
|
||||
void MatchDynamic(SkinElement rel, ContainerState context, Transform anchor = null) {
|
||||
ChartPlayer.etor.ContextTransform = anchor;
|
||||
foreach (var p in rel.properties) {
|
||||
if (p.Key.Name == null)
|
||||
if (p.Key.Name == 0)
|
||||
throw new InvalidOperationException("Component creation in dynamic context is not allowed");
|
||||
var prop = GetPropOp(anchor, p.Key);
|
||||
if (context.CloneType > prop.UpdateCloneType) continue;
|
||||
|
Reference in New Issue
Block a user