km fix, convert all to colorease, multisounds stuff

fix that goddamn ms.startBeat = sounds[0].beat; bug + if it's already converting to a list, why not just define the sounds as a list??????? they're a list most of the time anyways

ive got work ahead of me.
This commit is contained in:
AstrlJelly 2024-02-11 01:55:26 -05:00
parent d1eb6661b9
commit 13bf8b083b
12 changed files with 93 additions and 114 deletions

View file

@ -141,7 +141,9 @@ namespace HeavenStudio
public void SetBeat(double beat) public void SetBeat(double beat)
{ {
var chart = GameManager.instance.Beatmap; var gameManager = GameManager.instance;
var chart = gameManager.Beatmap;
double offset = chart.data.offset; double offset = chart.data.offset;
startPos = GetSongPosFromBeat(beat); startPos = GetSongPosFromBeat(beat);
@ -152,9 +154,13 @@ namespace HeavenStudio
SeekMusicToTime(startPos, offset); SeekMusicToTime(startPos, offset);
var oldSongPosBeat = songPosBeat;
songPosBeat = GetBeatFromSongPos(time); songPosBeat = GetBeatFromSongPos(time);
if (oldSongPosBeat != songPosBeat && gameManager.minigame != null) {
gameManager.minigame.OnTimelineChange(songPosBeat);
}
GameManager.instance.SetCurrentEventToClosest(beat); gameManager.SetCurrentEventToClosest(beat);
} }
public void PlaySetup(double beat) public void PlaySetup(double beat)

View file

@ -213,7 +213,7 @@ namespace HeavenStudio.Games
} }
} }
public override void OnTimeChange() public override void OnTimelineChange(double beat)
{ {
UpdateCameraZoom(); UpdateCameraZoom();
} }

View file

@ -67,10 +67,10 @@ namespace HeavenStudio.Games.Loaders
resizable = true, resizable = true,
parameters = new List<Param>() parameters = new List<Param>()
{ {
new Param("colorAStart", new Color(43/255f, 207/255f, 51/255f), "Color A Start", "Set the top-most color of the background gradient at the start of the event."), new Param("colorAStart", new Color(43/255f, 207/255f, 51/255f), "Top Color Start", "Set the top-most color of the background gradient at the start of the event."),
new Param("colorA", new Color(43/255f, 207/255f, 51/255f), "Color A End", "Set the top-most color of the background gradient at the end of the event."), new Param("colorA", new Color(43/255f, 207/255f, 51/255f), "Top Color End", "Set the top-most color of the background gradient at the end of the event."),
new Param("colorBStart", new Color(1, 1, 1), "Color B Start", "Set the bottom-most color of the background gradient at the start of the event."), new Param("colorBStart", new Color(1, 1, 1), "Bottom Color Start", "Set the bottom-most color of the background gradient at the start of the event."),
new Param("colorB", new Color(1, 1, 1), "Color B End", "Set the bottom-most color of the background gradient at the end of the event."), new Param("colorB", new Color(1, 1, 1), "Bottom Color End", "Set the bottom-most color of the background gradient at the end of the event."),
new Param("colorC", new Color(1, 247/255f, 0), "Streak Color", "Set the color of the streaks that appear upon a successful hit."), new Param("colorC", new Color(1, 247/255f, 0), "Streak Color", "Set the color of the streaks that appear upon a successful hit."),
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.")
} }
@ -280,46 +280,22 @@ namespace HeavenStudio.Games
SetFaces(0); SetFaces(0);
} }
private double colorStartBeat = -1; private ColorEase tColorEase = new(new Color(43 / 255f, 207 / 255f, 51 / 255f)); // top gradient color
private float colorLength = 0f; private ColorEase bColorEase = new(Color.white); // bottom gradient color
private Color colorStart = new Color(43 / 255f, 207 / 255f, 51 / 255f); //obviously put to the default color of the game
private Color colorEnd = new Color(43 / 255f, 207 / 255f, 51 / 255f);
private Color colorStartB = Color.white; //obviously put to the default color of the game
private Color colorEndB = Color.white;
private Util.EasingFunction.Ease colorEase; //putting Util in case this game is using jukebox
//call this in update //call this in update
private void BackgroundColorUpdate() private void BackgroundColorUpdate()
{ {
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength)); backgroundGradient.color = GetNewColor(tColorEase);
background.color = GetNewColor(bColorEase);
var func = Util.EasingFunction.GetEasingFunction(colorEase);
float newR = func(colorStart.r, colorEnd.r, normalizedBeat);
float newG = func(colorStart.g, colorEnd.g, normalizedBeat);
float newB = func(colorStart.b, colorEnd.b, normalizedBeat);
backgroundGradient.color = new Color(newR, newG, newB);
float newRB = func(colorStartB.r, colorEndB.r, normalizedBeat);
float newGB = func(colorStartB.g, colorEndB.g, normalizedBeat);
float newBB = func(colorStartB.b, colorEndB.b, normalizedBeat);
background.color = new Color(newRB, newGB, newBB);
} }
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, Color colorStartSetB, Color colorEndSetB, Color setStreak, int ease) public void BackgroundColor(double beat, float length, Color colorStartSetT, Color colorEndSetT, Color colorStartSetB, Color colorEndSetB, Color setStreak, int ease)
{ {
colorStartBeat = beat; tColorEase = new ColorEase(beat, length, colorStartSetT, colorEndSetT, ease);
colorLength = length; bColorEase = new ColorEase(beat, length, colorStartSetB, colorEndSetB, ease);
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorStartB = colorStartSetB;
colorEndB = colorEndSetB;
colorEase = (Util.EasingFunction.Ease)ease;
foreach (SpriteRenderer streak in streaks) foreach (SpriteRenderer streak in streaks) {
{
streak.color = new Color(setStreak.r, setStreak.g, setStreak.b, streak.color.a); streak.color = new Color(setStreak.r, setStreak.g, setStreak.b, streak.color.a);
} }
} }

View file

@ -117,7 +117,6 @@ namespace HeavenStudio.Games.Loaders
}, },
inactiveFunction = delegate { inactiveFunction = delegate {
var e = eventCaller.currentEntity; var e = eventCaller.currentEntity;
KarateMan.QueueCue(e);
KarateMan.CreateItemSFX(e.beat, e["type"], e["mute"]); KarateMan.CreateItemSFX(e.beat, e["type"], e["mute"]);
}, },
defaultLength = 2, defaultLength = 2,
@ -137,7 +136,6 @@ namespace HeavenStudio.Games.Loaders
}, },
inactiveFunction = delegate { inactiveFunction = delegate {
var e = eventCaller.currentEntity; var e = eventCaller.currentEntity;
KarateMan.QueueCue(e);
if (!e["mute"]) KarateMan.CreateBulbSFX(e.beat, e["type"], e["sfx"], e["throwSfx"]); if (!e["mute"]) KarateMan.CreateBulbSFX(e.beat, e["type"], e["sfx"], e["throwSfx"]);
}, },
defaultLength = 2, defaultLength = 2,
@ -167,7 +165,6 @@ namespace HeavenStudio.Games.Loaders
}, },
inactiveFunction = delegate { inactiveFunction = delegate {
var e = eventCaller.currentEntity; var e = eventCaller.currentEntity;
KarateMan.QueueCue(e);
KarateMan.KickSFX(); KarateMan.KickSFX();
}, },
defaultLength = 4f, defaultLength = 4f,
@ -196,7 +193,6 @@ namespace HeavenStudio.Games.Loaders
}, },
inactiveFunction = delegate { inactiveFunction = delegate {
var e = eventCaller.currentEntity; var e = eventCaller.currentEntity;
KarateMan.QueueCue(e);
KarateMan.ComboSFX(); KarateMan.ComboSFX();
}, },
defaultLength = 4, defaultLength = 4,
@ -310,6 +306,7 @@ namespace HeavenStudio.Games.Loaders
new Param("startTexture", new Color(), "Start Texture Color", "Set the color at the start of the event."), new Param("startTexture", new Color(), "Start Texture Color", "Set the color at the start of the event."),
new Param("endTexture", new Color(), "End Texture Color", "Set the color at the end of the event."), new Param("endTexture", new Color(), "End Texture Color", "Set the color at the end of the event."),
}, },
isVfx = true,
}, },
// new GameAction("set background effects", "Background Appearance (OLD)") // new GameAction("set background effects", "Background Appearance (OLD)")
// { // {
@ -526,7 +523,7 @@ namespace HeavenStudio.Games
} }
#endregion #endregion
static List<RiqEntity> queuedCues = new(); // static List<RiqEntity> queuedCues = new();
public static bool IsComboEnable = true; //only stops Out combo inputs, this basically makes combo contextual public static bool IsComboEnable = true; //only stops Out combo inputs, this basically makes combo contextual
// public static bool IsKickEnable = true; //same as above, except with kick inputs // public static bool IsKickEnable = true; //same as above, except with kick inputs
public bool IsNoriActive { get { return Nori.MaxNori > 0; } } public bool IsNoriActive { get { return Nori.MaxNori > 0; } }
@ -567,16 +564,6 @@ namespace HeavenStudio.Games
static double wordClearTime = double.MinValue; static double wordClearTime = double.MinValue;
[Header("Backgrounds")] [Header("Backgrounds")]
// // 0 = bg color, 1 = shadow color, 2 = filter color
// private double[] colorStartBeats = new double[3] {
// -1,
// -1,
// -1
// };
// private float[] colorLengths = new float[3];
// private Color[] colorStarts, colorEnds = new Color[3];
// private Util.EasingFunction.Ease[] colorEases = new Util.EasingFunction.Ease[3];
private ColorEase[] colorEases = new ColorEase[3]; private ColorEase[] colorEases = new ColorEase[3];
public int currentBgEffect = (int)BackgroundFXType.None; public int currentBgEffect = (int)BackgroundFXType.None;
@ -718,15 +705,17 @@ namespace HeavenStudio.Games
Update(); Update();
} }
public override void OnPlay(double beat) => OnGameSwitch(beat);
public override void OnGameSwitch(double beat) public override void OnGameSwitch(double beat)
{ {
EntityPreCheck(beat);
var entities = gameManager.Beatmap.Entities.FindAll(e => (e.datamodel is "karateman/hit" or "karateman/bulb" or "karateman/kick" or "karateman/combo") && e.beat < beat && e.beat + 1 > beat);
// queued objects // queued objects
if (queuedCues.Count > 0) foreach (var e in entities.FindAll(e => (e.datamodel is "karateman/hit" or "karateman/bulb" or "karateman/kick" or "karateman/combo") && e.beat < beat && e.beat + 1 > beat))
{
foreach (var e in queuedCues)
{
switch (e.datamodel)
{ {
switch (e.datamodel) {
case "karateman/hit": CreateItem(e.beat, e["type"], e["type2"]); break; case "karateman/hit": CreateItem(e.beat, e["type"], e["type2"]); break;
case "karateman/bulb": CreateBulbSpecial(e.beat, e["type"], e["colorA"], e["type2"], e["sfx"], e["hitSfx"]); break; case "karateman/bulb": CreateBulbSpecial(e.beat, e["type"], e["colorA"], e["type2"], e["sfx"], e["hitSfx"]); break;
case "karateman/kick": Kick(e.beat, e["toggle"], e["shouldGlow"], e["type"], e["pitchVoice"], e["forcePitch"], e["cutOut"], e["disableVoice"], e["woodColor"], e["hoopColor"]); break; case "karateman/kick": Kick(e.beat, e["toggle"], e["shouldGlow"], e["type"], e["pitchVoice"], e["forcePitch"], e["cutOut"], e["disableVoice"], e["woodColor"], e["hoopColor"]); break;
@ -734,22 +723,14 @@ namespace HeavenStudio.Games
default: Debug.LogError($"Karate Man has failed to cue an object with datamodel {e.datamodel} at beat {e.beat}"); break; default: Debug.LogError($"Karate Man has failed to cue an object with datamodel {e.datamodel} at beat {e.beat}"); break;
} }
} }
queuedCues.Clear();
}
EntityPreCheck(beat);
}
public override void OnPlay(double beat)
{
queuedCues.Clear();
EntityPreCheck(beat);
} }
public override void OnStop(double beat) => EntityPreCheck(beat);
public override void OnTimelineChange(double beat) => EntityPreCheck(beat);
void EntityPreCheck(double beat) void EntityPreCheck(double beat)
{ {
if (gameManager == null) return; if (gameManager == null) return;
List<RiqEntity> prevEntities = GameManager.instance.Beatmap.Entities.FindAll(c => c.datamodel.Split(0) == "karateman"); List<RiqEntity> prevEntities = gameManager.Beatmap.Entities.FindAll(c => c.datamodel.Split(0) == "karateman");
RiqEntity voice = prevEntities.FindLast(c => c.beat < beat && c.datamodel == "karateman/warnings"); RiqEntity voice = prevEntities.FindLast(c => c.beat < beat && c.datamodel == "karateman/warnings");
if (wordClearTime > beat && wordStartTime < beat && voice != null) if (wordClearTime > beat && wordStartTime < beat && voice != null)
@ -802,10 +783,10 @@ namespace HeavenStudio.Games
{ {
var songPos = conductor.songPositionInBeatsAsDouble; var songPos = conductor.songPositionInBeatsAsDouble;
if (conductor != null && !conductor.isPlaying) // if (conductor != null && !conductor.isPlaying)
{ // {
EntityPreCheck(songPos); // EntityPreCheck(songPos);
} // }
switch (currentBgEffect) switch (currentBgEffect)
{ {
@ -871,7 +852,6 @@ namespace HeavenStudio.Games
} }
if (!Conductor.instance.NotStopped()) if (!Conductor.instance.NotStopped())
{ {
if (queuedCues.Count > 0) queuedCues.Clear();
startCamSpecial = double.MinValue; startCamSpecial = double.MinValue;
wantsReturn = double.MinValue; wantsReturn = double.MinValue;
cameraReturnLength = 0f; cameraReturnLength = 0f;
@ -927,11 +907,6 @@ namespace HeavenStudio.Games
return $"Word0{(type < (int)HitThree.HitThreeAlt ? type : type - 1)}"; return $"Word0{(type < (int)HitThree.HitThreeAlt ? type : type - 1)}";
} }
public static void QueueCue(RiqEntity entity)
{
queuedCues.Add(entity);
}
public static void CreateItemSFX(double beat, int type, bool muteSound = false) public static void CreateItemSFX(double beat, int type, bool muteSound = false)
{ {
if (!muteSound) SoundByte.PlayOneShotGame($"karateman/{(beat % 1.0 == 0.5 ? $"offbeatObject" : "object")}Out", forcePlay: true); if (!muteSound) SoundByte.PlayOneShotGame($"karateman/{(beat % 1.0 == 0.5 ? $"offbeatObject" : "object")}Out", forcePlay: true);

View file

@ -479,33 +479,17 @@ namespace HeavenStudio.Games
player.canClap = true; player.canClap = true;
} }
private double colorStartBeat = -1; private ColorEase bgColorEase = new(Color.white);
private float colorLength = 0f;
private Color colorStart = Color.white; //obviously put to the default color of the game
private Color colorEnd = Color.white;
private Util.EasingFunction.Ease colorEase; //putting Util in case this game is using jukebox
//call this in update //call this in update
private void BackgroundColorUpdate() private void BackgroundColorUpdate()
{ {
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength)); background.color = GetNewColor(bgColorEase);
var func = Util.EasingFunction.GetEasingFunction(colorEase);
float newR = func(colorStart.r, colorEnd.r, normalizedBeat);
float newG = func(colorStart.g, colorEnd.g, normalizedBeat);
float newB = func(colorStart.b, colorEnd.b, normalizedBeat);
background.color = new Color(newR, newG, newB);
} }
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease) public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)
{ {
colorStartBeat = beat; bgColorEase = new ColorEase(beat, length, colorStartSet, colorEndSet, ease);
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorEase = (Util.EasingFunction.Ease)ease;
} }
//call this in OnPlay(double beat) and OnGameSwitch(double beat) //call this in OnPlay(double beat) and OnGameSwitch(double beat)

View file

@ -290,7 +290,7 @@ namespace HeavenStudio.Games
{ {
} }
public virtual void OnTimeChange() public virtual void OnTimelineChange(double beat)
{ {
} }
@ -429,7 +429,7 @@ namespace HeavenStudio.Games
#endregion #endregion
#region Color #region Color
public struct ColorEase public class ColorEase
{ {
public double startBeat; public double startBeat;
public float length; public float length;

View file

@ -193,7 +193,7 @@ namespace HeavenStudio.Games
} }
} }
public override void OnTimeChange() public override void OnTimelineChange(double beat)
{ {
UpdateCameraZoom(); UpdateCameraZoom();
} }

View file

@ -123,7 +123,7 @@ namespace HeavenStudio.Games
Destroy(BallsHolder.transform.GetChild(i).gameObject); Destroy(BallsHolder.transform.GetChild(i).gameObject);
} }
public override void OnTimeChange() public override void OnTimelineChange(double beat)
{ {
UpdateCameraZoom(); UpdateCameraZoom();
} }

View file

@ -179,7 +179,7 @@ namespace HeavenStudio.Games
} }
} }
public override void OnTimeChange() public override void OnTimelineChange(double beat)
{ {
UpdateCameraZoom(); UpdateCameraZoom();
} }

View file

@ -6,6 +6,7 @@ using Jukebox;
using TMPro; using TMPro;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using static HeavenStudio.Minigames;
namespace HeavenStudio.Editor.Track namespace HeavenStudio.Editor.Track
{ {
@ -38,6 +39,7 @@ namespace HeavenStudio.Editor.Track
[Header("Properties")] [Header("Properties")]
public RiqEntity entity; public RiqEntity entity;
public GameAction gameAction;
public float length; public float length;
private bool lastVisible; private bool lastVisible;
public bool selected; public bool selected;
@ -97,6 +99,7 @@ namespace HeavenStudio.Editor.Track
if (action != null) if (action != null)
{ {
gameAction = action;
this.resizable = action.resizable; this.resizable = action.resizable;
if (action.resizable == false) if (action.resizable == false)
{ {
@ -326,9 +329,15 @@ namespace HeavenStudio.Editor.Track
if (Conductor.instance.NotStopped()) return; if (Conductor.instance.NotStopped()) return;
if (Input.GetMouseButton(1) || Input.GetMouseButton(2)) return; if (Input.GetMouseButton(1) || Input.GetMouseButton(2)) return;
if (!moving) if (!moving) {
if (!altWhenClicked) if (!altWhenClicked) {
altWhenClicked = Input.GetKey(KeyCode.LeftAlt); altWhenClicked = Input.GetKey(KeyCode.LeftAlt);
}
} else {
if (gameAction.isVfx) {
gameAction.function.Invoke();
}
}
if (!altWhenClicked) if (!altWhenClicked)
{ {

View file

@ -760,6 +760,35 @@ namespace HeavenStudio
GameManager.instance.ToggleInputs(eventCaller.currentEntity["toggle"]); GameManager.instance.ToggleInputs(eventCaller.currentEntity["toggle"]);
} }
), ),
// These are still here for backwards-compatibility but are hidden in the editor
new GameAction("flash", "", 1f, true,
new List<Param>()
{
new Param("colorA", Color.white, "Start Color"),
new Param("colorB", Color.white, "End Color"),
new Param("valA", new EntityTypes.Float(0, 1, 1), "Start Opacity"),
new Param("valB", new EntityTypes.Float(0, 1, 0), "End Opacity"),
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
},
hidden: true
),
new GameAction("move camera", "", 1f, true, new List<Param>()
{
new Param("valA", new EntityTypes.Float(-50, 50, 0), "Right / Left"),
new Param("valB", new EntityTypes.Float(-50, 50, 0), "Up / Down"),
new Param("valC", new EntityTypes.Float(-0, 250, 10), "In / Out"),
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease Type")
},
hidden: true ),
new GameAction("rotate camera", "", 1f, true, new List<Param>()
{
new Param("valA", new EntityTypes.Integer(-360, 360, 0), "Pitch"),
new Param("valB", new EntityTypes.Integer(-360, 360, 0), "Yaw"),
new Param("valC", new EntityTypes.Integer(-360, 360, 0), "Roll"),
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease Type")
},
hidden: true ),
}), }),
new Minigame("countIn", "Count-Ins", "", false, true, new List<GameAction>() new Minigame("countIn", "Count-Ins", "", false, true, new List<GameAction>()

View file

@ -35,14 +35,14 @@ namespace HeavenStudio.Util
} }
} }
public static MultiSound Play(Sound[] snds, bool game = true, bool forcePlay = false) public static MultiSound Play(Sound[] sounds, bool game = true, bool forcePlay = false)
{ {
return Play(snds.ToList(), game, forcePlay); return Play(sounds.ToList(), game, forcePlay);
} }
public static MultiSound Play(List<Sound> sounds, bool game = true, bool forcePlay = false) public static MultiSound Play(List<Sound> sounds, bool game = true, bool forcePlay = false)
{ {
if (Conductor.instance == null || sounds.Count <= 0) return null; if (Conductor.instance == null || sounds.Count < 1) return null;
GameObject go = new GameObject("MultiSound"); GameObject go = new GameObject("MultiSound");
MultiSound ms = go.AddComponent<MultiSound>(); MultiSound ms = go.AddComponent<MultiSound>();