* Script prototype
parent
ba2c94721c
commit
ad39897144
|
@ -70,10 +70,6 @@
|
|||
<HintPath>System.Xml.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenSim.Framework.Interfaces" >
|
||||
<HintPath>OpenSim.Framework.Interfaces.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="libsecondlife.dll" >
|
||||
<HintPath>..\bin\libsecondlife.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
<include name="System.Data.dll" />
|
||||
<include name="System.Xml.dll" />
|
||||
<include name="../bin/OpenSim.Framework.dll" />
|
||||
<include name="OpenSim.Framework.Interfaces.dll" />
|
||||
<include name="../bin/OpenSim.Framework.Console.dll" />
|
||||
<include name="../bin/libsecondlife.dll" />
|
||||
<include name="../bin/Db4objects.Db4o.dll" />
|
||||
|
|
|
@ -7,6 +7,8 @@ using OpenSim.UserServer;
|
|||
using OpenSim.Servers;
|
||||
using OpenSim.Assets;
|
||||
using OpenSim.Framework.Inventory;
|
||||
using libsecondlife;
|
||||
using OpenSim.RegionServer.world.scripting;
|
||||
|
||||
namespace OpenSim.CAPS
|
||||
{
|
||||
|
@ -34,7 +36,10 @@ namespace OpenSim.CAPS
|
|||
server.AddRestHandler("GET", "/Admin", GetAdminPage);
|
||||
server.AddRestHandler("GET", "/Admin/Welcome", GetWelcomePage);
|
||||
server.AddRestHandler("GET", "/Admin/Accounts", GetAccountsPage );
|
||||
server.AddRestHandler("GET", "/Admin/Clients", GetConnectedClientsPage );
|
||||
server.AddRestHandler("GET", "/Admin/Clients", GetConnectedClientsPage);
|
||||
server.AddRestHandler("GET", "/Admin/Entities", GetEntitiesPage);
|
||||
server.AddRestHandler("GET", "/Admin/Scripts", GetScriptsPage);
|
||||
server.AddRestHandler("GET", "/Admin/AddTestScript", AddTestScript );
|
||||
server.AddRestHandler("GET", "/ClientInventory", GetClientsInventory);
|
||||
|
||||
server.AddRestHandler("POST", "/Admin/NewAccount", PostNewAccount );
|
||||
|
@ -133,6 +138,68 @@ namespace OpenSim.CAPS
|
|||
return responseString;
|
||||
}
|
||||
|
||||
|
||||
private class TestScript : Script
|
||||
{
|
||||
int toggle = 0;
|
||||
|
||||
public TestScript()
|
||||
: base(LLUUID.Random())
|
||||
{
|
||||
OnFrame += MyOnFrame;
|
||||
}
|
||||
|
||||
private void MyOnFrame(IScriptContext context)
|
||||
{
|
||||
toggle = 2 - toggle;
|
||||
|
||||
LLVector3 pos = context.GetPos();
|
||||
|
||||
pos.X += (toggle - 1);
|
||||
|
||||
context.MoveTo(pos);
|
||||
}
|
||||
}
|
||||
|
||||
private string AddTestScript(string request, string path)
|
||||
{
|
||||
int index = path.LastIndexOf('/');
|
||||
|
||||
string lluidStr = path.Substring(index+1);
|
||||
|
||||
LLUUID id;
|
||||
|
||||
if( LLUUID.TryParse( lluidStr, out id ) )
|
||||
{
|
||||
// This is just here for concept purposes... Remove!
|
||||
m_world.AddScript( m_world.Entities[id], new TestScript());
|
||||
return String.Format("Added new script to object [{0}]", id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format("Couldn't parse [{0}]", lluidStr );
|
||||
}
|
||||
}
|
||||
|
||||
private string GetScriptsPage(string request, string path)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
private string GetEntitiesPage(string request, string path)
|
||||
{
|
||||
string responseString;
|
||||
responseString = " <p> Listing current entities</p><ul>";
|
||||
|
||||
foreach (Entity entity in m_world.Entities.Values)
|
||||
{
|
||||
string testScriptLink = "javascript:loadXMLDoc('Admin/AddTestScript/" + entity.uuid.ToString() + "');";
|
||||
responseString += String.Format( "<li>[{0}] \"{1}\" @ {2} <a href=\"{3}\">add test script</a></li>", entity.uuid, entity.getName(), entity.position, testScriptLink );
|
||||
}
|
||||
responseString += "</ul>";
|
||||
return responseString;
|
||||
}
|
||||
|
||||
private string GetClientsInventory(string request, string path)
|
||||
{
|
||||
string[] line;
|
||||
|
@ -187,38 +254,17 @@ namespace OpenSim.CAPS
|
|||
try
|
||||
{
|
||||
StreamReader SR;
|
||||
string lines;
|
||||
AdminPage = "";
|
||||
NewAccountForm = "";
|
||||
LoginForm = "";
|
||||
|
||||
SR = File.OpenText("testadmin.htm");
|
||||
|
||||
while (!SR.EndOfStream)
|
||||
{
|
||||
lines = SR.ReadLine();
|
||||
AdminPage += lines + "\n";
|
||||
|
||||
}
|
||||
AdminPage = SR.ReadToEnd();
|
||||
SR.Close();
|
||||
|
||||
SR = File.OpenText("newaccountform.htm");
|
||||
|
||||
while (!SR.EndOfStream)
|
||||
{
|
||||
lines = SR.ReadLine();
|
||||
NewAccountForm += lines + "\n";
|
||||
|
||||
}
|
||||
NewAccountForm = SR.ReadToEnd();
|
||||
SR.Close();
|
||||
|
||||
SR = File.OpenText("login.htm");
|
||||
|
||||
while (!SR.EndOfStream)
|
||||
{
|
||||
lines = SR.ReadLine();
|
||||
LoginForm += lines + "\n";
|
||||
|
||||
}
|
||||
LoginForm = SR.ReadToEnd();
|
||||
SR.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
@ -184,6 +184,15 @@
|
|||
<Compile Include="world\scripting\IScript.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="world\scripting\IScriptContext.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="world\scripting\IScriptHandler.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="world\scripting\Script.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
|
||||
<PropertyGroup>
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<include name="world/SurfacePatch.cs" />
|
||||
<include name="world/World.cs" />
|
||||
<include name="world/scripting/IScript.cs" />
|
||||
<include name="world/scripting/IScriptContext.cs" />
|
||||
<include name="world/scripting/IScriptHandler.cs" />
|
||||
<include name="world/scripting/Script.cs" />
|
||||
</sources>
|
||||
<references basedir="${project::get-base-directory()}">
|
||||
<lib>
|
||||
|
|
|
@ -11,6 +11,8 @@ using OpenSim.Framework.Assets;
|
|||
using OpenSim.Framework.Terrain;
|
||||
using OpenSim.Framework.Inventory;
|
||||
using OpenSim.Assets;
|
||||
using OpenSim.world.scripting;
|
||||
using OpenSim.RegionServer.world.scripting;
|
||||
|
||||
namespace OpenSim.world
|
||||
{
|
||||
|
@ -29,6 +31,7 @@ namespace OpenSim.world
|
|||
private uint _primCount = 702000;
|
||||
private int storageCount;
|
||||
private Dictionary<uint, SimClient> m_clientThreads;
|
||||
private Dictionary<LLUUID, ScriptHandler> m_scriptHandlers;
|
||||
private ulong m_regionHandle;
|
||||
private string m_regionName;
|
||||
private InventoryCache _inventoryCache;
|
||||
|
@ -40,6 +43,8 @@ namespace OpenSim.world
|
|||
m_regionHandle = regionHandle;
|
||||
m_regionName = regionName;
|
||||
|
||||
m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>();
|
||||
|
||||
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance");
|
||||
Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
|
||||
|
||||
|
@ -52,6 +57,12 @@ namespace OpenSim.world
|
|||
Avatar.LoadAnims();
|
||||
}
|
||||
|
||||
public void AddScript(Entity entity, Script script)
|
||||
{
|
||||
ScriptHandler scriptHandler = new ScriptHandler(script, entity, this);
|
||||
m_scriptHandlers.Add(scriptHandler.ScriptId, scriptHandler);
|
||||
}
|
||||
|
||||
public InventoryCache InventoryCache
|
||||
{
|
||||
set
|
||||
|
@ -102,6 +113,11 @@ namespace OpenSim.world
|
|||
Entities[UUID].update();
|
||||
}
|
||||
|
||||
foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values)
|
||||
{
|
||||
scriptHandler.OnFrame();
|
||||
}
|
||||
|
||||
//backup world data
|
||||
this.storageCount++;
|
||||
if (storageCount > 1200) //set to how often you want to backup
|
||||
|
@ -194,7 +210,7 @@ namespace OpenSim.world
|
|||
|
||||
foreach (SimClient client in m_clientThreads.Values)
|
||||
{
|
||||
this.SendLayerData(pointx , pointy , client);
|
||||
this.SendLayerData(pointx, pointy, client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -251,10 +267,10 @@ namespace OpenSim.world
|
|||
int[] patches = new int[1];
|
||||
int patchx, patchy;
|
||||
patchx = px / 16;
|
||||
/* if (patchx > 12)
|
||||
{
|
||||
patchx = 12;
|
||||
}*/
|
||||
/* if (patchx > 12)
|
||||
{
|
||||
patchx = 12;
|
||||
}*/
|
||||
patchy = py / 16;
|
||||
|
||||
patches[0] = patchx + 0 + patchy * 16;
|
||||
|
@ -270,9 +286,10 @@ namespace OpenSim.world
|
|||
{
|
||||
foreach (libsecondlife.LLUUID UUID in Entities.Keys)
|
||||
{
|
||||
if (Entities[UUID].ToString() == "OpenSim.world.Primitive")
|
||||
if (Entities[UUID] is Primitive)
|
||||
{
|
||||
((OpenSim.world.Primitive)Entities[UUID]).UpdateClient(RemoteClient);
|
||||
Primitive primitive = Entities[UUID] as Primitive;
|
||||
primitive.UpdateClient(RemoteClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +323,7 @@ namespace OpenSim.world
|
|||
prim.PhysActor = this.phyScene.AddPrim(pVec, pSize);
|
||||
}
|
||||
}
|
||||
//prim.PhysicsEnabled = true;
|
||||
|
||||
this.Entities.Add(prim.uuid, prim);
|
||||
this._primCount++;
|
||||
}
|
||||
|
@ -314,7 +331,7 @@ namespace OpenSim.world
|
|||
public bool DeRezObject(SimClient simClient, Packet packet)
|
||||
{
|
||||
DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;
|
||||
// Console.WriteLine(DeRezPacket);
|
||||
// Console.WriteLine(DeRezPacket);
|
||||
//Needs to delete object from physics at a later date
|
||||
if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.RegionServer.world.scripting
|
||||
{
|
||||
public interface IScriptContext
|
||||
{
|
||||
bool MoveTo(LLVector3 newPos);
|
||||
LLVector3 GetPos();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using libsecondlife;
|
||||
using OpenSim.Physics.Manager;
|
||||
using OpenSim.world;
|
||||
using Primitive=OpenSim.world.Primitive;
|
||||
|
||||
namespace OpenSim.RegionServer.world.scripting
|
||||
{
|
||||
public delegate void ScriptEventHandler( IScriptContext context );
|
||||
|
||||
public class ScriptHandler : IScriptContext
|
||||
{
|
||||
private World m_world;
|
||||
private Script m_script;
|
||||
private Entity m_entity;
|
||||
|
||||
public LLUUID ScriptId
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_script.ScriptId;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnFrame()
|
||||
{
|
||||
m_script.OnFrame(this);
|
||||
}
|
||||
|
||||
public ScriptHandler( Script script, Entity entity, World world )
|
||||
{
|
||||
m_script = script;
|
||||
m_entity = entity;
|
||||
m_world = world;
|
||||
}
|
||||
|
||||
#region IScriptContext Members
|
||||
|
||||
bool IScriptContext.MoveTo(LLVector3 newPos)
|
||||
{
|
||||
if (m_entity is Primitive)
|
||||
{
|
||||
Primitive prim = m_entity as Primitive;
|
||||
// Of course, we really should have asked the physEngine if this is possible, and if not, returned false.
|
||||
prim.UpdatePosition( newPos );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
LLVector3 IScriptContext.GetPos()
|
||||
{
|
||||
return m_entity.position;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.RegionServer.world.scripting
|
||||
{
|
||||
public class Script
|
||||
{
|
||||
private LLUUID m_scriptId;
|
||||
|
||||
public virtual LLUUID ScriptId
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_scriptId;
|
||||
}
|
||||
}
|
||||
|
||||
public Script( LLUUID scriptId )
|
||||
{
|
||||
m_scriptId = scriptId;
|
||||
}
|
||||
|
||||
public ScriptEventHandler OnFrame;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual C# Express 2005
|
||||
# Visual Studio 2005
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim", "OpenSim\OpenSim.csproj", "{438A9556-0000-0000-0000-000000000000}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Physics.OdePlugin", "OpenSim.Physics\OdePlugin\OpenSim.Physics.OdePlugin.csproj", "{63A05FE9-0000-0000-0000-000000000000}"
|
||||
|
|
|
@ -115,6 +115,7 @@ if (http_request.readyState==4)
|
|||
</div><br />
|
||||
<button onclick="loadXMLDoc('Admin/Clients')">Clients</button>
|
||||
<button onclick="loadXMLDoc('Admin/Accounts')">Accounts</button>
|
||||
<button onclick="loadXMLDoc('Admin/Entities')">Entities</button>
|
||||
|
||||
</body>
|
||||
|
||||
|
|
|
@ -118,7 +118,6 @@
|
|||
<Reference name="System.Data" localCopy="false"/>
|
||||
<Reference name="System.Xml" localCopy="false"/>
|
||||
<Reference name="OpenSim.Framework"/>
|
||||
<Reference name="OpenSim.Framework.Interfaces"/>
|
||||
<Reference name="OpenSim.Framework.Console"/>
|
||||
<Reference name="libsecondlife.dll"/>
|
||||
<Reference name="Db4objects.Db4o.dll"/>
|
||||
|
|
Loading…
Reference in New Issue