+ Complex32 x = new Complex32(1f,2f);
+ Complex32 y = Complex32.FromPolarCoordinates(1f, Math.Pi);
+ Complex32 z = (x + y) / (x - y);
+
+
+ // a, b of type Complex32
+ a.Conjugate = b;
+
+ is equivalent to
+
+ // a, b of type Complex32
+ a = b.Conjugate
+
+
+ long x,y,d;
+ d = Fn.GreatestCommonDivisor(45,18,out x, out y);
+ -> d == 9 && x == 1 && y == -2
+
+ The
+ long x,y,d;
+ d = Fn.GreatestCommonDivisor(45,18,out x, out y);
+ -> d == 9 && x == 1 && y == -2
+
+ The + 1, 2, 3 + 4, 5, 6 will be returned as 1, 4, 7, 2, 5, 8, 3, 6, 9 + 7, 8, 9 +
+ 1, 2, 3 + 4, 5, 6 will be returned as 1, 2, 3, 4, 5, 6, 7, 8, 9 + 7, 8, 9 +
+ 1, 2, 3 + 4, 5, 6 will be returned as 1, 4, 7, 2, 5, 8, 3, 6, 9 + 7, 8, 9 +
+ 1, 2, 3 + 4, 5, 6 will be returned as 1, 2, 3, 4, 5, 6, 7, 8, 9 + 7, 8, 9 +
Xn = a * Xn鈭�3 + c mod 2^32
+ http://www.jstatsoft.org/v08/i14/paper
+ x -> exp(x)-1
+ exp(power)-1.x -> exp(x)-1
+ exp(power)-1.(a,b) -> sqrt(a^2 + b^2)
+ sqrt(a2 + b2) without underflow/overflow.(a,b) -> sqrt(a^2 + b^2)
+ sqrt(a2 + b2) without underflow/overflow.(a,b) -> sqrt(a^2 + b^2)
+ sqrt(a2 + b2) without underflow/overflow.(a,b) -> sqrt(a^2 + b^2)
+ sqrt(a2 + b2) without underflow/overflow.+ N-1 + - ' + y = > coef[i] T (x/2) + - i + i=0 ++ Coefficients are stored in reverse order, i.e. the zero + order term is last in the array. Note N is the number of + coefficients, not the order. + + If coefficients are for the interval a to b, x must + have been transformed to x -> 2(2x - b - a)/(b-a) before + entering the routine. This maps x from (a, b) to (-1, 1), + over which the Chebyshev polynomials are defined. + + If the coefficients are for the inverted interval, in + which (a, b) is mapped to (1/b, 1/a), the transformation + required is x -> 2(2ab/x - b - a)/(b-a). If b is infinity, + this becomes x -> 4a/x - 1. + + SPEED: + + Taking advantage of the recurrence properties of the + Chebyshev polynomials, the routine requires one more + addition per loop than evaluating a nested polynomial of + the same degree. +
@@ -157,9 +155,9 @@ namespace LRC
///
///
@@ -333,16 +331,20 @@ namespace LRC
public bool ForceBlockUpdate
{
get => forceBlockUpdate;
- set => forceBlockUpdate = value;
+ set => forceBlockUpdate = value;
}
-
+
///
/// 项目标题
///
public string TitleName
{
get => titleLabel.text;
- set => titleLabel.text = value;
+ set
+ {
+ if (titleLabel != null)
+ titleLabel.text = value;
+ }
}
///
@@ -375,7 +377,7 @@ namespace LRC
get => unitLabel.text;
set => unitLabel.text = value;
}
-
+
[SerializeField]
// [Obsolete("请使用访问器")]
private object _value;
@@ -385,7 +387,7 @@ namespace LRC
///
public object Value
{
- get => _value;
+ get => _value;
protected set
{
if (IsValueInitNull && value != null)
@@ -395,11 +397,11 @@ namespace LRC
}
// ==== 暂存 ==== //
-
+
public FieldInfo FieldInfo;
public Type FieldType;
-
+
#endregion
#region 生命周期
@@ -431,7 +433,7 @@ namespace LRC
ConfigItemList.Add(this);
ForceUpdateAllConfigEvent += ForceUpdate;
ForceSetAllSourceValueEvent += SetSourceValueRequest;
-
+
if (dirtyAutoReset)
IsDirty = false;
}
@@ -535,9 +537,9 @@ namespace LRC
_ => Vector3.zero
};
}
-
+
#endregion
-
+
#region 初始化方法
///
@@ -600,7 +602,7 @@ namespace LRC
#endregion
#region 更新方法
-
+
///
/// 更新函数
///
@@ -614,7 +616,7 @@ namespace LRC
IsDirty = false;
var value = GetSourceValue?.Invoke(this);
if (value == null)
- return ;
+ return;
RefreshValueWithoutEvent(value, forceSet);
RefreshAutoUpdateValue();
}
@@ -665,15 +667,15 @@ namespace LRC
{
var isSourceValueAutoUpdate = GetSourceValueAutoUpdate?.Invoke(this);
if (isSourceValueAutoUpdate != null)
- AutoUpdateValue = isSourceValueAutoUpdate.Value;
+ AutoUpdateValue = isSourceValueAutoUpdate.Value;
}
-
+
///
/// 刷新格式化文本,在触发刷新时将产生更新
///
protected virtual void RefreshFormatValue(object newValue)
{
-
+
}
protected void WhenStartEdit()
@@ -681,7 +683,7 @@ namespace LRC
// Debug.Log("开始编辑");
ForceBlockUpdate = true;
}
-
+
///
/// 数值输入完毕,或焦点移除时调用。
///
@@ -691,7 +693,7 @@ namespace LRC
ForceBlockUpdate = false;
OnEndEdit?.Invoke(this, Value);
}
-
+
#endregion
#region 外观设定
@@ -705,7 +707,7 @@ namespace LRC
Destroy(autoUpdateValueToggle.gameObject);
this.autoUpdateValue = autoUpdateValueReversalState ^ autoUpdateValue;
}
-
+
#endregion
}
diff --git a/Samples~/ConfigUIElement/Scripts/ConfigSelectableItem.cs.meta b/Samples~/ConfigUIElement/Scripts/Element/ConfigSelectableItem.cs.meta
similarity index 100%
rename from Samples~/ConfigUIElement/Scripts/ConfigSelectableItem.cs.meta
rename to Samples~/ConfigUIElement/Scripts/Element/ConfigSelectableItem.cs.meta
diff --git a/Samples~/ConfigUIElement/Scripts/ConfigTextInputField.cs b/Samples~/ConfigUIElement/Scripts/Element/ConfigTextInputField.cs
similarity index 81%
rename from Samples~/ConfigUIElement/Scripts/ConfigTextInputField.cs
rename to Samples~/ConfigUIElement/Scripts/Element/ConfigTextInputField.cs
index 0db11a9..314b69d 100644
--- a/Samples~/ConfigUIElement/Scripts/ConfigTextInputField.cs
+++ b/Samples~/ConfigUIElement/Scripts/Element/ConfigTextInputField.cs
@@ -1,10 +1,5 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
using TMPro;
-using UnityEngine;
using UnityEngine.EventSystems;
-using UnityEngine.UI;
namespace LRC
{
@@ -14,14 +9,19 @@ namespace LRC
public class ConfigTextInputField : ConfigSelectableItem
{
#region 属性字段
-
+
#if UNITY_EDITOR
public string editorInput;
#endif
-
+
public TMP_InputField targetInput;
-
+
+ // 定义一个委托,接受字符串参数并返回布尔值
+ public delegate bool StringEventHandler(string input);
+ // 声明事件
+ public static event StringEventHandler 判断是否重名;
+
public override bool AllowInput
{
get => base.AllowInput;
@@ -53,19 +53,25 @@ namespace LRC
{
WhenStartEdit();
});
- targetInput.onValueChanged.AddListener(o =>
+ targetInput.onEndEdit.AddListener(o =>
{
- if(double.TryParse(o, out var value))
- SetValue(value);
+ if (判断是否重名 != null)
+ {
+ if (判断是否重名.Invoke(o))
+ {
+ SetValue(o);
+ }
+ }
});
targetInput.onEndEdit.AddListener(delegate
{
WhenEndEdit();
});
+
}
#endregion
-
+
#region 实现
protected override void SetValue(object newValue)
@@ -77,11 +83,11 @@ namespace LRC
{
base.RefreshValueWithoutEvent(newValue, forceSet);
}
-
+
protected override void Initialization_ChildConstruction(UIBehaviour component)
{
base.Initialization_ChildConstruction(component);
-
+
if (component is TMP_InputField inputField)
{
if (targetInput != null)
@@ -94,7 +100,7 @@ namespace LRC
base.RefreshFormatValue(newValue);
targetInput.text = newValue.ToString();
}
-
+
#endregion
}
}
diff --git a/Samples~/ConfigUIElement/Scripts/ConfigTextInputField.cs.meta b/Samples~/ConfigUIElement/Scripts/Element/ConfigTextInputField.cs.meta
similarity index 100%
rename from Samples~/ConfigUIElement/Scripts/ConfigTextInputField.cs.meta
rename to Samples~/ConfigUIElement/Scripts/Element/ConfigTextInputField.cs.meta
diff --git a/Samples~/ConfigUIElement/Scripts/ConfigToggleGroup.cs b/Samples~/ConfigUIElement/Scripts/Element/ConfigToggleGroup.cs
similarity index 98%
rename from Samples~/ConfigUIElement/Scripts/ConfigToggleGroup.cs
rename to Samples~/ConfigUIElement/Scripts/Element/ConfigToggleGroup.cs
index d795027..db2575f 100644
--- a/Samples~/ConfigUIElement/Scripts/ConfigToggleGroup.cs
+++ b/Samples~/ConfigUIElement/Scripts/Element/ConfigToggleGroup.cs
@@ -78,6 +78,8 @@ namespace LRC
// toggle.isOn = true;
// Debug.Log(TitleName +":设置布尔项目");
// }
+
+ //toggles[newIndex].isOn = true;
toggles[newIndex].SetIsOnWithoutNotify(true);
}
diff --git a/Samples~/ConfigUIElement/Scripts/ConfigToggleGroup.cs.meta b/Samples~/ConfigUIElement/Scripts/Element/ConfigToggleGroup.cs.meta
similarity index 100%
rename from Samples~/ConfigUIElement/Scripts/ConfigToggleGroup.cs.meta
rename to Samples~/ConfigUIElement/Scripts/Element/ConfigToggleGroup.cs.meta
diff --git a/Samples~/ConfigUIElement/Scripts/ConfigTypeOverrideAttribute.cs b/Samples~/ConfigUIElement/Scripts/Element/ConfigTypeOverrideAttribute.cs
similarity index 100%
rename from Samples~/ConfigUIElement/Scripts/ConfigTypeOverrideAttribute.cs
rename to Samples~/ConfigUIElement/Scripts/Element/ConfigTypeOverrideAttribute.cs
diff --git a/Samples~/ConfigUIElement/Scripts/ConfigTypeOverrideAttribute.cs.meta b/Samples~/ConfigUIElement/Scripts/Element/ConfigTypeOverrideAttribute.cs.meta
similarity index 100%
rename from Samples~/ConfigUIElement/Scripts/ConfigTypeOverrideAttribute.cs.meta
rename to Samples~/ConfigUIElement/Scripts/Element/ConfigTypeOverrideAttribute.cs.meta
diff --git a/Samples~/ConfigUIElement/Scripts/ConfigVec2InputField.cs b/Samples~/ConfigUIElement/Scripts/Element/ConfigVec2InputField.cs
similarity index 100%
rename from Samples~/ConfigUIElement/Scripts/ConfigVec2InputField.cs
rename to Samples~/ConfigUIElement/Scripts/Element/ConfigVec2InputField.cs
diff --git a/Samples~/ConfigUIElement/Scripts/ConfigVec2InputField.cs.meta b/Samples~/ConfigUIElement/Scripts/Element/ConfigVec2InputField.cs.meta
similarity index 100%
rename from Samples~/ConfigUIElement/Scripts/ConfigVec2InputField.cs.meta
rename to Samples~/ConfigUIElement/Scripts/Element/ConfigVec2InputField.cs.meta
diff --git a/Samples~/ConfigUIElement/Scripts/ConfigVec3InputField.cs b/Samples~/ConfigUIElement/Scripts/Element/ConfigVec3InputField.cs
similarity index 100%
rename from Samples~/ConfigUIElement/Scripts/ConfigVec3InputField.cs
rename to Samples~/ConfigUIElement/Scripts/Element/ConfigVec3InputField.cs
diff --git a/Samples~/ConfigUIElement/Scripts/ConfigVec3InputField.cs.meta b/Samples~/ConfigUIElement/Scripts/Element/ConfigVec3InputField.cs.meta
similarity index 100%
rename from Samples~/ConfigUIElement/Scripts/ConfigVec3InputField.cs.meta
rename to Samples~/ConfigUIElement/Scripts/Element/ConfigVec3InputField.cs.meta
diff --git a/Samples~/HorizonLineOrbit/DrawTerminalLine2T3_OpSlot.cs b/Samples~/HorizonLineOrbit/DrawTerminalLine2T3_OpSlot.cs
index 13731fc..98fd0ab 100644
--- a/Samples~/HorizonLineOrbit/DrawTerminalLine2T3_OpSlot.cs
+++ b/Samples~/HorizonLineOrbit/DrawTerminalLine2T3_OpSlot.cs
@@ -1,12 +1,4 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using Deconstruction.Element;
-using Deconstruction.Interface;
using Deconstruction.Manager;
-using Deconstruction.Tool;
-using Deconstruction.Trajectory;
using Deconstruction.Type.DMToolSlot;
using Deconstruction.Type.Linkable;
using UnityEngine;
@@ -14,8 +6,6 @@ using XericLibrary.Runtime.MacroLibrary;
namespace SesothoLine
{
- using LineSegment2 = Deconstruction.Element.PromptLine2.LineSegment2;
-
///
/// 绘制轨迹线的操作
///
@@ -83,6 +73,7 @@ namespace SesothoLine
// public SesothoArrangementWiresTool myWiresTool;
// myWiresTool = targetTool as SesothoArrangementWiresTool;
+ public static bool 判断是否在绘制区域内;
#endregion
#region 引用封装
@@ -179,7 +170,13 @@ namespace SesothoLine
ReplaceThis(new DrawTerminalLine2T3_OpSlot());
}
// 取消
- else if (IsReleaseCanelKey())
+ else if (IsReleaseCanelKey() || (!判断是否在绘制区域内))
+ {
+ RemoveThis();
+ EndPrecondition();
+ }
+ // 判断按下ESC取消线段绘制 2024.8.8
+ else if (Input.GetKeyDown(KeyCode.Escape))
{
RemoveThis();
EndPrecondition();
@@ -192,6 +189,8 @@ namespace SesothoLine
*/
}
+
+
protected override void AsyncBeforeUpdate()
{
base.AsyncBeforeUpdate();
@@ -245,8 +244,8 @@ namespace SesothoLine
{
_isStartPointSubstitute = false;
selfWiresTool.GetElement(out _startPoint);
- _lastPointPosition = SesothoArrangementWiresTool.OpKey_IgnoreNeighborAdsorption.Getkey() ?
- wfui_Slot.MouseHelperPosition :
+ _lastPointPosition = SesothoArrangementWiresTool.OpKey_IgnoreNeighborAdsorption.Getkey() ?
+ wfui_Slot.MouseHelperPosition :
CameraMouseInputHelper.Inst.GetGridAdsorb(wfui_Slot.MouseHelperPosition);
_lastPointNormal = default;
}
@@ -272,15 +271,17 @@ namespace SesothoLine
selfWiresTool.DeleteElement(_endPoint);
}
-
///
/// 线路绘制过程
///
private void DrawingProcess()
{
+ var forceStr = SesothoArrangementWiresTool.OpKey_ForceStr.Getkey();
+ var forceStraightLine = SesothoArrangementWiresTool.OpKey_ForceStraightLine.Getkey();
+ var force90Arc = SesothoArrangementWiresTool.OpKey_90Arc.Getkey();
+
// 获取当前的坐标
_helperPosition = PlaceElementManager.Inst.InputHelper.CurrentGridPosition;
-
_startPoint.transform.position = _lastPointPosition;
_isFreeEndPoint = true;
@@ -292,7 +293,7 @@ namespace SesothoLine
_isFreeEndPoint = false;
if (_endPoint.gameObject.activeSelf)
_endPoint.gameObject.SetActive(false);
-
+
_helperPosition = SesothoPeManager.NearestPoint;
_endPoint.transform.position = SesothoPeManager.NearestPoint;
if (SesothoArrangementWiresTool.GetNearestObjectAsLine(_otherPoint, out var terminalLine,
@@ -304,7 +305,7 @@ namespace SesothoLine
// {
// NearestLineTangentPoint
// }
-
+
// 否则自由点
if (_isFreeEndPoint)
{
@@ -315,6 +316,36 @@ namespace SesothoLine
_endPoint.transform.position = _helperPosition;
}
+ if (forceStr)
+ {
+ Vector3 startPos = _startPoint.GetPosition3();
+ Vector3 endPoint = _endPoint.GetPosition3();
+ if ((int)startPos.x != (int)endPoint.x && (int)startPos.z != (int)endPoint.z)
+ {
+ Vector3 vector3 = endPoint - startPos;
+ if (Mathf.Abs(vector3.x) > Mathf.Abs(vector3.z))
+ {
+ Vector3 vector = new Vector3(endPoint.x, endPoint.y, startPos.z);
+ _endPoint.SetPosition3(vector);
+ }
+ else if (Mathf.Abs(vector3.x) < Mathf.Abs(vector3.z))
+ {
+ Vector3 vector = new Vector3(startPos.x, endPoint.y, endPoint.z);
+ _endPoint.SetPosition3(vector);
+ }
+ _helperPosition = _endPoint.GetPosition3();
+ _line.SetLineSegment(
+ _lastPointPosition, _helperPosition,
+ _lastPointNormal, _helperNormal
+ );
+ }
+ }
+ else if (force90Arc)
+ {
+ _helperPosition = _line.GetEndPointWorldPosition();
+ }
+
+
_line.SetLineSegment(
_lastPointPosition, _helperPosition,
_lastPointNormal, _helperNormal
@@ -326,22 +357,24 @@ namespace SesothoLine
// Debug.Log($"角度{arc.Angle} {arc.AngleExact}");
// }
- var forceStr = SesothoArrangementWiresTool.OpKey_ForceStr.Getkey();
- if (forceStr)
+ if (forceStr || forceStraightLine)
+ {
_line.DrawStraightLine();
+ }
else
{
- var force90Arc = SesothoArrangementWiresTool.OpKey_90Arc.Getkey();
var force180Arc = SesothoArrangementWiresTool.OpKey_180Arc.Getkey();
var forceRevCisoid = SesothoArrangementWiresTool.OpKey_RevCisoid.Getkey();
-
var angle = -1;
if (force90Arc || force180Arc)
{
angle = 0;
if (force90Arc)
+ {
angle += 90;
+
+ }
if (force180Arc)
angle += 180;
}
diff --git a/Samples~/HorizonLineOrbit/SesothoArrangementWiresTool.cs b/Samples~/HorizonLineOrbit/SesothoArrangementWiresTool.cs
index 9032b58..97c220c 100644
--- a/Samples~/HorizonLineOrbit/SesothoArrangementWiresTool.cs
+++ b/Samples~/HorizonLineOrbit/SesothoArrangementWiresTool.cs
@@ -1,8 +1,5 @@
using System;
-using System.Collections;
using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.CompilerServices;
using Deconstruction.Element;
using Deconstruction.Interface;
using Deconstruction.Manager;
@@ -13,7 +10,6 @@ using Deconstruction.Type.Linkable;
using SerializerHelper.Type;
using UnityEngine;
using UnityEngine.Pool;
-using XericLibrary.Runtime.MacroLibrary;
using XericLibrary.Runtime.Nav;
namespace SesothoLine
@@ -39,19 +35,19 @@ namespace SesothoLine
/// 工具中成员移除事件
///
public event ToolMemberChange OnDecreasing;
-
+
///
/// 当任意元素苏醒
///
public event ToolMemberChange OnAnyVivification;
-
+
///
/// 当任意元素休眠
///
public event ToolMemberChange OnAnyDormancy;
-
+
#endregion
-
+
#region 快捷键
/*
@@ -61,11 +57,19 @@ namespace SesothoLine
* shift+b 忽略对象吸附
* shift+n 忽略网格吸附
*/
-
+
+ ///
+ /// 强制X轴或Y轴
+ ///
+ public static KeyPack OpKey_PlotTheXAndYAxes = new KeyPack();
+ ///
+ /// 强制X轴或Y轴直线
+ ///
+ public static KeyPack OpKey_ForceStr = new KeyPack(KeyCode.LeftControl);
///
/// 强制直线
///
- public static KeyPack OpKey_ForceStr = new KeyPack(KeyCode.Alpha1);
+ public static KeyPack OpKey_ForceStraightLine = new KeyPack(KeyCode.LeftShift, KeyCode.Q);
///
/// 强制90度圆弧
///
@@ -82,18 +86,20 @@ namespace SesothoLine
///
/// 忽略吸附功能
///
- public static KeyPack OpKey_IgnoreNeighborAdsorption = new KeyPack(KeyCode.LeftShift, KeyCode.B);
+ public static KeyPack OpKey_IgnoreNeighborAdsorption = new KeyPack(KeyCode.Alpha1);
///
/// 忽略网格吸附
///
public static KeyPack OpKey_IgnoreGridAdsorption = new KeyPack(KeyCode.LeftShift, KeyCode.N);
-
+
#endregion
#region 字段属性
private ObjectPool _linePool;
private ObjectPool _pointPool;
+ public ObjectPool LinePool => _linePool;
+ public ObjectPool PointPool => _pointPool;
#endregion
@@ -115,7 +121,7 @@ namespace SesothoLine
point = null;
return false;
}
-
+
///
/// 获取光标下最近的对象为线
///
@@ -146,27 +152,27 @@ namespace SesothoLine
if (point is null)
goto End;
// 检查最近线切线是否有效,是否相连
- if (SesothoPeManager.NearestLineTangentObject is TerminalLine2T3 otherLine &&
+ if (SesothoPeManager.NearestLineTangentObject is TerminalLine2T3 otherLine &&
point.TryGetLinkLineNormal(otherLine, out normal))
{
line = otherLine;
return true;
}
-
- End:
+
+ End:
line = null;
normal = default;
return false;
}
#endregion
-
+
#region 生命周期
protected override void Awake()
{
base.Awake();
-
+
_linePool = new ObjectPool(
createFunc: CreatElement,
actionOnGet: ElementActive,
@@ -176,7 +182,7 @@ namespace SesothoLine
collectionCheck: true,
defaultCapacity: 10,
maxSize: 10000);
-
+
_pointPool = new ObjectPool(
createFunc: CreatElement,
actionOnGet: ElementActive,
@@ -186,7 +192,7 @@ namespace SesothoLine
collectionCheck: true,
defaultCapacity: 10,
maxSize: 10000);
-
+
}
protected override void OnEnableTool()
@@ -194,13 +200,13 @@ namespace SesothoLine
// 启用时创建一个输入等待行为,随后进入绘制行为
var target = GenerateOperateSlot();
target.InitializeNextTodo(() => new DrawTerminalLine2T3_OpSlot());
-
+
Debug.Log("激活线路绘制工具");
}
protected override void OnDisableTool()
{
-
+
}
protected override void OnFinalEnd()
@@ -232,11 +238,11 @@ namespace SesothoLine
{
if (!base.ToolDiserializDispost(context))
return false;
-
+
var deserializeList = new List<(PlacementBase, SerializeUnion)>();
var safeCount = ushort.MaxValue;
Debug.Log("反序列化过程开始创建对象");
- while (0 <-- safeCount && SerializeTemp.IndexMoveToNext(out var block))
+ while (0 < --safeCount && SerializeTemp.IndexMoveToNext(out var block))
{
var union = SerializeTemp.GetDeserializeObject();
var type = TypeConsignMap.GetMapType(union.Index);
@@ -258,18 +264,18 @@ namespace SesothoLine
}
else
Debug.LogError($"无法创建序列化元素,原因是类型不支持{type}");
-
+
if (block) break;
}
Debug.Log("反序列化过程开始恢复链接关系");
foreach (var item in deserializeList)
item.Item1.DeserializeHysteresisOccurs(item.Item2);
-
+
return true;
}
#endregion
-
+
#region 方法
///
@@ -319,7 +325,7 @@ namespace SesothoLine
obj.gameObject.SetActive(false);
OnAnyDormancy?.Invoke(obj);
}
-
+
///
/// 获取元素
///
@@ -343,7 +349,7 @@ namespace SesothoLine
obj = null;
return false;
}
-
+
///
/// 获取元素
///
@@ -368,7 +374,7 @@ namespace SesothoLine
obj = null;
return false;
}
-
+
///
/// 删除元素
@@ -376,7 +382,7 @@ namespace SesothoLine
///
///
public void DeleteElement(T obj)
- where T : PlacementBase,
+ where T : PlacementBase,
ILinkconfidentPe
{
var name = typeof(T).Name;
@@ -394,8 +400,8 @@ namespace SesothoLine
}
}
-
-
+
+
///
/// 保存元素链,在创建并常态化元素后都需要执行的操作 (注意不是在创建后立刻保存)
///
@@ -404,7 +410,7 @@ namespace SesothoLine
///
///
public void PersistentElement(T obj)
- where T : PlacementBase,
+ where T : PlacementBase,
ILinkconfidentPe
{
// 保存链表结构,反过来也持有这个节点,便于后续查找
@@ -418,14 +424,14 @@ namespace SesothoLine
///
///
public void ExcisionElement(T obj)
- where T : PlacementBase,
+ where T : PlacementBase,
ILinkconfidentPe
{
if (obj.GetLinkedNode(out var node))
SesothoPeManager.Inst.RemoveLinkedTarget(node);
}
-
-
+
+
///
/// 添加小型元素到网格中
///
@@ -442,7 +448,7 @@ namespace SesothoLine
}
SesothoPeManager.Inst.InsertNeighbor(obj, out var index);
obj.NeighborGridIndex = index;
-
+
// 回调事件
OnAdditional?.Invoke(obj);
}
@@ -451,8 +457,8 @@ namespace SesothoLine
/// 添加大型元素到网格中
///
public void AddBulkPeToNeighborGrid(T obj)
- where T : PlacementBase,
- ILinkconfidentPe,
+ where T : PlacementBase,
+ ILinkconfidentPe,
IPossessorTrajectory2
{
if (obj.NeighborGridIndex != null)
@@ -462,7 +468,7 @@ namespace SesothoLine
}
SesothoPeManager.Inst.InsertGiantNeighbor(obj, out var index);
obj.NeighborGridIndex = index;
-
+
// 回调事件
OnAdditional?.Invoke(obj);
}
@@ -476,7 +482,7 @@ namespace SesothoLine
where T : PlacementBase,
ILinkconfidentPe
{
- if (obj.NeighborGridIndex != null &&
+ if (obj.NeighborGridIndex != null &&
obj.NeighborGridIndex.GetAsIndex(out var index))
SesothoPeManager.Inst.RemoveNeighbor(index);
else
@@ -485,16 +491,16 @@ namespace SesothoLine
// 回调事件
OnDecreasing?.Invoke(obj);
}
-
+
///
/// 移除这个大型元素
///
public void RemoveBulkPeFormNeighborGrid(T obj)
- where T : PlacementBase,
- ILinkconfidentPe,
+ where T : PlacementBase,
+ ILinkconfidentPe,
IPossessorTrajectory2
{
- if (obj.NeighborGridIndex != null &&
+ if (obj.NeighborGridIndex != null &&
obj.NeighborGridIndex.GetAsMappingIndex(out var index))
SesothoPeManager.Inst.RemoveGiantNeighbor(index);
else
@@ -513,7 +519,7 @@ namespace SesothoLine
*
* 主要提供绘制线路时的多段线拟合,障碍物避让
*/
-
+
///
/// 获取一个可以通过的路径
///
diff --git a/Samples~/HorizonLineOrbit/SesothoPeManager.cs b/Samples~/HorizonLineOrbit/SesothoPeManager.cs
index a0e43f0..ae6142d 100644
--- a/Samples~/HorizonLineOrbit/SesothoPeManager.cs
+++ b/Samples~/HorizonLineOrbit/SesothoPeManager.cs
@@ -12,10 +12,12 @@ using Deconstruction.Manager;
using Deconstruction.Tool;
using Deconstruction.Type.Area;
using Deconstruction.Type.Serialize;
+using Newtonsoft.Json;
using SerializerHelper.Type;
using UnityEngine.UI;
using XericLibrary.Runtime.Debuger;
using XericLibrary.Runtime.MacroLibrary;
+using Deconstruction.Type.DMToolSlot;
namespace SesothoLine
{
@@ -29,9 +31,6 @@ namespace SesothoLine
{
#region 静态成员
- ///
- /// 此处提供的单例与父类单例是独立的
- ///
public new static SesothoPeManager Inst => _inst;
private static SesothoPeManager _inst;
@@ -57,52 +56,47 @@ namespace SesothoLine
/// 光标下最近的对象
///
public static PlacementBase NearestObject => TrackingTool.TrackingCurrentTarget;
-
+
private static TrajectoryTrackingTool.TrackPersistentCommunicate _lineTangentTraceTool;
-
#endregion
#region 调试功能
#if UNITY_EDITOR
-
+
public bool EnableGridDebugDraw = false;
public void DebugFunc()
{
if (EnableGridDebugDraw)
- {
- PlacementNeighbor.DebugDrawGrid();
- }
+ PlacementNeighbor.DebugDrawGrid();
}
-
+
#endif
-
+
#endregion
-
+
#region 生命周期
-
+
protected override void Awake()
{
base.Awake();
_inst = this;
-
+
if (LineMaterial == null)
Debug.LogError("需要给管理器提供一个线段材质");
if (PointMaterial == null)
Debug.LogError("需要给管理器提供一个点材质");
-
+
// 初始化画线工具
_wiresTool = new SesothoArrangementWiresTool();
_wiresTool.InitializeParent(transform);
_lineTangentTraceTool = TrackingTool.InstantiationTrackCaculate(PlaceholdersAreaType.LinearContinuity);
-
+
// 手动开启代理更新
EnableUpdate = true;
-
-
}
protected override void Start()
@@ -127,7 +121,6 @@ namespace SesothoLine
// new SerializeUnion();
}
- private string serializeContext = null;
protected override void LateUpdate()
{
base.LateUpdate();
@@ -136,18 +129,27 @@ namespace SesothoLine
#if !UNITY_EDITOR || !_DEBUG_
return;
#endif
+ // 取消路线绘制 2024.8.8
+ /*if (Input.GetKeyDown(KeyCode.Escape))
+ {
+ _wiresTool.EnableTool = false;
+
+ //DrawTerminalLine2T3_OpSlot.RemoveThis();
+ //DrawTerminalLine2T3_OpSlot.EndPrecondition();
+ }*/
+
// 工具功能测试
- if (Input.GetKeyDown(KeyCode.L))
+ /*if (Input.GetKeyDown(KeyCode.L))
{
_wiresTool.EnableTool = !_wiresTool.EnableTool;
Debug.Log($"{(_wiresTool.EnableTool ? "绘制工具已激活" : "工具已取消激活")}");
- }
-
+ }*/
+
// 存档功能测试
- if (Input.GetKeyDown(KeyCode.S))
+ /*if (Input.GetKeyDown(KeyCode.S))
{
var obj = _wiresTool.ToolSerializeDispost();
- serializeContext = MacroFile.JsonSerializerFormatter.formatter.Serializer(obj);
+ serializeContext = JsonConvert.SerializeObject(obj);
Debug.Log(obj.ToString());
}
if (Input.GetKeyDown(KeyCode.D))
@@ -158,29 +160,31 @@ namespace SesothoLine
return;
}
- var obj = MacroFile.JsonSerializerFormatter.formatter.Deserializer(serializeContext);
+ var obj = JsonConvert.DeserializeObject(serializeContext);
_wiresTool.ToolDiserializDispost(obj);
}
if (Input.GetKeyDown(KeyCode.A))
{
_wiresTool.EnableCompress = !_wiresTool.EnableCompress;
- if (_wiresTool.EnableCompress )
+ if (_wiresTool.EnableCompress)
Debug.Log("开启压缩");
else
Debug.Log("关闭压缩");
- }
-
-
+ }*/
+
+
// 绘制一下吸附的目标位置
if (TrackingTool.EnableTool || TrackingTool._enableAuxiliaryTool)
{
- MacroDebugDraw.DrawDownArrow(NearestPoint, Quaternion.identity, Color.magenta);
- MacroDebugDraw.DrawDownArrow(NearestLineTangentPoint, Quaternion.identity, Color.green);
+ MacroDebugDraw.SetColor(Color.magenta);
+ MacroDebugDraw.DrawDownArrow(NearestPoint);
+ MacroDebugDraw.SetColor(Color.green);
+ MacroDebugDraw.DrawDownArrow(NearestLineTangentPoint);
+ MacroDebugDraw.ResetColor();
}
}
#endregion
-
}
}
diff --git a/Samples~/HorizonLineOrbit/TerminalLine2T3.cs b/Samples~/HorizonLineOrbit/TerminalLine2T3.cs
index 83137d0..85b865e 100644
--- a/Samples~/HorizonLineOrbit/TerminalLine2T3.cs
+++ b/Samples~/HorizonLineOrbit/TerminalLine2T3.cs
@@ -1,21 +1,14 @@
-using System;
using System.Collections.Generic;
-using System.IO;
-using System.Runtime.Serialization;
-using System.Runtime.Serialization.Formatters.Binary;
-using System.Text;
using Deconstruction.Element;
-using Deconstruction.Interface;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
-using UnityEngine.Serialization;
+using UnityEngine.UIElements;
using XericLibrary.Runtime.Debuger;
using XericLibrary.Runtime.MacroLibrary;
-using XericLibrary.Runtime.Type;
namespace SesothoLine
{
@@ -38,7 +31,9 @@ namespace SesothoLine
private LineSegment2 _lineSegment = new LineSegment2();
public bool DebugDrawGrid = false;
-
+
+ public Vector3 ah, bh;
+
#endregion
#region 生命周期
@@ -61,10 +56,7 @@ namespace SesothoLine
SesothoPeManager.Inst.RemoveEmbedded(this);
}
- protected virtual void OnDestroy()
- {
-
- }
+
protected override void AgencyOnEnable()
{
@@ -86,9 +78,10 @@ namespace SesothoLine
{
foreach (var index in indexs.Indexs)
{
+ MacroDebugDraw.SetColor(Color.red);
MacroDebugDraw.DrawDownArrow(
- index.GetCellWorldIndexPosition() + MacroMath.RandomVector3(0.1f, Identifier), Quaternion.identity,
- Color.red);
+ index.GetCellWorldIndexPosition() + MacroMath.RandomVector3(0.1f, Identifier));
+ MacroDebugDraw.ResetColor();
}
}
@@ -128,8 +121,12 @@ namespace SesothoLine
b.UpwardPlaneToVector2(),
ah.UpwardPlaneToVector2(),
bh.UpwardPlaneToVector2());
- // ah?.GetEndPointNormal ?? default,
- // bh?.GetStartPointNormal ?? default);
+ // ah?.GetEndPointNormal ?? default,
+ // bh?.GetStartPointNormal ?? default);
+
+ this.ah = ah;
+ this.bh = bh;
+
return _lineSegment;
}
@@ -145,7 +142,6 @@ namespace SesothoLine
AutomaticDrawCircularLine(straightLine);
}
-
///
/// 重新计算原点
///