diff --git a/DontTrackList - Example.txt b/DontTrackList - Example.txt new file mode 100644 index 0000000..2de90a1 --- /dev/null +++ b/DontTrackList - Example.txt @@ -0,0 +1,4 @@ +planterpot +planterbox +plantershelf +alongplanter diff --git a/ResourceMonitor Unity Project/Assets/prefabs/ResourceMonitorModel.prefab b/ResourceMonitor Unity Project/Assets/prefabs/ResourceMonitorModel.prefab index add85f7..875433a 100644 --- a/ResourceMonitor Unity Project/Assets/prefabs/ResourceMonitorModel.prefab +++ b/ResourceMonitor Unity Project/Assets/prefabs/ResourceMonitorModel.prefab @@ -91,7 +91,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!1 &1222060525602326 GameObject: m_ObjectHideFlags: 1 @@ -467,7 +467,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1534684113904162} m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068} - m_LocalPosition: {x: 0, y: -0.5, z: 0} + m_LocalPosition: {x: 0, y: -0.5, z: 0.049} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4261509917996202} @@ -569,7 +569,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0.18382353, g: 0.18382353, b: 0.18382353, a: 1} + m_Color: {r: 0.18382353, g: 0.18382353, b: 0.18382353, a: 0} m_RaycastTarget: 1 m_OnCullStateChanged: m_PersistentCalls: @@ -1114,7 +1114,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_UiScaleMode: 0 - m_ReferencePixelsPerUnit: 100 + m_ReferencePixelsPerUnit: 50 m_ScaleFactor: 1 m_ReferenceResolution: {x: 800, y: 600} m_ScreenMatchMode: 0 @@ -1315,7 +1315,7 @@ RectTransform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1659912519055400} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0.015} + m_LocalPosition: {x: 0, y: 0, z: 0.063999996} m_LocalScale: {x: -0.0009234928, y: 0.0010885138, z: 1.3644528} m_Children: - {fileID: 224340271212837900} diff --git a/ResourceMonitor Unity Project/Built Asset Bundles/Built Asset Bundles b/ResourceMonitor Unity Project/Built Asset Bundles/Built Asset Bundles index 737558f..690c33b 100644 Binary files a/ResourceMonitor Unity Project/Built Asset Bundles/Built Asset Bundles and b/ResourceMonitor Unity Project/Built Asset Bundles/Built Asset Bundles differ diff --git a/ResourceMonitor Unity Project/Built Asset Bundles/Built Asset Bundles.manifest b/ResourceMonitor Unity Project/Built Asset Bundles/Built Asset Bundles.manifest index f2ff5e8..9836621 100644 --- a/ResourceMonitor Unity Project/Built Asset Bundles/Built Asset Bundles.manifest +++ b/ResourceMonitor Unity Project/Built Asset Bundles/Built Asset Bundles.manifest @@ -1,5 +1,5 @@ ManifestFileVersion: 0 -CRC: 3554606922 +CRC: 2170159394 AssetBundleManifest: AssetBundleInfos: Info_0: diff --git a/ResourceMonitor Unity Project/Built Asset Bundles/resources b/ResourceMonitor Unity Project/Built Asset Bundles/resources index 01c4cae..de4312c 100644 Binary files a/ResourceMonitor Unity Project/Built Asset Bundles/resources and b/ResourceMonitor Unity Project/Built Asset Bundles/resources differ diff --git a/ResourceMonitor Unity Project/Built Asset Bundles/resources.manifest b/ResourceMonitor Unity Project/Built Asset Bundles/resources.manifest index 718eb3a..6ae451e 100644 --- a/ResourceMonitor Unity Project/Built Asset Bundles/resources.manifest +++ b/ResourceMonitor Unity Project/Built Asset Bundles/resources.manifest @@ -1,9 +1,9 @@ ManifestFileVersion: 0 -CRC: 644164568 +CRC: 3116201863 Hashes: AssetFileHash: serializedVersion: 2 - Hash: 28d6eaac1d1aea8f5217f72285da92f1 + Hash: b3f9ac2f149687dfd441e044b658aeed TypeTreeHash: serializedVersion: 2 Hash: cd706fa7e487f229c6b1a506387ac5ed diff --git a/ResourceMonitor Unity Project/Library/CurrentLayout.dwlt b/ResourceMonitor Unity Project/Library/CurrentLayout.dwlt index 1576a16..5097521 100644 --- a/ResourceMonitor Unity Project/Library/CurrentLayout.dwlt +++ b/ResourceMonitor Unity Project/Library/CurrentLayout.dwlt @@ -20,7 +20,7 @@ MonoBehaviour: m_ShowMode: 4 m_Title: m_RootView: {fileID: 6} - m_MinSize: {x: 950, y: 371} + m_MinSize: {x: 950, y: 300} m_MaxSize: {x: 10000, y: 10000} --- !u!114 &2 MonoBehaviour: @@ -42,8 +42,8 @@ MonoBehaviour: y: 30 width: 1920 height: 947 - m_MinSize: {x: 681, y: 321} - m_MaxSize: {x: 12006, y: 8021} + m_MinSize: {x: 683, y: 492} + m_MaxSize: {x: 14004, y: 14042} vertical: 0 controlID: 49 --- !u!114 &3 @@ -89,8 +89,8 @@ MonoBehaviour: y: 0 width: 284 height: 655 - m_MinSize: {x: 202, y: 221} - m_MaxSize: {x: 4002, y: 4021} + m_MinSize: {x: 200, y: 200} + m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 16} m_Panes: - {fileID: 16} @@ -114,15 +114,15 @@ MonoBehaviour: y: 655 width: 1594 height: 292 - m_MinSize: {x: 100, y: 100} - m_MaxSize: {x: 4000, y: 4000} - m_ActualView: {fileID: 13} + m_MinSize: {x: 232, y: 271} + m_MaxSize: {x: 10002, y: 10021} + m_ActualView: {fileID: 14} m_Panes: - {fileID: 14} - {fileID: 19} - {fileID: 13} - m_Selected: 2 - m_LastSelected: 0 + m_Selected: 0 + m_LastSelected: 2 --- !u!114 &6 MonoBehaviour: m_ObjectHideFlags: 52 @@ -207,8 +207,8 @@ MonoBehaviour: y: 0 width: 1594 height: 947 - m_MinSize: {x: 406, y: 321} - m_MaxSize: {x: 8006, y: 8021} + m_MinSize: {x: 406, y: 492} + m_MaxSize: {x: 10002, y: 14042} vertical: 1 controlID: 50 --- !u!114 &10 @@ -253,8 +253,8 @@ MonoBehaviour: y: 0 width: 1310 height: 655 - m_MinSize: {x: 204, y: 221} - m_MaxSize: {x: 4004, y: 4021} + m_MinSize: {x: 200, y: 200} + m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 17} m_Panes: - {fileID: 17} @@ -372,18 +372,18 @@ MonoBehaviour: m_ShowAllHits: 0 m_SearchArea: 0 m_Folders: - - Assets + - Assets/prefabs m_ViewMode: 1 m_StartGridSize: 70 m_LastFolders: - - Assets + - Assets/prefabs m_LastFoldersGridSize: 70 m_LastProjectPath: D:\Subnatuic Modding\ResourceMonitor\ResourceMonitor Unity Project m_IsLocked: 0 m_FolderTreeState: scrollPos: {x: 0, y: 0} - m_SelectedIDs: 26270000 - m_LastClickedID: 10022 + m_SelectedIDs: 74270000 + m_LastClickedID: 10100 m_ExpandedIDs: 000000002627000000ca9a3bffffff7f m_RenameOverlay: m_UserAcceptedRename: 0 @@ -437,8 +437,8 @@ MonoBehaviour: m_Icon: {fileID: 0} m_ResourceFile: m_ListAreaState: - m_SelectedInstanceIDs: 6413feff - m_LastClickedInstanceID: -126108 + m_SelectedInstanceIDs: + m_LastClickedInstanceID: 0 m_HadKeyboardFocusLastEvent: 1 m_ExpandedInstanceIDs: c62300005a1400007017000078170000f00d0000e262ffff3e28000000000000 m_RenameOverlay: @@ -528,23 +528,23 @@ MonoBehaviour: height: 634 m_TreeViewState: scrollPos: {x: 0, y: 0} - m_SelectedIDs: 6413feff - m_LastClickedID: -126108 - m_ExpandedIDs: 3601feff6813feff60f4ffff4efbffff80fbffffa0fbffffa4fbffffa6fbffff00000000 + m_SelectedIDs: + m_LastClickedID: 0 + m_ExpandedIDs: 48fbffff5afbffff80fbffffa0fbffffa4fbffffa6fbffff00000000 m_RenameOverlay: m_UserAcceptedRename: 0 - m_Name: IdleScreen - m_OriginalName: IdleScreen + m_Name: + m_OriginalName: m_EditFieldRect: serializedVersion: 2 x: 0 y: 0 width: 0 height: 0 - m_UserData: -126108 + m_UserData: 0 m_IsWaitingForDelay: 0 m_IsRenaming: 0 - m_OriginalEventType: 0 + m_OriginalEventType: 11 m_IsRenamingFilename: 0 m_ClientGUIView: {fileID: 4} m_SearchString: @@ -585,9 +585,9 @@ MonoBehaviour: m_isRotationLocked: 0 m_AudioPlay: 0 m_Position: - m_Target: {x: -0.009873722, y: -0.08379525, z: -0.3697785} + m_Target: {x: -0.036659535, y: 0.04360065, z: 0.29956484} speed: 2 - m_Value: {x: -0.009873722, y: -0.08379525, z: -0.3697785} + m_Value: {x: -0.036659535, y: 0.04360065, z: 0.29956484} m_RenderMode: 0 m_ValidateTrueMetals: 0 m_SceneViewState: @@ -610,9 +610,9 @@ MonoBehaviour: speed: 2 m_Value: 0 m_Rotation: - m_Target: {x: -0.0008759998, y: 0.99546325, z: -0.09469282, w: -0.009244689} + m_Target: {x: 0.00056211103, y: 0.9952013, z: -0.09768218, w: 0.0056855464} speed: 2 - m_Value: {x: -0.0008759998, y: 0.99546325, z: -0.09469282, w: -0.009244689} + m_Value: {x: 0.00056211103, y: 0.9952013, z: -0.09768218, w: 0.0056855464} m_Size: m_Target: 1.1984951 speed: 2 diff --git a/ResourceMonitor Unity Project/Library/LastBuild.buildreport b/ResourceMonitor Unity Project/Library/LastBuild.buildreport index 672bd8a..4de47d2 100644 Binary files a/ResourceMonitor Unity Project/Library/LastBuild.buildreport and b/ResourceMonitor Unity Project/Library/LastBuild.buildreport differ diff --git a/ResourceMonitor Unity Project/Library/assetDatabase3 b/ResourceMonitor Unity Project/Library/assetDatabase3 index 710eb69..a9b1579 100644 Binary files a/ResourceMonitor Unity Project/Library/assetDatabase3 and b/ResourceMonitor Unity Project/Library/assetDatabase3 differ diff --git a/ResourceMonitor/Components/ItemButton.cs b/ResourceMonitor/Components/ItemButton.cs index fa34a60..7b920e5 100644 --- a/ResourceMonitor/Components/ItemButton.cs +++ b/ResourceMonitor/Components/ItemButton.cs @@ -16,7 +16,7 @@ public TechType Type { set { - TextLineOne = TechTypeExtensions.Get(Language.main, value); + TextLineOne = "Take " + TechTypeExtensions.Get(Language.main, value); type = value; } diff --git a/ResourceMonitor/Components/OnScreenButton.cs b/ResourceMonitor/Components/OnScreenButton.cs index 55cb81b..0886f11 100644 --- a/ResourceMonitor/Components/OnScreenButton.cs +++ b/ResourceMonitor/Components/OnScreenButton.cs @@ -12,18 +12,32 @@ public abstract class OnScreenButton : MonoBehaviour protected bool IsHovered { get; set; } protected string TextLineOne { get; set; } protected string TextLineTwo { get; set; } + private bool isHoveredOutOfRange; public virtual void OnDisable() { IsHovered = false; + isHoveredOutOfRange = false; } public virtual void Update() { - if (IsHovered && InInteractionRange()) + bool inInteractionRange = InInteractionRange(); + + if (IsHovered && inInteractionRange) { HandReticle.main.SetInteractTextRaw(TextLineOne, TextLineTwo); } + + if (IsHovered && inInteractionRange == false) + { + IsHovered = false; + } + + if (IsHovered == false && isHoveredOutOfRange && inInteractionRange) + { + IsHovered = true; + } } public virtual void OnPointerEnter(PointerEventData eventData) @@ -33,12 +47,14 @@ public virtual void OnPointerEnter(PointerEventData eventData) IsHovered = true; } + isHoveredOutOfRange = true; ResourceMonitorDisplay.ResetIdleTimer(); } public virtual void OnPointerExit(PointerEventData eventData) { IsHovered = false; + isHoveredOutOfRange = false; ResourceMonitorDisplay.ResetIdleTimer(); } diff --git a/ResourceMonitor/Components/PaginatorButton.cs b/ResourceMonitor/Components/PaginatorButton.cs index ee3d44c..1309b47 100644 --- a/ResourceMonitor/Components/PaginatorButton.cs +++ b/ResourceMonitor/Components/PaginatorButton.cs @@ -34,11 +34,11 @@ public void OnEnable() public override void OnDisable() { - base.OnDisable(); if (text != null) { text.color = STARTING_COLOR; } + base.OnDisable(); } public override void OnPointerEnter(PointerEventData eventData) diff --git a/ResourceMonitor/Components/ResourceMonitorDisplay.cs b/ResourceMonitor/Components/ResourceMonitorDisplay.cs index ceaa150..d1bef12 100644 --- a/ResourceMonitor/Components/ResourceMonitorDisplay.cs +++ b/ResourceMonitor/Components/ResourceMonitorDisplay.cs @@ -24,12 +24,16 @@ public class ResourceMonitorDisplay : MonoBehaviour, IPointerClickHandler, IPoin }; public static readonly float MAX_INTERACTION_DISTANCE = 2.5f; - public static readonly float MAX_INTERACTION_IDLE_PAGE_DISTANCE = 10f; + public static readonly float MAX_INTERACTION_IDLE_PAGE_DISTANCE = 5f; private static readonly float WELCOME_ANIMATION_TIME = 8.5f; private static readonly float MAIN_SCREEN_ANIMATION_TIME = 1.2f; private static readonly int ITEMS_PER_PAGE = 12; private static readonly float IDLE_TIME = 20f; + private static readonly float IDLE_TIME_RANDOMNESS_LOW_BOUND = 1f; + private static readonly float IDLE_TIME_RANDOMNESS_HIGH_BOUND = 10f; private static readonly float IDLE_SCREEN_COLOR_TRANSITION_TIME = 2f; + private static readonly float IDLE_SCREEN_COLOR_TRANSITION_RANDOMNESS_HIGH_BOUND = 2f; + private static readonly float IDLE_SCREEN_COLOR_TRANSITION_RANDOMNESS_LOW_BOUND = 0f; public ResourceMonitorLogic ResourceMonitorLogic { get; private set; } private Dictionary trackedResourcesDisplayElements; @@ -39,9 +43,11 @@ public class ResourceMonitorDisplay : MonoBehaviour, IPointerClickHandler, IPoin private float timeSinceLastInteraction = 0f; private bool isIdle = false; private float nextColorTransitionCurrentTime; + private float transitionIdleTime; private Color currentColor = POSSIBLE_IDLE_COLORS[0]; private Color nextColor = POSSIBLE_IDLE_COLORS[1]; private bool isHovered = false; + private bool isHoveredOutOfRange = false; private Animator animator; private GameObject canvasGameObject; @@ -68,6 +74,7 @@ public void Setup(ResourceMonitorLogic rml) return; } + CalculateNewColourTransitionTime(); CalculateNewIdleTime(); currentPage = 1; UpdatePaginator(); @@ -178,7 +185,7 @@ private void ClearPage() private void CreateAndAddItemDisplay(TechType type, int amount) { - GameObject itemDisplay = Instantiate(EntryPoint.ResourceMonitorDisplayItemUIPrefab); + GameObject itemDisplay = Instantiate(EntryPoint.RESOURCE_MONITOR_DISPLAY_ITEM_UI_PREFAB); itemDisplay.transform.SetParent(mainScreenItemGrid.transform, false); itemDisplay.GetComponentInChildren().text = "x" + amount; @@ -205,6 +212,12 @@ public void Update() EnterIdleScreen(); } + if (isHovered == false && isHoveredOutOfRange == true && InIdleInteractionRange() == true) + { + isHovered = true; + ExitIdleScreen(); + } + if (isHovered == true) { ResetIdleTimer(); @@ -212,7 +225,7 @@ public void Update() if (isIdle == true) { - if (nextColorTransitionCurrentTime >= IDLE_SCREEN_COLOR_TRANSITION_TIME) + if (nextColorTransitionCurrentTime >= transitionIdleTime) { nextColorTransitionCurrentTime = 0f; for (int i = 0; i < POSSIBLE_IDLE_COLORS.Length; i++) @@ -226,16 +239,22 @@ public void Update() i = 0; } nextColor = POSSIBLE_IDLE_COLORS[i]; + CalculateNewColourTransitionTime(); } } } nextColorTransitionCurrentTime += Time.deltaTime; - idleScreenTitleBackgroundImage.color = Color.Lerp(currentColor, nextColor, nextColorTransitionCurrentTime / IDLE_SCREEN_COLOR_TRANSITION_TIME); + idleScreenTitleBackgroundImage.color = Color.Lerp(currentColor, nextColor, nextColorTransitionCurrentTime / transitionIdleTime); } } private bool InIdleInteractionRange() + { + return Mathf.Abs(Vector3.Distance(gameObject.transform.position, Player.main.transform.position)) <= MAX_INTERACTION_IDLE_PAGE_DISTANCE; + } + + private bool InInteractionRange() { return Mathf.Abs(Vector3.Distance(gameObject.transform.position, Player.main.transform.position)) <= MAX_INTERACTION_DISTANCE; } @@ -255,6 +274,7 @@ public void OnPointerClick(PointerEventData eventData) public void OnPointerEnter(PointerEventData eventData) { + isHoveredOutOfRange = true; if (InIdleInteractionRange()) { isHovered = true; @@ -273,6 +293,7 @@ public void OnPointerEnter(PointerEventData eventData) public void OnPointerExit(PointerEventData eventData) { + isHoveredOutOfRange = false; isHovered = false; if (isIdle && InIdleInteractionRange()) { @@ -303,7 +324,7 @@ private void ExitIdleScreen() private void CalculateNewIdleTime() { - idlePeriodLength = IDLE_TIME + UnityEngine.Random.Range(0f, 10f); + idlePeriodLength = IDLE_TIME + UnityEngine.Random.Range(IDLE_TIME_RANDOMNESS_LOW_BOUND, IDLE_TIME_RANDOMNESS_HIGH_BOUND); } public void ResetIdleTimer() @@ -311,6 +332,11 @@ public void ResetIdleTimer() timeSinceLastInteraction = 0f; } + private void CalculateNewColourTransitionTime() + { + transitionIdleTime = IDLE_SCREEN_COLOR_TRANSITION_TIME + UnityEngine.Random.Range(IDLE_SCREEN_COLOR_TRANSITION_RANDOMNESS_LOW_BOUND, IDLE_SCREEN_COLOR_TRANSITION_RANDOMNESS_HIGH_BOUND); + } + private bool FindAllComponents() { canvasGameObject = gameObject.GetComponentInChildren()?.gameObject; diff --git a/ResourceMonitor/Components/ResourceMonitorLogic.cs b/ResourceMonitor/Components/ResourceMonitorLogic.cs index 2bd4794..b93ad63 100644 --- a/ResourceMonitor/Components/ResourceMonitorLogic.cs +++ b/ResourceMonitor/Components/ResourceMonitorLogic.cs @@ -24,6 +24,7 @@ public class TrackedResource */ public class ResourceMonitorLogic : MonoBehaviour, IConstructable { + public static List DONT_TRACK_GAMEOBJECTS { get; private set; } = new List(); private static readonly float COOLDOWN_TIME_BETWEEN_PICKING_UP_LAST_ITEM_TYPE = 1f; public SortedDictionary TrackedResources { private set; get; } = new SortedDictionary(); @@ -139,6 +140,14 @@ private void TrackStorageContainer(StorageContainer sc) return; } + foreach (string notTrackedObject in DONT_TRACK_GAMEOBJECTS) + { + if (sc.gameObject.name.ToLower().Contains(notTrackedObject)) + { + return; + } + } + foreach (var item in sc.container.GetItemTypes()) { AddItemsToTracker(sc, item, sc.container.GetCount(item)); @@ -214,37 +223,32 @@ public void AttemptToTakeItem(TechType item) if (TrackedResources.ContainsKey(item)) { TrackedResource trackedResource = TrackedResources[item]; + int beforeRemoveAmount = trackedResource.Amount; if (trackedResource.Containers.Count >= 1) { StorageContainer sc = trackedResource.Containers.ElementAt(0); if (sc.container.Contains(item)) - { - GameObject gameObject = CraftData.InstantiateFromPrefab(item, false); - if (gameObject == null) - { - return; - } - - gameObject.transform.position = MainCamera.camera.transform.position + MainCamera.camera.transform.forward * 3f; - CrafterLogic.NotifyCraftEnd(gameObject, item); - Pickupable pickup = gameObject.GetComponent(); - if (pickup == null) + { + Pickupable pickup = sc.container.RemoveItem(item); + if (pickup != null) { - return; - } - - bool addResult = Inventory.main.Pickup(pickup); - if (addResult) - { - if (trackedResource.Amount == 1) + if (Inventory.main.Pickup(pickup)) + { + CrafterLogic.NotifyCraftEnd(Player.main.gameObject, item); + if (beforeRemoveAmount == 1) + { + timerTillNextPickup = COOLDOWN_TIME_BETWEEN_PICKING_UP_LAST_ITEM_TYPE; + } + } + else { - timerTillNextPickup = COOLDOWN_TIME_BETWEEN_PICKING_UP_LAST_ITEM_TYPE; + // If it fails to get added to the inventory lets add it back into the storage container. + sc.container.AddItem(pickup); } - sc.container.RemoveItem(item); } } } } } } -} +} \ No newline at end of file diff --git a/ResourceMonitor/EntryPoint.cs b/ResourceMonitor/EntryPoint.cs index c09a318..c76e444 100644 --- a/ResourceMonitor/EntryPoint.cs +++ b/ResourceMonitor/EntryPoint.cs @@ -1,4 +1,5 @@ using Harmony; +using System.IO; using System.Reflection; using UnityEngine; @@ -9,11 +10,13 @@ namespace ResourceMonitor */ public class EntryPoint { - public const string AssetsFolderLocation = "ResourceMonitor/Assets"; - public const string AssetBundleLocation = "./QMods/" + AssetsFolderLocation + "/resources"; - public static GameObject ResourceMonitorDisplayUIPrefab { private set; get; } - public static GameObject ResourceMonitorDisplayItemUIPrefab { private set; get; } - public static GameObject ResourceMonitorDisplayModel { private set; get; } + public static readonly string MOD_FOLDER_LOCATION = "./QMods/ResourceMonitor/"; + public static readonly string ASSETS_FOLDER_LOCATION = MOD_FOLDER_LOCATION + "Assets/"; + public static readonly string ASSET_BUNDLE_LOCATION = ASSETS_FOLDER_LOCATION + "resources"; + public static readonly string SETTINGS_FILE_LOCATION = MOD_FOLDER_LOCATION + "DontTrackList.txt"; + public static GameObject RESOURCE_MONITOR_DISPLAY_UI_PREFAB { private set; get; } + public static GameObject RESOURCE_MONITOR_DISPLAY_ITEM_UI_PREFAB { private set; get; } + public static GameObject RESOURCE_MONITOR_DISPLAY_MODEL { private set; get; } /** * Entry method. @@ -25,14 +28,38 @@ public static void Entry() new Game_Items.ResourceMonitorScreenLarge().Patch(); new Game_Items.ResourceMonitorScreenSmall().Patch(); LoadAssets(); + LoadDontTrackList(); } private static void LoadAssets() { - AssetBundle ab = AssetBundle.LoadFromFile(AssetBundleLocation); - ResourceMonitorDisplayUIPrefab = ab.LoadAsset("ResourceMonitorDisplayUI") as GameObject; - ResourceMonitorDisplayItemUIPrefab = ab.LoadAsset("ResourceItem") as GameObject; - ResourceMonitorDisplayModel = ab.LoadAsset("ResourceMonitorModel") as GameObject; + AssetBundle ab = AssetBundle.LoadFromFile(ASSET_BUNDLE_LOCATION); + RESOURCE_MONITOR_DISPLAY_UI_PREFAB = ab.LoadAsset("ResourceMonitorDisplayUI") as GameObject; + RESOURCE_MONITOR_DISPLAY_ITEM_UI_PREFAB = ab.LoadAsset("ResourceItem") as GameObject; + RESOURCE_MONITOR_DISPLAY_MODEL = ab.LoadAsset("ResourceMonitorModel") as GameObject; + } + + private static void LoadDontTrackList() + { + if (File.Exists(SETTINGS_FILE_LOCATION)) + { + System.Console.WriteLine("[ResourceMonitor] Found the dont track list at location: " + SETTINGS_FILE_LOCATION); + using (StreamReader reader = new StreamReader(SETTINGS_FILE_LOCATION)) + { + string line; + while ((line = reader.ReadLine()) != null) + { + if (string.IsNullOrEmpty(line) == false) + { + Components.ResourceMonitorLogic.DONT_TRACK_GAMEOBJECTS.Add(line); + } + } + } + } + else + { + System.Console.WriteLine("[ResourceMonitor] Did not find the dont track list at location: " + SETTINGS_FILE_LOCATION); + } } } } diff --git a/ResourceMonitor/Game Items/ResourceMonitorScreenGeneric.cs b/ResourceMonitor/Game Items/ResourceMonitorScreenGeneric.cs index 25afea4..d0de5b5 100644 --- a/ResourceMonitor/Game Items/ResourceMonitorScreenGeneric.cs +++ b/ResourceMonitor/Game Items/ResourceMonitorScreenGeneric.cs @@ -8,7 +8,7 @@ namespace ResourceMonitor.Game_Items */ public abstract class ResourceMonitorScreenGeneric : Buildable { - public override string AssetsFolder => EntryPoint.AssetsFolderLocation; + public override string AssetsFolder => EntryPoint.ASSETS_FOLDER_LOCATION; public override TechGroup GroupForPDA => TechGroup.InteriorModules; public override TechCategory CategoryForPDA => TechCategory.InteriorModule; @@ -18,7 +18,8 @@ protected ResourceMonitorScreenGeneric(string classId, string friendlyName, stri public override GameObject GetGameObject() { - GameObject screen = Object.Instantiate(EntryPoint.ResourceMonitorDisplayModel); + GameObject screen = Object.Instantiate(EntryPoint.RESOURCE_MONITOR_DISPLAY_MODEL); + GameObject screenModel = screen.transform.GetChild(0).gameObject; Shader shader = Shader.Find("MarmosetUBER"); Renderer[] renderers = screen.GetComponentsInChildren(); @@ -36,16 +37,15 @@ public override GameObject GetGameObject() constructable.allowedInSub = true; constructable.allowedOnGround = false; constructable.allowedOutside = false; - constructable.model = screen.transform.GetChild(0).gameObject; + constructable.model = screenModel; constructable.techType = this.TechType; BoxCollider boxCollider = screen.GetComponent(); - screen.AddComponent().bounds = new OrientedBounds(boxCollider.center, boxCollider.transform.rotation, new Vector3(boxCollider.size.x, boxCollider.size.y, 0f)); + screen.AddComponent().bounds = new OrientedBounds(new Vector3(-0.1f, -0.1f, 0f), new Quaternion(0, 0, 0, 0), new Vector3(0.9f, 0.5f, 0f)); screen.AddComponent().type = this.TechType; - screen.AddComponent(); screen.AddComponent().ClassId = ClassID; screen.AddComponent(); - screen.AddComponent().cellLevel = LargeWorldEntity.CellLevel.Near; // CHECK WHAT THIS DOES + screen.AddComponent(); return screen; } }