225 lines
6.2 KiB
C#
225 lines
6.2 KiB
C#
|
|
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 XericLibrary.Runtime.Debuger;
|
|||
|
|
using XericLibrary.Runtime.MacroLibrary;
|
|||
|
|
using XericLibrary.Runtime.Type;
|
|||
|
|
|
|||
|
|
namespace SesothoLine
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
using LineSegment2 = Deconstruction.Element.PromptLine2.LineSegment2;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD>ն<EFBFBD>ִ<EFBFBD>нű<D0BD><C5B1><EFBFBD>ʹ<EFBFBD>ö<EFBFBD>ά<EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public class TerminalLine2T3 : PromptLine2,
|
|||
|
|
ILinkconfidentPe // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
#region <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
private LinkedListNode<PlacementBase> _linkNode;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
private LineSegment2 _lineSegment = new LineSegment2();
|
|||
|
|
|
|||
|
|
public bool DebugDrawGrid = false;
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
protected override void Start()
|
|||
|
|
{
|
|||
|
|
base.Start();
|
|||
|
|
InitPromptLine<LineRendererUnbodied>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override void OnEnable()
|
|||
|
|
{
|
|||
|
|
base.OnEnable();
|
|||
|
|
SesothoPeManager.Inst.AddEmbedded(this);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override void OnDisable()
|
|||
|
|
{
|
|||
|
|
base.OnDisable();
|
|||
|
|
SesothoPeManager.Inst.RemoveEmbedded(this);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected virtual void OnDestroy()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override void AgencyOnEnable()
|
|||
|
|
{
|
|||
|
|
base.AgencyOnEnable();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override void AgencyOnDisable()
|
|||
|
|
{
|
|||
|
|
base.AgencyOnDisable();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override void AgencyMainUpdate()
|
|||
|
|
{
|
|||
|
|
base.AgencyMainUpdate();
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|||
|
|
if (DebugDrawGrid &&
|
|||
|
|
NeighborGridIndex.SafeGetAsMappingIndex(out var indexs))
|
|||
|
|
{
|
|||
|
|
foreach (var index in indexs.Indexs)
|
|||
|
|
{
|
|||
|
|
MacroDebugDraw.DrawDownArrow(
|
|||
|
|
index.GetCellWorldIndexPosition() + MacroMath.RandomVector3(0.1f, Identifier),
|
|||
|
|
Color.red);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override void AgencyAsyncBeforeUpdate()
|
|||
|
|
{
|
|||
|
|
base.AgencyAsyncBeforeUpdate();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override void AgencyAsyncUpdate()
|
|||
|
|
{
|
|||
|
|
base.AgencyAsyncUpdate();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override void AgencyAsyncAfterUpdate()
|
|||
|
|
{
|
|||
|
|
base.AgencyAsyncAfterUpdate();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region <EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="a"></param>
|
|||
|
|
/// <param name="b"></param>
|
|||
|
|
/// <param name="ah"></param>
|
|||
|
|
/// <param name="bh"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public LineSegment2 SetLineSegment(Vector3 a, Vector3 b, Vector3 ah = default, Vector3 bh = default)
|
|||
|
|
{
|
|||
|
|
_lineSegment.SetValue(
|
|||
|
|
a.UpwardPlaneToVector2(),
|
|||
|
|
b.UpwardPlaneToVector2(),
|
|||
|
|
ah.UpwardPlaneToVector2(),
|
|||
|
|
bh.UpwardPlaneToVector2());
|
|||
|
|
// ah?.GetEndPointNormal ?? default,
|
|||
|
|
// bh?.GetStartPointNormal ?? default);
|
|||
|
|
return _lineSegment;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void AutomaticDrawCircularLine(float constraintAngle = -1, bool fullArc = false)
|
|||
|
|
{
|
|||
|
|
AutomaticDrawCircularLine(_lineSegment, constraintAngle, fullArc);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private LineSegment2 straightLine = new LineSegment2();
|
|||
|
|
public void DrawStraightLine()
|
|||
|
|
{
|
|||
|
|
straightLine.SetValue(_lineSegment.pointA, _lineSegment.pointB);
|
|||
|
|
AutomaticDrawCircularLine(straightLine);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ԭ<EFBFBD><D4AD>
|
|||
|
|
/// <code>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>˹켣<CBB9><ECBCA3>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㣬<EFBFBD><E3A3AC>ôͨ<C3B4><CDA8><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>֮<EFBFBD>䡣
|
|||
|
|
/// ע<>⣺ʹ<E2A3BA><CAB9>ǰ<EFBFBD><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD>켣<EFBFBD><ECBCA3>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </code>
|
|||
|
|
/// </summary>
|
|||
|
|
public void ReapplyOrigin()
|
|||
|
|
{
|
|||
|
|
if (TrajectoryRenderer == null || TrajectoryCalculator == null)
|
|||
|
|
{
|
|||
|
|
Debug.LogError("<22><>ǰ<EFBFBD>켣<EFBFBD><ECBCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ٶ<EFBFBD><D9B6><EFBFBD><EFBFBD>еĹ켣<C4B9>DZ<EFBFBD><C7B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
var center = ((TrajectoryCalculator.GetStartPointPosition + TrajectoryCalculator.GetEndPointPosition) / 2).UpwardPlaneToVector3();
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>
|
|||
|
|
var local = TrajectoryCalculator.Origin.UpwardPlaneToVector3();
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
|
|||
|
|
var offset = local - center;
|
|||
|
|
|
|||
|
|
TrajectoryCalculator.Origin = offset.UpwardPlaneToVector2();
|
|||
|
|
transform.position += center;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
|
UpdateRender();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region ʵ<EFBFBD><EFBFBD> - ILinkconfidentPe
|
|||
|
|
|
|||
|
|
public bool GetLinkedNode(out LinkedListNode<PlacementBase> node)
|
|||
|
|
{
|
|||
|
|
if (_linkNode == null)
|
|||
|
|
{
|
|||
|
|
node = null;
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
node = _linkNode;
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void SetLinkedNode(LinkedListNode<PlacementBase> node)
|
|||
|
|
{
|
|||
|
|
_linkNode = node;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region <EFBFBD><EFBFBD>д - ISerializablePost
|
|||
|
|
|
|||
|
|
public override SerializerHelper.Type.SerializeUnion SerializedOccurs()
|
|||
|
|
{
|
|||
|
|
return base.SerializedOccurs();
|
|||
|
|
}
|
|||
|
|
public override bool CheckDeserializeUnion(SerializerHelper.Type.SerializeUnion context)
|
|||
|
|
{
|
|||
|
|
return base.CheckDeserializeUnion(context);
|
|||
|
|
}
|
|||
|
|
public override void DeserializeOccurs(SerializerHelper.Type.SerializeUnion context)
|
|||
|
|
{
|
|||
|
|
base.DeserializeOccurs(context);
|
|||
|
|
}
|
|||
|
|
public override void DeserializeHysteresisOccurs(SerializerHelper.Type.SerializeUnion context)
|
|||
|
|
{
|
|||
|
|
base.DeserializeHysteresisOccurs(context);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|