Color Persistence for Nightly Games (#881)

Added color persistence between game switches for most of the games in the nightly that needed it:
- Basketball Girls
- Bouncy Road
- Chameleon
- Clap Trap
- Fillbots
- Frog Princess
- Sick Beats
- Sumo Brothers

Slot Monster has none yet, because its color changing is a little different lol
This commit is contained in:
wookywok 2024-04-19 14:16:16 -05:00 committed by GitHub
parent 1fd316ac94
commit 727ec7a3a1
8 changed files with 166 additions and 0 deletions

View file

@ -241,6 +241,28 @@ namespace HeavenStudio.Games
{
BGPlane.color = bgColorEase.GetColor();
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("basketballGirls", new string[] { "background appearance" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeat.Count > 0)
{
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEvent = allEventsBeforeBeat[^1];
BackgroundColorSet(lastEvent.beat, lastEvent.length, lastEvent["colorBGStart"], lastEvent["colorBGEnd"], lastEvent["ease"]);
}
}
public override void OnPlay(double beat)
{
PersistColor(beat);
}
public override void OnGameSwitch(double beat)
{
PersistColor(beat);
}
}
}

View file

@ -190,6 +190,9 @@ namespace HeavenStudio.Games
public override void OnGameSwitch(double beat)
{
PersistColor(beat);
double gameStartBeat = beat, gameEndBeat = double.MaxValue;
var firstEnd = EventCaller.GetAllInGameManagerList("gameManager", new string[] { "switchGame", "end" }).Find(x => x.beat > gameStartBeat);
gameEndBeat = firstEnd?.beat ?? gameEndBeat;
@ -371,5 +374,16 @@ namespace HeavenStudio.Games
BGHigh.color = colorEases[0].GetColor();
BGLow.color = colorEases[1].GetColor();
}
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("bouncyRoad", new string[] { "background appearance" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeat.Count > 0)
{
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEvent = allEventsBeforeBeat[^1];
BackgroundColorSet(lastEvent.beat, lastEvent.length, lastEvent["colorBG1Start"], lastEvent["colorBG1End"], lastEvent["colorBG2Start"], lastEvent["colorBG2End"], lastEvent["ease"]);
}
}
}
}

View file

@ -150,6 +150,8 @@ namespace HeavenStudio.Games
public override void OnPlay(double beat)
{
PersistColor(beat);
if (queuedFlys.Count > 0) queuedFlys.Clear();
foreach (var evt in scheduledInputs)
{
@ -296,5 +298,23 @@ namespace HeavenStudio.Games
if (GameManager.instance.currentGame == "chameleon")
Chameleon.instance.Crown.SetActive(enableCrown);
}
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("chameleon", new string[] { "background appearance" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeat.Count > 0)
{
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEvent = allEventsBeforeBeat[^1];
BackgroundColorSet(lastEvent.beat, lastEvent.length, lastEvent["colorBG1Start"], lastEvent["colorBG1End"], lastEvent["colorBG2Start"], lastEvent["colorBG2End"], lastEvent["ease"]);
}
}
public override void OnGameSwitch(double beat)
{
PersistColor(beat);
}
}
}

View file

@ -380,5 +380,35 @@ namespace HeavenStudio.Games
spotlightMaterial.SetColor("_ColorDelta", bottomSpot);
}
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("clapTrap", new string[] { "background color" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeat.Count > 0)
{
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEvent = allEventsBeforeBeat[^1];
BackgroundColor(lastEvent["bgColor"], lastEvent["bgColorEnd"], lastEvent["ease"], lastEvent.length, lastEvent.beat);
}
var allEventsBeforeBeatHand = EventCaller.GetAllInGameManagerList("clapTrap", new string[] { "hand color" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeatHand.Count > 0)
{
allEventsBeforeBeatHand.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEventHand = allEventsBeforeBeatHand[^1];
ChangeHandColor(lastEventHand["left"], lastEventHand["right"], lastEventHand["spotlightBottom"], lastEventHand["spotlightTop"], lastEventHand["spotlightGlow"]);
}
}
public override void OnGameSwitch(double beat)
{
PersistColor(beat);
}
public override void OnPlay(double beat)
{
PersistColor(beat);
}
}
}

View file

@ -238,6 +238,7 @@ namespace HeavenStudio.Games
public override void OnPlay(double beat)
{
PersistColor(beat);
if (queuedBots.Count > 0) queuedBots.Clear();
foreach (var evt in scheduledInputs)
{
@ -548,6 +549,37 @@ namespace HeavenStudio.Games
metersFuel[i].color = colorEases[i+1].GetColor();
}
}
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("fillbots", new string[] { "background appearance" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeat.Count > 0)
{
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEvent = allEventsBeforeBeat[^1];
BackgroundColorSet(lastEvent.beat, lastEvent.length, lastEvent["colorBGStart"], lastEvent["colorBGEnd"], lastEvent["colorMetersStart"],
lastEvent["colorMeter1Start"], lastEvent["colorMeter2Start"],
lastEvent["colorMeter3Start"], lastEvent["colorMeter4Start"],
lastEvent["colorMeter5Start"], lastEvent["colorMeter6Start"],
lastEvent["colorMetersEnd"], lastEvent["colorMeter1End"],
lastEvent["colorMeter2End"], lastEvent["colorMeter3End"],
lastEvent["colorMeter4End"], lastEvent["colorMeter5End"], lastEvent["colorMeter6End"],
lastEvent["separate"], lastEvent["ease"]);
}
var allEventsBeforeBeatObj = EventCaller.GetAllInGameManagerList("fillbots", new string[] { "object appearance" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeatObj.Count > 0)
{
allEventsBeforeBeatObj.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEventObj = allEventsBeforeBeatObj[^1];
ObjectColorSet(lastEventObj["colorFuel"], lastEventObj["colorLampOff"], lastEventObj["colorLampOn"], lastEventObj["colorImpact"], lastEventObj["colorFiller"], lastEventObj["colorConveyor"]);
}
}
public override void OnGameSwitch(double beat)
{
PersistColor(beat);
}
}
}

View file

@ -379,5 +379,26 @@ namespace HeavenStudio.Games
{
BGPlane.color = bgColorEase.GetColor();
}
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("frogPrincess", new string[] { "background appearance" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeat.Count > 0)
{
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEvent = allEventsBeforeBeat[^1];
BackgroundColorSet(lastEvent.beat, lastEvent.length, lastEvent["colorBGStart"], lastEvent["colorBGEnd"], lastEvent["ease"]);
}
}
public override void OnPlay(double beat)
{
PersistColor(beat);
}
public override void OnGameSwitch(double beat)
{
PersistColor(beat);
}
}
}

View file

@ -237,6 +237,7 @@ namespace HeavenStudio.Games
[NonSerialized] public double gameEndBeat = double.MaxValue;
public override void OnGameSwitch(double beat)
{
PersistColor(beat);
var entities = GameManager.instance.Beatmap.Entities;
// find out when the next game switch (or remix end) happens
RiqEntity firstEnd = entities.Find(c => (c.datamodel.StartsWith("gameManager/switchGame") || c.datamodel.Equals("gameManager/end")) && c.beat > beat);
@ -465,5 +466,16 @@ namespace HeavenStudio.Games
return UnityEngine.Random.Range(0, 4);
}
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("sickBeats", new string[] { "virusColor" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeat.Count > 0)
{
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEvent = allEventsBeforeBeat[^1];
UpdateMaterialColor(lastEvent["colorVirus1"], lastEvent["colorVirus2"], lastEvent["colorVirus3"], lastEvent["colorVirus4"]);
}
}
}
}

View file

@ -443,6 +443,8 @@ namespace HeavenStudio.Games
public override void OnGameSwitch(double beat) // stole code from manzai
{
FindNextGameswitchBeat(beat);
PersistColor(beat);
foreach(var entity in GameManager.instance.Beatmap.Entities)
{
@ -464,6 +466,8 @@ namespace HeavenStudio.Games
{
bgTypeNext = BGType.None;
FindNextGameswitchBeat(beat);
PersistColor(beat);
}
private void FindNextGameswitchBeat(double beat)
@ -1306,6 +1310,17 @@ namespace HeavenStudio.Games
}
}
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("sumoBrothers", new string[] { "background color" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeat.Count > 0)
{
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEvent = allEventsBeforeBeat[^1];
BackgroundColor(lastEvent.beat, lastEvent.length, lastEvent["colorFrom"], lastEvent["colorTo"], lastEvent["colorFrom2"], lastEvent["colorTo2"], lastEvent["ease"]);
}
}
}
}