diff options
author | MW | 2007-06-10 12:28:41 +0000 |
---|---|---|
committer | MW | 2007-06-10 12:28:41 +0000 |
commit | 9f25f70b248c37f9b112a83094cb471f2dbd31b2 (patch) | |
tree | 805ff84e93795865c74dada2e12f13c88af9fef3 /OpenSim/OpenSim.Reg/scripting/Scripts | |
parent | Renamed folder (diff) | |
download | opensim-SC_OLD-9f25f70b248c37f9b112a83094cb471f2dbd31b2.zip opensim-SC_OLD-9f25f70b248c37f9b112a83094cb471f2dbd31b2.tar.gz opensim-SC_OLD-9f25f70b248c37f9b112a83094cb471f2dbd31b2.tar.bz2 opensim-SC_OLD-9f25f70b248c37f9b112a83094cb471f2dbd31b2.tar.xz |
Messed up the renaming of the folder, so part one of the fix
Diffstat (limited to 'OpenSim/OpenSim.Reg/scripting/Scripts')
-rw-r--r-- | OpenSim/OpenSim.Reg/scripting/Scripts/FollowRandomAvatar.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.Reg/scripting/Scripts/FollowRandomAvatar.cs b/OpenSim/OpenSim.Reg/scripting/Scripts/FollowRandomAvatar.cs new file mode 100644 index 0000000..9c0146b --- /dev/null +++ b/OpenSim/OpenSim.Reg/scripting/Scripts/FollowRandomAvatar.cs | |||
@@ -0,0 +1,37 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | |||
6 | namespace OpenSim.Region.Scripting | ||
7 | { | ||
8 | public class FollowRandomAvatar : Script | ||
9 | { | ||
10 | public FollowRandomAvatar() | ||
11 | : base(LLUUID.Random()) | ||
12 | { | ||
13 | OnFrame += MyOnFrame; | ||
14 | } | ||
15 | |||
16 | private void MyOnFrame(IScriptContext context) | ||
17 | { | ||
18 | LLVector3 pos = context.Entity.Pos; | ||
19 | |||
20 | IScriptReadonlyEntity avatar; | ||
21 | |||
22 | if (context.TryGetRandomAvatar(out avatar)) | ||
23 | { | ||
24 | LLVector3 avatarPos = avatar.Pos; | ||
25 | |||
26 | float x = pos.X + ((float)avatarPos.X.CompareTo(pos.X)) / 2; | ||
27 | float y = pos.Y + ((float)avatarPos.Y.CompareTo(pos.Y)) / 2; | ||
28 | |||
29 | LLVector3 newPos = new LLVector3(x, y, pos.Z); | ||
30 | |||
31 | context.Entity.Pos = newPos; | ||
32 | } | ||
33 | } | ||
34 | } | ||
35 | |||
36 | |||
37 | } | ||