aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Examples/SimpleApp/PulseScript.cs
blob: b65765cb1b687dad23c08d992e00e86646e83140 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.Scripting;
using OpenSim.Region.Environment.Scenes;
namespace SimpleApp
{
    public class PulseScript : IScript
    {
        ScriptInfo script;

        private libsecondlife.LLVector3 pulse = new libsecondlife.LLVector3(0.1f, 0.1f, 0.1f);
        public string getName()
        {
            return "pulseScript 0.1";
        }

        public void Initialise(ScriptInfo scriptInfo)
        {
            script = scriptInfo;
            script.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame);
            script.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
        }

        void events_OnNewPresence(ScenePresence presence)
        {
            script.logger.Verbose("Hello " + presence.firstname.ToString() + "!");
        }

        void events_OnFrame()
        {
            foreach (EntityBase ent in this.script.world.Entities.Values)
            {
                if (ent is SceneObject)
                {
                    SceneObject prim = (SceneObject)ent;
                    if ((prim.rootPrimitive.Scale.X > 1) && (prim.rootPrimitive.Scale.Y > 1) && (prim.rootPrimitive.Scale.Z > 1))
                    {
                        this.pulse = new libsecondlife.LLVector3(-0.1f, -0.1f, -0.1f);
                    }
                    else if ((prim.rootPrimitive.Scale.X < 0.2f) && (prim.rootPrimitive.Scale.Y < 0.2f) && (prim.rootPrimitive.Scale.Z < 0.2f))
                    {
                        pulse = new libsecondlife.LLVector3(0.1f, 0.1f, 0.1f);
                    }

                    prim.rootPrimitive.ResizeGoup(prim.rootPrimitive.Scale + pulse);
                }
            }
        }

    }
}