auto km bulb, fix dupe pixelize

oh ALSO THAT PLAY ANIM BUG GOT FIXED. YAY.
This commit is contained in:
AstrlJelly 2024-05-12 01:15:47 -04:00
parent 7760a2b92b
commit e632645e82
3 changed files with 103 additions and 117 deletions

View file

@ -106919,10 +106919,9 @@ MonoBehaviour:
SoundSequences: []
scheduledInputs: []
LightBulbColors:
- {r: 0, g: 0, b: 0, a: 0}
- {r: 1, g: 1, b: 1, a: 0}
- {r: 0.23137255, g: 1, b: 1, a: 1}
- {r: 1, g: 1, b: 0, a: 1}
- {r: 0, g: 0, b: 0, a: 0}
BackgroundColors:
- {r: 1, g: 0.8156863, b: 0.21176471, a: 1}
- {r: 0.99607843, g: 0.60784316, b: 0.98039216, a: 1}

View file

@ -73,30 +73,19 @@ namespace HeavenStudio.Games.Loaders
}
RiqBeatmap.OnUpdateEntity += BackgroundUpdater;
// RiqEntity GameCapitalizer(string datamodel, RiqEntity entity)
// {
// if (datamodel.Split('/')[0] == "karateman")
// {
// string name = datamodel.Split('/')[1];
// entity.datamodel = "karateman/" + name;
// var tempData = entity.dynamicData.ToDictionary(x => x.Key);
// foreach ((string key, dynamic item) in tempData)
// {
// if (item.GetType() == typeof(Newtonsoft.Json.Linq.JObject)) {
// entity.dynamicData[key] = new Color((float)item["r"], (float)item["g"], (float)item["b"]);
// }
// Debug.Log(key + ", " + item);
// }
// entity.version = 1;
RiqEntity BulbUpdater(string datamodel, RiqEntity e)
{
if (e.datamodel == "karateman/bulb" && e.version == 0)
{
e.version = 1;
// return entity;
// } else if (datamodel == "gameManager/switchGame/karateman") {
// entity.datamodel = "gameManager/switchGame/karateman";
// return entity;
// }
// return null;
// }
// RiqBeatmap.OnUpdateEntity += GameCapitalizer;
e["type"]++;
return e;
}
return null;
}
RiqBeatmap.OnUpdateEntity += BulbUpdater;
return new Minigame("karateman", "Karate Man", "fbca3e", false, false, new List<GameAction>()
{
@ -142,7 +131,7 @@ namespace HeavenStudio.Games.Loaders
defaultLength = 2,
parameters = new List<Param>()
{
new Param("type", KarateMan.LightBulbType.Normal, "Type", "Choose the bulb type. Yellow is used for kicks, while Blue is used for combos", new List<Param.CollapseParam>()
new Param("type", KarateMan.LightBulbType.Automatic, "Type", "Choose the bulb type. Yellow is used for kicks, while Blue is used for combos", new List<Param.CollapseParam>()
{
new Param.CollapseParam((x, _) => (int)x == (int)KarateMan.LightBulbType.Custom, new string[] { "colorA" })
}),
@ -157,6 +146,30 @@ namespace HeavenStudio.Games.Loaders
new Param("hitSfx", "lightbulbHit", "Hit SFX", "Choose the type of SFX to use for hitting the bulb."),
},
},
new GameAction("combo", "Combo")
{
function = delegate {
var e = eventCaller.currentEntity;
KarateMan.instance.Combo(e.beat, e["type"], e["pitchVoice"], e["forcePitch"], e["cutOut"], e["disableVoice"]);
KarateMan.ComboSFX();
},
inactiveFunction = delegate {
var e = eventCaller.currentEntity;
KarateMan.ComboSFX();
},
defaultLength = 4,
parameters = new List<Param>()
{
new Param("type", KarateMan.KarateManFaces.Happy, "Success Expression", "Set the facial expression for Karate Joe to show if he hits the object."),
new Param("pitchVoice", false, "Pitch Voice", "Toggle if the voice should be pitched.", new List<Param.CollapseParam>()
{
new Param.CollapseParam((x, _) => (bool)x, new string[] { "forcePitch" }),
}),
new Param("forcePitch", new EntityTypes.Float(0.5f, 2f, 1f), "Force Pitch", "Set the pitching of the voice, or keep it at 1 for automatic pitching."),
new Param("cutOut", true, "Cut Out Voice", "Toggle if this cue will be cut out if another voiced cue plays."),
new Param("disableVoice", false, "Mute Voice", "Toggle if the voice should be muted."),
}
},
new GameAction("kick", "Kick")
{
function = delegate {
@ -185,30 +198,6 @@ namespace HeavenStudio.Games.Loaders
new Param("hoopColor", new Color(0.714f, 0.309f, 0.424f), "Barrel Hoop Color", "Choose the color of the barrel's hoops."),
}
},
new GameAction("combo", "Combo")
{
function = delegate {
var e = eventCaller.currentEntity;
KarateMan.instance.Combo(e.beat, e["type"], e["pitchVoice"], e["forcePitch"], e["cutOut"], e["disableVoice"]);
KarateMan.ComboSFX();
},
inactiveFunction = delegate {
var e = eventCaller.currentEntity;
KarateMan.ComboSFX();
},
defaultLength = 4,
parameters = new List<Param>()
{
new Param("type", KarateMan.KarateManFaces.Happy, "Success Expression", "Set the facial expression for Karate Joe to show if he hits the object."),
new Param("pitchVoice", false, "Pitch Voice", "Toggle if the voice should be pitched.", new List<Param.CollapseParam>()
{
new Param.CollapseParam((x, _) => (bool)x, new string[] { "forcePitch" }),
}),
new Param("forcePitch", new EntityTypes.Float(0.5f, 2f, 1f), "Force Pitch", "Set the pitching of the voice, or keep it at 1 for automatic pitching."),
new Param("cutOut", true, "Cut Out Voice", "Toggle if this cue will be cut out if another voiced cue plays."),
new Param("disableVoice", false, "Mute Voice", "Toggle if the voice should be muted."),
}
},
new GameAction("warnings", "Text Warnings")
{
function = delegate {
@ -442,9 +431,10 @@ namespace HeavenStudio.Games
public enum LightBulbType
{
Automatic,
Normal,
Blue,
Yellow,
Combo,
Kick,
Custom
}
@ -582,13 +572,7 @@ namespace HeavenStudio.Games
public WindZone Wind;
public ParticleSystem[] Effects;
[Header("Unloaded Game Calls")]
//public static Queue<Beatmap.Entity> ItemQueue = new Queue<Beatmap.Entity>();
public static bool WantBop = true;
public static bool WantNori = true;
public static int WantNoriType = (int)NoriMode.None;
public static double WantBgChangeStart = double.MinValue;
public static float WantBgChangeLength = 0f;
private const float PITCH_MOD = 125;
const int IAAltDownCat = IAMAXCAT;
const int IAAltUpCat = IAMAXCAT + 1;
@ -680,7 +664,7 @@ namespace HeavenStudio.Games
public static PlayerInput.InputAction InputAction_TouchUp =
new("KarateAltUp", new int[] { IAEmptyCat, IAReleaseCat, IAEmptyCat },
IA_PadAltUp, IA_EmptyTouchUp, IA_BatonAltUp);
public List<RiqEntity> voiceEntities, hitVoiceEntities = new();
public List<RiqEntity> specialEntities, hitVoiceEntities = new();
public static KarateMan instance;
@ -774,7 +758,7 @@ namespace HeavenStudio.Games
}
// get all entities to later check against eachother to cut out voices
voiceEntities = prevEntities.FindAll(c => c.beat > beat && (c.datamodel is "karateman/kick" or "karateman/combo"));
specialEntities = prevEntities.FindAll(c => c.beat >= beat && (c.datamodel is "karateman/kick" or "karateman/combo"));
hitVoiceEntities = prevEntities.FindAll(c => c.beat > beat && (c.datamodel is "karateman/warnings" && c["whichWarning"] <= (int)HitThree.HitFour));
}
@ -861,6 +845,20 @@ namespace HeavenStudio.Games
private Color TintColor(Color color) => Color.LerpUnclamped(color, new Color(195 / 255f, 48 / 255f, 2 / 255f), 0.45f);
private static LightBulbType GetNextSpecial(double beat)
{
var entities = instance != null ? instance.specialEntities : null;
RiqEntity nextSpecial = entities != null ?
(entities.Count > 0 ? entities.Find(e => e.beat >= beat) : null) :
GameManager.instance.Beatmap.Entities.Find(c => c.beat >= beat && (c.datamodel is "karateman/combo" or "karateman/kick"));
return nextSpecial?.datamodel switch {
"karateman/combo" => LightBulbType.Combo,
"karateman/kick" => LightBulbType.Kick,
null or _ => LightBulbType.Normal,
};
}
public static void DoSpecialCamera(double beat, float length, bool returns)
{
if (cameraAngle == CameraAngle.Normal)
@ -894,7 +892,7 @@ namespace HeavenStudio.Games
new MultiSound.Sound($"karateman/{(type == (int)HitThree.HitThreeAlt ? "hitAlt" : "hit")}", beat + 0.5f, offset: 0.042f),
new MultiSound.Sound($"karateman/{number}", beat + 1f),
};
Array.ForEach(sounds, x => x.pitch = bpmPitch ? Conductor.instance.GetBpmAtBeat(x.beat) / 125 : forcePitch);
Array.ForEach(sounds, x => x.pitch = bpmPitch ? Conductor.instance.GetBpmAtBeat(x.beat) / PITCH_MOD : forcePitch);
MultiSound.Play(sounds, forcePlay: true);
}
@ -907,27 +905,6 @@ namespace HeavenStudio.Games
return $"Word0{(type < (int)HitThree.HitThreeAlt ? type : type - 1)}";
}
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);
}
public static void CreateBulbSFX(double beat, int type, int sfx, string throwSfx)
{
string obj = sfx switch
{
(int)LightBulbSfx.Automatic => type == (int)LightBulbType.Yellow ? "LightbulbNtr" : "Lightbulb",
(int)LightBulbSfx.DS => "LightbulbNtr",
(int)LightBulbSfx.Custom => throwSfx,
_ => "Lightbulb",
};
if (sfx != (int)LightBulbSfx.Custom)
{
obj = (beat % 1.0 == 0.5) ? $"offbeat{obj}Out" : obj.ToLower() + "Out";
}
SoundByte.PlayOneShotGame($"karateman/{obj}", forcePlay: true);
}
public void CreateItem(double beat, int type, int expression)
{
switch (type)
@ -937,7 +914,7 @@ namespace HeavenStudio.Games
break;
case (int)HitType.Lightbulb:
var mobj = CreateItemInstance(beat, "Item01", expression, KarateManPot.ItemType.Bulb);
mobj.SetBulbColor(LightBulbColors[0]);
mobj.SetBulbColor(new Color(0, 0, 0, 0));
break;
case (int)HitType.Rock:
CreateItemInstance(beat, "Item02", expression, KarateManPot.ItemType.Rock);
@ -963,11 +940,38 @@ namespace HeavenStudio.Games
}
}
public void CreateBulbSpecial(double beat, int type, Color color, int expression, int sfx, string hitSfx = "")
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);
}
public static void CreateBulbSFX(double beat, int type, int sfx, string throwSfx)
{
if (type == (int)LightBulbType.Automatic) {
type = (int)GetNextSpecial(beat);
}
string obj = sfx switch
{
(int)LightBulbSfx.Automatic => type == (int)LightBulbType.Yellow ? "LightbulbNtr" : "Lightbulb",
(int)LightBulbSfx.Automatic => type == (int)LightBulbType.Kick ? "LightbulbNtr" : "Lightbulb",
(int)LightBulbSfx.DS => "LightbulbNtr",
(int)LightBulbSfx.Custom => throwSfx,
_ => "Lightbulb",
};
if (sfx != (int)LightBulbSfx.Custom)
{
obj = (beat % 1.0 == 0.5) ? $"offbeat{obj}Out" : obj.ToLower() + "Out";
}
SoundByte.PlayOneShotGame($"karateman/{obj}", forcePlay: true);
}
public void CreateBulbSpecial(double beat, int type, Color color, int expression, int sfx, string hitSfx = "")
{
if (type == (int)LightBulbType.Automatic) {
type = (int)GetNextSpecial(beat);
}
string obj = sfx switch
{
(int)LightBulbSfx.Automatic => type == (int)LightBulbType.Kick ? "LightbulbNtr" : "Lightbulb",
(int)LightBulbSfx.DS => "LightbulbNtr",
(int)LightBulbSfx.Custom => hitSfx,
_ => "Lightbulb",
@ -975,7 +979,8 @@ namespace HeavenStudio.Games
if (sfx != (int)LightBulbSfx.Custom) obj += "Hit";
var mobj = CreateItemInstance(beat, "Item01", expression, KarateManPot.ItemType.Bulb, hitSfxOverride: $"karateman/{obj}");
mobj.SetBulbColor((type == (int)LightBulbType.Custom) ? color : LightBulbColors[type]);
// use the type to index, starting at 0 (i.e the normal lightbulb color, which is transparent)
mobj.SetBulbColor((type == (int)LightBulbType.Custom) ? color : LightBulbColors[type - (int)LightBulbType.Normal]);
}
public static void ComboSFX()
@ -1008,15 +1013,15 @@ namespace HeavenStudio.Games
new MultiSound.Sound("karateman/pow", beat + 2.5f)
};
if (voiceEntities.Count > 0 && cutOut)
if (specialEntities.Count > 0 && cutOut)
{
RiqEntity firstVoice = voiceEntities.Find(x => x.beat >= beat + 1);
RiqEntity firstVoice = specialEntities.Find(x => x.beat >= beat + 1);
RiqEntity firstHitVoice = hitVoiceEntities.Find(x => x.beat >= beat + 1);
if (firstVoice != null) sounds.RemoveAll(x => x.beat > firstVoice.beat);
if (firstHitVoice != null) sounds.RemoveAll(x => x.beat > firstHitVoice.beat - 0.5);
}
sounds.ForEach(x => x.pitch = bpmPitch ? Conductor.instance.GetBpmAtBeat(x.beat) / 125 : forcePitch);
sounds.ForEach(x => x.pitch = bpmPitch ? Conductor.instance.GetBpmAtBeat(x.beat) / PITCH_MOD : forcePitch);
MultiSound.Play(sounds.ToArray(), forcePlay: true);
}
@ -1044,15 +1049,15 @@ namespace HeavenStudio.Games
new MultiSound.Sound("karateman/punchKick4", beat + 2.5f),
};
if (voiceEntities.Count > 0 && cutOut)
if (specialEntities.Count > 0 && cutOut)
{
RiqEntity firstVoice = voiceEntities.Find(x => x.beat >= beat + 1);
RiqEntity firstVoice = specialEntities.Find(x => x.beat >= beat + 1);
RiqEntity firstHitVoice = hitVoiceEntities.Find(x => x.beat >= beat + 1);
if (firstVoice != null) sounds.RemoveAll(x => x.beat > firstVoice.beat);
if (firstHitVoice != null) sounds.RemoveAll(x => x.beat > firstHitVoice.beat);
}
sounds.ForEach(x => x.pitch = bpmPitch ? Conductor.instance.GetBpmAtBeat(x.beat) / 125 : forcePitch);
sounds.ForEach(x => x.pitch = bpmPitch ? Conductor.instance.GetBpmAtBeat(x.beat) / PITCH_MOD : forcePitch);
MultiSound.Play(sounds.ToArray(), forcePlay: true);
}

View file

@ -276,8 +276,8 @@ namespace HeavenStudio
else if (type == typeof(EntityTypes.Button))
e.dynamicData[param.propertyName] = (string)e[param.propertyName];
else if (type == typeof(EntityTypes.Dropdown)) {
JValue value = e[param.propertyName]["value"];
JArray values = e[param.propertyName]["Values"];
JValue value = e[param.propertyName].value;
JArray values = e[param.propertyName].Values;
e.dynamicData[param.propertyName] = new EntityTypes.DropdownObj((int)value, values.Select(x => (string)x).ToList());
}
else if (type == typeof(EntityTypes.NoteSampleDropdown))
@ -305,10 +305,12 @@ namespace HeavenStudio
// use default value
if (type == typeof(EntityTypes.Integer))
e.dynamicData[param.propertyName] = ((EntityTypes.Integer)param.parameter).val;
else if (type == typeof(EntityTypes.Note))
e.dynamicData[param.propertyName] = ((EntityTypes.Note)param.parameter).val;
else if (type == typeof(EntityTypes.Float))
e.dynamicData[param.propertyName] = ((EntityTypes.Float)param.parameter).val;
// else if (type == typeof(EntityTypes.Dropdown))
// e.dynamicData[param.propertyName] = new EntityTypes.DropdownObj();
else if (type == typeof(EntityTypes.Note))
e.dynamicData[param.propertyName] = ((EntityTypes.Note)param.parameter).val;
else if (type.IsEnum && param.propertyName != "ease")
e.dynamicData[param.propertyName] = (int)param.parameter;
else
@ -1213,26 +1215,6 @@ namespace HeavenStudio
}
},
new GameAction("pixelQuad", "Pixelize", "VFX")
{
resizable = true,
parameters = new()
{
new("pixelSizeStart", new EntityTypes.Float(0.00f, 1f, 0.00f), "Start Pixel Size", "Set the pixel size at the start of the event."),
new("pixelSizeEnd", new EntityTypes.Float(0.00f, 1f, 0.5f), "End Pixel Size", "Set the pixel size at the end of the event."),
new("ratioStart", new EntityTypes.Float(0.2f, 5f, 1f), "Start Pixel Ratio", "Set the pixel ratio at the start of the event."),
new("ratioEnd", new EntityTypes.Float(0.2f, 5f, 1f), "End Pixel Ratio", "Set the pixel ratio at the end of the event."),
new("xScaleStart", new EntityTypes.Float(0.2f, 5f, 1f), "Start X Scale", "Set the X scale of the pixels at the start of the event."),
new("xScaleEnd", new EntityTypes.Float(0.2f, 5f, 1f), "End X Scale", "Set the X scale of the pixels at the end of the event."),
new("yScaleStart", new EntityTypes.Float(0.2f, 5f, 1f), "Start Y Scale", "Set the Y scale of the pixels at the start of the event."),
new("yScaleEnd", new EntityTypes.Float(0.2f, 5f, 1f), "End Y Scale", "Set the Y scale of the pixels at the end of the event."),
new("ease", Util.EasingFunction.Ease.Linear, "Ease", "Set the easing of the action.", new()
{
new((x, y) => (Util.EasingFunction.Ease)x != Util.EasingFunction.Ease.Instant, new string[] { "pixelSizeStart", "ratioStart", "xScaleStart", "yScaleStart" })
}),
}
},
new GameAction("retroTv", "Retro TV", "VFX")
{
resizable = true,