2022-01-17 19:23:18 +00:00
using System.Collections ;
using System.Collections.Generic ;
2023-10-29 19:44:47 +00:00
using System.Threading.Tasks ;
using Cysharp.Threading.Tasks ;
2022-06-12 19:32:00 +00:00
2022-01-17 19:23:18 +00:00
using UnityEngine ;
2023-12-26 05:22:51 +00:00
using UnityEngine.Networking ;
2022-02-28 19:31:28 +00:00
using DG.Tweening ;
2022-01-17 19:23:18 +00:00
2022-03-14 14:21:05 +00:00
using HeavenStudio.Util ;
2022-06-06 16:54:49 +00:00
using HeavenStudio.Editor.Track ;
2022-03-14 14:21:05 +00:00
using HeavenStudio.Games ;
2023-06-10 19:13:29 +00:00
using Jukebox ;
2022-01-17 19:23:18 +00:00
2022-04-12 16:14:46 +00:00
using System ;
using System.Linq ;
using System.Reflection ;
2022-06-12 19:32:00 +00:00
using System.IO ;
2022-04-12 16:14:46 +00:00
2022-03-14 14:21:05 +00:00
namespace HeavenStudio
2022-01-17 19:23:18 +00:00
{
2023-09-11 22:28:04 +00:00
2022-01-17 19:23:18 +00:00
public class Minigames
{
2023-10-29 19:44:47 +00:00
public enum RecommendedControlStyle
{
Any ,
Pad ,
Touch ,
Baton ,
}
2023-09-11 22:28:04 +00:00
2023-06-10 19:13:29 +00:00
public static void InitPreprocessor ( )
{
RiqBeatmap . OnUpdateBeatmap + = PreProcessBeatmap ;
2023-12-26 05:22:51 +00:00
RiqFileHandler . AudioConverter = JukeboxAudioConverter ;
2023-06-10 19:13:29 +00:00
}
2023-12-26 05:22:51 +00:00
readonly public static Dictionary < string , object > propertiesModel = new ( )
{
// mapper set properties? (future: use this to flash the button)
{ "propertiesmodified" , false } ,
////// CATEGORY 1: SONG INFO
// general chart info
{ "remixtitle" , "New Remix" } , // chart name
{ "remixauthor" , "Your Name" } , // charter's name
{ "remixdesc" , "Remix Description" } , // chart description
{ "remixlevel" , 1 } , // chart difficulty (maybe offer a suggestion but still have the mapper determine it)
{ "remixtempo" , 120f } , // avg. chart tempo
{ "remixtags" , "" } , // chart tags
{ "icontype" , 0 } , // chart icon (presets, custom - future)
{ "iconres" , new EntityTypes . Resource ( EntityTypes . Resource . ResourceType . Image , "Images/Select/" , "Icon" ) } , // custom icon location (future)
{ "challengetype" , 0 } , // perfect challenge type
{ "playstyle" , RecommendedControlStyle . Any } , // recommended control style
// chart song info
{ "idolgenre" , "Song Genre" } , // song genre
{ "idolsong" , "Song Name" } , // song name
{ "idolcredit" , "Artist" } , // song artist
////// CATEGORY 2: PROLOGUE AND EPILOGUE
// chart prologue
{ "prologuetype" , 0 } , // prologue card animation (future)
{ "prologuecaption" , "Remix" } , // prologue card sub-title (future)
// chart results screen messages
{ "resultcaption" , "Rhythm League Notes" } , // result screen header
{ "resultcommon_hi" , "Good rhythm." } , // generic "Superb" message (one-liner)
{ "resultcommon_ok" , "Eh. Passable." } , // generic "OK" message (one-liner)
{ "resultcommon_ng" , "Try harder next time." } , // generic "Try Again" message (one-liner)
{ "resultcat0_hi" , "You show strong fundamentals." } , // "Superb" message for input category 0 "normal" (two-liner)
{ "resultcat0_ng" , "Work on your fundamentals." } , // "Try Again" message for input category 0 "normal" (two-liner)
{ "resultcat1_hi" , "You kept the beat well." } , // "Superb" message for input category 1 "keep" (two-liner)
{ "resultcat1_ng" , "You had trouble keeping the beat." } , // "Try Again" message for input category 1 "keep" (two-liner)
{ "resultcat2_hi" , "You had great aim." } , // "Superb" message for input category 2 "aim" (two-liner)
{ "resultcat2_ng" , "Your aim was a little shaky." } , // "Try Again" message for input category 2 "aim" (two-liner)
{ "resultcat3_hi" , "You followed the example well." } , // "Superb" message for input category 3 "repeat" (two-liner)
{ "resultcat3_ng" , "Next time, follow the example better." } , // "Try Again" message for input category 3 "repeat" (two-liner)
{ "epilogue_hi" , "Superb picture" } , // epilogue "Superb" message
{ "epilogue_ok" , "OK picture" } , // epilogue "OK" message
{ "epilogue_ng" , "Try Again picture" } , // epilogue "Try Again" message
{ "epilogue_hi_res" , new EntityTypes . Resource ( EntityTypes . Resource . ResourceType . Image , "Images/Epilogue/" , "Hi" ) } , // epilogue "Superb" image resource path
{ "epilogue_ok_res" , new EntityTypes . Resource ( EntityTypes . Resource . ResourceType . Image , "Images/Epilogue/" , "Ok" ) } , // epilogue "OK" image resource path
{ "epilogue_ng_res" , new EntityTypes . Resource ( EntityTypes . Resource . ResourceType . Image , "Images/Epilogue/" , "Ng" ) } , // epilogue "Try Again" image resource path
} ;
readonly static Dictionary < string , object > tempoChangeModel = new ( )
2023-06-11 16:12:25 +00:00
{
{ "tempo" , 120f } ,
{ "swing" , 0f } ,
{ "timeSignature" , new Vector2 ( 4 , 4 ) } ,
} ;
2023-12-26 05:22:51 +00:00
readonly static Dictionary < string , object > volumeChangeModel = new ( )
2023-06-11 16:12:25 +00:00
{
{ "volume" , 1f } ,
{ "fade" , Util . EasingFunction . Ease . Instant } ,
} ;
2023-12-26 05:22:51 +00:00
readonly static Dictionary < string , object > sectionMarkModel = new ( )
2023-06-11 16:12:25 +00:00
{
{ "sectionName" , "" } ,
{ "startPerfect" , false } ,
2023-12-26 05:22:51 +00:00
{ "weight" , 1f } ,
{ "category" , 0 } ,
2023-06-11 16:12:25 +00:00
} ;
static void PreProcessSpecialEntity ( RiqEntity e , Dictionary < string , object > model )
{
foreach ( var t in model )
{
string propertyName = t . Key ;
Type type = t . Value . GetType ( ) ;
if ( ! e . dynamicData . ContainsKey ( propertyName ) )
{
e . CreateProperty ( propertyName , t . Value ) ;
}
Type pType = e [ propertyName ] . GetType ( ) ;
if ( pType ! = type )
{
try
{
2023-06-14 01:21:13 +00:00
if ( type . IsEnum )
2023-06-11 16:12:25 +00:00
{
2023-06-14 01:21:13 +00:00
if ( pType = = typeof ( string ) )
e . dynamicData [ propertyName ] = ( int ) Enum . Parse ( type , ( string ) e [ propertyName ] ) ;
2023-06-11 16:12:25 +00:00
else
2023-06-14 01:21:13 +00:00
e . dynamicData [ propertyName ] = ( int ) e [ propertyName ] ;
2023-06-11 16:12:25 +00:00
}
else if ( pType = = typeof ( Newtonsoft . Json . Linq . JObject ) )
e [ propertyName ] = e [ propertyName ] . ToObject ( type ) ;
else
e [ propertyName ] = Convert . ChangeType ( e [ propertyName ] , type ) ;
}
catch
{
Debug . LogWarning ( $"Could not convert {propertyName} to {type}! Using default value..." ) ;
// use default value
e . CreateProperty ( propertyName , t . Value ) ;
}
}
}
}
2023-12-26 05:22:51 +00:00
public static string JukeboxAudioConverter ( string filePath , AudioType audioType , string specificType )
{
if ( Directory . Exists ( Path . Combine ( Application . temporaryCachePath , "/savewav" ) ) )
{
Directory . Delete ( Path . Combine ( Application . temporaryCachePath , "/savewav" ) , true ) ;
}
2024-01-10 23:53:57 +00:00
if ( ! Directory . Exists ( Application . temporaryCachePath , "/savewav" ) )
Directory . CreateDirectory ( Application . temporaryCachePath , "/savewav" ) ;
2023-12-26 05:22:51 +00:00
if ( audioType = = AudioType . MPEG )
{
Debug . Log ( $"mp3 loaded, Converting {filePath} to wav..." ) ;
// convert mp3 to wav
// import the mp3 as an audioclip
string url = "file://" + filePath ;
using ( var www = UnityWebRequestMultimedia . GetAudioClip ( url , audioType ) )
{
www . SendWebRequest ( ) ;
while ( ! www . isDone ) { }
if ( www . result = = UnityWebRequest . Result . ConnectionError )
{
Debug . LogError ( $"Could not load audio file {filePath}! Error: {www.error}" ) ;
return filePath ;
}
AudioClip clip = DownloadHandlerAudioClip . GetContent ( www ) ;
string fileName = Path . GetFileNameWithoutExtension ( filePath ) ;
SavWav . Save ( "/savewav/" + fileName , clip , true ) ;
filePath = Path . Combine ( Application . temporaryCachePath , "/savewav/" + fileName + ".wav" ) ;
clip = null ;
}
}
return filePath ;
}
2023-06-10 19:13:29 +00:00
/// <summary>
/// processes an riq beatmap after it is loaded
/// </summary>
public static RiqBeatmapData ? PreProcessBeatmap ( string version , RiqBeatmapData data )
{
Debug . Log ( "Preprocessing beatmap..." ) ;
Minigames . Minigame game ;
Minigames . GameAction action ;
System . Type type , pType ;
2023-12-26 05:22:51 +00:00
if ( EventCaller . instance ! = null )
2023-06-10 19:13:29 +00:00
{
2024-01-08 06:38:05 +00:00
string [ ] split ;
2023-12-26 05:22:51 +00:00
foreach ( var e in data . entities )
2023-06-10 19:13:29 +00:00
{
2024-01-08 06:38:05 +00:00
split = e . datamodel . Split ( '/' ) ;
var gameName = split [ 0 ] ;
var actionName = split [ 1 ] ;
2023-12-26 05:22:51 +00:00
game = EventCaller . instance . GetMinigame ( gameName ) ;
if ( game = = null )
2023-06-10 19:13:29 +00:00
{
2023-12-26 05:22:51 +00:00
Debug . LogWarning ( $"Unknown game {gameName} found in remix.json! Adding game..." ) ;
game = new Minigames . Minigame ( gameName , gameName . DisplayName ( ) + " \n<color=#eb5454>[inferred from remix.json]</color>" , "" , false , false , new List < Minigames . GameAction > ( ) , inferred : true ) ;
2024-01-08 06:38:05 +00:00
EventCaller . instance . minigames . Add ( gameName , game ) ;
2023-12-26 05:22:51 +00:00
if ( Editor . Editor . instance ! = null )
Editor . Editor . instance . AddIcon ( game ) ;
2023-06-10 19:13:29 +00:00
}
2023-12-26 05:22:51 +00:00
action = EventCaller . instance . GetGameAction ( game , actionName ) ;
if ( action = = null )
2023-06-10 19:13:29 +00:00
{
2023-12-26 05:22:51 +00:00
Debug . LogWarning ( $"Unknown action {gameName}/{actionName} found in remix.json! Adding action..." ) ;
var parameters = new List < Minigames . Param > ( ) ;
foreach ( var item in e . dynamicData )
2023-06-10 19:13:29 +00:00
{
2023-12-26 05:22:51 +00:00
Debug . Log ( $"k: {item.Key}, v: {item.Value}" ) ;
if ( item . Key = = "track" )
continue ;
if ( item . Value = = null )
continue ;
var value = item . Value ;
if ( value . GetType ( ) = = typeof ( long ) )
value = new EntityTypes . Integer ( int . MinValue , int . MaxValue , ( int ) value ) ;
else if ( value . GetType ( ) = = typeof ( double ) )
value = new EntityTypes . Float ( float . NegativeInfinity , float . PositiveInfinity , ( float ) value ) ;
parameters . Add ( new Minigames . Param ( item . Key , value , item . Key . DisplayName ( ) , "[inferred from remix.json]" ) ) ;
2023-06-10 19:13:29 +00:00
}
2023-12-26 05:22:51 +00:00
action = new Minigames . GameAction ( actionName , actionName . DisplayName ( ) , e . length , true , parameters ) ;
game . actions . Add ( action ) ;
}
//check each param of the action
if ( action . parameters ! = null )
{
foreach ( var param in action . parameters )
2023-06-10 19:13:29 +00:00
{
2023-12-26 05:22:51 +00:00
type = param . parameter . GetType ( ) ;
//add property if it doesn't exist
if ( ! e . dynamicData . ContainsKey ( param . propertyName ) )
2023-06-10 19:13:29 +00:00
{
2023-12-26 05:22:51 +00:00
Debug . LogWarning ( $"Property {param.propertyName} does not exist in the entity's dynamic data! Adding..." ) ;
2023-06-10 19:13:29 +00:00
if ( type = = typeof ( EntityTypes . Integer ) )
2023-12-26 05:22:51 +00:00
e . dynamicData . Add ( param . propertyName , ( ( EntityTypes . Integer ) param . parameter ) . val ) ;
2023-06-10 19:13:29 +00:00
else if ( type = = typeof ( EntityTypes . Float ) )
2023-12-26 05:22:51 +00:00
e . dynamicData . Add ( param . propertyName , ( ( EntityTypes . Float ) param . parameter ) . val ) ;
2023-06-14 01:21:13 +00:00
else if ( type . IsEnum )
2023-12-26 05:22:51 +00:00
e . dynamicData . Add ( param . propertyName , ( int ) param . parameter ) ;
2023-06-10 19:13:29 +00:00
else
2023-12-26 05:22:51 +00:00
e . dynamicData . Add ( param . propertyName , Convert . ChangeType ( param . parameter , type ) ) ;
continue ;
2023-06-10 19:13:29 +00:00
}
2023-12-26 05:22:51 +00:00
pType = e [ param . propertyName ] . GetType ( ) ;
if ( pType ! = type )
2023-06-10 19:13:29 +00:00
{
2023-12-26 05:22:51 +00:00
try
{
if ( type = = typeof ( EntityTypes . Integer ) )
e . dynamicData [ param . propertyName ] = ( int ) e [ param . propertyName ] ;
else if ( type = = typeof ( EntityTypes . Float ) )
e . dynamicData [ param . propertyName ] = ( float ) e [ param . propertyName ] ;
else if ( type = = typeof ( EntityTypes . Resource ) )
e . dynamicData [ param . propertyName ] = ( EntityTypes . Resource ) e [ param . propertyName ] ;
else if ( type . IsEnum )
{
if ( pType = = typeof ( string ) )
e . dynamicData [ param . propertyName ] = ( int ) Enum . Parse ( type , ( string ) e [ param . propertyName ] ) ;
else
e . dynamicData [ param . propertyName ] = ( int ) e [ param . propertyName ] ;
}
else if ( pType = = typeof ( Newtonsoft . Json . Linq . JObject ) )
e . dynamicData [ param . propertyName ] = e [ param . propertyName ] . ToObject ( type ) ;
else
e . dynamicData [ param . propertyName ] = Convert . ChangeType ( e [ param . propertyName ] , type ) ;
}
catch
{
Debug . LogWarning ( $"Could not convert {param.propertyName} to {type}! Using default value..." ) ;
// GlobalGameManager.ShowErrorMessage("Warning", $"Could not convert {e.datamodel}/{param.propertyName} to {type}! This will be loaded using the default value, so chart may be unstable.");
// use default value
if ( type = = typeof ( EntityTypes . Integer ) )
e . dynamicData [ param . propertyName ] = ( ( EntityTypes . Integer ) param . parameter ) . val ;
else if ( type = = typeof ( EntityTypes . Float ) )
e . dynamicData [ param . propertyName ] = ( ( EntityTypes . Float ) param . parameter ) . val ;
else if ( type . IsEnum & & param . propertyName ! = "ease" )
e . dynamicData [ param . propertyName ] = ( int ) param . parameter ;
else
e . dynamicData [ param . propertyName ] = Convert . ChangeType ( param . parameter , type ) ;
}
2023-06-10 19:13:29 +00:00
}
}
}
}
}
foreach ( var tempo in data . tempoChanges )
{
2023-06-11 16:12:25 +00:00
PreProcessSpecialEntity ( tempo , tempoChangeModel ) ;
2023-06-10 19:13:29 +00:00
}
2023-06-11 19:52:14 +00:00
if ( data . tempoChanges [ 0 ] [ "tempo" ] < = 0 )
{
data . tempoChanges [ 0 ] [ "tempo" ] = 120 ;
}
2023-06-10 19:13:29 +00:00
foreach ( var vol in data . volumeChanges )
{
2023-06-11 16:12:25 +00:00
PreProcessSpecialEntity ( vol , volumeChangeModel ) ;
2023-06-10 19:13:29 +00:00
}
foreach ( var section in data . beatmapSections )
{
2023-06-11 16:12:25 +00:00
PreProcessSpecialEntity ( section , sectionMarkModel ) ;
2023-06-10 19:13:29 +00:00
}
//go thru each property of the model beatmap and add any missing keyvalue pair
foreach ( var prop in propertiesModel )
{
2023-12-26 05:22:51 +00:00
var mType = propertiesModel [ prop . Key ] . GetType ( ) ;
2023-06-10 19:13:29 +00:00
if ( ! data . properties . ContainsKey ( prop . Key ) )
{
data . properties . Add ( prop . Key , prop . Value ) ;
}
2023-12-26 05:22:51 +00:00
else
{
// convert enums to the intended enum type
if ( mType . IsEnum )
{
if ( data . properties [ prop . Key ] . GetType ( ) = = typeof ( string ) )
data . properties [ prop . Key ] = Enum . Parse ( mType , ( string ) data . properties [ prop . Key ] ) ;
2024-01-06 03:51:27 +00:00
else
data . properties [ prop . Key ] = Enum . ToObject ( mType , data . properties [ prop . Key ] ) ;
2023-12-26 05:22:51 +00:00
}
// convert all JObjects to their respective types
else if ( data . properties [ prop . Key ] . GetType ( ) = = typeof ( Newtonsoft . Json . Linq . JObject ) )
{
data . properties [ prop . Key ] = ( data . properties [ prop . Key ] as Newtonsoft . Json . Linq . JObject ) . ToObject ( mType ) ;
}
}
2023-06-10 19:13:29 +00:00
}
return data ;
}
2022-01-17 19:23:18 +00:00
public class Minigame
{
2023-09-11 22:28:04 +00:00
2022-01-17 19:23:18 +00:00
public string name ;
public string displayName ;
public string color ;
2023-10-29 19:44:47 +00:00
public string splitColorL ;
public string splitColorR ;
2023-05-21 17:35:00 +00:00
public bool hidden ;
2022-02-03 03:58:08 +00:00
public bool fxOnly ;
2022-01-17 19:23:18 +00:00
public List < GameAction > actions = new List < GameAction > ( ) ;
2022-06-12 19:32:00 +00:00
public List < string > tags ;
public string defaultLocale = "en" ;
public string wantAssetBundle = "" ;
public List < string > supportedLocales ;
2023-04-02 17:15:19 +00:00
public bool inferred ;
2022-06-12 19:32:00 +00:00
2023-10-29 19:44:47 +00:00
public bool usesAssetBundle = > wantAssetBundle ! = "" ;
public bool hasLocales = > supportedLocales . Count > 0 ;
public bool AssetsLoaded = > ( ( hasLocales & & localeLoaded & & currentLoadedLocale = = defaultLocale ) | | ( ! hasLocales ) ) & & commonLoaded ;
2023-01-12 01:42:12 +00:00
public bool SequencesPreloaded = > soundSequences ! = null ;
2023-04-02 17:15:19 +00:00
public string LoadableName = > inferred ? "noGame" : name ;
2023-10-29 19:44:47 +00:00
public GameObject LoadedPrefab = > loadedPrefab ;
2022-06-12 19:32:00 +00:00
private AssetBundle bundleCommon = null ;
private bool commonLoaded = false ;
private bool commonPreloaded = false ;
private string currentLoadedLocale = "" ;
private AssetBundle bundleLocalized = null ;
private bool localeLoaded = false ;
private bool localePreloaded = false ;
2023-10-29 19:44:47 +00:00
private GameObject loadedPrefab = null ;
private Dictionary < string , AudioClip > commonAudioClips ;
private Dictionary < string , AudioClip > localeAudioClips ;
2022-06-12 19:32:00 +00:00
2023-01-12 01:42:12 +00:00
private SoundSequence . SequenceKeyValue [ ] soundSequences = null ;
public SoundSequence . SequenceKeyValue [ ] LoadedSoundSequences
{
get = > soundSequences ;
set = > soundSequences = value ;
}
2023-10-29 19:44:47 +00:00
public Dictionary < string , AudioClip > CommonAudioClips = > commonAudioClips ;
public Dictionary < string , AudioClip > LocaleAudioClips = > localeAudioClips ;
2023-01-12 01:42:12 +00:00
2023-05-21 17:35:00 +00:00
public Minigame ( string name , string displayName , string color , bool hidden , bool fxOnly , List < GameAction > actions , List < string > tags = null , string assetBundle = "" , string defaultLocale = "en" , List < string > supportedLocales = null , bool inferred = false )
2022-01-17 19:23:18 +00:00
{
this . name = name ;
this . displayName = displayName ;
this . color = color ;
this . actions = actions ;
2023-05-21 17:35:00 +00:00
this . hidden = hidden ;
2022-02-03 03:58:08 +00:00
this . fxOnly = fxOnly ;
2022-06-12 19:32:00 +00:00
this . tags = tags ? ? new List < string > ( ) ;
this . wantAssetBundle = assetBundle ;
this . defaultLocale = defaultLocale ;
this . supportedLocales = supportedLocales ? ? new List < string > ( ) ;
2023-04-02 17:15:19 +00:00
this . inferred = inferred ;
2023-10-29 19:44:47 +00:00
this . splitColorL = null ;
this . splitColorR = null ;
}
public Minigame ( string name , string displayName , string color , string splitColorL , string splitColorR , bool hidden , bool fxOnly , List < GameAction > actions , List < string > tags = null , string assetBundle = "" , string defaultLocale = "en" , List < string > supportedLocales = null , bool inferred = false )
{
this . name = name ;
this . displayName = displayName ;
this . color = color ;
this . actions = actions ;
this . hidden = hidden ;
this . fxOnly = fxOnly ;
this . tags = tags ? ? new List < string > ( ) ;
this . wantAssetBundle = assetBundle ;
this . defaultLocale = defaultLocale ;
this . supportedLocales = supportedLocales ? ? new List < string > ( ) ;
this . inferred = inferred ;
this . splitColorL = splitColorL ;
this . splitColorR = splitColorR ;
2022-06-12 19:32:00 +00:00
}
public AssetBundle GetLocalizedAssetBundle ( )
{
2023-12-26 05:22:51 +00:00
if ( bundleLocalized ! = null & & ! localeLoaded )
{
bundleLocalized . Unload ( true ) ;
bundleLocalized = null ;
localeLoaded = false ;
localePreloaded = false ;
}
2022-06-12 19:32:00 +00:00
if ( ! hasLocales ) return null ;
if ( ! usesAssetBundle ) return null ;
if ( bundleLocalized = = null | | currentLoadedLocale ! = defaultLocale ) //TEMPORARY: use the game's default locale until we add localization support
{
if ( localeLoaded ) return bundleLocalized ;
// TODO: try/catch for missing assetbundles
currentLoadedLocale = defaultLocale ;
bundleLocalized = AssetBundle . LoadFromFile ( Path . Combine ( Application . streamingAssetsPath , wantAssetBundle + "/locale." + defaultLocale ) ) ;
localeLoaded = true ;
}
return bundleLocalized ;
}
public AssetBundle GetCommonAssetBundle ( )
{
2023-12-26 05:22:51 +00:00
if ( bundleCommon ! = null & & ! commonLoaded )
{
bundleCommon . Unload ( true ) ;
bundleCommon = null ;
commonLoaded = false ;
commonPreloaded = false ;
}
2022-06-12 19:32:00 +00:00
if ( commonLoaded ) return bundleCommon ;
if ( ! usesAssetBundle ) return null ;
if ( bundleCommon = = null )
{
// TODO: try/catch for missing assetbundles
bundleCommon = AssetBundle . LoadFromFile ( Path . Combine ( Application . streamingAssetsPath , wantAssetBundle + "/common" ) ) ;
commonLoaded = true ;
}
return bundleCommon ;
}
2023-10-29 19:44:47 +00:00
public async UniTask LoadAssetsAsync ( )
2022-06-12 19:32:00 +00:00
{
2023-10-29 19:44:47 +00:00
if ( AssetsLoaded | | ! usesAssetBundle ) return ;
await UniTask . WhenAll ( LoadCommonAssetBundleAsync ( ) , LoadLocalizedAssetBundleAsync ( ) ) ;
await UniTask . WhenAll ( LoadGamePrefabAsync ( ) ) ;
await UniTask . WhenAll ( LoadCommonAudioClips ( ) ) ;
await UniTask . WhenAll ( LoadLocalizedAudioClips ( ) ) ;
}
2022-06-12 19:32:00 +00:00
2023-10-29 19:44:47 +00:00
public async UniTask LoadCommonAssetBundleAsync ( )
{
2023-12-26 05:22:51 +00:00
if ( bundleCommon ! = null & & ! commonLoaded )
{
await bundleCommon . UnloadAsync ( true ) ;
bundleCommon = null ;
commonLoaded = false ;
commonPreloaded = false ;
}
2023-10-29 19:44:47 +00:00
if ( commonPreloaded | | commonLoaded ) return ;
commonPreloaded = true ;
if ( ! usesAssetBundle ) return ;
if ( bundleCommon ! = null ) return ;
2022-06-12 19:32:00 +00:00
2023-10-29 19:44:47 +00:00
AssetBundle bundle = await AssetBundle . LoadFromFileAsync ( Path . Combine ( Application . streamingAssetsPath , wantAssetBundle + "/common" ) ) . ToUniTask ( ) ;
2022-06-12 19:32:00 +00:00
2023-10-29 19:44:47 +00:00
bundleCommon = bundle ;
2022-06-12 19:32:00 +00:00
commonLoaded = true ;
}
2023-10-29 19:44:47 +00:00
public async UniTask LoadLocalizedAssetBundleAsync ( )
2022-06-12 19:32:00 +00:00
{
2023-12-26 05:22:51 +00:00
if ( bundleLocalized ! = null & & ! localeLoaded )
{
await bundleLocalized . UnloadAsync ( true ) ;
bundleLocalized = null ;
localeLoaded = false ;
localePreloaded = false ;
}
2023-10-29 19:44:47 +00:00
if ( ! hasLocales ) return ;
if ( localePreloaded ) return ;
2022-06-12 19:32:00 +00:00
localePreloaded = true ;
2023-10-29 19:44:47 +00:00
if ( ! usesAssetBundle ) return ;
if ( localeLoaded & & bundleLocalized ! = null & & currentLoadedLocale = = defaultLocale ) return ;
2022-06-12 19:32:00 +00:00
2023-10-29 19:44:47 +00:00
AssetBundle bundle = await AssetBundle . LoadFromFileAsync ( Path . Combine ( Application . streamingAssetsPath , wantAssetBundle + "/locale." + defaultLocale ) ) . ToUniTask ( ) ;
if ( localeLoaded & & bundleLocalized ! = null & & currentLoadedLocale = = defaultLocale ) return ;
2022-06-12 19:32:00 +00:00
2023-10-29 19:44:47 +00:00
bundleLocalized = bundle ;
2022-06-12 19:32:00 +00:00
currentLoadedLocale = defaultLocale ;
localeLoaded = true ;
2022-01-17 19:23:18 +00:00
}
2023-10-29 19:44:47 +00:00
public async UniTask LoadGamePrefabAsync ( )
{
if ( ! usesAssetBundle ) return ;
if ( ! commonLoaded ) return ;
if ( bundleCommon = = null ) return ;
UnityEngine . Object asset = await bundleCommon . LoadAssetAsync < GameObject > ( name ) . ToUniTask ( ) ;
loadedPrefab = asset as GameObject ;
// load sound sequences here for now
// this is taxing and is still done synchronously
// move sequences to their own assets so that we don't have to look up a component
if ( loadedPrefab . TryGetComponent < Games . Minigame > ( out Games . Minigame minigame ) )
{
soundSequences = minigame . SoundSequences ;
}
}
public async UniTask LoadCommonAudioClips ( )
{
if ( ! commonLoaded ) return ;
if ( bundleCommon = = null ) return ;
commonAudioClips = new ( ) ;
var assets = bundleCommon . LoadAllAssetsAsync ( ) ;
await assets ;
// await UniTask.SwitchToThreadPool();
// foreach (var asset in assets.allAssets)
// {
// AudioClip clip = asset as AudioClip;
// commonAudioClips.Add(clip.name, clip);
// }
// await UniTask.SwitchToMainThread();
}
public async UniTask LoadLocalizedAudioClips ( )
{
if ( ! localeLoaded ) return ;
if ( bundleLocalized = = null ) return ;
localeAudioClips = new ( ) ;
var assets = bundleLocalized . LoadAllAssetsAsync ( ) ;
await assets ;
// await UniTask.SwitchToThreadPool();
// foreach (var asset in assets.allAssets)
// {
// AudioClip clip = asset as AudioClip;
// localeAudioClips.Add(clip.name, clip);
// }
// await UniTask.SwitchToMainThread();
}
public async UniTask UnloadAllAssets ( )
{
if ( ! usesAssetBundle ) return ;
commonAudioClips . Clear ( ) ;
localeAudioClips . Clear ( ) ;
if ( loadedPrefab ! = null )
{
loadedPrefab = null ;
}
if ( bundleCommon ! = null )
{
await bundleCommon . UnloadAsync ( true ) ;
bundleCommon = null ;
commonLoaded = false ;
commonPreloaded = false ;
}
if ( bundleLocalized ! = null )
{
await bundleLocalized . UnloadAsync ( true ) ;
bundleLocalized = null ;
localeLoaded = false ;
localePreloaded = false ;
}
}
2022-01-17 19:23:18 +00:00
}
public class GameAction
{
public string actionName ;
2022-08-20 23:03:51 +00:00
public string displayName ;
2022-08-21 03:13:52 +00:00
public EventCallback function = delegate { } ;
public float defaultLength = 1 ;
public bool resizable = false ;
public List < Param > parameters = null ;
public bool hidden = false ;
2023-01-19 02:31:08 +00:00
public int priority = 0 ;
2022-08-21 03:13:52 +00:00
public EventCallback inactiveFunction = delegate { } ;
public EventCallback preFunction = delegate { } ;
2023-02-18 22:12:49 +00:00
public float preFunctionLength = 2.0f ;
2022-01-17 19:23:18 +00:00
2022-03-02 21:59:35 +00:00
/// <summary>
/// <para>Creates a block that can be used in the editor. The block's function and attributes are defined in the parentheses.</para>
/// <para>Note: Every parameter after the second one is an optional parameter. You can change optional parameters by adding (name): (value) after the second parameter.</para>
/// </summary>
2022-08-20 23:03:51 +00:00
/// <param name="actionName">Entity model name</param>
/// <param name="displayName">Name of the block used in the UI</param>
2022-03-02 21:59:35 +00:00
/// <param name="defaultLength">How long the block appears in the editor</param>
/// <param name="resizable">Allows the user to resize the block</param>
/// <param name="parameters">Extra parameters for this block that change how it functions.</param>
2022-08-20 23:03:51 +00:00
/// <param name="function"><para>What the block does when read during playback</para>
/// <para>Only does this if the game that it is associated with is loaded.</para></param>
2022-03-02 21:59:35 +00:00
/// <param name="inactiveFunction">What the block does when read while the game it's associated with isn't loaded.</param>
2022-08-20 23:03:51 +00:00
/// <param name="prescheduleFunction">What the block does when the GameManager seeks to this cue for pre-scheduling.</param>
/// <param name="hidden">Prevents the block from being shown in the game list. Block will still function normally if it is in the timeline.</param>
2023-01-19 02:31:08 +00:00
/// <param name="preFunction">Runs two beats before this event is reached.</param>
/// <param name="priority">Priority of this event. Higher priority events will be run first.</param>
2023-02-18 22:12:49 +00:00
public GameAction ( string actionName , string displayName , float defaultLength = 1 , bool resizable = false , List < Param > parameters = null , EventCallback function = null , EventCallback inactiveFunction = null , EventCallback prescheduleFunction = null , bool hidden = false , EventCallback preFunction = null , int priority = 0 , float preFunctionLength = 2.0f )
2022-01-17 19:23:18 +00:00
{
this . actionName = actionName ;
2022-08-20 23:03:51 +00:00
if ( displayName = = String . Empty ) this . displayName = actionName ;
else this . displayName = displayName ;
2022-01-17 19:23:18 +00:00
this . defaultLength = defaultLength ;
this . resizable = resizable ;
2022-02-03 22:20:26 +00:00
this . parameters = parameters ;
2022-03-01 08:17:06 +00:00
this . hidden = hidden ;
2022-08-20 23:03:51 +00:00
this . function = function ? ? delegate { } ;
this . inactiveFunction = inactiveFunction ? ? delegate { } ;
this . preFunction = prescheduleFunction ? ? delegate { } ;
2023-01-19 02:31:08 +00:00
this . priority = priority ;
2023-02-18 22:12:49 +00:00
this . preFunctionLength = preFunctionLength ;
2022-08-20 23:03:51 +00:00
}
/// <summary>
/// <para>Shorthand constructor for a GameAction with only required data</para>
/// </summary>
/// <param name="actionName">Entity model name</param>
/// <param name="displayName">Name of the block used in the UI</param>
public GameAction ( string actionName , string displayName )
{
this . actionName = actionName ;
if ( displayName = = String . Empty ) this . displayName = actionName ;
else this . displayName = displayName ;
2022-02-03 22:20:26 +00:00
}
}
[System.Serializable]
public class Param
{
public string propertyName ;
public object parameter ;
public string propertyCaption ;
2022-03-01 21:11:19 +00:00
public string tooltip ;
2023-08-16 11:00:27 +00:00
public List < CollapseParam > collapseParams ;
2022-02-03 22:20:26 +00:00
2022-03-02 21:59:35 +00:00
/// <summary>
/// A parameter that changes the function of a GameAction.
/// </summary>
2022-08-20 23:03:51 +00:00
/// <param name="propertyName">The name of the variable that's being changed.</param>
2022-03-02 21:59:35 +00:00
/// <param name="parameter">The value of the parameter</param>
/// <param name="propertyCaption">The name shown in the editor. Can be anything you want.</param>
2023-08-16 11:00:27 +00:00
public Param ( string propertyName , object parameter , string propertyCaption , string tooltip = "" , List < CollapseParam > collapseParams = null )
2022-02-03 22:20:26 +00:00
{
this . propertyName = propertyName ;
this . parameter = parameter ;
this . propertyCaption = propertyCaption ;
2022-03-01 21:11:19 +00:00
this . tooltip = tooltip ;
2023-08-16 11:00:27 +00:00
this . collapseParams = collapseParams ;
}
public class CollapseParam
{
2023-10-27 20:19:11 +00:00
public Func < object , RiqEntity , bool > CollapseOn ;
2023-08-16 11:00:27 +00:00
public string [ ] collapseables ;
/// <summary>
/// Class that decides how other parameters will be collapsed
/// </summary>
/// <param name="collapseOn">What values should make it collapse/uncollapse?</param>
/// <param name="collapseables">IDs of the parameters to collapse</param>
2023-10-27 20:19:11 +00:00
public CollapseParam ( Func < object , RiqEntity , bool > collapseOn , string [ ] collapseables )
2023-08-16 11:00:27 +00:00
{
CollapseOn = collapseOn ;
this . collapseables = collapseables ;
}
2022-01-17 19:23:18 +00:00
}
}
public delegate void EventCallback ( ) ;
2023-06-10 19:13:29 +00:00
public delegate void ParamChangeCallback ( string paramName , object paramValue , RiqEntity entity ) ;
2022-01-17 19:23:18 +00:00
2022-04-12 16:14:46 +00:00
// overengineered af but it's a modified version of
// https://stackoverflow.com/a/19877141
static List < Func < EventCaller , Minigame > > loadRunners ;
2023-09-11 22:28:04 +00:00
static void BuildLoadRunnerList ( )
{
2022-04-12 16:14:46 +00:00
loadRunners = System . Reflection . Assembly . GetExecutingAssembly ( )
. GetTypes ( )
. Where ( x = > x . Namespace = = "HeavenStudio.Games.Loaders" & & x . GetMethod ( "AddGame" , BindingFlags . Public | BindingFlags . Static ) ! = null )
2023-09-11 22:28:04 +00:00
. Select ( t = > ( Func < EventCaller , Minigame > ) Delegate . CreateDelegate (
typeof ( Func < EventCaller , Minigame > ) ,
null ,
2022-04-12 16:14:46 +00:00
t . GetMethod ( "AddGame" , BindingFlags . Public | BindingFlags . Static ) ,
false
) )
. ToList ( ) ;
2023-09-11 22:28:04 +00:00
2022-04-12 16:14:46 +00:00
}
2022-01-17 19:23:18 +00:00
public static void Init ( EventCaller eventCaller )
{
2024-01-08 06:38:05 +00:00
List < Minigame > defaultGames = new ( )
2022-01-17 19:23:18 +00:00
{
2022-02-03 03:58:08 +00:00
new Minigame ( "gameManager" , "Game Manager" , "" , false , true , new List < GameAction > ( )
2022-01-17 19:23:18 +00:00
{
2023-09-11 22:28:04 +00:00
new GameAction ( "switchGame" , "Switch Game" , 0.5f , false ,
function : delegate { var e = eventCaller . currentEntity ; GameManager . instance . SwitchGame ( eventCaller . currentSwitchGame , eventCaller . currentEntity . beat , e [ "toggle" ] ) ; } ,
2023-04-07 15:15:19 +00:00
parameters : new List < Param > ( )
{
2023-10-29 19:44:47 +00:00
new Param ( "toggle" , true , "Black Flash" , "Enable or disable the black screen for this Game Switch" )
2023-04-07 15:15:19 +00:00
} ,
inactiveFunction : delegate { var e = eventCaller . currentEntity ; GameManager . instance . SwitchGame ( eventCaller . currentSwitchGame , eventCaller . currentEntity . beat , e [ "toggle" ] ) ; }
2022-08-20 23:03:51 +00:00
) ,
new GameAction ( "end" , "End Remix" ,
2023-09-11 22:28:04 +00:00
function : delegate {
Debug . Log ( "end" ) ;
2022-08-20 23:03:51 +00:00
if ( Timeline . instance ! = null )
2023-10-29 19:44:47 +00:00
Timeline . instance ? . Stop ( Timeline . instance . PlaybackBeat ) ;
2022-08-20 23:03:51 +00:00
else
2023-12-26 05:22:51 +00:00
GameManager . instance . Stop ( eventCaller . currentEntity . beat ) ;
2022-08-20 23:03:51 +00:00
}
) ,
2023-03-11 04:51:22 +00:00
new GameAction ( "skill star" , "Skill Star" , 1f , true )
{
//temp for testing
function = delegate {
var e = eventCaller . currentEntity ;
2023-11-23 21:31:23 +00:00
Common . SkillStarManager . instance . DoStarIn ( e . beat , e . length ) ;
2023-03-11 04:51:22 +00:00
}
} ,
2022-08-20 23:03:51 +00:00
new GameAction ( "toggle inputs" , "Toggle Inputs" , 0.5f , true ,
new List < Param > ( )
{
new Param ( "toggle" , true , "Enable Inputs" )
} ,
delegate
{
2022-08-21 23:46:45 +00:00
GameManager . instance . ToggleInputs ( eventCaller . currentEntity [ "toggle" ] ) ;
2022-08-20 23:03:51 +00:00
}
) ,
2022-02-08 01:07:03 +00:00
2022-08-20 23:03:51 +00:00
// These are still here for backwards-compatibility but are hidden in the editor
2023-09-11 22:28:04 +00:00
new GameAction ( "flash" , "" , 1f , true ,
2022-08-20 23:03:51 +00:00
new List < Param > ( )
{
new Param ( "colorA" , Color . white , "Start Color" ) ,
new Param ( "colorB" , Color . white , "End Color" ) ,
new Param ( "valA" , new EntityTypes . Float ( 0 , 1 , 1 ) , "Start Opacity" ) ,
new Param ( "valB" , new EntityTypes . Float ( 0 , 1 , 0 ) , "End Opacity" ) ,
2023-06-10 19:13:29 +00:00
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" )
2022-08-20 23:03:51 +00:00
} ,
hidden : true
) ,
2023-09-11 22:28:04 +00:00
new GameAction ( "move camera" , "" , 1f , true , new List < Param > ( )
2022-05-16 05:29:39 +00:00
{
new Param ( "valA" , new EntityTypes . Float ( - 50 , 50 , 0 ) , "Right / Left" ) ,
new Param ( "valB" , new EntityTypes . Float ( - 50 , 50 , 0 ) , "Up / Down" ) ,
new Param ( "valC" , new EntityTypes . Float ( - 0 , 250 , 10 ) , "In / Out" ) ,
2023-06-10 19:13:29 +00:00
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease Type" )
2022-06-04 03:15:05 +00:00
} ,
hidden : true ) ,
2023-09-11 22:28:04 +00:00
new GameAction ( "rotate camera" , "" , 1f , true , new List < Param > ( )
2022-05-16 05:29:39 +00:00
{
new Param ( "valA" , new EntityTypes . Integer ( - 360 , 360 , 0 ) , "Pitch" ) ,
new Param ( "valB" , new EntityTypes . Integer ( - 360 , 360 , 0 ) , "Yaw" ) ,
new Param ( "valC" , new EntityTypes . Integer ( - 360 , 360 , 0 ) , "Roll" ) ,
2023-06-10 19:13:29 +00:00
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease Type" )
2022-06-04 03:15:05 +00:00
} ,
hidden : true ) ,
2022-01-17 19:23:18 +00:00
} ) ,
2022-07-28 23:07:19 +00:00
2022-02-03 03:58:08 +00:00
new Minigame ( "countIn" , "Count-Ins" , "" , false , true , new List < GameAction > ( )
{
2022-08-20 23:03:51 +00:00
new GameAction ( "4 beat count-in" , "4 Beat Count-In" , 4f , true ,
new List < Param > ( )
{
new Param ( "type" , SoundEffects . CountInType . Normal , "Type" , "The sounds to play for the count-in" )
} ,
2022-08-21 23:46:45 +00:00
delegate { var e = eventCaller . currentEntity ; SoundEffects . FourBeatCountIn ( e . beat , e . length / 4f , e [ "type" ] ) ; }
2022-08-20 23:03:51 +00:00
) ,
new GameAction ( "8 beat count-in" , "8 Beat Count-In" , 8f , true ,
new List < Param > ( )
{
new Param ( "type" , SoundEffects . CountInType . Normal , "Type" , "The sounds to play for the count-in" )
} ,
2022-08-21 23:46:45 +00:00
delegate { var e = eventCaller . currentEntity ; SoundEffects . EightBeatCountIn ( e . beat , e . length / 8f , e [ "type" ] ) ; }
2022-08-20 23:03:51 +00:00
) ,
new GameAction ( "count" , "Count" , 1f , false ,
new List < Param > ( )
{
new Param ( "type" , SoundEffects . CountNumbers . One , "Number" , "The sound to play" ) ,
new Param ( "toggle" , false , "Alt" , "Whether or not the alternate version should be played" )
} ,
2022-08-21 23:46:45 +00:00
delegate { var e = eventCaller . currentEntity ; SoundEffects . Count ( e [ "type" ] , e [ "toggle" ] ) ; }
2022-08-20 23:03:51 +00:00
) ,
new GameAction ( "cowbell" , "Cowbell" ,
function : delegate { SoundEffects . Cowbell ( ) ; }
) ,
new GameAction ( "ready!" , "Ready!" , 2f , true ,
function : delegate { var e = eventCaller . currentEntity ; SoundEffects . Ready ( e . beat , e . length / 2f ) ; }
) ,
new GameAction ( "and" , "And" , 0.5f ,
function : delegate { SoundEffects . And ( ) ; }
) ,
2023-09-11 22:28:04 +00:00
new GameAction ( "go!" , "Go!" , 1f , false ,
2022-08-20 23:03:51 +00:00
new List < Param > ( )
{
new Param ( "toggle" , false , "Alt" , "Whether or not the alternate version should be played" )
} ,
2022-08-21 23:46:45 +00:00
function : delegate { SoundEffects . Go ( eventCaller . currentEntity [ "toggle" ] ) ; }
2022-08-20 23:03:51 +00:00
) ,
2022-03-01 19:21:23 +00:00
// These are still here for backwards-compatibility but are hidden in the editor
2022-08-20 23:03:51 +00:00
new GameAction ( "4 beat count-in (alt)" , "" , 4f , function : delegate { var e = eventCaller . currentEntity ; SoundEffects . FourBeatCountIn ( e . beat , e . length , 1 ) ; } , hidden : true ) ,
new GameAction ( "4 beat count-in (cowbell)" , "" , 4f , function : delegate { var e = eventCaller . currentEntity ; SoundEffects . FourBeatCountIn ( e . beat , e . length , 2 ) ; } , hidden : true ) ,
new GameAction ( "8 beat count-in (alt)" , "" , 8f , function : delegate { var e = eventCaller . currentEntity ; SoundEffects . EightBeatCountIn ( e . beat , e . length , 1 ) ; } , hidden : true ) ,
new GameAction ( "8 beat count-in (cowbell)" , "" , 8f , function : delegate { var e = eventCaller . currentEntity ; SoundEffects . EightBeatCountIn ( e . beat , e . length , 2 ) ; } , hidden : true ) ,
new GameAction ( "one" , "" , function : delegate { SoundEffects . Count ( 0 , false ) ; } , hidden : true ) ,
new GameAction ( "two" , "" , function : delegate { SoundEffects . Count ( 1 , false ) ; } , hidden : true ) ,
new GameAction ( "three" , "" , function : delegate { SoundEffects . Count ( 2 , false ) ; } , hidden : true ) ,
new GameAction ( "four" , "" , function : delegate { SoundEffects . Count ( 3 , false ) ; } , hidden : true ) ,
new GameAction ( "one (alt)" , "" , function : delegate { SoundEffects . Count ( 0 , true ) ; } , hidden : true ) ,
new GameAction ( "two (alt)" , "" , function : delegate { SoundEffects . Count ( 1 , true ) ; } , hidden : true ) ,
new GameAction ( "three (alt)" , "" , function : delegate { SoundEffects . Count ( 2 , true ) ; } , hidden : true ) ,
new GameAction ( "four (alt)" , "" , function : delegate { SoundEffects . Count ( 3 , true ) ; } , hidden : true ) ,
new GameAction ( "go! (alt)" , "" , function : delegate { SoundEffects . Go ( true ) ; } , hidden : true ) ,
2022-02-03 03:58:08 +00:00
} ) ,
2022-07-28 23:07:19 +00:00
2022-06-04 03:15:05 +00:00
new Minigame ( "vfx" , "Visual Effects" , "" , false , true , new List < GameAction > ( )
{
2023-09-11 22:28:04 +00:00
new GameAction ( "flash" , "Flash" , 1f , true ,
2022-08-20 23:03:51 +00:00
new List < Param > ( )
{
new Param ( "colorA" , Color . white , "Start Color" ) ,
new Param ( "colorB" , Color . white , "End Color" ) ,
new Param ( "valA" , new EntityTypes . Float ( 0 , 1 , 1 ) , "Start Opacity" ) ,
new Param ( "valB" , new EntityTypes . Float ( 0 , 1 , 0 ) , "End Opacity" ) ,
2023-11-23 21:31:23 +00:00
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "" , new ( )
{
new ( ( x , y ) = > ( Util . EasingFunction . Ease ) x ! = Util . EasingFunction . Ease . Instant , new string [ ] { "colorA" , "valA" } )
} )
2022-08-20 23:03:51 +00:00
}
) ,
2023-01-27 03:42:16 +00:00
new GameAction ( "filter" , "Filter" , 1f , true ,
new List < Param > ( )
{
new Param ( "filter" , Games . Global . Filter . FilterType . grayscale , "Filter" ) ,
2023-11-20 19:54:48 +00:00
// old
/ * new Param ( "inten" , new EntityTypes . Float ( 0 , 100 , 100 ) , "Intensity" ) ,
2023-01-27 03:42:16 +00:00
new Param ( "fadein" , new EntityTypes . Float ( 0 , 100 , 0 ) , "Fade In" ) ,
2023-11-20 19:54:48 +00:00
new Param ( "fadeout" , new EntityTypes . Float ( 0 , 100 , 0 ) , "Fade Out" ) * /
// new
2023-11-24 15:46:21 +00:00
new Param ( "slot" , new EntityTypes . Integer ( 1 , 10 , 1 ) , "Slot" , "Slot 1 is activated first and slot 10 last." ) ,
2023-11-20 19:54:48 +00:00
new Param ( "start" , new EntityTypes . Float ( 0 , 1 , 1 ) , "Start Intensity" ) ,
new Param ( "end" , new EntityTypes . Float ( 0 , 1 , 1 ) , "End Intensity" ) ,
2023-11-23 21:31:23 +00:00
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "" , new ( )
{
new ( ( x , y ) = > ( Util . EasingFunction . Ease ) x ! = Util . EasingFunction . Ease . Instant , new string [ ] { "start" } )
} ) ,
2023-01-27 03:42:16 +00:00
}
) ,
2023-09-11 22:28:04 +00:00
new GameAction ( "move camera" , "Move Camera" , 1f , true , new List < Param > ( )
2022-08-20 23:03:51 +00:00
{
2023-03-11 04:51:22 +00:00
new Param ( "valA" , new EntityTypes . Float ( - 50 , 50 , 0 ) , "Right / Left" , "Next position on the X axis" ) ,
new Param ( "valB" , new EntityTypes . Float ( - 50 , 50 , 0 ) , "Up / Down" , "Next position on the Y axis" ) ,
new Param ( "valC" , new EntityTypes . Float ( - 0 , 250 , 10 ) , "In / Out" , "Next position on the Z axis" ) ,
2023-06-10 19:13:29 +00:00
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease Type" ) ,
2023-03-11 04:51:22 +00:00
new Param ( "axis" , GameCamera . CameraAxis . All , "Axis" , "The axis to move the camera on" )
2022-08-20 23:03:51 +00:00
}
) ,
2023-09-11 22:28:04 +00:00
new GameAction ( "rotate camera" , "Rotate Camera" , 1f , true , new List < Param > ( )
2022-08-20 23:03:51 +00:00
{
2023-03-11 04:51:22 +00:00
new Param ( "valA" , new EntityTypes . Integer ( - 360 , 360 , 0 ) , "Pitch" , "Next rotation on the X axis" ) ,
new Param ( "valB" , new EntityTypes . Integer ( - 360 , 360 , 0 ) , "Yaw" , "Next rotation on the Y axis" ) ,
new Param ( "valC" , new EntityTypes . Integer ( - 360 , 360 , 0 ) , "Roll" , "Next rotation on the Z axis" ) ,
2023-06-10 19:13:29 +00:00
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease Type" ) ,
2023-03-11 04:51:22 +00:00
new Param ( "axis" , GameCamera . CameraAxis . All , "Axis" , "The axis to move the camera on" )
2023-09-11 22:28:04 +00:00
}
2022-08-20 23:03:51 +00:00
) ,
2023-11-25 16:05:20 +00:00
new ( "stretch camera" , "Stretch Camera" )
{
resizable = true ,
parameters = new ( )
{
new ( "x1" , new EntityTypes . Float ( 0f , 50f , 1f ) , "Start Width" ) ,
new ( "y1" , new EntityTypes . Float ( 0f , 50f , 1f ) , "Start Height" ) ,
new ( "x2" , new EntityTypes . Float ( 0f , 50f , 1f ) , "End Width" ) ,
new ( "y2" , new EntityTypes . Float ( 0f , 50f , 1f ) , "End Height" ) ,
new ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "" , new ( )
{
new ( ( x , y ) = > ( Util . EasingFunction . Ease ) x ! = Util . EasingFunction . Ease . Instant , new string [ ] { "x1" , "y1" } )
} ) ,
new Param ( "axis" , GameCamera . CameraAxis . All , "Axis" )
}
} ,
2023-07-17 15:56:57 +00:00
new GameAction ( "camera background color" , "Camera Background Color" , 1 , true , new List < Param > ( )
{
new Param ( "color" , Color . black , "Start Color" ) ,
new Param ( "color2" , Color . black , "End Color" ) ,
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease Type" )
}
) ,
2023-09-11 22:28:04 +00:00
new GameAction ( "pan view" , "Pan Viewport" , 1f , true , new List < Param > ( )
2023-03-11 04:51:22 +00:00
{
new Param ( "valA" , new EntityTypes . Float ( - 50 , 50 , 0 ) , "Right / Left" , "Next position on the X axis" ) ,
new Param ( "valB" , new EntityTypes . Float ( - 50 , 50 , 0 ) , "Up / Down" , "Next position on the Y axis" ) ,
2023-06-10 19:13:29 +00:00
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease Type" ) ,
2023-03-11 04:51:22 +00:00
new Param ( "axis" , StaticCamera . ViewAxis . All , "Axis" , "The axis to pan the viewport in" )
}
) ,
2023-09-11 22:28:04 +00:00
new GameAction ( "rotate view" , "Rotate Viewport" , 1f , true , new List < Param > ( )
2023-03-11 04:51:22 +00:00
{
new Param ( "valA" , new EntityTypes . Float ( - 360 , 360 , 0 ) , "Rotation" , "Next viewport rotation" ) ,
2023-06-10 19:13:29 +00:00
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease Type" ) ,
2023-03-11 04:51:22 +00:00
}
) ,
2023-09-11 22:28:04 +00:00
new GameAction ( "scale view" , "Scale Viewport" , 1f , true , new List < Param > ( )
2023-03-11 04:51:22 +00:00
{
new Param ( "valA" , new EntityTypes . Float ( 0 , 50 , 1 ) , "Width" , "Next viewport width" ) ,
new Param ( "valB" , new EntityTypes . Float ( 0 , 50 , 1 ) , "Height" , "Next viewport height" ) ,
2023-06-10 19:13:29 +00:00
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease Type" ) ,
2023-03-11 04:51:22 +00:00
new Param ( "axis" , StaticCamera . ViewAxis . All , "Axis" , "The axis to scale the viewport in" )
}
) ,
2022-08-20 23:03:51 +00:00
new GameAction ( "screen shake" , "Screen Shake" , 1f , true ,
new List < Param > ( )
{
new Param ( "valA" , new EntityTypes . Float ( 0 , 10 , 0 ) , "Horizontal Intensity" ) ,
new Param ( "valB" , new EntityTypes . Float ( 0 , 10 , 1 ) , "Vertical Intensity" )
}
) ,
2023-09-11 22:28:04 +00:00
new GameAction ( "display textbox" , "Display Textbox" , 1f , true , new List < Param > ( )
2022-08-20 23:03:51 +00:00
{
new Param ( "text1" , "" , "Text" , "The text to display in the textbox (Rich Text is supported!)" ) ,
new Param ( "type" , Games . Global . Textbox . TextboxAnchor . TopMiddle , "Anchor" , "Where to anchor the textbox" ) ,
new Param ( "valA" , new EntityTypes . Float ( 0.25f , 4 , 1 ) , "Textbox Width" , "Textbox width multiplier" ) ,
new Param ( "valB" , new EntityTypes . Float ( 0.5f , 8 , 1 ) , "Textbox Height" , "Textbox height multiplier" )
}
) ,
2023-09-11 22:28:04 +00:00
new GameAction ( "display open captions" , "Display Open Captions" , 1f , true ,
new List < Param > ( )
2022-08-20 23:03:51 +00:00
{
new Param ( "text1" , "" , "Text" , "The text to display in the captions (Rich Text is supported!)" ) ,
new Param ( "type" , Games . Global . Textbox . TextboxAnchor . BottomMiddle , "Anchor" , "Where to anchor the captions" ) ,
new Param ( "valA" , new EntityTypes . Float ( 0.25f , 4 , 1 ) , "Captions Width" , "Captions width multiplier" ) ,
new Param ( "valB" , new EntityTypes . Float ( 0.5f , 8 , 1 ) , "Captions Height" , "Captions height multiplier" )
2023-09-11 22:28:04 +00:00
}
2022-08-20 23:03:51 +00:00
) ,
2023-09-11 22:28:04 +00:00
new GameAction ( "display closed captions" , "Display Closed Captions" , 1f , true ,
new List < Param > ( )
2022-08-20 23:03:51 +00:00
{
new Param ( "text1" , "" , "Text" , "The text to display in the captions (Rich Text is supported!)" ) ,
new Param ( "type" , Games . Global . Textbox . ClosedCaptionsAnchor . Top , "Anchor" , "Where to anchor the captions" ) ,
new Param ( "valA" , new EntityTypes . Float ( 0.5f , 4 , 1 ) , "Captions Height" , "Captions height multiplier" )
}
) ,
2023-09-11 22:28:04 +00:00
new GameAction ( "display song artist" , "Display Song Info" , 1f , true ,
2022-08-20 23:03:51 +00:00
new List < Param > ( )
{
new Param ( "text1" , "" , "Title" , "Text to display in the upper label (Rich Text is supported!)" ) ,
new Param ( "text2" , "" , "Artist" , "Text to display in the lower label (Rich Text is supported!)" ) ,
2023-10-29 19:44:47 +00:00
new Param ( "instantOn" , false , "Instant Show" , "Skip the show animation?" ) ,
new Param ( "instantOff" , false , "Instant Hide" , "Skip the hide animation?" ) ,
2022-08-20 23:03:51 +00:00
}
) ,
2023-11-23 21:31:23 +00:00
// Post Processing VFX
new GameAction ( "vignette" , "Vignette" )
{
resizable = true ,
parameters = new ( )
{
new ( "intenStart" , new EntityTypes . Float ( 0f , 1f ) , "Start Intensity" ) ,
new ( "intenEnd" , new EntityTypes . Float ( 0f , 1f , 1f ) , "End Intensity" ) ,
new ( "colorStart" , Color . black , "Start Color" ) ,
new ( "colorEnd" , Color . black , "End Color" ) ,
new ( "smoothStart" , new EntityTypes . Float ( 0.01f , 1f , 0.2f ) , "Start Smoothness" ) ,
new ( "smoothEnd" , new EntityTypes . Float ( 0.01f , 1f , 0.2f ) , "End Smoothness" ) ,
new ( "roundStart" , new EntityTypes . Float ( 0f , 1f , 1f ) , "Start Roundness" ) ,
new ( "roundEnd" , new EntityTypes . Float ( 0f , 1f , 1f ) , "End Roundness" ) ,
new ( "rounded" , false , "Rounded" ) ,
new ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "" , new ( )
{
new ( ( x , y ) = > ( Util . EasingFunction . Ease ) x ! = Util . EasingFunction . Ease . Instant , new string [ ] { "intenStart" , "colorStart" , "smoothStart" , "roundStart" } )
} ) ,
}
} ,
new GameAction ( "cabb" , "Chromatic Abberation" )
{
resizable = true ,
parameters = new ( )
{
new ( "intenStart" , new EntityTypes . Float ( 0f , 1f ) , "Start Intensity" ) ,
new ( "intenEnd" , new EntityTypes . Float ( 0f , 1f , 1f ) , "End Intensity" ) ,
new ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "" , new ( )
{
new ( ( x , y ) = > ( Util . EasingFunction . Ease ) x ! = Util . EasingFunction . Ease . Instant , new string [ ] { "intenStart" } )
} ) ,
}
} ,
new GameAction ( "bloom" , "Bloom" )
{
resizable = true ,
parameters = new ( )
{
new ( "intenStart" , new EntityTypes . Float ( 0f , 100f , 0f ) , "Start Intensity" ) ,
new ( "intenEnd" , new EntityTypes . Float ( 0f , 100f , 1f ) , "End Intensity" ) ,
new ( "colorStart" , Color . white , "Start Tint" ) ,
new ( "colorEnd" , Color . white , "End Tint" ) ,
new ( "thresholdStart" , new EntityTypes . Float ( 0f , 100f , 1f ) , "Start Threshold" ) ,
new ( "thresholdEnd" , new EntityTypes . Float ( 0f , 100f , 1f ) , "End Threshold" ) ,
new ( "softKneeStart" , new EntityTypes . Float ( 0f , 1f , 0.5f ) , "Start Soft Knee" ) ,
new ( "softKneeEnd" , new EntityTypes . Float ( 0f , 1f , 0.5f ) , "End Soft Knee" ) ,
new ( "anaStart" , new EntityTypes . Float ( - 1f , 1f , 0f ) , "Start Anamorphic Ratio" ) ,
new ( "anaEnd" , new EntityTypes . Float ( - 1f , 1f , 0f ) , "End Anamorphic Ratio" ) ,
new ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "" , new ( )
{
new ( ( x , y ) = > ( Util . EasingFunction . Ease ) x ! = Util . EasingFunction . Ease . Instant , new string [ ] { "intenStart" , "colorStart" , "thresholdStart" , "softKneeStart" , "anaStart" } )
} ) ,
}
} ,
new GameAction ( "lensD" , "Lens Distortion" )
{
resizable = true ,
parameters = new ( )
{
new ( "intenStart" , new EntityTypes . Float ( - 100f , 100f , 0f ) , "Start Intensity" ) ,
new ( "intenEnd" , new EntityTypes . Float ( - 100f , 100f , 1f ) , "End Intensity" ) ,
new ( "xStart" , new EntityTypes . Float ( 0f , 1f , 1f ) , "Start X Multiplier" ) ,
new ( "yStart" , new EntityTypes . Float ( 0f , 1f , 1f ) , "Start Y Multiplier" ) ,
new ( "xEnd" , new EntityTypes . Float ( 0f , 1f , 1f ) , "End X Multiplier" ) ,
new ( "yEnd" , new EntityTypes . Float ( 0f , 1f , 1f ) , "End Y Multiplier" ) ,
new ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "" , new ( )
{
new ( ( x , y ) = > ( Util . EasingFunction . Ease ) x ! = Util . EasingFunction . Ease . Instant , new string [ ] { "intenStart" , "xStart" , "yStart" } )
} ) ,
}
} ,
new GameAction ( "grain" , "Grain" )
{
resizable = true ,
parameters = new ( )
{
new ( "intenStart" , new EntityTypes . Float ( 0f , 1f ) , "Start Intensity" ) ,
new ( "intenEnd" , new EntityTypes . Float ( 0f , 1f , 1f ) , "End Intensity" ) ,
new ( "sizeStart" , new EntityTypes . Float ( 0.3f , 3f , 1f ) , "Start Size" ) ,
new ( "sizeEnd" , new EntityTypes . Float ( 0.3f , 3f , 1f ) , "End Size" ) ,
new ( "colored" , true , "Colored" ) ,
new ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "" , new ( )
{
new ( ( x , y ) = > ( Util . EasingFunction . Ease ) x ! = Util . EasingFunction . Ease . Instant , new string [ ] { "intenStart" , "sizeStart" } )
} ) ,
}
} ,
new GameAction ( "colorGrading" , "Color Grading" )
{
resizable = true ,
parameters = new ( )
{
new ( "tempStart" , new EntityTypes . Float ( - 100f , 100f ) , "Start Temperature" ) ,
new ( "tempEnd" , new EntityTypes . Float ( - 100f , 100f ) , "End Temperature" ) ,
new ( "tintStart" , new EntityTypes . Float ( - 100f , 100f ) , "Start Tint" ) ,
new ( "tintEnd" , new EntityTypes . Float ( - 100f , 100f ) , "End Tint" ) ,
new ( "colorStart" , Color . white , "Start Color Filter" ) ,
new ( "colorEnd" , Color . white , "End Color Filter" ) ,
new ( "hueShiftStart" , new EntityTypes . Float ( - 180f , 180f ) , "Start Hue Shift" ) ,
new ( "hueShiftEnd" , new EntityTypes . Float ( - 180f , 180f ) , "End Hue Shift" ) ,
new ( "satStart" , new EntityTypes . Float ( - 100f , 100f ) , "Start Saturation" ) ,
new ( "satEnd" , new EntityTypes . Float ( - 100f , 100f ) , "End Saturation" ) ,
new ( "brightStart" , new EntityTypes . Float ( - 100f , 100f ) , "Start Brightness" ) ,
new ( "brightEnd" , new EntityTypes . Float ( - 100f , 100f ) , "End Brightness" ) ,
new ( "conStart" , new EntityTypes . Float ( - 100f , 100f ) , "Start Contrast" ) ,
new ( "conEnd" , new EntityTypes . Float ( - 100f , 100f ) , "End Contrast" ) ,
new ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "" , new ( )
{
new ( ( x , y ) = > ( Util . EasingFunction . Ease ) x ! = Util . EasingFunction . Ease . Instant , new string [ ] { "tempStart" , "tintStart" , "colorStart" , "hueShiftStart" , "satStart" , "brightStart" , "conStart" } )
} ) ,
}
} ,
2023-11-24 22:49:59 +00:00
new GameAction ( "fitScreen" , "Fit Game To Screen" )
{
defaultLength = 0.5f ,
parameters = new ( )
{
new ( "enable" , true , "Enabled" )
}
} ,
new GameAction ( "screenTiling" , "Tile Screen" )
2023-11-23 21:31:23 +00:00
{
resizable = true ,
parameters = new ( )
{
new ( "xStart" , new EntityTypes . Float ( 1 , 100 , 1 ) , "Start Horizontal Tiles" ) ,
new ( "yStart" , new EntityTypes . Float ( 1 , 100 , 1 ) , "Start Vertical Tiles" ) ,
new ( "xEnd" , new EntityTypes . Float ( 1 , 100 , 1 ) , "End Horizontal Tiles" ) ,
new ( "yEnd" , new EntityTypes . Float ( 1 , 100 , 1 ) , "End Vertical Tiles" ) ,
2023-11-24 22:49:59 +00:00
new Param ( "axis" , StaticCamera . ViewAxis . All , "Axis" ) ,
new ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "" , new ( )
{
new ( ( x , y ) = > ( Util . EasingFunction . Ease ) x ! = Util . EasingFunction . Ease . Instant , new string [ ] { "xStart" , "yStart" } )
} ) ,
}
} ,
new GameAction ( "scrollTiles" , "Scroll Tiles" )
{
resizable = true ,
parameters = new ( )
{
2023-11-23 21:31:23 +00:00
new ( "xScrollStart" , new EntityTypes . Float ( - 100 , 100 , 0 ) , "Start Horizontal Scroll" ) ,
new ( "yScrollStart" , new EntityTypes . Float ( - 100 , 100 , 0 ) , "Start Vertical Scroll" ) ,
new ( "xScrollEnd" , new EntityTypes . Float ( - 100 , 100 , 0 ) , "End Horizontal Scroll" ) ,
new ( "yScrollEnd" , new EntityTypes . Float ( - 100 , 100 , 0 ) , "End Vertical Scroll" ) ,
2023-11-24 22:49:59 +00:00
new Param ( "axis" , StaticCamera . ViewAxis . All , "Axis" ) ,
2023-11-23 21:31:23 +00:00
new ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "" , new ( )
{
2023-11-24 22:49:59 +00:00
new ( ( x , y ) = > ( Util . EasingFunction . Ease ) x ! = Util . EasingFunction . Ease . Instant , new string [ ] { "xScrollStart" , "yScrollStart" } )
2023-11-23 21:31:23 +00:00
} ) ,
}
}
2022-06-04 03:15:05 +00:00
} ) ,
2022-01-17 19:23:18 +00:00
} ;
2022-06-04 03:15:05 +00:00
2024-01-08 06:38:05 +00:00
foreach ( var game in defaultGames )
{
eventCaller . minigames . Add ( game . name , game ) ;
}
2022-04-12 16:14:46 +00:00
BuildLoadRunnerList ( ) ;
2024-01-08 06:38:05 +00:00
Debug . Log ( $"Running {loadRunners.Count} game loaders..." ) ;
2023-09-11 22:28:04 +00:00
foreach ( var load in loadRunners )
2022-04-12 17:30:22 +00:00
{
Debug . Log ( "Running game loader " + RuntimeReflectionExtensions . GetMethodInfo ( load ) . DeclaringType . Name ) ;
2024-01-08 06:38:05 +00:00
Minigame game = load ( eventCaller ) ;
if ( game = = null )
{
Debug . LogError ( "Game loader " + RuntimeReflectionExtensions . GetMethodInfo ( load ) . DeclaringType . Name + " failed!" ) ;
continue ;
}
eventCaller . minigames . Add ( game . name , game ) ;
2022-04-12 17:30:22 +00:00
}
2022-01-17 19:23:18 +00:00
}
}
2024-01-10 23:53:57 +00:00
}