狗屎Minimax坏我代码

This commit is contained in:
SoulliesOfficial
2026-04-18 13:57:19 -04:00
parent 41140a2017
commit 7379583165
473 changed files with 34480 additions and 8069 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 57a8fba7ccba44e0b7981a248487550f
timeCreated: 1773740972

View File

@@ -0,0 +1,21 @@
#if TMP_PRESENT
using TMPro;
namespace SickscoreGames.HUDNavigationSystem.Adapters
{
public class HNSTextAdapter_TMP : IHNSTextAdapter
{
private TextMeshProUGUI _text;
public HNSTextAdapter_TMP(TextMeshProUGUI text)
{
_text = text;
}
public void SetText(string text)
{
_text.text = text;
}
}
}
#endif

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 9d85ff5f60304b2c8a2b3ec6eea80b6a
timeCreated: 1773741624
AssetOrigin:
serializedVersion: 1
productId: 103056
packageName: HUD Navigation System
packageVersion: 3.0.0
assetPath: Assets/OtherPlugins/HUD-Navigation-System/Scripts/Utilities/Adapters/HNSTextAdapter_TMP.cs
uploadId: 884440

View File

@@ -0,0 +1,19 @@
using UnityEngine.UI;
namespace SickscoreGames.HUDNavigationSystem.Adapters
{
public class HNSTextAdapter_UI : IHNSTextAdapter
{
private Text _text;
public HNSTextAdapter_UI(Text text)
{
_text = text;
}
public void SetText(string text)
{
_text.text = text;
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 7e48b9ad97ec458f85f1f2c52d5dae6d
timeCreated: 1773741782
AssetOrigin:
serializedVersion: 1
productId: 103056
packageName: HUD Navigation System
packageVersion: 3.0.0
assetPath: Assets/OtherPlugins/HUD-Navigation-System/Scripts/Utilities/Adapters/HNSTextAdapter_UI.cs
uploadId: 884440

View File

@@ -1,9 +1,6 @@
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using SickscoreGames;
namespace SickscoreGames.HUDNavigationSystem
{

View File

@@ -15,6 +15,6 @@ AssetOrigin:
serializedVersion: 1
productId: 103056
packageName: HUD Navigation System
packageVersion: 2.2.0
assetPath: Assets/Sickscore Games/HUD-Navigation-System/Scripts/Utilities/Editor/HNSDocumentation.cs
uploadId: 382610
packageVersion: 3.0.0
assetPath: Assets/OtherPlugins/HUD-Navigation-System/Scripts/Utilities/Editor/HNSDocumentation.cs
uploadId: 884440

View File

@@ -1,12 +1,7 @@
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using SickscoreGames;
namespace SickscoreGames.HUDNavigationSystem
{
@@ -42,7 +37,7 @@ namespace SickscoreGames.HUDNavigationSystem
#region Utility Methods
private static void CheckInstance<T> (int instanceId, Rect selectionRect, string iconName) where T : UnityEngine.Object
{
GameObject go = EditorUtility.InstanceIDToObject(instanceId) as GameObject;
GameObject go = HUDNavigationExtensions.EntityOrInstanceIdToObject(instanceId) as GameObject;
if (go == null) return;
if (go.GetComponent<T> () != null)
DrawIcon(iconName, selectionRect);

View File

@@ -13,6 +13,6 @@ AssetOrigin:
serializedVersion: 1
productId: 103056
packageName: HUD Navigation System
packageVersion: 2.2.0
assetPath: Assets/Sickscore Games/HUD-Navigation-System/Scripts/Utilities/Editor/HNSEditorIcons.cs
uploadId: 382610
packageVersion: 3.0.0
assetPath: Assets/OtherPlugins/HUD-Navigation-System/Scripts/Utilities/Editor/HNSEditorIcons.cs
uploadId: 884440

View File

@@ -0,0 +1,65 @@
using UnityEditor;
using UnityEngine;
namespace SickscoreGames.HUDNavigationSystem
{
[CustomEditor(typeof(HNSTextReference))]
public class HNSTextReferenceEditor : HUDNavigationBaseEditor
{
#region Variables
protected HNSTextReference hudTarget;
#endregion
#region Main Methods
void OnEnable()
{
editorTitle = "HNS Text Reference";
splashTexture = (Texture2D)Resources.Load("Textures/splashTexture_TextReference", typeof(Texture2D));
showExpandButton = false;
hudTarget = (HNSTextReference)target;
}
protected override void OnBaseInspectorGUI()
{
// update serialized object
serializedObject.Update();
// get the text adapter
var adapter = hudTarget.GetAdapter();
// cache serialized properties
SerializedProperty _pTextComponent = serializedObject.FindProperty("_textComponent");
EditorGUILayout.PropertyField(_pTextComponent, new GUIContent("Text Component", "The text component which will get updated"));
EditorGUILayout.LabelField("Adapter", adapter?.GetType().Name ?? "<none>");
if (adapter == null)
{
EditorGUILayout.Space();
if (hudTarget.GetTextComponent() != null)
EditorGUILayout.HelpBox("Assigned component is not a valid text adapter.", MessageType.Error);
else
EditorGUILayout.HelpBox("No supported text component detected.", MessageType.Warning);
if (!Application.isPlaying)
{
if (GUILayout.Button("Refresh"))
{
hudTarget.ForceInitialize();
}
}
}
// apply modified properties
serializedObject.ApplyModifiedProperties ();
}
#endregion
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 3624fe1881f44ed59e430ff886406935
timeCreated: 1773743684
AssetOrigin:
serializedVersion: 1
productId: 103056
packageName: HUD Navigation System
packageVersion: 3.0.0
assetPath: Assets/OtherPlugins/HUD-Navigation-System/Scripts/Utilities/Editor/HNSTextReferenceEditor.cs
uploadId: 884440

View File

@@ -1,11 +1,5 @@
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Serialization;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.IMGUI.Controls;

View File

@@ -15,6 +15,6 @@ AssetOrigin:
serializedVersion: 1
productId: 103056
packageName: HUD Navigation System
packageVersion: 2.2.0
assetPath: Assets/Sickscore Games/HUD-Navigation-System/Scripts/Utilities/Editor/HNSTextureCreatorEditor.cs
uploadId: 382610
packageVersion: 3.0.0
assetPath: Assets/OtherPlugins/HUD-Navigation-System/Scripts/Utilities/Editor/HNSTextureCreatorEditor.cs
uploadId: 884440

View File

@@ -1,8 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using UnityEditor;
using SickscoreGames;
namespace SickscoreGames.HUDNavigationSystem
{
@@ -90,14 +87,14 @@ namespace SickscoreGames.HUDNavigationSystem
return;
// add hud navigation system to scene
HUDNavigationSystem hudSystem = GameObject.FindObjectOfType<HUDNavigationSystem> ();
HUDNavigationSystem hudSystem = HUDNavigationExtensions.FindFirst<HUDNavigationSystem> ();
if (hudSystem == null) {
GameObject hnsGO = new GameObject("[HUD Navigation System]");
hudSystem = hnsGO.AddComponent<HUDNavigationSystem> ();
}
// add scene manager to scene
HUDNavigationSceneManager sceneManager = GameObject.FindObjectOfType<HUDNavigationSceneManager> ();
HUDNavigationSceneManager sceneManager = HUDNavigationExtensions.FindFirst<HUDNavigationSceneManager> ();
if (sceneManager == null)
hudSystem.gameObject.AddComponent<HUDNavigationSceneManager> ();
@@ -106,7 +103,7 @@ namespace SickscoreGames.HUDNavigationSystem
hudSystem.PlayerCamera = goCamera;
// add hud navigation canvas to scene
HUDNavigationCanvas hudCanvas = GameObject.FindObjectOfType<HUDNavigationCanvas> ();
HUDNavigationCanvas hudCanvas = HUDNavigationExtensions.FindFirst<HUDNavigationCanvas> ();
if (hudCanvas == null) {
// add canvas prefab from assets to scene
GameObject hudPrefab = Resources.Load ("Prefabs/HUD Navigation Canvas") as GameObject;

View File

@@ -15,6 +15,6 @@ AssetOrigin:
serializedVersion: 1
productId: 103056
packageName: HUD Navigation System
packageVersion: 2.2.0
assetPath: Assets/Sickscore Games/HUD-Navigation-System/Scripts/Utilities/Editor/HUDNavigationSystem_QSWindow.cs
uploadId: 382610
packageVersion: 3.0.0
assetPath: Assets/OtherPlugins/HUD-Navigation-System/Scripts/Utilities/Editor/HUDNavigationSystem_QSWindow.cs
uploadId: 884440

View File

@@ -0,0 +1,114 @@
using SickscoreGames.HUDNavigationSystem.Adapters;
using UnityEngine;
using UnityEngine.UI;
#if TMP_PRESENT
using TMPro;
#endif
namespace SickscoreGames.HUDNavigationSystem
{
[DisallowMultipleComponent]
public class HNSTextReference : MonoBehaviour
{
#region Variables
[SerializeField] private Component _textComponent;
private IHNSTextAdapter _adapter;
#endregion
#region Main Methods
private void Awake()
{
Initialize();
}
#if UNITY_EDITOR
private void OnValidate()
{
if (!Application.isPlaying)
Initialize();
}
#endif
private void Initialize()
{
// create adapter from component
if (_textComponent != null)
{
_adapter = CreateAdapter(_textComponent);
if (_adapter != null)
return;
Debug.LogWarning($"[HNSTextReference] Assigned component is not supported: {_textComponent.GetType().Name}", this);
}
// try to auto-detect text component
_textComponent = AutoDetectComponent();
if (_textComponent != null)
{
_adapter = CreateAdapter(_textComponent);
return;
}
_adapter = null;
}
#endregion
#region Utility Methods
private Component AutoDetectComponent()
{
#if TMP_PRESENT
// TextMeshPro
if (HUDNavigationExtensions.TryGet(this, out TextMeshProUGUI tmp))
return tmp;
#endif
// UI Text (legacy)
if (HUDNavigationExtensions.TryGet(this, out Text uiText))
return uiText;
// Third-party adapter
var adapters = GetComponents<IHNSTextAdapter>();
if (adapters.Length > 0)
// ReSharper disable once SuspiciousTypeConversion.Global
return adapters[0] as Component;
return null;
}
private IHNSTextAdapter CreateAdapter(Component component)
{
#if TMP_PRESENT
if (component is TextMeshProUGUI tmp)
return new HNSTextAdapter_TMP(tmp);
#endif
if (component is Text uiText)
return new HNSTextAdapter_UI(uiText);
// ReSharper disable once SuspiciousTypeConversion.Global
if (component is IHNSTextAdapter adapter)
return adapter;
return null;
}
#endregion
#region Public API
public void SetText(string value)
{
_adapter?.SetText(value);
}
public IHNSTextAdapter GetAdapter() => _adapter;
public Component GetTextComponent() => _textComponent;
public void ForceInitialize() => Initialize();
#endregion
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 5ecc4b41a1574f739f1ddc6af9d0b0fe
timeCreated: 1773738709
AssetOrigin:
serializedVersion: 1
productId: 103056
packageName: HUD Navigation System
packageVersion: 3.0.0
assetPath: Assets/OtherPlugins/HUD-Navigation-System/Scripts/Utilities/HNSTextReference.cs
uploadId: 884440

View File

@@ -1,12 +1,9 @@
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using SickscoreGames;
namespace SickscoreGames.HUDNavigationSystem
{
@@ -45,7 +42,7 @@ namespace SickscoreGames.HUDNavigationSystem
public static void InitTextureCreator ()
{
// find / instantiate TextureCreator
HNSTextureCreator textureCreator = FindObjectOfType<HNSTextureCreator> ();
HNSTextureCreator textureCreator = HUDNavigationExtensions.FindFirst<HNSTextureCreator> ();
if (textureCreator == null)
textureCreator = new GameObject ("HNS MapTextureCreator").AddComponent<HNSTextureCreator> ();
@@ -270,6 +267,10 @@ namespace SickscoreGames.HUDNavigationSystem
if (textureImporter.textureType != TextureImporterType.Sprite)
textureImporter.textureType = TextureImporterType.Sprite;
// set sprite mode to single
if (textureImporter.spriteImportMode != SpriteImportMode.Single)
textureImporter.spriteImportMode = SpriteImportMode.Single;
// update texture size
if (textureImporter.maxTextureSize != (int)TextureSize)
textureImporter.maxTextureSize = (int)TextureSize;

View File

@@ -15,6 +15,6 @@ AssetOrigin:
serializedVersion: 1
productId: 103056
packageName: HUD Navigation System
packageVersion: 2.2.0
assetPath: Assets/Sickscore Games/HUD-Navigation-System/Scripts/Utilities/HNSTextureCreator.cs
uploadId: 382610
packageVersion: 3.0.0
assetPath: Assets/OtherPlugins/HUD-Navigation-System/Scripts/Utilities/HNSTextureCreator.cs
uploadId: 884440

View File

@@ -1,12 +1,5 @@
using System;
using System.Linq;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using SickscoreGames;
namespace SickscoreGames.HUDNavigationSystem
{
@@ -55,6 +48,20 @@ namespace SickscoreGames.HUDNavigationSystem
}
public static Vector3 KeepInCircleBounds (this RectTransform rect, Vector3 markerPos, out bool outOfBounds)
{
Vector3 center = rect.rect.center;
float radius = Mathf.Min(rect.rect.width, rect.rect.height) * 0.5f;
Vector3 offset = markerPos - center;
Vector3 clamped = Vector3.ClampMagnitude(offset, radius);
outOfBounds = offset != clamped;
return center + clamped;
}
public static float GetIconRadius (this HUDNavigationElement element, NavigationElementType elementType)
{
float radius = (elementType == NavigationElementType.Radar) ? element.Radar.PrefabRect.sizeDelta.x : element.Minimap.PrefabRect.sizeDelta.x;
@@ -163,7 +170,7 @@ namespace SickscoreGames.HUDNavigationSystem
#region CompassBar Extension Methods
public static void ShowCompassBarDistance (this HUDNavigationElement element, int distance = 0)
{
if (element.CompassBar.DistanceText == null)
if (!element.CompassBar.DistanceText)
return;
// only update if value has changed
@@ -172,8 +179,8 @@ namespace SickscoreGames.HUDNavigationSystem
element.CompassBar.DistanceText.gameObject.SetActive (useDistanceText);
// update distance text if active
if (useDistanceText) // TODO add TextMeshPro support?
element.CompassBar.DistanceText.text = string.Format (element.compassBarDistanceTextFormat, distance);
if (useDistanceText)
element.CompassBar.DistanceText.SetText(string.Format (element.compassBarDistanceTextFormat, distance));
}
#endregion
@@ -198,17 +205,17 @@ namespace SickscoreGames.HUDNavigationSystem
public static void ShowIndicatorDistance (this HUDNavigationElement element, bool onScreen, int distance = 0)
{
// show/hide distance text
Text distanceText = (onScreen) ? element.Indicator.OnscreenDistanceText : element.Indicator.OffscreenDistanceText;
if (distanceText != null) {
bool showDistance = (onScreen) ? element.useIndicatorDistanceText : element.useIndicatorDistanceText && element.showOffscreenIndicatorDistance;
var distanceText = onScreen ? element.Indicator.OnscreenDistanceText : element.Indicator.OffscreenDistanceText;
if (distanceText) {
bool showDistance = onScreen ? element.useIndicatorDistanceText : element.useIndicatorDistanceText && element.showOffscreenIndicatorDistance;
// only update if value has changed
if (showDistance != distanceText.gameObject.activeSelf)
distanceText.gameObject.SetActive (showDistance);
// update distance text if active
if (showDistance) // TODO add TextMeshPro support?
distanceText.text = string.Format ((onScreen) ? element.indicatorOnscreenDistanceTextFormat : element.indicatorOffscreenDistanceTextFormat, distance);
if (showDistance)
distanceText.SetText(string.Format (onScreen ? element.indicatorOnscreenDistanceTextFormat : element.indicatorOffscreenDistanceTextFormat, distance));
}
}
@@ -291,5 +298,36 @@ namespace SickscoreGames.HUDNavigationSystem
return (float)profile.MapTextureSize.x / (float)profile.MapTextureSize.y;
}
#endregion
#region General Extension Methods
public static T FindFirst<T>() where T : Object
{
#if UNITY_2023_1_OR_NEWER
return GameObject.FindFirstObjectByType<T>();
#else
return Object.FindObjectOfType<T>();
#endif
}
public static bool TryGet<T>(Component component, out T result) where T : Component
{
#if UNITY_2019_2_OR_NEWER
return component.TryGetComponent(out result);
#else
result = component.GetComponent<T>();
return result != null;
#endif
}
public static Object EntityOrInstanceIdToObject(int id)
{
#if UNITY_2023_1_OR_NEWER
return EditorUtility.EntityIdToObject(id);
#else
return EditorUtility.InstanceIDToObject(id);
#endif
}
#endregion
}
}

View File

@@ -14,6 +14,6 @@ AssetOrigin:
serializedVersion: 1
productId: 103056
packageName: HUD Navigation System
packageVersion: 2.2.0
assetPath: Assets/Sickscore Games/HUD-Navigation-System/Scripts/Utilities/HUDNavigationExtensions.cs
uploadId: 382610
packageVersion: 3.0.0
assetPath: Assets/OtherPlugins/HUD-Navigation-System/Scripts/Utilities/HUDNavigationExtensions.cs
uploadId: 884440

View File

@@ -0,0 +1,7 @@
namespace SickscoreGames.HUDNavigationSystem
{
public interface IHNSTextAdapter
{
void SetText(string text);
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 2dcc006e740743efa40392f576a56dd4
timeCreated: 1773740708
AssetOrigin:
serializedVersion: 1
productId: 103056
packageName: HUD Navigation System
packageVersion: 3.0.0
assetPath: Assets/OtherPlugins/HUD-Navigation-System/Scripts/Utilities/IHNSTextAdapter.cs
uploadId: 884440