blob: 9c0146bf9de7c663f7d8cb20c3b43df648794b99 (
plain)
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
|
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Region.Scripting
{
public class FollowRandomAvatar : Script
{
public FollowRandomAvatar()
: base(LLUUID.Random())
{
OnFrame += MyOnFrame;
}
private void MyOnFrame(IScriptContext context)
{
LLVector3 pos = context.Entity.Pos;
IScriptReadonlyEntity avatar;
if (context.TryGetRandomAvatar(out avatar))
{
LLVector3 avatarPos = avatar.Pos;
float x = pos.X + ((float)avatarPos.X.CompareTo(pos.X)) / 2;
float y = pos.Y + ((float)avatarPos.Y.CompareTo(pos.Y)) / 2;
LLVector3 newPos = new LLVector3(x, y, pos.Z);
context.Entity.Pos = newPos;
}
}
}
}
|