HeavenStudio/Assets/Scripts/Beatmap.cs

77 lines
2.9 KiB
C#
Raw Normal View History

2021-12-23 00:08:35 +00:00
using System;
2021-12-22 00:42:01 +00:00
using System.Collections.Generic;
using UnityEngine;
2022-01-15 22:52:53 +00:00
using Newtonsoft.Json;
2021-12-22 00:42:01 +00:00
2022-02-04 22:16:22 +00:00
using RhythmHeavenMania.Util;
2021-12-23 00:08:35 +00:00
namespace RhythmHeavenMania
2021-12-22 00:42:01 +00:00
{
2021-12-23 00:08:35 +00:00
[Serializable]
public class Beatmap
2021-12-22 00:42:01 +00:00
{
2021-12-23 02:28:05 +00:00
public float bpm;
2022-01-08 16:42:48 +00:00
public List<Entity> entities = new List<Entity>();
public List<TempoChange> tempoChanges = new List<TempoChange>();
2022-02-24 14:02:21 +00:00
public float firstBeatOffset;
2021-12-22 00:42:01 +00:00
2021-12-23 00:08:35 +00:00
[Serializable]
public class Entity : ICloneable
{
public float beat;
public int track;
2022-01-15 22:52:53 +00:00
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float length;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float valA;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float valB;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float valC;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public bool toggle;
2022-01-15 22:52:53 +00:00
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public int type;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public int type2;
2022-02-04 22:16:22 +00:00
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public EasingFunction.Ease ease;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public Color colorA;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public Color colorB;
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public Color colorC;
2022-02-24 14:12:19 +00:00
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float swing;
2021-12-23 00:08:35 +00:00
public string datamodel;
[JsonIgnore] public Editor.Track.TimelineEventObj eventObj;
public object Clone()
{
return this.MemberwiseClone();
}
2022-02-03 22:20:26 +00:00
public object this[string propertyName]
{
get
{
return typeof(Entity).GetField(propertyName).GetValue(this);
}
set
{
try
{
typeof(Entity).GetField(propertyName).SetValue(this, value);
}
catch (Exception ex)
{
UnityEngine.Debug.LogError($"You probably misspelled a paramater, or defined the object type wrong. Exception log: {ex}");
}
}
}
}
[Serializable]
public class TempoChange : ICloneable
{
public float beat;
public float length;
public float tempo;
2021-12-23 00:08:35 +00:00
public object Clone()
{
return this.MemberwiseClone();
}
}
2021-12-22 00:42:01 +00:00
}
2021-12-23 00:08:35 +00:00
}