Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
Box.cs
浏览该文件的文档.
1namespace Engine {
2 public struct Box : IEquatable<Box> {
3 public int Left;
4
5 public int Top;
6
7 public int Near;
8
9 public int Width;
10
11 public int Height;
12
13 public int Depth;
14
15 public static Box Empty;
16
18 get => new(Left, Top, Near);
19 set {
20 Left = value.X;
21 Top = value.Y;
22 Near = value.Z;
23 }
24 }
25
26 public Point3 Size {
27 get => new(Width, Height, Depth);
28 set {
29 Width = value.X;
30 Height = value.Y;
31 Depth = value.Z;
32 }
33 }
34
35 public int Right => Left + Width;
36
37 public int Bottom => Top + Height;
38
39 public int Far => Near + Depth;
40
41 public Box(int left, int top, int near, int width, int height, int depth) {
42 Left = left;
43 Top = top;
44 Near = near;
45 Width = width;
46 Height = height;
47 Depth = depth;
48 }
49
50 public static implicit operator Box((int Left, int Top, int Near, int Width, int Height, int Depth) v) =>
51 new(v.Left, v.Top, v.Near, v.Width, v.Height, v.Depth);
52
53 public bool Equals(Box other) => Left == other.Left
54 && Top == other.Top
55 && Near == other.Near
56 && Width == other.Width
57 && Height == other.Height
58 && Depth == other.Depth;
59
60 public override bool Equals(object obj) => obj is Box box && Equals(box);
61
62 public override int GetHashCode() => Left + Top + Near + Width + Height + Depth;
63
64 public override string ToString() => $"{Left},{Top},{Near},{Width},{Height},{Depth}";
65
66 public bool Contains(Point3 p) => p.X >= Left && p.X < Left + Width && p.Y >= Top && p.Y < Top + Height && p.Z >= Near && p.Z < Near + Depth;
67
68 public static Box Intersection(Box b1, Box b2) {
69 int num = Math.Max(b1.Left, b2.Left);
70 int num2 = Math.Max(b1.Top, b2.Top);
71 int num3 = Math.Min(b1.Near, b2.Near);
72 int num4 = Math.Min(b1.Left + b1.Width, b2.Left + b2.Width);
73 int num5 = Math.Min(b1.Top + b1.Height, b2.Top + b2.Height);
74 int num6 = Math.Min(b1.Near + b1.Depth, b2.Near + b2.Depth);
75 return num4 <= num || num5 <= num2 || num6 <= num3 ? Empty : new Box(num, num2, num3, num4 - num, num5 - num2, num6 - num3);
76 }
77
78 public static Box Union(Box b1, Box b2) {
79 int num = Math.Min(b1.Left, b2.Left);
80 int num2 = Math.Min(b1.Top, b2.Top);
81 int num3 = Math.Min(b1.Near, b2.Near);
82 int num4 = Math.Max(b1.Left + b1.Width, b2.Left + b2.Width);
83 int num5 = Math.Max(b1.Top + b1.Height, b2.Top + b2.Height);
84 int num6 = Math.Max(b1.Near + b1.Depth, b2.Near + b2.Depth);
85 return new Box(num, num2, num3, num4 - num, num5 - num2, num6 - num3);
86 }
87
88 public static bool operator ==(Box b1, Box b2) => b1.Equals(b2);
89
90 public static bool operator !=(Box b1, Box b2) => !b1.Equals(b2);
91 }
92}
override bool Equals(object obj)
定义 Box.cs:60
static Box Intersection(Box b1, Box b2)
定义 Box.cs:68
static bool operator==(Box b1, Box b2)
定义 Box.cs:88
override string ToString()
定义 Box.cs:64
override int GetHashCode()
定义 Box.cs:62
Box(int left, int top, int near, int width, int height, int depth)
定义 Box.cs:41
static Box Union(Box b1, Box b2)
定义 Box.cs:78
bool Contains(Point3 p)
定义 Box.cs:66
static Box Empty
定义 Box.cs:15
int Width
定义 Box.cs:9
Point3 Location
定义 Box.cs:17
static bool operator!=(Box b1, Box b2)
定义 Box.cs:90
Point3 Size
定义 Box.cs:26
bool Equals(Box other)
定义 Box.cs:53