[Player][Interactions] Pulver moves to item and goes back. Item disappears, but in wrong order

This commit is contained in:
Michal Pikulski
2025-09-04 00:00:46 +02:00
parent 97c5edf619
commit 0c930d09a4
18 changed files with 455 additions and 43 deletions

View File

@@ -7,8 +7,12 @@ public class LevelSwitch : MonoBehaviour
public SpriteRenderer iconRenderer;
private Interactable interactable;
private bool _isActive = true;
void Awake()
{
_isActive = true;
if (iconRenderer == null)
iconRenderer = GetComponent<SpriteRenderer>();
@@ -51,11 +55,12 @@ public class LevelSwitch : MonoBehaviour
private async void OnInteracted()
{
Debug.Log($"LevelSwitch.OnInteracted: Switching to level {switchData?.targetLevelSceneName}");
if (switchData != null && !string.IsNullOrEmpty(switchData.targetLevelSceneName))
if (switchData != null && !string.IsNullOrEmpty(switchData.targetLevelSceneName) && _isActive)
{
// Optionally: show loading UI here
var progress = new Progress<float>(p => Debug.Log($"Loading progress: {p * 100:F0}%"));
await SceneManagerService.Instance.SwitchSceneAsync(switchData.targetLevelSceneName, progress);
_isActive = false;
// Optionally: hide loading UI here
}
}