-
Notifications
You must be signed in to change notification settings - Fork 19
/
TheVision_SolanumVisionResponse.cs
181 lines (153 loc) · 9.22 KB
/
TheVision_SolanumVisionResponse.cs
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
using UnityEngine;
using NewHorizons.Utility;
namespace TheVision.CustomProps
{
public class TheVision_SolanumVisionResponse : MonoBehaviour
{
public NomaiConversationManager _nomaiConversationManager;
public SolanumAnimController _solanumAnimController;
public NomaiWallText solanumVisionResponse;
public OWAudioSource PlayerHeadsetAudioSource;
public static readonly int MAX_WAIT_FRAMES = 20;
// Main
public void WriteMessage()
{
// one-time code that runs after waitFrames are up
_solanumAnimController.OnWriteResponse += (int unused) =>
{
_nomaiConversationManager._activeResponseText = solanumVisionResponse;
_nomaiConversationManager._pendingResponseText = null;
solanumVisionResponse.Show();
};
_solanumAnimController.StartWritingMessage();
TheVision.Instance.ModHelper.Events.Unity.RunWhen(() => !_solanumAnimController.isStartingWrite && !solanumVisionResponse.IsAnimationPlaying(), () =>
{
_solanumAnimController.StopWritingMessage(gestureToText: false);
_nomaiConversationManager._state = NomaiConversationManager.State.WatchingSky;
_solanumAnimController.StopWatchingPlayer();
// Spawning SolanumCopies and Signals on vision response
TheVision.Instance.ModHelper.Events.Unity.FireInNUpdates(TheVision.Instance.SpawnOnVisionEnd, 10);
});
}
public void OnVisionStart()
{
if (_nomaiConversationManager._activeResponseText != null) _nomaiConversationManager._activeResponseText.Hide();
_nomaiConversationManager._activeResponseText = null;
_nomaiConversationManager._pendingResponseText = solanumVisionResponse;
// Disabling music on QM once the vision is showed
Locator.GetAstroObject(AstroObject.Name.QuantumMoon).transform.Find("Volumes/AudioVolume_QM_Music").gameObject.SetActive(false);
}
public void OnVisionEnd()
{
PlayerData.SetPersistentCondition("SOLANUM_PROJECTION_COMPLETE", true);
// flicker
var effect = Locator.GetActiveCamera().transform.Find("ScreenEffects/LightFlickerEffectBubble").GetComponent<LightFlickerController>();
effect.FlickerOffAndOn(offDuration: 6.8f, onDuration: 1f);
PlayerData.SetPersistentCondition("MET_SOLANUM", true);
PlayerData.SetPersistentCondition("MET_PRISONER", true);
TheVision.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() =>
{
// sfx
PlayWindSound();
PlayStartSound();
Invoke("PlayImpactSound", 0.5f);
Invoke("PlayShockSound", 0.5f);
PlayFadeInSound();
});
TheVision.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() =>
{
/* No such parameters in New Horizons v1.8.0
// wh parameters
var whiteHoleOptions = Locator.GetAstroObject(AstroObject.Name.QuantumMoon).transform.Find("Sector_QuantumMoon/WhiteHole/AmbientLight").GetComponent<Light>();
whiteHoleOptions.color = new Color(1, 1, 2, 1);
whiteHoleOptions.range = 30;
whiteHoleOptions.intensity = 3;
whiteHoleOptions.enabled = true;
*/
// QM White Hole parameters
var qmWhiteHole = Locator.GetAstroObject(AstroObject.Name.QuantumMoon).transform.Find("Sector_QuantumMoon/WhiteHole").gameObject;
var qmWhiteHoleLock = qmWhiteHole.AddComponent<MemoryUplinkTrigger>()._lockOnTransform;
qmWhiteHole.SetActive(true);
Invoke("ApplyForce", 0.5f);
Invoke("SolanumAnim", 10f);
Invoke("SolanumAnim2", 25f);
// Camera lock on target
var cameraFixedPosition = Locator.GetPlayerTransform().gameObject.GetComponent<PlayerLockOnTargeting>();
cameraFixedPosition.LockOn(qmWhiteHole.transform, 20f, true, 3f);
TheVision.Instance.ModHelper.Console.WriteLine("PROJECTION COMPLETE");
Locator.GetShipLogManager().RevealFact("SOLANUM_PROJECTION_COMPLETE");
_nomaiConversationManager.enabled = false;
//TheVision.Instance.ModHelper.Events.Unity.FireInNUpdates(WriteMessage, MAX_WAIT_FRAMES);
WriteMessage();
});
}
// Utility
public void ApplyForce()
{
SearchUtilities.Find("Player_Body/PlayerCamera").GetComponent<PlayerCameraEffectController>().ApplyExposureDamage();
// Pushing out force for flat version and VR version
var applyForce = Locator.GetPlayerTransform().gameObject.GetComponent<OWRigidbody>();
Vector3 pushBack = new Vector3(0f, 0.0062f, -0.008f);
applyForce.AddLocalImpulse(pushBack);
}
public void SolanumAnim()
{
var SolanumAnim = SearchUtilities.Find("QuantumMoon_Body/Sector_QuantumMoon/State_EYE/Interactables_EYEState/ConversationPivot/Character_NOM_Solanum/Nomai_ANIM_SkyWatching_Idle").GetComponent<SolanumAnimController>();
SolanumAnim.StartWatchingPlayer();
SolanumAnim.StartConversation();
}
public void SolanumAnim2()
{
var SolanumAnim = SearchUtilities.Find("QuantumMoon_Body/Sector_QuantumMoon/State_EYE/Interactables_EYEState/ConversationPivot/Character_NOM_Solanum/Nomai_ANIM_SkyWatching_Idle").GetComponent<SolanumAnimController>();
SolanumAnim.EndConversation();
SolanumAnim.StopWatchingPlayer();
}
// Sounds and music
public void PlayWindSound()
{
// SFX on QM after Solanumptojection
PlayerHeadsetAudioSource = Locator.GetAstroObject(AstroObject.Name.QuantumMoon).transform.Find("Sector_QuantumMoon/State_EYE/Interactables_EYEState/ConversationPivot/Character_NOM_Solanum").gameObject.AddComponent<OWAudioSource>();
PlayerHeadsetAudioSource.enabled = true;
PlayerHeadsetAudioSource.AssignAudioLibraryClip(AudioType.EyeVortex_LP); // shattering sound 2428 //2697 - station flicker // 2252 - EyeVortex_LP wind // 2005 - electric core
PlayerHeadsetAudioSource.SetMaxVolume(maxVolume: 0.5f);
PlayerHeadsetAudioSource.GetComponent<AudioSource>().playOnAwake = false;
PlayerHeadsetAudioSource.Play();
}
public void PlayFadeInSound()
{
PlayerHeadsetAudioSource = Locator.GetAstroObject(AstroObject.Name.QuantumMoon).transform.Find("Sector_QuantumMoon/State_EYE/Interactables_EYEState/ConversationPivot/NomaiConversation").gameObject.AddComponent<OWAudioSource>();
PlayerHeadsetAudioSource.enabled = true;
PlayerHeadsetAudioSource.AssignAudioLibraryClip(AudioType.MemoryUplink_Start); // shattering sound 2428 //2697 - station flicker // 2252 -wind // 2005 - electric core // 2460 MemoryUplink_Start
PlayerHeadsetAudioSource.SetMaxVolume(maxVolume: 1f);
PlayerHeadsetAudioSource.GetComponent<AudioSource>().playOnAwake = false;
PlayerHeadsetAudioSource.PlayDelayed(4.5f);
}
public void PlayImpactSound()
{
PlayerHeadsetAudioSource = SearchUtilities.Find("Player_Body").gameObject.AddComponent<OWAudioSource>();
PlayerHeadsetAudioSource.enabled = true;
PlayerHeadsetAudioSource.AssignAudioLibraryClip(AudioType.ImpactHighSpeed); // StationFlicker_RW = 2696// 2005 - electric core //502 -ToolFlashlightFlicker
PlayerHeadsetAudioSource.SetMaxVolume(maxVolume: 1f);
PlayerHeadsetAudioSource.GetComponent<AudioSource>().playOnAwake = false;
PlayerHeadsetAudioSource.PlayOneShot();
}
public void PlayShockSound()
{
PlayerHeadsetAudioSource = SearchUtilities.Find("Player_Body").gameObject.AddComponent<OWAudioSource>();
PlayerHeadsetAudioSource.enabled = true;
PlayerHeadsetAudioSource.AssignAudioLibraryClip(AudioType.ElectricShock); // StationFlicker_RW = 2696// 2005 - electric core //502 -ToolFlashlightFlicker
PlayerHeadsetAudioSource.SetMaxVolume(maxVolume: 1f);
PlayerHeadsetAudioSource.GetComponent<AudioSource>().playOnAwake = false;
PlayerHeadsetAudioSource.PlayOneShot();
}
public void PlayStartSound()
{
PlayerHeadsetAudioSource = Locator.GetAstroObject(AstroObject.Name.QuantumMoon).transform.Find("Sector_QuantumMoon/State_EYE").gameObject.AddComponent<OWAudioSource>();
PlayerHeadsetAudioSource.enabled = true;
PlayerHeadsetAudioSource.AssignAudioLibraryClip(AudioType.GD_IslandLiftedByTornado); // shattering sound 2428 //2697 - station flicker // 2252 -wind // 2005 - electric core // 2011 - GD_IslandLiftedByTornado
PlayerHeadsetAudioSource.SetMaxVolume(maxVolume: 1f);
PlayerHeadsetAudioSource.GetComponent<AudioSource>().playOnAwake = false;
PlayerHeadsetAudioSource.PlayOneShot();
}
}
}