This commit is contained in:
MuHua-123
2024-11-25 18:32:05 +08:00
parent 72d1f89b54
commit 84243e75a8
353 changed files with 17666 additions and 3206 deletions
-19
View File
@@ -1,19 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class DataPlateTool {
/// <summary> 核心模块 </summary>
private static ModuleCore ModuleCore => ModuleCore.I;
/// <summary> 可视化模块 </summary>
private static ModuleVisual<DataPlate> VisualPlate => ModuleCore.VisualPlate;
/// <summary> 多边形算法模块 </summary>
private static ModuleAlgorithm<DataPlate> AlgorithmPolygon => ModuleCore.AlgorithmPolygon;
public static void UpdateVisual(this DataPlate data) {
//多边形计算
AlgorithmPolygon.Compute(data);
//生成可视化内容
VisualPlate.UpdateVisual(data);
}
}
-9
View File
@@ -1,9 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class DataPointTool {
public static Vector3 DefaultBezier(Vector3 a, Vector3 b) {
return (b - a) * 0.3f;
}
}
+33
View File
@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class DataSideTool {
public static void SetBezierPositionA(this DataSide side, Vector3 position) {
if (side.bezier == Bezier.) { return; }
if (side.bezier == Bezier.) { side.bBezier = position; }
side.aBezier = position;
}
public static void SetBezierPositionB(this DataSide side, Vector3 position) {
if (side.bezier == Bezier.) { return; }
if (side.bezier == Bezier.) { side.aBezier = position; }
side.bBezier = position;
}
public static void OneRankBezier(this DataSide side) {
side.bezier = Bezier.;
}
public static void TwoRankBezier(this DataSide side) {
side.bezier = Bezier.;
DataPoint a = side.aPoint;
DataPoint b = side.bPoint;
side.aBezier = a.position + (b.position - a.position) * 0.5f;
side.bBezier = a.position + (b.position - a.position) * 0.5f;
}
public static void ThreeRankBezier(this DataSide side) {
side.bezier = Bezier.;
DataPoint a = side.aPoint;
DataPoint b = side.bPoint;
side.aBezier = a.position + (b.position - a.position) * 0.3f;
side.bBezier = a.position + (b.position - a.position) * 0.7f;
}
}
+12
View File
@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class DataSutureTool {
public static float SutureLength(this DataSuture suture) {
if (suture.a.MaxLength < suture.b.MaxLength) {
return suture.a.MaxLength;
}
else { return suture.b.MaxLength; }
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 79682c49363b7bb4f8ca387d80cd5b1f
guid: 37c96b1f560cfb14caa5c758ce900239
MonoImporter:
externalObjects: {}
serializedVersion: 2
+48
View File
@@ -0,0 +1,48 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GridTool<Data> {
public Data[,] array;
public readonly int wide;
public readonly int high;
/// <summary> 初始化网格 </summary>
public GridTool(int wide, int high, Func<int, int, Data> generate) {
this.wide = wide;
this.high = high;
array = new Data[wide, high];
Loop((x, y) => { array[x, y] = generate(x, y); });
}
/// <summary> 循环网格获取x和y </summary>
public void Loop(Action<int, int> action) {
for (int y = 0; y < high; y++) {
for (int x = 0; x < wide; x++) { action?.Invoke(x, y); }
}
}
/// <summary> 校验xy是否超限 </summary>
public bool TryXY(int x, int y) {
return x >= 0 && x < wide && y >= 0 && y < high;
}
/// <summary> 强制写入数据,超过边界时写在边界 </summary>
public Data Get(int x, int y) {
x = Mathf.Clamp(x, 0, wide - 1);
y = Mathf.Clamp(y, 0, high - 1);
return array[x, y];
}
/// <summary> 强制读取数据,超过边界时读取边界 </summary>
public void Set(int x, int y, Data data) {
x = Mathf.Clamp(x, 0, wide - 1);
y = Mathf.Clamp(y, 0, high - 1);
array[x, y] = data;
}
/// <summary> 校验xy是否超限 读取正确范围内的数据 </summary>
public bool TryGet(int x, int y, out Data data) {
data = Get(x, y); return TryXY(x, y);
}
/// <summary> 校验xy是否超限 写入正确范围内的数据 </summary>
public bool TrySet(int x, int y, Data data) {
if (TryXY(x, y)) { array[x, y] = data; return true; }
else { return false; }
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 101c9bc9bc2c5a34389120061f5de367
guid: 0d586f3bf8d81b64da59700b2f31c48a
MonoImporter:
externalObjects: {}
serializedVersion: 2
+11
View File
@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 图层遮罩工具
/// </summary>
public static class LayerMaskTool {
/// <summary> 安排点图层遮罩 </summary>
public static readonly LayerMask Arrange = 1 << LayerMask.NameToLayer("Arrange");
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f6c7eea6439008142b8aaeae1445a351
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
-30
View File
@@ -1,30 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
public static class ModuleCoreTool {
public static void FunctionRegister<Module>(this ModuleCore core, Module module) {
Type baseType = module.GetType().BaseType;
FieldInfo fieldInfo = FindField<ModuleCore>(baseType);
if (fieldInfo == null) {
Debug.LogError($"{typeof(ModuleCore).Name} 类型没有 {baseType.Name} 字段!");
return;
}
object obj = fieldInfo.GetValue(core);
if (obj != null) {
Debug.LogWarning($"{module.GetType().Name} 模块替换了 {obj.GetType().Name} 模块!");
return;
}
fieldInfo.SetValue(core, module);
}
public static FieldInfo FindField<T>(Type baseType) {
FieldInfo[] fileInfos = typeof(T).GetFields();
for (int i = 0; i < fileInfos.Length; i++) {
if (fileInfos[i].FieldType == baseType) { return fileInfos[i]; }
}
return null;
}
}
+10
View File
@@ -0,0 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class VectorTool {
/// <summary> 向量的xyz和 </summary>
public static float VectorSum(this Vector3 v) {
return v.x + v.y + v.z;
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3909cc8b21b91e740b86bb3a8ffcda0e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: