Misc Additions #4 (#192)

* update icons

* add background loading of sound sequences

- fix bug with preFunction
- remove most of the old preloading code

* update spritesheets for karate man, marching orders

* file explorer chart loading

* update icon for trick on the class
This commit is contained in:
minenice55
2023-01-11 20:42:12 -05:00
committed by GitHub
parent ddc183acdd
commit 41e9d36177
89 changed files with 1970 additions and 459 deletions

View File

@ -26,13 +26,55 @@ namespace HeavenStudio.Util
this.clips = new List<SequenceClip>(clips);
}
public MultiSound Play(float startBeat)
public MultiSound Play(float startBeat, params SequenceParams[] args)
{
List<MultiSound.Sound> sounds = new List<MultiSound.Sound>();
Dictionary<string, string> paramMaps = new Dictionary<string, string>();
foreach (SequenceClip clip in clips)
foreach (SequenceClip clipdat in clips)
{
sounds.Add(new MultiSound.Sound(clip.clip, startBeat + clip.beat, clip.pitch, clip.volume, clip.looping, clip.offset));
string clip = clipdat.clip;
float beat = clipdat.beat;
float pitch = clipdat.pitch;
float volume = clipdat.volume;
bool looping = clipdat.looping;
float offset = clipdat.offset;
if (args != null && clipdat.parameters != null && clipdat.parameters.Length > 0)
{
paramMaps.Clear();
// map param names to overrides
foreach (SequenceParams prm in clipdat.parameters)
{
if (!paramMaps.ContainsKey(prm.name))
paramMaps.Add(prm.name, prm.map);
}
// apply overrides
foreach (SequenceParams prm in args)
{
if (paramMaps.ContainsKey(prm.name))
{
string map = paramMaps[prm.name];
switch (map)
{
case "beat":
beat = prm.value;
break;
case "pitch":
pitch = prm.value;
break;
case "volume":
volume = prm.value;
break;
case "offset":
offset = prm.value;
break;
default:
break;
}
}
}
}
sounds.Add(new MultiSound.Sound(clip, startBeat + beat, pitch, volume, looping, offset));
}
return MultiSound.Play(sounds.ToArray(), game, force);
@ -41,16 +83,6 @@ namespace HeavenStudio.Util
[Serializable]
public struct SequenceClip
{
public SequenceClip(string clip, float beat, float pitch = 1f, float volume = 1f, bool looping = false, float offset = 0f)
{
this.clip = clip;
this.beat = beat;
this.pitch = pitch;
this.volume = volume;
this.looping = looping;
this.offset = offset;
}
[Tooltip("Filename of clip to use (will look in assetbundles before resources)")]
public string clip;
[Tooltip("Beat to play clip at relative to start of sequence")]
@ -65,6 +97,9 @@ namespace HeavenStudio.Util
public bool looping;
[Tooltip("Offset to start playing clip")]
public float offset;
[Tooltip("Set of possible value overrides for clip data")]
public SequenceParams[] parameters;
}
[Serializable]
@ -75,5 +110,26 @@ namespace HeavenStudio.Util
[Tooltip("Sequence to play")]
public SoundSequence sequence;
}
[Serializable]
public struct SequenceParams
{
//SequenceParams used in minigame code
public SequenceParams(string name, float value)
{
this.map = "";
this.name = name;
this.value = value;
}
[Tooltip("Inspector use only; Sequence Clip value to override")]
public string map;
[Tooltip("Name of parameter")]
public string name;
[NonSerialized]
public float value;
}
}
}