Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
3ecf3b4bfc | |||
1da8647ff1 | |||
2f19e8daad | |||
07f62c7aeb | |||
39db8dfa45 | |||
f04cd370f1 | |||
5c4acd54ce | |||
82dbc5c479 | |||
1f1663d714 | |||
a3c5392caa | |||
6c983cc2cb | |||
3bf3fdac3d | |||
f2f3dba098 | |||
3728360dd2 | |||
887837bb3d | |||
99b4c2dfc1 | |||
e59769158a | |||
ba3238614b | |||
a115999aab | |||
393947db9f | |||
e9b2a7f894 | |||
9c73455761 |
@@ -6,6 +6,7 @@ using System.ComponentModel;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using UnsafeIL;
|
||||||
|
|
||||||
namespace Cryville.Crtr {
|
namespace Cryville.Crtr {
|
||||||
[JsonConverter(typeof(BeatTimeConverter))]
|
[JsonConverter(typeof(BeatTimeConverter))]
|
||||||
@@ -154,6 +155,10 @@ namespace Cryville.Crtr {
|
|||||||
protected ChartEvent() {
|
protected ChartEvent() {
|
||||||
PropSrcs = new Dictionary<int, PropSrc>();
|
PropSrcs = new Dictionary<int, PropSrc>();
|
||||||
PropOps = new Dictionary<int, PropOp>();
|
PropOps = new Dictionary<int, PropOp>();
|
||||||
|
SubmitPropSrc("event", new PropSrc.Float(() => {
|
||||||
|
int hash = GetHashCode();
|
||||||
|
return Unsafe.As<int, float>(ref hash);
|
||||||
|
}));
|
||||||
SubmitPropSrc("long", new PropSrc.Boolean(() => IsLong));
|
SubmitPropSrc("long", new PropSrc.Boolean(() => IsLong));
|
||||||
SubmitPropSrc("time", new PropSrc.BeatTime(() => time.Value));
|
SubmitPropSrc("time", new PropSrc.BeatTime(() => time.Value));
|
||||||
SubmitPropSrc("endtime", new PropSrc.BeatTime(() => endtime.Value));
|
SubmitPropSrc("endtime", new PropSrc.BeatTime(() => endtime.Value));
|
||||||
@@ -320,7 +325,7 @@ namespace Cryville.Crtr {
|
|||||||
else {
|
else {
|
||||||
AbsoluteValue = Vector.Construct(registry.Type, m.Groups[11].Value);
|
AbsoluteValue = Vector.Construct(registry.Type, m.Groups[11].Value);
|
||||||
}
|
}
|
||||||
SubmitPropSrc("value", VectorSrc.Construct(() => {
|
SubmitPropSrc("value", new VectorSrc(() => {
|
||||||
if (RelativeNode != null) return RelativeNode.Value;
|
if (RelativeNode != null) return RelativeNode.Value;
|
||||||
else return AbsoluteValue;
|
else return AbsoluteValue;
|
||||||
}));
|
}));
|
||||||
|
@@ -175,16 +175,21 @@ namespace Cryville.Crtr {
|
|||||||
string url = texLoader.url;
|
string url = texLoader.url;
|
||||||
string name = StringUtils.TrimExt(url.Substring(url.LastIndexOfAny(new char[] {'/', '\\'}) + 1));
|
string name = StringUtils.TrimExt(url.Substring(url.LastIndexOfAny(new char[] {'/', '\\'}) + 1));
|
||||||
#if UNITY_5_4_OR_NEWER
|
#if UNITY_5_4_OR_NEWER
|
||||||
if (texHandler.isDone) {
|
if (texLoader.isDone) {
|
||||||
var tex = texHandler.texture;
|
if (texHandler.isDone) {
|
||||||
tex.wrapMode = TextureWrapMode.Clamp;
|
var tex = texHandler.texture;
|
||||||
if (frames.ContainsKey(name)) {
|
tex.wrapMode = TextureWrapMode.Clamp;
|
||||||
Logger.Log("main", 3, "Load/Prehandle", "Duplicated texture name: {0}", name);
|
if (frames.ContainsKey(name)) {
|
||||||
|
Logger.Log("main", 3, "Load/Prehandle", "Duplicated texture name: {0}", name);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
frames.Add(name, new SpriteFrame(tex));
|
||||||
|
}
|
||||||
|
texs.Add(name, tex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
frames.Add(name, new SpriteFrame(tex));
|
Logger.Log("main", 4, "Load/Prehandle", "Unable to load texture: {0}", name);
|
||||||
}
|
}
|
||||||
texs.Add(name, tex);
|
|
||||||
texLoader.Dispose();
|
texLoader.Dispose();
|
||||||
texHandler.Dispose();
|
texHandler.Dispose();
|
||||||
texLoader = null;
|
texLoader = null;
|
||||||
@@ -468,6 +473,8 @@ namespace Cryville.Crtr {
|
|||||||
Logger.Log("main", 0, "Load/Prehandle", "Cleaning up");
|
Logger.Log("main", 0, "Load/Prehandle", "Cleaning up");
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
if (disableGC) GarbageCollector.GCMode = GarbageCollector.Mode.Disabled;
|
if (disableGC) GarbageCollector.GCMode = GarbageCollector.Mode.Disabled;
|
||||||
|
cbus.ForwardByTime(startOffset);
|
||||||
|
bbus.ForwardByTime(startOffset);
|
||||||
timer.Stop();
|
timer.Stop();
|
||||||
Logger.Log("main", 1, "Load/Prehandle", "Prehandling done ({0}ms)", timer.Elapsed.TotalMilliseconds);
|
Logger.Log("main", 1, "Load/Prehandle", "Prehandling done ({0}ms)", timer.Elapsed.TotalMilliseconds);
|
||||||
if (Settings.Default.ClearLogOnPlay) {
|
if (Settings.Default.ClearLogOnPlay) {
|
||||||
|
@@ -4,6 +4,12 @@ using UnityEngine;
|
|||||||
namespace Cryville.Crtr.Components {
|
namespace Cryville.Crtr.Components {
|
||||||
public abstract class MeshBase : SkinComponent {
|
public abstract class MeshBase : SkinComponent {
|
||||||
public MeshBase() {
|
public MeshBase() {
|
||||||
|
SubmitProperty("color", new PropOp.Color(v => Color = v));
|
||||||
|
SubmitProperty("opacity", new PropOp.Float(v => {
|
||||||
|
var c = Color;
|
||||||
|
c.a *= v;
|
||||||
|
Color = c;
|
||||||
|
}));
|
||||||
SubmitProperty("zindex", new PropOp.Integer(v => ZIndex = (short)v));
|
SubmitProperty("zindex", new PropOp.Integer(v => ZIndex = (short)v));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,12 +34,32 @@ namespace Cryville.Crtr.Components {
|
|||||||
mat.renderQueue = _zindex;
|
mat.renderQueue = _zindex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color _color = Color.white;
|
||||||
|
public Color Color {
|
||||||
|
get { return _color; }
|
||||||
|
set {
|
||||||
|
_color = value;
|
||||||
|
UpdateColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected void UpdateColor() {
|
||||||
|
if (!mesh.Initialized) return;
|
||||||
|
foreach (var mat in materials) {
|
||||||
|
mat.color = _color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnDestroy() {
|
protected override void OnDestroy() {
|
||||||
if (materials != null)
|
DestroyMaterials();
|
||||||
foreach (var mat in materials) {
|
|
||||||
Material.Destroy(mat);
|
|
||||||
}
|
|
||||||
mesh.Destroy();
|
mesh.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void DestroyMaterials() {
|
||||||
|
if (materials == null) return;
|
||||||
|
foreach (var mat in materials) {
|
||||||
|
Material.Destroy(mat);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -107,7 +107,7 @@ namespace Cryville.Crtr.Components {
|
|||||||
base.Init();
|
base.Init();
|
||||||
mesh.Init(transform);
|
mesh.Init(transform);
|
||||||
|
|
||||||
mesh.Renderer.materials = materials = new Material[] {
|
mesh.Renderer.sharedMaterials = materials = new Material[] {
|
||||||
MeshWrapper.NewMaterial(),
|
MeshWrapper.NewMaterial(),
|
||||||
MeshWrapper.NewMaterial(),
|
MeshWrapper.NewMaterial(),
|
||||||
MeshWrapper.NewMaterial(),
|
MeshWrapper.NewMaterial(),
|
||||||
|
@@ -88,8 +88,9 @@ namespace Cryville.Crtr.Components {
|
|||||||
|
|
||||||
protected void InternalInit(string meshName = "quad") {
|
protected void InternalInit(string meshName = "quad") {
|
||||||
mesh.Init(transform);
|
mesh.Init(transform);
|
||||||
mesh.Renderer.materials = materials = new Material[] { MeshWrapper.NewMaterial() };
|
mesh.Renderer.sharedMaterials = materials = new Material[] { MeshWrapper.NewMaterial() };
|
||||||
mesh.Mesh = GenericResources.Meshes[meshName];
|
mesh.Mesh = GenericResources.Meshes[meshName];
|
||||||
|
UpdateColor();
|
||||||
UpdateScale();
|
UpdateScale();
|
||||||
UpdateZIndex();
|
UpdateZIndex();
|
||||||
}
|
}
|
||||||
|
@@ -60,7 +60,7 @@ namespace Cryville.Crtr.Components {
|
|||||||
SubmitProperty("frames", new PropOp.StringArray(v => Frames = v));
|
SubmitProperty("frames", new PropOp.StringArray(v => Frames = v));
|
||||||
SubmitProperty("index", new PropOp.Integer(v => Index = v));
|
SubmitProperty("index", new PropOp.Integer(v => Index = v));
|
||||||
SubmitProperty("fit", new PropOp.Enum<FitMode>(v => Fit = v, v => (FitMode)v));
|
SubmitProperty("fit", new PropOp.Enum<FitMode>(v => Fit = v, v => (FitMode)v));
|
||||||
SubmitProperty("opacity", new PropOp.Float(v => Opacity = v));
|
SubmitProperty("shader", new PropOp.String(v => Shader = v));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector2[] _origuv;
|
static Vector2[] _origuv;
|
||||||
@@ -122,9 +122,21 @@ namespace Cryville.Crtr.Components {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mesh.Renderer.enabled = true;
|
mesh.Renderer.enabled = true;
|
||||||
mesh.Renderer.material.mainTexture = frame.Frame.Texture;
|
mesh.Renderer.sharedMaterial.mainTexture = frame.Frame.Texture;
|
||||||
UpdateUV();
|
UpdateUV();
|
||||||
UpdateScale();
|
UpdateScale();
|
||||||
|
}
|
||||||
|
Shader m_shader;
|
||||||
|
public string Shader {
|
||||||
|
set {
|
||||||
|
m_shader = GenericResources.Shaders[value];
|
||||||
|
UpdateShader();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void UpdateShader() {
|
||||||
|
if (!mesh.Initialized) return;
|
||||||
|
if (m_shader == null) m_shader = GenericResources.Shaders["default"];
|
||||||
|
mesh.Renderer.sharedMaterial.shader = m_shader;
|
||||||
UpdateZIndex();
|
UpdateZIndex();
|
||||||
}
|
}
|
||||||
readonly Vector2[] _uvs = new Vector2[4];
|
readonly Vector2[] _uvs = new Vector2[4];
|
||||||
@@ -138,21 +150,6 @@ namespace Cryville.Crtr.Components {
|
|||||||
mesh.Mesh.uv = _uvs;
|
mesh.Mesh.uv = _uvs;
|
||||||
}
|
}
|
||||||
|
|
||||||
float _opacity = 1;
|
|
||||||
public float Opacity {
|
|
||||||
get { return _opacity; }
|
|
||||||
set {
|
|
||||||
_opacity = value;
|
|
||||||
UpdateOpacity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected void UpdateOpacity() {
|
|
||||||
if (!mesh.Initialized) return;
|
|
||||||
var c = mesh.Renderer.material.color;
|
|
||||||
c.a = _opacity;
|
|
||||||
mesh.Renderer.material.color = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FitMode m_fit = FitMode.height;
|
private FitMode m_fit = FitMode.height;
|
||||||
public FitMode Fit {
|
public FitMode Fit {
|
||||||
get { return m_fit; }
|
get { return m_fit; }
|
||||||
@@ -185,7 +182,7 @@ namespace Cryville.Crtr.Components {
|
|||||||
public override void Init() {
|
public override void Init() {
|
||||||
InternalInit();
|
InternalInit();
|
||||||
OnFrameUpdate();
|
OnFrameUpdate();
|
||||||
UpdateOpacity();
|
UpdateShader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,22 +2,7 @@
|
|||||||
|
|
||||||
namespace Cryville.Crtr.Components {
|
namespace Cryville.Crtr.Components {
|
||||||
public class SpriteRect : SpriteBase {
|
public class SpriteRect : SpriteBase {
|
||||||
public SpriteRect() {
|
public SpriteRect() { }
|
||||||
SubmitProperty("color", new PropOp.Color(v => Color = v));
|
|
||||||
}
|
|
||||||
|
|
||||||
Color _color;
|
|
||||||
public Color Color {
|
|
||||||
get { return _color; }
|
|
||||||
set {
|
|
||||||
_color = value;
|
|
||||||
OnColorUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void OnColorUpdate() {
|
|
||||||
if (!mesh.Initialized) return;
|
|
||||||
mesh.Renderer.material.SetColor("_Color", _color);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Vector3 BaseScale {
|
protected override Vector3 BaseScale {
|
||||||
get { return Vector3.one; }
|
get { return Vector3.one; }
|
||||||
@@ -25,7 +10,6 @@ namespace Cryville.Crtr.Components {
|
|||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
InternalInit();
|
InternalInit();
|
||||||
OnColorUpdate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -84,7 +84,6 @@ namespace Cryville.Crtr.Components {
|
|||||||
public override void Init() {
|
public override void Init() {
|
||||||
InternalInit("quad_scale3h");
|
InternalInit("quad_scale3h");
|
||||||
OnFrameUpdate();
|
OnFrameUpdate();
|
||||||
UpdateOpacity();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@ namespace Cryville.Crtr.Components {
|
|||||||
SubmitProperty("value", new PropOp.TargetString(() => Value));
|
SubmitProperty("value", new PropOp.TargetString(() => Value));
|
||||||
SubmitProperty("size", new PropOp.Float(v => Size = v));
|
SubmitProperty("size", new PropOp.Float(v => Size = v));
|
||||||
SubmitProperty("spacing", new PropOp.Float(v => Spacing = v));
|
SubmitProperty("spacing", new PropOp.Float(v => Spacing = v));
|
||||||
SubmitProperty("opacity", new PropOp.Float(v => Opacity = v));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE1006
|
#pragma warning disable IDE1006
|
||||||
@@ -47,7 +46,7 @@ namespace Cryville.Crtr.Components {
|
|||||||
Dictionary<char, SpriteInfo> m_frames;
|
Dictionary<char, SpriteInfo> m_frames;
|
||||||
public Dictionary<char, SpriteInfo> Frames {
|
public Dictionary<char, SpriteInfo> Frames {
|
||||||
get { return m_frames; }
|
get { return m_frames; }
|
||||||
set { m_frames = value; UpdateFrames(); UpdateScale(); }
|
set { m_frames = value; UpdateFrames(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly TargetString m_value = new TargetString();
|
readonly TargetString m_value = new TargetString();
|
||||||
@@ -78,7 +77,11 @@ namespace Cryville.Crtr.Components {
|
|||||||
meshes.Clear();
|
meshes.Clear();
|
||||||
verts.Clear();
|
verts.Clear();
|
||||||
uvs.Clear();
|
uvs.Clear();
|
||||||
|
DestroyMaterials();
|
||||||
|
materials = new Material[m_frames.Count];
|
||||||
|
int i = 0;
|
||||||
foreach (var f in m_frames) {
|
foreach (var f in m_frames) {
|
||||||
|
if (SpriteInfo.IsNullOrEmpty(f.Value)) continue;
|
||||||
if (frameHeight == 0) frameHeight = f.Value.Rect.height;
|
if (frameHeight == 0) frameHeight = f.Value.Rect.height;
|
||||||
else if (frameHeight != f.Value.Rect.height) throw new Exception("Inconsistent frame height for text component");
|
else if (frameHeight != f.Value.Rect.height) throw new Exception("Inconsistent frame height for text component");
|
||||||
var tex = f.Value.Frame.Texture;
|
var tex = f.Value.Frame.Texture;
|
||||||
@@ -86,14 +89,17 @@ namespace Cryville.Crtr.Components {
|
|||||||
var m = new MeshWrapper();
|
var m = new MeshWrapper();
|
||||||
m.Init(mesh.MeshTransform);
|
m.Init(mesh.MeshTransform);
|
||||||
m.Mesh = new Mesh();
|
m.Mesh = new Mesh();
|
||||||
m.Renderer.material = MeshWrapper.NewMaterial(); // TODO Destroy or add to `materials`
|
var mat = MeshWrapper.NewMaterial();
|
||||||
m.Renderer.material.mainTexture = tex;
|
mat.mainTexture = tex;
|
||||||
|
m.Renderer.sharedMaterial = materials[i++] = mat;
|
||||||
meshes.Add(tex, m);
|
meshes.Add(tex, m);
|
||||||
verts.Add(tex, new List<Vector3>());
|
verts.Add(tex, new List<Vector3>());
|
||||||
uvs.Add(tex, new List<Vector2>());
|
uvs.Add(tex, new List<Vector2>());
|
||||||
tris.Add(tex, new List<int>());
|
tris.Add(tex, new List<int>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UpdateColor();
|
||||||
|
UpdateScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
float sum_x;
|
float sum_x;
|
||||||
@@ -158,23 +164,6 @@ namespace Cryville.Crtr.Components {
|
|||||||
get { return new Vector2(-0.5f, -0.5f); }
|
get { return new Vector2(-0.5f, -0.5f); }
|
||||||
}
|
}
|
||||||
|
|
||||||
float _opacity = 1;
|
|
||||||
public float Opacity {
|
|
||||||
get { return _opacity; }
|
|
||||||
set {
|
|
||||||
_opacity = value;
|
|
||||||
UpdateOpacity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void UpdateOpacity() {
|
|
||||||
if (!mesh.Initialized) return;
|
|
||||||
foreach (var m in meshes) {
|
|
||||||
var c = m.Value.Renderer.material.color;
|
|
||||||
c.a = _opacity;
|
|
||||||
m.Value.Renderer.material.color = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
InternalInit();
|
InternalInit();
|
||||||
UpdateFrames();
|
UpdateFrames();
|
||||||
|
@@ -93,10 +93,10 @@ namespace Cryville.Crtr.Config {
|
|||||||
var tsrc = src.Value;
|
var tsrc = src.Value;
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
if (proxy.IsUsed(tsrc)) {
|
if (proxy.IsUsed(tsrc)) {
|
||||||
text.text += " (Used)";
|
text.text += " <size=9>(Used)</size>";
|
||||||
}
|
}
|
||||||
else if (tsrc.Handler.GetDimension(src.Value.Type) < m_configScene.ruleset.Root.inputs[_sel].dim) {
|
else if (tsrc.Handler.GetDimension(src.Value.Type) < m_configScene.ruleset.Root.inputs[_sel].dim) {
|
||||||
text.text += " (Not Applicable)";
|
text.text += " <size=9>(Not Applicable)</size>";
|
||||||
}
|
}
|
||||||
else flag = true;
|
else flag = true;
|
||||||
btn.interactable = flag;
|
btn.interactable = flag;
|
||||||
|
@@ -40,17 +40,23 @@ namespace Cryville.Crtr {
|
|||||||
_pool.Return(item);
|
_pool.Return(item);
|
||||||
_endQueue.RemoveAt(0);
|
_endQueue.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
foreach (var instance in _instances) {
|
||||||
|
instance.Value.Tick();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void Emit(float index) {
|
public void Emit(float index) {
|
||||||
EffectInstance instance;
|
EffectInstance instance;
|
||||||
if (!_instances.TryGetValue(index, out instance)) {
|
if (_instances.TryGetValue(index, out instance)) {
|
||||||
|
var i = _endQueue.BinarySearch(instance);
|
||||||
|
_endQueue.RemoveAt(i);
|
||||||
|
}
|
||||||
|
else {
|
||||||
_instances.Add(index, instance = _pool.Rent());
|
_instances.Add(index, instance = _pool.Rent());
|
||||||
}
|
}
|
||||||
instance.Index = index;
|
instance.Index = index;
|
||||||
instance.OnEmit(_time);
|
instance.OnEmit(_time);
|
||||||
var i = _endQueue.BinarySearch(instance);
|
var i2 = ~_endQueue.BinarySearch(instance);
|
||||||
if (i < 0) i = ~i;
|
_endQueue.Insert(i2, instance);
|
||||||
_endQueue.Insert(i, instance);
|
|
||||||
}
|
}
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
_pool.DisposeAll();
|
_pool.DisposeAll();
|
||||||
|
@@ -23,18 +23,29 @@ namespace Cryville.Crtr {
|
|||||||
_indexSrc = new PropSrc.Float(() => Index);
|
_indexSrc = new PropSrc.Float(() => Index);
|
||||||
_durationOp = new PropOp.Float(v => _duration = v);
|
_durationOp = new PropOp.Float(v => _duration = v);
|
||||||
}
|
}
|
||||||
public float Index { get; set; }
|
private float m_index;
|
||||||
static readonly int _var_index = IdentifierManager.SharedInstance.Request("index");
|
public float Index {
|
||||||
|
get { return m_index; }
|
||||||
|
set {
|
||||||
|
if (m_index == value) return;
|
||||||
|
m_index = value;
|
||||||
|
_indexSrc.Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal static readonly int _VAR_EFFECT_INDEX = IdentifierManager.SharedInstance.Request("effect_index");
|
||||||
readonly PropSrc _indexSrc;
|
readonly PropSrc _indexSrc;
|
||||||
double _startTime;
|
double _startTime;
|
||||||
float _duration;
|
float _duration;
|
||||||
readonly PropOp _durationOp;
|
readonly PropOp _durationOp;
|
||||||
public double EndTime { get { return _startTime + _duration; } }
|
public double EndTime { get { return _startTime + _duration; } }
|
||||||
|
public void Tick() {
|
||||||
|
_skinContainer.MatchDynamic(this, 1);
|
||||||
|
}
|
||||||
public void OnEmit(double time) {
|
public void OnEmit(double time) {
|
||||||
_startTime = time;
|
_startTime = time;
|
||||||
RootTransform.gameObject.SetActive(true);
|
RootTransform.gameObject.SetActive(true);
|
||||||
ChartPlayer.etor.ContextCascadeInsert();
|
ChartPlayer.etor.ContextCascadeInsert();
|
||||||
ChartPlayer.etor.ContextCascadeUpdate(_var_index, _indexSrc);
|
ChartPlayer.etor.ContextCascadeUpdate(_VAR_EFFECT_INDEX, _indexSrc);
|
||||||
ChartPlayer.etor.Evaluate(_durationOp, _def.duration);
|
ChartPlayer.etor.Evaluate(_durationOp, _def.duration);
|
||||||
_skinContainer.MatchDynamic(this, 0);
|
_skinContainer.MatchDynamic(this, 0);
|
||||||
ChartPlayer.etor.ContextCascadeDiscard();
|
ChartPlayer.etor.ContextCascadeDiscard();
|
||||||
@@ -60,7 +71,9 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int CompareTo(EffectInstance other) {
|
public int CompareTo(EffectInstance other) {
|
||||||
return EndTime.CompareTo(other.EndTime);
|
int r = EndTime.CompareTo(other.EndTime);
|
||||||
|
if (r != 0) return r;
|
||||||
|
return GetHashCode().CompareTo(other.GetHashCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,9 @@ namespace Cryville.Crtr {
|
|||||||
|
|
||||||
Materials.Add("-SpriteMat", Resources.Load<Material>("Materials/SpriteMat"));
|
Materials.Add("-SpriteMat", Resources.Load<Material>("Materials/SpriteMat"));
|
||||||
|
|
||||||
|
Shaders.Add("default", Shader.Find("Sprites/Default"));
|
||||||
|
Shaders.Add("additive", Shader.Find("Sprites/Additive"));
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -361,7 +361,7 @@ namespace Cryville.Crtr {
|
|||||||
public abstract float DelerpWith(Vector start, Vector value);
|
public abstract float DelerpWith(Vector start, Vector value);
|
||||||
public abstract bool IsZero();
|
public abstract bool IsZero();
|
||||||
public override abstract string ToString();
|
public override abstract string ToString();
|
||||||
public abstract float[] ToArray();
|
public abstract unsafe void ToArray(float* arr);
|
||||||
|
|
||||||
public Vector Clone() {
|
public Vector Clone() {
|
||||||
return (Vector)MemberwiseClone();
|
return (Vector)MemberwiseClone();
|
||||||
@@ -442,8 +442,8 @@ namespace Cryville.Crtr {
|
|||||||
return Value.ToString(CultureInfo.InvariantCulture);
|
return Value.ToString(CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float[] ToArray() {
|
public override unsafe void ToArray(float* arr) {
|
||||||
return new float[] { Value };
|
arr[0] = Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,8 +504,8 @@ namespace Cryville.Crtr {
|
|||||||
return Value.ToString(CultureInfo.InvariantCulture);
|
return Value.ToString(CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float[] ToArray() {
|
public override unsafe void ToArray(float* arr) {
|
||||||
return new float[] { Value };
|
arr[0] = Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,8 +566,8 @@ namespace Cryville.Crtr {
|
|||||||
return Value.ToString(CultureInfo.InvariantCulture);
|
return Value.ToString(CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float[] ToArray() {
|
public override unsafe void ToArray(float* arr) {
|
||||||
return new float[] { Value };
|
arr[0] = Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -669,8 +669,9 @@ namespace Cryville.Crtr {
|
|||||||
return ToString(w, h);
|
return ToString(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float[] ToArray() {
|
public override unsafe void ToArray(float* arr) {
|
||||||
return new float[] { w.Value, h.Value };
|
arr[0] = w.Value;
|
||||||
|
arr[1] = h.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,8 +765,10 @@ namespace Cryville.Crtr {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float[] ToArray() {
|
public override unsafe void ToArray(float* arr) {
|
||||||
return new float[] { x.Value, y.Value, z.Value };
|
arr[0] = x.Value;
|
||||||
|
arr[1] = y.Value;
|
||||||
|
arr[2] = z.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -845,8 +848,11 @@ namespace Cryville.Crtr {
|
|||||||
return VecPtComp.ToString(xw, xh) + "," + VecPtComp.ToString(yw, yh);
|
return VecPtComp.ToString(xw, xh) + "," + VecPtComp.ToString(yw, yh);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float[] ToArray() {
|
public override unsafe void ToArray(float* arr) {
|
||||||
return new float[] { xw.Value, xh.Value, yw.Value, yh.Value };
|
arr[0] = xw.Value;
|
||||||
|
arr[1] = xh.Value;
|
||||||
|
arr[2] = yw.Value;
|
||||||
|
arr[3] = yh.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -936,40 +942,25 @@ namespace Cryville.Crtr {
|
|||||||
return VecPtComp.ToString(xw, xh) + "," + VecPtComp.ToString(yw, yh) + "," + (z != null ? z.Value.ToString(CultureInfo.InvariantCulture) : "");
|
return VecPtComp.ToString(xw, xh) + "," + VecPtComp.ToString(yw, yh) + "," + (z != null ? z.Value.ToString(CultureInfo.InvariantCulture) : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float[] ToArray() {
|
public override unsafe void ToArray(float* arr) {
|
||||||
return new float[] { xw.Value, xh.Value, yw.Value, yh.Value, z.Value };
|
arr[0] = xw.Value;
|
||||||
|
arr[1] = xh.Value;
|
||||||
|
arr[2] = yw.Value;
|
||||||
|
arr[3] = yh.Value;
|
||||||
|
arr[4] = z.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class VectorSrc : PropSrc {
|
public class VectorSrc : PropSrc.FixedBuffer {
|
||||||
protected readonly Func<Vector> _cb;
|
protected readonly Func<Vector> _cb;
|
||||||
public VectorSrc(Func<Vector> cb, int type) : base(type) { _cb = cb; }
|
public VectorSrc(Func<Vector> cb) : base(PdtInternalType.Vector, 8 * sizeof(float) + sizeof(int)) { _cb = cb; }
|
||||||
public static VectorSrc Construct(Func<Vector> cb) {
|
protected override unsafe void InternalGet() {
|
||||||
if (cb().Dimension == 1) return new INumber(cb);
|
var v = _cb();
|
||||||
else return new IVector(cb);
|
if (v.Dimension > 8) throw new NotSupportedException("Vector dimension too large");
|
||||||
}
|
fixed (byte* rptr = buf) {
|
||||||
class INumber : VectorSrc {
|
var ptr = (float*)rptr;
|
||||||
public INumber(Func<Vector> cb) : base(cb, PdtInternalType.Number) { }
|
v.ToArray(ptr);
|
||||||
protected override unsafe void InternalGet() {
|
*(int*)(ptr + v.Dimension) = PdtInternalType.Number;
|
||||||
var arr = _cb().ToArray();
|
|
||||||
buf = new byte[sizeof(float)];
|
|
||||||
fixed (byte* ptr = buf) {
|
|
||||||
*(float*)ptr = arr[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class IVector : VectorSrc {
|
|
||||||
public IVector(Func<Vector> cb) : base(cb, PdtInternalType.Vector) { }
|
|
||||||
protected override unsafe void InternalGet() {
|
|
||||||
var arr = _cb().ToArray();
|
|
||||||
buf = new byte[sizeof(float) * arr.Length + sizeof(int)];
|
|
||||||
fixed (byte* rptr = buf) {
|
|
||||||
var ptr = (float*)rptr;
|
|
||||||
for (int i = 0; i < arr.Length; i++, ptr++) {
|
|
||||||
*ptr = arr[i];
|
|
||||||
}
|
|
||||||
*(int*)ptr = PdtInternalType.Number;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,8 @@ namespace Cryville.Crtr {
|
|||||||
|
|
||||||
static readonly byte[] _nullbuf = new byte[0];
|
static readonly byte[] _nullbuf = new byte[0];
|
||||||
readonly byte[] _numbuf = new byte[4];
|
readonly byte[] _numbuf = new byte[4];
|
||||||
|
readonly PropSrc _vecsrc;
|
||||||
|
Vector _vec;
|
||||||
static readonly int _var_w = IdentifierManager.SharedInstance.Request("w");
|
static readonly int _var_w = IdentifierManager.SharedInstance.Request("w");
|
||||||
static readonly int _var_h = IdentifierManager.SharedInstance.Request("h");
|
static readonly int _var_h = IdentifierManager.SharedInstance.Request("h");
|
||||||
static readonly int _var_current_time = IdentifierManager.SharedInstance.Request("current_time");
|
static readonly int _var_current_time = IdentifierManager.SharedInstance.Request("current_time");
|
||||||
@@ -32,8 +34,9 @@ namespace Cryville.Crtr {
|
|||||||
prop.Get(out type, out value);
|
prop.Get(out type, out value);
|
||||||
}
|
}
|
||||||
else if (ContextState != null && ChartPlayer.motionRegistry.ContainsKey(id)) {
|
else if (ContextState != null && ChartPlayer.motionRegistry.ContainsKey(id)) {
|
||||||
var vec = ContextState.GetRawValue(id);
|
_vec = ContextState.GetRawValue(id);
|
||||||
VectorSrc.Construct(() => vec).Get(out type, out value);
|
_vecsrc.Invalidate();
|
||||||
|
_vecsrc.Get(out type, out value);
|
||||||
}
|
}
|
||||||
else if (ContextState != null && ContextState.Handler.PropSrcs.TryGetValue(name, out prop)) {
|
else if (ContextState != null && ContextState.Handler.PropSrcs.TryGetValue(name, out prop)) {
|
||||||
prop.Get(out type, out value);
|
prop.Get(out type, out value);
|
||||||
@@ -140,6 +143,7 @@ namespace Cryville.Crtr {
|
|||||||
public PdtEvaluator() {
|
public PdtEvaluator() {
|
||||||
ContextCascadeBlocks.Push(0);
|
ContextCascadeBlocks.Push(0);
|
||||||
for (int i = 0; i < ContextCascade.Length; i++) ContextCascade[i] = new Dictionary<int, PropSrc>();
|
for (int i = 0; i < ContextCascade.Length; i++) ContextCascade[i] = new Dictionary<int, PropSrc>();
|
||||||
|
_vecsrc = new VectorSrc(() => _vec);
|
||||||
|
|
||||||
_ctxops.Add(IdentifierManager.SharedInstance.Request("screen_edge"), new func_screen_edge(() => ContextTransform));
|
_ctxops.Add(IdentifierManager.SharedInstance.Request("screen_edge"), new func_screen_edge(() => ContextTransform));
|
||||||
_ctxops.Add(IdentifierManager.SharedInstance.Request("int"), new func_int(() => ContextSelfValue));
|
_ctxops.Add(IdentifierManager.SharedInstance.Request("int"), new func_int(() => ContextSelfValue));
|
||||||
@@ -559,7 +563,7 @@ namespace Cryville.Crtr {
|
|||||||
if (src == null) throw new ArgumentNullException("src");
|
if (src == null) throw new ArgumentNullException("src");
|
||||||
int type; byte[] value;
|
int type; byte[] value;
|
||||||
src.Get(out type, out value);
|
src.Get(out type, out value);
|
||||||
if (type != PdtInternalType.Number)
|
if (type != PdtInternalType.Number && type != PdtInternalType.Vector)
|
||||||
throw new ArgumentException("Not a number");
|
throw new ArgumentException("Not a number");
|
||||||
fixed (byte* ptr = value) {
|
fixed (byte* ptr = value) {
|
||||||
return *(float*)ptr;
|
return *(float*)ptr;
|
||||||
|
@@ -6,7 +6,7 @@ using RangeAttribute = Cryville.Common.ComponentModel.RangeAttribute;
|
|||||||
namespace Cryville.Crtr {
|
namespace Cryville.Crtr {
|
||||||
public class Settings {
|
public class Settings {
|
||||||
[Category("graphics")]
|
[Category("graphics")]
|
||||||
[LogarithmicScale][Step(0.5f)][Precision(1e-2)]
|
[LogarithmicScale][Range(0.01f, 20f)][Step(0.5f)][Precision(1e-2)]
|
||||||
public float BackwardClippingDistance {
|
public float BackwardClippingDistance {
|
||||||
get {
|
get {
|
||||||
return PlayerPrefs.GetFloat("BackwardClippingDistance", 0.2f);
|
return PlayerPrefs.GetFloat("BackwardClippingDistance", 0.2f);
|
||||||
@@ -62,8 +62,7 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Category("gameplay")]
|
[Category("gameplay")]
|
||||||
[Step(0.01f)]
|
[Step(0.01f)][Precision(1e-3)]
|
||||||
[Precision(1e-3)]
|
|
||||||
public float GraphicalOffset {
|
public float GraphicalOffset {
|
||||||
get {
|
get {
|
||||||
return PlayerPrefs.GetFloat("GraphicalOffset", 0);
|
return PlayerPrefs.GetFloat("GraphicalOffset", 0);
|
||||||
@@ -132,7 +131,7 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Category("graphics")]
|
[Category("graphics")]
|
||||||
[LogarithmicScale][Step(0.5f)][Precision(1e-1)]
|
[LogarithmicScale][Range(0.1f, 200f)][Step(0.5f)][Precision(1e-1)]
|
||||||
public float RenderDistance {
|
public float RenderDistance {
|
||||||
get {
|
get {
|
||||||
return PlayerPrefs.GetFloat("RenderDistance", 4);
|
return PlayerPrefs.GetFloat("RenderDistance", 4);
|
||||||
@@ -166,8 +165,8 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
[Category("gameplay")]
|
[Category("debug")]
|
||||||
[Description("(Not implemented yet)")]
|
[Range(0, float.PositiveInfinity)][Step(10f)][Precision(1e-1)]
|
||||||
public float StartOffset {
|
public float StartOffset {
|
||||||
get {
|
get {
|
||||||
return PlayerPrefs.GetFloat("StartOffset", 0);
|
return PlayerPrefs.GetFloat("StartOffset", 0);
|
||||||
|
@@ -59,6 +59,7 @@ namespace Cryville.Crtr {
|
|||||||
foreach (var e in effects) {
|
foreach (var e in effects) {
|
||||||
var effect = e.Value;
|
var effect = e.Value;
|
||||||
etor.ContextCascadeInsert();
|
etor.ContextCascadeInsert();
|
||||||
|
etor.ContextCascadeUpdate(EffectInstance._VAR_EFFECT_INDEX, PropSrc.Error);
|
||||||
etor.Optimize(effect.duration);
|
etor.Optimize(effect.duration);
|
||||||
effect.elements.Optimize(etor);
|
effect.elements.Optimize(etor);
|
||||||
etor.ContextCascadeDiscard();
|
etor.ContextCascadeDiscard();
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using Cryville.Common.Pdt;
|
using Cryville.Common.Pdt;
|
||||||
using Cryville.Crtr.Event;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Profiling;
|
using UnityEngine.Profiling;
|
||||||
@@ -40,7 +39,10 @@ namespace Cryville.Crtr {
|
|||||||
ChartPlayer.etor.ContextTransform = rc.Transform;
|
ChartPlayer.etor.ContextTransform = rc.Transform;
|
||||||
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeInsert(rc.PropSrcs);
|
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeInsert(rc.PropSrcs);
|
||||||
foreach (var p in rel.properties) {
|
foreach (var p in rel.properties) {
|
||||||
p.Key.ExecuteStatic(group, ctx, p.Value);
|
try {
|
||||||
|
p.Key.ExecuteStatic(group, ctx, p.Value);
|
||||||
|
}
|
||||||
|
catch (EvaluationFailureException) { }
|
||||||
if (p.Key.IsValueRequired && !p.Value.IsConstant) stack.Properties.Add(
|
if (p.Key.IsValueRequired && !p.Value.IsConstant) stack.Properties.Add(
|
||||||
new DynamicProperty { Context = ctx, Key = p.Key, Value = p.Value }
|
new DynamicProperty { Context = ctx, Key = p.Key, Value = p.Value }
|
||||||
);
|
);
|
||||||
|
@@ -400,7 +400,7 @@ namespace System.Text.Formatting {
|
|||||||
var segmentsLeft = false;
|
var segmentsLeft = false;
|
||||||
var prevArgIndex = 0;
|
var prevArgIndex = 0;
|
||||||
do {
|
do {
|
||||||
CheckCapacity((int)(end - curr));
|
CheckCapacity((int)(end - curr) + 1);
|
||||||
fixed (char* bufferPtr = &buffer[currentCount])
|
fixed (char* bufferPtr = &buffer[currentCount])
|
||||||
segmentsLeft = AppendSegment(ref curr, end, bufferPtr, ref prevArgIndex, ref args);
|
segmentsLeft = AppendSegment(ref curr, end, bufferPtr, ref prevArgIndex, ref args);
|
||||||
}
|
}
|
||||||
|
8
Assets/Resources/Shaders.meta
Normal file
8
Assets/Resources/Shaders.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9bd2dd8289f72d5479fc93154ddaf762
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
74
Assets/Resources/Shaders/Sprites-Additive.shader
Normal file
74
Assets/Resources/Shaders/Sprites-Additive.shader
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||||
|
|
||||||
|
Shader "Sprites/Additive"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
|
||||||
|
_Color("Tint", Color) = (1,1,1,1)
|
||||||
|
[MaterialToggle] PixelSnap("Pixel snap", Float) = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags
|
||||||
|
{
|
||||||
|
"Queue" = "Transparent"
|
||||||
|
"IgnoreProjector" = "True"
|
||||||
|
"RenderType" = "Transparent"
|
||||||
|
"PreviewType" = "Plane"
|
||||||
|
"CanUseSpriteAtlas" = "True"
|
||||||
|
}
|
||||||
|
|
||||||
|
Cull Off
|
||||||
|
Lighting Off
|
||||||
|
ZWrite Off
|
||||||
|
Fog { Mode Off }
|
||||||
|
Blend SrcAlpha One
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
|
#pragma multi_compile DUMMY PIXELSNAP_ON
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
struct appdata_t {
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
float4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 vertex : SV_POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
half2 texcoord : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
fixed4 _Color;
|
||||||
|
|
||||||
|
v2f vert(appdata_t IN) {
|
||||||
|
v2f OUT;
|
||||||
|
OUT.vertex = UnityObjectToClipPos(IN.vertex);
|
||||||
|
OUT.texcoord = IN.texcoord;
|
||||||
|
OUT.color = IN.color * _Color;
|
||||||
|
#ifdef PIXELSNAP_ON
|
||||||
|
OUT.vertex = UnityPixelSnap(OUT.vertex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return OUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
|
||||||
|
fixed4 frag(v2f IN) : SV_Target
|
||||||
|
{
|
||||||
|
fixed4 c = tex2D(_MainTex, IN.texcoord) * IN.color;
|
||||||
|
c.rgb *= c.a;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
Assets/Resources/Shaders/Sprites-Additive.shader.meta
Normal file
10
Assets/Resources/Shaders/Sprites-Additive.shader.meta
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 566d6ad96aab9ea4599b9595dc35f01d
|
||||||
|
ShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
defaultTextures: []
|
||||||
|
nonModifiableTextures: []
|
||||||
|
preprocessorOverride: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Reference in New Issue
Block a user