分散文件结构,添加了枚举类型的一个辅助类
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d0b936e6a4957548b70fbc19a5d4e70
|
||||
guid: 861e0bb053777664c8fd1ff8f6a125d7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
33
Editor/CustomDrawer/ReName.cs
Normal file
33
Editor/CustomDrawer/ReName.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEditor;
|
||||
using XericLibrary.Runtime.CustomDrawer;
|
||||
|
||||
namespace XericLibrary.Editor.CustomDrawer
|
||||
{
|
||||
|
||||
[CustomPropertyDrawer(typeof(ReNameAttribute))]
|
||||
public class ReNameDrawer : PropertyDrawer
|
||||
{
|
||||
private GUIContent lable = null;
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if(lable == null)
|
||||
{
|
||||
string name = (attribute as ReNameAttribute).Name;
|
||||
lable = new GUIContent(name);
|
||||
}
|
||||
|
||||
EditorGUI.PropertyField(position, property, lable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5c96d394d80e624296ef2777a48dc07
|
||||
guid: 16413afe09f44374d8cdefbe1fcb6960
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,30 +0,0 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// Use this editor example C# file to develop editor (non-runtime) code.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
namespace Lrss3.XericLibrary.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// Provide a general description of the public class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Packages require XmlDoc documentation for ALL Package APIs.
|
||||
/// https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/xml-documentation-comments
|
||||
/// </remarks>
|
||||
public class MyPublicEditorExampleClass
|
||||
{
|
||||
/// <summary>
|
||||
/// Provide a description of what this private method does.
|
||||
/// </summary>
|
||||
/// <param name="parameter1"> Description of parameter 1 </param>
|
||||
/// <param name="parameter2"> Description of parameter 2 </param>
|
||||
/// <param name="parameter3"> Description of parameter 3 </param>
|
||||
/// <returns> Description of what the function returns </returns>
|
||||
public int CountThingsAndDoStuff(int parameter1, int parameter2, bool parameter3)
|
||||
{
|
||||
return parameter3 ? (parameter1 + parameter2) : (parameter1 - parameter2);
|
||||
}
|
||||
}
|
||||
}
|
||||
7
LICENSE.meta
Normal file
7
LICENSE.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b35ade651ed44bb43883217ce64b221b
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78c744bdc2c69df4fafba296e39987eb
|
||||
guid: 5acfcc21434615842ba9b630afcffe60
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
18
Runtime/CustomDrawer/ReName.cs
Normal file
18
Runtime/CustomDrawer/ReName.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.CustomDrawer
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class ReNameAttribute : PropertyAttribute
|
||||
{
|
||||
public string Name;
|
||||
public ReNameAttribute(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96cbfb583c534f946950be81e68280f0
|
||||
guid: a38c2728078def2458ddbe0163f6a1d9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48d0ca12b8b36464aa6264d8aff7940c
|
||||
guid: 10fcb4f8258542744b6a1e2b639a4d86
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
148
Runtime/Logger/MergeDebug.cs
Normal file
148
Runtime/Logger/MergeDebug.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
using log4net.Util;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
using static Codice.CM.WorkspaceServer.WorkspaceTreeDataStore;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// Merged debug messages
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <20>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ̫<CEAA><CCAB><EFBFBD><EFBFBD>̫ϸ<CCAB>鵼<EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>飬
|
||||
/// <20><><EFBFBD>ʺ<EFBFBD>ʹ<EFBFBD>úϲ<C3BA><CFB2><EFBFBD>Ϣ<EFBFBD><CFA2>
|
||||
/// </remarks>
|
||||
public class MergeDebug
|
||||
{
|
||||
#region <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>η<EFBFBD><CEB7><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD>
|
||||
/// </summary>
|
||||
private const int debugInfomationLengthLimit = 4000;
|
||||
|
||||
/// <summary>
|
||||
/// <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
private StringBuilder messageContext;
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD>
|
||||
|
||||
public MergeDebug()
|
||||
{
|
||||
messageContext = new StringBuilder();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
|
||||
/// <summary>
|
||||
/// Push the message content
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ѹ<><D1B9><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||
/// </remarks>
|
||||
public void PushLog(string message)
|
||||
{
|
||||
messageContext.Append(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Push the message content, with a line feed
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ѹ<><D1B9><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD>ĩβ<CEB2><D7B7>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD>
|
||||
/// </remarks>
|
||||
public void PushLogLine(string message)
|
||||
{
|
||||
messageContext.AppendLine(message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
|
||||
private static bool IsNewLine(char c)
|
||||
{
|
||||
return c == '\n' || c == '\r';
|
||||
}
|
||||
|
||||
private static void PopLog(StringBuilder sb, Action<string> debugFunc)
|
||||
{
|
||||
//debugInfomationLengthLimit
|
||||
var context = sb.ToString();
|
||||
|
||||
int startIndex = 0;
|
||||
int endIndex = 0;
|
||||
|
||||
while(startIndex < context.Length)
|
||||
{
|
||||
endIndex = Math.Min(startIndex + debugInfomationLengthLimit, context.Length);
|
||||
|
||||
while(endIndex > startIndex && !IsNewLine(context[endIndex - 1]))
|
||||
{
|
||||
endIndex--;
|
||||
}
|
||||
|
||||
string line = context.Substring(startIndex, endIndex - startIndex);
|
||||
debugFunc(line);
|
||||
|
||||
startIndex = endIndex;
|
||||
while(startIndex < context.Length && IsNewLine(context[startIndex]))
|
||||
{
|
||||
startIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send information in a message type
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <20><><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
/// </remarks>
|
||||
public void Log()
|
||||
{
|
||||
PopLog(messageContext, a => Debug.Log(a));
|
||||
messageContext.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send information in a Warning type
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <20>Ծ<EFBFBD><D4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
/// </remarks>
|
||||
public void LogWarning()
|
||||
{
|
||||
PopLog(messageContext, a => Debug.LogWarning(a));
|
||||
messageContext.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send information in a Error type
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <20>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
/// </remarks>
|
||||
public void LogError()
|
||||
{
|
||||
PopLog(messageContext, a => Debug.LogError(a));
|
||||
messageContext.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5fc80c26917602543b1db1cc73b00d15
|
||||
guid: 12ca18e1b72f65247a03c7f98672eb00
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,6 +1,14 @@
|
||||
{
|
||||
"name": "Lrss3.XericLibrary",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": []
|
||||
}
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: caece903f4fbc394989879cffabbbd4c
|
||||
guid: c3fe6ea067e41f047a94cf2f23dbd2d8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
98
Runtime/MicroLibrary/MacroConst.cs
Normal file
98
Runtime/MicroLibrary/MacroConst.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
public static partial class MacroMath
|
||||
{
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ת<EFBFBD>Ƕ<EFBFBD>
|
||||
/// </summary>
|
||||
public const float Rad2Ang = 57.295779513082320876798154814105f;
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ת<EFBFBD>Ƕ<EFBFBD>
|
||||
/// </summary>
|
||||
public const double Rad2Ang_d = 57.295779513082320876798154814105d;
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ת<EFBFBD>Ƕ<EFBFBD>
|
||||
/// </summary>
|
||||
public const decimal Rad2Ang_m = 57.295779513082320876798154814105m;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20>Ƕ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public const float Ang2Rad = .01745329251994329576923690768489f;
|
||||
/// <summary>
|
||||
/// <20>Ƕ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public const double Ang2Rad_d = .01745329251994329576923690768489d;
|
||||
/// <summary>
|
||||
/// <20>Ƕ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public const decimal Ang2Rad_m = .01745329251994329576923690768489m;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public const float MaxError = .000001f;
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public const double MaxError_d = .0000001d;
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public const decimal MaxError_m = .00000001m;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>2<EFBFBD><32>һ<EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>
|
||||
/// </summary>
|
||||
public const float Sqrt22 = 0.70710678118654752440084436210485f;
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>2<EFBFBD><32>һ<EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>
|
||||
/// </summary>
|
||||
public const double Sqrt22_d = 0.70710678118654752440084436210485d;
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>2<EFBFBD><32>һ<EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>
|
||||
/// </summary>
|
||||
public const decimal Sqrt22_m = 0.70710678118654752440084436210485m;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20>Ѹ<EFBFBD><D1B8><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷֲ漰<D6B2><E6BCB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿ڱ仯<DAB1><E4BBAF>ˮ<EFBFBD><CBAE><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public const float Feigenbaum = 4.669201609102990671853203820466201617258185577475768632745651343004134f;
|
||||
/// <summary>
|
||||
/// <20>Ѹ<EFBFBD><D1B8><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷֲ漰<D6B2><E6BCB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿ڱ仯<DAB1><E4BBAF>ˮ<EFBFBD><CBAE><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public const double Feigenbaum_d = 4.669201609102990671853203820466201617258185577475768632745651343004134d;
|
||||
/// <summary>
|
||||
/// <20>Ѹ<EFBFBD><D1B8><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷֲ漰<D6B2><E6BCB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿ڱ仯<DAB1><E4BBAF>ˮ<EFBFBD><CBAE><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public const decimal Feigenbaum_m = 4.669201609102990671853203820466201617258185577475768632745651343004134m;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ʾ<EFBFBD><CABE>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>ʸ<EFBFBD><CAB8>
|
||||
/// </summary>
|
||||
public static readonly Vector3Int Vector3Int_Negate = new Vector3Int(-1, -1, -1);
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ʾ<EFBFBD><CABE>Ч<EFBFBD>Ķ<EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>ʸ<EFBFBD><CAB8>
|
||||
/// </summary>
|
||||
public static readonly Vector2Int Vector2Int_Negate = new Vector2Int(-1, -1);
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ʾ<EFBFBD><CABE>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public static readonly int Int_Negate = -1;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf363a55b6e618c44a48334e02a8e03a
|
||||
guid: fc508d99ffe561a488e1a2a002f20871
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
144
Runtime/MicroLibrary/MacroEnum.cs
Normal file
144
Runtime/MicroLibrary/MacroEnum.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Unity.VisualScripting.YamlDotNet.Core.Tokens;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// ö<>ٺ꣬<D9BA><EAA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public class MacroEnum<T>
|
||||
where T: struct, Enum
|
||||
{
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
/// </summary>
|
||||
private Array valueArray;
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
private string[] nameArray;
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ö<EFBFBD>ٸ<EFBFBD><D9B8><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public MacroEnum()
|
||||
{
|
||||
valueArray = typeof(T).GetEnumValues();
|
||||
nameArray = typeof(T).GetEnumNames();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD>б<EFBFBD>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<T> GetValues()
|
||||
{
|
||||
foreach(var type in valueArray)
|
||||
yield return (T)type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD>б<EFBFBD>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<string> GetNames()
|
||||
{
|
||||
foreach(var type in nameArray)
|
||||
yield return type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡö<C8A1><C3B6><EFBFBD><EFBFBD>Ŀ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<(string, T)> GetEnums()
|
||||
{
|
||||
var output = nameArray
|
||||
.Zip(GetValues(), (name, value) => (name, value));
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>ö<EFBFBD><C3B6>ֵ
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="values"></param>
|
||||
public static void SetEnum(ref int target, params T[] values)
|
||||
{
|
||||
foreach(var value in values)
|
||||
{
|
||||
target |= Convert.ToInt32(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>ö<EFBFBD><C3B6>ֵ
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="values"></param>
|
||||
public static void SetEnum(ref int target, T value)
|
||||
{
|
||||
target |= Convert.ToInt32(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>λĿ<CEBB><C4BF><EFBFBD><EFBFBD>ö<EFBFBD><C3B6>ֵ
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="values"></param>
|
||||
public static void ResetEnum(ref int target, params T[] values)
|
||||
{
|
||||
int temp = 0;
|
||||
foreach(var value in values)
|
||||
{
|
||||
temp |= Convert.ToInt32(value);
|
||||
}
|
||||
target &= ~temp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>λĿ<CEBB><C4BF><EFBFBD><EFBFBD>ö<EFBFBD><C3B6>ֵ
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="values"></param>
|
||||
public static void ResetEnum(ref int target, T value)
|
||||
{
|
||||
target &= ~Convert.ToInt32(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>תĿ<D7AA><C4BF><EFBFBD><EFBFBD>ö<EFBFBD><C3B6>ֵ
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="values"></param>
|
||||
public static void FlipEnum(ref int target, params T[] values)
|
||||
{
|
||||
int temp = 0;
|
||||
foreach(var value in values)
|
||||
{
|
||||
temp |= Convert.ToInt32(value);
|
||||
}
|
||||
target ^= temp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>תĿ<D7AA><C4BF><EFBFBD><EFBFBD>ö<EFBFBD><C3B6>ֵ
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="values"></param>
|
||||
public static void FlipEnum(ref int target, T value)
|
||||
{
|
||||
target ^= Convert.ToInt32(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/MicroLibrary/MacroEnum.cs.meta
Normal file
11
Runtime/MicroLibrary/MacroEnum.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94a45cbae926bdb4e9a05c822232c00b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
127
Runtime/MicroLibrary/MacroMath.cs
Normal file
127
Runtime/MicroLibrary/MacroMath.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// <20><>ѧ<EFBFBD><D1A7>
|
||||
/// </summary>
|
||||
public static partial class MacroMath
|
||||
{
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong MurmurFinalize(ulong index)
|
||||
{
|
||||
index ^= index >> 33;
|
||||
index *= 0xff51afd7ed558ccd;
|
||||
index ^= index >> 33;
|
||||
index *= 0xc4ceb9fe1a85ec53;
|
||||
index ^= index >> 33;
|
||||
return index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong RandomNumber(ulong index)
|
||||
{
|
||||
index *= 1103515245;
|
||||
index += 12345;
|
||||
index *= 6364136223846793005UL;
|
||||
index += 1442695040888963407UL;
|
||||
index %= 18446744073709551615UL;
|
||||
return index;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD>ѧ
|
||||
|
||||
/// <summary>
|
||||
/// pmod
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double PMod(double a, double b)
|
||||
{
|
||||
double z = a % b;
|
||||
double w = (z < 0) ? -1 : 1;
|
||||
z = (z < 0) ? -z : z;
|
||||
if(w < 0)
|
||||
return b - z;
|
||||
else
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float MinPositive(float a, float b)
|
||||
=> Math.Min(Math.Max(0, a), Math.Max(0, b));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int MinPositive(int a, int b)
|
||||
=> Math.Min(Math.Max(0, a), Math.Max(0, b));
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD>ֽڿ<EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void SetByteState(ref int target, int site, bool state)
|
||||
{
|
||||
if(state)
|
||||
target |= 1 << site;
|
||||
|
||||
else
|
||||
target &= 0xff - (1 << site);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void SetByteState(ref int target, Enum site, bool state)
|
||||
{
|
||||
SetByteState(ref target, Convert.ToInt32(site), state);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool GetByteState(int target, int site)
|
||||
{
|
||||
return (target >> site & 0x01) > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool GetByteState(int target, Enum site)
|
||||
{
|
||||
return GetByteState(target, Convert.ToInt32(site));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
11
Runtime/MicroLibrary/MacroMath.cs.meta
Normal file
11
Runtime/MicroLibrary/MacroMath.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45a81e001aee8594dbc45766fef9dfcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
42
Runtime/MicroLibrary/MacroObject.cs
Normal file
42
Runtime/MicroLibrary/MacroObject.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
public static class MacroObject
|
||||
{
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ζ<EFBFBD>Ҫ<EFBFBD><D2AA>ȡһ<C8A1><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static T GetComponentAnyway<T>(this GameObject obj)
|
||||
where T : Component
|
||||
{
|
||||
var component = obj.GetComponent<T>();
|
||||
if(component is null)
|
||||
component = obj.AddComponent<T>();
|
||||
return component;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ζ<EFBFBD>Ҫ<EFBFBD><D2AA>ȡһ<C8A1><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static T GetObjectAnyway<T>(this T obj)
|
||||
where T : new()
|
||||
{
|
||||
if(obj is null)
|
||||
obj = new T();
|
||||
return obj;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
11
Runtime/MicroLibrary/MacroObject.cs.meta
Normal file
11
Runtime/MicroLibrary/MacroObject.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba90139bc3f0a3347afd4673b38919a1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Runtime/MicroLibrary/MacroString.cs
Normal file
41
Runtime/MicroLibrary/MacroString.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
public static partial class MacroMath
|
||||
{
|
||||
|
||||
#region <EFBFBD>ı<EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>clone<6E><65><EFBFBD><EFBFBD><EFBFBD><D7BA><EFBFBD><EFBFBD>ʡ<EFBFBD><CAA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static string GetGameObjectNameWithoutClone(GameObject gameObject)
|
||||
{
|
||||
return GetGameObjectNameWithoutClone(gameObject.name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>clone<6E><65><EFBFBD><EFBFBD><EFBFBD><D7BA><EFBFBD><EFBFBD>ʡ<EFBFBD><CAA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static string GetGameObjectNameWithoutClone(string gameObjectName)
|
||||
{
|
||||
const string cloneSuffix = "(Clone)";
|
||||
if(gameObjectName.EndsWith(cloneSuffix))
|
||||
{
|
||||
int suffixIndex = gameObjectName.LastIndexOf(cloneSuffix);
|
||||
string nameWithoutClone = gameObjectName.Substring(0, suffixIndex);
|
||||
return nameWithoutClone;
|
||||
}
|
||||
return gameObjectName;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Runtime/MicroLibrary/MacroString.cs.meta
Normal file
11
Runtime/MicroLibrary/MacroString.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddcec615e26876649b458ceb73acef9f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
52
Runtime/MicroLibrary/MacroTransferAxes.cs
Normal file
52
Runtime/MicroLibrary/MacroTransferAxes.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Xeric.Runtime.MicroLibrary
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </remarks>
|
||||
public static class MacroTransferAxes
|
||||
{
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/**
|
||||
* <20><>Maya<79><61><EFBFBD><EFBFBD>Y<EFBFBD><59><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Silicon Graphice,Inc.<2E><>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>Ҳ<EFBFBD><D2B2>SGI<47>ı<EFBFBD><EFBFBD><D7BC>
|
||||
* <20>Լ<EFBFBD>DX,OpenGLҲ<4C><D2B2>ʹ<EFBFBD><CAB9>Z<EFBFBD><5A><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>Ⱦ<EFBFBD><C8BE>
|
||||
* Unity,Zbrush,DirectXʹ<58>õ<EFBFBD><C3B5><EFBFBD>Y<EFBFBD><59><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
|
||||
* Maya,OpenGLʹ<4C>õ<EFBFBD><C3B5><EFBFBD>Y<EFBFBD><59><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
|
||||
*
|
||||
* <20><>Unreal<61><6C><EFBFBD><EFBFBD>ʱMaya<79><61>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD><D2B6>õ<EFBFBD><C3B5><EFBFBD>3D Max<61><78><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD><5A><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>
|
||||
* <20><><EFBFBD><EFBFBD>3D Max<61><78>source engine<6E><65>cry engine, blenderʹ<72>õ<EFBFBD><C3B5><EFBFBD>Z<EFBFBD><5A><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>
|
||||
*
|
||||
* <20><>ѧ<EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>Щ
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// <20><>Y<EFBFBD><59><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ϵתΪZ<CEAA><5A><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public static Vector3 YupToZupAxes(Vector3 input)
|
||||
{
|
||||
return new Vector3(input.x, input.y, input.z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>Z<EFBFBD><5A><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ϵתΪY<CEAA><59><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public static Vector3 ZupToYupAxes(Vector3 input)
|
||||
{
|
||||
return new Vector3(input.x, input.y, input.z);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
11
Runtime/MicroLibrary/MacroTransferAxes.cs.meta
Normal file
11
Runtime/MicroLibrary/MacroTransferAxes.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dfe731c33104d5458aa7cc26ea22e32
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
754
Runtime/MicroLibrary/NeighborGrid.cs
Normal file
754
Runtime/MicroLibrary/NeighborGrid.cs
Normal file
@@ -0,0 +1,754 @@
|
||||
using XericLibrary.Runtime.MacroLibrary;
|
||||
using XericLibrary.Runtime.Type;
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
public class NeighborGrid<T> : WeaklyObject,
|
||||
IEnumerable<KeyValuePair<int, List<T>>>
|
||||
{
|
||||
#region <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
private Vector3 position;
|
||||
private Vector3 cellSize;
|
||||
private Vector3Int numCells;
|
||||
private int maxNeighbor = 8;
|
||||
|
||||
|
||||
public Vector3 Position
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => position;
|
||||
}
|
||||
public Vector3 CellSize
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => cellSize;
|
||||
}
|
||||
public Vector3Int NumCells
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => numCells;
|
||||
}
|
||||
|
||||
|
||||
internal System.Random random = new System.Random();
|
||||
private int NeighborRandomIndex
|
||||
{
|
||||
get => random.Next(maxNeighbor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5>洢<EFBFBD><E6B4A2>
|
||||
/// </summary>
|
||||
private Dictionary<int, List<T>> grid = new Dictionary<int, List<T>>();
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳߴ<DCB3>
|
||||
/// </summary>
|
||||
public Vector3 Fullsize
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => cellSize.Mul(numCells);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳתΪ<D7AA><CEAA><EFBFBD>巶Χ
|
||||
/// </summary>
|
||||
public Bounds GridBounds
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => new Bounds(position, Fullsize / 2);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set
|
||||
{
|
||||
position = value.center;
|
||||
cellSize = (value.size * 2).Div(numCells);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20>ٽ<EFBFBD><D9BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="position"><3E><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
||||
/// <param name="cellSize"><3E><><EFBFBD><EFBFBD><F1BEA7B8>ߴ<EFBFBD></param>
|
||||
/// <param name="fullSize"><3E><><EFBFBD><EFBFBD><EFBFBD>ܳߴ<DCB3></param>
|
||||
/// <param name="maxNeighbor"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD><EFBFBD><EFBFBD></param>
|
||||
public NeighborGrid(Vector3 position, Vector3 cellSize, Vector3 fullSize, int maxNeighbor = 8)
|
||||
{
|
||||
this.position = position;
|
||||
this.cellSize = cellSize;
|
||||
this.numCells = fullSize.Div(cellSize).FloorToInt().Max(Vector3Int.one);
|
||||
this.maxNeighbor = maxNeighbor;
|
||||
|
||||
Debug.Log($"ԭ<>㣺{position}<7D><> <20><><EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD>{cellSize}<7D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{numCells}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public struct NeighborGridIndex
|
||||
{
|
||||
#region <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
private NeighborGrid<T> grid;
|
||||
|
||||
private NeighborGridSpace drivenSpace;
|
||||
|
||||
private object drivenIndex;
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
public NeighborGridIndex(NeighborGrid<T> grid)
|
||||
{
|
||||
this.grid = grid;
|
||||
drivenSpace = (NeighborGridSpace)(-1);
|
||||
drivenIndex = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡΪ <20><><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="world"></param>
|
||||
public Vector3 GetDrivenAsWorld()
|
||||
{
|
||||
DrivenTransformTo(NeighborGridSpace.World);
|
||||
return (Vector3)drivenIndex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡΪ <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="simulation"></param>
|
||||
public Vector3 GetDrivenAsSimulation()
|
||||
{
|
||||
DrivenTransformTo(NeighborGridSpace.Simulation);
|
||||
return (Vector3)drivenIndex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡΪ <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="unit"></param>
|
||||
public Vector3 GetDrivenAsUnit()
|
||||
{
|
||||
DrivenTransformTo(NeighborGridSpace.Unit);
|
||||
return (Vector3)drivenIndex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡΪ <20><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="world"></param>
|
||||
public Vector3Int GetDrivenAsIndex()
|
||||
{
|
||||
DrivenTransformTo(NeighborGridSpace.Index);
|
||||
return (Vector3Int)drivenIndex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡΪ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="world"></param>
|
||||
public int GetDrivenAsLinear()
|
||||
{
|
||||
DrivenTransformTo(NeighborGridSpace.Linear);
|
||||
return (int)drivenIndex;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>Ϊ <20><><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="world"></param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public NeighborGridIndex SetDrivenAsWorld(Vector3 world)
|
||||
{
|
||||
drivenIndex = world;
|
||||
drivenSpace = NeighborGridSpace.World;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>Ϊ <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="simulation"></param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public NeighborGridIndex SetDrivenAsSimulation(Vector3 simulation)
|
||||
{
|
||||
drivenIndex = simulation;
|
||||
drivenSpace = NeighborGridSpace.Simulation;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>Ϊ <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="unit"></param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public NeighborGridIndex SetDrivenAsUnit(Vector3 unit)
|
||||
{
|
||||
drivenIndex = unit;
|
||||
drivenSpace = NeighborGridSpace.Unit;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>Ϊ <20><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="world"></param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public NeighborGridIndex SetDrivenAsIndex(Vector3Int index)
|
||||
{
|
||||
drivenIndex = index;
|
||||
drivenSpace = NeighborGridSpace.Index;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>Ϊ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="world"></param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public NeighborGridIndex SetDrivenAsLinear(int linear)
|
||||
{
|
||||
drivenIndex = linear;
|
||||
drivenSpace = NeighborGridSpace.Linear;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ת<><D7AA><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="targetSpace"></param>
|
||||
public NeighborGridIndex DrivenTransformTo(NeighborGridSpace targetSpace)
|
||||
{
|
||||
switch(targetSpace)
|
||||
{
|
||||
case NeighborGridSpace.World:
|
||||
TransformToWorld();
|
||||
break;
|
||||
|
||||
case NeighborGridSpace.Simulation:
|
||||
TransformToSimulation();
|
||||
break;
|
||||
|
||||
case NeighborGridSpace.Unit:
|
||||
TransformToUnit();
|
||||
break;
|
||||
|
||||
case NeighborGridSpace.Index:
|
||||
TransformToIndex();
|
||||
break;
|
||||
|
||||
case NeighborGridSpace.Linear:
|
||||
TransformToLiear();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new System.Exception("ת<><D7AA><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>Ŀ<EFBFBD><C4BF>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
private void TransformToWorld()
|
||||
{
|
||||
switch(drivenSpace)
|
||||
{
|
||||
case NeighborGridSpace.World:
|
||||
drivenSpace = NeighborGridSpace.World;
|
||||
break;
|
||||
|
||||
case NeighborGridSpace.Simulation:
|
||||
drivenIndex = grid.SimulationToWorld((Vector3)drivenIndex);
|
||||
goto case NeighborGridSpace.World;
|
||||
|
||||
case NeighborGridSpace.Unit:
|
||||
drivenIndex = grid.UnitToSimulation((Vector3)drivenIndex);
|
||||
goto case NeighborGridSpace.Simulation;
|
||||
|
||||
case NeighborGridSpace.Index:
|
||||
drivenIndex = grid.IndexToUnit((Vector3Int)drivenIndex);
|
||||
goto case NeighborGridSpace.Unit;
|
||||
|
||||
case NeighborGridSpace.Linear:
|
||||
drivenIndex = grid.LinearToIndex((int)drivenIndex);
|
||||
goto case NeighborGridSpace.Index;
|
||||
|
||||
default:
|
||||
throw new System.Exception("ת<><D7AA><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>Ŀ<EFBFBD><C4BF>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿռ<D8BF>
|
||||
/// </summary>
|
||||
private void TransformToSimulation()
|
||||
{
|
||||
switch(drivenSpace)
|
||||
{
|
||||
case NeighborGridSpace.World:
|
||||
drivenIndex = grid.WorldToSimulation((Vector3)drivenIndex);
|
||||
goto case NeighborGridSpace.Simulation;
|
||||
|
||||
case NeighborGridSpace.Simulation:
|
||||
drivenSpace = NeighborGridSpace.Simulation;
|
||||
break;
|
||||
|
||||
case NeighborGridSpace.Unit:
|
||||
drivenIndex = grid.UnitToSimulation((Vector3)drivenIndex);
|
||||
goto case NeighborGridSpace.Simulation;
|
||||
|
||||
case NeighborGridSpace.Index:
|
||||
drivenIndex = grid.IndexToUnit((Vector3Int)drivenIndex);
|
||||
goto case NeighborGridSpace.Unit;
|
||||
|
||||
case NeighborGridSpace.Linear:
|
||||
drivenIndex = grid.LinearToIndex((int)drivenIndex);
|
||||
goto case NeighborGridSpace.Index;
|
||||
|
||||
default:
|
||||
throw new System.Exception("ת<><D7AA><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>Ŀ<EFBFBD><C4BF>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
private void TransformToUnit()
|
||||
{
|
||||
switch(drivenSpace)
|
||||
{
|
||||
case NeighborGridSpace.World:
|
||||
drivenIndex = grid.WorldToSimulation((Vector3)drivenIndex);
|
||||
goto case NeighborGridSpace.Simulation;
|
||||
|
||||
case NeighborGridSpace.Simulation:
|
||||
drivenIndex = grid.SimulationToUnit((Vector3)drivenIndex);
|
||||
goto case NeighborGridSpace.Unit;
|
||||
|
||||
case NeighborGridSpace.Unit:
|
||||
drivenSpace = NeighborGridSpace.Unit;
|
||||
break;
|
||||
|
||||
case NeighborGridSpace.Index:
|
||||
drivenIndex = grid.IndexToUnit((Vector3Int)drivenIndex);
|
||||
goto case NeighborGridSpace.Unit;
|
||||
|
||||
case NeighborGridSpace.Linear:
|
||||
drivenIndex = grid.LinearToIndex((int)drivenIndex);
|
||||
goto case NeighborGridSpace.Index;
|
||||
|
||||
default:
|
||||
throw new System.Exception("ת<><D7AA><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>Ŀ<EFBFBD><C4BF>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
private void TransformToIndex()
|
||||
{
|
||||
switch(drivenSpace)
|
||||
{
|
||||
case NeighborGridSpace.World:
|
||||
drivenIndex = grid.WorldToSimulation((Vector3)drivenIndex);
|
||||
goto case NeighborGridSpace.Simulation;
|
||||
|
||||
case NeighborGridSpace.Simulation:
|
||||
drivenIndex = grid.SimulationToUnit((Vector3)drivenIndex);
|
||||
goto case NeighborGridSpace.Unit;
|
||||
|
||||
case NeighborGridSpace.Unit:
|
||||
drivenIndex = grid.UnitToIndex((Vector3)drivenIndex);
|
||||
goto case NeighborGridSpace.Index;
|
||||
|
||||
case NeighborGridSpace.Index:
|
||||
drivenSpace = NeighborGridSpace.Index;
|
||||
break;
|
||||
|
||||
case NeighborGridSpace.Linear:
|
||||
drivenIndex = grid.LinearToIndex((int)drivenIndex);
|
||||
goto case NeighborGridSpace.Index;
|
||||
|
||||
default:
|
||||
throw new System.Exception("ת<><D7AA><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>Ŀ<EFBFBD><C4BF>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
private void TransformToLiear()
|
||||
{
|
||||
switch(drivenSpace)
|
||||
{
|
||||
case NeighborGridSpace.World:
|
||||
drivenIndex = grid.WorldToSimulation((Vector3)drivenIndex);
|
||||
goto case NeighborGridSpace.Simulation;
|
||||
|
||||
case NeighborGridSpace.Simulation:
|
||||
drivenIndex = grid.SimulationToUnit((Vector3)drivenIndex);
|
||||
goto case NeighborGridSpace.Unit;
|
||||
|
||||
case NeighborGridSpace.Unit:
|
||||
drivenIndex = grid.UnitToIndex((Vector3)drivenIndex);
|
||||
goto case NeighborGridSpace.Index;
|
||||
|
||||
case NeighborGridSpace.Index:
|
||||
drivenIndex = grid.IndexToLinear((Vector3Int)drivenIndex);
|
||||
break;
|
||||
|
||||
case NeighborGridSpace.Linear:
|
||||
drivenSpace = NeighborGridSpace.Linear;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new System.Exception("ת<><D7AA><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20>ٽ<EFBFBD><D9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>ö<EFBFBD><C3B6>
|
||||
/// </summary>
|
||||
public enum NeighborGridSpace
|
||||
{
|
||||
World,
|
||||
Simulation,
|
||||
Unit,
|
||||
Index,
|
||||
Linear
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>任
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD> <20>任Ϊ <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="world"><3E><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Vector3 WorldToSimulation(Vector3 world)
|
||||
=> world - position - (-Fullsize / 2);
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD> <20>任Ϊ <20><><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="world"><3E><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Vector3 SimulationToWorld(Vector3 simulation)
|
||||
=> simulation + position + (-Fullsize / 2);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD> <20>任Ϊ <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="simulation"><3E><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Vector3 SimulationToUnit(Vector3 simulation)
|
||||
=> simulation.Div(Fullsize);
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD> <20>任Ϊ <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="simulation"><3E><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Vector3 UnitToSimulation(Vector3 unit)
|
||||
=> unit.Mul(Fullsize);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD> <20>任Ϊ <20><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="unit"><3E><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Vector3Int UnitToIndex(Vector3 unit)
|
||||
=> unit.IsInUnit() ? unit.Mul(numCells).FloorToInt() : MacroMath.Vector3Int_Negate;
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD> <20>任Ϊ <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="index"><3E><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Vector3 IndexToUnit(Vector3Int index)
|
||||
{
|
||||
if(index.IsValid())
|
||||
{
|
||||
Vector3 unit = ((Vector3)index).Div(numCells);
|
||||
unit.x = numCells.x == 1 && unit.x <= 0 ? .5f : unit.x;
|
||||
unit.y = numCells.y == 1 && unit.y <= 0 ? .5f : unit.y;
|
||||
unit.z = numCells.z == 1 && unit.z <= 0 ? .5f : unit.z;
|
||||
return unit;
|
||||
}
|
||||
return MacroMath.Vector3Int_Negate;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD> <20>任Ϊ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="unit"><3E><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int UnitToLinear(Vector3 unit)
|
||||
{
|
||||
if(unit.IsInUnit())
|
||||
{
|
||||
return IndexToLinear(UnitToIndex(unit));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD> <20>任Ϊ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="index"><3E><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int IndexToLinear(Vector3Int index)
|
||||
{
|
||||
if(index.IsValid() && index.IsInIndexRange(numCells))
|
||||
{
|
||||
return (int)(index.x +
|
||||
(index.y * numCells.x) +
|
||||
(index.z * numCells.y * numCells.x));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="linear"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
||||
/// <param name="side"><3E>߳<EFBFBD></param>
|
||||
/// <returns></returns>
|
||||
public Vector3Int LinearToGridIndex(int linear, int side)
|
||||
{
|
||||
return new Vector3Int(linear % side, linear / side, linear / side.Quad());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>任Ϊ <20><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="linear"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Vector3Int LinearToIndex(int linear)
|
||||
{
|
||||
int z = linear / (numCells.x * numCells.y);
|
||||
int y = (linear - (z * numCells.x * numCells.y)) / numCells.x;
|
||||
int x = linear - (z * numCells.x * numCells.y) - (y * numCells.x);
|
||||
|
||||
return new Vector3Int(x, y, z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>任Ϊ <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="linear"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Vector3 LinearToUnit(int linear)
|
||||
{
|
||||
Debug.Log($"<22><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>{LinearToIndex(linear)}<7D><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>λ");
|
||||
return IndexToUnit(LinearToIndex(linear));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public void Clean()
|
||||
{
|
||||
grid.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ŀ
|
||||
/// </summary>
|
||||
/// <param name="linear"><3E><><EFBFBD><EFBFBD></param>
|
||||
/// <returns><3E><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ӳɹ<D3B3></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool Insert(int linear, T obj)
|
||||
{
|
||||
if(linear < 0)
|
||||
return false;
|
||||
if(grid.ContainsKey(linear))
|
||||
{
|
||||
int index = grid[linear].IndexOf(obj);
|
||||
if(index < 0)
|
||||
{
|
||||
grid[linear].Add(obj);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
grid.Add(linear, new List<T> { obj });
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
|
||||
/// </summary>
|
||||
/// <param name="linear"><3E><><EFBFBD><EFBFBD></param>
|
||||
/// <param name="obj"><3E><>Ŀ</param>
|
||||
/// <returns><3E><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ƴ<EFBFBD><C6B3>ɹ<EFBFBD></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool Remove(int linear, T obj)
|
||||
{
|
||||
if(grid.ContainsKey(linear))
|
||||
{
|
||||
bool resualt = grid[linear].Remove(obj);
|
||||
if(grid[linear].Count <= 0)
|
||||
grid.Remove(linear);
|
||||
return resualt;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// <20>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
|
||||
/// </summary>
|
||||
/// <param name="linear"><3E><><EFBFBD><EFBFBD></param>
|
||||
/// <returns><3E><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ƴ<EFBFBD><C6B3>ɹ<EFBFBD></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Remove(int linear)
|
||||
{
|
||||
if(grid[linear] is not null)
|
||||
{
|
||||
grid[linear].Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
|
||||
/// </summary>
|
||||
/// <param name="linear"><3E><><EFBFBD><EFBFBD></param>
|
||||
/// <param name="obj"><3E><>Ŀ</param>
|
||||
/// <returns><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool Contains(int linear, T obj)
|
||||
{
|
||||
if(grid[linear] is not null)
|
||||
{
|
||||
return grid[linear].Contains(obj);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>е<EFBFBD><D0B5>ھ<EFBFBD>
|
||||
/// <code>
|
||||
/// <20><><EFBFBD>棺DZ<E6A3BA>ڵĸ<DAB5><C4B8><EFBFBD><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD>
|
||||
/// </code>
|
||||
/// </summary>
|
||||
/// <param name="linear"></param>
|
||||
/// <returns></returns>
|
||||
public bool GetAllNeighbor(int linear, out List<T> values)
|
||||
{
|
||||
return grid.TryGetValue(linear, out values);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD>ڵ<EFBFBD><DAB5>ھ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="linear"><3E><><EFBFBD><EFBFBD>λ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<T> GetNeighbor(int linear)
|
||||
{
|
||||
int startIndex = NeighborRandomIndex;
|
||||
int count = grid[linear].Count;
|
||||
for(int i = 0; i < maxNeighbor; i++)
|
||||
{
|
||||
yield return grid[linear][(startIndex + i) % count];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD>뾶<EFBFBD><EBBEB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="linear"><3E><><EFBFBD><EFBFBD>λ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD></param>
|
||||
/// <param name="range"><3E><><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD>Χ</param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<T> GetNeighbor(int linear, int radius)
|
||||
{
|
||||
int side = radius * 2 + 1;
|
||||
int length = side.Cubic();
|
||||
Vector3Int index = LinearToIndex(linear);
|
||||
index = index.Sub(radius);
|
||||
|
||||
for(int i = 0; i < length; i++)
|
||||
{
|
||||
var neighbor = GetNeighbor(IndexToLinear(index +
|
||||
LinearToGridIndex(i, side)))
|
||||
.GetEnumerator();
|
||||
while(neighbor.MoveNext())
|
||||
{
|
||||
yield return neighbor.Current;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ʵ<EFBFBD><EFBFBD>
|
||||
|
||||
public IEnumerator<KeyValuePair<int, List<T>>> GetEnumerator()
|
||||
{
|
||||
foreach(var list in grid)
|
||||
{
|
||||
yield return list;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Runtime/MicroLibrary/NeighborGrid.cs.meta
Normal file
11
Runtime/MicroLibrary/NeighborGrid.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ffd0ac031e48e94990e3501ec6bb5ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
132
Runtime/MicroLibrary/NeighborGridExtend.cs
Normal file
132
Runtime/MicroLibrary/NeighborGridExtend.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
public static class NeighborGridExtend
|
||||
{
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC>任Ϊ<E4BBBB><CEAA><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="world"></param>
|
||||
/// <param name="grid"><3E><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 WorldToSimulation<T>(this Vector3 world, NeighborGrid<T> grid)
|
||||
=> grid.WorldToSimulation(world);
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC>任Ϊ<E4BBBB><CEAA><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="simulation"></param>
|
||||
/// <param name="grid"><3E><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 SimulationToWorld<T>(this Vector3 simulation, NeighborGrid<T> grid)
|
||||
=> grid.SimulationToWorld(simulation);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="simulation"></param>
|
||||
/// <param name="grid"><3E><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 SimulationToUnit<T>(this Vector3 simulation, NeighborGrid<T> grid)
|
||||
=> grid.SimulationToUnit(simulation);
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="unit"></param>
|
||||
/// <param name="grid"><3E><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 UnitToSimulation<T>(this Vector3 unit, NeighborGrid<T> grid)
|
||||
=> grid.UnitToSimulation(unit);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD>תΪ<D7AA><CEAA>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="unit"></param>
|
||||
/// <param name="grid"><3E><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int UnitToIndex<T>(this Vector3 unit, NeighborGrid<T> grid)
|
||||
=> grid.UnitToIndex(unit);
|
||||
/// <summary>
|
||||
/// <20><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="grid"><3E><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 IndexToUnit<T>(this Vector3Int index, NeighborGrid<T> grid)
|
||||
=> grid.IndexToUnit(index);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="unit"><3E><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD></param>
|
||||
/// <param name="grid"><3E><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int UnitToLinear<T>(this Vector3 unit, NeighborGrid<T> grid)
|
||||
=> grid.UnitToLinear(unit);
|
||||
/// <summary>
|
||||
/// <20><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="index"><3E><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD></param>
|
||||
/// <param name="grid"><3E><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int IndexToLinear<T>(this Vector3Int index, NeighborGrid<T> grid)
|
||||
=> grid.IndexToLinear(index);
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ص<EFBFBD>λ<EFBFBD>ռ<EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="unit"><3E><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD></param>
|
||||
/// <param name="grid"><3E><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int LinearToIndex<T>(this int Linear, NeighborGrid<T> grid)
|
||||
=> grid.LinearToIndex(Linear);
|
||||
/// <summary>
|
||||
/// <20><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="index"><3E><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD></param>
|
||||
/// <param name="grid"><3E><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 LinearToUnit<T>(this int Linear, NeighborGrid<T> grid)
|
||||
=> grid.LinearToUnit(Linear);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="Linear"></param>
|
||||
/// <param name="grid"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int WorldToLinear<T>(this Vector3 Linear, NeighborGrid<T> grid)
|
||||
=> Linear.WorldToSimulation(grid).SimulationToUnit(grid).UnitToLinear(grid);
|
||||
}
|
||||
}
|
||||
11
Runtime/MicroLibrary/NeighborGridExtend.cs.meta
Normal file
11
Runtime/MicroLibrary/NeighborGridExtend.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f67516c9f81441149a09742c65b0ffed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
248
Runtime/MicroLibrary/TypeExtend.cs
Normal file
248
Runtime/MicroLibrary/TypeExtend.cs
Normal file
@@ -0,0 +1,248 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
using Xorti = XericLibrary.Runtime.MacroLibrary.MacroMath;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
public static class ExtendType
|
||||
{
|
||||
#region <EFBFBD>㷨
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>Ƿ<EFBFBD><C7B7>ڷ<EFBFBD>Χ<EFBFBD><CEA7>[min, max]
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsInRange(this int value, int min, int max)
|
||||
=> value >= min && value <= max;
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><CEA7>[min, max)
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsInIndexRange(this int value, int min, int max)
|
||||
=> value >= min && value < max;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>η<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int Quad(this int value)
|
||||
{
|
||||
return value * value;
|
||||
}
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>η<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int Cubic(this int value)
|
||||
{
|
||||
return value * value * value;
|
||||
}
|
||||
/// <summary>
|
||||
/// <20>Ĵη<C4B4>
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int Quart(this int value)
|
||||
{
|
||||
return value * value * value * value;
|
||||
}
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>η<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int Quint(this int value)
|
||||
{
|
||||
return value * value * value * value * value;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>η<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Quad(this float value)
|
||||
{
|
||||
return value * value;
|
||||
}
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>η<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Cubic(this float value)
|
||||
{
|
||||
return value * value * value;
|
||||
}
|
||||
/// <summary>
|
||||
/// <20>Ĵη<C4B4>
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Quart(this float value)
|
||||
{
|
||||
return value * value * value * value;
|
||||
}
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>η<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Quint(this float value)
|
||||
{
|
||||
return value * value * value * value * value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD>¼<EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>صص<D8B5><D8B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>¼<EFBFBD><C2BC>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool InvokeConservative(this Action invokedEvent, int sign, ref int register)
|
||||
{
|
||||
if(Xorti.GetByteState(register, sign))
|
||||
return false;
|
||||
Xorti.SetByteState(ref register, sign, true);
|
||||
invokedEvent?.Invoke();
|
||||
Xorti.SetByteState(ref register, sign, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>صص<D8B5><D8B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>¼<EFBFBD><C2BC>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool InvokeConservative<PARAM>(this Action<PARAM> invokedEvent, PARAM input, int sign, ref int register)
|
||||
{
|
||||
if(Xorti.GetByteState(register, sign))
|
||||
return false;
|
||||
Xorti.SetByteState(ref register, sign, true);
|
||||
invokedEvent?.Invoke(input);
|
||||
Xorti.SetByteState(ref register, sign, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>亯<EFBFBD><E4BAAF>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="component"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool GetComponent<T>(this GameObject target, out T component)
|
||||
{
|
||||
component = target.GetComponent<T>();
|
||||
return component is not null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20>˶<EFBFBD><CBB6><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD>ǵڶ<C7B5><DAB6><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="other"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool ParentIs(this GameObject target, GameObject other)
|
||||
{
|
||||
return target.transform.parent == other.transform;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20>˶<EFBFBD><CBB6><EFBFBD><EFBFBD>ǵڶ<C7B5><DAB6>ߵĸ<DFB5><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="other"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsParent(this GameObject target, GameObject other)
|
||||
{
|
||||
return target.transform == other.transform.parent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20>˶<EFBFBD><CBB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="other"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsBrother(this GameObject target, GameObject other)
|
||||
{
|
||||
return target.transform.parent == other.transform.parent;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region bound
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsInUnit(this Vector3 vec, float align = 1)
|
||||
{
|
||||
float negat = 1 - align;
|
||||
return
|
||||
vec.x <= align &&
|
||||
vec.y <= align &&
|
||||
vec.z <= align &&
|
||||
vec.x >= negat &&
|
||||
vec.y >= negat &&
|
||||
vec.z >= negat;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region string
|
||||
|
||||
private static string ListToString<T>(this List<List<T>> context)
|
||||
{
|
||||
string result = "";
|
||||
Func<List<T>, string> ListFormat = (List<T> list) =>
|
||||
{
|
||||
string result = "";
|
||||
for (int i = 0; i < list.Count; i++, result += ",")
|
||||
result += $"{i}: {list[i]}";
|
||||
return result;
|
||||
};
|
||||
for(int i = 0; i < context.Count; i++)
|
||||
result += $"List{i}: {{{ListFormat(context[i])}}}\r\n";
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Runtime/MicroLibrary/TypeExtend.cs.meta
Normal file
11
Runtime/MicroLibrary/TypeExtend.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5083902ec572f1b449bfe335c374ed4e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
113
Runtime/MicroLibrary/Vector2Extend.cs
Normal file
113
Runtime/MicroLibrary/Vector2Extend.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
public static class Vector2Extend
|
||||
{
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>涨<EFBFBD>ı༭<C4B1><E0BCAD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="vec"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 ToVector3(this Vector2 vec)
|
||||
=> new Vector3(vec.x, 0, vec.y);
|
||||
|
||||
[Obsolete("unfinished")]
|
||||
public static Vector2 Projection(this Vector2 point, Vector3 start, Vector3 end)
|
||||
{
|
||||
Vector3 vec = end - start;
|
||||
float xx = Mathf.Pow(vec.x, 2f);
|
||||
float yy = Mathf.Pow(vec.y, 2f);
|
||||
float denominator = xx + yy;
|
||||
if(denominator == 0)
|
||||
return point;
|
||||
|
||||
float xy = vec.x * vec.y;
|
||||
//float moleculey = yy *
|
||||
return new Vector2(xx, xy);
|
||||
}
|
||||
|
||||
public static Vector2 Projection(this Vector2 point, Vector2 start, Vector2 end)
|
||||
{
|
||||
Vector2 ab = end - start;
|
||||
Vector2 ap = point - start;
|
||||
return start + ab * Vector2.Dot(ap, ab) / ab.sqrMagnitude;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="vec"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector2 Orthogonalization(this Vector2 vec)
|
||||
=> new Vector2(
|
||||
(float)Math.Round(vec.x),
|
||||
(float)Math.Round(vec.y)
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector2 Min(this Vector2 a, Vector2 b)
|
||||
{
|
||||
return new Vector2(Math.Min(a.x, b.x), Math.Min(a.y, b.y));
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector2 Max(this Vector2 a, Vector2 b)
|
||||
{
|
||||
return new Vector2(Math.Max(a.x, b.x), Math.Max(a.y, b.y));
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float MinElement(this Vector2 a)
|
||||
{
|
||||
return Math.Min(a.x, a.y);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float MaxElement(this Vector2 a)
|
||||
{
|
||||
return Math.Max(a.x, a.y);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector2 Abs(this Vector2 a)
|
||||
{
|
||||
return new Vector2(Math.Abs(a.x), Math.Abs(a.y));
|
||||
}
|
||||
/// <summary>
|
||||
/// <20><>ȡʸ<C8A1><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="vec"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector2 Sign(this Vector2 vec)
|
||||
=> new Vector2(
|
||||
Math.Sign(vec.x),
|
||||
Math.Sign(vec.y)
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Cross(this Vector2 lhs, Vector2 rhs)
|
||||
=> lhs.x * rhs.y - rhs.x * lhs.y;
|
||||
|
||||
/// <summary>
|
||||
/// <20><>б<EFBFBD>߶<EFBFBD><DFB6><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <param name=""></param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector2 ObliqueAlign(this Vector2 point, Vector2 constPoint, out float exec)
|
||||
{
|
||||
float b1 = point.y - point.x, b2 = constPoint.y - constPoint.x;
|
||||
float dt = b1 + (b2 - b1);
|
||||
exec = dt * MacroMath.Sqrt22;
|
||||
Vector2 ab = constPoint - point;
|
||||
bool cool = ab.x * ab.y < 0;
|
||||
return exec * (cool ? Vector2.one : new Vector2(-1, 1));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Runtime/MicroLibrary/Vector2Extend.cs.meta
Normal file
11
Runtime/MicroLibrary/Vector2Extend.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93b81a983491c7a4791024a82c310d26
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
446
Runtime/MicroLibrary/Vector3Extend.cs
Normal file
446
Runtime/MicroLibrary/Vector3Extend.cs
Normal file
@@ -0,0 +1,446 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
public static class Vector3Extend
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Add(this Vector3 a, Vector3 b)
|
||||
=> new Vector3(
|
||||
a.x + b.x,
|
||||
a.y + b.y,
|
||||
a.z + b.z
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Add(this Vector3 a, Vector3Int b)
|
||||
=> new Vector3(
|
||||
a.x + b.x,
|
||||
a.y + b.y,
|
||||
a.z + b.z
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Add(this Vector3 a, float b)
|
||||
=> new Vector3(
|
||||
a.x + b,
|
||||
a.y + b,
|
||||
a.z + b
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Sub(this Vector3 a, Vector3 b)
|
||||
=> new Vector3(
|
||||
a.x - b.x,
|
||||
a.y - b.y,
|
||||
a.z - b.z
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Sub(this Vector3 a, Vector3Int b)
|
||||
=> new Vector3(
|
||||
a.x - b.x,
|
||||
a.y - b.y,
|
||||
a.z - b.z
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Sub(this Vector3 a, float b)
|
||||
=> new Vector3(
|
||||
a.x - b,
|
||||
a.y - b,
|
||||
a.z - b
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Mul(this Vector3 a, Vector3 b)
|
||||
=> new Vector3(
|
||||
a.x * b.x,
|
||||
a.y * b.y,
|
||||
a.z * b.z
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Mul(this Vector3 a, Vector3Int b)
|
||||
=> new Vector3(
|
||||
a.x * b.x,
|
||||
a.y * b.y,
|
||||
a.z * b.z
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Mul(this Vector3 a, float b)
|
||||
=> new Vector3(
|
||||
a.x * b,
|
||||
a.y * b,
|
||||
a.z * b
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Div(this Vector3 a, Vector3 b)
|
||||
=> new Vector3(
|
||||
a.x / b.x,
|
||||
a.y / b.y,
|
||||
a.z / b.z
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Div(this Vector3 a, Vector3Int b)
|
||||
=> new Vector3(
|
||||
a.x / b.x,
|
||||
a.y / b.y,
|
||||
a.z / b.z
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Div(this Vector3 a, float b)
|
||||
=> new Vector3(
|
||||
a.x / b,
|
||||
a.y / b,
|
||||
a.z / b
|
||||
);
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Xonly(this Vector3 a)
|
||||
=> new Vector3(
|
||||
a.x,
|
||||
0f,
|
||||
0f
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Yonly(this Vector3 a)
|
||||
=> new Vector3(
|
||||
0f,
|
||||
a.y,
|
||||
0f
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Zonly(this Vector3 a)
|
||||
=> new Vector3(
|
||||
0f,
|
||||
0f,
|
||||
a.z
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Mode(this Vector3 a, Vector3 b)
|
||||
{
|
||||
return new Vector3(a.x % b.x, a.y % b.y, a.z % b.z);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Mode(this Vector3 a, float b)
|
||||
{
|
||||
return new Vector3(a.x % b, a.y % b, a.z % b);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Sign(this Vector3 vec)
|
||||
=> new Vector3(
|
||||
Math.Sign(vec.x),
|
||||
Math.Sign(vec.y),
|
||||
Math.Sign(vec.z)
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int CeilToInt(this Vector3 vec)
|
||||
=> new Vector3Int((int)Mathf.Ceil(vec.x), (int)Mathf.Ceil(vec.y), (int)Mathf.Ceil(vec.z));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Ceil(this Vector3 vec)
|
||||
=> new Vector3(Mathf.Ceil(vec.x), Mathf.Ceil(vec.y), Mathf.Ceil(vec.z));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int RoundToInt(this Vector3 vec)
|
||||
=> new Vector3Int((int)Mathf.Round(vec.x), (int)Mathf.Round(vec.y), (int)Mathf.Round(vec.z));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Round(this Vector3 vec)
|
||||
=> new Vector3(Mathf.Round(vec.x), Mathf.Round(vec.y), Mathf.Round(vec.z));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int FloorToInt(this Vector3 vec)
|
||||
=> new Vector3Int((int)vec.x, (int)vec.y, (int)vec.z);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Floor(this Vector3 vec)
|
||||
=> new Vector3((int)vec.x, (int)vec.y, (int)vec.z);
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Min(this Vector3 a, Vector3 b)
|
||||
{
|
||||
return new Vector3(Math.Min(a.x, b.x), Math.Min(a.y, b.y), Math.Min(a.z, b.z));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Max(this Vector3 a, Vector3 b)
|
||||
{
|
||||
return new Vector3(Math.Max(a.x, b.x), Math.Max(a.y, b.y), Math.Max(a.z, b.z));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float MinElement(this Vector3 a)
|
||||
{
|
||||
return Math.Min(Math.Min(a.x, a.y), a.z);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float MaxElement(this Vector3 a)
|
||||
{
|
||||
return Math.Max(Math.Max(a.x, a.y), a.z);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Abs(this Vector3 a)
|
||||
{
|
||||
return new Vector3(Mathf.Abs(a.x), Mathf.Abs(a.y), Mathf.Abs(a.z));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Negative(this Vector3 a)
|
||||
=> new Vector3(-a.x, -a.y, -a.z);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>涨<EFBFBD>ı༭<C4B1><E0BCAD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="vec"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector2 ToVector2(this Vector3 vec)
|
||||
=> new Vector2(vec.x, vec.z);
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static Vector2 ToVector2(this Vector3 vec, string format)
|
||||
{
|
||||
Vector2 result = new Vector2();
|
||||
for(int i = 0; i < format.Length && i < 2; i++)
|
||||
{
|
||||
int index = MacroMath.MinPositive(format[i] - 'X', format[i] - 'x');
|
||||
result[index] = format[i] switch
|
||||
{
|
||||
'x' => vec.x,
|
||||
'X' => vec.x,
|
||||
'y' => vec.y,
|
||||
'Y' => vec.y,
|
||||
'z' => vec.z,
|
||||
'Z' => vec.z,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static Vector3 AxisZero(this Vector3 vec, string format)
|
||||
{
|
||||
Vector3 result = vec;
|
||||
for(int i = 0; i < format.Length && i < 2; i++)
|
||||
{
|
||||
int index = MacroMath.MinPositive(format[i] - 'X', format[i] - 'x');
|
||||
result[index] = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͶӰ<CDB6><D3B0>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>ϣ<EFBFBD>ͬʱ<CDAC>任<EFBFBD><E4BBBB>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="vec">ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
||||
/// <param name="planeOrigin">ƽ<><C6BD>ԭ<EFBFBD><D4AD></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 ProjectToUpPlane(this Vector3 vec, Vector3 planeOrigin)
|
||||
=> vec - new Vector3(0, (vec - planeOrigin).y, 0);
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>벻<EFBFBD><EBB2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="vec">ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
||||
/// <param name="offset">ƫ<><C6AB><EFBFBD><EFBFBD></param>
|
||||
/// <param name="unit"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ</param>
|
||||
/// <param name="thresholdPorp"><3E><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>[0-1]</param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 CoordinateGridAdsorb(this Vector3 vec, Vector3 offset, float unit, float thresholdPorp)
|
||||
{
|
||||
Vector3 vecInUnit = (vec + offset).Mode(unit);
|
||||
Vector3 sig = vecInUnit.Sign() * unit / 2;
|
||||
Vector3 dis = sig - vecInUnit;
|
||||
Vector3 drive = dis.Abs().Sub(unit * thresholdPorp).Sign();
|
||||
Vector3 ofs = (dis - sig).Mul(drive * 2) + vecInUnit;
|
||||
return ofs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="vec">ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
||||
/// <param name="offset">ƫ<><C6AB><EFBFBD><EFBFBD></param>
|
||||
/// <param name="unit"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ</param>
|
||||
/// <param name="thresholdPorp"><3E><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>[0-1]</param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 CoordinateGridAdsorbRound(this Vector3 vec, Vector3 offset, float unit)
|
||||
{
|
||||
return ((vec + offset) / unit).Round() * unit;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="vec"></param>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 Orthogonalization(this Vector3 vec)
|
||||
=> new Vector3(
|
||||
(float)Math.Round(vec.x),
|
||||
(float)Math.Round(vec.y),
|
||||
(float)Math.Round(vec.z)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class Vector3IntExtend
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Add(this Vector3Int a, Vector3Int b)
|
||||
=> new Vector3Int(
|
||||
a.x + b.x,
|
||||
a.y + b.y,
|
||||
a.z + b.z
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Add(this Vector3Int a, Vector3 b)
|
||||
=> new Vector3Int(
|
||||
(int)(a.x + b.x),
|
||||
(int)(a.y + b.y),
|
||||
(int)(a.z + b.z)
|
||||
);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Add(this Vector3Int a, int b)
|
||||
=> new Vector3Int(
|
||||
a.x + b,
|
||||
a.y + b,
|
||||
a.z + b
|
||||
);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Sub(this Vector3Int a, Vector3Int b)
|
||||
=> new Vector3Int(
|
||||
a.x - b.x,
|
||||
a.y - b.y,
|
||||
a.z - b.z
|
||||
);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Sub(this Vector3Int a, Vector3 b)
|
||||
=> new Vector3Int(
|
||||
(int)(a.x - b.x),
|
||||
(int)(a.y - b.y),
|
||||
(int)(a.z - b.z)
|
||||
);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Sub(this Vector3Int a, int b)
|
||||
=> new Vector3Int(
|
||||
a.x - b,
|
||||
a.y - b,
|
||||
a.z - b
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Mul(this Vector3Int a, Vector3Int b)
|
||||
=> new Vector3Int(
|
||||
a.x * b.x,
|
||||
a.y * b.y,
|
||||
a.z * b.z
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Mul(this Vector3Int a, Vector3 b)
|
||||
=> new Vector3Int(
|
||||
(int)(a.x * b.x),
|
||||
(int)(a.y * b.y),
|
||||
(int)(a.z * b.z)
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Mul(this Vector3Int a, int b)
|
||||
=> new Vector3Int(
|
||||
a.x * b,
|
||||
a.y * b,
|
||||
a.z * b
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Div(this Vector3Int a, Vector3Int b)
|
||||
=> new Vector3Int(
|
||||
a.x / b.x,
|
||||
a.y / b.y,
|
||||
a.z / b.z
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Div(this Vector3Int a, Vector3 b)
|
||||
=> new Vector3Int(
|
||||
(int)(a.x / b.x),
|
||||
(int)(a.y / b.y),
|
||||
(int)(a.z / b.z)
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Div(this Vector3Int a, int b)
|
||||
=> new Vector3Int(
|
||||
a.x / b,
|
||||
a.y / b,
|
||||
a.z / b
|
||||
);
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Negative(this Vector3Int a)
|
||||
=> new Vector3Int(-a.x, -a.y, -a.z);
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Min(this Vector3Int a, Vector3Int b)
|
||||
{
|
||||
return new Vector3Int(Math.Min(a.x, b.x), Math.Min(a.y, b.y), Math.Min(a.z, b.z));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3Int Max(this Vector3Int a, Vector3Int b)
|
||||
{
|
||||
return new Vector3Int(Math.Max(a.x, b.x), Math.Max(a.y, b.y), Math.Max(a.z, b.z));
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsValid(this Vector3Int lhs)
|
||||
{
|
||||
return lhs.x >= 0 && lhs.y >= 0 && lhs.z >= 0;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsInIndexRange(this Vector3Int lhs, Vector3Int max)
|
||||
{
|
||||
return
|
||||
lhs.x.IsInIndexRange(0, max.x) &&
|
||||
lhs.y.IsInIndexRange(0, max.y) &&
|
||||
lhs.z.IsInIndexRange(0, max.z);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Runtime/MicroLibrary/Vector3Extend.cs.meta
Normal file
11
Runtime/MicroLibrary/Vector3Extend.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61faf554d3acd9b49ad13a6b5697336b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,30 +0,0 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// Use this runtime example C# file to develop runtime code.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
namespace Lrss3.XericLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// Provide a general description of the public class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Packages require XmlDoc documentation for ALL Package APIs.
|
||||
/// https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/xml-documentation-comments
|
||||
/// </remarks>
|
||||
public class MyPublicRuntimeExampleClass
|
||||
{
|
||||
/// <summary>
|
||||
/// Provide a description of what this private method does.
|
||||
/// </summary>
|
||||
/// <param name="parameter1"> Description of parameter 1 </param>
|
||||
/// <param name="parameter2"> Description of parameter 2 </param>
|
||||
/// <param name="parameter3"> Description of parameter 3 </param>
|
||||
/// <returns> Description of what the function returns </returns>
|
||||
public int CountThingsAndDoStuff(int parameter1, int parameter2, bool parameter3)
|
||||
{
|
||||
return parameter3 ? (parameter1 + parameter2) : (parameter1 - parameter2);
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Runtime/Type.meta
Normal file
8
Runtime/Type.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b505c52c75ec3f40932605e026e951f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
148
Runtime/Type/WeaklyMonoBase.cs
Normal file
148
Runtime/Type/WeaklyMonoBase.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
#define _HISTORY_
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.Type
|
||||
{
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>ͽű<CDBD>
|
||||
/// </summary>
|
||||
public class WeaklyMonoBase : MonoBehaviour
|
||||
{
|
||||
#region <EFBFBD>ֶ<EFBFBD>
|
||||
|
||||
private WeaklyObjectBase weaklyBase = null;
|
||||
|
||||
#if _HISTORY_
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
private Vector3 history_Position;
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ʷ<EFBFBD><CAB7>ת
|
||||
/// </summary>
|
||||
private Quaternion history_Rotation;
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
private Vector3 history_Scale;
|
||||
|
||||
//private
|
||||
|
||||
#endif
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
private static PlayModeStateChange playModeState;
|
||||
|
||||
[Obsolete("<22><><EFBFBD>༭<EFBFBD><E0BCAD>ģʽ<C4A3>¿<EFBFBD><C2BF><EFBFBD>")]
|
||||
public static PlayModeStateChange PlayModeState => playModeState;
|
||||
public static bool IsNotExitingPlayMode
|
||||
{
|
||||
[Obsolete("<22><><EFBFBD>༭<EFBFBD><E0BCAD>ģʽ<C4A3>¿<EFBFBD><C2BF><EFBFBD>")]
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
#if _HISTORY_
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD><C8A1>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public Vector3 HistoryPosition => history_Position;
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD><C8A1>ʷ<EFBFBD><CAB7>ת
|
||||
/// </summary>
|
||||
public Quaternion HistoryRotation => history_Rotation;
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD><C8A1>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public Vector3 HistoryScale => history_Scale;
|
||||
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
[InitializeOnLoadMethod]
|
||||
static void OnLoad()
|
||||
{
|
||||
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD>¼<EFBFBD>
|
||||
|
||||
#if UNITY_EDITOR
|
||||
static void OnPlayModeStateChanged(PlayModeStateChange state)
|
||||
{
|
||||
IsNotExitingPlayMode = state != PlayModeStateChange.ExitingPlayMode;
|
||||
playModeState = state;
|
||||
Debug.Log($">>>>>>> {Enum.GetName(typeof(PlayModeStateChange), state)} <<<<<<<");
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD>
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return base.ToString();
|
||||
}
|
||||
|
||||
public static bool operator ==(WeaklyMonoBase lhs, WeaklyMonoBase rhs)
|
||||
{
|
||||
if(lhs == null)
|
||||
return rhs == null;
|
||||
if(rhs == null)
|
||||
return lhs == null;
|
||||
return lhs.Equals(rhs);
|
||||
}
|
||||
|
||||
public static bool operator !=(WeaklyMonoBase lhs, WeaklyMonoBase rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
public static implicit operator bool(WeaklyMonoBase lhs)
|
||||
{
|
||||
return lhs.Equals(null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
11
Runtime/Type/WeaklyMonoBase.cs.meta
Normal file
11
Runtime/Type/WeaklyMonoBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8bdf55a4d01a44418c07a6bfcfa7d15
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
Runtime/Type/WeaklyObject.cs
Normal file
44
Runtime/Type/WeaklyObject.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.Type
|
||||
{
|
||||
public class WeaklyObject
|
||||
{
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return base.ToString();
|
||||
}
|
||||
|
||||
public static bool operator ==(WeaklyObject lhs, WeaklyObject rhs)
|
||||
{
|
||||
if(lhs == null)
|
||||
return rhs == null;
|
||||
if(rhs == null)
|
||||
return lhs == null;
|
||||
return lhs.Equals(rhs);
|
||||
}
|
||||
|
||||
public static bool operator !=(WeaklyObject lhs, WeaklyObject rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
public static implicit operator bool(WeaklyObject lhs)
|
||||
{
|
||||
return lhs.Equals(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Type/WeaklyObject.cs.meta
Normal file
11
Runtime/Type/WeaklyObject.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bac5cbcb94dfc5847a0b628887919d7b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
112
Runtime/Type/WeaklyObjectBase.cs
Normal file
112
Runtime/Type/WeaklyObjectBase.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
#define _HIGHQUALITYRANDOM_
|
||||
|
||||
using XericLibrary.Runtime.MacroLibrary;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.Type
|
||||
{
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class WeaklyObjectBase : WeaklyObject
|
||||
{
|
||||
#region <EFBFBD>ֶ<EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20>ϴβ<CFB4><CEB2><EFBFBD>ʱ<EFBFBD><CAB1>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
private static DateTime lastDate = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// <20>ϴβ<CFB4><CEB2><EFBFBD>ʱ<EFBFBD><CAB1>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
private static ulong lastTime = 0;
|
||||
|
||||
/// <summary>
|
||||
/// ͬһʱ<D2BB><CAB1><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ʹ<><CAB9>ulongֻ<67><D6BB>Ϊ<EFBFBD>˲<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>Ϸ<EFBFBD>Χֻ<CEA7><D6BB>short<72><74><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵҲû<D2B2>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>
|
||||
/// </summary>
|
||||
private static ulong sameCount = 0;
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>к<EFBFBD>
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private ulong suffixIndex = 0;
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>й<EFBFBD>ϣ
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private string suffixHash;
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><D7BA><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public ulong SuffixIndex => suffixIndex;
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><D7BA><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public string SuffixHash => suffixHash;
|
||||
|
||||
/// <summary>
|
||||
/// ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
private static ulong InstanceCounters
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
if(lastDate.ToString() != DateTime.Now.ToString())
|
||||
{
|
||||
lastDate = DateTime.Now;
|
||||
lastTime = 0;
|
||||
string now = DateTime.Now.ToString();
|
||||
for(int i = 0; i < now.Length; i++)
|
||||
{
|
||||
lastTime ^= (ulong)now[i] << (56 - (int)((float)i / now.Length * 63));
|
||||
#if _HIGHQUALITYRANDOM_
|
||||
MacroMath.RandomNumber(lastTime);
|
||||
#endif
|
||||
}
|
||||
sameCount = 0;
|
||||
}
|
||||
return sameCount++ + MacroMath.RandomNumber(lastTime);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// ע<>ⲻҪ<E2B2BB><D2AA><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>ֱ<EFBFBD>ӳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ᵼ<EFBFBD><E1B5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䲻<EFBFBD><E4B2BB>
|
||||
/// </summary>
|
||||
public WeaklyObjectBase()
|
||||
{
|
||||
InitWeaklyObjectIndex();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
public void InitWeaklyObjectIndex()
|
||||
{
|
||||
suffixIndex = InstanceCounters;
|
||||
suffixHash = MacroMath.MurmurFinalize(suffixIndex).ToString("X");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
11
Runtime/Type/WeaklyObjectBase.cs.meta
Normal file
11
Runtime/Type/WeaklyObjectBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9cf76d46fc472db4fbd9351402c59c04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Runtime/WindowsSystem.meta
Normal file
8
Runtime/WindowsSystem.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5fc6b770cabbcf04688e4925cfd3dc3b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Runtime/WindowsSystem/SMTC.cs
Normal file
35
Runtime/WindowsSystem/SMTC.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.WindowsSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// SMTC Transport Protocol Example Library
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// SMTC<54><43>System Media Transport Controls<6C><73><EFBFBD><EFBFBD>д<EFBFBD><D0B4>
|
||||
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Windows 10<31>豸<EFBFBD>Ŀؼ<C4BF><D8BC><EFBFBD>
|
||||
/// Ϊ<>û<EFBFBD><C3BB>ṩһ<E1B9A9>µķ<C2B5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>MediaPlayer<65><72><EFBFBD>в<EFBFBD><D0B2>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD>岥<EFBFBD><E5B2A5>12<31><32>
|
||||
/// </remarks>
|
||||
public static class SMTC
|
||||
{
|
||||
//void aaa()
|
||||
//{
|
||||
|
||||
// MediaPlayer mediaPlayer = new MediaPlayer();
|
||||
|
||||
// // <20><>ȡSMTC
|
||||
// SystemMediaTransportControls smtc = SystemMediaTransportControls.GetForCurrentView();
|
||||
|
||||
// // <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>ŵ<EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||
// MediaItemDisplayProperties props = smtc.DisplayUpdater.MusicProperties;
|
||||
|
||||
// // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
// string title = props.Title;
|
||||
// string artist = props.Artist;
|
||||
// string albumArtist = props.AlbumArtist;
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
11
Runtime/WindowsSystem/SMTC.cs.meta
Normal file
11
Runtime/WindowsSystem/SMTC.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 983cbd90a24344b48b370ebc2d7e374a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Sample.meta
Normal file
8
Sample.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7b40f5fb9e82d5489e64e495086efc6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Sample/FeigenbaumConstant.meta
Normal file
8
Sample/FeigenbaumConstant.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50284f9be7a194b46ae71888697a7264
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Sample/FeigenbaumConstant/FeigenbaumConstant.meta
Normal file
8
Sample/FeigenbaumConstant/FeigenbaumConstant.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5af7e005eb125b74b966d59e1ebcf090
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
6
Sample/FeigenbaumConstant/FeigenbaumConstant/App.config
Normal file
6
Sample/FeigenbaumConstant/FeigenbaumConstant/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
</configuration>
|
||||
32
Sample/FeigenbaumConstant/FeigenbaumConstant/App.config.meta
Normal file
32
Sample/FeigenbaumConstant/FeigenbaumConstant/App.config.meta
Normal file
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26aa23cdf06a1c149940bd9e7a9f753b
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 1
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7437ebf70336c604f837a7d3ce4ffbcc
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 813aec0738ebeb74ebef4f2ed251ecfc
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Sample/FeigenbaumConstant/FeigenbaumConstant/Program.cs
Normal file
55
Sample/FeigenbaumConstant/FeigenbaumConstant/Program.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FeigenbaumConstant
|
||||
{
|
||||
/// <summary>
|
||||
/// 费根鲍姆常数计算器
|
||||
/// <code>
|
||||
/// 费根鲍姆常数是一个现代科学计算的常数,
|
||||
/// 是被周期分叉及混沌现象的一个比值,约为4.669,
|
||||
/// 世界乃至宇宙万物的规律都跟这个常数有关,
|
||||
/// 包括生物神经电现象,经济,电流,交通流,甚至水龙头滴出来的水都有这个现象。
|
||||
/// </code>
|
||||
/// </summary>
|
||||
internal class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前人口
|
||||
/// </summary>
|
||||
static decimal px= 2;
|
||||
|
||||
/// <summary>
|
||||
/// 当前增长率
|
||||
/// </summary>
|
||||
static decimal pr = 2;
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine($"开始人口{px},增长率{pr}");
|
||||
while(px >= 0)
|
||||
{
|
||||
px = RobertMay_PopulationGrowthModel(pr, px);
|
||||
Console.WriteLine($"{px}");
|
||||
}
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用来计算的公式,
|
||||
/// 这里使用的是 罗伯特·梅 的 人口增长模型
|
||||
/// </summary>
|
||||
/// <param name="r">人口增长率</param>
|
||||
/// <param name="xn">第n代人口,</param>
|
||||
/// <returns>输出X_n+1表示下一代的人口</returns>
|
||||
static decimal RobertMay_PopulationGrowthModel(decimal r, decimal xn)
|
||||
{
|
||||
// X_n+1 = r X_n ( 1 - X_n )
|
||||
|
||||
return r * xn * (1 - xn);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Sample/FeigenbaumConstant/FeigenbaumConstant/Program.cs.meta
Normal file
11
Sample/FeigenbaumConstant/FeigenbaumConstant/Program.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 966be8e483dde584fbda8a4377bd77bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a5bc2d12b7dc7740999c7585accccf8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("FeigenbaumConstant")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("FeigenbaumConstant")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("ee221233-2074-4a7d-a0d0-1ddec5624dc4")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f7c7d85220ad4346bbfa3665f4f7a0e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Sample/FeigenbaumConstant/FeigenbaumConstant/bin.meta
Normal file
8
Sample/FeigenbaumConstant/FeigenbaumConstant/bin.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9f096beb45698c41ae41c2142520894
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5fad2166d2e250848a1e46a6f82dbeea
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
</configuration>
|
||||
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2435f80b4bc6954b82c112d091c0f0c
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 1
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6b103c29d45eea47afaa9939fc49374
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Sample/FeigenbaumConstant/FeigenbaumConstant/obj.meta
Normal file
8
Sample/FeigenbaumConstant/FeigenbaumConstant/obj.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ecbcedec3e2fe8a43820fb40ce3f295d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fe415040d3d67e4091b6cdec7abfb46
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c25c49f9c87f7ad489d78e0be2f4412d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb381742126580b42b6574ccf0877128
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd9fc11cd56677040b2bb913bcbf3338
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
G:\UnityProject\MyPrit\Packages\com.lrss3.xericlibrary\Sample\FeigenbaumConstant\FeigenbaumConstant\bin\Debug\FeigenbaumConstant.exe.config
|
||||
G:\UnityProject\MyPrit\Packages\com.lrss3.xericlibrary\Sample\FeigenbaumConstant\FeigenbaumConstant\bin\Debug\FeigenbaumConstant.exe
|
||||
G:\UnityProject\MyPrit\Packages\com.lrss3.xericlibrary\Sample\FeigenbaumConstant\FeigenbaumConstant\bin\Debug\FeigenbaumConstant.pdb
|
||||
G:\UnityProject\MyPrit\Packages\com.lrss3.xericlibrary\Sample\FeigenbaumConstant\FeigenbaumConstant\obj\Debug\FeigenbaumConstant.csproj.AssemblyReference.cache
|
||||
G:\UnityProject\MyPrit\Packages\com.lrss3.xericlibrary\Sample\FeigenbaumConstant\FeigenbaumConstant\obj\Debug\FeigenbaumConstant.csproj.SuggestedBindingRedirects.cache
|
||||
G:\UnityProject\MyPrit\Packages\com.lrss3.xericlibrary\Sample\FeigenbaumConstant\FeigenbaumConstant\obj\Debug\FeigenbaumConstant.csproj.CoreCompileInputs.cache
|
||||
G:\UnityProject\MyPrit\Packages\com.lrss3.xericlibrary\Sample\FeigenbaumConstant\FeigenbaumConstant\obj\Debug\FeigenbaumConstant.exe
|
||||
G:\UnityProject\MyPrit\Packages\com.lrss3.xericlibrary\Sample\FeigenbaumConstant\FeigenbaumConstant\obj\Debug\FeigenbaumConstant.pdb
|
||||
@@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51ebe42b1738ff64ea409a84d5b05c3e
|
||||
AssemblyDefinitionImporter:
|
||||
guid: ce636184b8aeab043b2ab413db44175f
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf0612e25fc294849a90ec46579e58d3
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2cedfacef3c91b44bb4e22b96041f59a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 081141d0177247448aedd101e596e33f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"displayName":"Example Sample",
|
||||
"description": "Replace this string with your own description of the sample. Delete the Samples folder if not needed.",
|
||||
"createSeparatePackage": false
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// Use this sample example C# file to develop samples to guide usage of APIs
|
||||
// in your package.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
namespace Lrss3.XericLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// Provide a general description of the public class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Packages require XmlDoc documentation for ALL Package APIs.
|
||||
/// https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/xml-documentation-comments
|
||||
/// </remarks>
|
||||
public class MyPublicSampleExampleClass
|
||||
{
|
||||
/// <summary>
|
||||
/// Provide a description of what this public method does.
|
||||
/// </summary>
|
||||
public void CountThingsAndDoStuffAndOutputIt()
|
||||
{
|
||||
var result = new MyPublicRuntimeExampleClass().CountThingsAndDoStuff(1, 2, false);
|
||||
Debug.Log("Call CountThingsAndDoStuffAndOutputIt returns " + result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine.TestTools;
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
|
||||
namespace Lrss3.XericLibrary.Editor.Tests
|
||||
{
|
||||
|
||||
class EditorExampleTest
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void EditorSampleTestSimplePasses()
|
||||
{
|
||||
// Use the Assert class to test conditions.
|
||||
}
|
||||
|
||||
// A UnityTest behaves like a coroutine in PlayMode
|
||||
// and allows you to yield null to skip a frame in EditMode
|
||||
[UnityTest]
|
||||
public IEnumerator EditorSampleTestWithEnumeratorPasses()
|
||||
{
|
||||
// Use the Assert class to test conditions.
|
||||
// yield to skip a frame
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"name": "Lrss3.XericLibrary.Editor.Tests",
|
||||
"references": [
|
||||
"Lrss3.XericLibrary.Editor",
|
||||
"Lrss3.XericLibrary"
|
||||
],
|
||||
"optionalUnityReferences": [
|
||||
"TestAssemblies"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": []
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 296acdc89982788448c050eb596ad6f8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"name": "Lrss3.XericLibrary.Tests",
|
||||
"references": [
|
||||
"Lrss3.XericLibrary"
|
||||
],
|
||||
"optionalUnityReferences": [
|
||||
"TestAssemblies"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": []
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d2a3c8f571496842b07eb6a6ed1b1b6
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,28 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
|
||||
namespace Lrss3.XericLibrary.Tests
|
||||
{
|
||||
|
||||
class RuntimeExampleTest
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void PlayModeSampleTestSimplePasses()
|
||||
{
|
||||
// Use the Assert class to test conditions.
|
||||
}
|
||||
|
||||
// A UnityTest behaves like a coroutine in PlayMode
|
||||
// and allows you to yield null to skip a frame in EditMode
|
||||
[UnityTest]
|
||||
public IEnumerator PlayModeSampleTestWithEnumeratorPasses()
|
||||
{
|
||||
// Use the Assert class to test conditions.
|
||||
// yield to skip a frame
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dba38a948462fe547b61062ffe8426c8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
package.json
14
package.json
@@ -1,9 +1,7 @@
|
||||
{
|
||||
"name": "com.lrss3.xericlibrary",
|
||||
"displayName":"Xeric Library",
|
||||
"version": "0.1.0",
|
||||
"unity": "2021.3",
|
||||
"description": "Replace this string with your own description of the package. This description appears in the Package Manager window when the user selects this package from the list. \n\nFor best results, use this text to summarize: \n\u25AA What the package does \n\u25AA How it can benefit the user \n\nNote: Special formatting characters are supported, including line breaks ('\\n') and bullets ('\\u25AA').",
|
||||
"dependencies": {
|
||||
}
|
||||
}
|
||||
"name": "com.lrss3.xericlibrary",
|
||||
"displayName": "Xeric Library",
|
||||
"version": "0.1.1",
|
||||
"unity": "2021.3",
|
||||
"description": "Replace this string with your own description of the package. This description appears in the Package Manager window when the user selects this package from the list. \n\nFor best results, use this text to summarize: \n\u25aa What the package does \n\u25aa How it can benefit the user \n\nNote: Special formatting characters are supported, including line breaks ('\\n') and bullets ('\\u25AA')."
|
||||
}
|
||||
Reference in New Issue
Block a user