1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using UnityEngine ;
4
+ using static KeepCoding . ComponentPool ;
5
+ using static Localization ;
6
+ using Connection = IRCConnection ;
7
+ using KTInput = KTInputManager ;
8
+ using KTMod = ModManager ;
9
+ using KTPlayer = Assets . Scripts . Settings . PlayerSettingsManager ;
10
+ using KTScene = SceneManager ;
11
+ using KTModSourceEnum = Assets . Scripts . Mods . ModInfo . ModSourceEnum ;
4
12
5
13
namespace KeepCoding
6
14
{
@@ -80,19 +88,19 @@ public static class IRCConnection
80
88
/// Sends a message to the chat.
81
89
/// </value>
82
90
/// <remarks>Arguments: <c>message</c>.</remarks>
83
- public static Action < string > SendMessage => message => Debug . Log ( $ "Sending message to chat: { message } " ) ;
91
+ public static Action < string > SendMessage => Connection . SendMessage ;
84
92
85
93
/// <value>
86
94
/// Sends a message to the chat.
87
95
/// </value>
88
96
/// <remarks>Arguments: <c>message</c> and <c>args</c>.</remarks>
89
- public static Action < string , object [ ] > SendMessageFormat => ( message , args ) => Debug . Log ( $ "Sending message to chat: { message . Form ( args ) } " ) ;
90
-
97
+ public static Action < string , object [ ] > SendMessageFormat => Connection . SendMessageFormat ;
98
+
91
99
/// <value>
92
100
/// Whispers a message to a person.
93
101
/// </value>
94
102
/// <remarks>Arguments: <c>userNickName</c>, <c>message</c>, and <c>args</c>.</remarks>
95
- public static Action < string , string , object [ ] > SendWhisper => ( userNickName , message , args ) => Debug . Log ( $ "Whispering message to user { userNickName } : { message . Form ( args ) } " ) ;
103
+ public static Action < string , string , object [ ] > SendWhisper => Connection . SendWhisper ;
96
104
}
97
105
98
106
/// <summary>
@@ -108,7 +116,7 @@ public static class KTInputManager
108
116
/// <value>
109
117
/// The current way the game is being controlled.
110
118
/// </value>
111
- public static ControlType CurrentControlType => ControlType . Mouse ;
119
+ public static ControlType CurrentControlType => ( ControlType ) KTInput . Instance . CurrentControlType ;
112
120
}
113
121
114
122
/// <summary>
@@ -119,27 +127,58 @@ public static class Mission
119
127
/// <value>
120
128
/// Determines whether or not all pacing events are enabled.
121
129
/// </value>
122
- public static bool IsPacingEvents => false ;
130
+ public static bool IsPacingEvents => KTScene . Instance . GameplayState . Mission . PacingEventsEnabled ;
123
131
124
132
/// <value>
125
133
/// The description as it appears in the bomb binder.
126
134
/// </value>
127
- public static string Description => "Everybody has to start somewhere. Let's just hope it doesn't end here too. \n \n Make sure your experts have the manual and are ready to help." ;
135
+ public static string Description => GetLocalizedString ( KTScene . Instance . GameplayState . Mission . DescriptionTerm ) ;
128
136
129
137
/// <value>
130
138
/// The mission name as it appears in the bomb binder.
131
139
/// </value>
132
- public static string DisplayName => "The First Bomb" ;
140
+ public static string DisplayName => GetLocalizedString ( KTScene . Instance . GameplayState . Mission . DisplayNameTerm ) ;
133
141
134
142
/// <value>
135
143
/// The ID of the mission.
136
144
/// </value>
137
- public static string ID => "firsttime" ;
145
+ public static string ID => KTScene . Instance . GameplayState . Mission . ID ;
138
146
139
147
/// <value>
140
148
/// Gets the generator setting of the mission.
141
149
/// </value>
142
- public static GeneratorSetting GeneratorSetting => new GeneratorSetting ( ) ;
150
+ public static GeneratorSetting GeneratorSetting
151
+ {
152
+ get
153
+ {
154
+ var setting = KTScene . Instance . GameplayState . Mission . GeneratorSetting ;
155
+
156
+ var list = new List < ComponentPool > ( ) ;
157
+
158
+ foreach ( var pool in setting . ComponentPools )
159
+ {
160
+ var types = new List < ComponentTypeEnum > ( ) ;
161
+
162
+ foreach ( var type in pool . ComponentTypes )
163
+ types . Add ( ( ComponentTypeEnum ) type ) ;
164
+
165
+ list . Add ( new ComponentPool (
166
+ pool . Count ,
167
+ ( ComponentSource ) pool . AllowedSources ,
168
+ ( SpecialComponentTypeEnum ) pool . SpecialComponentType ,
169
+ pool . ModTypes ,
170
+ types ) ) ;
171
+ }
172
+
173
+ return new GeneratorSetting (
174
+ setting . FrontFaceOnly ,
175
+ setting . OptionalWidgetCount ,
176
+ setting . NumStrikes ,
177
+ setting . TimeBeforeNeedyActivation ,
178
+ setting . TimeLimit ,
179
+ list ) ;
180
+ }
181
+ }
143
182
}
144
183
145
184
/// <summary>
@@ -150,17 +189,17 @@ public static class ModManager
150
189
/// <value>
151
190
/// Gets all of the disabled mod paths.
152
191
/// </value>
153
- public static Func < List < string > > GetDisabledModPaths => ( ) => new List < string > ( ) ;
192
+ public static Func < List < string > > GetDisabledModPaths => KTMod . Instance . GetDisabledModPaths ;
154
193
155
194
/// <value>
156
195
/// Gets all of the mod paths within the <see cref="ModSourceEnum"/> constraint.
157
196
/// </value>
158
- public static Func < ModSourceEnum , List < string > > GetAllModPathsFromSource => source => new List < string > ( ) ;
197
+ public static Func < ModSourceEnum , List < string > > GetAllModPathsFromSource => source => KTMod . Instance . GetAllModPathsFromSource ( ( KTModSourceEnum ) source ) ;
159
198
160
199
/// <value>
161
200
/// Gets all of the enabled mod paths within the <see cref="ModSourceEnum"/> constraint.
162
201
/// </value>
163
- public static Func < ModSourceEnum , List < string > > GetEnabledModPaths => source => new List < string > ( ) ;
202
+ public static Func < ModSourceEnum , List < string > > GetEnabledModPaths => source => KTMod . Instance . GetEnabledModPaths ( ( KTModSourceEnum ) source ) ;
164
203
}
165
204
166
205
/// <summary>
@@ -171,108 +210,118 @@ public static class PlayerSettings
171
210
/// <value>
172
211
/// Determines if vertical tilting is flipped or not.
173
212
/// </value>
174
- public static bool InvertTiltControls => false ;
213
+ public static bool InvertTiltControls => KTPlayer . Instance . PlayerSettings . InvertTiltControls ;
175
214
176
215
/// <value>
177
216
/// Determines if the option to lock the mouse to the window is enabled.
178
217
/// </value>
179
- public static bool LockMouseToWindow => false ;
218
+ public static bool LockMouseToWindow => KTPlayer . Instance . PlayerSettings . LockMouseToWindow ;
180
219
181
220
/// <value>
182
221
/// Determines if the option to show the leaderboards from the pamphlet.
183
222
/// </value>
184
- public static bool ShowLeaderBoards => true ;
223
+ public static bool ShowLeaderBoards => KTPlayer . Instance . PlayerSettings . ShowLeaderBoards ;
185
224
186
225
/// <value>
187
226
/// Determines if the option to show the rotation of the User Interface is enabled.
188
227
/// </value>
189
- public static bool ShowRotationUI => true ;
228
+ public static bool ShowRotationUI => KTPlayer . Instance . PlayerSettings . ShowRotationUI ;
190
229
191
230
/// <value>
192
231
/// Determines if the option to show scanlines is enabled.
193
232
/// </value>
194
- public static bool ShowScanline => true ;
233
+ public static bool ShowScanline => KTPlayer . Instance . PlayerSettings . ShowScanline ;
195
234
196
235
/// <value>
197
236
/// Determines if the option to skip the title screen is enabled.
198
237
/// </value>
199
- public static bool SkipTitleScreen => false ;
238
+ public static bool SkipTitleScreen => KTPlayer . Instance . PlayerSettings . SkipTitleScreen ;
200
239
201
240
/// <value>
202
241
/// Determines if the VR or regular controllers vibrate.
203
242
/// </value>
204
- public static bool RumbleEnabled => false ;
243
+ public static bool RumbleEnabled => KTPlayer . Instance . PlayerSettings . RumbleEnabled ;
205
244
206
245
/// <value>
207
246
/// Determines if the touchpad controls are inverted.
208
247
/// </value>
209
- public static bool TouchpadInvert => false ;
248
+ public static bool TouchpadInvert => KTPlayer . Instance . PlayerSettings . TouchpadInvert ;
210
249
211
250
/// <value>
212
251
/// Determines if the option to always use mods is enabled.
213
252
/// </value>
214
- public static bool UseModsAlways => false ;
253
+ public static bool UseModsAlways => KTPlayer . Instance . PlayerSettings . UseModsAlways ;
215
254
216
255
/// <value>
217
256
/// Determines if the option to use parallel/simultaneous mod loading is enabled.
218
257
/// </value>
219
- public static bool UseParallelModLoading => false ;
258
+ public static bool UseParallelModLoading => KTPlayer . Instance . PlayerSettings . UseParallelModLoading ;
220
259
221
260
/// <value>
222
261
/// Determines if VR mode is requested.
223
262
/// </value>
224
- public static bool VRModeRequested => true ;
263
+ public static bool VRModeRequested => KTPlayer . Instance . PlayerSettings . VRModeRequested ;
225
264
226
265
/// <value>
227
266
/// The intensity of anti-aliasing currently on the game. Ranges 0 to 8.
228
267
/// </value>
229
- public static int AntiAliasing => 8 ;
268
+ public static int AntiAliasing => KTPlayer . Instance . PlayerSettings . AntiAliasing ;
230
269
231
270
/// <value>
232
271
/// The current music volume from the dossier menu. Ranges 0 to 100.
233
272
/// </value>
234
- public static int MusicVolume => 100 ;
273
+ public static int MusicVolume => KTPlayer . Instance . PlayerSettings . MusicVolume ;
235
274
236
275
/// <value>
237
276
/// The current sound effects volume from the dosssier menu. Ranges 0 to 100.
238
277
/// </value>
239
- public static int SFXVolume => 100 ;
278
+ public static int SFXVolume => KTPlayer . Instance . PlayerSettings . SFXVolume ;
240
279
241
280
/// <value>
242
281
/// Determines if VSync is on or off.
243
282
/// </value>
244
- public static int VSync => 1 ;
283
+ public static int VSync => KTPlayer . Instance . PlayerSettings . VSync ;
245
284
246
285
/// <value>
247
286
/// The current language code.
248
287
/// </value>
249
- public static string LanguageCode => "en" ;
288
+ public static string LanguageCode => KTPlayer . Instance . PlayerSettings . LanguageCode ;
250
289
}
251
290
252
291
/// <value>
253
292
/// Adds an amount of strikes on the bomb.
254
293
/// </value>
255
- public static Action < GameObject , int > AddStrikes => ( gameObject , amount ) => Logger . Self ( $ "Adding the bomb's strike count with { amount } .") ;
294
+ public static Action < GameObject , int > AddStrikes => ( gameObject , amount ) =>
295
+ {
296
+ Logger . Self ( $ "Adding the bomb's strike count with { amount } .") ;
297
+ var bomb = ( Bomb ) Bomb ( gameObject ) ;
298
+ bomb . StrikeIndicator . StrikeCount = bomb . NumStrikes += amount ;
299
+ } ;
256
300
257
301
/// <value>
258
302
/// Sets an amount of strikes on the bomb.
259
303
/// </value>
260
- public static Action < GameObject , int > SetStrikes => ( gameObject , amount ) => Logger . Self ( $ "Setting the bomb's strike count to { amount } .") ;
304
+ public static Action < GameObject , int > SetStrikes => ( gameObject , amount ) =>
305
+ {
306
+ Logger . Self ( $ "Setting the bomb's strike count to { amount } .") ;
307
+ var bomb = ( Bomb ) Bomb ( gameObject ) ;
308
+ bomb . StrikeIndicator . StrikeCount = bomb . NumStrikes = amount ;
309
+ } ;
261
310
262
311
/// <value>
263
312
/// Gets the game's internal bomb component, not to be mistaken with <see cref="KMBomb"/>.
264
313
/// </value>
265
314
/// <remarks>
266
315
/// To prevent a reference to the game, the type is boxed in <see cref="object"/>. You can cast it to Bomb or <see cref="MonoBehaviour"/> type to restore its functionality.
267
316
/// </remarks>
268
- public static Func < GameObject , object > Bomb => gameObject => null ;
317
+ public static Func < GameObject , object > Bomb => gameObject => gameObject . GetComponentInParent ( typeof ( Bomb ) ) ;
269
318
270
319
/// <value>
271
320
/// Gets the game's internal timer component.
272
321
/// </value>
273
322
/// <remarks>
274
323
/// To prevent a reference to the game, the type is boxed in <see cref="object"/>. You can cast it to TimerComponent or <see cref="MonoBehaviour"/> type to restore its functionality.
275
324
/// </remarks>
276
- public static Func < GameObject , object > Timer => gameObject => null ;
325
+ public static Func < GameObject , object > Timer => gameObject => ( ( Bomb ) Bomb ( gameObject ) ) . GetTimer ( ) ;
277
326
}
278
327
}
0 commit comments