Skip to content

Commit 24fe01c

Browse files
committed
Revert "Merge branch 'editoronly' into main"
This reverts commit 95576cb, reversing changes made to a89063a.
1 parent 95576cb commit 24fe01c

File tree

3 files changed

+105
-34
lines changed

3 files changed

+105
-34
lines changed

KeepCoding.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
</PropertyGroup>
4040

4141
<ItemGroup>
42+
<Reference Include="Assembly-CSharp">
43+
<HintPath>D:\Steam\steamapps\common\Keep Talking and Nobody Explodes\ktane_Data\Managed\Assembly-CSharp.dll</HintPath>
44+
<Private>false</Private>
45+
<Aliases></Aliases>
46+
</Reference>
4247
<Reference Include="KMFramework">
4348
<HintPath>D:\ktanemodkit-master\Assets\Plugins\Managed\KMFramework.dll</HintPath>
4449
<Private>false</Private>
@@ -52,6 +57,14 @@
5257
<Reference Include="UnityEditor">
5358
<HintPath>..\..\..\..\..\Program Files\Editor\Data\Managed\UnityEditor.dll</HintPath>
5459
<Private>false</Private>
60+
</Reference>
61+
<Reference Include="TweaksAssembly">
62+
<HintPath>D:\Steam\steamapps\workshop\content\341800\1366808675\TweaksAssembly.dll</HintPath>
63+
<Private>false</Private>
64+
</Reference>
65+
<Reference Include="TwitchPlaysAssembly">
66+
<HintPath>D:\Steam\steamapps\workshop\content\341800\1711408527\TwitchPlaysAssembly.dll</HintPath>
67+
<Private>false</Private>
5568
</Reference>
5669
<Reference Include="UnityEngine">
5770
<HintPath>..\..\..\..\..\Program Files\Editor\Data\Managed\UnityEngine.dll</HintPath>

Source/MonoBehaviours/ModuleScript.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ public void Solve(params string[] logs)
216216
if (IsSolved)
217217
return;
218218

219+
if (!IsEditor && _hasException)
220+
Game.AddStrikes(gameObject, -_strikes);
221+
219222
LogMultiple(logs);
220223

221224
IsSolved = true;
@@ -437,7 +440,13 @@ private void OnException(string condition, string stackTrace, LogType type)
437440

438441
private void TimerTick()
439442
{
440-
var timer = Game.Timer(gameObject);
443+
var timer = (TimerComponent)Game.Timer(gameObject);
444+
445+
timer.TimerTick += (elapsed, remaining) =>
446+
{
447+
TimeLeft = remaining;
448+
OnTimerTick();
449+
};
441450
}
442451

443452
private void TimerTickEditor(in KMBombInfo bombInfo)

Source/Statics/Game.cs

Lines changed: 82 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
using System;
22
using System.Collections.Generic;
33
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;
412

513
namespace KeepCoding
614
{
@@ -80,19 +88,19 @@ public static class IRCConnection
8088
/// Sends a message to the chat.
8189
/// </value>
8290
/// <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;
8492

8593
/// <value>
8694
/// Sends a message to the chat.
8795
/// </value>
8896
/// <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+
9199
/// <value>
92100
/// Whispers a message to a person.
93101
/// </value>
94102
/// <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;
96104
}
97105

98106
/// <summary>
@@ -108,7 +116,7 @@ public static class KTInputManager
108116
/// <value>
109117
/// The current way the game is being controlled.
110118
/// </value>
111-
public static ControlType CurrentControlType => ControlType.Mouse;
119+
public static ControlType CurrentControlType => (ControlType)KTInput.Instance.CurrentControlType;
112120
}
113121

114122
/// <summary>
@@ -119,27 +127,58 @@ public static class Mission
119127
/// <value>
120128
/// Determines whether or not all pacing events are enabled.
121129
/// </value>
122-
public static bool IsPacingEvents => false;
130+
public static bool IsPacingEvents => KTScene.Instance.GameplayState.Mission.PacingEventsEnabled;
123131

124132
/// <value>
125133
/// The description as it appears in the bomb binder.
126134
/// </value>
127-
public static string Description => "Everybody has to start somewhere. Let's just hope it doesn't end here too.\n\nMake sure your experts have the manual and are ready to help.";
135+
public static string Description => GetLocalizedString(KTScene.Instance.GameplayState.Mission.DescriptionTerm);
128136

129137
/// <value>
130138
/// The mission name as it appears in the bomb binder.
131139
/// </value>
132-
public static string DisplayName => "The First Bomb";
140+
public static string DisplayName => GetLocalizedString(KTScene.Instance.GameplayState.Mission.DisplayNameTerm);
133141

134142
/// <value>
135143
/// The ID of the mission.
136144
/// </value>
137-
public static string ID => "firsttime";
145+
public static string ID => KTScene.Instance.GameplayState.Mission.ID;
138146

139147
/// <value>
140148
/// Gets the generator setting of the mission.
141149
/// </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+
}
143182
}
144183

145184
/// <summary>
@@ -150,17 +189,17 @@ public static class ModManager
150189
/// <value>
151190
/// Gets all of the disabled mod paths.
152191
/// </value>
153-
public static Func<List<string>> GetDisabledModPaths => () => new List<string>();
192+
public static Func<List<string>> GetDisabledModPaths => KTMod.Instance.GetDisabledModPaths;
154193

155194
/// <value>
156195
/// Gets all of the mod paths within the <see cref="ModSourceEnum"/> constraint.
157196
/// </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);
159198

160199
/// <value>
161200
/// Gets all of the enabled mod paths within the <see cref="ModSourceEnum"/> constraint.
162201
/// </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);
164203
}
165204

166205
/// <summary>
@@ -171,108 +210,118 @@ public static class PlayerSettings
171210
/// <value>
172211
/// Determines if vertical tilting is flipped or not.
173212
/// </value>
174-
public static bool InvertTiltControls => false;
213+
public static bool InvertTiltControls => KTPlayer.Instance.PlayerSettings.InvertTiltControls;
175214

176215
/// <value>
177216
/// Determines if the option to lock the mouse to the window is enabled.
178217
/// </value>
179-
public static bool LockMouseToWindow => false;
218+
public static bool LockMouseToWindow => KTPlayer.Instance.PlayerSettings.LockMouseToWindow;
180219

181220
/// <value>
182221
/// Determines if the option to show the leaderboards from the pamphlet.
183222
/// </value>
184-
public static bool ShowLeaderBoards => true;
223+
public static bool ShowLeaderBoards => KTPlayer.Instance.PlayerSettings.ShowLeaderBoards;
185224

186225
/// <value>
187226
/// Determines if the option to show the rotation of the User Interface is enabled.
188227
/// </value>
189-
public static bool ShowRotationUI => true;
228+
public static bool ShowRotationUI => KTPlayer.Instance.PlayerSettings.ShowRotationUI;
190229

191230
/// <value>
192231
/// Determines if the option to show scanlines is enabled.
193232
/// </value>
194-
public static bool ShowScanline => true;
233+
public static bool ShowScanline => KTPlayer.Instance.PlayerSettings.ShowScanline;
195234

196235
/// <value>
197236
/// Determines if the option to skip the title screen is enabled.
198237
/// </value>
199-
public static bool SkipTitleScreen => false;
238+
public static bool SkipTitleScreen => KTPlayer.Instance.PlayerSettings.SkipTitleScreen;
200239

201240
/// <value>
202241
/// Determines if the VR or regular controllers vibrate.
203242
/// </value>
204-
public static bool RumbleEnabled => false;
243+
public static bool RumbleEnabled => KTPlayer.Instance.PlayerSettings.RumbleEnabled;
205244

206245
/// <value>
207246
/// Determines if the touchpad controls are inverted.
208247
/// </value>
209-
public static bool TouchpadInvert => false;
248+
public static bool TouchpadInvert => KTPlayer.Instance.PlayerSettings.TouchpadInvert;
210249

211250
/// <value>
212251
/// Determines if the option to always use mods is enabled.
213252
/// </value>
214-
public static bool UseModsAlways => false;
253+
public static bool UseModsAlways => KTPlayer.Instance.PlayerSettings.UseModsAlways;
215254

216255
/// <value>
217256
/// Determines if the option to use parallel/simultaneous mod loading is enabled.
218257
/// </value>
219-
public static bool UseParallelModLoading => false;
258+
public static bool UseParallelModLoading => KTPlayer.Instance.PlayerSettings.UseParallelModLoading;
220259

221260
/// <value>
222261
/// Determines if VR mode is requested.
223262
/// </value>
224-
public static bool VRModeRequested => true;
263+
public static bool VRModeRequested => KTPlayer.Instance.PlayerSettings.VRModeRequested;
225264

226265
/// <value>
227266
/// The intensity of anti-aliasing currently on the game. Ranges 0 to 8.
228267
/// </value>
229-
public static int AntiAliasing => 8;
268+
public static int AntiAliasing => KTPlayer.Instance.PlayerSettings.AntiAliasing;
230269

231270
/// <value>
232271
/// The current music volume from the dossier menu. Ranges 0 to 100.
233272
/// </value>
234-
public static int MusicVolume => 100;
273+
public static int MusicVolume => KTPlayer.Instance.PlayerSettings.MusicVolume;
235274

236275
/// <value>
237276
/// The current sound effects volume from the dosssier menu. Ranges 0 to 100.
238277
/// </value>
239-
public static int SFXVolume => 100;
278+
public static int SFXVolume => KTPlayer.Instance.PlayerSettings.SFXVolume;
240279

241280
/// <value>
242281
/// Determines if VSync is on or off.
243282
/// </value>
244-
public static int VSync => 1;
283+
public static int VSync => KTPlayer.Instance.PlayerSettings.VSync;
245284

246285
/// <value>
247286
/// The current language code.
248287
/// </value>
249-
public static string LanguageCode => "en";
288+
public static string LanguageCode => KTPlayer.Instance.PlayerSettings.LanguageCode;
250289
}
251290

252291
/// <value>
253292
/// Adds an amount of strikes on the bomb.
254293
/// </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+
};
256300

257301
/// <value>
258302
/// Sets an amount of strikes on the bomb.
259303
/// </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+
};
261310

262311
/// <value>
263312
/// Gets the game's internal bomb component, not to be mistaken with <see cref="KMBomb"/>.
264313
/// </value>
265314
/// <remarks>
266315
/// 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.
267316
/// </remarks>
268-
public static Func<GameObject, object> Bomb => gameObject => null;
317+
public static Func<GameObject, object> Bomb => gameObject => gameObject.GetComponentInParent(typeof(Bomb));
269318

270319
/// <value>
271320
/// Gets the game's internal timer component.
272321
/// </value>
273322
/// <remarks>
274323
/// 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.
275324
/// </remarks>
276-
public static Func<GameObject, object> Timer => gameObject => null;
325+
public static Func<GameObject, object> Timer => gameObject => ((Bomb)Bomb(gameObject)).GetTimer();
277326
}
278327
}

0 commit comments

Comments
 (0)