2023-02-23 00:25:14 +00:00
using HeavenStudio.Util ;
2023-10-29 19:44:47 +00:00
using HeavenStudio.InputSystem ;
2023-02-23 00:25:14 +00:00
using System ;
using System.Collections.Generic ;
using UnityEngine ;
2023-12-31 04:06:31 +00:00
using System.Linq ;
2023-02-23 00:25:14 +00:00
namespace HeavenStudio.Games.Loaders
{
using static Minigames ;
2023-12-31 04:06:31 +00:00
public static class PcoMeatLoader
2023-02-23 00:25:14 +00:00
{
2023-10-29 19:44:47 +00:00
public static Minigame AddGame ( EventCaller eventCaller )
{
2023-12-31 04:06:31 +00:00
List < Param > reactionParams = new ( ) {
new Param ( "tackReaction" , MeatGrinder . TackExpressions . None , "Tack Reaction" , "If this is hit, what expression should tack do?" , new List < Param . CollapseParam > ( ) {
new ( ( x , y ) = > ( int ) x ! = ( int ) MeatGrinder . TackExpressions . None , new string [ ] { "tackReactionBeats" } ) ,
} ) ,
new Param ( "tackReactionBeats" , new EntityTypes . Float ( 0.5f , 10 , 1 ) , "Tack React After" , "The amount of beats to wait until tack reacts" ) ,
new Param ( "bossReaction" , MeatGrinder . BossExpressions . None , "Boss Reaction" , "If this is hit, what expression should boss do?" , new List < Param . CollapseParam > ( ) {
new ( ( x , y ) = > ( int ) x ! = ( int ) MeatGrinder . BossExpressions . None , new string [ ] { "bossReactionBeats" } ) ,
} ) ,
new Param ( "bossReactionBeats" , new EntityTypes . Float ( 0 , 10 , 0 ) , "Boss React After" , "The amount of beats to wait until boss reacts" ) ,
} ;
2023-04-02 02:28:23 +00:00
return new Minigame ( "meatGrinder" , "Meat Grinder" , "501d18" , false , false , new List < GameAction > ( )
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
new GameAction ( "bop" , "Bop" )
{
function = delegate {
var e = eventCaller . currentEntity ;
MeatGrinder . instance . Bop ( e . beat , e . length , e [ "bop" ] , e [ "bossBop" ] ) ;
} ,
parameters = new List < Param > ( )
{
new Param ( "bop" , true , "Boss Bops?" , "Does Boss bop?" ) ,
new Param ( "bossBop" , false , "Boss Bops? (Auto)" , "Does Boss Auto bop?" ) ,
} ,
resizable = true ,
priority = 1 ,
} ,
2023-02-23 00:25:14 +00:00
new GameAction ( "MeatToss" , "Meat Toss" )
{
function = delegate {
2023-10-29 19:44:47 +00:00
var e = eventCaller . currentEntity ;
2023-12-31 04:06:31 +00:00
SoundByte . PlayOneShotGame ( "meatGrinder/toss" , forcePlay : true ) ;
MeatGrinder . instance . MeatToss ( e . beat , e [ "bacon" ] , e [ "tackReaction" ] , e [ "tackReactionBeats" ] , e [ "bossReaction" ] , e [ "bossReactionBeats" ] ) ;
} ,
inactiveFunction = delegate {
SoundByte . PlayOneShotGame ( "meatGrinder/toss" , forcePlay : true ) ;
MeatGrinder . QueueMeatToss ( eventCaller . currentEntity ) ;
2023-02-23 00:25:14 +00:00
} ,
defaultLength = 2f ,
priority = 2 ,
2023-12-31 04:06:31 +00:00
parameters = new List < Param > ( )
{
new Param ( "bacon" , false , "Bacon Ball" , "Throw a bacon ball instead of the typical meat" ) ,
} . Concat ( reactionParams ) . ToList ( ) , // doing this because i want these params to always be the same
2023-02-23 00:25:14 +00:00
} ,
2023-12-31 04:06:31 +00:00
new GameAction ( "StartInterval" , "Start Interval" )
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
defaultLength = 4f ,
resizable = true ,
preFunction = delegate
{
2023-10-29 19:44:47 +00:00
var e = eventCaller . currentEntity ;
2023-12-31 04:06:31 +00:00
MeatGrinder . PreInterval ( e . beat , e . length , e [ "auto" ] ) ;
} ,
parameters = new List < Param > ( )
{
new Param ( "auto" , true , "Auto Pass Turn" )
2023-02-23 00:25:14 +00:00
} ,
2023-12-31 04:06:31 +00:00
preFunctionLength = 1
} ,
new GameAction ( "MeatCall" , "Meat Call" )
{
inactiveFunction = delegate { SoundByte . PlayOneShotGame ( "meatGrinder/signal" , forcePlay : true ) ; } ,
2023-02-23 00:25:14 +00:00
defaultLength = 0.5f ,
priority = 2 ,
2023-03-18 04:40:20 +00:00
preFunctionLength = 1f ,
2023-12-31 04:06:31 +00:00
parameters = reactionParams ,
} ,
new GameAction ( "passTurn" , "Pass Turn" )
{
preFunction = delegate { MeatGrinder . PrePassTurn ( eventCaller . currentEntity . beat ) ; } ,
preFunctionLength = 1
} ,
new GameAction ( "expressions" , "Expressions" )
{
function = delegate {
2023-10-29 19:44:47 +00:00
var e = eventCaller . currentEntity ;
2023-12-31 04:06:31 +00:00
MeatGrinder . instance . DoExpressions ( e [ "tackExpression" ] , e [ "bossExpression" ] ) ;
2023-03-18 04:40:20 +00:00
} ,
2023-12-31 04:06:31 +00:00
parameters = new List < Param > ( ) {
new Param ( "tackExpression" , MeatGrinder . TackExpressions . Content , "Tack Expression" , "The expression Tack will display" ) ,
new Param ( "bossExpression" , MeatGrinder . BossExpressions . None , "Boss Expression" , "The expression Boss will display" ) ,
}
2023-02-23 00:25:14 +00:00
} ,
2023-12-31 04:06:31 +00:00
new GameAction ( "cartGuy" , "Cart Guy" )
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
function = delegate {
2023-05-07 04:45:44 +00:00
var e = eventCaller . currentEntity ;
2023-12-31 04:06:31 +00:00
MeatGrinder . instance . CartGuy ( e . beat , e . length , e [ "spider" ] , e [ "direction" ] , e [ "ease" ] ) ;
2023-02-23 00:25:14 +00:00
} ,
2023-12-31 04:06:31 +00:00
resizable = true ,
defaultLength = 16 ,
parameters = new List < Param > ( ) {
new Param ( "spider" , false , "On Phone" , "Put a spider in the box?" ) ,
new Param ( "direction" , MeatGrinder . CartGuyDirection . Right , "Direction" , "The direction the cart will be carted to." ) ,
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "What ease will the cart use?" ) ,
}
2023-02-23 00:25:14 +00:00
} ,
2023-12-31 04:06:31 +00:00
new GameAction ( "gears" , "Gears" )
2023-02-23 00:25:14 +00:00
{
function = delegate {
2023-10-29 19:44:47 +00:00
var e = eventCaller . currentEntity ;
2023-12-31 04:06:31 +00:00
MeatGrinder . instance . ChangeGears ( e . beat , e . length , e [ "ease" ] , e [ "speed" ] ) ;
2023-02-23 00:25:14 +00:00
} ,
2023-03-07 17:22:32 +00:00
resizable = true ,
2023-12-31 04:06:31 +00:00
defaultLength = 1 ,
parameters = new List < Param > ( ) {
new Param ( "speed" , new EntityTypes . Float ( 0 , 10 , 1 ) , "Speed" , "How fast will the gears go?" ) ,
new Param ( "ease" , Util . EasingFunction . Ease . Linear , "Ease" , "What ease will the gears speed up/slow down with?" ) ,
}
2023-02-23 00:25:14 +00:00
} ,
2024-01-13 02:40:35 +00:00
} ,
new List < string > ( ) { "pco" , "normal" , "repeat" } ,
"pcomeat" , "en" ,
new List < string > ( ) { }
2023-05-28 17:34:44 +00:00
) ;
2023-02-23 00:25:14 +00:00
}
}
}
namespace HeavenStudio.Games
{
2023-12-31 04:06:31 +00:00
using Jukebox ;
2023-02-23 00:25:14 +00:00
using Scripts_MeatGrinder ;
2023-12-31 04:06:31 +00:00
2023-02-23 00:25:14 +00:00
public class MeatGrinder : Minigame
{
2023-12-31 04:06:31 +00:00
private static List < QueuedInterval > queuedIntervals = new ( ) ;
private struct QueuedInterval
{
public double beat ;
public float length ;
public bool autoPassTurn ;
}
public struct UpdateEasing
2023-05-07 04:45:44 +00:00
{
2023-06-10 19:17:06 +00:00
public double beat ;
2023-12-31 04:06:31 +00:00
public float length ;
public Util . EasingFunction . Ease ease ;
2023-05-07 04:45:44 +00:00
}
2023-02-23 00:25:14 +00:00
2023-12-31 04:06:31 +00:00
public struct Reaction
{
public int expression ;
public double beat ;
public Reaction ( int expression , double beat ) {
this . expression = expression ;
this . beat = beat ;
}
}
// private static List<RiqEntity> queuedMeats = new();
2023-02-23 00:25:14 +00:00
[Header("Objects")]
public GameObject MeatBase ;
2023-12-31 04:06:31 +00:00
public ParticleSystem MeatSplash ;
[SerializeField] Transform [ ] Gears ;
2023-02-23 00:25:14 +00:00
[Header("Animators")]
public Animator BossAnim ;
public Animator TackAnim ;
2023-12-31 04:06:31 +00:00
[SerializeField] Animator CartGuyParentAnim ;
[SerializeField] Animator CartGuyAnim ;
2023-02-23 00:25:14 +00:00
[Header("Variables")]
2023-12-31 04:06:31 +00:00
private bool bossBop = true ;
2023-02-23 00:25:14 +00:00
public bool bossAnnoyed = false ;
2023-12-31 04:06:31 +00:00
private UpdateEasing cartEase ;
private bool cartPhone = false ;
private string cartDir = "Left" ;
private UpdateEasing gearEase ;
private float oldGearSpeed = 1 ;
private float newGearSpeed = 1 ;
private const string sfxName = "meatGrinder/" ;
2023-02-23 00:25:14 +00:00
public static MeatGrinder instance ;
2023-12-31 04:06:31 +00:00
public enum TackExpressions
{
None ,
Content ,
Smug ,
Wonder ,
}
public enum BossExpressions
{
None ,
Eyebrow ,
Scared ,
}
public enum CartGuyDirection
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
Right ,
Left ,
2023-02-23 00:25:14 +00:00
}
2023-10-29 19:44:47 +00:00
protected static bool IA_PadAny ( out double dt )
{
return PlayerInput . GetPadDown ( InputController . ActionsPad . East , out dt )
| | PlayerInput . GetPadDown ( InputController . ActionsPad . Up , out dt )
| | PlayerInput . GetPadDown ( InputController . ActionsPad . Down , out dt )
| | PlayerInput . GetPadDown ( InputController . ActionsPad . Left , out dt )
| | PlayerInput . GetPadDown ( InputController . ActionsPad . Right , out dt ) ;
}
public static PlayerInput . InputAction InputAction_Press =
2023-12-31 04:06:31 +00:00
new ( "PcoMeatPress" , new int [ ] { IAPressCat , IAPressCat , IAPressCat } ,
2023-10-29 19:44:47 +00:00
IA_PadAny , IA_TouchBasicPress , IA_BatonBasicPress ) ;
2023-02-23 00:25:14 +00:00
private void Awake ( )
{
instance = this ;
2023-12-05 22:38:52 +00:00
SetupBopRegion ( "meatGrinder" , "bop" , "bossBop" ) ;
2023-12-31 04:06:31 +00:00
MeatBase . SetActive ( false ) ;
2023-02-23 00:25:14 +00:00
}
2023-10-29 19:44:47 +00:00
private void Update ( )
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
var cond = Conductor . instance ;
2023-10-29 19:44:47 +00:00
if ( PlayerInput . GetIsAction ( InputAction_Press ) & & ! IsExpectingInputNow ( InputAction_Press ) )
{
2023-02-23 00:25:14 +00:00
TackAnim . DoScaledAnimationAsync ( "TackEmptyHit" , 0.5f ) ;
TackAnim . SetBool ( "tackMeated" , false ) ;
2023-12-31 04:06:31 +00:00
SoundByte . PlayOneShotGame ( "meatGrinder/whiff" ) ;
2023-06-10 20:55:10 +00:00
bossAnnoyed = false ;
2023-02-23 00:25:14 +00:00
}
if ( bossAnnoyed ) BossAnim . SetBool ( "bossAnnoyed" , true ) ;
2023-05-07 04:45:44 +00:00
2023-12-31 04:06:31 +00:00
if ( passedTurns . Count > 0 )
2023-10-29 19:44:47 +00:00
{
2023-12-31 04:06:31 +00:00
foreach ( double pass in passedTurns )
{
PassTurnStandalone ( pass ) ;
}
passedTurns . Clear ( ) ;
}
var currentGearSpeed = newGearSpeed ;
if ( gearEase . length ! = 0 )
{
float normalizedBeat = cond . GetPositionFromBeat ( gearEase . beat , gearEase . length ) ;
Util . EasingFunction . Function func = Util . EasingFunction . GetEasingFunction ( gearEase . ease ) ;
currentGearSpeed = func ( oldGearSpeed , newGearSpeed , normalizedBeat ) ;
if ( normalizedBeat > = 1 ) cartEase . length = 0 ;
}
if ( cartEase . length ! = 0 )
{
float normalizedBeat = cond . GetPositionFromBeat ( cartEase . beat , cartEase . length ) ;
Util . EasingFunction . Function func = Util . EasingFunction . GetEasingFunction ( cartEase . ease ) ;
float newPos = func ( 0f , 1f , normalizedBeat ) ;
CartGuyParentAnim . DoNormalizedAnimation ( $"Move{cartDir}" , newPos ) ;
if ( normalizedBeat > = 1 ) cartEase . length = 0 ;
}
CartGuyParentAnim . gameObject . SetActive ( cartEase . length ! = 0 ) ;
if ( cond . isPlaying & & ! cond . isPaused ) {
foreach ( Transform gear in Gears ) {
double newZ = Time . deltaTime * currentGearSpeed * 50 * ( gear . name = = "Big" ? - 1 : 1 ) / cond . pitchedSecPerBeat ;
gear . Rotate ( new Vector3 ( 0 , 0 , ( float ) newZ ) ) ;
}
}
if ( cond . isPlaying ) {
MeatSplash . Play ( ) ;
} else if ( cond . isPaused ) {
MeatSplash . Pause ( ) ;
} else {
MeatSplash . Stop ( ) ;
2023-05-07 04:45:44 +00:00
}
2023-02-23 00:25:14 +00:00
}
2023-12-31 04:06:31 +00:00
public override void OnLateBeatPulse ( double beat )
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
if ( ! BossAnim . IsPlayingAnimationNames ( "BossCall" , "BossSignal" , "BossScared" ) & & BeatIsInBopRegion ( beat ) )
2023-02-23 00:25:14 +00:00
{
BossAnim . DoScaledAnimationAsync ( bossAnnoyed ? "BossMiss" : "Bop" , 0.5f ) ;
2023-06-04 04:30:42 +00:00
}
2023-12-31 04:06:31 +00:00
if ( CartGuyParentAnim . gameObject . activeSelf ) {
Debug . Log ( cartPhone ? "PhoneBop" : "Bop" ) ;
if ( cartPhone ) {
CartGuyAnim . DoScaledAnimationAsync ( "PhoneBop" , 0.5f ) ;
} else {
CartGuyAnim . DoScaledAnimationAsync ( "Bop" , 0.5f ) ;
}
}
}
public override void OnGameSwitch ( double beat )
{
if ( queuedIntervals . Count > 0 )
{
foreach ( var interval in queuedIntervals ) StartInterval ( interval . beat , interval . length , beat , interval . autoPassTurn ) ;
queuedIntervals . Clear ( ) ;
}
// if (queuedMeats.Count > 0)
// {
// foreach (var meat in queuedMeats) MeatToss(meat.beat, meat["bacon"], meat["tackReaction"], meat["tackReactionBeats"], meat["bossReaction"], meat["bossReactionBeats"]);
// queuedMeats.Clear();
// }
OnPlay ( beat ) ;
}
public override void OnPlay ( double beat )
{
List < RiqEntity > allEntities = GameManager . instance . Beatmap . Entities . FindAll ( c = > c . datamodel . Split ( '/' ) [ 0 ] = = "meatGrinder" ) ;
RiqEntity cg = allEntities . Find ( c = > c . datamodel = = "meatGrinder/cartGuy" ) ;
if ( cg ! = null ) {
CartGuy ( cg . beat , cg . length , cg [ "spider" ] , cg [ "direction" ] , cg [ "ease" ] ) ;
}
RiqEntity gr = allEntities . Find ( c = > c . datamodel = = "meatGrinder/gears" ) ;
if ( gr ! = null ) {
ChangeGears ( gr . beat , gr . length , gr [ "ease" ] , gr [ "speed" ] ) ;
}
List < RiqEntity > meats = allEntities . FindAll ( c = > c . datamodel = = "meatGrinder/MeatToss" & & beat > c . beat & & beat < c . beat + 1 ) ;
foreach ( var meat in meats ) {
MeatToss ( meat . beat , meat [ "bacon" ] , meat [ "tackReaction" ] , meat [ "tackReactionBeats" ] , meat [ "bossReaction" ] , meat [ "bossReactionBeats" ] ) ;
}
}
private List < RiqEntity > GetRelevantMeatCallsBetweenBeat ( double beat , double endBeat )
{
return EventCaller . GetAllInGameManagerList ( "meatGrinder" , new string [ ] { "MeatCall" } ) . FindAll ( x = > x . beat > = beat & & x . beat < endBeat ) ;
2023-02-23 00:25:14 +00:00
}
2023-06-10 20:55:10 +00:00
public void Bop ( double beat , double length , bool doesBop , bool autoBop )
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
bossBop = autoBop ;
2023-10-29 19:44:47 +00:00
if ( doesBop )
{
2023-12-31 04:06:31 +00:00
var actions = new List < BeatAction . Action > ( ) ;
2023-10-29 19:44:47 +00:00
for ( int i = 0 ; i < length ; i + + )
{
2023-12-31 04:06:31 +00:00
actions . Add ( new BeatAction . Action ( beat + i , delegate {
if ( ! BossAnim . IsPlayingAnimationNames ( "BossCall" , "BossSignal" ) ) {
BossAnim . DoScaledAnimationAsync ( bossAnnoyed ? "BossMiss" : "Bop" , 0.5f ) ;
}
} ) ) ;
2023-03-07 17:22:32 +00:00
}
2023-12-31 04:06:31 +00:00
BeatAction . New ( instance , actions ) ;
2023-03-07 17:22:32 +00:00
}
2023-02-23 00:25:14 +00:00
}
2023-12-31 04:06:31 +00:00
public void DoExpressions ( int tackExpression , int bossExpression = 0 )
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
if ( tackExpression ! = ( int ) TackExpressions . None ) {
string tackAnim = ( ( TackExpressions ) tackExpression ) . ToString ( ) ;
TackAnim . DoScaledAnimationAsync ( "Tack" + tackAnim , 0.5f ) ;
}
if ( bossExpression ! = ( int ) BossExpressions . None ) {
string bossAnim = ( ( BossExpressions ) bossExpression ) . ToString ( ) ;
BossAnim . DoScaledAnimationAsync ( "Boss" + bossAnim , 0.5f ) ;
}
}
2023-02-23 00:25:14 +00:00
2023-12-31 04:06:31 +00:00
public void CartGuy ( double beat , float length , bool spider , int direction , int ease )
{
cartEase = new ( ) {
beat = beat ,
length = length ,
ease = ( Util . EasingFunction . Ease ) ease ,
} ;
cartPhone = spider ;
cartDir = direction = = 0 ? "Right" : "Left" ;
if ( cartPhone ) {
CartGuyAnim . Play ( "Phone" , 0 , 0 ) ;
}
}
public void ChangeGears ( double beat , float length , int ease , float speed )
{
gearEase = new ( ) {
2023-05-07 04:45:44 +00:00
beat = beat ,
length = length ,
2023-12-31 04:06:31 +00:00
ease = ( Util . EasingFunction . Ease ) ease ,
} ;
2023-02-23 00:25:14 +00:00
2023-12-31 04:06:31 +00:00
oldGearSpeed = newGearSpeed ;
newGearSpeed = speed ;
}
public static void PreInterval ( double beat , float length , bool autoPassTurn )
{
2023-06-10 20:55:10 +00:00
SoundByte . PlayOneShotGame ( "meatGrinder/startSignal" , beat - 1 , forcePlay : true ) ;
2023-05-07 04:45:44 +00:00
2023-10-29 19:44:47 +00:00
if ( GameManager . instance . currentGame = = "meatGrinder" )
{
2023-12-31 04:06:31 +00:00
instance . StartInterval ( beat , length , beat , autoPassTurn ) ;
}
else
{
queuedIntervals . Add ( new QueuedInterval ( )
{
beat = beat ,
length = length ,
autoPassTurn = autoPassTurn
2023-10-29 19:44:47 +00:00
} ) ;
2023-05-07 04:45:44 +00:00
}
2023-02-23 00:25:14 +00:00
}
2023-12-31 04:06:31 +00:00
public void StartInterval ( double beat , float length , double gameSwitchBeat , bool autoPassTurn )
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
List < BeatAction . Action > actions = new ( ) {
new ( beat - 1 , delegate { if ( Conductor . instance . songPositionInBeatsAsDouble < beat ) BossAnim . DoScaledAnimationFromBeatAsync ( "BossSignal" , 0.5f , beat - 1 ) ; } ) ,
} ;
var allCallEvents = GetRelevantMeatCallsBetweenBeat ( beat , beat + length ) ;
allCallEvents . Sort ( ( x , y ) = > x . beat . CompareTo ( y . beat ) ) ;
for ( int i = 0 ; i < allCallEvents . Count ; i + + )
{
double eventBeat = allCallEvents [ i ] . beat ;
if ( eventBeat > = gameSwitchBeat )
{
actions . Add ( new BeatAction . Action ( eventBeat , delegate
{
BossAnim . DoScaledAnimationAsync ( "BossCall" , 0.5f ) ;
SoundByte . PlayOneShotGame ( "meatGrinder/signal" ) ;
} ) ) ;
}
}
2023-05-07 04:45:44 +00:00
2023-12-31 04:06:31 +00:00
BeatAction . New ( this , actions ) ;
2023-02-23 00:25:14 +00:00
2023-12-31 04:06:31 +00:00
if ( autoPassTurn )
{
PassTurn ( beat + length , beat , length , allCallEvents ) ;
}
2023-02-23 00:25:14 +00:00
}
2023-10-29 19:44:47 +00:00
2023-12-31 04:06:31 +00:00
public static void QueueMeatToss ( RiqEntity entity )
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
// queuedMeats.Add(entity);
}
2023-10-29 19:44:47 +00:00
2023-12-31 04:06:31 +00:00
public void MeatToss ( double beat , bool bacon , int tackReaction , float tackReactionBeats , int bossReaction , float bossReactionBeats )
{
Meat meat = Instantiate ( MeatBase , transform ) . GetComponent < Meat > ( ) ;
meat . gameObject . SetActive ( true ) ;
meat . startBeat = beat ;
meat . meatType = bacon ? Meat . MeatType . BaconBall : Meat . MeatType . DarkMeat ;
meat . tackReaction = new Reaction ( tackReaction , tackReactionBeats ) ;
meat . bossReaction = new Reaction ( bossReaction , bossReactionBeats ) ;
// meat.reaction = reaction;
2023-02-23 00:25:14 +00:00
}
2023-12-31 04:06:31 +00:00
public static void PrePassTurn ( double beat )
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
if ( GameManager . instance . currentGame = = "meatGrinder" )
{
instance . PassTurnStandalone ( beat ) ;
}
else
{
passedTurns . Add ( beat ) ;
}
}
2023-10-29 19:44:47 +00:00
2023-12-31 04:06:31 +00:00
private static List < double > passedTurns = new ( ) ;
2023-02-23 00:25:14 +00:00
2023-12-31 04:06:31 +00:00
private void PassTurnStandalone ( double beat )
{
var lastInterval = EventCaller . GetAllInGameManagerList ( "meatGrinder" , new string [ ] { "StartInterval" } ) . FindLast ( x = > x . beat < = beat ) ;
if ( lastInterval ! = null ) PassTurn ( beat , lastInterval . beat , lastInterval . length ) ;
2023-02-23 00:25:14 +00:00
}
2023-12-31 04:06:31 +00:00
private void PassTurn ( double beat , double intervalBeat , float intervalLength , List < RiqEntity > allCallEvents = null )
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
if ( allCallEvents = = null ) {
allCallEvents = GetRelevantMeatCallsBetweenBeat ( intervalBeat , intervalBeat + intervalLength ) ;
allCallEvents . Sort ( ( x , y ) = > x . beat . CompareTo ( y . beat ) ) ;
}
List < BeatAction . Action > meatCalls = new ( ) ;
for ( int i = 0 ; i < allCallEvents . Count ; i + + )
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
double relativeBeat = allCallEvents [ i ] . beat - intervalBeat ;
var tackReaction = new Reaction ( allCallEvents [ i ] [ "tackReaction" ] , allCallEvents [ i ] [ "tackReactionBeats" ] ) ;
var bossReaction = new Reaction ( allCallEvents [ i ] [ "bossReaction" ] , allCallEvents [ i ] [ "bossReactionBeats" ] ) ;
meatCalls . Add ( new BeatAction . Action ( beat + relativeBeat - 1 , delegate
2023-02-23 00:25:14 +00:00
{
2023-12-31 04:06:31 +00:00
Meat meat = Instantiate ( MeatBase , transform ) . GetComponent < Meat > ( ) ;
meat . gameObject . SetActive ( true ) ;
meat . startBeat = beat + relativeBeat - 1 ;
meat . meatType = Meat . MeatType . LightMeat ;
meat . tackReaction = tackReaction ;
meat . bossReaction = bossReaction ;
} ) ) ;
2023-02-23 00:25:14 +00:00
}
2023-12-31 04:06:31 +00:00
BeatAction . New ( this , meatCalls ) ;
2023-02-23 00:25:14 +00:00
}
}
}