diff --git a/ComputerInterface.Commands/ComputerInterface.Commands.csproj b/ComputerInterface.Commands/ComputerInterface.Commands.csproj index 0e40177..1e63c61 100644 --- a/ComputerInterface.Commands/ComputerInterface.Commands.csproj +++ b/ComputerInterface.Commands/ComputerInterface.Commands.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.1 diff --git a/ComputerInterface/AssetsLoader.cs b/ComputerInterface/AssetsLoader.cs index 1eccf94..8e61426 100644 --- a/ComputerInterface/AssetsLoader.cs +++ b/ComputerInterface/AssetsLoader.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Reflection; using System.Threading.Tasks; @@ -14,14 +15,15 @@ internal class AssetsLoader : IDisposable private AssetBundle _loadedBundle; private Task _loadingTask; + private readonly Dictionary _loadedObjects = new Dictionary(); + public async Task GetAsset(string name) where T : Object { + if (_loadedObjects.TryGetValue(name, out var cachedObject)) return (T)cachedObject; + if (!IsLoaded) { - if (_loadingTask == null) - { - _loadingTask = LoadBundleAsyncInternal(); - } + _loadingTask ??= LoadBundleAsyncInternal(); await _loadingTask; } @@ -41,7 +43,9 @@ public async Task GetAsset(string name) where T : Object completionSource.SetResult((T)assetBundleRequest.asset); }; - return await completionSource.Task; + var completedTask = await completionSource.Task; + _loadedObjects.Add(name, completedTask); + return completedTask; } private async Task LoadBundleAsyncInternal() diff --git a/ComputerInterface/ComputerInterface.csproj b/ComputerInterface/ComputerInterface.csproj index df18e45..fba8a42 100644 --- a/ComputerInterface/ComputerInterface.csproj +++ b/ComputerInterface/ComputerInterface.csproj @@ -1,7 +1,7 @@ - netstandard2.0 + netstandard2.1 8.0 diff --git a/ComputerInterface/CustomComputer.cs b/ComputerInterface/CustomComputer.cs index ca0d6f2..50f3f00 100644 --- a/ComputerInterface/CustomComputer.cs +++ b/ComputerInterface/CustomComputer.cs @@ -18,6 +18,7 @@ namespace ComputerInterface { public class CustomComputer : MonoBehaviour, IInitializable { + public static CustomComputer Instance => GorillaComputer.instance.GetComponent(); private bool _initialized; private GorillaComputer _gorillaComputer; @@ -296,7 +297,7 @@ private async Task ReplaceKeys(GameObject computer) _keyboardAudios.Add(audioSource); if (_keyboard.GetComponent() is MeshRenderer renderer) { - renderer.material.color = new Color(0.3f, 0.3f, 0.3f); + //renderer.material.color = new Color(0.3f, 0.3f, 0.3f); } var enterKey = _keys.Last(x => x.KeyboardKey == EKeyboardKey.Enter); @@ -416,24 +417,22 @@ private CustomKeyboardKey CreateKey(GameObject prefab, string goName, Vector3 of { RemoveMonitor(computer, location); - var tmpSettings = await _assetsLoader.GetAsset("TMP Settings"); + // Might need this later, but who knows + /* var tmpSettings = await _assetsLoader.GetAsset("TMP Settings"); typeof(TMP_Settings).GetField( "s_Instance", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)? - .SetValue(null, tmpSettings); + .SetValue(null, tmpSettings); */ var monitorAsset = await _assetsLoader.GetAsset("Monitor"); var newMonitor = Instantiate(monitorAsset); newMonitor.name = $"{location} Custom Monitor"; newMonitor.transform.SetParent(computer.transform.Find("monitor") ?? computer.transform.Find("monitor (1)"), false); - newMonitor.transform.localPosition = new Vector3(2.28f, -0.72f, 0.0f); - newMonitor.transform.localEulerAngles = new Vector3(0.0f, 270.0f, 270.02f); + newMonitor.transform.localPosition = new Vector3(-0.0787f, -0.21f, 0.5344f); + newMonitor.transform.localEulerAngles = new Vector3(90f, 0f, 0f); newMonitor.transform.SetParent(computer.transform.parent, true); - foreach (RectTransform rect in newMonitor.GetComponentsInChildren()) rect.gameObject.layer = 9; - newMonitor.GetComponentInChildren().enabled = false; - var info = new CustomScreenInfo { Transform = newMonitor.transform, @@ -441,14 +440,14 @@ private CustomKeyboardKey CreateKey(GameObject prefab, string goName, Vector3 of Renderer = newMonitor.GetComponentsInChildren().First(x => x.name == "Main Monitor"), RawImage = newMonitor.GetComponentInChildren() }; - info.RawImage.color = new Color(0.05f, 0.05f, 0.05f); + info.Renderer.gameObject.AddComponent(); info.Materials = info.Renderer.materials; info.Color = new Color(0.05f, 0.05f, 0.05f); return info; } - private void RemoveMonitor(GameObject computer, MonitorLocation monitorIndex) + private void RemoveMonitor(GameObject computer, MonitorLocation computerLocation) { GameObject monitor = null; foreach (Transform child in computer.transform) @@ -474,6 +473,12 @@ private void RemoveMonitor(GameObject computer, MonitorLocation monitorIndex) terminal.myScreenText?.gameObject?.SetActive(false); } + if (computerLocation == MonitorLocation.Treehouse) + { + var monitorTransform = computer.transform.parent.parent?.Find("Static/monitor") ?? null; + monitorTransform?.gameObject?.SetActive(false); + } + try { // Some monitors were baked into the scene, so we need to do all this jank to get rid of them @@ -487,7 +492,7 @@ private void RemoveMonitor(GameObject computer, MonitorLocation monitorIndex) ZoneData FindZoneData(GTZone zone) => (ZoneData)AccessTools.Method(typeof(ZoneManagement), "GetZoneData").Invoke(zoneManager, new object[] { zone }); - GameObject combinedScene = monitorIndex switch + GameObject combinedScene = computerLocation switch { MonitorLocation.Treehouse => FindZoneData(GTZone.forest).rootGameObjects[1].transform.Find("Terrain/Uncover ForestCombined/").GetComponentInChildren(true).gameObject, MonitorLocation.Mountains => FindZoneData(GTZone.mountain).rootGameObjects[0].transform.Find("Mountain Texture Baker/Uncover Mountain Lit/").GetComponentInChildren(true).gameObject, diff --git a/ComputerInterface/CustomScreenInfo.cs b/ComputerInterface/CustomScreenInfo.cs index 9afdbc5..a2a3704 100644 --- a/ComputerInterface/CustomScreenInfo.cs +++ b/ComputerInterface/CustomScreenInfo.cs @@ -14,8 +14,8 @@ public class CustomScreenInfo public Color Color { - get => RawImage.material.color; - set => RawImage.material.color = value; + get => RawImage.color; + set => RawImage.color = value; } public string Text diff --git a/ComputerInterface/MainInstaller.cs b/ComputerInterface/MainInstaller.cs index 77d078f..dcf8b9f 100644 --- a/ComputerInterface/MainInstaller.cs +++ b/ComputerInterface/MainInstaller.cs @@ -15,7 +15,7 @@ internal class MainInstaller : Installer public override void InstallBindings() { Container - .BindFactory() + .BindFactory() .FromFactory(); Container.BindInterfacesAndSelfTo().FromNewComponentOn(ComputerGetter).AsSingle(); diff --git a/ComputerInterface/Resources/assets b/ComputerInterface/Resources/assets index ba9435b..851b266 100644 Binary files a/ComputerInterface/Resources/assets and b/ComputerInterface/Resources/assets differ diff --git a/ComputerInterface/ViewLib/ComputerView.cs b/ComputerInterface/ViewLib/ComputerView.cs index 9c4c5b9..cd270e4 100644 --- a/ComputerInterface/ViewLib/ComputerView.cs +++ b/ComputerInterface/ViewLib/ComputerView.cs @@ -16,7 +16,7 @@ public class ComputerView : IComputerView /// /// How many characters fit in the x axis of the screen /// - public static int SCREEN_WIDTH = 41; + public static int SCREEN_WIDTH = 47; /// /// How many characters fit in the y axis of the screen diff --git a/ComputerInterface/ViewLib/ComputerViewFactory.cs b/ComputerInterface/ViewLib/ComputerViewFactory.cs index 6a819a4..9bd1729 100644 --- a/ComputerInterface/ViewLib/ComputerViewFactory.cs +++ b/ComputerInterface/ViewLib/ComputerViewFactory.cs @@ -4,7 +4,7 @@ namespace ComputerInterface.ViewLib { - public class ComputerViewFactory : IFactory + public class ComputerViewFactory : IFactory { private readonly DiContainer _container; @@ -13,9 +13,9 @@ public ComputerViewFactory(DiContainer container) _container = container; } - public IComputerView Create(Type viewType) + public ComputerView Create(Type viewType) { - return (IComputerView) _container.Instantiate(viewType); + return (ComputerView) _container.Instantiate(viewType); } } } \ No newline at end of file diff --git a/ComputerInterface/ViewLib/ComputerViewPlaceholderFactory.cs b/ComputerInterface/ViewLib/ComputerViewPlaceholderFactory.cs index 9c3ab68..ecdb654 100644 --- a/ComputerInterface/ViewLib/ComputerViewPlaceholderFactory.cs +++ b/ComputerInterface/ViewLib/ComputerViewPlaceholderFactory.cs @@ -4,5 +4,5 @@ namespace ComputerInterface.ViewLib { - public class ComputerViewPlaceholderFactory : PlaceholderFactory { } + public class ComputerViewPlaceholderFactory : PlaceholderFactory { } } \ No newline at end of file