Repository: Apptive-Game-Team/GyeMong
Pull request #276: Fix/274
Author: login: dev-yunseong
Labels: name: fix
description: 오류 수정
name: content(part)
description: 컨텐츠 구성
Created: 2025-03-09T13:23:15Z | Merged: 2025-03-11T07:38:56Z

closed #274

### 설명
- 오늘 있었던 이슈들 중 대부분을 해결했습니다.
    - 반딧불 슬라임이 죽었다 다시 일어날 때 불이 안 켜지는 문제, 
    - 슬라임이 먼곳에서 따라오는 문제
    - mob이 무한히 소환되는 문제
    - 꼬마 엘프가 복사되는 문제

- 꼬마 엘프가 계속 따라오는 문제는 PersistedGameObject issue에서 해결하도록 하겠습니다.

### 체크리스트
- [x] 코드가 잘 작동하는지 로컬에서 테스트했나요?
- [x] 기존 기능에 대한 테스트가 모두 통과했나요?
- [x] 코드 컨벤션이 일관된지 확인했습니까?


Linked issue #274: fix 튜토리얼, 그림자 숲
- [x] 꼬마 엘프 복사 버그 수정
- [x] 슬라임 수 제한
- [x] Detector 변경
- [x] 반딧불 슬라임 불 꺼져있는 거 수정

Diff:
diff --git a/Assets/Scenes/SpringRemaster/SpringBeachScene.unity b/Assets/Scenes/SpringRemaster/SpringBeachScene.unity
index 2428d1020..f8f869d15 100644
--- a/Assets/Scenes/SpringRemaster/SpringBeachScene.unity
+++ b/Assets/Scenes/SpringRemaster/SpringBeachScene.unity
@@ -3031,6 +3031,53 @@ PrefabInstance:
     m_AddedGameObjects: []
     m_AddedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: af5331454817c405f982b661525cf4a6, type: 3}
+--- !u!1 &812878835
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 812878837}
+  - component: {fileID: 812878836}
+  m_Layer: 0
+  m_Name: ChildElfCreator
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!114 &812878836
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 812878835}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 510ca1b6b5b1c4a48a574c4af0c414fc, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  _prefab: {fileID: 8934444904914948015, guid: 845dcf3fceef847748adb1c4078ac491, type: 3}
+  _conditionKey1: 
+  _conditionKey2: SpringChildEscortIsStarted
+--- !u!4 &812878837
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 812878835}
+  serializedVersion: 2
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: -8.034081, y: -1.3591499, z: -0.0725774}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_ConstrainProportionsScale: 0
+  m_Children: []
+  m_Father: {fileID: 0}
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
 --- !u!1 &842680980
 GameObject:
   m_ObjectHideFlags: 0
@@ -5235,74 +5282,6 @@ PrefabInstance:
     m_AddedGameObjects: []
     m_AddedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: a8c638ca210ca99478b7eae65070be1d, type: 3}
---- !u!1001 &1595919170206676193
-PrefabInstance:
-  m_ObjectHideFlags: 0
-  serializedVersion: 2
-  m_Modification:
-    serializedVersion: 3
-    m_TransformParent: {fileID: 0}
-    m_Modifications:
-    - target: {fileID: 4003107261100600892, guid: 845dcf3fceef847748adb1c4078ac491,
-        type: 3}
-      propertyPath: m_LocalPosition.x
-      value: -1.5308781
-      objectReference: {fileID: 0}
-    - target: {fileID: 4003107261100600892, guid: 845dcf3fceef847748adb1c4078ac491,
-        type: 3}
-      propertyPath: m_LocalPosition.y
-      value: -0.043521523
-      objectReference: {fileID: 0}
-    - target: {fileID: 4003107261100600892, guid: 845dcf3fceef847748adb1c4078ac491,
-        type: 3}
-      propertyPath: m_LocalPosition.z
-      value: 1.0157694
-      objectReference: {fileID: 0}
-    - target: {fileID: 4003107261100600892, guid: 845dcf3fceef847748adb1c4078ac491,
-        type: 3}
-      propertyPath: m_LocalRotation.w
-      value: 1
-      objectReference: {fileID: 0}
-    - target: {fileID: 4003107261100600892, guid: 845dcf3fceef847748adb1c4078ac491,
-        type: 3}
-      propertyPath: m_LocalRotation.x
-      value: -0
-      objectReference: {fileID: 0}
-    - target: {fileID: 4003107261100600892, guid: 845dcf3fceef847748adb1c4078ac491,
-        type: 3}
-      propertyPath: m_LocalRotation.y
-      value: -0
-      objectReference: {fileID: 0}
-    - target: {fileID: 4003107261100600892, guid: 845dcf3fceef847748adb1c4078ac491,
-        type: 3}
-      propertyPath: m_LocalRotation.z
-      value: -0
-      objectReference: {fileID: 0}
-    - target: {fileID: 4003107261100600892, guid: 845dcf3fceef847748adb1c4078ac491,
-        type: 3}
-      propertyPath: m_LocalEulerAnglesHint.x
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 4003107261100600892, guid: 845dcf3fceef847748adb1c4078ac491,
-        type: 3}
-      propertyPath: m_LocalEulerAnglesHint.y
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 4003107261100600892, guid: 845dcf3fceef847748adb1c4078ac491,
-        type: 3}
-      propertyPath: m_LocalEulerAnglesHint.z
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 8934444904914948015, guid: 845dcf3fceef847748adb1c4078ac491,
-        type: 3}
-      propertyPath: m_Name
-      value: ChildElf
-      objectReference: {fileID: 0}
-    m_RemovedComponents: []
-    m_RemovedGameObjects: []
-    m_AddedGameObjects: []
-    m_AddedComponents: []
-  m_SourcePrefab: {fileID: 100100000, guid: 845dcf3fceef847748adb1c4078ac491, type: 3}
 --- !u!1660057539 &9223372036854775807
 SceneRoots:
   m_ObjectHideFlags: 0
@@ -5321,6 +5300,6 @@ SceneRoots:
   - {fileID: 216580616}
   - {fileID: 86768398}
   - {fileID: 842680982}
-  - {fileID: 1595919170206676193}
   - {fileID: 1251935902}
   - {fileID: 545334271}
+  - {fileID: 812878837}
diff --git a/Assets/Scripts/Creature/Minion/MobSpawner.cs b/Assets/Scripts/Creature/Minion/MobSpawner.cs
index 15211c380..3cd364f38 100644
--- a/Assets/Scripts/Creature/Minion/MobSpawner.cs
+++ b/Assets/Scripts/Creature/Minion/MobSpawner.cs
@@ -27,8 +27,13 @@ private IEnumerator SpawnSlimeRoutine()
             while (true)
             {
                 yield return new WaitForSeconds(MOB_SPAWN_DELAY);
-                T mob = _mobPool.GetObject();
-                SpawnMob(mob);
+
+
+                T mob = _mobPool.GetInactiveObject();
+                if (mob != null)
+                {
+                    SpawnMob(mob);
+                }
             }
         }
 
diff --git a/Assets/Scripts/Creature/Minion/Slime/FireflySlime.cs b/Assets/Scripts/Creature/Minion/Slime/FireflySlime.cs
index 2c1109bc1..05d93d1e3 100644
--- a/Assets/Scripts/Creature/Minion/Slime/FireflySlime.cs
+++ b/Assets/Scripts/Creature/Minion/Slime/FireflySlime.cs
@@ -24,8 +24,13 @@ protected override void Initialize()
             _light.SetActive(_isOn);
             base.Initialize();
         }
-        
-        
+
+        public override void StartMob()
+        {
+            _isOn = true;
+            _light.SetActive(_isOn);
+            _slimeAnimator.SetSprites(_spriteOnVersion);
+        }
 
         public override void OnAttacked(float damage)
         {
@@ -70,5 +75,6 @@ public override int GetWeight()
         public class SlimeMeleeAttackState : MeleeAttackState {}
         public class DieState : SlimeDieState { }
         public class MoveState : SlimeMoveState { }
+        public class SlimeIdleState : IdleState { }
     }
 }
diff --git a/Assets/Scripts/Creature/Minion/Slime/Slime.cs b/Assets/Scripts/Creature/Minion/Slime/Slime.cs
index c8347992c..809da14af 100644
--- a/Assets/Scripts/Creature/Minion/Slime/Slime.cs
+++ b/Assets/Scripts/Creature/Minion/Slime/Slime.cs
@@ -11,5 +11,6 @@ public class  SlimeRangedAttackState : RangedAttackState { }
         public class SlimeMeleeAttackState : MeleeAttackState {}
         public class DieState : SlimeDieState { }
         public class MoveState : SlimeMoveState { }
+        public class SlimeIdleState : IdleState { }
     }
 }
diff --git a/Assets/Scripts/Creature/Minion/Slime/SlimeBase.cs b/Assets/Scripts/Creature/Minion/Slime/SlimeBase.cs
index 9380a828d..106de6533 100644
--- a/Assets/Scripts/Creature/Minion/Slime/SlimeBase.cs
+++ b/Assets/Scripts/Creature/Minion/Slime/SlimeBase.cs
@@ -1,3 +1,4 @@
+using System;
 using System.Collections;
 using System.Collections.Generic;
 using playerCharacter;
@@ -18,7 +19,7 @@ public abstract class SlimeBase : Creature
         protected  IPathFinder _pathFinder;
         protected  SlimeAnimator _slimeAnimator;
         [SerializeField] protected  SlimeSprites sprites;
-        protected  Coroutine _faceToPlayerCoroutine;
+        protected Coroutine _faceToPlayerCoroutine;
         
         public override void StartMob() { }
         
@@ -52,7 +53,7 @@ public IEnumerator FaceToPlayer()
                 yield return null;
             }
         }
-        
+
         protected virtual void Start()
         {
             Initialize();
@@ -94,6 +95,33 @@ public abstract class SlimeState : BaseState
             protected SlimeBase Slime => creature as SlimeBase;
         }
 
+        public class IdleState : SlimeState
+        {
+            public IdleState() { }
+            public IdleState(Creature creature)
+            {
+                this.creature = creature;
+            }
+            public override int GetWeight()
+            {
+                return 0;
+            }
+
+            public override IEnumerator StateCoroutine()
+            {
+                Slime._slimeAnimator.AsyncPlay(SlimeAnimator.AnimationType.IDLE, true);
+                while (true)
+                {
+                    Transform target = Slime._detector.DetectTarget()?.transform;
+                    if (target != null)
+                    {
+                        creature.ChangeState(new SlimeMoveState(Slime));
+                    }
+                    yield return new WaitForSeconds(1f);
+                }
+            }
+        }
+
         public abstract class RangedAttackState : SlimeState
         {
             public override int GetWeight()
@@ -125,7 +153,8 @@ public override IEnumerator StateCoroutine()
             {
                 Slime._slimeAnimator.AsyncPlay(SlimeAnimator.AnimationType.MELEE_ATTACK);
                 yield return new WaitForSeconds(SlimeAnimator.ANIMATION_DELTA_TIME * 2);
-                PlayerCharacter.Instance.TakeDamage(creature.damage);
+                if (creature.DistanceToPlayer <= creature.MeleeAttackRange)   
+                    PlayerCharacter.Instance.TakeDamage(creature.damage);
                 yield return new WaitForSeconds(SlimeAnimator.ANIMATION_DELTA_TIME);
                 Slime._slimeAnimator.AsyncPlay(SlimeAnimator.AnimationType.IDLE, true);
                 yield return new WaitForSeconds(1);
@@ -135,6 +164,13 @@ public override IEnumerator StateCoroutine()
     
         public class SlimeMoveState : SlimeState
         {
+            public SlimeMoveState(SlimeBase slime)
+            {
+                creature = slime;
+                
+            }
+            protected SlimeMoveState() { }
+
             public override int GetWeight()
             {
                 return creature.DistanceToPlayer > creature.MeleeAttackRange ? 5 : 0;
@@ -150,7 +186,15 @@ public override IEnumerator StateCoroutine()
                 {
                     timer += Time.deltaTime;
                     yield return null;
-                    creature.TrackPath(Slime._pathFinder.FindPath(creature.transform.position, PlayerCharacter.Instance.transform.position));
+                    Transform target = Slime._detector.DetectTarget()?.transform;
+                    if (target)
+                    {
+                        Slime.TrackPath(Slime._pathFinder.FindPath(creature.transform.position, target.position));
+                    }
+                    else
+                    {
+                        creature.ChangeState(new IdleState(creature));
+                    }
                 }
             
                 Slime._slimeAnimator.Stop();
diff --git a/Assets/Scripts/Creature/Minion/Spawner/SlimeSpawner.cs b/Assets/Scripts/Creature/Minion/Spawner/SlimeSpawner.cs
index 828e18514..47d649d55 100644
--- a/Assets/Scripts/Creature/Minion/Spawner/SlimeSpawner.cs
+++ b/Assets/Scripts/Creature/Minion/Spawner/SlimeSpawner.cs
@@ -1,8 +1,5 @@
 namespace Creature.Minion.Slime
 {
-    public class SlimeSpawner : MobSpawner<Slime>
-    {
-        
-    }
+    public class SlimeSpawner : MobSpawner<Slime> { }
 }
 
diff --git a/Assets/Scripts/System/Game/DynamicGameObjectCreator.cs b/Assets/Scripts/System/Game/DynamicGameObjectCreator.cs
index 26049a6ff..905554568 100644
--- a/Assets/Scripts/System/Game/DynamicGameObjectCreator.cs
+++ b/Assets/Scripts/System/Game/DynamicGameObjectCreator.cs
@@ -10,7 +10,7 @@ public class DynamicGameObjectCreator : MonoBehaviour
 
         private void Start()
         {
-            bool condition1 = false;
+            bool condition1 = true;
             bool condition2 = false;
 
             if (!string.IsNullOrEmpty(_conditionKey1))
diff --git a/Assets/Scripts/Util/ObjectCreator/ObjectPool.cs b/Assets/Scripts/Util/ObjectCreator/ObjectPool.cs
index ac74e7d8c..2a0341161 100644
--- a/Assets/Scripts/Util/ObjectCreator/ObjectPool.cs
+++ b/Assets/Scripts/Util/ObjectCreator/ObjectPool.cs
@@ -19,21 +19,17 @@ public ObjectPool(int numOfObjects, GameObject prefab)
 
         public T GetObject()
         {
-            foreach (T obj in _pool)
-            {
-                if (!obj.gameObject.activeInHierarchy)
-                {
-                    return obj;
-                }
-            }
+            T result = GetInactiveObject();
+            if (result != null)
+                return result;
 
             GameObject newGameObject = Object.Instantiate(_prefab);
-            T newObj = newGameObject.GetComponent<T>();
+            result = newGameObject.GetComponent<T>();
             
-            _pool.Add(newObj);
-            return newObj;
+            _pool.Add(result);
+            return result;
         }
-
+        
         public T GetObject(Vector3 position)
         {
             T obj = GetObject();
@@ -48,6 +44,18 @@ public T GetObject(Transform transform)
             return obj;
         }
         
+        public T GetInactiveObject()
+        {
+            foreach (T obj in _pool)
+            {
+                if (!obj.gameObject.activeInHierarchy)
+                {
+                    return obj;
+                }
+            }
+            return null;
+        }
+        
         public void ReturnObject(T obj)
         {
             obj.gameObject.SetActive(false);


Reviews:
user: login: Monolong
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-10T02:49:45Z
user: login: Monolong
body: 고생했어~
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-10T02:58:09Z
user: login: dev-yunseong
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-11T07:34:46Z

Review comments:
diff_hunk: @@ -48,6 +44,18 @@ public T GetObject(Transform transform)
             return obj;
         }
         
+        public T GetObjectNotMake()
path: Assets/Scripts/Util/ObjectCreator/ObjectPool.cs
user: login: Monolong
body: 이거 뭐하는 메소드야? 오브젝트 찾아오는데 안 만들어진 오브젝트 반환하는 건가?
이름이 쪼끔 직관적이지 않은 듯?
챗지피티에 물어봤는데 GetInactiveObject()는 어때?
created_at: 2025-03-10T02:49:45Z
author_association: CONTRIBUTOR
diff_hunk: @@ -48,6 +44,18 @@ public T GetObject(Transform transform)
             return obj;
         }
         
+        public T GetObjectNotMake()
path: Assets/Scripts/Util/ObjectCreator/ObjectPool.cs
user: login: dev-yunseong
body: 넵 인정입니다 수정하겠습니다

created_at: 2025-03-11T07:34:46Z
author_association: CONTRIBUTOR

PR comments:
user: login: Monolong
created_at: 2025-03-10T02:54:57Z
body: **피드백**
![image](https://github.com/user-attachments/assets/bb04f6fe-7d29-496a-8b42-043a92e059f0)
구하고 마을 갔을 때 꼬마애가 앞을 보면서 옆을 이동하는 데 조금 어색한듯

그 전에 삭제 하도록 하겠습니다.
현진이 형이 쓰는 npc object를 사용하는게 맞을듯

전투 튜토리얼 할 때 공격 - 스킬 공격 - 둥지 파괴 이렇게 들어가던데
스페이스로 안넘겨도 공격 했으면 다음 꺼 보여줄 수는 없나?
아 전체화면으로 나오는  팝업으로 바꾸면 어차피 멈추니까 상관없을 수도 있을 듯
author_association: CONTRIBUTOR
user: login: Monolong
created_at: 2025-03-10T02:57:55Z
body: ![image](https://github.com/user-attachments/assets/3bd07013-79d8-46cc-b320-c96e745f7512)
안개 색깔이 검은색이면 좀 이상하려나?

그게 더 어울릴 거 같네요 그 현진이 형한테 회의때 변경 가능하냐고 물어봐야겟다
author_association: CONTRIBUTOR
user: login: dev-yunseong
created_at: 2025-03-11T07:38:45Z
body: > 고생했어~

감사합니다~
author_association: CONTRIBUTOR