From 595172857ced7947879a3fd40a581796d871a589 Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Tue, 5 Dec 2023 23:23:36 +0100 Subject: [PATCH] Auto bop rework --- Assets/Scripts/Conductor.cs | 4 +- .../Games/BoardMeeting/BoardMeeting.cs | 6 +- Assets/Scripts/Games/CatchyTune/CatchyTune.cs | 18 ++--- .../Games/CheerReaders/CheerReaders.cs | 6 +- Assets/Scripts/Games/DJSchool/DJSchool.cs | 7 +- Assets/Scripts/Games/DJSchool/Student.cs | 4 +- Assets/Scripts/Games/DogNinja/DogNinja.cs | 6 +- Assets/Scripts/Games/DoubleDate/DoubleDate.cs | 6 +- .../DrummingPractice/DrummingPractice.cs | 9 +-- Assets/Scripts/Games/FanClub/FanClub.cs | 10 +-- Assets/Scripts/Games/KarateMan/KarateMan.cs | 5 +- .../Scripts/Games/MeatGrinder/MeatGrinder.cs | 6 +- Assets/Scripts/Games/Minigame.cs | 77 +++++++++++++++++++ Assets/Scripts/Games/MunchyMonk/MunchyMonk.cs | 30 +++++--- .../Games/OctopusMachine/OctopusMachine.cs | 5 +- .../Scripts/Games/RhythmRally/RhythmRally.cs | 6 +- .../Scripts/Games/RhythmSomen/RhythmSomen.cs | 7 +- Assets/Scripts/Games/Ringside/Ringside.cs | 7 +- .../Games/SamuraiSliceNtr/SamuraiSliceNtr.cs | 15 ++-- Assets/Scripts/Games/SpaceDance/SpaceDance.cs | 5 +- Assets/Scripts/Games/TapTrial/TapTrial.cs | 6 +- Assets/Scripts/Games/TheDazzles/TheDazzles.cs | 6 +- Assets/Scripts/Games/TossBoys/TossBoys.cs | 6 +- Assets/Scripts/Games/TrickClass/TrickClass.cs | 3 +- 24 files changed, 160 insertions(+), 100 deletions(-) diff --git a/Assets/Scripts/Conductor.cs b/Assets/Scripts/Conductor.cs index 5ee65b4be..0ee980b41 100644 --- a/Assets/Scripts/Conductor.cs +++ b/Assets/Scripts/Conductor.cs @@ -406,11 +406,11 @@ namespace HeavenStudio public void LateUpdate() { - if (metronome && isPlaying) + if (isPlaying) { if (songPositionInBeatsAsDouble >= Math.Ceiling(startBeat) + _metronomeTally) { - metronomeSound = Util.SoundByte.PlayOneShot("metronome", Math.Ceiling(startBeat) + _metronomeTally); + if (metronome) metronomeSound = Util.SoundByte.PlayOneShot("metronome", Math.Ceiling(startBeat) + _metronomeTally); _metronomeTally++; } } diff --git a/Assets/Scripts/Games/BoardMeeting/BoardMeeting.cs b/Assets/Scripts/Games/BoardMeeting/BoardMeeting.cs index 845e6d2c1..5967f6cdd 100644 --- a/Assets/Scripts/Games/BoardMeeting/BoardMeeting.cs +++ b/Assets/Scripts/Games/BoardMeeting/BoardMeeting.cs @@ -91,10 +91,8 @@ namespace HeavenStudio.Games [SerializeField] List executives = new List(); public BMExecutive firstSpinner; [SerializeField] float shakeIntensity = 0.5f; - public bool shouldBop = true; private bool assistantCanBop = true; private bool executivesCanBop = true; - public GameEvent bop = new GameEvent(); [NonSerialized] public Sound chairLoopSound = null; int missCounter = 0; private Tween shakeTween; @@ -104,6 +102,7 @@ namespace HeavenStudio.Games private void Awake() { instance = this; + SetupBopRegion("boardMeeting", "bop", "auto"); InitExecutives(); } @@ -145,7 +144,7 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { - if (!shouldBop) return; + if (!BeatIsInBopRegion(beat)) return; SingleBop(); } @@ -166,7 +165,6 @@ namespace HeavenStudio.Games public void Bop(double beat, float length, bool goBop, bool autoBop) { - shouldBop = autoBop; if (goBop) { for (int i = 0; i < length; i++) diff --git a/Assets/Scripts/Games/CatchyTune/CatchyTune.cs b/Assets/Scripts/Games/CatchyTune/CatchyTune.cs index 5f2503024..4be425988 100644 --- a/Assets/Scripts/Games/CatchyTune/CatchyTune.cs +++ b/Assets/Scripts/Games/CatchyTune/CatchyTune.cs @@ -80,10 +80,10 @@ namespace HeavenStudio.Games public enum WhoBops { - Alalin, - Plalin, - Both, - None + Alalin = 1, + Plalin = 2, + Both = 0, + None = 3 } public enum Background @@ -111,10 +111,6 @@ namespace HeavenStudio.Games private double startSmile = 0; private double stopSmile = 0; - private bool bopLeft = true; - private bool bopRight = true; - public GameEvent bop = new GameEvent(); - public static CatchyTune instance; static List queuedFruits = new List(); struct QueuedFruit @@ -184,6 +180,7 @@ namespace HeavenStudio.Games private void Awake() { instance = this; + SetupBopRegion("catchyTune", "bop", "bopAuto", false); } const float orangeoffset = 0.5f; @@ -249,6 +246,9 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { + int whoBopsAuto = BeatIsInBopRegionInt(beat); + bool bopLeft = whoBopsAuto == (int)WhoBops.Plalin || whoBopsAuto == (int)WhoBops.Both; + bool bopRight = whoBopsAuto == (int)WhoBops.Alalin || whoBopsAuto == (int)WhoBops.Both; if (bopLeft && stopCatchLeft == 0) { plalinAnim.DoScaledAnimationAsync("bop", 0.5f); @@ -323,8 +323,6 @@ namespace HeavenStudio.Games public void Bop(double beat, float length, int whoBops, int whoBopsAuto) { - bopLeft = whoBopsAuto == (int)WhoBops.Plalin || whoBopsAuto == (int)WhoBops.Both; - bopRight = whoBopsAuto == (int)WhoBops.Alalin || whoBopsAuto == (int)WhoBops.Both; for (int i = 0; i < length; i++) { BeatAction.New(instance, new List() diff --git a/Assets/Scripts/Games/CheerReaders/CheerReaders.cs b/Assets/Scripts/Games/CheerReaders/CheerReaders.cs index 0af61ec29..b0673f683 100644 --- a/Assets/Scripts/Games/CheerReaders/CheerReaders.cs +++ b/Assets/Scripts/Games/CheerReaders/CheerReaders.cs @@ -163,7 +163,6 @@ namespace HeavenStudio.Games Sound SpinningLoop; [Header("Variables")] [SerializeField] List posters = new List(); - bool shouldBop = true; bool canBop = true; public bool doingCue; double cueLength; @@ -171,7 +170,6 @@ namespace HeavenStudio.Games bool shouldYay; bool shouldDoSuccessZoom; public bool shouldBeBlack = false; - public GameEvent bop = new GameEvent(); int currentZoomIndex; double currentZoomCamBeat; float currentZoomCamLength; @@ -230,6 +228,7 @@ namespace HeavenStudio.Games void Awake() { instance = this; + SetupBopRegion("cheerReaders", "bop", "toggle2"); for (int i = 0; i < topMasks.Count; i++) { firstRow[i].posterBook = topMasks[i]; @@ -264,7 +263,7 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { - if (!shouldBop) return; + if (!BeatIsInBopRegion(beat)) return; BopSingle(); } @@ -482,7 +481,6 @@ namespace HeavenStudio.Games public void BopToggle(double beat, float length, bool startBop, bool bopAuto) { - shouldBop = bopAuto; if (startBop) { for (int i = 0; i < length; i++) diff --git a/Assets/Scripts/Games/DJSchool/DJSchool.cs b/Assets/Scripts/Games/DJSchool/DJSchool.cs index 953c5239d..c895d6384 100644 --- a/Assets/Scripts/Games/DJSchool/DJSchool.cs +++ b/Assets/Scripts/Games/DJSchool/DJSchool.cs @@ -113,14 +113,12 @@ namespace HeavenStudio.Games [SerializeField] private Student student; [SerializeField] private GameObject djYellow; private Animator djYellowAnim; - private double lastReportedBeat = 0f; public DJYellow djYellowScript; [Header("Properties")] public GameEvent bop = new GameEvent(); public bool djYellowHolding; public bool andStop; - public bool goBop; public double beatOfInstance; private bool djYellowBopLeft; public bool shouldBeHolding = false; @@ -138,7 +136,7 @@ namespace HeavenStudio.Games djYellowAnim = djYellow.GetComponent(); djYellowScript = djYellow.GetComponent(); student.Init(); - goBop = true; + SetupBopRegion("djSchool", "bop", "toggle"); } //For inactive game purposes @@ -167,7 +165,7 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { - if (!goBop) return; + if (!BeatIsInBopRegion(beat)) return; if (student.isHolding) { student.anim.DoScaledAnimationAsync("HoldBop", 0.5f); @@ -243,7 +241,6 @@ namespace HeavenStudio.Games public void Bop(double beat, float length, bool isBopping, bool autoBop) { - goBop = autoBop; if (isBopping) { for (int i = 0; i < length; i++) diff --git a/Assets/Scripts/Games/DJSchool/Student.cs b/Assets/Scripts/Games/DJSchool/Student.cs index f85881ab3..2a965660f 100644 --- a/Assets/Scripts/Games/DJSchool/Student.cs +++ b/Assets/Scripts/Games/DJSchool/Student.cs @@ -258,7 +258,7 @@ namespace HeavenStudio.Games.Scripts_DJSchool { new BeatAction.Action(caller.timer + caller.startBeat + 1, delegate { - if (game.goBop) + if (game.BeatIsInBopRegion(caller.timer + caller.startBeat + 1)) { game.djYellowScript.ChangeHeadSprite(DJYellow.DJExpression.CrossEyed); if (game.djYellowHolding) game.djYellowScript.Reverse(); @@ -278,7 +278,7 @@ namespace HeavenStudio.Games.Scripts_DJSchool { new BeatAction.Action(beat, delegate { - if (game.goBop) + if (game.BeatIsInBopRegion(beat)) { game.djYellowScript.ChangeHeadSprite(DJYellow.DJExpression.CrossEyed); if (game.djYellowHolding) game.djYellowScript.Reverse(); diff --git a/Assets/Scripts/Games/DogNinja/DogNinja.cs b/Assets/Scripts/Games/DogNinja/DogNinja.cs index 388d8a62a..01e9e4776 100644 --- a/Assets/Scripts/Games/DogNinja/DogNinja.cs +++ b/Assets/Scripts/Games/DogNinja/DogNinja.cs @@ -140,9 +140,7 @@ namespace HeavenStudio.Games [SerializeField] Sprite[] ObjectTypes; - private double lastReportedBeat = 0f; private bool birdOnScreen = false; - bool dontBop = false; private const string sfxNum = "dogNinja/"; public static DogNinja instance; @@ -200,6 +198,7 @@ namespace HeavenStudio.Games private void Awake() { instance = this; + SetupBopRegion("dogNinja", "Bop", "auto"); } void OnDestroy() @@ -216,7 +215,7 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { - if (dontBop) return; + if (!BeatIsInBopRegion(beat)) return; DogAnim.DoScaledAnimationAsync("Bop", 0.5f); } @@ -267,7 +266,6 @@ namespace HeavenStudio.Games public void Bop(double beat, float length, bool auto, bool bop) { - dontBop = !auto; if (!bop) return; List actions = new(); diff --git a/Assets/Scripts/Games/DoubleDate/DoubleDate.cs b/Assets/Scripts/Games/DoubleDate/DoubleDate.cs index e82f6aa52..e2cc3724f 100644 --- a/Assets/Scripts/Games/DoubleDate/DoubleDate.cs +++ b/Assets/Scripts/Games/DoubleDate/DoubleDate.cs @@ -76,9 +76,7 @@ namespace HeavenStudio.Games [SerializeField] public float shadowDepthScaleMax; [SerializeField] SuperCurveObject.Path[] ballBouncePaths; double lastGirlGacha = double.MinValue; - bool shouldBop = true; bool canBop = true; - GameEvent bop = new GameEvent(); public static DoubleDate instance; public static List queuedBalls = new List(); [NonSerialized] public double lastHitWeasel = double.MinValue; @@ -132,6 +130,7 @@ namespace HeavenStudio.Games private void Awake() { instance = this; + SetupBopRegion("doubleDate", "bop", "autoBop"); } private void Start() { @@ -140,7 +139,7 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { - if (shouldBop) SingleBop(); + if (BeatIsInBopRegion(beat)) SingleBop(); } void Update() @@ -198,7 +197,6 @@ namespace HeavenStudio.Games public void Bop(double beat, float length, bool goBop, bool autoBop) { - shouldBop = autoBop; if (goBop) { for (int i = 0; i < length; i++) diff --git a/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs b/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs index 071711e07..ed76d2fe2 100644 --- a/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs +++ b/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs @@ -21,7 +21,7 @@ namespace HeavenStudio.Games.Loaders parameters = new List() { new Param("bop", true, "Bop", "Should the drummers bop?"), - new Param("autoBop", true, "Bop (Auto)", "Should the drummers auto bop?") + new Param("autoBop", false, "Bop (Auto)", "Should the drummers auto bop?") } }, new GameAction("drum", "Hit Drum") @@ -121,9 +121,6 @@ namespace HeavenStudio.Games bool isMoving; string moveAnim; EasingFunction.Ease lastEase; - bool goBop = true; - - public GameEvent bop = new GameEvent(); public int count = 0; public static DrummingPractice instance; @@ -132,6 +129,7 @@ namespace HeavenStudio.Games { instance = this; SetMiis(); + SetupBopRegion("drummingPractice", "bop", "autoBop"); } public override void OnGameSwitch(double beat) @@ -146,7 +144,7 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { - if (goBop) + if (BeatIsInBopRegion(beat)) { Bop(); } @@ -191,7 +189,6 @@ namespace HeavenStudio.Games public void SetBop(double beat, float length, bool shouldBop, bool autoBop) { - goBop = autoBop; if (shouldBop) { for (int i = 0; i < length; i++) diff --git a/Assets/Scripts/Games/FanClub/FanClub.cs b/Assets/Scripts/Games/FanClub/FanClub.cs index bdadd7419..2212be69b 100644 --- a/Assets/Scripts/Games/FanClub/FanClub.cs +++ b/Assets/Scripts/Games/FanClub/FanClub.cs @@ -218,8 +218,6 @@ namespace HeavenStudio.Games private static bool wantKamoneAlt = false; private static double wantBigReady = double.MinValue; private bool hasJumped = false; - private bool goBopIdol = true; - private bool goBopSpec = true; private bool noJudgement = false; private bool noJudgementInput = false; @@ -235,6 +233,8 @@ namespace HeavenStudio.Games private void Awake() { instance = this; + SetupBopRegion("fanClub", "bop", "type2", false); + AddBopRegionEventsInt("fanClub", "finish", 3); Spectators = new List(); idolAnimator = Arisa.GetComponent(); backupRAnimator = Blue.GetComponent(); @@ -357,6 +357,9 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { var cond = Conductor.instance; + int whoBops = BeatIsInBopRegionInt(beat); + bool goBopIdol = whoBops == (int)IdolBopType.Both || whoBops == (int)IdolBopType.Idol; + bool goBopSpec = whoBops == (int)IdolBopType.Both || whoBops == (int)IdolBopType.Spectators; if (goBopIdol) { if (!(cond.songPositionInBeatsAsDouble >= noBop.startBeat && cond.songPositionInBeatsAsDouble < noBop.startBeat + noBop.length)) @@ -398,8 +401,6 @@ namespace HeavenStudio.Games public void Bop(double beat, float length, int target = (int) IdolBopType.Both, int targetAuto = (int)IdolBopType.Both) { - goBopIdol = targetAuto == (int)IdolBopType.Both || targetAuto == (int)IdolBopType.Idol; - goBopSpec = targetAuto == (int)IdolBopType.Both || targetAuto == (int)IdolBopType.Spectators; for (int i = 0; i < length; i++) { BeatAction.New(instance, new List() @@ -934,7 +935,6 @@ namespace HeavenStudio.Games if (noJudgement) return; noJudgement = true; noJudgementInput = false; - goBopSpec = false; // recreation of sub61 BeatAction.New(this, new List() diff --git a/Assets/Scripts/Games/KarateMan/KarateMan.cs b/Assets/Scripts/Games/KarateMan/KarateMan.cs index 9fca97f8b..4e2e5f55f 100644 --- a/Assets/Scripts/Games/KarateMan/KarateMan.cs +++ b/Assets/Scripts/Games/KarateMan/KarateMan.cs @@ -692,6 +692,7 @@ namespace HeavenStudio.Games private void Awake() { instance = this; + SetupBopRegion("karateman", "bop", "toggle"); KarateManPot.ResetLastCombo(); @@ -1168,13 +1169,13 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { + bool autoBop = BeatIsInBopRegion(beat); + Joe.bop.length = autoBop ? float.MaxValue : 0; Joe.RequestBop(); } public void ToggleBop(double beat, float length, bool toggle, bool autoBop) { - Joe.bop.length = autoBop ? float.MaxValue : 0; - if (toggle) { var actions = new List(); diff --git a/Assets/Scripts/Games/MeatGrinder/MeatGrinder.cs b/Assets/Scripts/Games/MeatGrinder/MeatGrinder.cs index f03d79db6..510e02091 100644 --- a/Assets/Scripts/Games/MeatGrinder/MeatGrinder.cs +++ b/Assets/Scripts/Games/MeatGrinder/MeatGrinder.cs @@ -94,10 +94,8 @@ namespace HeavenStudio.Games [Header("Variables")] bool intervalStarted; double intervalStartBeat; - bool bossBop = true; public double beatInterval = 4f; public bool bossAnnoyed = false; - private double lastReportedBeat = 0f; const string sfxName = "meatGrinder/"; public static MeatGrinder instance; @@ -124,6 +122,7 @@ namespace HeavenStudio.Games private void Awake() { instance = this; + SetupBopRegion("meatGrinder", "bop", "bossBop"); } void OnDestroy() @@ -161,7 +160,7 @@ namespace HeavenStudio.Games { if (!BossAnim.IsPlayingAnimationName("BossCall") && !BossAnim.IsPlayingAnimationName("BossSignal") - && bossBop) + && BeatIsInBopRegion(beat)) { BossAnim.DoScaledAnimationAsync(bossAnnoyed ? "BossMiss" : "Bop", 0.5f); } @@ -169,7 +168,6 @@ namespace HeavenStudio.Games public void Bop(double beat, double length, bool doesBop, bool autoBop) { - bossBop = autoBop; if (doesBop) { for (int i = 0; i < length; i++) diff --git a/Assets/Scripts/Games/Minigame.cs b/Assets/Scripts/Games/Minigame.cs index 632bb8810..7954ebbbe 100644 --- a/Assets/Scripts/Games/Minigame.cs +++ b/Assets/Scripts/Games/Minigame.cs @@ -6,6 +6,7 @@ using HeavenStudio.Util; using HeavenStudio.Common; using HeavenStudio.InputSystem; using System; +using System.Linq; namespace HeavenStudio.Games { @@ -448,6 +449,82 @@ namespace HeavenStudio.Games } + #region Bop + + protected enum DefaultBopEnum + { + Off = 0, + On = 1, + } + + private Dictionary bopRegion = new(); + + public bool BeatIsInBopRegion(double beat) + { + if (bopRegion.Count == 0) return true; + + int bop = 0; + foreach (var item in bopRegion) + { + if (beat < item.Key) break; + if (beat >= item.Key) bop = item.Value; + } + return (DefaultBopEnum)bop == DefaultBopEnum.On; + } + + public int BeatIsInBopRegionInt(double beat) + { + if (bopRegion.Count == 0) return 0; + + int bop = 0; + foreach (var item in bopRegion) + { + if (beat < item.Key) break; + if (beat >= item.Key) bop = item.Value; + } + return bop; + } + + protected void SetupBopRegion(string gameName, string eventName, string toggleName, bool isBool = true) + { + var allEvents = EventCaller.GetAllInGameManagerList(gameName, new string[] { eventName }); + allEvents.Sort((x, y) => x.beat.CompareTo(y.beat)); + + foreach (var e in allEvents) + { + if (isBool) + { + bopRegion.Add(e.beat, e[toggleName] ? 1 : 0); + } + else + { + bopRegion.Add(e.beat, e[toggleName]); + } + } + } + + protected void AddBopRegionEvents(string gameName, string eventName, bool allowBop) + { + var allEvents = EventCaller.GetAllInGameManagerList(gameName, new string[] { eventName }); + foreach (var e in allEvents) + { + bopRegion.Add(e.beat, allowBop ? 1 : 0); + } + bopRegion = bopRegion.OrderBy(pair => pair.Value).ToDictionary(pair => pair.Key, pair => pair.Value); + } + + protected void AddBopRegionEventsInt(string gameName, string eventName, int allowBop) + { + var allEvents = EventCaller.GetAllInGameManagerList(gameName, new string[] { eventName }); + foreach (var e in allEvents) + { + bopRegion.Add(e.beat, allowBop); + } + bopRegion = bopRegion.OrderBy(pair => pair.Value).ToDictionary(pair => pair.Key, pair => pair.Value); + } + + #endregion + private void OnDestroy() { foreach (var evt in scheduledInputs) diff --git a/Assets/Scripts/Games/MunchyMonk/MunchyMonk.cs b/Assets/Scripts/Games/MunchyMonk/MunchyMonk.cs index 9de0976dc..35e30dd6c 100644 --- a/Assets/Scripts/Games/MunchyMonk/MunchyMonk.cs +++ b/Assets/Scripts/Games/MunchyMonk/MunchyMonk.cs @@ -17,14 +17,14 @@ namespace HeavenStudio.Games.Loaders { function = delegate { var e = eventCaller.currentEntity; - MunchyMonk.instance.Bop(e.beat, e["bop"], e["autoBop"]); + MunchyMonk.instance.Bop(e.beat, e.length, e["bop"]); }, parameters = new List() { new Param("bop", true, "Monk Bops?", "Does the monk bop?"), new Param("autoBop", false, "Monk Bops? (Auto)", "Does the monk auto bop?"), }, - defaultLength = 0.5f, + resizable = true }, new GameAction("MonkMove", "Monk Move") { @@ -209,7 +209,6 @@ namespace HeavenStudio.Games public double lastReportedBeat = 0f; public bool needBlush; public bool isStaring; - bool monkBop = true; // these variables are static so that they can be set outside of the game/stay the same between game switches static public int howManyGulps; @@ -241,6 +240,7 @@ namespace HeavenStudio.Games { instance = this; Baby.SetActive(!disableBaby); + SetupBopRegion("munchyMonk", "Bop", "autoBop"); } private void Start() @@ -352,7 +352,7 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { if ((MonkAnim.IsAnimationNotPlaying() || MonkAnim.IsPlayingAnimationName("Bop") || MonkAnim.IsPlayingAnimationName("Idle")) - && monkBop + && BeatIsInBopRegion(beat) && !isStaring) { MonkAnim.DoScaledAnimationAsync("Bop", 0.5f); @@ -370,15 +370,23 @@ namespace HeavenStudio.Games } } - public void Bop(double beat, bool bop, bool autoBop) + public void Bop(double beat, double length, bool bop) { - monkBop = autoBop; - if (bop) { - needBlush = false; - MonkAnim.DoScaledAnimationAsync("Bop", 0.5f); - if (growLevel == 4) BrowAnim.DoScaledAnimationAsync("Bop", 0.5f); - if (growLevel > 0) StacheAnim.DoScaledAnimationAsync($"Bop{growLevel}", 0.5f); + if (!bop) return; + List actions = new(); + + for (int i = 0; i < length; i++) + { + actions.Add(new(beat + i, delegate + { + needBlush = false; + MonkAnim.DoScaledAnimationAsync("Bop", 0.5f); + if (growLevel == 4) BrowAnim.DoScaledAnimationAsync("Bop", 0.5f); + if (growLevel > 0) StacheAnim.DoScaledAnimationAsync($"Bop{growLevel}", 0.5f); + })); } + + if (actions.Count > 0) BeatAction.New(this, actions); } public void InputFunctions(int whichVar, float state = 0) diff --git a/Assets/Scripts/Games/OctopusMachine/OctopusMachine.cs b/Assets/Scripts/Games/OctopusMachine/OctopusMachine.cs index 18fdf4eeb..695958733 100644 --- a/Assets/Scripts/Games/OctopusMachine/OctopusMachine.cs +++ b/Assets/Scripts/Games/OctopusMachine/OctopusMachine.cs @@ -229,6 +229,7 @@ namespace HeavenStudio.Games void Awake() { instance = this; + SetupBopRegion("octopusMachine", "bop", "keepBop"); } private void Start() @@ -263,8 +264,11 @@ namespace HeavenStudio.Games if (autoAction) bopIterate++; + bool keepBop = BeatIsInBopRegion(beat); + foreach (var octo in octopodes) { + octo.cantBop = !keepBop; octo.RequestBop(); } } @@ -339,7 +343,6 @@ namespace HeavenStudio.Games foreach (var octo in octopodes) { if (singleBop) octo.PlayAnimation(whichBop); if (keepBop) bopStatus = whichBop; - octo.cantBop = !keepBop; } } diff --git a/Assets/Scripts/Games/RhythmRally/RhythmRally.cs b/Assets/Scripts/Games/RhythmRally/RhythmRally.cs index 0b808c355..8bb9d1cfe 100644 --- a/Assets/Scripts/Games/RhythmRally/RhythmRally.cs +++ b/Assets/Scripts/Games/RhythmRally/RhythmRally.cs @@ -152,8 +152,6 @@ namespace HeavenStudio.Games public Paddlers paddlers; - private bool goBop = true; - public static RhythmRally instance; private void Awake() @@ -166,6 +164,7 @@ namespace HeavenStudio.Games playerAnim.Play("Idle", 0, 0); opponentAnim.Play("Idle", 0, 0); + SetupBopRegion("rhythmRally", "bop", "bopAuto"); } const float tableHitTime = 0.58f; @@ -366,7 +365,7 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { - if (goBop && !inPose) + if (BeatIsInBopRegion(beat) && !inPose) { BopSingle(); } @@ -374,7 +373,6 @@ namespace HeavenStudio.Games public void Bop(double beat, float length, bool bop, bool bopAuto) { - goBop = bopAuto; if (bop) { for (int i = 0; i < length; i++) diff --git a/Assets/Scripts/Games/RhythmSomen/RhythmSomen.cs b/Assets/Scripts/Games/RhythmSomen/RhythmSomen.cs index ec54051b5..46bd45c39 100644 --- a/Assets/Scripts/Games/RhythmSomen/RhythmSomen.cs +++ b/Assets/Scripts/Games/RhythmSomen/RhythmSomen.cs @@ -70,23 +70,21 @@ namespace HeavenStudio.Games public Animator CloseCrane; public Animator FarCrane; public GameObject Player; - private bool shouldBop = true; private bool missed; private bool hasSlurped; - public GameEvent bop = new GameEvent(); - public static RhythmSomen instance; // Start is called before the first frame update void Awake() { instance = this; + SetupBopRegion("rhythmSomen", "bop", "toggle"); } public override void OnBeatPulse(double beat) { - if (shouldBop) SomenPlayer.DoScaledAnimationAsync("HeadBob", 0.5f); + if (BeatIsInBopRegion(beat)) SomenPlayer.DoScaledAnimationAsync("HeadBob", 0.5f); } void Update() @@ -125,7 +123,6 @@ namespace HeavenStudio.Games public void ToggleBop(double beat, float length, bool bopOrNah, bool autoBop) { - shouldBop = autoBop; if (bopOrNah) { for (int i = 0; i < length; i++) diff --git a/Assets/Scripts/Games/Ringside/Ringside.cs b/Assets/Scripts/Games/Ringside/Ringside.cs index 5da8b759b..ce77e8ea7 100644 --- a/Assets/Scripts/Games/Ringside/Ringside.cs +++ b/Assets/Scripts/Games/Ringside/Ringside.cs @@ -143,7 +143,6 @@ namespace HeavenStudio.Games private float currentZoomCamBeat; private Vector3 lastCamPos = new Vector3(0, 0, -10); private Vector3 currentCamPos = new Vector3(0, 0, -10); - private bool shouldBop = true; private bool missedBigGuy; private bool reporterShouldHeart; private bool hitPose; @@ -201,6 +200,7 @@ namespace HeavenStudio.Games void Awake() { instance = this; + SetupBopRegion("ringside", "toggleBop", "bop"); var camEvents = EventCaller.GetAllInGameManagerList("ringside", new string[] { "poseForTheFans" }); List tempEvents = new List(); for (int i = 0; i < camEvents.Count; i++) @@ -220,7 +220,7 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { - if (shouldBop && canBop) + if (BeatIsInBopRegion(beat) && canBop) { if (UnityEngine.Random.Range(1, 18) == 1) { @@ -331,7 +331,6 @@ namespace HeavenStudio.Games public void ToggleBop(double beat, float length, bool startBopping, bool autoBop) { - shouldBop = autoBop; if (startBopping) { for (int i = 0; i < length; i++) @@ -510,7 +509,7 @@ namespace HeavenStudio.Games new BeatAction.Action(beat + 1, delegate { PoseCheck(beat); }), new BeatAction.Action(beat + 4f, delegate { - if (shouldBop) + if (BeatIsInBopRegion(beat + 4f)) { if (UnityEngine.Random.Range(1, 18) == 1) { diff --git a/Assets/Scripts/Games/SamuraiSliceNtr/SamuraiSliceNtr.cs b/Assets/Scripts/Games/SamuraiSliceNtr/SamuraiSliceNtr.cs index 13d41c7e2..1d422b5a1 100644 --- a/Assets/Scripts/Games/SamuraiSliceNtr/SamuraiSliceNtr.cs +++ b/Assets/Scripts/Games/SamuraiSliceNtr/SamuraiSliceNtr.cs @@ -89,6 +89,7 @@ namespace HeavenStudio.Games.Loaders namespace HeavenStudio.Games { + using JetBrains.Annotations; using Scripts_NtrSamurai; public class SamuraiSliceNtr : Minigame @@ -102,15 +103,12 @@ namespace HeavenStudio.Games public enum WhoBops { - Samurai = 0, + Samurai = 2, Children = 1, - Both = 2, + Both = 0, None = 3 } - private bool goBopSamurai = true; - private bool goBopChild = true; - [Header("References")] public NtrSamurai player; public GameObject launcher; @@ -167,10 +165,15 @@ namespace HeavenStudio.Games private void Awake() { instance = this; + SetupBopRegion("samuraiSliceNtr", "bop", "whoBopsAuto", false); } public override void OnBeatPulse(double beat) { + int whoBopsAuto = BeatIsInBopRegionInt(beat); + bool goBopSamurai = whoBopsAuto == (int)WhoBops.Samurai || whoBopsAuto == (int)WhoBops.Both; + bool goBopChild = whoBopsAuto == (int)WhoBops.Children || whoBopsAuto == (int)WhoBops.Both; + if (goBopSamurai) player.Bop(); if (goBopChild) childParent.GetComponent().Bop(); } @@ -187,8 +190,6 @@ namespace HeavenStudio.Games public void Bop(double beat, float length, int whoBops, int whoBopsAuto) { - goBopSamurai = whoBopsAuto == (int)WhoBops.Samurai || whoBopsAuto == (int)WhoBops.Both; - goBopChild = whoBopsAuto == (int)WhoBops.Children || whoBopsAuto == (int)WhoBops.Both; for (int i = 0; i < length; i++) { BeatAction.New(instance, new List() diff --git a/Assets/Scripts/Games/SpaceDance/SpaceDance.cs b/Assets/Scripts/Games/SpaceDance/SpaceDance.cs index 45668df13..e061c5e58 100644 --- a/Assets/Scripts/Games/SpaceDance/SpaceDance.cs +++ b/Assets/Scripts/Games/SpaceDance/SpaceDance.cs @@ -144,7 +144,6 @@ namespace HeavenStudio.Games public Animator Gramps; public Animator Hit; public GameObject Player; - [NonSerialized] public bool shouldBop = true; bool canBop = true; bool grampsCanBop = true; public bool spaceGrampsShouldBop = false; @@ -226,11 +225,12 @@ namespace HeavenStudio.Games instance = this; colorStart = defaultBGColor; colorEnd = defaultBGColor; + SetupBopRegion("spaceDance", "bop", "auto"); } public override void OnBeatPulse(double beat) { - if (shouldBop) + if (BeatIsInBopRegion(beat)) { Bop(); } @@ -656,7 +656,6 @@ namespace HeavenStudio.Games public void EpicBop(double beat, float length, bool autoDancers, bool dancers, bool autoGramps, bool gramps) { - shouldBop = autoDancers; spaceGrampsShouldBop = autoGramps; if (dancers || gramps) { diff --git a/Assets/Scripts/Games/TapTrial/TapTrial.cs b/Assets/Scripts/Games/TapTrial/TapTrial.cs index 5c0eb84af..89df2aeb7 100644 --- a/Assets/Scripts/Games/TapTrial/TapTrial.cs +++ b/Assets/Scripts/Games/TapTrial/TapTrial.cs @@ -110,9 +110,7 @@ namespace HeavenStudio.Games [SerializeField] private float monkeyJumpHeight = 3f; [SerializeField] private float maxFlashOpacity = 0.8f; - private GameEvent bop = new(); private bool canBop = true; - private bool shouldBop = true; private double jumpStartBeat = double.MinValue; @@ -121,11 +119,12 @@ namespace HeavenStudio.Games private void Awake() { instance = this; + SetupBopRegion("tapTrial", "bop", "toggle2"); } public override void OnBeatPulse(double beat) { - if (shouldBop) SingleBop(); + if (BeatIsInBopRegion(beat)) SingleBop(); } private void Update() @@ -253,7 +252,6 @@ namespace HeavenStudio.Games public void Bop(double beat, float length, bool bop, bool autoBop) { - shouldBop = autoBop; if (bop) { List actions = new(); diff --git a/Assets/Scripts/Games/TheDazzles/TheDazzles.cs b/Assets/Scripts/Games/TheDazzles/TheDazzles.cs index 2a35b7e28..0592d454b 100644 --- a/Assets/Scripts/Games/TheDazzles/TheDazzles.cs +++ b/Assets/Scripts/Games/TheDazzles/TheDazzles.cs @@ -228,8 +228,6 @@ namespace HeavenStudio.Games bool doingPoses = false; bool shouldHold = false; double crouchEndBeat; - public bool shouldBop = true; - public GameEvent bop = new GameEvent(); static List queuedPoses = new List(); static List queuedCrouches = new List(); [Header("Components")] @@ -255,11 +253,12 @@ namespace HeavenStudio.Games void Awake() { instance = this; + SetupBopRegion("theDazzles", "bop", "toggle"); } public override void OnBeatPulse(double beat) { - if (shouldBop) + if (BeatIsInBopRegion(beat)) { foreach (var girl in npcGirls) { @@ -353,7 +352,6 @@ namespace HeavenStudio.Games public void Bop(double beat, float length, bool goBop, bool autoBop) { - shouldBop = autoBop; if (goBop) { for (int i = 0; i < length; i++) diff --git a/Assets/Scripts/Games/TossBoys/TossBoys.cs b/Assets/Scripts/Games/TossBoys/TossBoys.cs index 6fb612563..b583bd972 100644 --- a/Assets/Scripts/Games/TossBoys/TossBoys.cs +++ b/Assets/Scripts/Games/TossBoys/TossBoys.cs @@ -147,8 +147,6 @@ namespace HeavenStudio.Games Dictionary passBallDict = new(); string currentPassType; public static TossBoys instance; - bool shouldBop = true; - public GameEvent bop = new GameEvent(); float currentEventLength; const int IAAka = IAMAXCAT; @@ -236,6 +234,7 @@ namespace HeavenStudio.Games instance = this; colorStart = defaultBGColor; colorEnd = defaultBGColor; + SetupBopRegion("tossBoys", "bop", "auto"); } new void OnDrawGizmos() @@ -264,7 +263,7 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { - if (shouldBop) + if (BeatIsInBopRegion(beat)) { SingleBop(); } @@ -352,7 +351,6 @@ namespace HeavenStudio.Games public void Bop(double beat, float length, bool auto, bool goBop) { - shouldBop = auto; if (goBop) { List bops = new List(); diff --git a/Assets/Scripts/Games/TrickClass/TrickClass.cs b/Assets/Scripts/Games/TrickClass/TrickClass.cs index 31dda092e..c7394294f 100644 --- a/Assets/Scripts/Games/TrickClass/TrickClass.cs +++ b/Assets/Scripts/Games/TrickClass/TrickClass.cs @@ -114,12 +114,13 @@ namespace HeavenStudio.Games private void Awake() { instance = this; + SetupBopRegion("trickClass", "bop", "autoBop"); } public override void OnBeatPulse(double beat) { var cond = Conductor.instance; - if (!goBop) return; + if (!BeatIsInBopRegion(beat)) return; if ((!playerReady) && cond.songPositionInBeatsAsDouble > playerBopStart) playerAnim.DoScaledAnimationAsync("Bop");