yyl
2025-05-19 b118ece3db250a5a257b60713da92234d8d5a57a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Text.RegularExpressions;
 
public struct Int2
{
    public int x;
    public int y;
 
    public Int2(int _x, int _y)
    {
        this.x = _x;
        this.y = _y;
    }
 
    public int this[int index]
    {
        get
        {
            return index == 0 ? this.x : index == 1 ? this.y : 0;
        }
        set
        {
            if (index == 0)
            {
                this.x = value;
            }
            else if (index == 1)
            {
                this.y = value;
            }
        }
    }
 
    public static Int2 zero = new Int2(0, 0);
 
    public static bool TryParse(string input, out Int2 _value)
    {
        if (string.IsNullOrEmpty(input))
        {
            _value = Int2.zero;
            return false;
        }
        else
        {
            var matches = Regex.Matches(input.Trim(), "[-]{0,1}\\d+");
            if (matches.Count == 2)
            {
                _value = new Int2(int.Parse(matches[0].Value), int.Parse(matches[1].Value));
                return true;
            }
            else
            {
                _value = Int2.zero;
                return false;
            }
        }
    }
 
    public override bool Equals(object other)
    {
        if (other == null)
        {
            return false;
        }
        if ((other.GetType().Equals(this.GetType())) == false)
        {
            return false;
        }
 
        var temp = (Int2)other;
        return this.x.Equals(temp.x) && this.y.Equals(temp.y);
    }
 
    public override int GetHashCode()
    {
        return this.x.GetHashCode() + this.y.GetHashCode();
    }
 
    public override string ToString()
    {
        return string.Format("({0},{1})", this.x, this.y);
    }
 
    public static bool operator ==(Int2 lhs, Int2 rhs)
    {
        return lhs.x == rhs.x && lhs.y == rhs.y;
    }
 
    public static bool operator !=(Int2 lhs, Int2 rhs)
    {
        return lhs.x != rhs.x || lhs.y != rhs.y;
    }
 
    public static Int2 operator +(Int2 lhs, Int2 rhs)
    {
        return new Int2(lhs.x + rhs.x, lhs.y + rhs.y);
    }
 
    public static Int2 operator -(Int2 lhs, Int2 rhs)
    {
        return new Int2(lhs.x - rhs.x, lhs.y - rhs.y);
    }
 
}
 
public struct Int3
{
    public int x;
    public int y;
    public int z;
 
    public Int3(int _x, int _y)
    {
        this.x = _x;
        this.y = _y;
        this.z = 0;
    }
 
    public Int3(int _x, int _y, int _z)
    {
        this.x = _x;
        this.y = _y;
        this.z = _z;
    }
 
    public int this[int index]
    {
        get
        {
            return index == 0 ? this.x : index == 1 ? this.y : index == 2 ? this.z : 0;
        }
        set
        {
            if (index == 0)
            {
                this.x = value;
            }
            else if (index == 1)
            {
                this.y = value;
            }
            else if (index == 2)
            {
                this.z = value;
            }
        }
    }
 
    public static Int3 zero = new Int3(0, 0, 0);
 
    public static bool TryParse(string input, out Int3 _value)
    {
        if (string.IsNullOrEmpty(input))
        {
            _value = Int3.zero;
            return false;
        }
        else
        {
            var matches = Regex.Matches(input.Trim(), "[-]{0,1}\\d+");
            if (matches.Count == 2)
            {
                _value = new Int3(int.Parse(matches[0].Value), int.Parse(matches[1].Value), 0);
                return true;
            }
            else if (matches.Count == 3)
            {
                _value = new Int3(int.Parse(matches[0].Value), int.Parse(matches[1].Value), int.Parse(matches[2].Value));
                return true;
            }
            else
            {
                _value = Int3.zero;
                return false;
            }
        }
    }
 
    public override bool Equals(object other)
    {
        if (other == null)
        {
            return false;
        }
        if ((other.GetType().Equals(this.GetType())) == false)
        {
            return false;
        }
 
        var temp = (Int3)other;
        return this.x.Equals(temp.x) && this.y.Equals(temp.y) && this.z.Equals(temp.z);
    }
 
    public override int GetHashCode()
    {
        return this.x.GetHashCode() + this.y.GetHashCode() + this.z.GetHashCode();
    }
 
    public override string ToString()
    {
        return string.Format("({0},{1},{2})", this.x, this.y, this.z);
    }
 
    public static bool operator ==(Int3 lhs, Int3 rhs)
    {
        return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z;
    }
 
    public static bool operator !=(Int3 lhs, Int3 rhs)
    {
        return lhs.x != rhs.x || lhs.y != rhs.y || lhs.z != rhs.z;
    }
 
    public static Int3 operator +(Int3 lhs, Int3 rhs)
    {
        return new Int3(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z);
    }
 
    public static Int3 operator -(Int3 lhs, Int3 rhs)
    {
        return new Int3(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z);
    }
 
}