From cabe39011299c00e741a058221cf73447b137544 Mon Sep 17 00:00:00 2001 From: Tian jianyong <11429339@qq.com> Date: Mon, 21 Oct 2024 01:32:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86Vector3D=E7=9A=84Equ?= =?UTF-8?q?als=E5=92=8CGetHashCode=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Models/Common.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Models/Common.cs b/Models/Common.cs index 8476bac..f519e2a 100644 --- a/Models/Common.cs +++ b/Models/Common.cs @@ -109,6 +109,20 @@ namespace ActiveProtect.Models return !(left == right); } + public override bool Equals(object? obj) + { + if (obj is Vector3D other) + { + return this == other; + } + return false; + } + + public override int GetHashCode() + { + return HashCode.Combine(X, Y, Z); + } + /// /// 计算向量的模长 /// @@ -190,6 +204,7 @@ namespace ActiveProtect.Models Vector3D unitDirection = direction.Normalize(); return a + unitDirection * distance; } + } ///