mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 06:37:37 +02:00
prep work on dynamic beatmap format
This commit is contained in:
116
Assets/Scripts/BeatmapFormats/Beatmap.cs
Normal file
116
Assets/Scripts/BeatmapFormats/Beatmap.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio
|
||||
{
|
||||
[Serializable]
|
||||
public class Beatmap
|
||||
{
|
||||
public float bpm;
|
||||
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||
[DefaultValue(100)]
|
||||
public int musicVolume; // In percent (1-100)
|
||||
|
||||
public List<Entity> entities = new List<Entity>();
|
||||
public List<TempoChange> tempoChanges = new List<TempoChange>();
|
||||
public List<VolumeChange> volumeChanges = new List<VolumeChange>();
|
||||
public float firstBeatOffset;
|
||||
|
||||
[Serializable]
|
||||
public class Entity : ICloneable
|
||||
{
|
||||
public float beat;
|
||||
public int track;
|
||||
|
||||
// consideration: use arrays instead of hardcoding fixed parameter names
|
||||
// note from zeo: yeah definately use arrays
|
||||
[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;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public int type;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public int type2;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public int type3;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public int type4;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public int type5;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public int type6;
|
||||
[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;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public Color colorD;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public Color colorE;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public Color colorF;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public string text1;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public string text2;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public string text3;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float swing;
|
||||
public string datamodel;
|
||||
[JsonIgnore] public Editor.Track.TimelineEventObj eventObj;
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return this.MemberwiseClone();
|
||||
}
|
||||
|
||||
public Entity DeepCopy()
|
||||
{
|
||||
//lol the AI generated this
|
||||
return JsonConvert.DeserializeObject<Entity>(JsonConvert.SerializeObject(this));
|
||||
}
|
||||
|
||||
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 parameter, or defined the object type wrong. Exception log: {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class TempoChange : ICloneable
|
||||
{
|
||||
public float beat;
|
||||
public float length;
|
||||
public float tempo;
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return this.MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class VolumeChange : ICloneable
|
||||
{
|
||||
public float beat;
|
||||
public float length;
|
||||
public float volume;
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return this.MemberwiseClone();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/BeatmapFormats/Beatmap.cs.meta
Normal file
11
Assets/Scripts/BeatmapFormats/Beatmap.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ec74fe21af663f4d9645852eb4cfb88
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
118
Assets/Scripts/BeatmapFormats/DynamicBeatmap.cs
Normal file
118
Assets/Scripts/BeatmapFormats/DynamicBeatmap.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio
|
||||
{
|
||||
[Serializable]
|
||||
public class DynamicBeatmap
|
||||
{
|
||||
public float bpm;
|
||||
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||
[DefaultValue(100)] public int musicVolume; // In percent (1-100)
|
||||
|
||||
public Dictionary<string, object> properties =
|
||||
new Dictionary<string, object>() {
|
||||
{"remixtitle", "New Remix"},
|
||||
{"remixauthor", "Your Name"},
|
||||
};
|
||||
public List<DynamicEntity> entities = new List<DynamicEntity>();
|
||||
public List<TempoChange> tempoChanges = new List<TempoChange>();
|
||||
public List<VolumeChange> volumeChanges = new List<VolumeChange>();
|
||||
public float firstBeatOffset;
|
||||
|
||||
[Serializable]
|
||||
public class DynamicEntity : ICloneable
|
||||
{
|
||||
public float beat;
|
||||
public int track;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float length;
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float swing;
|
||||
public Dictionary<string, object> DynamicData = new Dictionary<string, object>();
|
||||
|
||||
public string datamodel;
|
||||
[JsonIgnore] public Editor.Track.TimelineEventObj eventObj;
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return this.MemberwiseClone();
|
||||
}
|
||||
|
||||
public DynamicEntity DeepCopy()
|
||||
{
|
||||
//lol the AI generated this
|
||||
return JsonConvert.DeserializeObject<DynamicEntity>(JsonConvert.SerializeObject(this));
|
||||
}
|
||||
|
||||
public object this[string propertyName]
|
||||
{
|
||||
get
|
||||
{
|
||||
return DynamicData[propertyName];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (DynamicData.ContainsKey(propertyName))
|
||||
{
|
||||
DynamicData[propertyName] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.Debug.LogError($"This entity does not have a property named {propertyName}! Attempted to insert value of type {value.GetType()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class TempoChange : ICloneable
|
||||
{
|
||||
public float beat;
|
||||
public float length;
|
||||
public float tempo;
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return this.MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class VolumeChange : ICloneable
|
||||
{
|
||||
public float beat;
|
||||
public float length;
|
||||
public float volume;
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return this.MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
public object this[string propertyName]
|
||||
{
|
||||
get
|
||||
{
|
||||
return properties[propertyName];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (properties.ContainsKey(propertyName))
|
||||
{
|
||||
properties[propertyName] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.Debug.LogError($"This beatmap does not have a property named {propertyName}! Attempted to insert value of type {value.GetType()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/BeatmapFormats/DynamicBeatmap.cs.meta
Normal file
11
Assets/Scripts/BeatmapFormats/DynamicBeatmap.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca2149f692fc3d84ba6526d33c132822
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user