mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:37:37 +02:00
Second Contact Rework + Small CNR API changes (#500)
* Just need to rewrite how player text works * text almost fixed * text is now fixed * ellipses added * Removed cnr api from rockers and working dough * oops
This commit is contained in:
@ -206,7 +206,6 @@ namespace HeavenStudio.Games
|
||||
public Sprite redArrowSprite;
|
||||
|
||||
public static WorkingDough instance;
|
||||
private static CallAndResponseHandler crHandlerInstance;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@ -232,7 +231,7 @@ namespace HeavenStudio.Games
|
||||
shipObject.SetActive(!bgDisabled && !shipOnly);
|
||||
}
|
||||
|
||||
private static List<RiqEntity> GetAllBallsInBetweenBeat(double beat, double endBeat)
|
||||
private List<RiqEntity> GetAllBallsInBetweenBeat(double beat, double endBeat)
|
||||
{
|
||||
List<RiqEntity> ballEvents = EventCaller.GetAllInGameManagerList("workingDough", new string[] { "small ball", "big ball" });
|
||||
List<RiqEntity> tempEvents = new();
|
||||
@ -247,11 +246,17 @@ namespace HeavenStudio.Games
|
||||
return tempEvents;
|
||||
}
|
||||
|
||||
private RiqEntity GetLastIntervalBeforeBeat(double beat)
|
||||
{
|
||||
List<RiqEntity> intervalEvents = EventCaller.GetAllInGameManagerList("workingDough", new string[] { "beat intervals" });
|
||||
if (intervalEvents.Count == 0) return null;
|
||||
var tempEvents = intervalEvents.FindAll(x => x.beat <= beat);
|
||||
tempEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
|
||||
return tempEvents[^1];
|
||||
}
|
||||
|
||||
public void SetIntervalStart(double beat, double gameSwitchBeat, float interval = 8f, bool autoPassTurn = true)
|
||||
{
|
||||
CallAndResponseHandler newHandler = new();
|
||||
crHandlerInstance = newHandler;
|
||||
crHandlerInstance.StartInterval(beat, interval);
|
||||
List<RiqEntity> relevantBalls = GetAllBallsInBetweenBeat(beat, beat + interval);
|
||||
bool hasBigBall = false;
|
||||
foreach (var ball in relevantBalls)
|
||||
@ -260,17 +265,14 @@ namespace HeavenStudio.Games
|
||||
if (ball.beat >= gameSwitchBeat)
|
||||
{
|
||||
SpawnBall(ball.beat - 1, isBig, isBig && ball["hasGandw"]);
|
||||
OnSpawnBall(ball.beat, isBig, isBig && ball["hasGandw"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnSpawnBallInactive(ball.beat, isBig, isBig && ball["hasGandw"]);
|
||||
OnSpawnBall(ball.beat, isBig);
|
||||
}
|
||||
if (isBig) hasBigBall = true;
|
||||
}
|
||||
Debug.Log(autoPassTurn);
|
||||
if (autoPassTurn)
|
||||
{
|
||||
PassTurn(beat + interval, interval, newHandler);
|
||||
PassTurn(beat + interval, interval, beat);
|
||||
}
|
||||
BeatAction.New(ballTransporterLeftNPC, new List<BeatAction.Action>()
|
||||
{
|
||||
@ -305,10 +307,12 @@ namespace HeavenStudio.Games
|
||||
|
||||
private void PassTurnStandalone(double beat)
|
||||
{
|
||||
if (crHandlerInstance != null) PassTurn(beat, crHandlerInstance.intervalLength, crHandlerInstance);
|
||||
RiqEntity lastInterval = GetLastIntervalBeforeBeat(beat);
|
||||
if (lastInterval == null) return;
|
||||
PassTurn(beat, lastInterval.length, lastInterval.beat);
|
||||
}
|
||||
|
||||
private void PassTurn(double beat, double length, CallAndResponseHandler crHandler)
|
||||
private void PassTurn(double beat, double length, double startBeat)
|
||||
{
|
||||
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
@ -316,15 +320,17 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
ballTransporterRightPlayer.GetComponent<Animator>().Play("BallTransporterRightOpen", 0, 0);
|
||||
ballTransporterLeftPlayer.GetComponent<Animator>().Play("BallTransporterLeftOpen", 0, 0);
|
||||
if (crHandler.queuedEvents.Count > 0)
|
||||
var relevantBallEvents = GetAllBallsInBetweenBeat(startBeat, startBeat + length);
|
||||
if (relevantBallEvents.Count > 0)
|
||||
{
|
||||
bool hasBig = false;
|
||||
foreach (var ball in crHandler.queuedEvents)
|
||||
foreach (var ball in relevantBallEvents)
|
||||
{
|
||||
SpawnPlayerBall(beat + ball.relativeBeat - 1, ball.tag == "big", ball["hasGandw"]);
|
||||
if (ball.tag == "big") hasBig = true;
|
||||
double relativeBeat = ball.beat - startBeat;
|
||||
bool isBig = ball.datamodel == "workingDough/big ball";
|
||||
SpawnPlayerBall(beat + relativeBeat - 1, isBig, isBig ? ball["hasGandw"] : false);
|
||||
if (isBig) hasBig = true;
|
||||
}
|
||||
crHandler.queuedEvents.Clear();
|
||||
bigModePlayer = hasBig;
|
||||
if (bigModePlayer)
|
||||
{
|
||||
@ -335,7 +341,7 @@ namespace HeavenStudio.Games
|
||||
new BeatAction.Action(beat + 1, delegate
|
||||
{
|
||||
if (gandwHasEntered && !bgDisabled) gandwAnim.Play("MrGameAndWatchLeverDown", 0, 0);
|
||||
if (crHandlerInstance == null || !crHandlerInstance.IntervalIsActive())
|
||||
if (beat + 1 > GetLastIntervalBeforeBeat(beat + 1).beat + GetLastIntervalBeforeBeat(beat + 1).length)
|
||||
{
|
||||
ballTransporterLeftNPC.GetComponent<Animator>().Play("BallTransporterLeftClose", 0, 0);
|
||||
ballTransporterRightNPC.GetComponent<Animator>().Play("BallTransporterRightClose", 0, 0);
|
||||
@ -381,24 +387,8 @@ namespace HeavenStudio.Games
|
||||
});
|
||||
}
|
||||
|
||||
public static void OnSpawnBallInactive(double beat, bool isBig, bool hasGandw)
|
||||
public void OnSpawnBall(double beat, bool isBig)
|
||||
{
|
||||
if (crHandlerInstance == null)
|
||||
{
|
||||
crHandlerInstance = new CallAndResponseHandler();
|
||||
}
|
||||
crHandlerInstance.AddEvent(beat, 0, isBig ? "big" : "small", new List<CallAndResponseHandler.CallAndResponseEventParam>()
|
||||
{
|
||||
new CallAndResponseHandler.CallAndResponseEventParam("hasGandw", hasGandw)
|
||||
});
|
||||
}
|
||||
|
||||
public void OnSpawnBall(double beat, bool isBig, bool hasGandw)
|
||||
{
|
||||
crHandlerInstance.AddEvent(beat, 0, isBig ? "big" : "small", new List<CallAndResponseHandler.CallAndResponseEventParam>()
|
||||
{
|
||||
new CallAndResponseHandler.CallAndResponseEventParam("hasGandw", hasGandw)
|
||||
});
|
||||
SoundByte.PlayOneShotGame(isBig ? "workingDough/hitBigOther" : "workingDough/hitSmallOther", beat);
|
||||
SoundByte.PlayOneShotGame(isBig ? "workingDough/bigOther" : "workingDough/smallOther", beat);
|
||||
}
|
||||
@ -445,19 +435,6 @@ namespace HeavenStudio.Games
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (crHandlerInstance != null && !Conductor.instance.isPlaying)
|
||||
{
|
||||
crHandlerInstance = null;
|
||||
}
|
||||
foreach (var evt in scheduledInputs)
|
||||
{
|
||||
evt.Disable();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGameSwitch(double beat)
|
||||
{
|
||||
if (Conductor.instance.isPlaying && !Conductor.instance.isPaused)
|
||||
@ -473,11 +450,6 @@ namespace HeavenStudio.Games
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnPlay(double beat)
|
||||
{
|
||||
crHandlerInstance = null;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (spaceshipRising && !bgDisabled) spaceshipAnimator.DoScaledAnimation("RiseSpaceship", risingStartBeat, risingLength);
|
||||
|
Reference in New Issue
Block a user