-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModBehaviour.cs
More file actions
45 lines (38 loc) · 1.46 KB
/
ModBehaviour.cs
File metadata and controls
45 lines (38 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Duckov.Modding;
using HarmonyLib;
using UnityEngine;
namespace MyJumpMod
{
public class ModBehaviour : Duckov.Modding.ModBehaviour
{
private Harmony _harmony;
protected override void OnAfterSetup()
{
// 하모니 아이디를 본인만의 것으로 설정
_harmony = new Harmony("com.cherry.jumpmod");
_harmony.PatchAll();
// 레벨 로딩 완료 후 실행될 이벤트 등록
LevelManager.OnAfterLevelInitialized += InstallJumpMod;
Debug.Log("[MyJumpMod] 점프 모드가 활성화되었습니다.");
}
private void InstallJumpMod()
{
var mainCharacter = LevelManager.Instance.MainCharacter;
if (mainCharacter != null)
{
// 캐릭터에게 컨트롤러가 없으면 추가
if (mainCharacter.GetComponent<CharacterJumpController>() == null)
{
mainCharacter.gameObject.AddComponent<CharacterJumpController>();
Debug.Log("[MyJumpMod] 점프 기능을 캐릭터에게 장착했습니다. (Z키)");
}
}
}
protected override void OnBeforeDeactivate()
{
LevelManager.OnAfterLevelInitialized -= InstallJumpMod;
_harmony?.UnpatchAll(_harmony.Id);
Debug.Log("[MyJumpMod] 점프 모드가 해제되었습니다.");
}
}
}