aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/world/World.Scripting.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim.RegionServer/world/World.Scripting.cs')
-rw-r--r--OpenSim.RegionServer/world/World.Scripting.cs124
1 files changed, 0 insertions, 124 deletions
diff --git a/OpenSim.RegionServer/world/World.Scripting.cs b/OpenSim.RegionServer/world/World.Scripting.cs
deleted file mode 100644
index 44ef05a..0000000
--- a/OpenSim.RegionServer/world/World.Scripting.cs
+++ /dev/null
@@ -1,124 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5using System.Reflection;
6using OpenSim.Framework;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Types;
9using libsecondlife;
10
11namespace OpenSim.world
12{
13 public partial class World
14 {
15 private Dictionary<string, IScriptEngine> scriptEngines = new Dictionary<string, IScriptEngine>();
16
17 private void LoadScriptEngines()
18 {
19 this.LoadScriptPlugins();
20 }
21
22 public void LoadScriptPlugins()
23 {
24 string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ScriptEngines");
25 string[] pluginFiles = Directory.GetFiles(path, "*.dll");
26
27
28 for (int i = 0; i < pluginFiles.Length; i++)
29 {
30 this.AddPlugin(pluginFiles[i]);
31 }
32 }
33
34 private void AddPlugin(string FileName)
35 {
36 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
37
38 foreach (Type pluginType in pluginAssembly.GetTypes())
39 {
40 if (pluginType.IsPublic)
41 {
42 if (!pluginType.IsAbstract)
43 {
44 Type typeInterface = pluginType.GetInterface("IScriptEngine", true);
45
46 if (typeInterface != null)
47 {
48 IScriptEngine plug = (IScriptEngine)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
49 plug.Init(this);
50 this.scriptEngines.Add(plug.GetName(), plug);
51
52 }
53
54 typeInterface = null;
55 }
56 }
57 }
58
59 pluginAssembly = null;
60 }
61
62 public void LoadScript(string scriptType, string scriptName, string script, Entity ent)
63 {
64 if(this.scriptEngines.ContainsKey(scriptType))
65 {
66 this.scriptEngines[scriptType].LoadScript(script, scriptName, ent.localid);
67 }
68 }
69
70 #region IScriptAPI Methods
71
72 public OSVector3 GetEntityPosition(uint localID)
73 {
74 OSVector3 res = new OSVector3();
75 // Console.WriteLine("script- getting entity " + localID + " position");
76 foreach (Entity entity in this.Entities.Values)
77 {
78 if (entity.localid == localID)
79 {
80 res.X = entity.Pos.X;
81 res.Y = entity.Pos.Y;
82 res.Z = entity.Pos.Z;
83 }
84 }
85 return res;
86 }
87
88 public void SetEntityPosition(uint localID, float x , float y, float z)
89 {
90 foreach (Entity entity in this.Entities.Values)
91 {
92 if (entity.localid == localID && entity is Primitive)
93 {
94 LLVector3 pos = entity.Pos;
95 pos.X = x;
96 pos.Y = y;
97 Primitive prim = entity as Primitive;
98 // Of course, we really should have asked the physEngine if this is possible, and if not, returned false.
99 prim.UpdatePosition(pos);
100 // Console.WriteLine("script- setting entity " + localID + " positon");
101 }
102 }
103
104 }
105
106 public uint GetRandomAvatarID()
107 {
108 //Console.WriteLine("script- getting random avatar id");
109 uint res = 0;
110 foreach (Entity entity in this.Entities.Values)
111 {
112 if (entity is Avatar)
113 {
114 res = entity.localid;
115 }
116 }
117 return res;
118 }
119
120 #endregion
121
122
123 }
124}