Skip to content

Commit

Permalink
Sample mods disabled (#20)
Browse files Browse the repository at this point in the history
* warping in debug mode. 
* all sample mods are disabled
  • Loading branch information
amazingalek authored Dec 23, 2019
1 parent a0f7d73 commit b0b85e6
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 15 deletions.
84 changes: 75 additions & 9 deletions OWML.SampleMods/OWML.EnableDebugMode/EnableDebugMode.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,97 @@
using OWML.Common;
using OWML.Events;
using UnityEngine;

namespace OWML.EnableDebugMode
{
public class EnableDebugMode : ModBehaviour
{
private int _renderValue;
private bool _isStarted;
private PlayerSpawner _playerSpawner;

private void Start()
{
ModHelper.Console.WriteLine($"In {nameof(EnableDebugMode)}!");
ModHelper.HarmonyHelper.EmptyMethod<DebugInputManager>("Awake");
ModHelper.Events.AddEvent<PlayerSpawner>(Common.Events.AfterAwake);
ModHelper.Events.OnEvent += OnEvent;
}

private int _renderValue;
private void OnEvent(MonoBehaviour behaviour, Common.Events ev)
{
if (behaviour.GetType() == typeof(PlayerSpawner) && ev == Common.Events.AfterAwake)
{
_playerSpawner = (PlayerSpawner)behaviour;
_isStarted = true;
}
}

private void Update()
{
if (!_isStarted)
{
return;
}

if (Input.GetKeyDown(DebugKeyCode.cycleGUIMode))
{
ModHelper.Console.WriteLine("F1 pressed!");
_renderValue++;
if (_renderValue >= 8)
{
_renderValue = 0;
}
ModHelper.Console.WriteLine("_renderValue: " + _renderValue);
typeof(GUIMode).GetAnyField("_renderMode").SetValue(null, _renderValue);
CycleGUIMode();
}

if (Input.GetKeyDown(DebugKeyCode.cometWarp))
{
WarpTo(SpawnLocation.Comet);
}
if (Input.GetKeyDown(DebugKeyCode.hourglassTwinsWarp))
{
WarpTo(SpawnLocation.HourglassTwin_1);
}
if (Input.GetKeyDown(DebugKeyCode.homePlanetWarp))
{
WarpTo(SpawnLocation.TimberHearth);
}
if (Input.GetKeyDown(DebugKeyCode.brittleHollowWarp))
{
WarpTo(SpawnLocation.BrittleHollow);
}
if (Input.GetKeyDown(DebugKeyCode.gasGiantWarp))
{
WarpTo(SpawnLocation.GasGiant);
}
if (Input.GetKeyDown(DebugKeyCode.darkBrambleWarp))
{
WarpTo(SpawnLocation.DarkBramble);
}
if (Input.GetKeyDown(DebugKeyCode.shipWarp))
{
WarpTo(SpawnLocation.Ship);
}
if (Input.GetKeyDown(DebugKeyCode.quantumWarp))
{
WarpTo(SpawnLocation.QuantumMoon);
}
if (Input.GetKeyDown(DebugKeyCode.moonWarp))
{
WarpTo(SpawnLocation.LunarLookout);
}
}

private void CycleGUIMode()
{
_renderValue++;
if (_renderValue >= 8)
{
_renderValue = 0;
}
ModHelper.Console.WriteLine("Render value: " + _renderValue);
typeof(GUIMode).GetAnyField("_renderMode").SetValue(null, _renderValue);
}

private void WarpTo(SpawnLocation location)
{
ModHelper.Console.WriteLine($"Warping to {location}!");
_playerSpawner.DebugWarp(_playerSpawner.GetSpawnPoint(location));
}

}
Expand Down
4 changes: 2 additions & 2 deletions OWML.SampleMods/OWML.EnableDebugMode/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "Alek",
"name": "EnableDebugMode",
"uniqueName": "Alek.EnableDebugMode",
"version": "0.1",
"version": "0.2",
"owmlVersion": "0.2.1",
"enabled": true
"enabled": false
}
2 changes: 1 addition & 1 deletion OWML.SampleMods/OWML.LoadCustomAssets/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"uniqueName": "Alek.LoadCustomAssets",
"version": "0.2",
"owmlVersion": "0.2.1",
"enabled": true
"enabled": false
}
6 changes: 3 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ OWML does the following:

## Sample mods

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

|Sample mod|Description|
|----------|-----------|
|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.|
|OWML.TestMod|This blows up the sun as soon as the player wakes up. Disabled by default (in manifest.json).|
|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.|
|OWML.TestMod|Blows up the sun as soon as the player wakes up.|
|OWML.LoadCustomAssets|Showcases loading of custom 3D objects and audio. Click the left mouse button to shoot rubber ducks.|

## For players
Expand Down

0 comments on commit b0b85e6

Please sign in to comment.