Skip to content

Commit b0b85e6

Browse files
authored
Sample mods disabled (#20)
* warping in debug mode. * all sample mods are disabled
1 parent a0f7d73 commit b0b85e6

File tree

4 files changed

+81
-15
lines changed

4 files changed

+81
-15
lines changed

OWML.SampleMods/OWML.EnableDebugMode/EnableDebugMode.cs

Lines changed: 75 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,97 @@
11
using OWML.Common;
22
using OWML.Events;
3+
using UnityEngine;
34

45
namespace OWML.EnableDebugMode
56
{
67
public class EnableDebugMode : ModBehaviour
78
{
9+
private int _renderValue;
10+
private bool _isStarted;
11+
private PlayerSpawner _playerSpawner;
12+
813
private void Start()
914
{
1015
ModHelper.Console.WriteLine($"In {nameof(EnableDebugMode)}!");
1116
ModHelper.HarmonyHelper.EmptyMethod<DebugInputManager>("Awake");
17+
ModHelper.Events.AddEvent<PlayerSpawner>(Common.Events.AfterAwake);
18+
ModHelper.Events.OnEvent += OnEvent;
1219
}
1320

14-
private int _renderValue;
21+
private void OnEvent(MonoBehaviour behaviour, Common.Events ev)
22+
{
23+
if (behaviour.GetType() == typeof(PlayerSpawner) && ev == Common.Events.AfterAwake)
24+
{
25+
_playerSpawner = (PlayerSpawner)behaviour;
26+
_isStarted = true;
27+
}
28+
}
1529

1630
private void Update()
1731
{
32+
if (!_isStarted)
33+
{
34+
return;
35+
}
36+
1837
if (Input.GetKeyDown(DebugKeyCode.cycleGUIMode))
1938
{
20-
ModHelper.Console.WriteLine("F1 pressed!");
21-
_renderValue++;
22-
if (_renderValue >= 8)
23-
{
24-
_renderValue = 0;
25-
}
26-
ModHelper.Console.WriteLine("_renderValue: " + _renderValue);
27-
typeof(GUIMode).GetAnyField("_renderMode").SetValue(null, _renderValue);
39+
CycleGUIMode();
40+
}
41+
42+
if (Input.GetKeyDown(DebugKeyCode.cometWarp))
43+
{
44+
WarpTo(SpawnLocation.Comet);
45+
}
46+
if (Input.GetKeyDown(DebugKeyCode.hourglassTwinsWarp))
47+
{
48+
WarpTo(SpawnLocation.HourglassTwin_1);
49+
}
50+
if (Input.GetKeyDown(DebugKeyCode.homePlanetWarp))
51+
{
52+
WarpTo(SpawnLocation.TimberHearth);
53+
}
54+
if (Input.GetKeyDown(DebugKeyCode.brittleHollowWarp))
55+
{
56+
WarpTo(SpawnLocation.BrittleHollow);
2857
}
58+
if (Input.GetKeyDown(DebugKeyCode.gasGiantWarp))
59+
{
60+
WarpTo(SpawnLocation.GasGiant);
61+
}
62+
if (Input.GetKeyDown(DebugKeyCode.darkBrambleWarp))
63+
{
64+
WarpTo(SpawnLocation.DarkBramble);
65+
}
66+
if (Input.GetKeyDown(DebugKeyCode.shipWarp))
67+
{
68+
WarpTo(SpawnLocation.Ship);
69+
}
70+
if (Input.GetKeyDown(DebugKeyCode.quantumWarp))
71+
{
72+
WarpTo(SpawnLocation.QuantumMoon);
73+
}
74+
if (Input.GetKeyDown(DebugKeyCode.moonWarp))
75+
{
76+
WarpTo(SpawnLocation.LunarLookout);
77+
}
78+
}
79+
80+
private void CycleGUIMode()
81+
{
82+
_renderValue++;
83+
if (_renderValue >= 8)
84+
{
85+
_renderValue = 0;
86+
}
87+
ModHelper.Console.WriteLine("Render value: " + _renderValue);
88+
typeof(GUIMode).GetAnyField("_renderMode").SetValue(null, _renderValue);
89+
}
90+
91+
private void WarpTo(SpawnLocation location)
92+
{
93+
ModHelper.Console.WriteLine($"Warping to {location}!");
94+
_playerSpawner.DebugWarp(_playerSpawner.GetSpawnPoint(location));
2995
}
3096

3197
}

OWML.SampleMods/OWML.EnableDebugMode/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"author": "Alek",
44
"name": "EnableDebugMode",
55
"uniqueName": "Alek.EnableDebugMode",
6-
"version": "0.1",
6+
"version": "0.2",
77
"owmlVersion": "0.2.1",
8-
"enabled": true
8+
"enabled": false
99
}

OWML.SampleMods/OWML.LoadCustomAssets/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"uniqueName": "Alek.LoadCustomAssets",
66
"version": "0.2",
77
"owmlVersion": "0.2.1",
8-
"enabled": true
8+
"enabled": false
99
}

Readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ OWML does the following:
1414

1515
## Sample mods
1616

17-
Some mods are included as examples/inspiration:
17+
Some mods are included as examples/inspiration. **They are all disabled by default. Enable in manifest.json.**
1818

1919
|Sample mod|Description|
2020
|----------|-----------|
21-
|OWML.EnableDebugMode|This enables the built-in debug mode in the game. It allows you to do some fun stuff by pressing certain keys, such as exploding the sun with the End key, and cycling through various debug UIs with F1.|
22-
|OWML.TestMod|This blows up the sun as soon as the player wakes up. Disabled by default (in manifest.json).|
21+
|OWML.EnableDebugMode|Enables the built-in debug mode in the game. Highlights: cycle through debug UIs with F1, warp to planets with the number keys, and explode the sun with the End key.|
22+
|OWML.TestMod|Blows up the sun as soon as the player wakes up.|
2323
|OWML.LoadCustomAssets|Showcases loading of custom 3D objects and audio. Click the left mouse button to shoot rubber ducks.|
2424

2525
## For players

0 commit comments

Comments
 (0)