fixed a lot of shit

This commit is contained in:
Rapandrasmus 2024-02-14 20:50:21 +01:00
parent b771d4c523
commit b6663dd112
3 changed files with 93 additions and 62 deletions

View file

@ -45087,14 +45087,18 @@ MonoBehaviour:
- {fileID: 4541619397523910160} - {fileID: 4541619397523910160}
- {fileID: 2441224063005478318} - {fileID: 2441224063005478318}
- {fileID: 5469916501946480897} - {fileID: 5469916501946480897}
_smallLogCutParticle: {fileID: 0} _smallLogCutParticle: {fileID: 1967221045720617934}
_bigLogHitParticle: {fileID: 0} _canCutParticle: {fileID: 1336100976886091474}
_bigLogCutParticle: {fileID: 0} _batCutParticle: {fileID: 7676651234050664727}
_hugeLogHitParticle: {fileID: 0} _broomCutParticle: {fileID: 3425449467504233482}
_hugeLogCutParticle: {fileID: 0} _bigLogHitParticle: {fileID: 2595403706729425131}
_bigLogCutParticle: {fileID: 77225483305886520}
_hugeLogHitParticle: {fileID: 4465514175500312505}
_hugeLogCutParticle: {fileID: 132537577928216743}
_peachHitParticle: {fileID: 6214329999445395356}
_peachCutParticle: {fileID: 8065249703308610300}
_catAnimationOffsetStart: -0.5 _catAnimationOffsetStart: -0.5
_catAnimationOffsetEnd: 0.5 _catAnimationOffsetEnd: 0.5
_catMoveLength: 1
--- !u!1 &3216973371467754786 --- !u!1 &3216973371467754786
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -1,4 +1,5 @@
using HeavenStudio.Util; using HeavenStudio.Util;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -11,6 +12,7 @@ namespace HeavenStudio.Games.Scripts_LumBEARjack
private LBJCatMove _moveScript; private LBJCatMove _moveScript;
private double _danceBeat = double.MaxValue; private double _danceBeat = double.MaxValue;
private double _stopDanceBeat = double.MaxValue;
private void Awake() private void Awake()
{ {
@ -20,23 +22,34 @@ namespace HeavenStudio.Games.Scripts_LumBEARjack
private void Update() private void Update()
{ {
if (Conductor.instance.songPositionInBeatsAsDouble >= _stopDanceBeat)
{
_anim.DoNormalizedAnimation("CatDance", 0);
return;
}
if (_danceBeat > Conductor.instance.songPositionInBeatsAsDouble) if (_danceBeat > Conductor.instance.songPositionInBeatsAsDouble)
{ {
_anim.Play("CatIdle"); _anim.DoNormalizedAnimation("CatIdle", 0);
return; return;
} }
float normalized = Conductor.instance.GetPositionFromBeat(_danceBeat, 2, false) % 1; float normalized = Conductor.instance.GetPositionFromBeat(_danceBeat, 2, false) % 1;
_anim.DoNormalizedAnimation("CatDance", normalized); _anim.DoNormalizedAnimation("CatDance", normalized);
} }
public void Activate(double beat, double length, bool inToScene, bool instant) public void Activate(double beat, double length, bool inToScene, bool moveInstant, bool dance, bool instant)
{ {
_moveScript.Move(beat, instant ? 0 : length, inToScene); _moveScript.Move(beat, moveInstant ? 0 : length, inToScene);
double overflowBeat = (beat + 0.5) % 2; double overflowBeat = beat % 2;
_danceBeat = beat - overflowBeat + (instant ? 0 : 2); double toBeat = 2.0 - overflowBeat;
_danceBeat = beat + (instant ? -overflowBeat : toBeat) - 0.5;
if (!inToScene) _danceBeat = double.MaxValue; if (!inToScene) _danceBeat = double.MaxValue;
_stopDanceBeat = beat + (instant ? -overflowBeat : toBeat) - 0.5;
if (dance) _stopDanceBeat = double.MaxValue;
} }
} }
} }

View file

@ -101,12 +101,13 @@ namespace HeavenStudio.Games.Loaders
}, },
new("cats", "Cats Presence") new("cats", "Cats Presence")
{ {
defaultLength = 0.5f, resizable = true,
parameters = new() parameters = new()
{ {
new("main", LumBEARjack.MainCatChoice.Right, "Main Cats"), new("main", LumBEARjack.MainCatChoice.Right, "Main Cats"),
new("bg", new EntityTypes.Integer(0, 12), "Background Cats"), new("bg", new EntityTypes.Integer(0, 12), "Background Cats"),
new("instant", false, "Instant") new("instant", false, "Instant"),
new("dance", true, "Dance")
} }
}, },
new("sigh", "Rest") new("sigh", "Rest")
@ -281,15 +282,19 @@ namespace HeavenStudio.Games
[Header("Particles")] [Header("Particles")]
[SerializeField] private ParticleSystem _smallLogCutParticle; [SerializeField] private ParticleSystem _smallLogCutParticle;
[SerializeField] private ParticleSystem _canCutParticle;
[SerializeField] private ParticleSystem _batCutParticle;
[SerializeField] private ParticleSystem _broomCutParticle;
[SerializeField] private ParticleSystem _bigLogHitParticle; [SerializeField] private ParticleSystem _bigLogHitParticle;
[SerializeField] private ParticleSystem _bigLogCutParticle; [SerializeField] private ParticleSystem _bigLogCutParticle;
[SerializeField] private ParticleSystem _hugeLogHitParticle; [SerializeField] private ParticleSystem _hugeLogHitParticle;
[SerializeField] private ParticleSystem _hugeLogCutParticle; [SerializeField] private ParticleSystem _hugeLogCutParticle;
[SerializeField] private ParticleSystem _peachHitParticle;
[SerializeField] private ParticleSystem _peachCutParticle;
[Header("Parameters")] [Header("Parameters")]
[SerializeField] private double _catAnimationOffsetStart = -0.5; [SerializeField] private double _catAnimationOffsetStart = -0.5;
[SerializeField] private double _catAnimationOffsetEnd = 0.5; [SerializeField] private double _catAnimationOffsetEnd = 0.5;
[SerializeField] private double _catMoveLength = 0.5;
private List<double> _bearNoBopBeats = new(); private List<double> _bearNoBopBeats = new();
private Dictionary<double, CatPutChoice> _catPuts = new(); private Dictionary<double, CatPutChoice> _catPuts = new();
@ -329,7 +334,7 @@ namespace HeavenStudio.Games
new(beat + (length / 3), delegate new(beat + (length / 3), delegate
{ {
LBJSmallObject spawnedObject = Instantiate(_smallObjectPrefab, _cutObjectHolder); LBJSmallObject spawnedObject = Instantiate(_smallObjectPrefab, _cutObjectHolder);
spawnedObject.Init(_bear, beat, length, type, huh, ObjectShouldBeRight(beat, cat), startUpBeat); spawnedObject.Init(_bear, beat, length, type, huh, ShouldBeRight(beat, cat), startUpBeat);
}) })
}); });
} }
@ -341,7 +346,7 @@ namespace HeavenStudio.Games
new(beat + (length / 4), delegate new(beat + (length / 4), delegate
{ {
LBJBigObject spawnedObject = Instantiate(_bigObjectPrefab, _cutObjectHolder); LBJBigObject spawnedObject = Instantiate(_bigObjectPrefab, _cutObjectHolder);
spawnedObject.Init(_bear, beat, length, type, ObjectShouldBeRight(beat, cat), startUpBeat); spawnedObject.Init(_bear, beat, length, type, ShouldBeRight(beat, cat), startUpBeat);
}) })
}); });
} }
@ -353,12 +358,12 @@ namespace HeavenStudio.Games
new(beat + (length / 6), delegate new(beat + (length / 6), delegate
{ {
LBJHugeObject spawnedObject = Instantiate(_hugeObjectPrefab, _cutObjectHolder); LBJHugeObject spawnedObject = Instantiate(_hugeObjectPrefab, _cutObjectHolder);
spawnedObject.Init(_bear, beat, length, type, ObjectShouldBeRight(beat, cat), zoom, startUpBeat); spawnedObject.Init(_bear, beat, length, type, ShouldBeRight(beat, cat), zoom, startUpBeat);
}) })
}); });
} }
private bool ObjectShouldBeRight(double beat, CatPutChoice cat) private bool ShouldBeRight(double beat, CatPutChoice cat)
{ {
switch (cat) switch (cat)
{ {
@ -427,33 +432,35 @@ namespace HeavenStudio.Games
switch (_startMainCat) switch (_startMainCat)
{ {
case MainCatChoice.Right: case MainCatChoice.Right:
ActivateCatVisualPresence(beat, true, true, true); ActivateCatVisualPresence(beat, 0, true, true, true);
ActivateCatVisualPresence(beat, false, false, true); ActivateCatVisualPresence(beat, 0, false, false, true);
break; break;
case MainCatChoice.Left: case MainCatChoice.Left:
ActivateCatVisualPresence(beat, false, true, true); ActivateCatVisualPresence(beat, 0, false, true, true);
ActivateCatVisualPresence(beat, true, false, true); ActivateCatVisualPresence(beat, 0, true, false, true);
break; break;
case MainCatChoice.Both: case MainCatChoice.Both:
ActivateCatVisualPresence(beat, true, true, true); ActivateCatVisualPresence(beat, 0, true, true, true);
ActivateCatVisualPresence(beat, true, false, true); ActivateCatVisualPresence(beat, 0, true, false, true);
break; break;
} }
SetBGCats(beat, BGCatPresenceBeforeBeat(beat), BGCatPresenceBeforeBeat(beat), true); SetBGCats(beat, 0, BGCatPresenceBeforeBeat(beat), BGCatPresenceBeforeBeat(beat), true, true);
var allPresencesAfterBeat = allPresences.FindAll(x => x.beat >= beat); var allPresencesAfterBeat = allPresences.FindAll(x => x.beat >= beat);
List<BeatAction.Action> actions = new(); List<BeatAction.Action> actions = new();
foreach (var e in allPresencesAfterBeat) foreach (var e in allPresencesAfterBeat)
{ {
double eventBeat = e.beat; double eventBeat = e.beat;
double eventLength = e.length;
bool instant = e["instant"]; bool instant = e["instant"];
bool dance = e["dance"];
int beforeBG = BGCatPresenceBeforeBeat(e.beat); int beforeBG = BGCatPresenceBeforeBeat(e.beat);
int atBG = e["bg"]; int atBG = e["bg"];
actions.Add(new(e.beat, delegate actions.Add(new(e.beat, delegate
{ {
SetBGCats(eventBeat, atBG, beforeBG, instant); SetBGCats(eventBeat, eventLength, atBG, beforeBG, instant, dance);
})); }));
MainCatChoice beforeCats = CatPresenceBeforeBeat(e.beat); MainCatChoice beforeCats = CatPresenceBeforeBeat(e.beat);
@ -468,12 +475,12 @@ namespace HeavenStudio.Games
{ {
if (beforeCats == MainCatChoice.Both) if (beforeCats == MainCatChoice.Both)
{ {
ActivateCatVisualPresence(eventBeat, true, true, true); ActivateCatVisualPresence(eventBeat, eventLength, true, true, true);
ActivateCatVisualPresence(eventBeat, false, false, instant); ActivateCatVisualPresence(eventBeat, eventLength, false, false, instant);
return; return;
} }
ActivateCatVisualPresence(eventBeat, true, true, instant); ActivateCatVisualPresence(eventBeat, eventLength, true, true, instant);
ActivateCatVisualPresence(eventBeat, false, false, instant); ActivateCatVisualPresence(eventBeat, eventLength, false, false, instant);
}) })
); );
break; break;
@ -483,12 +490,12 @@ namespace HeavenStudio.Games
{ {
if (beforeCats == MainCatChoice.Both) if (beforeCats == MainCatChoice.Both)
{ {
ActivateCatVisualPresence(eventBeat, false, true, instant); ActivateCatVisualPresence(eventBeat, eventLength, false, true, instant);
ActivateCatVisualPresence(eventBeat, true, false, true); ActivateCatVisualPresence(eventBeat, eventLength, true, false, true);
return; return;
} }
ActivateCatVisualPresence(eventBeat, false, true, instant); ActivateCatVisualPresence(eventBeat, eventLength, false, true, instant);
ActivateCatVisualPresence(eventBeat, true, false, instant); ActivateCatVisualPresence(eventBeat, eventLength, true, false, instant);
}) })
); );
break; break;
@ -496,8 +503,8 @@ namespace HeavenStudio.Games
actions.Add( actions.Add(
new(e.beat, delegate new(e.beat, delegate
{ {
ActivateCatVisualPresence(eventBeat, true, true, (beforeCats == MainCatChoice.Right) ? true : instant); ActivateCatVisualPresence(eventBeat, eventLength, true, true, (beforeCats == MainCatChoice.Right) ? true : instant);
ActivateCatVisualPresence(eventBeat, true, false, (beforeCats == MainCatChoice.Left) ? true : instant); ActivateCatVisualPresence(eventBeat, eventLength, true, false, (beforeCats == MainCatChoice.Left) ? true : instant);
}) })
); );
break; break;
@ -585,8 +592,24 @@ namespace HeavenStudio.Games
double nextGameSwitchBeat = double.MaxValue; double nextGameSwitchBeat = double.MaxValue;
if (nextGameSwitch != null) nextGameSwitchBeat = nextGameSwitch.beat; if (nextGameSwitch != null) nextGameSwitchBeat = nextGameSwitch.beat;
bool catRight = _startMainCat != MainCatChoice.Left; foreach (var e in allEvents)
bool first = true; {
float effectiveLength = e.length / (e.datamodel.Split(1) switch
{
"small" => 3,
"smallS" => 3,
"big" => 4,
"bigS" => 4,
"huge" => 6,
"hugeS" => 6,
_ => 3
});
if ((e.beat + _catAnimationOffsetStart < beat && e.beat + effectiveLength + _catAnimationOffsetEnd > beat) || (e.beat >= beat && e.beat < nextGameSwitchBeat))
if (!_catPuts.ContainsKey(e.beat)) _catPuts.Add(e.beat, (CatPutChoice)e["cat"]);
}
var sortedCatPuts = _catPuts.OrderBy(x => x.Key);
_catPuts = sortedCatPuts.ToDictionary(pair => pair.Key, pair => pair.Value);
foreach (var e in allEvents) foreach (var e in allEvents)
{ {
@ -603,20 +626,7 @@ namespace HeavenStudio.Games
if ((e.beat + _catAnimationOffsetStart < beat && e.beat + effectiveLength + _catAnimationOffsetEnd > beat) || (e.beat >= beat && e.beat < nextGameSwitchBeat)) if ((e.beat + _catAnimationOffsetStart < beat && e.beat + effectiveLength + _catAnimationOffsetEnd > beat) || (e.beat >= beat && e.beat < nextGameSwitchBeat))
{ {
if (!_catPuts.ContainsKey(e.beat)) _catPuts.Add(e.beat, (CatPutChoice)e["cat"]); bool catRight = ShouldBeRight(e.beat, (CatPutChoice)e["cat"]);
switch ((CatPutChoice)e["cat"])
{
case CatPutChoice.Alternate:
if (!first) catRight = !catRight;
if (CatPresenceAtBeat(e.beat) != MainCatChoice.Both) catRight = CatPresenceAtBeat(e.beat) != MainCatChoice.Left;
break;
case CatPutChoice.Left:
catRight = CatPresenceAtBeat(e.beat) == MainCatChoice.Right;
break;
default:
catRight = CatPresenceAtBeat(e.beat) != MainCatChoice.Left;
break;
}
switch (e.datamodel.Split(1)) switch (e.datamodel.Split(1))
{ {
@ -634,11 +644,7 @@ namespace HeavenStudio.Games
break; break;
} }
} }
first = false;
} }
var sortedCatPuts = _catPuts.OrderBy(x => x.Key);
_catPuts = sortedCatPuts.ToDictionary(pair => pair.Key, pair => pair.Value);
} }
#endregion #endregion
@ -892,13 +898,13 @@ namespace HeavenStudio.Games
} }
} }
private void ActivateCatVisualPresence(double beat, bool inToScene, bool right, bool instant = false) private void ActivateCatVisualPresence(double beat, double length, bool inToScene, bool right, bool instant = false)
{ {
LBJCatMove move = right ? _catRightMove : _catLeftMove; LBJCatMove move = right ? _catRightMove : _catLeftMove;
move.Move(beat, instant ? 0 : _catMoveLength, inToScene); move.Move(beat, instant ? 0 : length, inToScene);
} }
private void SetBGCats(double beat, int bgCats, int beforeBgCats, bool instant) private void SetBGCats(double beat, double length, int bgCats, int beforeBgCats, bool instant, bool dance)
{ {
bgCats = Math.Clamp(bgCats, 0, 12); bgCats = Math.Clamp(bgCats, 0, 12);
bgCats -= 1; bgCats -= 1;
@ -908,15 +914,15 @@ namespace HeavenStudio.Games
{ {
if (bgCats < beforeBgCats) if (bgCats < beforeBgCats)
{ {
_bgCats[i].Activate(beat, _catMoveLength, bgCats >= i, instant || !(i > bgCats && i <= beforeBgCats)); _bgCats[i].Activate(beat, length, bgCats >= i, instant || !(i > bgCats && i <= beforeBgCats), dance, instant);
} }
else if (bgCats > beforeBgCats) else if (bgCats > beforeBgCats)
{ {
_bgCats[i].Activate(beat, _catMoveLength, bgCats >= i, instant || !(i > beforeBgCats && i <= bgCats)); _bgCats[i].Activate(beat, length, bgCats >= i, instant || !(i > beforeBgCats && i <= bgCats), dance, instant);
} }
else else
{ {
_bgCats[i].Activate(beat, _catMoveLength, bgCats >= i, true); _bgCats[i].Activate(beat, length, bgCats >= i, true, dance, instant);
} }
} }
} }
@ -978,10 +984,16 @@ namespace HeavenStudio.Games
spawnedParticle.PlayScaledAsyncAllChildren(0.5f); spawnedParticle.PlayScaledAsyncAllChildren(0.5f);
break; break;
case SmallType.can: case SmallType.can:
ParticleSystem spawnedParticle1 = Instantiate(_canCutParticle, _particleCutPoint);
spawnedParticle1.PlayScaledAsyncAllChildren(1);
break; break;
case SmallType.bat: case SmallType.bat:
ParticleSystem spawnedParticle2 = Instantiate(_batCutParticle, _particleCutPoint);
spawnedParticle2.PlayScaledAsyncAllChildren(0.5f);
break; break;
case SmallType.broom: case SmallType.broom:
ParticleSystem spawnedParticle3 = Instantiate(_broomCutParticle, _particleCutPoint);
spawnedParticle3.PlayScaledAsyncAllChildren(0.5f);
break; break;
} }
} }
@ -1008,6 +1020,8 @@ namespace HeavenStudio.Games
case HugeType.freezer: case HugeType.freezer:
break; break;
case HugeType.peach: case HugeType.peach:
ParticleSystem spawnedParticle2 = Instantiate(hit ? _peachHitParticle : _peachCutParticle, hit ? _particleHitPoint : _particleCutPoint);
spawnedParticle2.PlayScaledAsyncAllChildren(1);
break; break;
} }
} }