forked from runuo/runuo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoint3DList.cs
113 lines (93 loc) · 2.31 KB
/
Point3DList.cs
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
/***************************************************************************
* Point3DList.cs
* -------------------
* begin : May 1, 2002
* copyright : (C) The RunUO Software Team
* email : [email protected]
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
using System;
namespace Server
{
public class Point3DList
{
private Point3D[] m_List;
private int m_Count;
public Point3DList()
{
m_List = new Point3D[8];
m_Count = 0;
}
public int Count
{
get
{
return m_Count;
}
}
public void Clear()
{
m_Count = 0;
}
public Point3D Last
{
get{ return m_List[m_Count - 1]; }
}
public Point3D this[int index]
{
get
{
return m_List[index];
}
}
public void Add( int x, int y, int z )
{
if ( (m_Count + 1) > m_List.Length )
{
Point3D[] old = m_List;
m_List = new Point3D[old.Length * 2];
for ( int i = 0; i < old.Length; ++i )
m_List[i] = old[i];
}
m_List[m_Count].m_X = x;
m_List[m_Count].m_Y = y;
m_List[m_Count].m_Z = z;
++m_Count;
}
public void Add( Point3D p )
{
if ( (m_Count + 1) > m_List.Length )
{
Point3D[] old = m_List;
m_List = new Point3D[old.Length * 2];
for ( int i = 0; i < old.Length; ++i )
m_List[i] = old[i];
}
m_List[m_Count].m_X = p.m_X;
m_List[m_Count].m_Y = p.m_Y;
m_List[m_Count].m_Z = p.m_Z;
++m_Count;
}
private static Point3D[] m_EmptyList = new Point3D[0];
public Point3D[] ToArray()
{
if ( m_Count == 0 )
return m_EmptyList;
Point3D[] list = new Point3D[m_Count];
for ( int i = 0; i < m_Count; ++i )
list[i] = m_List[i];
m_Count = 0;
return list;
}
}
}