diff options
author | MW | 2007-06-14 12:49:28 +0000 |
---|---|---|
committer | MW | 2007-06-14 12:49:28 +0000 |
commit | 841ae288e4e9ad841d2b5226cccd1a17c22b9168 (patch) | |
tree | 7f22e9befb5fc463210a9ea14348cfba8e752fab | |
parent | trying to clean up the namespaces. (diff) | |
download | opensim-SC_OLD-841ae288e4e9ad841d2b5226cccd1a17c22b9168.zip opensim-SC_OLD-841ae288e4e9ad841d2b5226cccd1a17c22b9168.tar.gz opensim-SC_OLD-841ae288e4e9ad841d2b5226cccd1a17c22b9168.tar.bz2 opensim-SC_OLD-841ae288e4e9ad841d2b5226cccd1a17c22b9168.tar.xz |
trying to clean up the namespaces.
18 files changed, 2961 insertions, 45 deletions
diff --git a/OpenSim/OpenSim.Region/OpenSim.Region.csproj b/OpenSim/OpenSim.Region/OpenSim.Region.csproj index 92a74cf..9b765f6 100644 --- a/OpenSim/OpenSim.Region/OpenSim.Region.csproj +++ b/OpenSim/OpenSim.Region/OpenSim.Region.csproj | |||
@@ -1,4 +1,4 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | 1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
2 | <PropertyGroup> | 2 | <PropertyGroup> |
3 | <ProjectType>Local</ProjectType> | 3 | <ProjectType>Local</ProjectType> |
4 | <ProductVersion>8.0.50727</ProductVersion> | 4 | <ProductVersion>8.0.50727</ProductVersion> |
@@ -6,8 +6,7 @@ | |||
6 | <ProjectGuid>{196916AF-0000-0000-0000-000000000000}</ProjectGuid> | 6 | <ProjectGuid>{196916AF-0000-0000-0000-000000000000}</ProjectGuid> |
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | 7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | 8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
9 | <ApplicationIcon> | 9 | <ApplicationIcon></ApplicationIcon> |
10 | </ApplicationIcon> | ||
11 | <AssemblyKeyContainerName> | 10 | <AssemblyKeyContainerName> |
12 | </AssemblyKeyContainerName> | 11 | </AssemblyKeyContainerName> |
13 | <AssemblyName>OpenSim.Region</AssemblyName> | 12 | <AssemblyName>OpenSim.Region</AssemblyName> |
@@ -16,11 +15,9 @@ | |||
16 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | 15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> |
17 | <DelaySign>false</DelaySign> | 16 | <DelaySign>false</DelaySign> |
18 | <OutputType>Library</OutputType> | 17 | <OutputType>Library</OutputType> |
19 | <AppDesignerFolder> | 18 | <AppDesignerFolder></AppDesignerFolder> |
20 | </AppDesignerFolder> | ||
21 | <RootNamespace>OpenSim.Region</RootNamespace> | 19 | <RootNamespace>OpenSim.Region</RootNamespace> |
22 | <StartupObject> | 20 | <StartupObject></StartupObject> |
23 | </StartupObject> | ||
24 | <FileUpgradeFlags> | 21 | <FileUpgradeFlags> |
25 | </FileUpgradeFlags> | 22 | </FileUpgradeFlags> |
26 | </PropertyGroup> | 23 | </PropertyGroup> |
@@ -31,8 +28,7 @@ | |||
31 | <ConfigurationOverrideFile> | 28 | <ConfigurationOverrideFile> |
32 | </ConfigurationOverrideFile> | 29 | </ConfigurationOverrideFile> |
33 | <DefineConstants>TRACE;DEBUG</DefineConstants> | 30 | <DefineConstants>TRACE;DEBUG</DefineConstants> |
34 | <DocumentationFile> | 31 | <DocumentationFile></DocumentationFile> |
35 | </DocumentationFile> | ||
36 | <DebugSymbols>True</DebugSymbols> | 32 | <DebugSymbols>True</DebugSymbols> |
37 | <FileAlignment>4096</FileAlignment> | 33 | <FileAlignment>4096</FileAlignment> |
38 | <Optimize>False</Optimize> | 34 | <Optimize>False</Optimize> |
@@ -41,8 +37,7 @@ | |||
41 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | 37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> |
42 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | 38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
43 | <WarningLevel>4</WarningLevel> | 39 | <WarningLevel>4</WarningLevel> |
44 | <NoWarn> | 40 | <NoWarn></NoWarn> |
45 | </NoWarn> | ||
46 | </PropertyGroup> | 41 | </PropertyGroup> |
47 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | 42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
48 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | 43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
@@ -51,8 +46,7 @@ | |||
51 | <ConfigurationOverrideFile> | 46 | <ConfigurationOverrideFile> |
52 | </ConfigurationOverrideFile> | 47 | </ConfigurationOverrideFile> |
53 | <DefineConstants>TRACE</DefineConstants> | 48 | <DefineConstants>TRACE</DefineConstants> |
54 | <DocumentationFile> | 49 | <DocumentationFile></DocumentationFile> |
55 | </DocumentationFile> | ||
56 | <DebugSymbols>False</DebugSymbols> | 50 | <DebugSymbols>False</DebugSymbols> |
57 | <FileAlignment>4096</FileAlignment> | 51 | <FileAlignment>4096</FileAlignment> |
58 | <Optimize>True</Optimize> | 52 | <Optimize>True</Optimize> |
@@ -61,27 +55,26 @@ | |||
61 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | 55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> |
62 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | 56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
63 | <WarningLevel>4</WarningLevel> | 57 | <WarningLevel>4</WarningLevel> |
64 | <NoWarn> | 58 | <NoWarn></NoWarn> |
65 | </NoWarn> | ||
66 | </PropertyGroup> | 59 | </PropertyGroup> |
67 | <ItemGroup> | 60 | <ItemGroup> |
68 | <Reference Include="Axiom.MathLib.dll"> | 61 | <Reference Include="Axiom.MathLib.dll" > |
69 | <HintPath>..\..\bin\Axiom.MathLib.dll</HintPath> | 62 | <HintPath>..\..\bin\Axiom.MathLib.dll</HintPath> |
70 | <Private>False</Private> | 63 | <Private>False</Private> |
71 | </Reference> | 64 | </Reference> |
72 | <Reference Include="Db4objects.Db4o.dll"> | 65 | <Reference Include="Db4objects.Db4o.dll" > |
73 | <HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath> | 66 | <HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath> |
74 | <Private>False</Private> | 67 | <Private>False</Private> |
75 | </Reference> | 68 | </Reference> |
76 | <Reference Include="libsecondlife.dll"> | 69 | <Reference Include="libsecondlife.dll" > |
77 | <HintPath>..\..\bin\libsecondlife.dll</HintPath> | 70 | <HintPath>..\..\bin\libsecondlife.dll</HintPath> |
78 | <Private>False</Private> | 71 | <Private>False</Private> |
79 | </Reference> | 72 | </Reference> |
80 | <Reference Include="System"> | 73 | <Reference Include="System" > |
81 | <HintPath>System.dll</HintPath> | 74 | <HintPath>System.dll</HintPath> |
82 | <Private>False</Private> | 75 | <Private>False</Private> |
83 | </Reference> | 76 | </Reference> |
84 | <Reference Include="System.Xml"> | 77 | <Reference Include="System.Xml" > |
85 | <HintPath>System.Xml.dll</HintPath> | 78 | <HintPath>System.Xml.dll</HintPath> |
86 | <Private>False</Private> | 79 | <Private>False</Private> |
87 | </Reference> | 80 | </Reference> |
@@ -91,49 +84,49 @@ | |||
91 | <Name>OpenGrid.Framework.Communications</Name> | 84 | <Name>OpenGrid.Framework.Communications</Name> |
92 | <Project>{683344D5-0000-0000-0000-000000000000}</Project> | 85 | <Project>{683344D5-0000-0000-0000-000000000000}</Project> |
93 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | 86 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> |
94 | <Private>False</Private> | 87 | <Private>False</Private> |
95 | </ProjectReference> | 88 | </ProjectReference> |
96 | <ProjectReference Include="..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj"> | 89 | <ProjectReference Include="..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj"> |
97 | <Name>OpenSim.Framework</Name> | 90 | <Name>OpenSim.Framework</Name> |
98 | <Project>{8ACA2445-0000-0000-0000-000000000000}</Project> | 91 | <Project>{8ACA2445-0000-0000-0000-000000000000}</Project> |
99 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | 92 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> |
100 | <Private>False</Private> | 93 | <Private>False</Private> |
101 | </ProjectReference> | 94 | </ProjectReference> |
102 | <ProjectReference Include="..\..\Common\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj"> | 95 | <ProjectReference Include="..\..\Common\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj"> |
103 | <Name>OpenSim.Framework.Console</Name> | 96 | <Name>OpenSim.Framework.Console</Name> |
104 | <Project>{A7CD0630-0000-0000-0000-000000000000}</Project> | 97 | <Project>{A7CD0630-0000-0000-0000-000000000000}</Project> |
105 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | 98 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> |
106 | <Private>False</Private> | 99 | <Private>False</Private> |
107 | </ProjectReference> | 100 | </ProjectReference> |
108 | <ProjectReference Include="..\..\Common\OpenSim.GenericConfig\Xml\OpenSim.GenericConfig.Xml.csproj"> | 101 | <ProjectReference Include="..\..\Common\OpenSim.GenericConfig\Xml\OpenSim.GenericConfig.Xml.csproj"> |
109 | <Name>OpenSim.GenericConfig.Xml</Name> | 102 | <Name>OpenSim.GenericConfig.Xml</Name> |
110 | <Project>{E88EF749-0000-0000-0000-000000000000}</Project> | 103 | <Project>{E88EF749-0000-0000-0000-000000000000}</Project> |
111 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | 104 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> |
112 | <Private>False</Private> | 105 | <Private>False</Private> |
113 | </ProjectReference> | 106 | </ProjectReference> |
114 | <ProjectReference Include="..\OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj"> | 107 | <ProjectReference Include="..\OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj"> |
115 | <Name>OpenSim.Physics.Manager</Name> | 108 | <Name>OpenSim.Physics.Manager</Name> |
116 | <Project>{8BE16150-0000-0000-0000-000000000000}</Project> | 109 | <Project>{8BE16150-0000-0000-0000-000000000000}</Project> |
117 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | 110 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> |
118 | <Private>False</Private> | 111 | <Private>False</Private> |
119 | </ProjectReference> | 112 | </ProjectReference> |
120 | <ProjectReference Include="..\..\Common\OpenSim.Servers\OpenSim.Servers.csproj"> | 113 | <ProjectReference Include="..\..\Common\OpenSim.Servers\OpenSim.Servers.csproj"> |
121 | <Name>OpenSim.Servers</Name> | 114 | <Name>OpenSim.Servers</Name> |
122 | <Project>{8BB20F0A-0000-0000-0000-000000000000}</Project> | 115 | <Project>{8BB20F0A-0000-0000-0000-000000000000}</Project> |
123 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | 116 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> |
124 | <Private>False</Private> | 117 | <Private>False</Private> |
125 | </ProjectReference> | 118 | </ProjectReference> |
126 | <ProjectReference Include="..\OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj"> | 119 | <ProjectReference Include="..\OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj"> |
127 | <Name>OpenSim.Terrain.BasicTerrain</Name> | 120 | <Name>OpenSim.Terrain.BasicTerrain</Name> |
128 | <Project>{2270B8FE-0000-0000-0000-000000000000}</Project> | 121 | <Project>{2270B8FE-0000-0000-0000-000000000000}</Project> |
129 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | 122 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> |
130 | <Private>False</Private> | 123 | <Private>False</Private> |
131 | </ProjectReference> | 124 | </ProjectReference> |
132 | <ProjectReference Include="..\..\Common\XmlRpcCS\XMLRPC.csproj"> | 125 | <ProjectReference Include="..\..\Common\XmlRpcCS\XMLRPC.csproj"> |
133 | <Name>XMLRPC</Name> | 126 | <Name>XMLRPC</Name> |
134 | <Project>{8E81D43C-0000-0000-0000-000000000000}</Project> | 127 | <Project>{8E81D43C-0000-0000-0000-000000000000}</Project> |
135 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | 128 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> |
136 | <Private>False</Private> | 129 | <Private>False</Private> |
137 | </ProjectReference> | 130 | </ProjectReference> |
138 | </ItemGroup> | 131 | </ItemGroup> |
139 | <ItemGroup> | 132 | <ItemGroup> |
@@ -199,4 +192,4 @@ | |||
199 | <PostBuildEvent> | 192 | <PostBuildEvent> |
200 | </PostBuildEvent> | 193 | </PostBuildEvent> |
201 | </PropertyGroup> | 194 | </PropertyGroup> |
202 | </Project> \ No newline at end of file | 195 | </Project> |
diff --git a/OpenSim/OpenSim.Region/OpenSim.Region.dll.build b/OpenSim/OpenSim.Region/OpenSim.Region.dll.build index 0a37a99..15d842e 100644 --- a/OpenSim/OpenSim.Region/OpenSim.Region.dll.build +++ b/OpenSim/OpenSim.Region/OpenSim.Region.dll.build | |||
@@ -13,22 +13,22 @@ | |||
13 | <sources failonempty="true"> | 13 | <sources failonempty="true"> |
14 | <include name="EstateManager.cs" /> | 14 | <include name="EstateManager.cs" /> |
15 | <include name="ParcelManager.cs" /> | 15 | <include name="ParcelManager.cs" /> |
16 | <include name="Scene/Scene.cs" /> | 16 | <include name="Scenes/Scene.cs" /> |
17 | <include name="Scene/Scene.PacketHandlers.cs" /> | 17 | <include name="Scenes/Scene.PacketHandlers.cs" /> |
18 | <include name="Scene/Scene.Scripting.cs" /> | 18 | <include name="Scenes/Scene.Scripting.cs" /> |
19 | <include name="Scene/SceneBase.cs" /> | 19 | <include name="Scenes/SceneBase.cs" /> |
20 | <include name="Scene/Entities/Avatar.Animations.cs" /> | 20 | <include name="Scenes/Entities/Avatar.Animations.cs" /> |
21 | <include name="Scene/Entities/Avatar.cs" /> | 21 | <include name="Scenes/Entities/Avatar.cs" /> |
22 | <include name="Scene/Entities/Avatar.Update.cs" /> | 22 | <include name="Scenes/Entities/Avatar.Update.cs" /> |
23 | <include name="Scene/Entities/Entity.cs" /> | 23 | <include name="Scenes/Entities/Entity.cs" /> |
24 | <include name="Scene/Entities/Primitive.cs" /> | 24 | <include name="Scenes/Entities/Primitive.cs" /> |
25 | <include name="Scene/Entities/SceneObject.cs" /> | 25 | <include name="Scenes/Entities/SceneObject.cs" /> |
26 | <include name="Scene/scripting/IScriptContext.cs" /> | 26 | <include name="Scenes/scripting/IScriptContext.cs" /> |
27 | <include name="Scene/scripting/IScriptEntity.cs" /> | 27 | <include name="Scenes/scripting/IScriptEntity.cs" /> |
28 | <include name="Scene/scripting/IScriptHandler.cs" /> | 28 | <include name="Scenes/scripting/IScriptHandler.cs" /> |
29 | <include name="Scene/scripting/Script.cs" /> | 29 | <include name="Scenes/scripting/Script.cs" /> |
30 | <include name="Scene/scripting/ScriptFactory.cs" /> | 30 | <include name="Scenes/scripting/ScriptFactory.cs" /> |
31 | <include name="Scene/scripting/Scripts/FollowRandomAvatar.cs" /> | 31 | <include name="Scenes/scripting/Scripts/FollowRandomAvatar.cs" /> |
32 | </sources> | 32 | </sources> |
33 | <references basedir="${project::get-base-directory()}"> | 33 | <references basedir="${project::get-base-directory()}"> |
34 | <lib> | 34 | <lib> |
diff --git a/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Animations.cs b/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Animations.cs new file mode 100644 index 0000000..1963a8a --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Animations.cs | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | using System.Xml; | ||
33 | |||
34 | namespace OpenSim.Region.Scenes | ||
35 | { | ||
36 | partial class Avatar | ||
37 | { | ||
38 | public class AvatarAnimations | ||
39 | { | ||
40 | |||
41 | public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>(); | ||
42 | public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>(); | ||
43 | |||
44 | public AvatarAnimations() | ||
45 | { | ||
46 | } | ||
47 | |||
48 | public void LoadAnims() | ||
49 | { | ||
50 | //OpenSim.Framework.Console.MainConsole.Instance.Verbose("Avatar.cs:LoadAnims() - Loading avatar animations"); | ||
51 | XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"); | ||
52 | |||
53 | XmlDocument doc = new XmlDocument(); | ||
54 | doc.Load(reader); | ||
55 | foreach (XmlNode nod in doc.DocumentElement.ChildNodes) | ||
56 | { | ||
57 | |||
58 | if (nod.Attributes["name"] != null) | ||
59 | { | ||
60 | AnimsLLUUID.Add(nod.Attributes["name"].Value, nod.InnerText); | ||
61 | } | ||
62 | |||
63 | } | ||
64 | |||
65 | reader.Close(); | ||
66 | |||
67 | // OpenSim.Framework.Console.MainConsole.Instance.Verbose("Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)"); | ||
68 | |||
69 | foreach (KeyValuePair<string, LLUUID> kp in OpenSim.Region.Scenes.Avatar.Animations.AnimsLLUUID) | ||
70 | { | ||
71 | AnimsNames.Add(kp.Value, kp.Key); | ||
72 | } | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Update.cs b/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Update.cs new file mode 100644 index 0000000..d5c25f3 --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Update.cs | |||
@@ -0,0 +1,148 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | using libsecondlife.Packets; | ||
33 | using OpenSim.Physics.Manager; | ||
34 | using OpenSim.Framework.Interfaces; | ||
35 | |||
36 | namespace OpenSim.Region.Scenes | ||
37 | { | ||
38 | partial class Avatar | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// | ||
42 | /// </summary> | ||
43 | public override void update() | ||
44 | { | ||
45 | |||
46 | |||
47 | } | ||
48 | |||
49 | /// <summary> | ||
50 | /// | ||
51 | /// </summary> | ||
52 | /// <param name="remoteAvatar"></param> | ||
53 | public void SendUpdateToOtherClient(Avatar remoteAvatar) | ||
54 | { | ||
55 | |||
56 | } | ||
57 | |||
58 | /// <summary> | ||
59 | /// | ||
60 | /// </summary> | ||
61 | /// <returns></returns> | ||
62 | public ObjectUpdatePacket CreateUpdatePacket() | ||
63 | { | ||
64 | return null; | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// | ||
69 | /// </summary> | ||
70 | public void SendInitialPosition() | ||
71 | { | ||
72 | this.ControllingClient.SendAvatarData(m_regionInfo, this.firstname, this.lastname, this.uuid, this.localid, new LLVector3(128, 128, 60)); | ||
73 | } | ||
74 | |||
75 | /// <summary> | ||
76 | /// | ||
77 | /// </summary> | ||
78 | public void SendOurAppearance() | ||
79 | { | ||
80 | |||
81 | } | ||
82 | |||
83 | /// <summary> | ||
84 | /// | ||
85 | /// </summary> | ||
86 | /// <param name="OurClient"></param> | ||
87 | public void SendOurAppearance(IClientAPI OurClient) | ||
88 | { | ||
89 | this.ControllingClient.SendWearables(this.Wearables); | ||
90 | } | ||
91 | |||
92 | /// <summary> | ||
93 | /// | ||
94 | /// </summary> | ||
95 | /// <param name="avatarInfo"></param> | ||
96 | public void SendAppearanceToOtherAgent(Avatar avatarInfo) | ||
97 | { | ||
98 | |||
99 | } | ||
100 | |||
101 | /// <summary> | ||
102 | /// | ||
103 | /// </summary> | ||
104 | /// <param name="texture"></param> | ||
105 | /// <param name="visualParam"></param> | ||
106 | public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) | ||
107 | { | ||
108 | |||
109 | } | ||
110 | |||
111 | /// <summary> | ||
112 | /// | ||
113 | /// </summary> | ||
114 | public void StopMovement() | ||
115 | { | ||
116 | |||
117 | } | ||
118 | |||
119 | /// <summary> | ||
120 | /// Very likely to be deleted soon! | ||
121 | /// </summary> | ||
122 | /// <returns></returns> | ||
123 | public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() | ||
124 | { | ||
125 | return null; | ||
126 | } | ||
127 | |||
128 | /// <summary> | ||
129 | /// | ||
130 | /// </summary> | ||
131 | /// <param name="animID"></param> | ||
132 | /// <param name="seq"></param> | ||
133 | public void SendAnimPack(LLUUID animID, int seq) | ||
134 | { | ||
135 | |||
136 | |||
137 | } | ||
138 | |||
139 | /// <summary> | ||
140 | /// | ||
141 | /// </summary> | ||
142 | public void SendAnimPack() | ||
143 | { | ||
144 | |||
145 | } | ||
146 | |||
147 | } | ||
148 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.cs b/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.cs new file mode 100644 index 0000000..6ae4319 --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.cs | |||
@@ -0,0 +1,225 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Text; | ||
32 | using libsecondlife; | ||
33 | using libsecondlife.Packets; | ||
34 | using OpenSim.Physics.Manager; | ||
35 | using OpenSim.Framework.Inventory; | ||
36 | using OpenSim.Framework.Interfaces; | ||
37 | using OpenSim.Framework.Types; | ||
38 | using Axiom.MathLib; | ||
39 | |||
40 | namespace OpenSim.Region.Scenes | ||
41 | { | ||
42 | public partial class Avatar : Entity | ||
43 | { | ||
44 | public static bool PhysicsEngineFlying = false; | ||
45 | public static AvatarAnimations Animations; | ||
46 | public string firstname; | ||
47 | public string lastname; | ||
48 | public IClientAPI ControllingClient; | ||
49 | public LLUUID current_anim; | ||
50 | public int anim_seq; | ||
51 | private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; | ||
52 | private bool updateflag = false; | ||
53 | private byte movementflag = 0; | ||
54 | private List<NewForce> forcesList = new List<NewForce>(); | ||
55 | private short _updateCount = 0; | ||
56 | private Axiom.MathLib.Quaternion bodyRot; | ||
57 | private LLObject.TextureEntry avatarAppearanceTexture = null; | ||
58 | private byte[] visualParams; | ||
59 | private AvatarWearable[] Wearables; | ||
60 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); | ||
61 | private ulong m_regionHandle; | ||
62 | private Dictionary<uint, IClientAPI> m_clientThreads; | ||
63 | private bool childAvatar = false; | ||
64 | |||
65 | protected RegionInfo m_regionInfo; | ||
66 | /// <summary> | ||
67 | /// | ||
68 | /// </summary> | ||
69 | /// <param name="theClient"></param> | ||
70 | /// <param name="world"></param> | ||
71 | /// <param name="clientThreads"></param> | ||
72 | /// <param name="regionDat"></param> | ||
73 | public Avatar(IClientAPI theClient, Scene world, Dictionary<uint, IClientAPI> clientThreads, RegionInfo reginfo) | ||
74 | { | ||
75 | |||
76 | m_world = world; | ||
77 | m_clientThreads = clientThreads; | ||
78 | this.uuid = theClient.AgentId; | ||
79 | |||
80 | m_regionInfo = reginfo; | ||
81 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Avatar.cs - Loading details from grid (DUMMY)"); | ||
82 | ControllingClient = theClient; | ||
83 | this.firstname = ControllingClient.FirstName; | ||
84 | this.lastname = ControllingClient.LastName; | ||
85 | localid = this.m_world.NextLocalId; | ||
86 | Pos = ControllingClient.StartPos; | ||
87 | visualParams = new byte[218]; | ||
88 | for (int i = 0; i < 218; i++) | ||
89 | { | ||
90 | visualParams[i] = 100; | ||
91 | } | ||
92 | |||
93 | Wearables = AvatarWearable.DefaultWearables; | ||
94 | |||
95 | this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); | ||
96 | |||
97 | //register for events | ||
98 | ControllingClient.OnRequestWearables += new GenericCall(this.SendOurAppearance); | ||
99 | //ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance); | ||
100 | ControllingClient.OnCompleteMovementToRegion += new GenericCall2(this.CompleteMovement); | ||
101 | ControllingClient.OnCompleteMovementToRegion += new GenericCall2(this.SendInitialPosition); | ||
102 | /* ControllingClient.OnAgentUpdate += new GenericCall3(this.HandleAgentUpdate); | ||
103 | ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); | ||
104 | ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | ||
105 | ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | ||
106 | */ | ||
107 | } | ||
108 | |||
109 | /// <summary> | ||
110 | /// | ||
111 | /// </summary> | ||
112 | public PhysicsActor PhysActor | ||
113 | { | ||
114 | set | ||
115 | { | ||
116 | this._physActor = value; | ||
117 | } | ||
118 | get | ||
119 | { | ||
120 | return _physActor; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | /// <summary> | ||
125 | /// | ||
126 | /// </summary> | ||
127 | /// <param name="status"></param> | ||
128 | public void ChildStatusChange(bool status) | ||
129 | { | ||
130 | |||
131 | } | ||
132 | |||
133 | /// <summary> | ||
134 | /// | ||
135 | /// </summary> | ||
136 | public override void addForces() | ||
137 | { | ||
138 | |||
139 | } | ||
140 | |||
141 | /// <summary> | ||
142 | /// likely to removed very soon | ||
143 | /// </summary> | ||
144 | /// <param name="name"></param> | ||
145 | public static void SetupTemplate(string name) | ||
146 | { | ||
147 | |||
148 | } | ||
149 | |||
150 | /// <summary> | ||
151 | /// likely to removed very soon | ||
152 | /// </summary> | ||
153 | /// <param name="objdata"></param> | ||
154 | protected static void SetDefaultPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata) | ||
155 | { | ||
156 | |||
157 | |||
158 | |||
159 | } | ||
160 | |||
161 | /// <summary> | ||
162 | /// | ||
163 | /// </summary> | ||
164 | public void CompleteMovement() | ||
165 | { | ||
166 | this.ControllingClient.MoveAgentIntoRegion(m_regionInfo); | ||
167 | } | ||
168 | |||
169 | /// <summary> | ||
170 | /// | ||
171 | /// </summary> | ||
172 | /// <param name="pack"></param> | ||
173 | public void HandleAgentUpdate(Packet pack) | ||
174 | { | ||
175 | this.HandleUpdate((AgentUpdatePacket)pack); | ||
176 | } | ||
177 | |||
178 | /// <summary> | ||
179 | /// | ||
180 | /// </summary> | ||
181 | /// <param name="pack"></param> | ||
182 | public void HandleUpdate(AgentUpdatePacket pack) | ||
183 | { | ||
184 | |||
185 | } | ||
186 | |||
187 | /// <summary> | ||
188 | /// | ||
189 | /// </summary> | ||
190 | public void SendRegionHandshake() | ||
191 | { | ||
192 | |||
193 | } | ||
194 | |||
195 | /// <summary> | ||
196 | /// | ||
197 | /// </summary> | ||
198 | public static void LoadAnims() | ||
199 | { | ||
200 | |||
201 | } | ||
202 | |||
203 | /// <summary> | ||
204 | /// | ||
205 | /// </summary> | ||
206 | public override void LandRenegerated() | ||
207 | { | ||
208 | |||
209 | } | ||
210 | |||
211 | |||
212 | public class NewForce | ||
213 | { | ||
214 | public float X; | ||
215 | public float Y; | ||
216 | public float Z; | ||
217 | |||
218 | public NewForce() | ||
219 | { | ||
220 | |||
221 | } | ||
222 | } | ||
223 | } | ||
224 | |||
225 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/Entities/Entity.cs b/OpenSim/OpenSim.Region/Scenes/Entities/Entity.cs new file mode 100644 index 0000000..d4c981a --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/Entities/Entity.cs | |||
@@ -0,0 +1,148 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using Axiom.MathLib; | ||
32 | using OpenSim.Physics.Manager; | ||
33 | using libsecondlife; | ||
34 | using OpenSim.Region.Scripting; | ||
35 | |||
36 | namespace OpenSim.Region.Scenes | ||
37 | { | ||
38 | public abstract class Entity : IScriptReadonlyEntity | ||
39 | { | ||
40 | public libsecondlife.LLUUID uuid; | ||
41 | public uint localid; | ||
42 | public LLVector3 velocity; | ||
43 | public Quaternion rotation; | ||
44 | protected List<Entity> children; | ||
45 | protected LLVector3 m_pos; | ||
46 | protected PhysicsActor _physActor; | ||
47 | protected Scene m_world; | ||
48 | protected string m_name; | ||
49 | |||
50 | /// <summary> | ||
51 | /// | ||
52 | /// </summary> | ||
53 | public virtual string Name | ||
54 | { | ||
55 | get { return m_name; } | ||
56 | } | ||
57 | |||
58 | /// <summary> | ||
59 | /// | ||
60 | /// </summary> | ||
61 | public virtual LLVector3 Pos | ||
62 | { | ||
63 | get | ||
64 | { | ||
65 | if (this._physActor != null) | ||
66 | { | ||
67 | m_pos.X = _physActor.Position.X; | ||
68 | m_pos.Y = _physActor.Position.Y; | ||
69 | m_pos.Z = _physActor.Position.Z; | ||
70 | } | ||
71 | |||
72 | return m_pos; | ||
73 | } | ||
74 | set | ||
75 | { | ||
76 | if (this._physActor != null) | ||
77 | { | ||
78 | try | ||
79 | { | ||
80 | lock (this.m_world.SyncRoot) | ||
81 | { | ||
82 | |||
83 | this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z); | ||
84 | } | ||
85 | } | ||
86 | catch (Exception e) | ||
87 | { | ||
88 | Console.WriteLine(e.Message); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | m_pos = value; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | /// <summary> | ||
97 | /// Creates a new Entity (should not occur on it's own) | ||
98 | /// </summary> | ||
99 | public Entity() | ||
100 | { | ||
101 | uuid = new libsecondlife.LLUUID(); | ||
102 | localid = 0; | ||
103 | m_pos = new LLVector3(); | ||
104 | velocity = new LLVector3(); | ||
105 | rotation = new Quaternion(); | ||
106 | m_name = "(basic entity)"; | ||
107 | children = new List<Entity>(); | ||
108 | } | ||
109 | |||
110 | /// <summary> | ||
111 | /// | ||
112 | /// </summary> | ||
113 | public virtual void addForces() | ||
114 | { | ||
115 | foreach (Entity child in children) | ||
116 | { | ||
117 | child.addForces(); | ||
118 | } | ||
119 | } | ||
120 | |||
121 | /// <summary> | ||
122 | /// Performs any updates that need to be done at each frame. This function is overridable from it's children. | ||
123 | /// </summary> | ||
124 | public virtual void update() { | ||
125 | // Do any per-frame updates needed that are applicable to every type of entity | ||
126 | foreach (Entity child in children) | ||
127 | { | ||
128 | child.update(); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | /// <summary> | ||
133 | /// Called at a set interval to inform entities that they should back themsleves up to the DB | ||
134 | /// </summary> | ||
135 | public virtual void BackUp() | ||
136 | { | ||
137 | |||
138 | } | ||
139 | |||
140 | /// <summary> | ||
141 | /// Infoms the entity that the land (heightmap) has changed | ||
142 | /// </summary> | ||
143 | public virtual void LandRenegerated() | ||
144 | { | ||
145 | |||
146 | } | ||
147 | } | ||
148 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs b/OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs new file mode 100644 index 0000000..9bccfd3 --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs | |||
@@ -0,0 +1,541 @@ | |||
1 | |||
2 | /* | ||
3 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
4 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions are met: | ||
8 | * * Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * * Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * * Neither the name of the OpenSim Project nor the | ||
14 | * names of its contributors may be used to endorse or promote products | ||
15 | * derived from this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
20 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
27 | * | ||
28 | */ | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using libsecondlife; | ||
33 | using libsecondlife.Packets; | ||
34 | using OpenSim.Framework.Interfaces; | ||
35 | using OpenSim.Physics.Manager; | ||
36 | using OpenSim.Framework.Types; | ||
37 | using OpenSim.Framework.Inventory; | ||
38 | |||
39 | namespace OpenSim.Region.Scenes | ||
40 | { | ||
41 | public class Primitive : Entity | ||
42 | { | ||
43 | internal PrimData primData; | ||
44 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); | ||
45 | // private Dictionary<uint, IClientAPI> m_clientThreads; | ||
46 | private ulong m_regionHandle; | ||
47 | private const uint FULL_MASK_PERMISSIONS = 2147483647; | ||
48 | private bool physicsEnabled = false; | ||
49 | private byte updateFlag = 0; | ||
50 | |||
51 | private Dictionary<LLUUID, InventoryItem> inventoryItems; | ||
52 | |||
53 | #region Properties | ||
54 | |||
55 | public LLVector3 Scale | ||
56 | { | ||
57 | set | ||
58 | { | ||
59 | this.primData.Scale = value; | ||
60 | //this.dirtyFlag = true; | ||
61 | } | ||
62 | get | ||
63 | { | ||
64 | return this.primData.Scale; | ||
65 | } | ||
66 | } | ||
67 | |||
68 | public PhysicsActor PhysActor | ||
69 | { | ||
70 | set | ||
71 | { | ||
72 | this._physActor = value; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | public override LLVector3 Pos | ||
77 | { | ||
78 | get | ||
79 | { | ||
80 | return base.Pos; | ||
81 | } | ||
82 | set | ||
83 | { | ||
84 | base.Pos = value; | ||
85 | } | ||
86 | } | ||
87 | #endregion | ||
88 | |||
89 | /// <summary> | ||
90 | /// | ||
91 | /// </summary> | ||
92 | /// <param name="clientThreads"></param> | ||
93 | /// <param name="regionHandle"></param> | ||
94 | /// <param name="world"></param> | ||
95 | public Primitive( ulong regionHandle, Scene world) | ||
96 | { | ||
97 | // m_clientThreads = clientThreads; | ||
98 | m_regionHandle = regionHandle; | ||
99 | m_world = world; | ||
100 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | ||
101 | } | ||
102 | |||
103 | /// <summary> | ||
104 | /// | ||
105 | /// </summary> | ||
106 | /// <param name="regionHandle"></param> | ||
107 | /// <param name="world"></param> | ||
108 | /// <param name="addPacket"></param> | ||
109 | /// <param name="ownerID"></param> | ||
110 | /// <param name="localID"></param> | ||
111 | public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID) | ||
112 | { | ||
113 | // m_clientThreads = clientThreads; | ||
114 | m_regionHandle = regionHandle; | ||
115 | m_world = world; | ||
116 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | ||
117 | this.CreateFromPacket(addPacket, ownerID, localID); | ||
118 | } | ||
119 | |||
120 | /// <summary> | ||
121 | /// | ||
122 | /// </summary> | ||
123 | /// <param name="clientThreads"></param> | ||
124 | /// <param name="regionHandle"></param> | ||
125 | /// <param name="world"></param> | ||
126 | /// <param name="owner"></param> | ||
127 | /// <param name="fullID"></param> | ||
128 | /// <param name="localID"></param> | ||
129 | public Primitive( ulong regionHandle, Scene world, LLUUID owner, LLUUID fullID, uint localID) | ||
130 | { | ||
131 | // m_clientThreads = clientThreads; | ||
132 | m_regionHandle = regionHandle; | ||
133 | m_world = world; | ||
134 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | ||
135 | this.primData = new PrimData(); | ||
136 | this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
137 | this.primData.OwnerID = owner; | ||
138 | this.primData.FullID = this.uuid = fullID; | ||
139 | this.primData.LocalID = this.localid = localID; | ||
140 | } | ||
141 | |||
142 | /// <summary> | ||
143 | /// Constructor to create a default cube | ||
144 | /// </summary> | ||
145 | /// <param name="clientThreads"></param> | ||
146 | /// <param name="regionHandle"></param> | ||
147 | /// <param name="world"></param> | ||
148 | /// <param name="owner"></param> | ||
149 | /// <param name="localID"></param> | ||
150 | /// <param name="position"></param> | ||
151 | public Primitive( ulong regionHandle, Scene world, LLUUID owner, uint localID, LLVector3 position) | ||
152 | { | ||
153 | //m_clientThreads = clientThreads; | ||
154 | m_regionHandle = regionHandle; | ||
155 | m_world = world; | ||
156 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | ||
157 | this.primData = PrimData.DefaultCube(); | ||
158 | this.primData.OwnerID = owner; | ||
159 | this.primData.LocalID = this.localid = localID; | ||
160 | this.Pos = this.primData.Position = position; | ||
161 | |||
162 | this.updateFlag = 1; | ||
163 | } | ||
164 | |||
165 | /// <summary> | ||
166 | /// | ||
167 | /// </summary> | ||
168 | /// <returns></returns> | ||
169 | public byte[] GetByteArray() | ||
170 | { | ||
171 | byte[] result = null; | ||
172 | List<byte[]> dataArrays = new List<byte[]>(); | ||
173 | dataArrays.Add(primData.ToBytes()); | ||
174 | foreach (Entity child in children) | ||
175 | { | ||
176 | if (child is OpenSim.Region.Scenes.Primitive) | ||
177 | { | ||
178 | dataArrays.Add(((OpenSim.Region.Scenes.Primitive)child).GetByteArray()); | ||
179 | } | ||
180 | } | ||
181 | byte[] primstart = Helpers.StringToField("<Prim>"); | ||
182 | byte[] primend = Helpers.StringToField("</Prim>"); | ||
183 | int totalLength = primstart.Length + primend.Length; | ||
184 | for (int i = 0; i < dataArrays.Count; i++) | ||
185 | { | ||
186 | totalLength += dataArrays[i].Length; | ||
187 | } | ||
188 | |||
189 | result = new byte[totalLength]; | ||
190 | int arraypos = 0; | ||
191 | Array.Copy(primstart, 0, result, 0, primstart.Length); | ||
192 | arraypos += primstart.Length; | ||
193 | for (int i = 0; i < dataArrays.Count; i++) | ||
194 | { | ||
195 | Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length); | ||
196 | arraypos += dataArrays[i].Length; | ||
197 | } | ||
198 | Array.Copy(primend, 0, result, arraypos, primend.Length); | ||
199 | |||
200 | return result; | ||
201 | } | ||
202 | |||
203 | #region Overridden Methods | ||
204 | |||
205 | /// <summary> | ||
206 | /// | ||
207 | /// </summary> | ||
208 | public override void update() | ||
209 | { | ||
210 | if (this.updateFlag == 1) // is a new prim just been created/reloaded | ||
211 | { | ||
212 | this.SendFullUpdateToAllClients(); | ||
213 | this.updateFlag = 0; | ||
214 | } | ||
215 | if (this.updateFlag == 2) //some change has been made so update the clients | ||
216 | { | ||
217 | this.SendTerseUpdateToALLClients(); | ||
218 | this.updateFlag = 0; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | /// <summary> | ||
223 | /// | ||
224 | /// </summary> | ||
225 | public override void BackUp() | ||
226 | { | ||
227 | |||
228 | } | ||
229 | |||
230 | #endregion | ||
231 | |||
232 | #region Packet handlers | ||
233 | |||
234 | /// <summary> | ||
235 | /// | ||
236 | /// </summary> | ||
237 | /// <param name="pos"></param> | ||
238 | public void UpdatePosition(LLVector3 pos) | ||
239 | { | ||
240 | this.Pos = new LLVector3(pos.X, pos.Y, pos.Z); | ||
241 | this.updateFlag = 2; | ||
242 | } | ||
243 | |||
244 | /// <summary> | ||
245 | /// | ||
246 | /// </summary> | ||
247 | /// <param name="addPacket"></param> | ||
248 | public void UpdateShape(ObjectShapePacket.ObjectDataBlock updatePacket) | ||
249 | { | ||
250 | this.primData.PathBegin = updatePacket.PathBegin; | ||
251 | this.primData.PathEnd = updatePacket.PathEnd; | ||
252 | this.primData.PathScaleX = updatePacket.PathScaleX; | ||
253 | this.primData.PathScaleY = updatePacket.PathScaleY; | ||
254 | this.primData.PathShearX = updatePacket.PathShearX; | ||
255 | this.primData.PathShearY = updatePacket.PathShearY; | ||
256 | this.primData.PathSkew = updatePacket.PathSkew; | ||
257 | this.primData.ProfileBegin = updatePacket.ProfileBegin; | ||
258 | this.primData.ProfileEnd = updatePacket.ProfileEnd; | ||
259 | this.primData.PathCurve = updatePacket.PathCurve; | ||
260 | this.primData.ProfileCurve = updatePacket.ProfileCurve; | ||
261 | this.primData.ProfileHollow = updatePacket.ProfileHollow; | ||
262 | this.primData.PathRadiusOffset = updatePacket.PathRadiusOffset; | ||
263 | this.primData.PathRevolutions = updatePacket.PathRevolutions; | ||
264 | this.primData.PathTaperX = updatePacket.PathTaperX; | ||
265 | this.primData.PathTaperY = updatePacket.PathTaperY; | ||
266 | this.primData.PathTwist = updatePacket.PathTwist; | ||
267 | this.primData.PathTwistBegin = updatePacket.PathTwistBegin; | ||
268 | } | ||
269 | |||
270 | /// <summary> | ||
271 | /// | ||
272 | /// </summary> | ||
273 | /// <param name="tex"></param> | ||
274 | public void UpdateTexture(byte[] tex) | ||
275 | { | ||
276 | this.primData.Texture = tex; | ||
277 | } | ||
278 | |||
279 | /// <summary> | ||
280 | /// | ||
281 | /// </summary> | ||
282 | /// <param name="pack"></param> | ||
283 | public void UpdateObjectFlags(ObjectFlagUpdatePacket pack) | ||
284 | { | ||
285 | |||
286 | } | ||
287 | |||
288 | /// <summary> | ||
289 | /// | ||
290 | /// </summary> | ||
291 | /// <param name="prim"></param> | ||
292 | public void AssignToParent(Primitive prim) | ||
293 | { | ||
294 | |||
295 | } | ||
296 | |||
297 | #endregion | ||
298 | |||
299 | # region Inventory Methods | ||
300 | /// <summary> | ||
301 | /// | ||
302 | /// </summary> | ||
303 | /// <param name="item"></param> | ||
304 | /// <returns></returns> | ||
305 | public bool AddToInventory(InventoryItem item) | ||
306 | { | ||
307 | return false; | ||
308 | } | ||
309 | |||
310 | /// <summary> | ||
311 | /// | ||
312 | /// </summary> | ||
313 | /// <param name="itemID"></param> | ||
314 | /// <returns></returns> | ||
315 | public InventoryItem RemoveFromInventory(LLUUID itemID) | ||
316 | { | ||
317 | return null; | ||
318 | } | ||
319 | |||
320 | /// <summary> | ||
321 | /// | ||
322 | /// </summary> | ||
323 | /// <param name="simClient"></param> | ||
324 | /// <param name="packet"></param> | ||
325 | public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet) | ||
326 | { | ||
327 | |||
328 | } | ||
329 | |||
330 | /// <summary> | ||
331 | /// | ||
332 | /// </summary> | ||
333 | /// <param name="simClient"></param> | ||
334 | /// <param name="xferID"></param> | ||
335 | public void RequestXferInventory(IClientAPI simClient, ulong xferID) | ||
336 | { | ||
337 | //will only currently work if the total size of the inventory data array is under about 1000 bytes | ||
338 | SendXferPacketPacket send = new SendXferPacketPacket(); | ||
339 | |||
340 | send.XferID.ID = xferID; | ||
341 | send.XferID.Packet = 1 + 2147483648; | ||
342 | send.DataPacket.Data = this.ConvertInventoryToBytes(); | ||
343 | |||
344 | simClient.OutPacket(send); | ||
345 | } | ||
346 | |||
347 | /// <summary> | ||
348 | /// | ||
349 | /// </summary> | ||
350 | /// <returns></returns> | ||
351 | public byte[] ConvertInventoryToBytes() | ||
352 | { | ||
353 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
354 | byte[] result = new byte[0]; | ||
355 | List<byte[]> inventoryData = new List<byte[]>(); | ||
356 | int totallength = 0; | ||
357 | foreach (InventoryItem invItem in inventoryItems.Values) | ||
358 | { | ||
359 | byte[] data = enc.GetBytes(invItem.ExportString()); | ||
360 | inventoryData.Add(data); | ||
361 | totallength += data.Length; | ||
362 | } | ||
363 | //TODO: copy arrays into the single result array | ||
364 | |||
365 | return result; | ||
366 | } | ||
367 | |||
368 | /// <summary> | ||
369 | /// | ||
370 | /// </summary> | ||
371 | /// <param name="data"></param> | ||
372 | public void CreateInventoryFromBytes(byte[] data) | ||
373 | { | ||
374 | |||
375 | } | ||
376 | |||
377 | #endregion | ||
378 | |||
379 | #region Update viewers Methods | ||
380 | |||
381 | /// <summary> | ||
382 | /// | ||
383 | /// </summary> | ||
384 | /// <param name="remoteClient"></param> | ||
385 | public void SendFullUpdateForAllChildren(IClientAPI remoteClient) | ||
386 | { | ||
387 | this.SendFullUpdateToClient(remoteClient); | ||
388 | for (int i = 0; i < this.children.Count; i++) | ||
389 | { | ||
390 | if (this.children[i] is Primitive) | ||
391 | { | ||
392 | ((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient); | ||
393 | } | ||
394 | } | ||
395 | } | ||
396 | |||
397 | /// <summary> | ||
398 | /// | ||
399 | /// </summary> | ||
400 | /// <param name="remoteClient"></param> | ||
401 | public void SendFullUpdateToClient(IClientAPI remoteClient) | ||
402 | { | ||
403 | LLVector3 lPos; | ||
404 | if (this._physActor != null && this.physicsEnabled) | ||
405 | { | ||
406 | PhysicsVector pPos = this._physActor.Position; | ||
407 | lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); | ||
408 | } | ||
409 | else | ||
410 | { | ||
411 | lPos = this.Pos; | ||
412 | } | ||
413 | |||
414 | remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.localid, this.primData, lPos, new LLUUID("00000000-0000-0000-5005-000000000005")); | ||
415 | } | ||
416 | |||
417 | /// <summary> | ||
418 | /// | ||
419 | /// </summary> | ||
420 | public void SendFullUpdateToAllClients() | ||
421 | { | ||
422 | List<Avatar> avatars = this.m_world.RequestAvatarList(); | ||
423 | for (int i = 0; i < avatars.Count; i++) | ||
424 | { | ||
425 | this.SendFullUpdateToClient(avatars[i].ControllingClient); | ||
426 | } | ||
427 | } | ||
428 | |||
429 | /// <summary> | ||
430 | /// | ||
431 | /// </summary> | ||
432 | /// <param name="RemoteClient"></param> | ||
433 | public void SendTerseUpdateToClient(IClientAPI RemoteClient) | ||
434 | { | ||
435 | LLVector3 lPos; | ||
436 | Axiom.MathLib.Quaternion lRot; | ||
437 | if (this._physActor != null && this.physicsEnabled) | ||
438 | { | ||
439 | PhysicsVector pPos = this._physActor.Position; | ||
440 | lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); | ||
441 | lRot = this._physActor.Orientation; | ||
442 | } | ||
443 | else | ||
444 | { | ||
445 | lPos = this.Pos; | ||
446 | lRot = this.rotation; | ||
447 | } | ||
448 | } | ||
449 | |||
450 | /// <summary> | ||
451 | /// | ||
452 | /// </summary> | ||
453 | public void SendTerseUpdateToALLClients() | ||
454 | { | ||
455 | List<Avatar> avatars = this.m_world.RequestAvatarList(); | ||
456 | for (int i = 0; i < avatars.Count; i++) | ||
457 | { | ||
458 | this.SendTerseUpdateToClient(avatars[i].ControllingClient); | ||
459 | } | ||
460 | } | ||
461 | |||
462 | #endregion | ||
463 | |||
464 | #region Create Methods | ||
465 | |||
466 | /// <summary> | ||
467 | /// | ||
468 | /// </summary> | ||
469 | /// <param name="addPacket"></param> | ||
470 | /// <param name="ownerID"></param> | ||
471 | /// <param name="localID"></param> | ||
472 | public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID) | ||
473 | { | ||
474 | PrimData PData = new PrimData(); | ||
475 | this.primData = PData; | ||
476 | this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
477 | |||
478 | PData.OwnerID = ownerID; | ||
479 | PData.PCode = addPacket.ObjectData.PCode; | ||
480 | PData.PathBegin = addPacket.ObjectData.PathBegin; | ||
481 | PData.PathEnd = addPacket.ObjectData.PathEnd; | ||
482 | PData.PathScaleX = addPacket.ObjectData.PathScaleX; | ||
483 | PData.PathScaleY = addPacket.ObjectData.PathScaleY; | ||
484 | PData.PathShearX = addPacket.ObjectData.PathShearX; | ||
485 | PData.PathShearY = addPacket.ObjectData.PathShearY; | ||
486 | PData.PathSkew = addPacket.ObjectData.PathSkew; | ||
487 | PData.ProfileBegin = addPacket.ObjectData.ProfileBegin; | ||
488 | PData.ProfileEnd = addPacket.ObjectData.ProfileEnd; | ||
489 | PData.Scale = addPacket.ObjectData.Scale; | ||
490 | PData.PathCurve = addPacket.ObjectData.PathCurve; | ||
491 | PData.ProfileCurve = addPacket.ObjectData.ProfileCurve; | ||
492 | PData.ParentID = 0; | ||
493 | PData.ProfileHollow = addPacket.ObjectData.ProfileHollow; | ||
494 | PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; | ||
495 | PData.PathRevolutions = addPacket.ObjectData.PathRevolutions; | ||
496 | PData.PathTaperX = addPacket.ObjectData.PathTaperX; | ||
497 | PData.PathTaperY = addPacket.ObjectData.PathTaperY; | ||
498 | PData.PathTwist = addPacket.ObjectData.PathTwist; | ||
499 | PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; | ||
500 | LLVector3 pos1 = addPacket.ObjectData.RayEnd; | ||
501 | this.primData.FullID = this.uuid = LLUUID.Random(); | ||
502 | this.primData.LocalID = this.localid = (uint)(localID); | ||
503 | this.primData.Position = this.Pos = pos1; | ||
504 | |||
505 | this.updateFlag = 1; | ||
506 | } | ||
507 | |||
508 | /// <summary> | ||
509 | /// | ||
510 | /// </summary> | ||
511 | /// <param name="data"></param> | ||
512 | public void CreateFromBytes(byte[] data) | ||
513 | { | ||
514 | |||
515 | } | ||
516 | |||
517 | /// <summary> | ||
518 | /// | ||
519 | /// </summary> | ||
520 | /// <param name="primData"></param> | ||
521 | public void CreateFromPrimData(PrimData primData) | ||
522 | { | ||
523 | this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false); | ||
524 | } | ||
525 | |||
526 | /// <summary> | ||
527 | /// | ||
528 | /// </summary> | ||
529 | /// <param name="primData"></param> | ||
530 | /// <param name="posi"></param> | ||
531 | /// <param name="localID"></param> | ||
532 | /// <param name="newprim"></param> | ||
533 | public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim) | ||
534 | { | ||
535 | |||
536 | } | ||
537 | |||
538 | #endregion | ||
539 | |||
540 | } | ||
541 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/Entities/SceneObject.cs b/OpenSim/OpenSim.Region/Scenes/Entities/SceneObject.cs new file mode 100644 index 0000000..5df87bf --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/Entities/SceneObject.cs | |||
@@ -0,0 +1,128 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | using libsecondlife.Packets; | ||
33 | using OpenSim.Framework.Interfaces; | ||
34 | using OpenSim.Physics.Manager; | ||
35 | using OpenSim.Framework.Types; | ||
36 | using OpenSim.Framework.Inventory; | ||
37 | |||
38 | namespace OpenSim.Region.Scenes | ||
39 | { | ||
40 | public class SceneObject : Entity | ||
41 | { | ||
42 | private LLUUID rootUUID; | ||
43 | //private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>(); | ||
44 | protected Primitive rootPrimitive; | ||
45 | private Scene m_world; | ||
46 | protected ulong regionHandle; | ||
47 | |||
48 | /// <summary> | ||
49 | /// | ||
50 | /// </summary> | ||
51 | public SceneObject() | ||
52 | { | ||
53 | |||
54 | } | ||
55 | |||
56 | /// <summary> | ||
57 | /// | ||
58 | /// </summary> | ||
59 | /// <param name="addPacket"></param> | ||
60 | /// <param name="agentID"></param> | ||
61 | /// <param name="localID"></param> | ||
62 | public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID) | ||
63 | { | ||
64 | this.rootPrimitive = new Primitive( this.regionHandle, this.m_world, addPacket, agentID, localID); | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// | ||
69 | /// </summary> | ||
70 | /// <param name="data"></param> | ||
71 | public void CreateFromBytes(byte[] data) | ||
72 | { | ||
73 | |||
74 | } | ||
75 | |||
76 | /// <summary> | ||
77 | /// | ||
78 | /// </summary> | ||
79 | public override void update() | ||
80 | { | ||
81 | |||
82 | } | ||
83 | |||
84 | /// <summary> | ||
85 | /// | ||
86 | /// </summary> | ||
87 | public override void BackUp() | ||
88 | { | ||
89 | |||
90 | } | ||
91 | |||
92 | /// <summary> | ||
93 | /// | ||
94 | /// </summary> | ||
95 | /// <param name="client"></param> | ||
96 | public void GetProperites(IClientAPI client) | ||
97 | { | ||
98 | //needs changing | ||
99 | ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); | ||
100 | proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; | ||
101 | proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); | ||
102 | proper.ObjectData[0].ItemID = LLUUID.Zero; | ||
103 | proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.primData.CreationDate; | ||
104 | proper.ObjectData[0].CreatorID = this.rootPrimitive.primData.OwnerID; | ||
105 | proper.ObjectData[0].FolderID = LLUUID.Zero; | ||
106 | proper.ObjectData[0].FromTaskID = LLUUID.Zero; | ||
107 | proper.ObjectData[0].GroupID = LLUUID.Zero; | ||
108 | proper.ObjectData[0].InventorySerial = 0; | ||
109 | proper.ObjectData[0].LastOwnerID = LLUUID.Zero; | ||
110 | proper.ObjectData[0].ObjectID = this.uuid; | ||
111 | proper.ObjectData[0].OwnerID = this.rootPrimitive.primData.OwnerID; | ||
112 | proper.ObjectData[0].TouchName = new byte[0]; | ||
113 | proper.ObjectData[0].TextureID = new byte[0]; | ||
114 | proper.ObjectData[0].SitName = new byte[0]; | ||
115 | proper.ObjectData[0].Name = new byte[0]; | ||
116 | proper.ObjectData[0].Description = new byte[0]; | ||
117 | proper.ObjectData[0].OwnerMask = this.rootPrimitive.primData.OwnerMask; | ||
118 | proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.primData.NextOwnerMask; | ||
119 | proper.ObjectData[0].GroupMask = this.rootPrimitive.primData.GroupMask; | ||
120 | proper.ObjectData[0].EveryoneMask = this.rootPrimitive.primData.EveryoneMask; | ||
121 | proper.ObjectData[0].BaseMask = this.rootPrimitive.primData.BaseMask; | ||
122 | |||
123 | client.OutPacket(proper); | ||
124 | |||
125 | } | ||
126 | |||
127 | } | ||
128 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs b/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs new file mode 100644 index 0000000..3d41200 --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs | |||
@@ -0,0 +1,253 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | using libsecondlife.Packets; | ||
33 | using OpenSim.Physics.Manager; | ||
34 | using OpenSim.Framework.Interfaces; | ||
35 | using OpenSim.Framework.Types; | ||
36 | using OpenSim.Framework.Inventory; | ||
37 | using OpenSim.Framework.Utilities; | ||
38 | |||
39 | namespace OpenSim.Region.Scenes | ||
40 | { | ||
41 | public partial class Scene | ||
42 | { | ||
43 | /// <summary> | ||
44 | /// | ||
45 | /// </summary> | ||
46 | /// <param name="action"></param> | ||
47 | /// <param name="north"></param> | ||
48 | /// <param name="west"></param> | ||
49 | public void ModifyTerrain(byte action, float north, float west) | ||
50 | { | ||
51 | switch (action) | ||
52 | { | ||
53 | case 1: | ||
54 | // raise terrain | ||
55 | Terrain.raise(north, west, 10.0, 0.001); | ||
56 | RegenerateTerrain(true, (int)north, (int)west); | ||
57 | break; | ||
58 | case 2: | ||
59 | //lower terrain | ||
60 | Terrain.lower(north, west, 10.0, 0.001); | ||
61 | RegenerateTerrain(true, (int)north, (int)west); | ||
62 | break; | ||
63 | } | ||
64 | return; | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// | ||
69 | /// </summary> | ||
70 | /// <param name="message"></param> | ||
71 | /// <param name="type"></param> | ||
72 | /// <param name="fromPos"></param> | ||
73 | /// <param name="fromName"></param> | ||
74 | /// <param name="fromAgentID"></param> | ||
75 | public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) | ||
76 | { | ||
77 | Console.WriteLine("Chat message"); | ||
78 | Avatar avatar = null; | ||
79 | foreach (IClientAPI client in m_clientThreads.Values) | ||
80 | { | ||
81 | int dis = -1000; | ||
82 | if (this.Avatars.ContainsKey(client.AgentId)) | ||
83 | { | ||
84 | |||
85 | avatar = this.Avatars[client.AgentId]; | ||
86 | // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); | ||
87 | dis= (int)avatar.Pos.GetDistanceTo(fromPos); | ||
88 | Console.WriteLine("found avatar at " +dis); | ||
89 | |||
90 | } | ||
91 | |||
92 | switch (type) | ||
93 | { | ||
94 | case 0: // Whisper | ||
95 | if ((dis < 10) && (dis > -10)) | ||
96 | { | ||
97 | //should change so the message is sent through the avatar rather than direct to the ClientView | ||
98 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
99 | } | ||
100 | break; | ||
101 | case 1: // Say | ||
102 | if ((dis < 30) && (dis > -30)) | ||
103 | { | ||
104 | Console.WriteLine("sending chat"); | ||
105 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
106 | } | ||
107 | break; | ||
108 | case 2: // Shout | ||
109 | if ((dis < 100) && (dis > -100)) | ||
110 | { | ||
111 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
112 | } | ||
113 | break; | ||
114 | |||
115 | case 0xff: // Broadcast | ||
116 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
117 | break; | ||
118 | } | ||
119 | |||
120 | } | ||
121 | } | ||
122 | |||
123 | /// <summary> | ||
124 | /// | ||
125 | /// </summary> | ||
126 | /// <param name="primAsset"></param> | ||
127 | /// <param name="pos"></param> | ||
128 | public void RezObject(AssetBase primAsset, LLVector3 pos) | ||
129 | { | ||
130 | |||
131 | } | ||
132 | |||
133 | /// <summary> | ||
134 | /// | ||
135 | /// </summary> | ||
136 | /// <param name="packet"></param> | ||
137 | /// <param name="simClient"></param> | ||
138 | public void DeRezObject(Packet packet, IClientAPI simClient) | ||
139 | { | ||
140 | |||
141 | } | ||
142 | |||
143 | /// <summary> | ||
144 | /// | ||
145 | /// </summary> | ||
146 | /// <param name="remoteClient"></param> | ||
147 | public void SendAvatarsToClient(IClientAPI remoteClient) | ||
148 | { | ||
149 | |||
150 | } | ||
151 | |||
152 | /// <summary> | ||
153 | /// | ||
154 | /// </summary> | ||
155 | /// <param name="parentPrim"></param> | ||
156 | /// <param name="childPrims"></param> | ||
157 | public void LinkObjects(uint parentPrim, List<uint> childPrims) | ||
158 | { | ||
159 | |||
160 | |||
161 | } | ||
162 | |||
163 | /// <summary> | ||
164 | /// | ||
165 | /// </summary> | ||
166 | /// <param name="primLocalID"></param> | ||
167 | /// <param name="shapeBlock"></param> | ||
168 | public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) | ||
169 | { | ||
170 | |||
171 | } | ||
172 | |||
173 | /// <summary> | ||
174 | /// | ||
175 | /// </summary> | ||
176 | /// <param name="primLocalID"></param> | ||
177 | /// <param name="remoteClient"></param> | ||
178 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) | ||
179 | { | ||
180 | |||
181 | } | ||
182 | |||
183 | /// <summary> | ||
184 | /// | ||
185 | /// </summary> | ||
186 | /// <param name="localID"></param> | ||
187 | /// <param name="packet"></param> | ||
188 | /// <param name="remoteClient"></param> | ||
189 | public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) | ||
190 | { | ||
191 | |||
192 | } | ||
193 | |||
194 | /// <summary> | ||
195 | /// | ||
196 | /// </summary> | ||
197 | /// <param name="localID"></param> | ||
198 | /// <param name="texture"></param> | ||
199 | /// <param name="remoteClient"></param> | ||
200 | public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) | ||
201 | { | ||
202 | |||
203 | } | ||
204 | |||
205 | /// <summary> | ||
206 | /// | ||
207 | /// </summary> | ||
208 | /// <param name="localID"></param> | ||
209 | /// <param name="pos"></param> | ||
210 | /// <param name="remoteClient"></param> | ||
211 | public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) | ||
212 | { | ||
213 | foreach (Entity ent in Entities.Values) | ||
214 | { | ||
215 | if (ent.localid == localID) | ||
216 | { | ||
217 | ((OpenSim.Region.Scenes.Primitive)ent).UpdatePosition(pos); | ||
218 | break; | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | |||
223 | /// <summary> | ||
224 | /// | ||
225 | /// </summary> | ||
226 | /// <param name="localID"></param> | ||
227 | /// <param name="rot"></param> | ||
228 | /// <param name="remoteClient"></param> | ||
229 | public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) | ||
230 | { | ||
231 | |||
232 | } | ||
233 | |||
234 | /// <summary> | ||
235 | /// | ||
236 | /// </summary> | ||
237 | /// <param name="localID"></param> | ||
238 | /// <param name="scale"></param> | ||
239 | /// <param name="remoteClient"></param> | ||
240 | public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient) | ||
241 | { | ||
242 | } | ||
243 | |||
244 | /// <summary> | ||
245 | /// Sends prims to a client | ||
246 | /// </summary> | ||
247 | /// <param name="RemoteClient">Client to send to</param> | ||
248 | public void GetInitialPrims(IClientAPI RemoteClient) | ||
249 | { | ||
250 | |||
251 | } | ||
252 | } | ||
253 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/Scene.Scripting.cs b/OpenSim/OpenSim.Region/Scenes/Scene.Scripting.cs new file mode 100644 index 0000000..50df16e --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/Scene.Scripting.cs | |||
@@ -0,0 +1,184 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Interfaces; | ||
35 | using OpenSim.Framework.Types; | ||
36 | using libsecondlife; | ||
37 | |||
38 | namespace OpenSim.Region.Scenes | ||
39 | { | ||
40 | public partial class Scene | ||
41 | { | ||
42 | private Dictionary<string, IScriptEngine> scriptEngines = new Dictionary<string, IScriptEngine>(); | ||
43 | |||
44 | /// <summary> | ||
45 | /// | ||
46 | /// </summary> | ||
47 | private void LoadScriptEngines() | ||
48 | { | ||
49 | this.LoadScriptPlugins(); | ||
50 | } | ||
51 | |||
52 | /// <summary> | ||
53 | /// | ||
54 | /// </summary> | ||
55 | public void LoadScriptPlugins() | ||
56 | { | ||
57 | string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ScriptEngines"); | ||
58 | string[] pluginFiles = Directory.GetFiles(path, "*.dll"); | ||
59 | |||
60 | |||
61 | for (int i = 0; i < pluginFiles.Length; i++) | ||
62 | { | ||
63 | this.AddPlugin(pluginFiles[i]); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// | ||
69 | /// </summary> | ||
70 | /// <param name="FileName"></param> | ||
71 | private void AddPlugin(string FileName) | ||
72 | { | ||
73 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | ||
74 | |||
75 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
76 | { | ||
77 | if (pluginType.IsPublic) | ||
78 | { | ||
79 | if (!pluginType.IsAbstract) | ||
80 | { | ||
81 | Type typeInterface = pluginType.GetInterface("IScriptEngine", true); | ||
82 | |||
83 | if (typeInterface != null) | ||
84 | { | ||
85 | IScriptEngine plug = (IScriptEngine)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
86 | plug.Init(this); | ||
87 | this.scriptEngines.Add(plug.GetName(), plug); | ||
88 | |||
89 | } | ||
90 | |||
91 | typeInterface = null; | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | |||
96 | pluginAssembly = null; | ||
97 | } | ||
98 | |||
99 | /// <summary> | ||
100 | /// | ||
101 | /// </summary> | ||
102 | /// <param name="scriptType"></param> | ||
103 | /// <param name="scriptName"></param> | ||
104 | /// <param name="script"></param> | ||
105 | /// <param name="ent"></param> | ||
106 | public void LoadScript(string scriptType, string scriptName, string script, Entity ent) | ||
107 | { | ||
108 | if(this.scriptEngines.ContainsKey(scriptType)) | ||
109 | { | ||
110 | this.scriptEngines[scriptType].LoadScript(script, scriptName, ent.localid); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | #region IScriptAPI Methods | ||
115 | |||
116 | /// <summary> | ||
117 | /// | ||
118 | /// </summary> | ||
119 | /// <param name="localID"></param> | ||
120 | /// <returns></returns> | ||
121 | public LLVector3 GetEntityPosition(uint localID) | ||
122 | { | ||
123 | LLVector3 res = new LLVector3(); | ||
124 | // Console.WriteLine("script- getting entity " + localID + " position"); | ||
125 | foreach (Entity entity in this.Entities.Values) | ||
126 | { | ||
127 | if (entity.localid == localID) | ||
128 | { | ||
129 | res.X = entity.Pos.X; | ||
130 | res.Y = entity.Pos.Y; | ||
131 | res.Z = entity.Pos.Z; | ||
132 | } | ||
133 | } | ||
134 | return res; | ||
135 | } | ||
136 | |||
137 | /// <summary> | ||
138 | /// | ||
139 | /// </summary> | ||
140 | /// <param name="localID"></param> | ||
141 | /// <param name="x"></param> | ||
142 | /// <param name="y"></param> | ||
143 | /// <param name="z"></param> | ||
144 | public void SetEntityPosition(uint localID, float x , float y, float z) | ||
145 | { | ||
146 | foreach (Entity entity in this.Entities.Values) | ||
147 | { | ||
148 | if (entity.localid == localID && entity is Primitive) | ||
149 | { | ||
150 | LLVector3 pos = entity.Pos; | ||
151 | pos.X = x; | ||
152 | pos.Y = y; | ||
153 | Primitive prim = entity as Primitive; | ||
154 | // Of course, we really should have asked the physEngine if this is possible, and if not, returned false. | ||
155 | //prim.UpdatePosition(pos); | ||
156 | // Console.WriteLine("script- setting entity " + localID + " positon"); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | } | ||
161 | |||
162 | /// <summary> | ||
163 | /// | ||
164 | /// </summary> | ||
165 | /// <returns></returns> | ||
166 | public uint GetRandomAvatarID() | ||
167 | { | ||
168 | //Console.WriteLine("script- getting random avatar id"); | ||
169 | uint res = 0; | ||
170 | foreach (Entity entity in this.Entities.Values) | ||
171 | { | ||
172 | if (entity is Avatar) | ||
173 | { | ||
174 | res = entity.localid; | ||
175 | } | ||
176 | } | ||
177 | return res; | ||
178 | } | ||
179 | |||
180 | #endregion | ||
181 | |||
182 | |||
183 | } | ||
184 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/Scene.cs b/OpenSim/OpenSim.Region/Scenes/Scene.cs new file mode 100644 index 0000000..7c61c90 --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/Scene.cs | |||
@@ -0,0 +1,718 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using libsecondlife; | ||
30 | using libsecondlife.Packets; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Text; | ||
33 | using System.Reflection; | ||
34 | using System.IO; | ||
35 | using System.Threading; | ||
36 | using System.Timers; | ||
37 | using OpenSim.Physics.Manager; | ||
38 | using OpenSim.Framework.Interfaces; | ||
39 | using OpenSim.Framework.Types; | ||
40 | using OpenSim.Framework.Inventory; | ||
41 | using OpenSim.Framework; | ||
42 | using OpenSim.Region.Scripting; | ||
43 | using OpenSim.Terrain; | ||
44 | using OpenGrid.Framework.Communications; | ||
45 | |||
46 | |||
47 | namespace OpenSim.Region.Scenes | ||
48 | { | ||
49 | public delegate bool FilterAvatarList(Avatar avatar); | ||
50 | |||
51 | public partial class Scene : SceneBase, ILocalStorageReceiver, IScriptAPI | ||
52 | { | ||
53 | protected System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer(); | ||
54 | protected Dictionary<libsecondlife.LLUUID, Avatar> Avatars; | ||
55 | protected Dictionary<libsecondlife.LLUUID, Primitive> Prims; | ||
56 | private PhysicsScene phyScene; | ||
57 | private float timeStep = 0.1f; | ||
58 | public ILocalStorage localStorage; | ||
59 | private Random Rand = new Random(); | ||
60 | private uint _primCount = 702000; | ||
61 | private int storageCount; | ||
62 | private Dictionary<LLUUID, ScriptHandler> m_scriptHandlers; | ||
63 | private Dictionary<string, ScriptFactory> m_scripts; | ||
64 | private Mutex updateLock; | ||
65 | public string m_datastore; | ||
66 | protected AuthenticateSessionsBase authenticateHandler; | ||
67 | protected RegionCommsHostBase regionCommsHost; | ||
68 | protected RegionServerCommsManager commsManager; | ||
69 | |||
70 | public ParcelManager parcelManager; | ||
71 | public EstateManager estateManager; | ||
72 | |||
73 | #region Properties | ||
74 | /// <summary> | ||
75 | /// | ||
76 | /// </summary> | ||
77 | public PhysicsScene PhysScene | ||
78 | { | ||
79 | set | ||
80 | { | ||
81 | this.phyScene = value; | ||
82 | } | ||
83 | get | ||
84 | { | ||
85 | return (this.phyScene); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | #endregion | ||
90 | |||
91 | #region Constructors | ||
92 | /// <summary> | ||
93 | /// Creates a new World class, and a region to go with it. | ||
94 | /// </summary> | ||
95 | /// <param name="clientThreads">Dictionary to contain client threads</param> | ||
96 | /// <param name="regionHandle">Region Handle for this region</param> | ||
97 | /// <param name="regionName">Region Name for this region</param> | ||
98 | public Scene(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regInfo, AuthenticateSessionsBase authen, RegionServerCommsManager commsMan) | ||
99 | { | ||
100 | try | ||
101 | { | ||
102 | updateLock = new Mutex(false); | ||
103 | this.authenticateHandler = authen; | ||
104 | this.commsManager = commsMan; | ||
105 | m_clientThreads = clientThreads; | ||
106 | m_regInfo = regInfo; | ||
107 | m_regionHandle = m_regInfo.RegionHandle; | ||
108 | m_regionName = m_regInfo.RegionName; | ||
109 | this.m_datastore = m_regInfo.DataStore; | ||
110 | this.RegisterRegionWithComms(); | ||
111 | |||
112 | parcelManager = new ParcelManager(this, this.m_regInfo); | ||
113 | estateManager = new EstateManager(this, this.m_regInfo); | ||
114 | |||
115 | m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>(); | ||
116 | m_scripts = new Dictionary<string, ScriptFactory>(); | ||
117 | |||
118 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs - creating new entitities instance"); | ||
119 | Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); | ||
120 | Avatars = new Dictionary<LLUUID, Avatar>(); | ||
121 | Prims = new Dictionary<LLUUID, Primitive>(); | ||
122 | |||
123 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs - creating LandMap"); | ||
124 | TerrainManager = new TerrainManager(new SecondLife()); | ||
125 | Terrain = new TerrainEngine(); | ||
126 | Avatar.SetupTemplate("avatar-texture.dat"); | ||
127 | |||
128 | Avatar.LoadAnims(); | ||
129 | |||
130 | //this.SetDefaultScripts(); | ||
131 | //this.LoadScriptEngines(); | ||
132 | |||
133 | |||
134 | } | ||
135 | catch (Exception e) | ||
136 | { | ||
137 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, "World.cs: Constructor failed with exception " + e.ToString()); | ||
138 | } | ||
139 | } | ||
140 | #endregion | ||
141 | |||
142 | /// <summary> | ||
143 | /// | ||
144 | /// </summary> | ||
145 | public void StartTimer() | ||
146 | { | ||
147 | m_heartbeatTimer.Enabled = true; | ||
148 | m_heartbeatTimer.Interval = 100; | ||
149 | m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat); | ||
150 | } | ||
151 | |||
152 | |||
153 | #region Update Methods | ||
154 | |||
155 | |||
156 | /// <summary> | ||
157 | /// Performs per-frame updates regularly | ||
158 | /// </summary> | ||
159 | /// <param name="sender"></param> | ||
160 | /// <param name="e"></param> | ||
161 | void Heartbeat(object sender, System.EventArgs e) | ||
162 | { | ||
163 | this.Update(); | ||
164 | } | ||
165 | |||
166 | /// <summary> | ||
167 | /// Performs per-frame updates on the world, this should be the central world loop | ||
168 | /// </summary> | ||
169 | public override void Update() | ||
170 | { | ||
171 | updateLock.WaitOne(); | ||
172 | try | ||
173 | { | ||
174 | if (this.phyScene.IsThreaded) | ||
175 | { | ||
176 | this.phyScene.GetResults(); | ||
177 | |||
178 | } | ||
179 | |||
180 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
181 | { | ||
182 | Entities[UUID].addForces(); | ||
183 | } | ||
184 | |||
185 | lock (this.m_syncRoot) | ||
186 | { | ||
187 | this.phyScene.Simulate(timeStep); | ||
188 | } | ||
189 | |||
190 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
191 | { | ||
192 | Entities[UUID].update(); | ||
193 | } | ||
194 | |||
195 | foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values) | ||
196 | { | ||
197 | scriptHandler.OnFrame(); | ||
198 | } | ||
199 | foreach (IScriptEngine scripteng in this.scriptEngines.Values) | ||
200 | { | ||
201 | scripteng.OnFrame(); | ||
202 | } | ||
203 | //backup world data | ||
204 | this.storageCount++; | ||
205 | if (storageCount > 1200) //set to how often you want to backup | ||
206 | { | ||
207 | this.Backup(); | ||
208 | storageCount = 0; | ||
209 | } | ||
210 | } | ||
211 | catch (Exception e) | ||
212 | { | ||
213 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: Update() - Failed with exception " + e.ToString()); | ||
214 | } | ||
215 | updateLock.ReleaseMutex(); | ||
216 | |||
217 | } | ||
218 | |||
219 | /// <summary> | ||
220 | /// | ||
221 | /// </summary> | ||
222 | /// <returns></returns> | ||
223 | public bool Backup() | ||
224 | { | ||
225 | /* | ||
226 | try | ||
227 | { | ||
228 | // Terrain backup routines | ||
229 | if (Terrain.tainted > 0) | ||
230 | { | ||
231 | Terrain.tainted = 0; | ||
232 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: Backup() - Terrain tainted, saving."); | ||
233 | localStorage.SaveMap(Terrain.getHeights1D()); | ||
234 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: Backup() - Terrain saved, informing Physics."); | ||
235 | lock (this.m_syncRoot) | ||
236 | { | ||
237 | phyScene.SetTerrain(Terrain.getHeights1D()); | ||
238 | } | ||
239 | } | ||
240 | |||
241 | // Primitive backup routines | ||
242 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: Backup() - Backing up Primitives"); | ||
243 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
244 | { | ||
245 | Entities[UUID].BackUp(); | ||
246 | } | ||
247 | |||
248 | //Parcel backup routines | ||
249 | ParcelData[] parcels = new ParcelData[parcelManager.parcelList.Count]; | ||
250 | int i = 0; | ||
251 | foreach (OpenSim.Region.Parcel parcel in parcelManager.parcelList.Values) | ||
252 | { | ||
253 | parcels[i] = parcel.parcelData; | ||
254 | i++; | ||
255 | } | ||
256 | localStorage.SaveParcels(parcels); | ||
257 | |||
258 | // Backup successful | ||
259 | return true; | ||
260 | } | ||
261 | catch (Exception e) | ||
262 | { | ||
263 | // Backup failed | ||
264 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Backup() - Backup Failed with exception " + e.ToString()); | ||
265 | return false; | ||
266 | } | ||
267 | */ | ||
268 | return true; | ||
269 | } | ||
270 | #endregion | ||
271 | |||
272 | #region Setup Methods | ||
273 | /// <summary> | ||
274 | /// Loads a new storage subsystem from a named library | ||
275 | /// </summary> | ||
276 | /// <param name="dllName">Storage Library</param> | ||
277 | /// <returns>Successful or not</returns> | ||
278 | public bool LoadStorageDLL(string dllName) | ||
279 | { | ||
280 | try | ||
281 | { | ||
282 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
283 | ILocalStorage store = null; | ||
284 | |||
285 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
286 | { | ||
287 | if (pluginType.IsPublic) | ||
288 | { | ||
289 | if (!pluginType.IsAbstract) | ||
290 | { | ||
291 | Type typeInterface = pluginType.GetInterface("ILocalStorage", true); | ||
292 | |||
293 | if (typeInterface != null) | ||
294 | { | ||
295 | ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
296 | store = plug; | ||
297 | |||
298 | store.Initialise(this.m_datastore); | ||
299 | break; | ||
300 | } | ||
301 | |||
302 | typeInterface = null; | ||
303 | } | ||
304 | } | ||
305 | } | ||
306 | pluginAssembly = null; | ||
307 | this.localStorage = store; | ||
308 | return (store == null); | ||
309 | } | ||
310 | catch (Exception e) | ||
311 | { | ||
312 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: LoadStorageDLL() - Failed with exception " + e.ToString()); | ||
313 | return false; | ||
314 | } | ||
315 | } | ||
316 | |||
317 | #endregion | ||
318 | |||
319 | #region Regenerate Terrain | ||
320 | |||
321 | /// <summary> | ||
322 | /// Rebuilds the terrain using a procedural algorithm | ||
323 | /// </summary> | ||
324 | public void RegenerateTerrain() | ||
325 | { | ||
326 | try | ||
327 | { | ||
328 | Terrain.hills(); | ||
329 | |||
330 | lock (this.m_syncRoot) | ||
331 | { | ||
332 | this.phyScene.SetTerrain(Terrain.getHeights1D()); | ||
333 | } | ||
334 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); | ||
335 | |||
336 | foreach (IClientAPI client in m_clientThreads.Values) | ||
337 | { | ||
338 | this.SendLayerData(client); | ||
339 | } | ||
340 | |||
341 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
342 | { | ||
343 | Entities[UUID].LandRenegerated(); | ||
344 | } | ||
345 | } | ||
346 | catch (Exception e) | ||
347 | { | ||
348 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); | ||
349 | } | ||
350 | } | ||
351 | |||
352 | /// <summary> | ||
353 | /// Rebuilds the terrain using a 2D float array | ||
354 | /// </summary> | ||
355 | /// <param name="newMap">256,256 float array containing heights</param> | ||
356 | public void RegenerateTerrain(float[,] newMap) | ||
357 | { | ||
358 | try | ||
359 | { | ||
360 | this.Terrain.setHeights2D(newMap); | ||
361 | lock (this.m_syncRoot) | ||
362 | { | ||
363 | this.phyScene.SetTerrain(this.Terrain.getHeights1D()); | ||
364 | } | ||
365 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); | ||
366 | |||
367 | foreach (IClientAPI client in m_clientThreads.Values) | ||
368 | { | ||
369 | this.SendLayerData(client); | ||
370 | } | ||
371 | |||
372 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
373 | { | ||
374 | Entities[UUID].LandRenegerated(); | ||
375 | } | ||
376 | } | ||
377 | catch (Exception e) | ||
378 | { | ||
379 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); | ||
380 | } | ||
381 | } | ||
382 | |||
383 | /// <summary> | ||
384 | /// Rebuilds the terrain assuming changes occured at a specified point[?] | ||
385 | /// </summary> | ||
386 | /// <param name="changes">???</param> | ||
387 | /// <param name="pointx">???</param> | ||
388 | /// <param name="pointy">???</param> | ||
389 | public void RegenerateTerrain(bool changes, int pointx, int pointy) | ||
390 | { | ||
391 | try | ||
392 | { | ||
393 | if (changes) | ||
394 | { | ||
395 | /* Dont save here, rely on tainting system instead */ | ||
396 | |||
397 | foreach (IClientAPI client in m_clientThreads.Values) | ||
398 | { | ||
399 | this.SendLayerData(pointx, pointy, client); | ||
400 | } | ||
401 | } | ||
402 | } | ||
403 | catch (Exception e) | ||
404 | { | ||
405 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); | ||
406 | } | ||
407 | } | ||
408 | |||
409 | #endregion | ||
410 | |||
411 | #region Load Terrain | ||
412 | /// <summary> | ||
413 | /// Loads the World heightmap | ||
414 | /// </summary> | ||
415 | public override void LoadWorldMap() | ||
416 | { | ||
417 | try | ||
418 | { | ||
419 | float[] map = this.localStorage.LoadWorld(); | ||
420 | if (map == null) | ||
421 | { | ||
422 | Console.WriteLine("creating new terrain"); | ||
423 | this.Terrain.hills(); | ||
424 | |||
425 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); | ||
426 | } | ||
427 | else | ||
428 | { | ||
429 | this.Terrain.setHeights1D(map); | ||
430 | } | ||
431 | } | ||
432 | catch (Exception e) | ||
433 | { | ||
434 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: LoadWorldMap() - Failed with exception " + e.ToString()); | ||
435 | } | ||
436 | } | ||
437 | #endregion | ||
438 | |||
439 | #region Primitives Methods | ||
440 | |||
441 | |||
442 | /// <summary> | ||
443 | /// Loads the World's objects | ||
444 | /// </summary> | ||
445 | public void LoadPrimsFromStorage() | ||
446 | { | ||
447 | try | ||
448 | { | ||
449 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: LoadPrimsFromStorage() - Loading primitives"); | ||
450 | this.localStorage.LoadPrimitives(this); | ||
451 | } | ||
452 | catch (Exception e) | ||
453 | { | ||
454 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString()); | ||
455 | } | ||
456 | } | ||
457 | |||
458 | /// <summary> | ||
459 | /// Loads a specific object from storage | ||
460 | /// </summary> | ||
461 | /// <param name="prim">The object to load</param> | ||
462 | public void PrimFromStorage(PrimData prim) | ||
463 | { | ||
464 | |||
465 | } | ||
466 | |||
467 | /// <summary> | ||
468 | /// | ||
469 | /// </summary> | ||
470 | /// <param name="addPacket"></param> | ||
471 | /// <param name="agentClient"></param> | ||
472 | public void AddNewPrim(Packet addPacket, IClientAPI agentClient) | ||
473 | { | ||
474 | AddNewPrim((ObjectAddPacket)addPacket, agentClient.AgentId); | ||
475 | } | ||
476 | |||
477 | /// <summary> | ||
478 | /// | ||
479 | /// </summary> | ||
480 | /// <param name="addPacket"></param> | ||
481 | /// <param name="ownerID"></param> | ||
482 | public void AddNewPrim(ObjectAddPacket addPacket, LLUUID ownerID) | ||
483 | { | ||
484 | try | ||
485 | { | ||
486 | // MainConsole.Instance.Notice("World.cs: AddNewPrim() - Creating new prim"); | ||
487 | Primitive prim = new Primitive(m_regionHandle, this, addPacket, ownerID, this._primCount); | ||
488 | |||
489 | this.Entities.Add(prim.uuid, prim); | ||
490 | this._primCount++; | ||
491 | } | ||
492 | catch (Exception e) | ||
493 | { | ||
494 | // MainConsole.Instance.Warn("World.cs: AddNewPrim() - Failed with exception " + e.ToString()); | ||
495 | } | ||
496 | } | ||
497 | |||
498 | #endregion | ||
499 | |||
500 | #region Add/Remove Avatar Methods | ||
501 | |||
502 | /// <summary> | ||
503 | /// | ||
504 | /// </summary> | ||
505 | /// <param name="remoteClient"></param | ||
506 | /// <param name="agentID"></param> | ||
507 | /// <param name="child"></param> | ||
508 | public override void AddNewAvatar(IClientAPI remoteClient, LLUUID agentID, bool child) | ||
509 | { | ||
510 | remoteClient.OnRegionHandShakeReply += new GenericCall(this.SendLayerData); | ||
511 | //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); | ||
512 | remoteClient.OnChatFromViewer += new ChatFromViewer(this.SimChat); | ||
513 | remoteClient.OnRequestWearables += new GenericCall(this.InformClientOfNeighbours); | ||
514 | remoteClient.OnAddPrim += new GenericCall4(this.AddNewPrim); | ||
515 | remoteClient.OnUpdatePrimPosition += new UpdatePrimVector(this.UpdatePrimPosition); | ||
516 | |||
517 | /* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest); | ||
518 | remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest); | ||
519 | remoteClient.OnParcelJoinRequest += new ParcelJoinRequest(parcelManager.handleParcelJoinRequest); | ||
520 | remoteClient.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(parcelManager.handleParcelPropertiesUpdateRequest); | ||
521 | remoteClient.OnEstateOwnerMessage += new EstateOwnerMessageRequest(estateManager.handleEstateOwnerMessage); | ||
522 | */ | ||
523 | |||
524 | Avatar newAvatar = null; | ||
525 | try | ||
526 | { | ||
527 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); | ||
528 | newAvatar = new Avatar(remoteClient, this, m_clientThreads, this.m_regInfo); | ||
529 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Adding new avatar to world"); | ||
530 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Starting RegionHandshake "); | ||
531 | |||
532 | //newAvatar.SendRegionHandshake(); | ||
533 | this.estateManager.sendRegionHandshake(remoteClient); | ||
534 | |||
535 | PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z); | ||
536 | lock (this.m_syncRoot) | ||
537 | { | ||
538 | newAvatar.PhysActor = this.phyScene.AddAvatar(pVec); | ||
539 | } | ||
540 | |||
541 | lock (Entities) | ||
542 | { | ||
543 | if (!Entities.ContainsKey(agentID)) | ||
544 | { | ||
545 | this.Entities.Add(agentID, newAvatar); | ||
546 | } | ||
547 | else | ||
548 | { | ||
549 | Entities[agentID] = newAvatar; | ||
550 | } | ||
551 | } | ||
552 | lock (Avatars) | ||
553 | { | ||
554 | if (Avatars.ContainsKey(agentID)) | ||
555 | { | ||
556 | Avatars[agentID] = newAvatar; | ||
557 | } | ||
558 | else | ||
559 | { | ||
560 | this.Avatars.Add(agentID, newAvatar); | ||
561 | } | ||
562 | } | ||
563 | } | ||
564 | catch (Exception e) | ||
565 | { | ||
566 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: AddViewerAgent() - Failed with exception " + e.ToString()); | ||
567 | } | ||
568 | return; | ||
569 | } | ||
570 | |||
571 | /// <summary> | ||
572 | /// | ||
573 | /// </summary> | ||
574 | protected void InformClientOfNeighbours(IClientAPI remoteClient) | ||
575 | { | ||
576 | // Console.WriteLine("informing client of neighbouring regions"); | ||
577 | List<RegionInfo> neighbours = this.commsManager.GridServer.RequestNeighbours(this.m_regInfo); | ||
578 | |||
579 | //Console.WriteLine("we have " + neighbours.Count + " neighbouring regions"); | ||
580 | if (neighbours != null) | ||
581 | { | ||
582 | for (int i = 0; i < neighbours.Count; i++) | ||
583 | { | ||
584 | // Console.WriteLine("sending neighbours data"); | ||
585 | AgentCircuitData agent = remoteClient.RequestClientInfo(); | ||
586 | agent.BaseFolder = LLUUID.Zero; | ||
587 | agent.InventoryFolder = LLUUID.Zero; | ||
588 | agent.startpos = new LLVector3(128, 128, 70); | ||
589 | this.commsManager.InterSims.InformNeighbourOfChildAgent(neighbours[i].RegionHandle, agent); | ||
590 | remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, System.Net.IPAddress.Parse(neighbours[i].IPListenAddr), (ushort)neighbours[i].IPListenPort); | ||
591 | } | ||
592 | } | ||
593 | } | ||
594 | |||
595 | /// <summary> | ||
596 | /// | ||
597 | /// </summary> | ||
598 | /// <param name="agentID"></param> | ||
599 | public override void RemoveAvatar(LLUUID agentID) | ||
600 | { | ||
601 | return; | ||
602 | } | ||
603 | #endregion | ||
604 | |||
605 | #region Request Avatars List Methods | ||
606 | //The idea is to have a group of method that return a list of avatars meeting some requirement | ||
607 | // ie it could be all Avatars within a certain range of the calling prim/avatar. | ||
608 | |||
609 | /// <summary> | ||
610 | /// Request a List of all Avatars in this World | ||
611 | /// </summary> | ||
612 | /// <returns></returns> | ||
613 | public List<Avatar> RequestAvatarList() | ||
614 | { | ||
615 | List<Avatar> result = new List<Avatar>(); | ||
616 | |||
617 | foreach (Avatar avatar in Avatars.Values) | ||
618 | { | ||
619 | result.Add(avatar); | ||
620 | } | ||
621 | |||
622 | return result; | ||
623 | } | ||
624 | |||
625 | /// <summary> | ||
626 | /// Request a filtered list of Avatars in this World | ||
627 | /// </summary> | ||
628 | /// <returns></returns> | ||
629 | public List<Avatar> RequestAvatarList(FilterAvatarList filter) | ||
630 | { | ||
631 | List<Avatar> result = new List<Avatar>(); | ||
632 | |||
633 | foreach (Avatar avatar in Avatars.Values) | ||
634 | { | ||
635 | if (filter(avatar)) | ||
636 | { | ||
637 | result.Add(avatar); | ||
638 | } | ||
639 | } | ||
640 | |||
641 | return result; | ||
642 | } | ||
643 | |||
644 | /// <summary> | ||
645 | /// Request a Avatar by UUID | ||
646 | /// </summary> | ||
647 | /// <param name="avatarID"></param> | ||
648 | /// <returns></returns> | ||
649 | public Avatar RequestAvatar(LLUUID avatarID) | ||
650 | { | ||
651 | if (this.Avatars.ContainsKey(avatarID)) | ||
652 | { | ||
653 | return Avatars[avatarID]; | ||
654 | } | ||
655 | return null; | ||
656 | } | ||
657 | #endregion | ||
658 | |||
659 | #region ShutDown | ||
660 | /// <summary> | ||
661 | /// Tidy before shutdown | ||
662 | /// </summary> | ||
663 | public override void Close() | ||
664 | { | ||
665 | try | ||
666 | { | ||
667 | this.localStorage.ShutDown(); | ||
668 | } | ||
669 | catch (Exception e) | ||
670 | { | ||
671 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Close() - Failed with exception " + e.ToString()); | ||
672 | } | ||
673 | } | ||
674 | #endregion | ||
675 | |||
676 | #region RegionCommsHost | ||
677 | |||
678 | /// <summary> | ||
679 | /// | ||
680 | /// </summary> | ||
681 | public void RegisterRegionWithComms() | ||
682 | { | ||
683 | this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo); | ||
684 | if (this.regionCommsHost != null) | ||
685 | { | ||
686 | this.regionCommsHost.OnExpectUser += new ExpectUserDelegate(this.NewUserConnection); | ||
687 | } | ||
688 | } | ||
689 | |||
690 | /// <summary> | ||
691 | /// | ||
692 | /// </summary> | ||
693 | /// <param name="regionHandle"></param> | ||
694 | /// <param name="agent"></param> | ||
695 | public void NewUserConnection(ulong regionHandle, AgentCircuitData agent) | ||
696 | { | ||
697 | // Console.WriteLine("World.cs - add new user connection"); | ||
698 | //should just check that its meant for this region | ||
699 | if (regionHandle == this.m_regInfo.RegionHandle) | ||
700 | { | ||
701 | this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent); | ||
702 | } | ||
703 | } | ||
704 | |||
705 | #endregion | ||
706 | |||
707 | /// <summary> | ||
708 | /// | ||
709 | /// </summary> | ||
710 | /// <param name="px"></param> | ||
711 | /// <param name="py"></param> | ||
712 | /// <param name="RemoteClient"></param> | ||
713 | public override void SendLayerData(int px, int py, IClientAPI RemoteClient) | ||
714 | { | ||
715 | RemoteClient.SendLayerData( Terrain.getHeights1D() ); | ||
716 | } | ||
717 | } | ||
718 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/SceneBase.cs b/OpenSim/OpenSim.Region/Scenes/SceneBase.cs new file mode 100644 index 0000000..d9d07b0 --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/SceneBase.cs | |||
@@ -0,0 +1,138 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using libsecondlife; | ||
30 | using libsecondlife.Packets; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Text; | ||
33 | using System.Reflection; | ||
34 | using System.IO; | ||
35 | using System.Threading; | ||
36 | using OpenSim.Physics.Manager; | ||
37 | using OpenSim.Framework.Interfaces; | ||
38 | using OpenSim.Framework.Types; | ||
39 | using OpenSim.Framework.Inventory; | ||
40 | using OpenSim.Region.Scripting; | ||
41 | using OpenSim.Terrain; | ||
42 | |||
43 | namespace OpenSim.Region.Scenes | ||
44 | { | ||
45 | public abstract class SceneBase : IWorld | ||
46 | { | ||
47 | public Dictionary<libsecondlife.LLUUID, Entity> Entities; | ||
48 | protected Dictionary<uint, IClientAPI> m_clientThreads; | ||
49 | protected ulong m_regionHandle; | ||
50 | protected string m_regionName; | ||
51 | protected RegionInfo m_regInfo; | ||
52 | |||
53 | public TerrainEngine Terrain; //TODO: Replace TerrainManager with this. | ||
54 | protected libsecondlife.TerrainManager TerrainManager; // To be referenced via TerrainEngine | ||
55 | protected object m_syncRoot = new object(); | ||
56 | private uint m_nextLocalId = 8880000; | ||
57 | |||
58 | #region Update Methods | ||
59 | /// <summary> | ||
60 | /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation) | ||
61 | /// </summary> | ||
62 | public abstract void Update(); | ||
63 | |||
64 | #endregion | ||
65 | |||
66 | #region Terrain Methods | ||
67 | |||
68 | /// <summary> | ||
69 | /// Loads the World heightmap | ||
70 | /// </summary> | ||
71 | public abstract void LoadWorldMap(); | ||
72 | |||
73 | /// <summary> | ||
74 | /// Send the region heightmap to the client | ||
75 | /// </summary> | ||
76 | /// <param name="RemoteClient">Client to send to</param> | ||
77 | public virtual void SendLayerData(IClientAPI RemoteClient) | ||
78 | { | ||
79 | RemoteClient.SendLayerData(Terrain.getHeights1D()); | ||
80 | } | ||
81 | |||
82 | /// <summary> | ||
83 | /// Sends a specified patch to a client | ||
84 | /// </summary> | ||
85 | /// <param name="px">Patch coordinate (x) 0..16</param> | ||
86 | /// <param name="py">Patch coordinate (y) 0..16</param> | ||
87 | /// <param name="RemoteClient">The client to send to</param> | ||
88 | public abstract void SendLayerData(int px, int py, IClientAPI RemoteClient); | ||
89 | |||
90 | #endregion | ||
91 | |||
92 | #region Add/Remove Agent/Avatar | ||
93 | /// <summary> | ||
94 | /// | ||
95 | /// </summary> | ||
96 | /// <param name="remoteClient"></param> | ||
97 | /// <param name="agentID"></param> | ||
98 | /// <param name="child"></param> | ||
99 | public abstract void AddNewAvatar(IClientAPI remoteClient, LLUUID agentID, bool child); | ||
100 | |||
101 | /// <summary> | ||
102 | /// | ||
103 | /// </summary> | ||
104 | /// <param name="agentID"></param> | ||
105 | public abstract void RemoveAvatar(LLUUID agentID); | ||
106 | |||
107 | #endregion | ||
108 | |||
109 | /// <summary> | ||
110 | /// | ||
111 | /// </summary> | ||
112 | /// <returns></returns> | ||
113 | public virtual RegionInfo RegionInfo | ||
114 | { | ||
115 | get { return null; } | ||
116 | } | ||
117 | |||
118 | public object SyncRoot | ||
119 | { | ||
120 | get { return m_syncRoot; } | ||
121 | } | ||
122 | |||
123 | public uint NextLocalId | ||
124 | { | ||
125 | get { return m_nextLocalId++; } | ||
126 | } | ||
127 | |||
128 | #region Shutdown | ||
129 | /// <summary> | ||
130 | /// Tidy before shutdown | ||
131 | /// </summary> | ||
132 | public abstract void Close(); | ||
133 | |||
134 | #endregion | ||
135 | |||
136 | |||
137 | } | ||
138 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/IScriptContext.cs b/OpenSim/OpenSim.Region/Scenes/scripting/IScriptContext.cs new file mode 100644 index 0000000..daa1b92 --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/scripting/IScriptContext.cs | |||
@@ -0,0 +1,40 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | |||
33 | namespace OpenSim.Region.Scripting | ||
34 | { | ||
35 | public interface IScriptContext | ||
36 | { | ||
37 | IScriptEntity Entity { get; } | ||
38 | bool TryGetRandomAvatar(out IScriptReadonlyEntity avatar); | ||
39 | } | ||
40 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/IScriptEntity.cs b/OpenSim/OpenSim.Region/Scenes/scripting/IScriptEntity.cs new file mode 100644 index 0000000..44b886f --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/scripting/IScriptEntity.cs | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | |||
33 | namespace OpenSim.Region.Scripting | ||
34 | { | ||
35 | public interface IScriptReadonlyEntity | ||
36 | { | ||
37 | LLVector3 Pos { get; } | ||
38 | string Name { get; } | ||
39 | } | ||
40 | |||
41 | public interface IScriptEntity | ||
42 | { | ||
43 | LLVector3 Pos { get; set; } | ||
44 | string Name { get; } | ||
45 | } | ||
46 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/IScriptHandler.cs b/OpenSim/OpenSim.Region/Scenes/scripting/IScriptHandler.cs new file mode 100644 index 0000000..581ad43 --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/scripting/IScriptHandler.cs | |||
@@ -0,0 +1,126 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | using OpenSim.Physics.Manager; | ||
33 | using OpenSim.Region; | ||
34 | using OpenSim.Region.Scenes; | ||
35 | using Avatar=OpenSim.Region.Scenes.Avatar; | ||
36 | using Primitive = OpenSim.Region.Scenes.Primitive; | ||
37 | |||
38 | namespace OpenSim.Region.Scripting | ||
39 | { | ||
40 | public delegate void ScriptEventHandler(IScriptContext context); | ||
41 | |||
42 | public class ScriptHandler : IScriptContext, IScriptEntity, IScriptReadonlyEntity | ||
43 | { | ||
44 | private Scene m_world; | ||
45 | private Script m_script; | ||
46 | private Entity m_entity; | ||
47 | |||
48 | public LLUUID ScriptId | ||
49 | { | ||
50 | get | ||
51 | { | ||
52 | return m_script.ScriptId; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | public void OnFrame() | ||
57 | { | ||
58 | m_script.OnFrame(this); | ||
59 | } | ||
60 | |||
61 | public ScriptHandler(Script script, Entity entity, Scene world) | ||
62 | { | ||
63 | m_script = script; | ||
64 | m_entity = entity; | ||
65 | m_world = world; | ||
66 | } | ||
67 | |||
68 | #region IScriptContext Members | ||
69 | |||
70 | IScriptEntity IScriptContext.Entity | ||
71 | { | ||
72 | get | ||
73 | { | ||
74 | return this; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | bool IScriptContext.TryGetRandomAvatar(out IScriptReadonlyEntity avatar) | ||
79 | { | ||
80 | foreach (Entity entity in m_world.Entities.Values ) | ||
81 | { | ||
82 | if( entity is Avatar ) | ||
83 | { | ||
84 | avatar = entity; | ||
85 | return true; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | avatar = null; | ||
90 | return false; | ||
91 | } | ||
92 | |||
93 | #endregion | ||
94 | |||
95 | #region IScriptEntity and IScriptReadonlyEntity Members | ||
96 | |||
97 | public string Name | ||
98 | { | ||
99 | get | ||
100 | { | ||
101 | return m_entity.Name; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | public LLVector3 Pos | ||
106 | { | ||
107 | get | ||
108 | { | ||
109 | return m_entity.Pos; | ||
110 | } | ||
111 | |||
112 | set | ||
113 | { | ||
114 | if (m_entity is Primitive) | ||
115 | { | ||
116 | Primitive prim = m_entity as Primitive; | ||
117 | // Of course, we really should have asked the physEngine if this is possible, and if not, returned false. | ||
118 | // prim.UpdatePosition( value ); | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | |||
123 | #endregion | ||
124 | } | ||
125 | |||
126 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs b/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs new file mode 100644 index 0000000..1d01f3c --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs | |||
@@ -0,0 +1,53 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | |||
33 | namespace OpenSim.Region.Scripting | ||
34 | { | ||
35 | public class Script | ||
36 | { | ||
37 | private LLUUID m_scriptId; | ||
38 | public virtual LLUUID ScriptId | ||
39 | { | ||
40 | get | ||
41 | { | ||
42 | return m_scriptId; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | public Script( LLUUID scriptId ) | ||
47 | { | ||
48 | m_scriptId = scriptId; | ||
49 | } | ||
50 | |||
51 | public ScriptEventHandler OnFrame; | ||
52 | } | ||
53 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptFactory.cs b/OpenSim/OpenSim.Region/Scenes/scripting/ScriptFactory.cs new file mode 100644 index 0000000..32ef046 --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/scripting/ScriptFactory.cs | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | |||
32 | namespace OpenSim.Region.Scripting | ||
33 | { | ||
34 | public delegate Script ScriptFactory(); | ||
35 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/Scripts/FollowRandomAvatar.cs b/OpenSim/OpenSim.Region/Scenes/scripting/Scripts/FollowRandomAvatar.cs new file mode 100644 index 0000000..21f07a8 --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/scripting/Scripts/FollowRandomAvatar.cs | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | |||
33 | namespace OpenSim.Region.Scripting | ||
34 | { | ||
35 | public class FollowRandomAvatar : Script | ||
36 | { | ||
37 | public FollowRandomAvatar() | ||
38 | : base(LLUUID.Random()) | ||
39 | { | ||
40 | OnFrame += MyOnFrame; | ||
41 | } | ||
42 | |||
43 | private void MyOnFrame(IScriptContext context) | ||
44 | { | ||
45 | LLVector3 pos = context.Entity.Pos; | ||
46 | |||
47 | IScriptReadonlyEntity avatar; | ||
48 | |||
49 | if (context.TryGetRandomAvatar(out avatar)) | ||
50 | { | ||
51 | LLVector3 avatarPos = avatar.Pos; | ||
52 | |||
53 | float x = pos.X + ((float)avatarPos.X.CompareTo(pos.X)) / 2; | ||
54 | float y = pos.Y + ((float)avatarPos.Y.CompareTo(pos.Y)) / 2; | ||
55 | |||
56 | LLVector3 newPos = new LLVector3(x, y, pos.Z); | ||
57 | |||
58 | context.Entity.Pos = newPos; | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | |||
63 | |||
64 | } | ||