-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFifthModJam.cs
More file actions
128 lines (113 loc) · 6.19 KB
/
Copy pathFifthModJam.cs
File metadata and controls
128 lines (113 loc) · 6.19 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
using HarmonyLib;
using NewHorizons.Utility;
using OWML.Common;
using OWML.ModHelper;
using System.Collections;
using System.Reflection;
using UnityEngine;
namespace FifthModJam
{
public class FifthModJam : ModBehaviour
{
public static INewHorizons NewHorizonsAPI { get; private set; }
public static IAchievements AchievementsAPI { get; private set; }
private static FifthModJam _instance;
public static FifthModJam Instance
{
get
{
if (_instance == null) _instance = FindObjectOfType<FifthModJam>();
return _instance;
}
}
public void Start()
{
// Starting here, you'll have access to OWML's mod helper.
ModHelper.Console.WriteLine($"My mod {nameof(FifthModJam)} is loaded!", MessageType.Success);
// Get the New Horizons API and load configs
NewHorizonsAPI = ModHelper.Interaction.TryGetModApi<INewHorizons>("xen.NewHorizons");
NewHorizonsAPI.LoadConfigs(this);
// Get the Achievement+ API
AchievementsAPI = ModHelper.Interaction.TryGetModApi<IAchievements>("xen.AchievementTracker");
if(AchievementsAPI != null)
{
RegisterAllAchievements();
}
// Harmony patching
new Harmony("TheSignalJammers.FifthModJam").PatchAll(Assembly.GetExecutingAssembly());
// Example of accessing game code.
NewHorizonsAPI.GetStarSystemLoadedEvent().AddListener(OnCompleteSceneLoad);
}
public void OnCompleteSceneLoad(string newScene)
{
if (newScene != "Jam5") return;
ModHelper.Console.WriteLine("Loaded into jam5 system!", MessageType.Success);
DioramaWarpManager.Spawn();
MuseumDisablerManager.Spawn();
LanguageManager.Spawn();
TowerCollapseManager.Spawn();
ScoutCodeManager.Spawn();
TotemCodePromptManager.Spawn();
PingCampfireFlameManager.Spawn();
ItemsReturnedAchievementManager.Spawn();
FrequencyUpgradeManager.Spawn();
}
public bool IsInJamFiveSystem()
{
return NewHorizonsAPI.GetCurrentStarSystem() == "Jam5";
}
// UTILS
public static void WriteLine(string text, MessageType messageType = MessageType.Message)
{
Instance.ModHelper.Console.WriteLine(text, messageType);
}
public static void WriteLineObjectOrComponentNotFound(string classLocation, string pathAttempted, string componentName = null)
{
string componentAddonStr = componentName == null ? "" : $" or component ({componentName})"; // Add this snippet if the component name is specified
FifthModJam.WriteLine($"[{classLocation}] Could not find an object{componentAddonStr}. Check path attempted: {pathAttempted}", MessageType.Error);
}
public static void WriteLineReady(string classLocation)
{
FifthModJam.WriteLine($"[{classLocation}] Ready", MessageType.Debug);
}
// COROUTINES
public IEnumerator CloseEyesCoroutine()
{
OWInput.ChangeInputMode(InputMode.None); // stop player input for a while
var cameraEffectController = FindObjectOfType<PlayerCameraEffectController>();
cameraEffectController.CloseEyes(Constants.BLINK_CLOSE_ANIM_TIME);
yield return new WaitForSeconds(Constants.BLINK_CLOSE_ANIM_TIME); // waits until animation stops to proceed to next line
GlobalMessenger.FireEvent("PlayerBlink"); // fires an event for the player blinking
}
public IEnumerator OpenEyesCoroutine()
{
var cameraEffectController = FindObjectOfType<PlayerCameraEffectController>();
cameraEffectController.OpenEyes(Constants.BLINK_OPEN_ANIM_TIME, false);
yield return new WaitForSeconds(Constants.BLINK_OPEN_ANIM_TIME); // Waits until animation stops to proceed to next line
OWInput.ChangeInputMode(InputMode.Character); // gives the player back input
}
// ACHIEVEMENTS
public void RegisterAllAchievements()
{
// Story Achievements (fully secret)
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_SHRUNK_HATCHLING, secret: true, this);
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_WHATS_THIS_BUTTON, secret: true, this);
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_KNOCK_KNOCK, secret: true, this);
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_THE_COSMIC_CURATORS, secret: true, this);
// Other Achievements (not hidden)
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_ERNESTO, secret: false, this);
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_YOU_FOUND_US, secret: false, this);
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_SCOUTLESS, secret: false, this);
// Other Achievements (semi-hidden, with hint)
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_ONE_RING_TO_RULE_THEM_ALL, secret: false, showDescriptionNotAchieved: true, this);
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_INFINITY_STICK, secret: false, showDescriptionNotAchieved: true, this);
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_MIXED_PASSWORDS, secret: false, showDescriptionNotAchieved: true, this);
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_WALK_THE_PLANK, secret: false, showDescriptionNotAchieved: true, this);
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_ITS_ONLY_A_MODEL, secret: false, showDescriptionNotAchieved: true, this);
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_ALL_IN_ITS_PLACE, secret: false, showDescriptionNotAchieved: true, this);
AchievementsAPI.RegisterAchievement(Constants.ACHIEVEMENT_FAT_SHAMING, secret: false, showDescriptionNotAchieved: true, this);
// Add translations
AchievementsAPI.RegisterTranslationsFromFiles(this, "translations/");
}
}
}