clockwerk-opensim-stable – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27  
28 using System;
29 using System.Collections.Generic;
30 using System.Text;
31 using OpenMetaverse;
32  
33 namespace OpenSim.Region.Framework.Scenes
34 {
35 public class Border
36 {
37 /// <summary>
38 /// Line perpendicular to the Direction Cardinal. Z value is the
39 /// </summary>
40 public Vector3 BorderLine = Vector3.Zero;
41  
42 /// <summary>
43 /// Direction cardinal of the border, think, 'which side of the region this is'. EX South border: Cardinal.S
44 /// </summary>
45 public Cardinals CrossDirection = Cardinals.N;
46 public uint TriggerRegionX = 0;
47 public uint TriggerRegionY = 0;
48  
49 public Border()
50 {
51 }
52  
53 /// <summary>
54 /// Creates a Border. The line is perpendicular to the direction cardinal.
55 /// IE: if the direction cardinal is South, the line is West->East
56 /// </summary>
57 /// <param name="lineStart">The starting point for the line of the border.
58 /// The position of an object must be greater then this for this border to trigger.
59 /// Perpendicular to the direction cardinal</param>
60 /// <param name="lineEnd">The ending point for the line of the border.
61 /// The position of an object must be less then this for this border to trigger.
62 /// Perpendicular to the direction cardinal</param>
63 /// <param name="triggerCoordinate">The position that triggers border the border
64 /// cross parallel to the direction cardinal. On the North cardinal, this
65 /// normally 256. On the South cardinal, it's normally 0. Any position past this
66 /// point on the cartesian coordinate will trigger the border cross as long as it
67 /// falls within the line start and the line end.</param>
68 /// <param name="triggerRegionX">When this border triggers, teleport to this regionX
69 /// in the grid</param>
70 /// <param name="triggerRegionY">When this border triggers, teleport to this regionY
71 /// in the grid</param>
72 /// <param name="direction">Cardinal for border direction. Think, 'which side of the
73 /// region is this'</param>
74 public Border(float lineStart, float lineEnd, float triggerCoordinate, uint triggerRegionX,
75 uint triggerRegionY, Cardinals direction)
76 {
77 BorderLine = new Vector3(lineStart,lineEnd,triggerCoordinate);
78 CrossDirection = direction;
79 TriggerRegionX = triggerRegionX;
80 TriggerRegionY = triggerRegionY;
81 }
82  
83 /// <summary>
84 /// Tests to see if the given position would cross this border.
85 /// </summary>
86 /// <returns></returns>
87 public bool TestCross(Vector3 position)
88 {
89 bool result = false;
90 switch (CrossDirection)
91 {
92 case Cardinals.N: // x+0, y+1
93 if (position.X >= BorderLine.X && position.X <= BorderLine.Y && position.Y > BorderLine.Z)
94 {
95 return true;
96 }
97 break;
98 case Cardinals.NE: // x+1, y+1
99 break;
100 case Cardinals.E: // x+1, y+0
101 if (position.Y >= BorderLine.X && position.Y <= BorderLine.Y && position.X > BorderLine.Z)
102 {
103 return true;
104 }
105 break;
106 case Cardinals.SE: // x+1, y-1
107 break;
108 case Cardinals.S: // x+0, y-1
109 if (position.X >= BorderLine.X && position.X <= BorderLine.Y && position.Y < BorderLine.Z)
110 {
111 return true;
112 }
113 break;
114 case Cardinals.SW: // x-1, y-1
115 break;
116 case Cardinals.W: // x-1, y+0
117 if (position.Y >= BorderLine.X && position.Y <= BorderLine.Y && position.X < BorderLine.Z)
118 {
119 return true;
120 }
121 break;
122 case Cardinals.NW: // x-1, y+1
123 break;
124 }
125  
126 return result;
127 }
128  
129 public float Extent
130 {
131 get
132 {
133 switch (CrossDirection)
134 {
135 case Cardinals.N:
136 break;
137 case Cardinals.S:
138 break;
139 case Cardinals.W:
140 break;
141 case Cardinals.E:
142 break;
143 }
144 return 0;
145 }
146 }
147 }
148 }