mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 21:47:39 +02:00
event caller refactoring
change operation order of minigame loading
This commit is contained in:
@ -8,6 +8,7 @@ namespace HeavenStudio
|
||||
{
|
||||
public class EventCaller : MonoBehaviour
|
||||
{
|
||||
public GameManager gameManager { get; private set; }
|
||||
public Transform GamesHolder;
|
||||
public RiqEntity currentEntity = new RiqEntity();
|
||||
public string currentSwitchGame;
|
||||
@ -18,6 +19,7 @@ namespace HeavenStudio
|
||||
|
||||
public Dictionary<string, Minigames.Minigame> minigames = new();
|
||||
|
||||
|
||||
public Minigames.Minigame GetMinigame(string gameName)
|
||||
{
|
||||
if (!minigames.ContainsKey(gameName))
|
||||
@ -55,34 +57,14 @@ namespace HeavenStudio
|
||||
return GetGameAction(gameName, action).parameters.Find(c => c.propertyName == param);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
public void Init(GameManager mgr)
|
||||
{
|
||||
gameManager = mgr;
|
||||
instance = this;
|
||||
|
||||
currentEntity = new RiqEntity();
|
||||
|
||||
Minigames.Init(this);
|
||||
|
||||
List<Minigames.Minigame> minigamesInBeatmap = new List<Minigames.Minigame>();
|
||||
for (int i = 0; i < GameManager.instance.Beatmap.Entities.Count; i++)
|
||||
{
|
||||
//go through every entity in the timeline and add the game that they're from to the minigamesInBeatmap list (ignore entities from FX only categories, i.e. Game Manager and Count-Ins)
|
||||
Minigames.Minigame game = GetMinigame(GameManager.instance.Beatmap.Entities[i].datamodel.Split('/')[0]);
|
||||
if (!minigamesInBeatmap.Contains(game) && !FXOnlyGames().Contains(game))
|
||||
{
|
||||
minigamesInBeatmap.Add(game);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < minigamesInBeatmap.Count; i++)
|
||||
{
|
||||
// minigames[minigames.FindIndex(c => c.name == minigamesInBeatmap[i].name)].holder = Resources.Load<GameObject>($"Games/{minigamesInBeatmap[i].name}");
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void CallEvent(RiqEntity entity, bool gameActive)
|
||||
@ -128,30 +110,9 @@ namespace HeavenStudio
|
||||
}
|
||||
}
|
||||
|
||||
static bool StringStartsWith(string a, string b)
|
||||
{
|
||||
int aLen = a.Length;
|
||||
int bLen = b.Length;
|
||||
|
||||
int ap = 0; int bp = 0;
|
||||
|
||||
while (ap < aLen && bp < bLen && a [ap] == b [bp])
|
||||
{
|
||||
ap++;
|
||||
bp++;
|
||||
}
|
||||
|
||||
return (bp == bLen);
|
||||
}
|
||||
|
||||
public static bool IsGameSwitch(RiqEntity entity)
|
||||
{
|
||||
return StringStartsWith(entity.datamodel, "gameManager/switchGame");
|
||||
}
|
||||
|
||||
public static List<RiqEntity> GetAllInGameManagerList(string gameName, string[] include)
|
||||
{
|
||||
List<RiqEntity> temp1 = GameManager.instance.Beatmap.Entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
|
||||
List<RiqEntity> temp1 = instance.gameManager.Beatmap.Entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
|
||||
List<RiqEntity> temp2 = new List<RiqEntity>();
|
||||
foreach (string s in include)
|
||||
{
|
||||
@ -162,7 +123,7 @@ namespace HeavenStudio
|
||||
|
||||
public static List<RiqEntity> GetAllInGameManagerListExclude(string gameName, string[] exclude)
|
||||
{
|
||||
List<RiqEntity> temp1 = GameManager.instance.Beatmap.Entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
|
||||
List<RiqEntity> temp1 = instance.gameManager.Beatmap.Entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
|
||||
List<RiqEntity> temp2 = new List<RiqEntity>();
|
||||
foreach (string s in exclude)
|
||||
{
|
||||
|
Reference in New Issue
Block a user