|
4 | 4 | public class Main : BaseUnityPlugin
|
5 | 5 | {
|
6 | 6 | // MOD INFO
|
7 |
| - private const string modName = "Alterra Weaponry"; |
8 |
| - private const string modGUID = "com.VELD.AlterraWeaponry"; |
9 |
| - private const string modVers = "1.0.3"; |
| 7 | + internal const string modName = "Alterra Weaponry"; |
| 8 | + internal const string modGUID = "com.VELD.AlterraWeaponry"; |
| 9 | + internal const string modVers = "1.0.5"; |
| 10 | + internal const string modLongVers = "1.0.5.1"; |
10 | 11 |
|
11 | 12 | // BepInEx/Harmony/Unity
|
12 | 13 | private static readonly Harmony harmony = new(modGUID);
|
13 | 14 | public static ManualLogSource logger;
|
14 | 15 |
|
15 | 16 | // STORY GOALS
|
16 |
| -#if BZ |
17 |
| - internal static StoryGoal AWPresentationGoal = new("Log_PDA_Goal_AWPresentation", Story.GoalType.PDA, 0f) { playInCreative = true, playInCinematics = false, delay = 8f }; |
18 |
| -#endif |
| 17 | + internal static StoryGoal AWPresentationGoal; |
| 18 | + internal static ItemGoal AWFirstLethal; |
19 | 19 |
|
20 |
| - public static readonly AssetBundle assets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "alterraweaponry.assets")); |
| 20 | + public static ResourcesCacheManager AssetsCache { get; private set; } |
21 | 21 |
|
| 22 | + internal static Options Options { get; } = OptionsPanelHandler.RegisterModOptions<Options>(); |
22 | 23 |
|
23 | 24 | private void Awake()
|
24 | 25 | {
|
25 | 26 | logger = Logger;
|
| 27 | + try |
| 28 | + { |
| 29 | + AssetsCache = ResourcesCacheManager.LoadResources(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "alterraweaponry.assets")); |
| 30 | + } |
| 31 | + catch (Exception ex) |
| 32 | + { |
| 33 | + logger.LogFatal($"Fatal error occured: Unable to load resources to cache.\n{ex}"); |
| 34 | + } |
26 | 35 | logger.LogInfo($"{modName} {modVers} started patching.");
|
27 | 36 | harmony.PatchAll();
|
28 | 37 | logger.LogInfo($"{modName} {modVers} harmony patched.");
|
29 |
| - |
30 |
| - Coal coal = new(); |
31 |
| - BlackPowder blackPowder = new(); |
32 |
| - ExplosiveTorpedo explosiveTorpedo = new(); |
33 |
| - PrawnSelfDefenseModule prawnSelfDefenseModule = new(); |
34 |
| - |
35 |
| - coal.Patch(); |
36 |
| - blackPowder.Patch(); |
37 |
| - explosiveTorpedo.Patch(); |
38 |
| - prawnSelfDefenseModule.Patch(); |
39 |
| - |
40 |
| - logger.LogInfo($"{modName} {modVers} items registered."); |
41 |
| - |
42 |
| - LanguagesHandler.LanguagePatch(); |
| 38 | + LanguagesHandler.GlobalPatch(); |
43 | 39 | logger.LogInfo($"{modName} {modVers} languages lines patched.");
|
44 |
| - |
45 |
| - RegisterPDAEncyEntries(); |
| 40 | + GlobalInitializer.PatchPDAEncyEntries(); |
46 | 41 | logger.LogInfo($"{modName} {modVers} PDA encyclopedia entries registered.");
|
47 |
| - RegisterPDALogs(); |
| 42 | + GlobalInitializer.PatchGoals(); |
| 43 | + logger.LogInfo($"{modName} {modVers} PDA goals initialized."); |
| 44 | + GlobalInitializer.PatchPDALogs(); |
48 | 45 | logger.LogInfo($"{modName} {modVers} PDA logs registered.");
|
49 | 46 |
|
50 |
| - } |
51 |
| - |
52 |
| - private void Update() |
53 |
| - { |
54 |
| - if(UnityInput.Current.GetKeyDown(KeyCode.P)) |
| 47 | + ModDatabankHandler.RegisterMod(new ModDatabankHandler.ModData() |
55 | 48 | {
|
56 |
| - logger.LogInfo("Should play audio."); |
57 |
| - GameObject cameraObject = Camera.main.gameObject; |
58 |
| - AudioSource audioSource = cameraObject.GetComponent<AudioSource>(); |
59 |
| - audioSource.clip = Main.assets.LoadAsset<AudioClip>("AudioClip.PWAPresentation"); |
60 |
| - audioSource.Play(); |
61 |
| - logger.LogInfo("Should have played an audio."); |
62 |
| - } |
63 |
| - } |
64 |
| - |
65 |
| - private static void RegisterPDALogs() |
66 |
| - { |
67 |
| - // Load audio clips |
68 |
| - logger.LogInfo($"{modName} {modVers} Loading audio clips..."); |
69 |
| -#if BZ |
70 |
| - AudioClip AWPresentationAudioClip = assets.LoadAsset<AudioClip>("pwa_presentation_message"); |
71 |
| - AudioClip AWFirstLethalAudioClip = assets.LoadAsset<AudioClip>("first_lethal_message"); |
72 |
| -#endif |
73 |
| - logger.LogInfo($"{modName} {modVers} Audio clips loaded!"); |
74 |
| - |
75 |
| - logger.LogInfo($"{modName} {modVers} Registering PDA Logs..."); |
76 |
| - |
77 |
| - // Presentation PDA log "Hello xenoworker 91802..." |
78 |
| -#if BZ |
79 |
| - CustomSoundHandler.RegisterCustomSound(AWPresentationGoal.key, AWPresentationAudioClip, AudioUtils.BusPaths.PDAVoice); |
80 |
| - FMODAsset presentation = ScriptableObject.CreateInstance<FMODAsset>(); |
81 |
| - presentation.path = AWPresentationGoal.key; |
82 |
| - presentation.id = AWPresentationGoal.key; |
83 |
| - PDALogHandler.AddCustomEntry( |
84 |
| - AWPresentationGoal.key, |
85 |
| - "Subtitles_AWPresentation", |
86 |
| - sound: presentation |
87 |
| - ); |
88 |
| -#endif |
| 49 | + guid = modGUID, |
| 50 | + version = modVers, |
| 51 | + image = AssetsCache.GetAsset<Texture2D>("ModLogo"), |
| 52 | + name = "Alterra Weaponry", |
| 53 | + desc = "Since the return of the Aurora survivor, Alterra secretely added a few weapons blueprints.\nThis information is kept confidential, by using the PWA (Personal Weaponry Assistance) you agree the Alterra's NDA (Non-Divulgation Accord)." |
| 54 | + }); |
89 | 55 |
|
90 |
| -// First lethal weapon PDA log "A lethal weapon have been detected into your inventory..." |
91 |
| -#if BZ |
92 |
| - CustomSoundHandler.RegisterCustomSound("Log_PDA_Goal_FirstLethal", AWFirstLethalAudioClip, AudioUtils.BusPaths.PDAVoice); |
93 |
| - FMODAsset firstLethal = ScriptableObject.CreateInstance<FMODAsset>(); |
94 |
| - firstLethal.path = "Log_PDA_Goal_FirstLethal"; |
95 |
| - firstLethal.id = "Log_PDA_Goal_FirstLethal"; |
96 |
| - PDALogHandler.AddCustomEntry( |
97 |
| - "Log_PDA_Goal_FirstLethal", |
98 |
| - "Subtitles_AWFirstLethal", |
99 |
| - sound: firstLethal |
100 |
| - ); |
101 |
| -#endif |
102 |
| - } |
| 56 | + Coal coal = new(); |
| 57 | + coal.Patch(); |
103 | 58 |
|
104 |
| - private static void RegisterPDAEncyEntries() |
105 |
| - { |
106 |
| - // Register AWModInfo entry |
107 |
| - PDAEncyclopediaHandler.AddCustomEntry(new() |
108 |
| - { |
109 |
| - key = "AWModInfo", |
110 |
| - kind = PDAEncyclopedia.EntryData.Kind.Encyclopedia, |
111 |
| - nodes = new[] { "Meta" }, |
112 |
| - path = "Meta", |
113 |
| - unlocked = true, |
114 |
| - }); |
| 59 | + BlackPowder blackPowder = new(); |
| 60 | + blackPowder.Patch(); |
115 | 61 |
|
116 |
| - // Explosive torpedoes entry |
117 |
| -#if BZ |
118 |
| - PDAEncyclopediaHandler.AddCustomEntry(new() |
119 |
| - { |
120 |
| - key = "ExplosiveTorpedo", |
121 |
| - kind = PDAEncyclopedia.EntryData.Kind.Encyclopedia, |
122 |
| - nodes = new[] { "Tech", "Weaponry" }, |
123 |
| - path = "Tech/Weaponry", |
124 |
| - unlocked = false, |
125 |
| - }); |
126 |
| -#endif |
| 62 | + ExplosiveTorpedo explosiveTorpedo = new(); |
| 63 | + explosiveTorpedo.Patch(); |
127 | 64 |
|
128 |
| - // Prawn laser arm entry |
129 |
| -#if BZ |
130 |
| - PDAEncyclopediaHandler.AddCustomEntry(new() |
131 |
| - { |
132 |
| - key = "PrawnLaserArm", |
133 |
| - kind = PDAEncyclopedia.EntryData.Kind.Encyclopedia, |
134 |
| - nodes = new[] { "Tech", "Weaponry" }, |
135 |
| - path = "Tech/Weaponry", |
136 |
| - unlocked = false, |
137 |
| - }); |
138 |
| -#endif |
| 65 | + PrawnSelfDefenseModule prawnSelfDefenseModule = new(); |
| 66 | + prawnSelfDefenseModule.Patch(); |
139 | 67 |
|
140 |
| - // Prawn Self Defense Module |
141 |
| -#if BZ |
142 |
| - PDAEncyclopediaHandler.AddCustomEntry(new() |
143 |
| - { |
144 |
| - key = "PrawnDefensePerimeter", |
145 |
| - kind = PDAEncyclopedia.EntryData.Kind.Encyclopedia, |
146 |
| - nodes = new[] { "Tech", "Modules" }, |
147 |
| - path = "Tech/Modules", |
148 |
| - unlocked = false, |
149 |
| - }); |
150 |
| -#endif |
| 68 | + logger.LogInfo($"{modName} {modVers} items registered."); |
151 | 69 | }
|
| 70 | + |
152 | 71 | }
|
0 commit comments