Skip to content

Commit

Permalink
Surrounded editor stuff in #ifs so assembly is loaded
Browse files Browse the repository at this point in the history
And fixed up the manifest and loader name
  • Loading branch information
nrgill28 committed Apr 5, 2021
1 parent 24de9d4 commit 4b47c57
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 15 deletions.
5 changes: 5 additions & 0 deletions WurstMod/MappingComponents/ComponentProxy.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using UnityEngine;

#if UNITY_EDITOR
using WurstMod.UnityEditor;
#endif

namespace WurstMod.MappingComponents
{
Expand All @@ -17,9 +20,11 @@ public abstract class ComponentProxy : MonoBehaviour
/// </summary>
public virtual void InitializeComponent() { }

#if UNITY_EDITOR
/// <summary>
/// This is called before the map is exported. Put one-time calculations and component validations here.
/// </summary>
public virtual void OnExport(ExportErrors err) { }
#endif
}
}
6 changes: 5 additions & 1 deletion WurstMod/MappingComponents/Generic/CustomScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using Valve.VR.InteractionSystem;
using WurstMod.Runtime;
using WurstMod.Shared;
#if UNITY_EDITOR
using WurstMod.UnityEditor;
#endif

namespace WurstMod.MappingComponents.Generic
{
Expand All @@ -23,11 +25,13 @@ public class CustomScene : ComponentProxy

public int PlayerIFF = 0;

#if UNITY_EDITOR
public override void OnExport(ExportErrors err)
{
Skybox = RenderSettings.skybox;
}

#endif

public override void InitializeComponent()
{
// This component is responsible for resolving many of the global/builtin things about a level.
Expand Down
5 changes: 4 additions & 1 deletion WurstMod/MappingComponents/Generic/PlayerTrigger.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using UnityEngine;
using UnityEngine.Events;
#if UNITY_EDITOR
using WurstMod.UnityEditor;

#endif
namespace WurstMod.MappingComponents.Generic
{
[RequireComponent(typeof(Collider))]
Expand All @@ -14,11 +15,13 @@ public class PlayerTrigger : ComponentProxy

private void OnTriggerExit(Collider other) => Exit.Invoke();

#if UNITY_EDITOR
public override void OnExport(ExportErrors err)
{
// We needs this to be a trigger on the ColOnlyHead layer.
GetComponent<Collider>().isTrigger = true;
gameObject.layer = LayerMask.NameToLayer("ColOnlyHead");
}
#endif
}
}
4 changes: 4 additions & 0 deletions WurstMod/MappingComponents/Generic/SosigSpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using UnityEngine;
using WurstMod.Runtime;
using WurstMod.Shared;
#if UNITY_EDITOR
using WurstMod.UnityEditor;
#endif
using Random = UnityEngine.Random;

namespace WurstMod.MappingComponents.Generic
Expand Down Expand Up @@ -131,13 +133,15 @@ private IEnumerator SpawnCoroutine()
}
}

#if UNITY_EDITOR
public override void OnExport(ExportErrors err)
{
if (SosigTypes.Length == 0) err.AddError("Sosig Spawner has no types to spawn!", this);
if (SpawnDelay < 0) err.AddError("Sosig Spawner cannot have a spawn delay of less than zero", this);
if (SpawnInterval < 0) err.AddError("Sosig Spawner cannot have a spawn interval of less than zero", this);
if (SpawnCount < 0) err.AddError("Sosig Spawner cannot have a spawn count of less than zero", this);
}
#endif

private void OnDrawGizmos()
{
Expand Down
5 changes: 5 additions & 0 deletions WurstMod/MappingComponents/Sandbox/PointableButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
using UnityEngine;
using UnityEngine.UI;
using WurstMod.Runtime;

#if UNITY_EDITOR
using WurstMod.UnityEditor;
#endif

namespace WurstMod.MappingComponents.Sandbox
{
Expand Down Expand Up @@ -44,12 +47,14 @@ public override void InitializeComponent()
Destroy(this);
}

#if UNITY_EDITOR
public override void OnExport(ExportErrors err)
{
// Set the collider's size
var collider = GetComponent<BoxCollider>();
var size = GetComponent<RectTransform>().sizeDelta;
collider.size = new Vector3(size.x, size.y, 1);
}
#endif
}
}
5 changes: 5 additions & 0 deletions WurstMod/MappingComponents/TakeAndHold/TNH_HoldPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
using UnityEngine;
using WurstMod.Runtime;
using WurstMod.Shared;

#if UNITY_EDITOR
using WurstMod.UnityEditor;
#endif

namespace WurstMod.MappingComponents.TakeAndHold
{
Expand Down Expand Up @@ -101,6 +104,7 @@ private object Resolve_AttackVector(AttackVector proxy)
return real;
}

#if UNITY_EDITOR
public override void OnExport(ExportErrors err)
{
// Make sure the nav blockers are disabled
Expand All @@ -112,5 +116,6 @@ public override void OnExport(ExportErrors err)
err.AddError("Holds must have at least 9 Sosig Defense Spawn Points.", this);
}
}
#endif
}
}
4 changes: 2 additions & 2 deletions WurstMod/Runtime/Entrypoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public Entrypoint()

private void StagesOnSetup(SetupStage stage)
{
stage.SharedAssetLoaders[Source, "Level"] = SharedAssetLoader;
stage.SharedAssetLoaders[Source, "level"] = LevelLoader;
}

private void SharedAssetLoader(Stage stage, Mod mod, IHandle handle)
private void LevelLoader(Stage stage, Mod mod, IHandle handle)
{
// If the config has disabled loading the default included levels, return
if (!loadDebugLevels.Value && mod.Info.Guid == "wurstmod")
Expand Down
5 changes: 5 additions & 0 deletions WurstMod/Runtime/LegacySupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ public class LegacySupport

public static void EnsureLegacyFolderExists(IFileHandle legacyManifest)
{
if (legacyManifest is null)
{
return;
}

var manifest = Path.Combine(Constants.LegacyLevelsDirectory, "manifest.json");
if (File.Exists(manifest)) return;
Directory.CreateDirectory(Constants.LegacyLevelsDirectory);
Expand Down
6 changes: 4 additions & 2 deletions WurstMod/UnityEditor/Exporter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
#if UNITY_EDITOR
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
Expand Down Expand Up @@ -100,4 +101,5 @@ public void AddError(string message, Object context = null)
UnityEngine.Debug.LogError(message, context);
}
}
}
}
#endif
6 changes: 4 additions & 2 deletions WurstMod/UnityEditor/ExporterWindow.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if UNITY_EDITOR
using System;
using System.Linq;
using UnityEditor;
using UnityEngine;
Expand Down Expand Up @@ -77,4 +78,5 @@ private string DrawGamemode(string current)
return choices[newIndex];
}
}
}
}
#endif
6 changes: 4 additions & 2 deletions WurstMod/UnityEditor/SceneExporters/SandboxExporter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine.SceneManagement;
#if UNITY_EDITOR
using UnityEngine.SceneManagement;
using WurstMod.MappingComponents.Generic;
using WurstMod.MappingComponents.Sandbox;
using WurstMod.Shared;
Expand All @@ -18,4 +19,5 @@ public override void Validate(Scene scene, CustomScene root, ExportErrors err)
RequiredComponents<Spawn>(1, 1);
}
}
}
}
#endif
6 changes: 4 additions & 2 deletions WurstMod/UnityEditor/SceneExporters/SceneExporter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FistVR;
#if UNITY_EDITOR
using FistVR;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -159,4 +160,5 @@ public static IEnumerable<Type> EnumerateExporterTypes()
/// <returns>The exporter object</returns>
public static SceneExporter GetExporterForGamemode(string gamemode) => RegisteredSceneExporters.FirstOrDefault(x => x.GamemodeId == gamemode);
}
}
}
#endif
6 changes: 4 additions & 2 deletions WurstMod/UnityEditor/SceneExporters/TakeAndHoldExporter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if UNITY_EDITOR
using System;
using UnityEditor;
using UnityEngine.SceneManagement;
using WurstMod.MappingComponents.Generic;
Expand Down Expand Up @@ -33,4 +34,5 @@ public override CustomScene.StringKeyValue[] OnExporterGUI(CustomScene.StringKey
return customData;
}
}
}
}
#endif
4 changes: 3 additions & 1 deletion WurstMod/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"dependencies": {},
"assets": {
"setup": {
"wurstmod.dll": "deli:assembly"
"wurstmod.dll": "deli:assembly",
"Debug Sandbox/": "wurstmodders.wurstmod:level",
"Debug TNH/": "wurstmodders.wurstmod:level"
}
}
}

0 comments on commit 4b47c57

Please sign in to comment.