Archived
添加了一些用于名称切换数据,可以满足随机名称的要求
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// 缓动步进库
|
||||
/// </summary>
|
||||
public static class MacroInching
|
||||
{
|
||||
/// <summary>
|
||||
/// 线性步进
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static double LinearTowards(double from, double to, double maxStepDelta)
|
||||
{
|
||||
return from + Math.Clamp(to - from, -maxStepDelta, maxStepDelta);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 线性步进
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static float LinearTowards(float from, float to, float maxStepDelta)
|
||||
{
|
||||
return (float)LinearTowards((double)from, (double)to, (double)maxStepDelta);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25b8c78062bd7454a944e8f73f7f17b5
|
||||
guid: dde2a3b263805b34db3b546fd5922f43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,3 +1,5 @@
|
||||
using Codice.CM.Triggers;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
@@ -129,7 +131,7 @@ namespace XericLibrary.Runtime.MacroLibrary
|
||||
#endregion
|
||||
|
||||
#region 应用算法
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取列表中随机顺序的对象
|
||||
/// </summary>
|
||||
@@ -144,6 +146,24 @@ namespace XericLibrary.Runtime.MacroLibrary
|
||||
yield return list[index[i]];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对列表中的成员按组进行划分,并读取特定组中特定索引下的成员
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="target"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<T> GetListGroupMember<T>(this List<T> list, int group, int target)
|
||||
{
|
||||
if(list.Count % group != 0)
|
||||
throw new Exception("在进行列组成员获取时,组不能刚好整除列表总数");
|
||||
|
||||
for(int i = 0; i < list.Count; i++)
|
||||
if((i % group) == target)
|
||||
yield return list[i];
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// 矢量宏库
|
||||
/// </summary>
|
||||
[Obsolete("与扩展库放在一起,不要单独出现")]
|
||||
public static class MacroVector3
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取与世界正交轴最近的一条轴线
|
||||
/// </summary>
|
||||
/// <param name="vector"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public static Vector3 GetWorldNormalAxis(Vector3 vector)
|
||||
{
|
||||
Vector3[] axes = { Vector3.right, Vector3.up, Vector3.forward };
|
||||
float minAngle = float.MaxValue;
|
||||
Vector3 minAngleAxis = Vector3.zero;
|
||||
|
||||
foreach(Vector3 axis in axes)
|
||||
{
|
||||
float dot = Vector3.Dot(vector, axis);
|
||||
float angle = Mathf.Abs(dot);
|
||||
if(angle < minAngle)
|
||||
{
|
||||
minAngle = angle;
|
||||
minAngleAxis = axis * Mathf.Sign(dot);
|
||||
}
|
||||
}
|
||||
|
||||
return minAngleAxis;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,10 @@ namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
public static class Vector2Extend
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector2 OneMinus(this Vector2 a)
|
||||
=> new Vector2(1 - a.x, 1 - a.y);
|
||||
|
||||
[Obsolete("unfinished")]
|
||||
public static Vector2 Projection(this Vector2 point, Vector3 start, Vector3 end)
|
||||
{
|
||||
|
||||
@@ -107,6 +107,10 @@ namespace XericLibrary.Runtime.MacroLibrary
|
||||
a.z / b
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 OneMinus(this Vector3 a)
|
||||
=> new Vector3(1 - a.x, 1 - a.y, 1 - a.z);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展运算
|
||||
|
||||
Reference in New Issue
Block a user