Re-add auto pause on AFK

This commit is contained in:
Lncvrt committed 2026-04-04 08:17:52 -07:00
1 parent c4e001a470
commit 026726674e
3 files changed
+37

No files matched your search

+12
View File
@@ -56,6 +56,7 @@ public class GamePlayer : MonoBehaviour {
public readonly List<GameObject> berries = new();
private readonly List<EntityId> noGravityBerries = new();
private bool hasJumped = false;
private float lastMoveTime;
internal bool IsGrounded() => Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), groundCollider).distance <= 0.1f;
@@ -82,6 +83,7 @@ public class GamePlayer : MonoBehaviour {
BazookaManager.Instance.GetAccountID() ?? 0
);
lastMoveTime = Time.time;
UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Enable();
highscore = BazookaManager.Instance.GetGameStoreHighScore();
totalNormalBerries = BazookaManager.Instance.GetGameStoreTotalNormalBerries();
@@ -142,17 +144,20 @@ public class GamePlayer : MonoBehaviour {
}
}
if (doMoveLeft && !doMoveRight) {
lastMoveTime = Time.time;
bird.transform.position += new UnityEngine.Vector3(-(576f * (speedModifier * canvasRect.lossyScale.x) * Time.deltaTime), 0f, 0f);
ClampPosition(bird);
bird.transform.localScale = new UnityEngine.Vector3(1f, 1f, 1f);
}
if (doMoveRight && !doMoveLeft) {
lastMoveTime = Time.time;
bird.transform.position += new UnityEngine.Vector3(576f * (speedModifier * canvasRect.lossyScale.x) * Time.deltaTime, 0f, 0f);
ClampPosition(bird);
bird.transform.localScale = new UnityEngine.Vector3(-1f, 1f, 1f);
}
if (doMoveLeft || doMoveRight) groundCollider.transform.position = new(bird.transform.position.x, groundCollider.transform.position.y);
if (doJump && IsGrounded() && !hasJumped) {
lastMoveTime = Time.time;
hasJumped = true;
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Jump"), Camera.main.transform.position, 0.75f * BazookaManager.Instance.GetSettingSFXVolume());
if (boostLeft > 0f || speedyLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 480f * canvasRect.lossyScale.y);
@@ -258,6 +263,12 @@ public class GamePlayer : MonoBehaviour {
SpawnBerries();
if (!pausePanel.activeSelf) {
if (Time.time - lastMoveTime > 20) {
lastMoveTime = float.MaxValue;
EnablePause();
return;
}
MoveBird();
if (boostLeft > 0f) {
boostLeft -= Time.deltaTime;
@@ -402,6 +413,7 @@ public class GamePlayer : MonoBehaviour {
GamePlayerPauseMenu.Instance.ToggleEditingUI();
return;
}
lastMoveTime = Time.time;
rb.gravityScale = 100f * canvasRect.lossyScale.y;
rb.linearVelocity = velocityBeforePause;
velocityBeforePause = new();