diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 7176fdad0..151cba81c 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -8307,9 +8307,9 @@ RectTransform: m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 0} + m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: -17, y: 20} + m_SizeDelta: {x: 0, y: 20} m_Pivot: {x: 0, y: 0} --- !u!114 &412194189 MonoBehaviour: @@ -9014,7 +9014,7 @@ RectTransform: m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 0.99999976} + m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 20, y: 20} m_Pivot: {x: 0.5, y: 0.5} @@ -10323,7 +10323,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: -73.03003} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 1} --- !u!114 &519035862 MonoBehaviour: @@ -19986,7 +19986,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &907710631 RectTransform: m_ObjectHideFlags: 0 @@ -20005,9 +20005,9 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 8} - m_SizeDelta: {x: 0, y: 16} - m_Pivot: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 1} --- !u!114 &907710632 MonoBehaviour: m_ObjectHideFlags: 0 @@ -20803,9 +20803,9 @@ RectTransform: m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} + m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: -17, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 1} --- !u!114 &953390098 MonoBehaviour: @@ -24594,10 +24594,10 @@ RectTransform: m_Father: {fileID: 519035861} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 943.50006, y: -263.485} - m_SizeDelta: {x: 1887.0001, y: 526.97} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 943.50006, y: 0} + m_SizeDelta: {x: 1887.0001, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1101630447 MonoBehaviour: @@ -34335,10 +34335,10 @@ RectTransform: m_Father: {fileID: 323746067} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} + m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 1} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 600} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1551320372 MonoBehaviour: @@ -35948,7 +35948,7 @@ MonoBehaviour: m_HandleRect: {fileID: 456371628} m_Direction: 2 m_Value: 0 - m_Size: 0.9999998 + m_Size: 1 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -37097,8 +37097,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 8, y: -8} - m_SizeDelta: {x: -16, y: -16} + m_AnchoredPosition: {x: 8, y: 0} + m_SizeDelta: {x: -16, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1663644542 MonoBehaviour: @@ -43752,7 +43752,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1935781035} - m_Enabled: 0 + m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 058cba836c1846c3aa1c5fd2e28aea77, type: 3} m_Name: diff --git a/Assets/Scripts/ConsoleController.cs b/Assets/Scripts/ConsoleController.cs index e5ecbfdd3..2a1e57f80 100644 --- a/Assets/Scripts/ConsoleController.cs +++ b/Assets/Scripts/ConsoleController.cs @@ -9,12 +9,14 @@ using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; +using System.Text.RegularExpressions; using UnityEngine.SceneManagement; using Object = UnityEngine.Object; public class ConsoleController { private static ConsoleController instance; + private static Regex permittedCharacters = new Regex("[^a-zA-Z0-9 -]"); private ConsoleController() { @@ -105,6 +107,11 @@ public class ConsoleController } char[] parmCharsArr = new char[parmChars.Count]; parmChars.CopyTo(parmCharsArr, 0); - return (new string(parmCharsArr)).Split(new char[] {'\n'}, StringSplitOptions.RemoveEmptyEntries); + var args = new string(parmCharsArr).Split(new[] {'\n'}, StringSplitOptions.RemoveEmptyEntries); + for (var i = 0; i < args.Length; i++) + { + args[i] = permittedCharacters.Replace(args[i], ""); + } + return args; } } diff --git a/Assets/Scripts/StrategyGameManager.cs b/Assets/Scripts/StrategyGameManager.cs index 12c8756df..6548529c3 100644 --- a/Assets/Scripts/StrategyGameManager.cs +++ b/Assets/Scripts/StrategyGameManager.cs @@ -153,7 +153,7 @@ public class StrategyGameManager : MonoBehaviour // Parse first argument as hull name, default to Fighter if argument missing HullData hullData; - if (args.Length > 0) + if (args.Length > 1) { hullData = _cache.GetAll().FirstOrDefault(h => h.Name == args[0]); if (hullData == null) @@ -169,9 +169,9 @@ public class StrategyGameManager : MonoBehaviour var hull = _context.CreateInstance(hullData.ID, .9f) as Gear; List gear = new List(); - if (args.Length > 1) + if (args.Length > 2) { - foreach (string arg in args.Skip(1)) + foreach (string arg in args.Skip(2)) { var gearData = _cache.GetAll().FirstOrDefault(h => h.Name == arg); if (gearData == null) @@ -184,21 +184,33 @@ public class StrategyGameManager : MonoBehaviour } else { - var thrusterData = _cache.GetAll().FirstOrDefault(g => g.Behaviors.Any(b => b is ThrusterData)); - var thruster = _context.CreateInstance(thrusterData.ID, .9f) as Gear; - gear.Add(thruster); + // If no gear arguments supplied and we're spawning a ship, get the first thruster and put it in + if (args[0] == "ship") + { + var thrusterData = _cache.GetAll().FirstOrDefault(g => g.Behaviors.Any(b => b is ThrusterData)); + var thruster = _context.CreateInstance(thrusterData.ID, .9f) as Gear; + gear.Add(thruster); + } } - var entity = new Ship(_context, hull, gear, Enumerable.Empty()); - var shipData = new ShipData // TODO: Better database entry for ships? + + if (args[0] == "ship") { - ID = Guid.NewGuid() - }; - _cache.Add(shipData); - _context.ZoneContents[zoneData][shipData] = entity; - _context.Agents.Add(new AgentController(_context, zoneData, entity)); - var zoneShip = Instantiate(ZoneShipPrefab, ZoneRoot); - zoneShip.Label.text = $"Ship {_zoneShips.Count}"; - _zoneShips[entity] = zoneShip; + var entity = new Ship(_context, hull, gear, Enumerable.Empty()); + var shipData = new ShipData // TODO: Better database entry for ships? + { + ID = Guid.NewGuid() + }; + _cache.Add(shipData); + _context.ZoneContents[zoneData][shipData] = entity; + _context.Agents.Add(new AgentController(_context, zoneData, entity)); + var zoneShip = Instantiate(ZoneShipPrefab, ZoneRoot); + zoneShip.Label.text = $"Ship {_zoneShips.Count}"; + _zoneShips[entity] = zoneShip; + } + else + { + Debug.Log($"Unknown entity type: \"{args[0]}\""); + } } private void Update() diff --git a/Assets/Scripts/UnityExtensions.cs b/Assets/Scripts/UnityExtensions.cs index d6d2f80cd..fd01d3d9c 100644 --- a/Assets/Scripts/UnityExtensions.cs +++ b/Assets/Scripts/UnityExtensions.cs @@ -13,10 +13,20 @@ using static Unity.Mathematics.math; public static class UnityExtensions { + public static void BroadcastAll(string fun, System.Object msg) { + GameObject[] gos = (GameObject[])GameObject.FindObjectsOfType(typeof(GameObject)); + foreach (GameObject go in gos) { + if (go && go.transform.parent == null) { + go.gameObject.BroadcastMessageExt(fun, msg, SendMessageOptions.DontRequireReceiver); + } + } + } + public static void BroadcastMessageExt(this GameObject go, string methodName, object value = null, SendMessageOptions options = SendMessageOptions.RequireReceiver) { var monoList = new List(); go.GetComponentsInChildren(true, monoList); + //monoList.Add(); foreach (var component in monoList) { try diff --git a/README.md b/README.md index 31984c022..249df9224 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,20 @@ At the top of the list view there is a text field where you can enter the URL of You can unfold the categories of items in the list view to see what items exist. If you select an item, the Database Inspector will populate with all of the available fields of that item. Any changes you make in the Inspector will automatically be pushed to RethinkDB. If you've connected to the production database, this will update the stats of in-game items in real-time! +### Debug Console + +Pressing the tilde key (`) while running the game allows you to access the console. Here you can view the debug log as well as entering commands which aid in testing various game mechanics. + +#### Commands + +##### spawn + +Arguments: + +- Entity type: needs to be "ship", "station" or "turret" +- Hull name (optional): selects the hull of the spawned entity by name +- Gear List (optional): every additional argument specifies a Gear item to install + ### Galaxy Editor When you select a galaxy asset in the Unity scene hierarchy, a custom editor opens in the inspector which enables the procedural generation of a new galaxy. There you can find some variables pertaining to the galaxy as a whole, such as the number and twist of the spiral arms.