final optimizations and fixes

damn i didn't think the preparing stuff would be such a big deal
This commit is contained in:
AstrlJelly 2024-03-09 01:20:07 -05:00
parent fe6bd8a516
commit 01083b709b
4 changed files with 44 additions and 85 deletions

View file

@ -109,9 +109,8 @@ MonoBehaviour:
RightCurve: {fileID: 8538313959133990924} RightCurve: {fileID: 8538313959133990924}
BarelyLeftCurve: {fileID: 5959598018215963193} BarelyLeftCurve: {fileID: 5959598018215963193}
BarelyRightCurve: {fileID: 4156529297438955755} BarelyRightCurve: {fileID: 4156529297438955755}
HalvesLeftBase: {fileID: 8462363345267808632} HalvesLeftBase: {fileID: 3507681361263350449}
HalvesRightBase: {fileID: 997672822965154321} HalvesRightBase: {fileID: 5646879835731180444}
ObjectParent: {fileID: 0}
objectLeftHalves: objectLeftHalves:
- {fileID: -5050977528292827191, guid: 1c59b9cd0adef0941bc4bd4bde66a759, type: 3} - {fileID: -5050977528292827191, guid: 1c59b9cd0adef0941bc4bd4bde66a759, type: 3}
- {fileID: -6734710479057769413, guid: 1c59b9cd0adef0941bc4bd4bde66a759, type: 3} - {fileID: -6734710479057769413, guid: 1c59b9cd0adef0941bc4bd4bde66a759, type: 3}
@ -541,7 +540,7 @@ MonoBehaviour:
rotSpeed: 140 rotSpeed: 140
fallLeftCurve: {fileID: 7764367815067799206} fallLeftCurve: {fileID: 7764367815067799206}
fallRightCurve: {fileID: 7122240029612248645} fallRightCurve: {fileID: 7122240029612248645}
halvesParent: {fileID: 2078672318315355962} sr: {fileID: 7206843505938361017}
--- !u!1 &1203023033644261752 --- !u!1 &1203023033644261752
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1730,13 +1729,8 @@ MonoBehaviour:
DogAnim: {fileID: 1770250701376598399} DogAnim: {fileID: 1770250701376598399}
BirdAnim: {fileID: 4964290445827434540} BirdAnim: {fileID: 4964290445827434540}
ObjectBase: {fileID: 4494871422713187218} ObjectBase: {fileID: 4494871422713187218}
FullBird: {fileID: 3439822116337821266}
WhichObject: {fileID: 1780506401517458247} WhichObject: {fileID: 1780506401517458247}
WhichLeftHalf: {fileID: 8550182553065708291} CutEverythingText: {fileID: 8405214087581042494}
WhichRightHalf: {fileID: 7206843505938361017}
cutEverythingText: {fileID: 8405214087581042494}
CurveFromLeft: {fileID: 2592536718110886033}
CurveFromRight: {fileID: 8538313959133990924}
ObjectTypes: ObjectTypes:
- {fileID: 0} - {fileID: 0}
- {fileID: -2307065246004786754, guid: 1c59b9cd0adef0941bc4bd4bde66a759, type: 3} - {fileID: -2307065246004786754, guid: 1c59b9cd0adef0941bc4bd4bde66a759, type: 3}
@ -4202,7 +4196,7 @@ MonoBehaviour:
rotSpeed: -140 rotSpeed: -140
fallLeftCurve: {fileID: 7191847337805905266} fallLeftCurve: {fileID: 7191847337805905266}
fallRightCurve: {fileID: 5028931464679965393} fallRightCurve: {fileID: 5028931464679965393}
halvesParent: {fileID: 2078672318315355962} sr: {fileID: 8550182553065708291}
--- !u!1 &8691542995859896262 --- !u!1 &8691542995859896262
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -18,16 +18,15 @@ namespace HeavenStudio.Games.Loaders
{ {
if (datamodel == "dogNinja/ThrowObject" && e.version == 0) if (datamodel == "dogNinja/ThrowObject" && e.version == 0)
{ {
Debug.Log("entity at beat " + e.beat + " is the same? " + (e["typeL"] == e["typeR"])); e["diffObjs"] = e["direction"] == 2 && e["typeL"] != e["typeR"];
bool diff = e["typeL"] == e["typeR"]; e["type"] = e["direction"] is 0 or 2 ? (int)e["typeL"] : e["typeR"];
Debug.Log("entity at beat " + e.beat + " is the same? " + (e["typeL"] == e["typeR"]));
e.CreateProperty("type", diff ? e["typeL"] : DogNinja.ObjectType.Random);
e.version = 1; e.version = 1;
return e; return e;
} }
return null; return null;
} }
// // Beatmap.Entities isn't available in a riqentity updater...
// RiqEntity BirdUpdater(string datamodel, RiqEntity e) // RiqEntity BirdUpdater(string datamodel, RiqEntity e)
// { // {
// if (datamodel == "dogNinja/CutEverything" && e.version == 0) // if (datamodel == "dogNinja/CutEverything" && e.version == 0)
@ -143,15 +142,8 @@ namespace HeavenStudio.Games
[Header("References")] [Header("References")]
[SerializeField] ThrowObject ObjectBase; [SerializeField] ThrowObject ObjectBase;
[SerializeField] GameObject FullBird;
[SerializeField] SpriteRenderer WhichObject; [SerializeField] SpriteRenderer WhichObject;
public SpriteRenderer WhichLeftHalf; [SerializeField] TMP_Text CutEverythingText;
public SpriteRenderer WhichRightHalf;
[SerializeField] TMP_Text cutEverythingText;
[Header("Curves")]
[SerializeField] BezierCurve3D CurveFromLeft;
[SerializeField] BezierCurve3D CurveFromRight;
[SerializeField] Sprite[] ObjectTypes; [SerializeField] Sprite[] ObjectTypes;
@ -228,22 +220,21 @@ namespace HeavenStudio.Games
public override void OnGameSwitch(double beat) public override void OnGameSwitch(double beat)
{ {
foreach (var e in gameManager.Beatmap.Entities.FindAll(e => e.datamodel is "dogNinja/ThrowObject" && beat > e.beat - 2 && beat < e.beat + 1)) foreach (var e in gameManager.Beatmap.Entities.FindAll(e => e.datamodel is "dogNinja/ThrowObject" && beat >= e.beat - 2 && beat < e.beat + 1))
{ {
// if (!e.dynamicData.ContainsKey("throwData")) {
// QueueObject(e.beat, e["direction"], e["diffObjs"], e["type"], e["typeL"], e["typeR"], e["shouldPrepare"], true, e);
// }
QueuedThrow t = e["throwData"]; QueuedThrow t = e["throwData"];
DogAnim.Play("Prepare", 0, 1); if (beat > e.beat) {
preparing = true; DogAnim.Play("Prepare", 0, 1);
ThrowObject(e.beat, e["direction"], t.types, t.sfxNumL, t.sfxNumR); preparing = true;
}
ThrowObject(e.beat, e["direction"], ((beat <= e.beat) && e["shouldPrepare"]), t.types, t.sfxNumL, t.sfxNumR);
} }
} }
private void Update() private void Update()
{ {
// prepare queuing stuff // prepare queuing stuff
if (queuePrepare && (DogAnim.IsAnimationNotPlaying() || DogAnim.IsPlayingAnimationNames("Bop"))) if (queuePrepare && !preparing && (DogAnim.IsAnimationNotPlaying() || DogAnim.IsPlayingAnimationNames("Bop")))
{ {
DogAnim.DoScaledAnimationAsync("Prepare", 0.5f); DogAnim.DoScaledAnimationAsync("Prepare", 0.5f);
preparing = true; preparing = true;
@ -253,8 +244,9 @@ namespace HeavenStudio.Games
// controls stuff // controls stuff
if (PlayerInput.GetIsAction(InputAction_TouchPress) && !GameManager.instance.autoplay) if (PlayerInput.GetIsAction(InputAction_TouchPress) && !GameManager.instance.autoplay)
{ {
queuePrepare = true; // queuePrepare = true;
DogAnim.DoScaledAnimationAsync("Prepare", 0.5f); DogAnim.DoScaledAnimationAsync("Prepare", 0.5f);
preparing = true;
} }
if (PlayerInput.GetIsAction(InputAction_TouchRelease) && (!IsExpectingInputNow(InputAction_Press)) && (!GameManager.instance.autoplay)) if (PlayerInput.GetIsAction(InputAction_TouchRelease) && (!IsExpectingInputNow(InputAction_Press)) && (!GameManager.instance.autoplay))
{ {
@ -268,20 +260,10 @@ namespace HeavenStudio.Games
DogAnim.DoScaledAnimationAsync(slice, 0.5f); DogAnim.DoScaledAnimationAsync(slice, 0.5f);
SoundByte.PlayOneShotGame("dogNinja/whiff"); SoundByte.PlayOneShotGame("dogNinja/whiff");
queuePrepare = false; StopPrepare();
} }
} }
private void LateUpdate()
{
// // prepare queuing stuff
// if (queuePrepare && (DogAnim.IsAnimationNotPlaying() || DogAnim.IsPlayingAnimationNames("Bop", "Idle")))
// {
// DogAnim.DoScaledAnimationAsync("Prepare", 0.5f);
// queuePrepare = false;
// }
}
public void Bop(double beat, float length, bool auto, bool bop) public void Bop(double beat, float length, bool auto, bool bop)
{ {
autoBop = auto; autoBop = auto;
@ -313,14 +295,9 @@ namespace HeavenStudio.Games
} }
} }
if (GameManager.instance.minigameObj.TryGetComponent(out DogNinja instance)) { if (GameManager.instance.minigame is DogNinja instance) {
instance.ThrowObject(beat, direction, types, sfxNums[0], sfxNums[1]); instance.ThrowObject(beat, direction, prepare, types, sfxNums[0], sfxNums[1]);
if (prepare) {
BeatAction.New(instance, new() {
new(beat, () => instance.queuePrepare = PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch || GameManager.instance.autoplay)
});
}
} else { } else {
var queuedThrow = new QueuedThrow() { var queuedThrow = new QueuedThrow() {
types = types, types = types,
@ -334,8 +311,13 @@ namespace HeavenStudio.Games
} }
} }
public void ThrowObject(double beat, int direction, int[] types, string sfxNumL, string sfxNumR) public void ThrowObject(double beat, int direction, bool prepare, int[] types, string sfxNumL, string sfxNumR)
{ {
if (prepare) {
BeatAction.New(this, new() {
new(beat, () => queuePrepare = PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch || GameManager.instance.autoplay)
});
}
for (int i = 0; i < (direction == 2 ? 2 : 1); i++) for (int i = 0; i < (direction == 2 ? 2 : 1); i++)
{ {
bool l = direction is 2 ? i == 0 : direction == 0; bool l = direction is 2 ? i == 0 : direction == 0;
@ -344,7 +326,7 @@ namespace HeavenStudio.Games
obj.startBeat = beat; obj.startBeat = beat;
obj.direction = direction; obj.direction = direction;
obj.fromLeft = l; obj.fromLeft = l;
obj.type = types[i]; obj.type = l ? types[0] : types[1];
obj.sfxNum = l ? sfxNumL : sfxNumR; obj.sfxNum = l ? sfxNumL : sfxNumR;
if (direction == 2) obj.shouldSfx = l == (types[0] == types[1]); if (direction == 2) obj.shouldSfx = l == (types[0] == types[1]);
} }
@ -354,7 +336,7 @@ namespace HeavenStudio.Games
{ {
if (sound) SoundByte.PlayOneShotGame("dogNinja/bird_flap"); if (sound) SoundByte.PlayOneShotGame("dogNinja/bird_flap");
BirdAnim.DoScaledAnimationAsync("FlyIn", 0.5f); BirdAnim.DoScaledAnimationAsync("FlyIn", 0.5f);
cutEverythingText.text = customText; CutEverythingText.text = customText;
BeatAction.New(this, new() { BeatAction.New(this, new() {
new(beat + length, () => BirdAnim.Play("FlyOut", 0, 0)) new(beat + length, () => BirdAnim.Play("FlyOut", 0, 0))

View file

@ -7,11 +7,11 @@ using NaughtyBezierCurves;
namespace HeavenStudio.Games.Scripts_DogNinja namespace HeavenStudio.Games.Scripts_DogNinja
{ {
// this code sucks but i don't wanna touch it. it works fine enough. sorry!
public class SpawnHalves : MonoBehaviour public class SpawnHalves : MonoBehaviour
{ {
public double startBeat; public double startBeat;
public Vector3 objPos; public Vector3 objPos;
private Vector3 posModifier;
public bool lefty; public bool lefty;
float bpmModifier; float bpmModifier;
double songPos; double songPos;
@ -22,24 +22,18 @@ namespace HeavenStudio.Games.Scripts_DogNinja
[SerializeField] BezierCurve3D fallLeftCurve; [SerializeField] BezierCurve3D fallLeftCurve;
[SerializeField] BezierCurve3D fallRightCurve; [SerializeField] BezierCurve3D fallRightCurve;
BezierCurve3D curve; BezierCurve3D curve;
[SerializeField] Transform halvesParent; public SpriteRenderer sr;
private void Awake()
{
bpmModifier = Conductor.instance.songBpm / 100;
songPos = Conductor.instance.songPositionInBeatsAsDouble;
}
private void Start() private void Start()
{ {
bpmModifier = Conductor.instance.songBpm / 100;
songPos = Conductor.instance.songPositionInBeatsAsDouble;
curve = lefty ? fallRightCurve : fallLeftCurve; curve = lefty ? fallRightCurve : fallLeftCurve;
} }
private void Update() private void Update()
{ {
// holy shit float flyPosHalves = (Conductor.instance.GetPositionFromBeat(songPos, 3f) * Conductor.instance.GetPositionFromBeat(songPos, 2f)) + Conductor.instance.GetPositionFromBeat(songPos, 1f);
float flyPosHalves = (Conductor.instance.GetPositionFromBeat(songPos, 3f)*(Conductor.instance.GetPositionFromBeat(songPos, 2f)))+Conductor.instance.GetPositionFromBeat(songPos, 1f);
flyPosHalves = (flyPosHalves * 0.2f) + 0.35f; flyPosHalves = (flyPosHalves * 0.2f) + 0.35f;
transform.position = curve.GetPoint(flyPosHalves) + objPos; transform.position = curve.GetPoint(flyPosHalves) + objPos;
@ -50,12 +44,7 @@ namespace HeavenStudio.Games.Scripts_DogNinja
// clean-up logic // clean-up logic
if (flyPosHalves > 1f) { if (flyPosHalves > 1f) {
Destroy(gameObject); Destroy(gameObject);
}; }
if ((!Conductor.instance.isPlaying && !Conductor.instance.isPaused)
|| GameManager.instance.currentGame != "dogNinja") {
Destroy(gameObject);
};
} }
} }
} }

View file

@ -33,9 +33,8 @@ namespace HeavenStudio.Games.Scripts_DogNinja
private BezierCurve3D barelyCurve; private BezierCurve3D barelyCurve;
[SerializeField] BezierCurve3D BarelyLeftCurve; [SerializeField] BezierCurve3D BarelyLeftCurve;
[SerializeField] BezierCurve3D BarelyRightCurve; [SerializeField] BezierCurve3D BarelyRightCurve;
[SerializeField] GameObject HalvesLeftBase; [SerializeField] SpawnHalves HalvesLeftBase;
[SerializeField] GameObject HalvesRightBase; [SerializeField] SpawnHalves HalvesRightBase;
[SerializeField] Transform ObjectParent;
public Sprite[] objectLeftHalves; public Sprite[] objectLeftHalves;
public Sprite[] objectRightHalves; public Sprite[] objectRightHalves;
@ -50,9 +49,8 @@ namespace HeavenStudio.Games.Scripts_DogNinja
private void Update() private void Update()
{ {
float flyPos = game.conductor.GetPositionFromBeat(startBeat, 1f)+1.1f;
float flyPosBarely = game.conductor.GetPositionFromBeat(barelyTime, 1f)+1f;
if (isActive) { if (isActive) {
float flyPos = game.conductor.GetPositionFromBeat(startBeat, 1f)+1.1f;
flyPos *= 0.31f; flyPos *= 0.31f;
transform.position = curve.GetPoint(flyPos); transform.position = curve.GetPoint(flyPos);
objPos = curve.GetPoint(flyPos); objPos = curve.GetPoint(flyPos);
@ -61,6 +59,7 @@ namespace HeavenStudio.Games.Scripts_DogNinja
Destroy(gameObject); Destroy(gameObject);
} }
} else { } else {
float flyPosBarely = game.conductor.GetPositionFromBeat(barelyTime, 1f)+1f;
flyPosBarely *= 0.3f; flyPosBarely *= 0.3f;
transform.position = barelyCurve.GetPoint(flyPosBarely) + objPos; transform.position = barelyCurve.GetPoint(flyPosBarely) + objPos;
float rot = fromLeft ? 200f : -200f; float rot = fromLeft ? 200f : -200f;
@ -69,11 +68,6 @@ namespace HeavenStudio.Games.Scripts_DogNinja
Destroy(gameObject); Destroy(gameObject);
} }
} }
if ((!game.conductor.isPlaying && !game.conductor.isPaused)
|| game.gameManager.currentGame != "dogNinja") {
Destroy(gameObject);
}
} }
private void Hit(PlayerActionEvent caller, float state) private void Hit(PlayerActionEvent caller, float state)
@ -89,16 +83,16 @@ namespace HeavenStudio.Games.Scripts_DogNinja
barelyTime = game.conductor.songPositionInBeatsAsDouble; barelyTime = game.conductor.songPositionInBeatsAsDouble;
DogAnim.DoScaledAnimationAsync("Barely" + dir, 0.5f); DogAnim.DoScaledAnimationAsync("Barely" + dir, 0.5f);
SoundByte.PlayOneShotGame("dogNinja/barely"); if (shouldSfx) SoundByte.PlayOneShotGame("dogNinja/barely");
} else { } else {
DogAnim.DoScaledAnimationAsync("Slice" + dir, 0.5f); DogAnim.DoScaledAnimationAsync("Slice" + dir, 0.5f);
if (shouldSfx) SoundByte.PlayOneShotGame(sfxNum + "2"); if (shouldSfx) SoundByte.PlayOneShotGame(sfxNum + "2");
Debug.Log("type - 1 : " + (type - 1)); Debug.Log("type - 1 : " + (type - 1));
game.WhichLeftHalf.sprite = objectLeftHalves[type - 1]; HalvesLeftBase.sr.sprite = objectLeftHalves[type - 1];
game.WhichRightHalf.sprite = objectRightHalves[type - 1]; HalvesRightBase.sr.sprite = objectRightHalves[type - 1];
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
SpawnHalves half = Instantiate(i == 0 ? HalvesLeftBase : HalvesRightBase, game.transform).GetComponent<SpawnHalves>(); SpawnHalves half = Instantiate(i == 0 ? HalvesLeftBase : HalvesRightBase, game.transform);
half.startBeat = startBeat; half.startBeat = startBeat;
half.lefty = fromLeft; half.lefty = fromLeft;
half.objPos = objPos; half.objPos = objPos;
@ -110,7 +104,7 @@ namespace HeavenStudio.Games.Scripts_DogNinja
private void Miss(PlayerActionEvent caller) private void Miss(PlayerActionEvent caller)
{ {
if (!game.queuePrepare) return; if (!game.preparing) return;
DogAnim.DoScaledAnimationAsync("Unprepare", 0.5f); DogAnim.DoScaledAnimationAsync("Unprepare", 0.5f);
game.StopPrepare(); game.StopPrepare();
} }