Skip to content

Chore/fix env for windows#31

Merged
AyakorK merged 7 commits intodevelopfrom
chore/fix_env_for_windows
Oct 25, 2024
Merged

Chore/fix env for windows#31
AyakorK merged 7 commits intodevelopfrom
chore/fix_env_for_windows

Conversation

@Thomlam
Copy link
Copy Markdown
Contributor

@Thomlam Thomlam commented Oct 25, 2024

Summary by CodeRabbit

  • Nouvelles Fonctionnalités

    • Ajout d'un nouveau prefab de piège dans la scène "EmptyRoom_2".
    • Intégration du chargement des variables d'environnement pour la gestion des connexions socket.
  • Améliorations

    • Amélioration de la gestion des erreurs lors du chargement des variables d'environnement.
    • Optimisation de la logique de gestion de la santé du joueur, y compris la prévention de l'émission multiple lors de la mort.
  • Corrections de Bugs

    • Suppression de la méthode de nettoyage de la connexion socket lors de la fermeture de l'application, ce qui pourrait entraîner des fuites de ressources.

@Thomlam Thomlam requested a review from AyakorK October 25, 2024 13:47
@Thomlam Thomlam self-assigned this Oct 25, 2024
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 25, 2024

Walkthrough

Les modifications apportées dans cette demande de tirage concernent principalement la configuration des objets de jeu et leurs propriétés dans la scène Unity EmptyRoom_2.unity, ainsi que l'ajout de méthodes pour charger des variables d'environnement dans les classes PlayerMovement et SocketManager. Les ajustements incluent des modifications des propriétés des instances de prefab, des objets de jeu et des méthodes de gestion de la santé du joueur, tout en maintenant la logique existante pour les connexions de socket et la gestion des pièges.

Changes

Fichiers Résumé des changements
Assets/Scenes/EmptyRoom_2.unity Ajout et modification des propriétés des instances de prefab, y compris l'ajout d'une référence pour trapPrefabs. Mise à jour des propriétés des objets de jeu tels que m_Name, m_IsActive, et ajustements des transformations.
Assets/Scripts/Player/PlayerController.cs Ajout de la méthode LoadEnvVariables pour charger les variables d'environnement depuis un fichier .env. Mise à jour de la méthode Start pour appeler LoadEnvVariables et gestion améliorée des erreurs lors de la connexion socket.
Assets/Scripts/SocketManager.cs Ajout de la méthode LoadEnvVariables pour charger les variables d'environnement avant d'établir la connexion socket. Maintien de la gestion des erreurs existante lors de la connexion.
Assets/Scripts/Trap/TrapManager.cs Suppression de la méthode OnApplicationQuit, qui gérait la déconnexion du socket à la fermeture de l'application. Aucune modification des autres méthodes ou de la logique de placement des pièges.
Assets/Scripts/UI/PlayerHealth.cs Modifications des méthodes de gestion de la santé, y compris des vérifications pour éviter les appels multiples lors de la mort du joueur. Amélioration de la logique de mise à jour de la santé sans changer les signatures des méthodes.

Possibly related PRs

  • feat: Add Socket to props to send them to back-end #8: Ajout d'un composant MonoBehaviour au prefab Player, lié à la gestion des objets de jeu dans la scène.
  • Feature/add traps #19: Introduction d'une classe Bear_Trap pour gérer les interactions avec un piège, en relation directe avec l'ajout d'une référence de piège dans EmptyRoom_2.unity.
  • feat: add death system #30: Modifications significatives du prefab Main Camera et ajout d'un DeathPanel, connectés à la gestion des états de jeu et des pièges.

Suggested reviewers

  • AyakorK

Poem

🐰 Dans la pièce vide, les pièges se cachent,
Des variables d'environnement, nous les attachons.
La santé du joueur, un cœur à protéger,
Avec des connexions solides, prêtes à vibrer.
Dans ce monde de code, nous sautons et dansons,
Ensemble, les changements, une belle chanson! 🎶


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (4)
Assets/Scripts/UI/PlayerHealth.cs (2)

Line range hint 39-46: Erreur de syntaxe dans la méthode Heal

Il manque une accolade fermante après currentHealth = maxHealth. Cette erreur empêchera la compilation du code.

Voici la correction à appliquer :

    public void Heal(int amount)
    {
        currentHealth += amount;
        if (currentHealth > maxHealth)
        {
            currentHealth = maxHealth;
+       }
        UpdateHealthBar();
    }

Line range hint 39-46: Suggestion d'amélioration pour la méthode Heal

Pour une meilleure cohérence avec la méthode TakeDamage, considérez l'ajout d'une vérification de santé minimale.

Voici une suggestion d'amélioration :

    public void Heal(int amount)
    {
        currentHealth += amount;
        if (currentHealth > maxHealth)
        {
            currentHealth = maxHealth;
        }
+       if (currentHealth < 0)
+       {
+           currentHealth = 0;
+       }
        UpdateHealthBar();
    }
Assets/Scripts/SocketManager.cs (1)

6-7: Imports System.Collections.Generic non utilisé

L'import System.Collections.Generic a été ajouté mais n'est pas utilisé dans le code.

using System;
using System.Threading.Tasks;
using UnityEngine;
using SocketIOClient;
using CandyCoded.env;
using System.IO;
-using System.Collections.Generic;
Assets/Scripts/Player/PlayerController.cs (1)

Line range hint 1-225: Recommandations générales pour la gestion des configurations

Pour améliorer la robustesse de l'application sur Windows, voici quelques suggestions architecturales :

  1. Centraliser la gestion des variables d'environnement dans une seule classe.
  2. Utiliser un système de configuration hiérarchique.
  3. Implémenter une validation des configurations au démarrage.

Je suggère de créer une classe ConfigurationManager dédiée. Voulez-vous que je propose une implémentation ?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 63971ff and 7399e72.

📒 Files selected for processing (5)
  • Assets/Scenes/EmptyRoom_2.unity (2 hunks)
  • Assets/Scripts/Player/PlayerController.cs (4 hunks)
  • Assets/Scripts/SocketManager.cs (2 hunks)
  • Assets/Scripts/Trap/TrapManager.cs (0 hunks)
  • Assets/Scripts/UI/PlayerHealth.cs (2 hunks)
💤 Files with no reviewable changes (1)
  • Assets/Scripts/Trap/TrapManager.cs
🔇 Additional comments (7)
Assets/Scripts/UI/PlayerHealth.cs (3)

62-67: Amélioration de la gestion de l'état de mort du joueur

La vérification supplémentaire de !deadCanvas.activeSelf est une bonne pratique pour éviter les émissions multiples de socket.


83-83: RAS sur la mise à jour de la barre de vie

La logique d'instanciation des cœurs est correcte.


62-67: Vérification de la gestion des sockets

Assurons-nous que l'émission du socket est correctement gérée dans tous les cas.

Assets/Scripts/SocketManager.cs (1)

32-32: Vérifier la compatibilité Windows du chemin du fichier

Le chemin du fichier .env utilise Application.dataPath qui pourrait causer des problèmes sur Windows.

✅ Verification successful

La gestion des chemins de fichiers est correctement implémentée

L'utilisation de Path.Combine avec Application.dataPath est la méthode recommandée par Unity pour gérer les chemins de fichiers de manière compatible sur toutes les plateformes, y compris Windows. Cette approche est utilisée de manière cohérente dans tout le code pour accéder au fichier .env.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Rechercher d'autres utilisations de Application.dataPath pour vérifier la cohérence
rg "Application.dataPath" -A 2

Length of output: 479


Script:

#!/bin/bash
# Vérifier l'utilisation de Path.Combine pour voir si c'est cohérent dans le code
rg "Path.Combine" -A 2

Length of output: 471

Assets/Scripts/Player/PlayerController.cs (1)

215-215: Amélioration de la clarté du message d'erreur

La modification apportée pour utiliser explicitement UnityEngine.Debug.LogError améliore la clarté du code.

Assets/Scenes/EmptyRoom_2.unity (2)

884-887: Confirmation requise pour l'activation par défaut de la caméra

L'activation par défaut de la caméra pourrait avoir un impact sur l'initialisation de la scène. Assurez-vous que cela n'interfère pas avec d'autres systèmes de caméra ou transitions.


693-696: Vérification nécessaire de la configuration du nouveau piège

L'ajout d'un nouveau préfab de piège nécessite une vérification de sa configuration pour assurer une intégration correcte avec le système de pièges existant.

✅ Verification successful

Configuration du préfab d'arbalète correctement intégrée

Le préfab d'arbalète est correctement configuré avec :

  • Le script Crossbow attaché avec les références nécessaires
  • Un point de tir (firePoint) correctement positionné
  • Une direction de tir appropriée
  • Les composants de collision et d'animation requis

Le système de gestion des pièges (TrapManager) prend également en charge ce type de piège dans son dictionnaire de préfabs.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Vérifier la configuration du préfab de piège
# Rechercher les références au préfab dans les scripts

rg -l "d7c2a5ac1f23afe428f872343ed56d71"

Length of output: 209


Script:

#!/bin/bash
# Vérifier le contenu du préfab de l'arbalète et ses références
cat Assets/Prefabs/Traps/Crossbow/crossbow_up_prefab.prefab

# Rechercher les scripts liés aux pièges pour vérifier l'intégration
rg -g "*.cs" "trap" -l

Length of output: 6810


Script:

#!/bin/bash
# Vérifier le script de gestion des pièges
cat Assets/Scripts/Trap/TrapManager.cs

# Vérifier le script spécifique à l'arbalète
rg -g "*.cs" "arrowPrefab" -l

Length of output: 4154


Script:

#!/bin/bash
# Vérifier le script de l'arbalète
cat Assets/Scripts/Trap/Crossbow/Crossbow.cs

# Vérifier les autres préfabs d'arbalète référencés
cat Assets/Prefabs/Traps/Crossbow/*.prefab

Length of output: 29463

Comment on lines +58 to +74

LoadEnvVariables();

try
{
var socketUrl = Environment.GetEnvironmentVariable("SOCKET_URL");
var uri = new Uri(socketUrl);
ClientSocket = new SocketIOUnity(uri);

// Connect to the server
await ClientSocket.ConnectAsync();
Debug.Log("Connected to backend via SocketManager.");
}
catch (Exception e)
{
Debug.LogError("Socket connection error: " + e.Message);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Code dupliqué dans SetupSocket

Il y a une duplication du bloc try-catch pour la connexion socket. De plus, deux approches différentes sont utilisées pour récupérer l'URL du socket.

Voici la correction proposée :

 private async Task SetupSocket()
 {
     LoadEnvVariables(); 

     try
     {
-        var socketUrl = Environment.GetEnvironmentVariable("SOCKET_URL");
-        var uri = new Uri(socketUrl);
-        ClientSocket = new SocketIOUnity(uri);
-
-        // Connect to the server
-        await ClientSocket.ConnectAsync();
-        Debug.Log("Connected to backend via SocketManager.");
-    }
-    catch (Exception e)
-    {
-        Debug.LogError("Socket connection error: " + e.Message);
-    }
-
-    try
-    {
-        env.TryParseEnvironmentVariable("SOCKET_URL", out string socketUrl);
+        if (!env.TryParseEnvironmentVariable("SOCKET_URL", out string socketUrl))
+        {
+            throw new Exception("Variable d'environnement SOCKET_URL non définie");
+        }
         var uri = new Uri(socketUrl);
         ClientSocket = new SocketIOUnity(uri);

         // Connect to the server
         await ClientSocket.ConnectAsync();
-        Debug.Log("Connected to backend via SocketManager.");
+        Debug.Log("Connecté au backend via SocketManager.");
     }
     catch (Exception e)
     {
-        Debug.LogError("Socket connection error: " + e.Message);
+        Debug.LogError($"Erreur de connexion socket : {e.Message}");
     }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
LoadEnvVariables();
try
{
var socketUrl = Environment.GetEnvironmentVariable("SOCKET_URL");
var uri = new Uri(socketUrl);
ClientSocket = new SocketIOUnity(uri);
// Connect to the server
await ClientSocket.ConnectAsync();
Debug.Log("Connected to backend via SocketManager.");
}
catch (Exception e)
{
Debug.LogError("Socket connection error: " + e.Message);
}
LoadEnvVariables();
try
{
if (!env.TryParseEnvironmentVariable("SOCKET_URL", out string socketUrl))
{
throw new Exception("Variable d'environnement SOCKET_URL non définie");
}
var uri = new Uri(socketUrl);
ClientSocket = new SocketIOUnity(uri);
// Connect to the server
await ClientSocket.ConnectAsync();
Debug.Log("Connecté au backend via SocketManager.");
}
catch (Exception e)
{
Debug.LogError($"Erreur de connexion socket : {e.Message}");
}

Comment on lines +30 to +54
private void LoadEnvVariables()
{
string envFilePath = Path.Combine(Application.dataPath, ".env");

if (File.Exists(envFilePath))
{
foreach (var line in File.ReadAllLines(envFilePath))
{
if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#"))
{
var keyValue = line.Split('=');
if (keyValue.Length == 2)
{
var key = keyValue[0].Trim();
var value = keyValue[1].Trim();
Environment.SetEnvironmentVariable(key, value);
}
}
}
}
else
{
Debug.LogError(".env file not found at " + envFilePath);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Améliorer la gestion des variables d'environnement

La méthode LoadEnvVariables présente plusieurs points à améliorer :

  1. Il manque une validation du contenu des variables d'environnement
  2. Les erreurs ne sont pas gérées lors de la lecture du fichier
  3. Le chemin du fichier .env pourrait être problématique sur certaines plateformes

Voici une version améliorée :

 private void LoadEnvVariables()
 {
-    string envFilePath = Path.Combine(Application.dataPath, ".env");
+    string envFilePath = Path.Combine(Application.persistentDataPath, ".env");

     if (File.Exists(envFilePath))
     {
-        foreach (var line in File.ReadAllLines(envFilePath))
+        try
         {
-            if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#"))
+            foreach (var line in File.ReadAllLines(envFilePath))
             {
-                var keyValue = line.Split('=');
-                if (keyValue.Length == 2)
+                if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#"))
                 {
-                    var key = keyValue[0].Trim();
-                    var value = keyValue[1].Trim();
-                    Environment.SetEnvironmentVariable(key, value);
+                    var keyValue = line.Split(new[] { '=' }, 2);
+                    if (keyValue.Length == 2)
+                    {
+                        var key = keyValue[0].Trim();
+                        var value = keyValue[1].Trim();
+                        if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
+                        {
+                            Environment.SetEnvironmentVariable(key, value);
+                        }
+                    }
                 }
             }
         }
+        catch (Exception e)
+        {
+            Debug.LogError($"Erreur lors de la lecture du fichier .env : {e.Message}");
+        }
     }
     else
     {
-        Debug.LogError(".env file not found at " + envFilePath);
+        Debug.LogError($"Fichier .env non trouvé : {envFilePath}");
     }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private void LoadEnvVariables()
{
string envFilePath = Path.Combine(Application.dataPath, ".env");
if (File.Exists(envFilePath))
{
foreach (var line in File.ReadAllLines(envFilePath))
{
if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#"))
{
var keyValue = line.Split('=');
if (keyValue.Length == 2)
{
var key = keyValue[0].Trim();
var value = keyValue[1].Trim();
Environment.SetEnvironmentVariable(key, value);
}
}
}
}
else
{
Debug.LogError(".env file not found at " + envFilePath);
}
}
private void LoadEnvVariables()
{
string envFilePath = Path.Combine(Application.persistentDataPath, ".env");
if (File.Exists(envFilePath))
{
try
{
foreach (var line in File.ReadAllLines(envFilePath))
{
if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#"))
{
var keyValue = line.Split(new[] { '=' }, 2);
if (keyValue.Length == 2)
{
var key = keyValue[0].Trim();
var value = keyValue[1].Trim();
if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
{
Environment.SetEnvironmentVariable(key, value);
}
}
}
}
}
catch (Exception e)
{
Debug.LogError($"Erreur lors de la lecture du fichier .env : {e.Message}");
}
}
else
{
Debug.LogError($"Fichier .env non trouvé : {envFilePath}");
}
}

Comment on lines +84 to +98
try
{
LoadEnvVariables();
var socketUrl = Environment.GetEnvironmentVariable("SOCKET_URL");
var uri = new Uri(socketUrl);
clientSocket = SocketManager.Instance.ClientSocket;
if (clientSocket == null)
{
Debug.LogError("SocketIO client is null! Check SocketManager initialization.");
}
}
catch (Exception e)
{
Debug.LogError("Socket connection error: " + e.Message);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Code dupliqué dans la méthode Start

Il y a une duplication du bloc try-catch pour la configuration du socket. De plus, vous mélangez deux approches différentes pour charger les variables d'environnement.

Suggestion de refactorisation :

 try
 {
     LoadEnvVariables();
-    var socketUrl = Environment.GetEnvironmentVariable("SOCKET_URL");
-    var uri = new Uri(socketUrl);
-    clientSocket = SocketManager.Instance.ClientSocket;
-    if (clientSocket == null)
-    {
-        Debug.LogError("SocketIO client is null! Check SocketManager initialization.");
-    }
- }
- catch (Exception e)
- {
-    Debug.LogError("Socket connection error: " + e.Message);
- }
- try
- {
     env.TryParseEnvironmentVariable("SOCKET_URL", out string socketUrl);
     var uri = new Uri(socketUrl);
     clientSocket = SocketManager.Instance.ClientSocket;

     if (clientSocket == null)
     {
-        Debug.LogError("SocketIO client is null! Check SocketManager initialization.");
+        Debug.LogError("Le client SocketIO est null ! Vérifiez l'initialisation du SocketManager.");
     }
 }
 catch (Exception e)
 {
-    Debug.LogError("Socket connection error: " + e.Message);
+    Debug.LogError($"Erreur de connexion socket : {e.Message}");
 }

Committable suggestion was skipped due to low confidence.

Comment on lines +33 to +57
private void LoadEnvVariables()
{
string envFilePath = Path.Combine(Application.dataPath, ".env");

if (File.Exists(envFilePath))
{
foreach (var line in File.ReadAllLines(envFilePath))
{
if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#"))
{
var keyValue = line.Split('=');
if (keyValue.Length == 2)
{
var key = keyValue[0].Trim();
var value = keyValue[1].Trim();
Environment.SetEnvironmentVariable(key, value);
}
}
}
}
else
{
Debug.LogError(".env file not found at " + envFilePath);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Attention à la gestion des chemins de fichiers sur Windows

La méthode LoadEnvVariables présente plusieurs points à améliorer :

  1. L'utilisation de Path.Combine est bonne pour la compatibilité Windows, mais Application.dataPath n'est peut-être pas le meilleur choix pour stocker le fichier .env.
  2. Il manque une validation du contenu des variables d'environnement.
  3. La méthode fait double emploi avec CandyCoded.env déjà importé.

Suggestions d'amélioration :

 private void LoadEnvVariables()
 {
-    string envFilePath = Path.Combine(Application.dataPath, ".env");
+    string envFilePath = Path.Combine(Application.persistentDataPath, ".env");

     if (File.Exists(envFilePath))
     {
         foreach (var line in File.ReadAllLines(envFilePath))
         {
             if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#"))
             {
                 var keyValue = line.Split('=');
                 if (keyValue.Length == 2)
                 {
                     var key = keyValue[0].Trim();
                     var value = keyValue[1].Trim();
+                    if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value))
+                    {
+                        Debug.LogWarning($"Variable d'environnement invalide : {line}");
+                        continue;
+                    }
                     Environment.SetEnvironmentVariable(key, value);
                 }
             }
         }
     }
     else
     {
-        Debug.LogError(".env file not found at " + envFilePath);
+        Debug.LogError($"Fichier .env non trouvé : {envFilePath}");
     }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private void LoadEnvVariables()
{
string envFilePath = Path.Combine(Application.dataPath, ".env");
if (File.Exists(envFilePath))
{
foreach (var line in File.ReadAllLines(envFilePath))
{
if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#"))
{
var keyValue = line.Split('=');
if (keyValue.Length == 2)
{
var key = keyValue[0].Trim();
var value = keyValue[1].Trim();
Environment.SetEnvironmentVariable(key, value);
}
}
}
}
else
{
Debug.LogError(".env file not found at " + envFilePath);
}
}
private void LoadEnvVariables()
{
string envFilePath = Path.Combine(Application.persistentDataPath, ".env");
if (File.Exists(envFilePath))
{
foreach (var line in File.ReadAllLines(envFilePath))
{
if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#"))
{
var keyValue = line.Split('=');
if (keyValue.Length == 2)
{
var key = keyValue[0].Trim();
var value = keyValue[1].Trim();
if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value))
{
Debug.LogWarning($"Variable d'environnement invalide : {line}");
continue;
}
Environment.SetEnvironmentVariable(key, value);
}
}
}
}
else
{
Debug.LogError($"Fichier .env non trouvé : {envFilePath}");
}
}

@AyakorK AyakorK merged commit 0d346b6 into develop Oct 25, 2024
@AyakorK AyakorK deleted the chore/fix_env_for_windows branch October 25, 2024 13:59
Thomlam added a commit that referenced this pull request Oct 26, 2024
* feat: add death system

* chore: add socket emiter for end game

* fix: fix heart generator if develop don't have socket

* fix: remove crossbow

* chore: try to fix .env for Windows and Unity

* fix: Quick Fix in production
@coderabbitai coderabbitai Bot mentioned this pull request Oct 26, 2024
AyakorK added a commit that referenced this pull request Oct 27, 2024
* Chore/shadering map (#24)

* technical : add shadering and post-traitement system, adapt asset and sprite for using this

* feat: update Room2

* feat: Link the chat to the back sockets (#25)

* feat: Link chat to backend (#26)

* feat: Link the chat to the back sockets

* fix: Move the dialogue script outside the canvas to avoid it to be disabled while the canvas is going to be disabled

* fix: remove dual camera

* fix: fix crossbow system (#27)

* fix: add request to back (room name)

* fix: Revert trap manager

* hotfix: Fix things that weren't working

* feat: RPS (#29)

* feat : add multiple option and itemscollider for RockPaperCissor

* feat: Link Rock Paper Scissors to backend socket

* feat: Link RockPaperScissors, but display missing

---------

Co-authored-by: Thomas Lamiable <lamiablethomas@gmail.com>

* hotfix: Change RPS size to match the screen

* fix: fix Crossbow up sprite and arrow system, change color pixel dead font

* chore: change EmptyRoom2

* feat: add death system (#30)

* feat: add death system

* chore: add socket emiter for end game

* fix: fix heart generator if develop don't have socket

* fix: remove crossbow

* feature: add audio system and fix crossbow with sound (#32)

Co-authored-by: Guillaume MORET <90462045+AyakorK@users.noreply.github.com>

* chore: Fix env for windows (#31)

* feat: add death system

* chore: add socket emiter for end game

* fix: fix heart generator if develop don't have socket

* fix: remove crossbow

* chore: try to fix .env for Windows and Unity

* fix: Quick Fix in production

* fix: QuickFx PlayerHealth fail merge

* Fix: fix Room

* feat: Adapt Waiting Room (#33)

* feat: Instantiate waiting room when arriving in the corridor 0

* fix: Add a flag to change message one time and avoid repetition of it

* feat: Add the creation of the room when instanciating the WaitingRoom process

* feat: Try to remove the Door collider before game has started

* fix: fix lock and door system, add waiting room, last fix for dialogue system for pity

---------

Co-authored-by: Thomlam <lamiablethomas@gmail.com>

* fix: rename bear_trap to prefab

* fix: quick fix prefab room for crossbow

* fix: quickfix for bear_trap

* feat: Add room deletion when disconnection from a game

* Wip/streaming back (#35)

* feat: add streaming system with recording and sending frame jpeg

* feat: add config

* feat: first try to add socketIOSystem

* feat: Add the right socket

* feature : deploy for 60fps

---------

Co-authored-by: AyakorK <guillaume.moret@yahoo.com>

* hotfix: Get rid of a Debug

* fix: fix arrows component and stade 24 fps to streaming

* fix: Global rendering fixes (#36)

* fix: Update corridor displays + additions of colliders to avoid glitching

* fix: Add a door transition lock

* feat: Add collision to the walls in the room

* fix: Fix collisions of the hole

* fix: Fix glitched hitboxes

* fix: Destory arrows when going to an other room

---------

Co-authored-by: Guillaume MORET <90462045+AyakorK@users.noreply.github.com>
Co-authored-by: AyakorK <guillaume.moret@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants