Prune code.
This commit is contained in:
@@ -50,16 +50,7 @@ namespace Cryville.Crtr.Components {
|
||||
static readonly ListPool<Vector2> _uvPool = new ListPool<Vector2>();
|
||||
static readonly ArrayPool<Vector2> _shapePool = new ArrayPool<Vector2>(0x100, 0x10000);
|
||||
|
||||
public PolygonSGO()
|
||||
: base() {
|
||||
/*
|
||||
SubmitProperty("head", new Property(typeof(string), () => head.frame, v => head.frame = (string)v));
|
||||
SubmitProperty("body", new Property(typeof(string), () => body.frame, v => body.frame = (string)v));
|
||||
SubmitProperty("tail", new Property(typeof(string), () => tail.frame, v => tail.frame = (string)v));
|
||||
SubmitProperty("transparent", new Property(typeof(bool), () => transparent, v => transparent = (bool)v));
|
||||
SubmitProperty("shape", new Property(typeof(Vector2[]), () => _shape, v => _shape = (Vector2[])v));
|
||||
*/
|
||||
|
||||
public PolygonSGO() {
|
||||
SubmitProperty("head", new PropOp.String(v => head.FrameName = v));
|
||||
SubmitProperty("body", new PropOp.String(v => body.FrameName = v));
|
||||
SubmitProperty("tail", new PropOp.String(v => tail.FrameName = v));
|
||||
@@ -146,17 +137,9 @@ namespace Cryville.Crtr.Components {
|
||||
lengths = _lPool.Rent();
|
||||
}
|
||||
|
||||
/*
|
||||
r = new Vector3(0, 0, 0);
|
||||
|
||||
Quaternion rotq = Quaternion.Euler(r);
|
||||
p = prevp + rotq * (p - prevpt);
|
||||
prevp = p;*/
|
||||
|
||||
for (int i = 0; i < _shapeLength; i++) {
|
||||
Vector2 sp = r * _shape[i];
|
||||
vertices.Add(p + (Vector3)sp);
|
||||
// uv.Add(new Vector2(i / (shape.Length - 1), vertCount));
|
||||
}
|
||||
|
||||
if (headGenerated) {
|
||||
|
@@ -1,54 +1,9 @@
|
||||
using Cryville.Common.Pdt;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr.Components {
|
||||
public abstract class SkinComponent : MonoBehaviour {
|
||||
#if false
|
||||
/// <summary>
|
||||
/// The properties of the component.
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public Dictionary<string, Property> Properties { get; private set; }
|
||||
/// <summary>
|
||||
/// Submits a property.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the property.</param>
|
||||
/// <param name="property">The property itself.</param>
|
||||
[Obsolete]
|
||||
protected void SubmitProperty(string name, Property property) {
|
||||
Properties.Add(name, property);
|
||||
}
|
||||
/// <summary>
|
||||
/// The property of a skin component.
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public struct Property {
|
||||
/// <summary>
|
||||
/// The type of the property.
|
||||
/// </summary>
|
||||
public readonly Type Type;
|
||||
/// <summary>
|
||||
/// The callback that gets the property value.
|
||||
/// </summary>
|
||||
public readonly Func<object> Get;
|
||||
/// <summary>
|
||||
/// The callback that sets the property value.
|
||||
/// </summary>
|
||||
public readonly Action<object> Set;
|
||||
/// <summary>
|
||||
/// Creates a property.
|
||||
/// </summary>
|
||||
/// <param name="type">The type of the property.</param>
|
||||
/// <param name="get">The callback that gets the property value.</param>
|
||||
/// <param name="set">The callback that sets the property value.</param>
|
||||
public Property(Type type, Func<object> get, Action<object> set) {
|
||||
Type = type; Get = get; Set = set;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// The property operators of the component.
|
||||
/// </summary>
|
||||
|
@@ -1,21 +1,9 @@
|
||||
using Cryville.Common.Pdt;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr.Components {
|
||||
public abstract class SpriteBase : SkinComponent {
|
||||
public SpriteBase()
|
||||
: base() {
|
||||
/*
|
||||
SubmitProperty("bound", new Property(typeof(BoundInfo), null, v => Bound = (BoundInfo)v));
|
||||
SubmitProperty("transparent", new Property(typeof(bool), () => transparent, v => transparent = (bool)v));
|
||||
SubmitProperty("pivot", new Property(typeof(Vector2), () => Pivot, v => Pivot = (Vector2)v));
|
||||
SubmitProperty("scale", new Property(typeof(Vector2), () => Scale, v => Scale = (Vector2)v));
|
||||
SubmitProperty("ui", new Property(typeof(bool), () => UI, v => UI = (bool)v));
|
||||
SubmitProperty("zindex", new Property(typeof(short), () => ZIndex, v => ZIndex = (short)v));
|
||||
*/
|
||||
|
||||
public SpriteBase() {
|
||||
SubmitProperty("bound", new op_set_bound(this));
|
||||
SubmitProperty("transparent", new PropOp.Boolean(v => transparent = v));
|
||||
SubmitProperty("pivot", new PropOp.Vector2(v => Pivot = v));
|
||||
@@ -87,28 +75,6 @@ namespace Cryville.Crtr.Components {
|
||||
get { return Vector2.zero; }
|
||||
}
|
||||
|
||||
#if false
|
||||
[Obsolete]
|
||||
public struct BoundInfo : IConstructable {
|
||||
public Vector2 Pivot;
|
||||
public Vector3 Position;
|
||||
public void Load(object data, IEvaluator etor) {
|
||||
var d = (IList)data;
|
||||
Pivot = (Vector2)etor.Cast(typeof(Vector2), d[0]);
|
||||
Position = (Vector3)etor.Cast(typeof(Vector3), d[1]);
|
||||
}
|
||||
}
|
||||
[Obsolete]
|
||||
public BoundInfo Bound {
|
||||
set {
|
||||
var r = Quaternion.Inverse(transform.rotation);
|
||||
var da = value.Pivot - Pivot;
|
||||
var dp = r * (value.Position - transform.localPosition);
|
||||
if (da.x != 0) _scale.x = dp.x / da.x;
|
||||
if (da.y != 0) _scale.y = dp.z / da.y;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
public void SetBound(Vector2 piv, Vector3 pos) {
|
||||
var r = Quaternion.Inverse(transform.rotation);
|
||||
var da = piv - Pivot;
|
||||
|
@@ -33,14 +33,7 @@ namespace Cryville.Crtr.Components {
|
||||
}
|
||||
|
||||
public class SpritePlane : SpriteBase {
|
||||
public SpritePlane()
|
||||
: base() {
|
||||
/*
|
||||
SubmitProperty("frame", new Property(typeof(string), () => Frame, v => Frame = (string)v));
|
||||
SubmitProperty("fit", new Property(typeof(FitMode), () => Fit, v => Fit = (FitMode)v));
|
||||
SubmitProperty("opacity", new Property(typeof(float), () => Opacity, v => Opacity = (float)v));
|
||||
*/
|
||||
|
||||
public SpritePlane() {
|
||||
SubmitProperty("frame", new PropOp.String(v => Frame = v));
|
||||
SubmitProperty("fit", new PropOp.Enum<FitMode>(v => Fit = v));
|
||||
SubmitProperty("opacity", new PropOp.Float(v => Opacity = v));
|
||||
|
@@ -1,14 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr.Components {
|
||||
public class SpriteRect : SpriteBase {
|
||||
public SpriteRect()
|
||||
: base() {
|
||||
/*
|
||||
SubmitProperty("color", new Property(typeof(Color), () => Color, v => Color = (Color)v));
|
||||
*/
|
||||
|
||||
public SpriteRect() {
|
||||
SubmitProperty("color", new PropOp.Color(v => Color = v));
|
||||
|
||||
transparent = true;
|
||||
|
@@ -4,12 +4,7 @@ using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr.Components {
|
||||
public class SpriteScale3 : SpritePlane {
|
||||
public SpriteScale3()
|
||||
: base() {
|
||||
/*
|
||||
SubmitProperty("border", new Property(typeof(Vector2), () => Border, v => Border = (Vector2)v));
|
||||
*/
|
||||
|
||||
public SpriteScale3() {
|
||||
SubmitProperty("border", new PropOp.Vector2(v => Border = v));
|
||||
}
|
||||
|
||||
|
@@ -1,22 +1,11 @@
|
||||
using Cryville.Common.Pdt;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr.Components {
|
||||
public class SpriteText : SpriteBase {
|
||||
public SpriteText() {
|
||||
/*
|
||||
SubmitProperty("frames", new Property(typeof(TextFrames), () => Frames, v => Frames = (TextFrames)v));
|
||||
SubmitProperty("value", new Property(typeof(string), () => Value, v => Value = (string)v));
|
||||
SubmitProperty("size", new Property(typeof(float), () => Size, v => Size = (float)v));
|
||||
SubmitProperty("spacing", new Property(typeof(float), () => Spacing, v => Spacing = (float)v));
|
||||
SubmitProperty("opacity", new Property(typeof(float), () => Opacity, v => Opacity = (float)v));
|
||||
*/
|
||||
|
||||
SubmitProperty("frames", new op_set_frames(this));
|
||||
SubmitProperty("value", new PropOp.String(v => Value = v));
|
||||
SubmitProperty("size", new PropOp.Float(v => Size = v));
|
||||
@@ -42,7 +31,7 @@ namespace Cryville.Crtr.Components {
|
||||
o += v.Length * sizeof(char) + sizeof(int);
|
||||
result.Add(keys[i], new SpriteInfo { FrameName = v });
|
||||
}
|
||||
_self.Frames = new TextFrames { Frames = result };
|
||||
_self.Frames = result;
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE1006
|
||||
@@ -53,19 +42,8 @@ namespace Cryville.Crtr.Components {
|
||||
}
|
||||
|
||||
readonly Dictionary<Texture2D, MeshWrapper> meshes = new Dictionary<Texture2D, MeshWrapper>();
|
||||
public struct TextFrames /*: IConstructable*/ {
|
||||
public Dictionary<char, SpriteInfo> Frames;
|
||||
/*public void Load(object data, IEvaluator etor) {
|
||||
var d = (IList)data;
|
||||
var keys = (string)d[0];
|
||||
var values = (List<object>)d[1];
|
||||
Frames = new Dictionary<char, SpriteInfo>(keys.Length);
|
||||
for (int i = 0; i < keys.Length; i++)
|
||||
Frames.Add(keys[i], new SpriteInfo() { FrameName = (string)values[i] });
|
||||
}*/
|
||||
}
|
||||
TextFrames m_frames;
|
||||
public TextFrames Frames {
|
||||
Dictionary<char, SpriteInfo> m_frames;
|
||||
public Dictionary<char, SpriteInfo> Frames {
|
||||
get { return m_frames; }
|
||||
set { m_frames = value; UpdateFrames(); UpdateScale(); }
|
||||
}
|
||||
@@ -102,7 +80,7 @@ namespace Cryville.Crtr.Components {
|
||||
float frameHeight = 0;
|
||||
foreach (var m in meshes) m.Value.Destroy();
|
||||
meshes.Clear();
|
||||
foreach (var f in m_frames.Frames) {
|
||||
foreach (var f in m_frames) {
|
||||
f.Value.Load();
|
||||
if (frameHeight == 0) frameHeight = f.Value.Rect.height;
|
||||
else if (frameHeight != f.Value.Rect.height) throw new Exception("Inconsistent frame height");
|
||||
@@ -128,7 +106,7 @@ namespace Cryville.Crtr.Components {
|
||||
uvs.Add(t, new List<Vector2>(vc));
|
||||
}
|
||||
foreach (var c in m_value) {
|
||||
var f = m_frames.Frames[c];
|
||||
var f = m_frames[c];
|
||||
var t = f.Frame.Texture;
|
||||
float w = f.Ratio * m_size;
|
||||
verts[t].Add(new Vector3(sum_x , 0, 0));
|
||||
|
Reference in New Issue
Block a user