Prune code.

This commit is contained in:
2022-09-30 18:19:19 +08:00
parent e8e36b83bd
commit cd4ea557c3
41 changed files with 22 additions and 3592 deletions

View File

@@ -1,12 +1,9 @@
using Cryville.Common;
using Cryville.Common.Pdt;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Security.AccessControl;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.UIElements;
namespace Cryville.Crtr {
public enum TransitionType : byte {
@@ -142,143 +139,6 @@ namespace Cryville.Crtr {
}
}
/*[JsonConverter(typeof(MotionValueConverter))]
public class MotionValue {
public MotionValue(Type type, int length) {
// if (!type.IsValueType) throw new ArgumentException();
Inherit = Inheritance.Inherit;
Method = InheritMethod.Addition;
values = new IVector[length];
for (int i = 0; i < length; i++) {
values[i] = (IVector)type.GetConstructor(new Type[]{}).Invoke(new object[]{});
_rel.Add(false);
}
valueType = type;
}
public MotionValue Clone() {
var r = (MotionValue)this.MemberwiseClone();
var len = Length;
var mvs = new IVector[len];
for (int i = 0; i < len; i++) {
var mv = values[i];
if (mv == null) mvs[i] = null;
else mvs[i] = mv.Clone();
}
r.values = mvs;
return r;
}
public MotionValue(string str) {
Inherit = Inheritance.Inherit;
Method = InheritMethod.Addition;
var m = Regex.Match(str, @"^([io]?)(p?)(h?)(.*)$");
switch (m.Groups[1].Value) {
case "i": Inherit = Inheritance.Inherit; break;
case "o": Inherit = Inheritance.Override; break;
}
// TODO Handle p and h modifiers
var vstr = m.Groups[4].Value;
var vs = vstr.Split(',');
if (vstr.Contains("w") || vstr.Contains("h")) valueType = typeof(Vec2);
else valueType = typeof(Vec1);
var len = vs.Length;
values = new IVector[len];
for (int i = 0; i < len; i++) {
var v = vs[i];
var m2 = Regex.Match(v, @"^\s*(\+?)\s*(.*?)\s*$");
_rel.Add(m2.Groups[1].Value != "");
if (m2.Groups[2].Value.Trim() == "") {
values[i] = null;
}
else if (valueType == typeof(Vec2)) {
Vector2 r = Vector2.zero;
var vs2 = m2.Groups[2].Value.Split('+');
foreach (var s in vs2) {
var s2 = s.Trim();
float n = float.Parse(s2.Substring(0, s2.Length - 1));
if (s2.EndsWith("w")) {
r.x += n;
}
else if (s2.EndsWith("h")) {
r.y += n;
}
}
values[i] = new Vec2(r);
}
else if (valueType == typeof(Vec1)) {
values[i] = new Vec1(float.Parse(v));
}
}
}
public Inheritance Inherit = Inheritance.Unset;
public InheritMethod Method = InheritMethod.Addition;
public readonly Type valueType;
List<bool> _rel = new List<bool>();
public IVector[] values;
/*public List<IVector> NonnullValues {
get {
var r = new List<IVector>();
foreach (var v in values) {
}
}
}*
public int Length { get { return values.Length; } }
public void Apply(MotionValue v) {
if (v.valueType != this.valueType) throw new ArgumentException();
if (v.Length != this.Length) throw new ArgumentException();
if (this.Inherit == Inheritance.Unset) this.Inherit = v.Inherit;
for (int i = 0; i < Length; i++) {
if (this.values[i] == null) continue;
if (v._rel[i]) {
this.values[i].Add(v.values[i]);
}
// else this.values[i] = v.values[i];
}
}
public void ApplyInheritance(MotionValue v) {
if (v.valueType != this.valueType) throw new ArgumentException();
if (v.Length != this.Length) throw new ArgumentException();
if (this.Inherit == Inheritance.Override) return;
for (int i = 0; i < Length; i++) {
if (Method == InheritMethod.Multiplication){
this.values[i].Multiply(((Vec1)v.values[i]).Value);
if (((Vec1)v.values[i]).Value < 1)
return;
}
else this.values[i].Add(v.values[i]);
}
}
}*/
/*public enum Inheritance {
Unset = 0, Inherit = 1, Override = 2
}
public enum InheritMethod {
Addition = 0, Multiplication = 1
}*/
/*public class MotionValueConverter : JsonConverter {
public override bool CanConvert(Type objectType) {
return objectType == typeof(string);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
return new MotionValue((string)reader.Value);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
throw new NotImplementedException();
}
}*/
public struct MotionName : IEquatable<MotionName> {
public string MainName { get; private set; }
public string SubName { get; private set; }