Skip to content

Commit

Permalink
ItemSpawner fixes and Generic level fixes.
Browse files Browse the repository at this point in the history
New unitypackage for 1.2.0.0.
  • Loading branch information
Nolenz committed Jun 19, 2020
1 parent 76a9bd8 commit 1734d3a
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 20 deletions.
12 changes: 9 additions & 3 deletions WurstMod/Exporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ private static void Export(LevelType type)
if (!choice) return;
}

// Pre-save, grab the skybox.
// TODO Doesn't always work for some reason.
levelComponent.skybox = RenderSettings.skybox;


CreateBundle(scene);
}
Expand Down Expand Up @@ -161,6 +159,14 @@ private static string CheckRoot(Scene scene, List<string> warnings)
return "Level Name and Level Author cannot contain newlines.";
}

// Warn empty skybox.
if (levelComponent.skybox == null && RenderSettings.skybox != null)
{
string warn = "WARNING: You didn't set your skybox on [LEVEL]!";
Debug.LogWarning(warn);
warnings.Add(warn);
}

return "";
}

Expand Down
3 changes: 2 additions & 1 deletion WurstMod/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,15 @@ public static void RefreshShader(this Material mat)
#endregion

#region Gizmos
public static void GenericGizmoCube(Color color, Vector3 center, Vector3 size, bool drawFacing, params Transform[] markers)
public static void GenericGizmoCube(Color color, Vector3 center, Vector3 size, bool drawFacing, bool drawNegativeFacing, params Transform[] markers)
{
Gizmos.color = color;
foreach (Transform ii in markers)
{
Gizmos.matrix = ii.localToWorldMatrix;
Gizmos.DrawCube(center, size);
if (drawFacing) Gizmos.DrawLine(center, center + Vector3.forward);
if (drawNegativeFacing) Gizmos.DrawLine(center, center - Vector3.forward);
}
}

Expand Down
2 changes: 1 addition & 1 deletion WurstMod/Generic/ItemSpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ItemSpawner : MonoBehaviour
{
void OnDrawGizmos()
{
Extensions.GenericGizmoCube(new Color(0.4f, 0.4f, 0.9f, 0.5f), new Vector3(0f, 1.5f, 0.25f), new Vector3(2.3f, 1.2f, 0.5f), true, transform);
Extensions.GenericGizmoCube(new Color(0.4f, 0.4f, 0.9f, 0.5f), new Vector3(0f, 1.5f, 0.25f), new Vector3(2.3f, 1.2f, 0.5f), true, false, transform);
}
}
}
3 changes: 1 addition & 2 deletions WurstMod/Generic_LevelPopulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ private static void CalculateScreenPositions()
}

// Trimming positions we don't want and order by -z.
// TODO Not ordered properly?
screenPositions = screenPositions.Where(x => x.z < -7f).ToList();
screenPositions = screenPositions.OrderByDescending(x => -x.z).ToList();
screenPositions = screenPositions.OrderByDescending(x => -x.z).ThenBy(x => Mathf.Abs(x.y - 4.15f)).ToList();
}

private static void InitObjects()
Expand Down
11 changes: 8 additions & 3 deletions WurstMod/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,14 @@ private static void Resolve_ItemSpawners()
GameObject spawnerBase = currentScene.GetAllGameObjectsInScene().Where(x => x.name == "ItemSpawner").First();
foreach (Transform ii in itemSpawners)
{
Debug.Log("Copying item spawner..."); // TODO REMOVE
GameObject spawnerCopy = GameObject.Instantiate(spawnerBase, loadedRoot.transform);
spawnerCopy.transform.position = ii.position + (0.8f * Vector3.up);
GameObject spawner = GameObject.Instantiate(spawnerBase, loadedRoot.transform);
//GameObject spawner = spawnerBase;
spawner.transform.position = ii.position + (0.8f * Vector3.up);
spawner.transform.localEulerAngles = ii.localEulerAngles;
spawner.SetActive(true);

Debug.Log(string.Join("\n", spawner.transform.AsEnumerable().Select(x => x.name + ", " + x.transform.position.ToString() ).ToArray()));
Debug.Log(spawner.transform.position);
}
}

Expand Down
2 changes: 1 addition & 1 deletion WurstMod/TNH/AttackVector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class AttackVector : MonoBehaviour
private void OnDrawGizmos()
{
Extensions.GenericGizmoSphere(new Color(0.8f, 0f, 0f, 0.5f), Vector3.zero, 0.25f, SpawnPoints_Sosigs_Attack.ToArray());
Extensions.GenericGizmoCube(new Color(0.1f, 0.5f, 0.1f, 0.5f), Vector3.zero, 0.5f * Vector3.one, true, GrenadeVector);
Extensions.GenericGizmoCube(new Color(0.1f, 0.5f, 0.1f, 0.5f), Vector3.zero, 0.5f * Vector3.one, true, false, GrenadeVector);
}
}
}
2 changes: 1 addition & 1 deletion WurstMod/TNH/ScoreboardArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ScoreboardArea : MonoBehaviour
{
private void OnDrawGizmos()
{
Extensions.GenericGizmoCube(new Color(0.4f, 0.4f, 0.9f, 0.5f), new Vector3(0f, 1.5f, 0f), new Vector3(5f, 3f, 5f), false, transform);
Extensions.GenericGizmoCube(new Color(0.4f, 0.4f, 0.9f, 0.5f), new Vector3(0f, 1.5f, 0f), new Vector3(5f, 3f, 5f), false, true, transform);
}
}
}
2 changes: 1 addition & 1 deletion WurstMod/TNH/TNH_DestructibleBarrierPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class TNH_DestructibleBarrierPoint : MonoBehaviour

private void OnDrawGizmos()
{
Extensions.GenericGizmoCube(new Color(0.0f, 0.6f, 0.0f, 0.5f), new Vector3(0, 1, 0), new Vector3(1, 2, 0.1f), false, transform);
Extensions.GenericGizmoCube(new Color(0.0f, 0.6f, 0.0f, 0.5f), new Vector3(0, 1, 0), new Vector3(1, 2, 0.1f), false, false, transform);
}
}
}
2 changes: 1 addition & 1 deletion WurstMod/TNH/TNH_HoldPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void OnDrawGizmos()
if (SpawnPoint_SystemNode != null) Extensions.GenericGizmoSphere(new Color(0.0f, 0.8f, 0.8f), 1.5f * Vector3.up, 0.25f, SpawnPoint_SystemNode);
if (SpawnPoints_Sosigs_Defense != null) Extensions.GenericGizmoSphere(new Color(0.8f, 0f, 0f, 0.5f), Vector3.zero, 0.25f, SpawnPoints_Sosigs_Defense.AsEnumerable().ToArray());
if (SpawnPoints_Turrets != null) Extensions.GenericGizmoSphere(new Color(0.8f, 0f, 0f, 0.1f), Vector3.zero, 0.25f, SpawnPoints_Turrets.AsEnumerable().ToArray());
if (SpawnPoints_Targets != null) Extensions.GenericGizmoCube(new Color(1f, 0.0f, 0.0f, 0.5f), Vector3.zero, new Vector3(0.1f, 0.5f, 0.1f), false, SpawnPoints_Targets.AsEnumerable().ToArray());
if (SpawnPoints_Targets != null) Extensions.GenericGizmoCube(new Color(1f, 0.0f, 0.0f, 0.5f), Vector3.zero, new Vector3(0.1f, 0.5f, 0.1f), false, false, SpawnPoints_Targets.AsEnumerable().ToArray());
}
}
}
12 changes: 6 additions & 6 deletions WurstMod/TNH/TNH_SupplyPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ public class TNH_SupplyPoint : MonoBehaviour
void OnDrawGizmos()
{
if (Bounds != null) Extensions.GenericGizmoCubeOutline(Color.white, Vector3.zero, Vector3.one, Bounds);
if (SpawnPoints_Panels != null) Extensions.GenericGizmoCube(new Color(0.4f, 0.4f, 0.9f, 0.5f), new Vector3(0f, 1.5f, 0.25f), new Vector3(2.3f, 1.2f, 0.5f), true, SpawnPoints_Panels.AsEnumerable().ToArray());
if (SpawnPoint_CaseLarge != null) Extensions.GenericGizmoCube(new Color(1f, 0.4f, 0.0f, 0.5f), new Vector3(0f, 0.12f, 0f), new Vector3(1.4f, 0.24f, 0.35f), true, SpawnPoint_CaseLarge);
if (SpawnPoint_CaseSmall != null) Extensions.GenericGizmoCube(new Color(1f, 0.4f, 0.0f, 0.5f), new Vector3(0f, 0.12f, 0f), new Vector3(0.6f, 0.24f, 0.35f), true, SpawnPoint_CaseSmall);
if (SpawnPoint_Tables != null) Extensions.GenericGizmoCube(new Color(0.5f, 0.5f, 0.5f, 0.5f), new Vector3(0f, 0.4f, 0.1f), new Vector3(0.7f, 0.8f, 1.5f), false, SpawnPoint_Tables.AsEnumerable().ToArray());
if (SpawnPoints_Boxes != null) Extensions.GenericGizmoCube(new Color(0.7f, 0.7f, 0.7f, 0.5f), Vector3.zero, 0.5f * Vector3.one, false, SpawnPoints_Boxes.AsEnumerable().ToArray());
if (SpawnPoints_Panels != null) Extensions.GenericGizmoCube(new Color(0.4f, 0.4f, 0.9f, 0.5f), new Vector3(0f, 1.5f, 0.25f), new Vector3(2.3f, 1.2f, 0.5f), true, false, SpawnPoints_Panels.AsEnumerable().ToArray());
if (SpawnPoint_CaseLarge != null) Extensions.GenericGizmoCube(new Color(1f, 0.4f, 0.0f, 0.5f), new Vector3(0f, 0.12f, 0f), new Vector3(1.4f, 0.24f, 0.35f), true, false, SpawnPoint_CaseLarge);
if (SpawnPoint_CaseSmall != null) Extensions.GenericGizmoCube(new Color(1f, 0.4f, 0.0f, 0.5f), new Vector3(0f, 0.12f, 0f), new Vector3(0.6f, 0.24f, 0.35f), true, false, SpawnPoint_CaseSmall);
if (SpawnPoint_Tables != null) Extensions.GenericGizmoCube(new Color(0.5f, 0.5f, 0.5f, 0.5f), new Vector3(0f, 0.4f, 0.1f), new Vector3(0.7f, 0.8f, 1.5f), false, false, SpawnPoint_Tables.AsEnumerable().ToArray());
if (SpawnPoints_Boxes != null) Extensions.GenericGizmoCube(new Color(0.7f, 0.7f, 0.7f, 0.5f), Vector3.zero, 0.5f * Vector3.one, false, false, SpawnPoints_Boxes.AsEnumerable().ToArray());
if (SpawnPoints_Sosigs_Defense != null) Extensions.GenericGizmoSphere(new Color(0.8f, 0f, 0f, 0.5f), Vector3.zero, 0.25f, SpawnPoints_Sosigs_Defense.AsEnumerable().ToArray());
if (SpawnPoints_Turrets != null) Extensions.GenericGizmoSphere(new Color(0.8f, 0f, 0f, 0.1f), Vector3.zero, 0.25f, SpawnPoints_Turrets.AsEnumerable().ToArray());
if (SpawnPoint_Melee != null) Extensions.GenericGizmoSphere(new Color(0.0f, 0.8f, 0f, 0.5f), Vector3.zero, 0.2f, SpawnPoint_Melee);
if (SpawnPoints_SmallItem != null) Extensions.GenericGizmoSphere(new Color(0.0f, 0.8f, 0f, 0.5f), Vector3.zero, 0.1f, SpawnPoints_SmallItem.AsEnumerable().ToArray());
if (SpawnPoint_PlayerSpawn != null) Extensions.GenericGizmoSphere(new Color(0.0f, 0.8f, 0.8f, 0.5f), Vector3.zero, 0.25f, SpawnPoint_PlayerSpawn);
if (SpawnPoint_Shield != null) Extensions.GenericGizmoCube(new Color(0.0f, 0.8f, 0.0f, 0.1f), Vector3.zero, new Vector3(0.4f, 0.6f, 0.1f), false, SpawnPoint_Shield);
if (SpawnPoint_Shield != null) Extensions.GenericGizmoCube(new Color(0.0f, 0.8f, 0.0f, 0.1f), Vector3.zero, new Vector3(0.4f, 0.6f, 0.1f), false, false, SpawnPoint_Shield);
}
}
}
Binary file modified WurstModWorkbench.unitypackage
Binary file not shown.

0 comments on commit 1734d3a

Please sign in to comment.