the burger fix (#681)

This commit is contained in:
AstrlJelly 2024-02-04 11:15:14 -05:00 committed by minenice55
parent 258a9ce2fb
commit 79251e1499
3 changed files with 51 additions and 63 deletions

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using HeavenStudio.Util; using HeavenStudio.Util;
using HeavenStudio.Games.Scripts_ForkLifter;
namespace HeavenStudio.Games.Loaders namespace HeavenStudio.Games.Loaders
{ {
@ -14,6 +15,10 @@ namespace HeavenStudio.Games.Loaders
{ {
new GameAction("flick", "Flick Food") new GameAction("flick", "Flick Food")
{ {
inactiveFunction = delegate {
var e = eventCaller.currentEntity;
ForkLifter.Flick(e.beat);
},
function = delegate { function = delegate {
var e = eventCaller.currentEntity; var e = eventCaller.currentEntity;
ForkLifter.Flick(e.beat); ForkLifter.Flick(e.beat);
@ -24,11 +29,6 @@ namespace HeavenStudio.Games.Loaders
{ {
new Param("type", ForkLifter.FlickType.Pea, "Object", "Choose the object to be flicked.") new Param("type", ForkLifter.FlickType.Pea, "Object", "Choose the object to be flicked.")
}, },
inactiveFunction = delegate {
var e = eventCaller.currentEntity;
ForkLifter.Flick(e.beat);
ForkLifter.queuedFlicks.Add(e);
},
}, },
new GameAction("prepare", "Prepare Hand") new GameAction("prepare", "Prepare Hand")
{ {
@ -41,7 +41,11 @@ namespace HeavenStudio.Games.Loaders
}, },
new GameAction("gulp", "Swallow") new GameAction("gulp", "Swallow")
{ {
function = delegate { ForkLifter.playerInstance.Eat(); } function = delegate { ForkLifter.playerInstance.Eat(eventCaller.currentEntity["sfx"]); },
parameters = new List<Param>()
{
new Param("sfx", ForkLifterPlayer.EatType.Default, "SFX", "Choose the SFX to play.")
}
}, },
new GameAction("sigh", "Sigh") new GameAction("sigh", "Sigh")
{ {
@ -50,24 +54,24 @@ namespace HeavenStudio.Games.Loaders
new GameAction("color", "Background Appearance") new GameAction("color", "Background Appearance")
{ {
function = delegate { var e = eventCaller.currentEntity; ForkLifter.instance.BackgroundColor(e.beat, e.length, e["start"], e["end"], e["ease"]); }, function = delegate { var e = eventCaller.currentEntity; ForkLifter.instance.BackgroundColor(e.beat, e.length, e["start"], e["end"], e["ease"]); },
resizable = true,
parameters = new List<Param>() parameters = new List<Param>()
{ {
new Param("start", Color.white, "Start Color", "Set the color at the start of the event."), new Param("start", Color.white, "Start Color", "Set the color at the start of the event."),
new Param("end", Color.white, "End Color", "Set the color at the end of the event."), new Param("end", Color.white, "End Color", "Set the color at the end of the event."),
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease", "Set the easing of the action.") new Param("ease", Util.EasingFunction.Ease.Linear, "Ease", "Set the easing of the action.")
}, },
resizable = true
}, },
new GameAction("colorGrad", "Gradient Appearance") new GameAction("colorGrad", "Gradient Appearance")
{ {
function = delegate { var e = eventCaller.currentEntity; ForkLifter.instance.BackgroundColorGrad(e.beat, e.length, e["start"], e["end"], e["ease"]); }, function = delegate { var e = eventCaller.currentEntity; ForkLifter.instance.BackgroundColorGrad(e.beat, e.length, e["start"], e["end"], e["ease"]); },
resizable = true,
parameters = new List<Param>() parameters = new List<Param>()
{ {
new Param("start", Color.white, "Start Color", "Set the color at the start of the event."), new Param("start", Color.white, "Start Color", "Set the color at the start of the event."),
new Param("end", Color.white, "End Color", "Set the color at the end of the event."), new Param("end", Color.white, "End Color", "Set the color at the end of the event."),
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease", "Set the easing of the action.") new Param("ease", Util.EasingFunction.Ease.Linear, "Ease", "Set the easing of the action.")
}, },
resizable = true
}, },
}, },
new List<string>() {"rvl", "normal"}, new List<string>() {"rvl", "normal"},
@ -85,8 +89,6 @@ namespace HeavenStudio.Games
public class ForkLifter : Minigame public class ForkLifter : Minigame
{ {
public static List<RiqEntity> queuedFlicks = new();
public enum FlickType public enum FlickType
{ {
Pea, Pea,
@ -126,34 +128,33 @@ namespace HeavenStudio.Games
public override void OnPlay(double beat) public override void OnPlay(double beat)
{ {
base.OnPlay(beat);
OnGameSwitch(beat); OnGameSwitch(beat);
} }
public override void OnGameSwitch(double beat) public override void OnGameSwitch(double beat)
{ {
base.OnGameSwitch(beat); var actions = GameManager.instance.Beatmap.Entities.FindAll(e => e.datamodel.Split('/')[0] == "forkLifter");
if (queuedFlicks.Count > 0) {
foreach (var flick in queuedFlicks) { FlickActive(flick.beat, flick["type"]); } var actionsBefore = actions.FindAll(e => e.beat < beat);
queuedFlicks.Clear();
var lastColor = actionsBefore.FindLast(e => e.datamodel == "forkLifter/color");
if (lastColor != null) {
BackgroundColor(lastColor.beat, lastColor.length, lastColor["start"], lastColor["end"], lastColor["ease"]);
} }
ForkLifterHand.allFlickEntities = GameManager.instance.Beatmap.Entities.FindAll(c => (c.datamodel == "forkLifter/flick") && (c.beat >= beat)); var lastColorGrad = actionsBefore.FindLast(e => e.datamodel == "forkLifter/colorGrad");
ForkLifterHand.CheckNextFlick(); if (lastColorGrad != null) {
PersistColor(beat); BackgroundColorGrad(lastColorGrad.beat, lastColorGrad.length, lastColorGrad["start"], lastColorGrad["end"], lastColorGrad["ease"]);
} }
public void Bop(double beat, double length, bool doesBop, bool autoBop) var tempFlicks = actions.FindAll(e => e.datamodel == "forkLifter/flick");
{
// playerInstance.shouldBop = autoBop; foreach (var e in tempFlicks.FindAll(e => e.beat < beat && e.beat + 2 > beat)) {
// if (doesBop) FlickActive(e.beat, e["type"]);
// { }
// var actions = new List<BeatAction.Action>();
// for (int i = 0; i < length; i++) { ForkLifterHand.allFlickEntities = tempFlicks.FindAll(e => e.beat >= beat);
// actions.Add(new(beat + i, delegate { playerInstance.SingleBop(); })); ForkLifterHand.CheckNextFlick();
// }
// BeatAction.New(playerInstance, actions);
// }
} }
public static void Flick(double beat) public static void Flick(double beat)
@ -208,9 +209,9 @@ namespace HeavenStudio.Games
var funcGrad = Util.EasingFunction.GetEasingFunction(colorEaseGrad); var funcGrad = Util.EasingFunction.GetEasingFunction(colorEaseGrad);
float newRGrad = func(colorStartGrad.r, colorEndGrad.r, normalizedBeatGrad); float newRGrad = funcGrad(colorStartGrad.r, colorEndGrad.r, normalizedBeatGrad);
float newGGrad = func(colorStartGrad.g, colorEndGrad.g, normalizedBeatGrad); float newGGrad = funcGrad(colorStartGrad.g, colorEndGrad.g, normalizedBeatGrad);
float newBGrad = func(colorStartGrad.b, colorEndGrad.b, normalizedBeatGrad); float newBGrad = funcGrad(colorStartGrad.b, colorEndGrad.b, normalizedBeatGrad);
bgGradient.color = new Color(newRGrad, newGGrad, newBGrad); bgGradient.color = new Color(newRGrad, newGGrad, newBGrad);
playerShadow.color = new Color(newRGrad, newGGrad, newBGrad); playerShadow.color = new Color(newRGrad, newGGrad, newBGrad);
@ -233,25 +234,5 @@ namespace HeavenStudio.Games
colorEndGrad = colorEndSet; colorEndGrad = colorEndSet;
colorEaseGrad = (Util.EasingFunction.Ease)ease; colorEaseGrad = (Util.EasingFunction.Ease)ease;
} }
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("forkLifter", new string[] { "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["start"], lastEvent["end"], lastEvent["ease"]);
}
var allEventsBeforeBeatGrad = EventCaller.GetAllInGameManagerList("forkLifter", new string[] { "colorGrad" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeatGrad.Count > 0)
{
allEventsBeforeBeatGrad.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEventGrad = allEventsBeforeBeatGrad[^1];
BackgroundColorGrad(lastEventGrad.beat, lastEventGrad.length, lastEventGrad["start"], lastEventGrad["end"], lastEventGrad["ease"]);
}
}
} }
} }

View File

@ -12,6 +12,13 @@ namespace HeavenStudio.Games.Scripts_ForkLifter
{ {
public static ForkLifterPlayer instance { get; set; } public static ForkLifterPlayer instance { get; set; }
public enum EatType
{
Default,
Normal,
Burger
}
[Header("Objects")] [Header("Objects")]
public Sprite hitFX; public Sprite hitFX;
public Sprite hitFXG; public Sprite hitFXG;
@ -29,6 +36,7 @@ namespace HeavenStudio.Games.Scripts_ForkLifter
public int currentLatePeasOnFork; public int currentLatePeasOnFork;
private bool isEating = false; private bool isEating = false;
public EatType eatType = 0;
// Burger shit // Burger shit
@ -50,10 +58,11 @@ namespace HeavenStudio.Games.Scripts_ForkLifter
} }
} }
public void Eat() public void Eat(int eatTypeTemp)
{ {
if (currentEarlyPeasOnFork != 0 || currentPerfectPeasOnFork != 0 || currentLatePeasOnFork != 0) if (currentEarlyPeasOnFork != 0 || currentPerfectPeasOnFork != 0 || currentLatePeasOnFork != 0)
{ {
eatType = (EatType)eatTypeTemp;
anim.Play("Player_Eat", 0, 0); anim.Play("Player_Eat", 0, 0);
isEating = true; isEating = true;
} }
@ -62,7 +71,7 @@ namespace HeavenStudio.Games.Scripts_ForkLifter
// used in an animation event // used in an animation event
public void EatConfirm() public void EatConfirm()
{ {
if (topbun && middleburger && bottombun) if (eatType != EatType.Normal && ((topbun && middleburger && bottombun) || eatType == EatType.Burger))
{ {
SoundByte.PlayOneShotGame("forkLifter/burger"); SoundByte.PlayOneShotGame("forkLifter/burger");
} }
@ -101,7 +110,7 @@ namespace HeavenStudio.Games.Scripts_ForkLifter
isEating = false; isEating = false;
topbun = false; middleburger = false; bottombun = false; topbun = middleburger = bottombun = false;
} }
public void Stab(Pea p) public void Stab(Pea p)
@ -122,11 +131,9 @@ namespace HeavenStudio.Games.Scripts_ForkLifter
hitFX2o.transform.localPosition = new Vector3(0.11f, -2.15f); hitFX2o.transform.localPosition = new Vector3(0.11f, -2.15f);
hitFX2o.transform.localScale = new Vector3(5.401058f, 1.742697f); hitFX2o.transform.localScale = new Vector3(5.401058f, 1.742697f);
hitFX2o.transform.localRotation = Quaternion.Euler(0, 0, -38.402f); hitFX2o.transform.localRotation = Quaternion.Euler(0, 0, -38.402f);
SpriteRenderer hfx2s = hitFX2o.AddComponent<SpriteRenderer>(); SpriteRenderer hfx2s = hitFX2o.AddComponent<SpriteRenderer>();
if (type == 2) hfx2s.sprite = type == 2 ? hitFXG : hitFX2;
hfx2s.sprite = hitFXG;
else
hfx2s.sprite = hitFX2;
hfx2s.sortingOrder = -5; hfx2s.sortingOrder = -5;
hfx2s.DOColor(new Color(1, 1, 1, 0), 0.07f).OnComplete(delegate { Destroy(hitFX2o); }); hfx2s.DOColor(new Color(1, 1, 1, 0), 0.07f).OnComplete(delegate { Destroy(hitFX2o); });
} }

View File

@ -83,9 +83,9 @@ namespace HeavenStudio.Games.Scripts_ForkLifter
player.currentPerfectPeasOnFork++; player.currentPerfectPeasOnFork++;
player.topbun = type == 1; if (type == 1) player.topbun = true;
player.middleburger = type == 2; if (type == 2) player.middleburger = true;
player.bottombun = type == 3; if (type == 3) player.bottombun = true;
Destroy(this.gameObject); Destroy(this.gameObject);
} }