Add the IInventoryModule interface and a sample method call

to Scene.INventory.cs
0.6.0-stable
Melanie Thielker 2008-08-17 18:41:13 +00:00
parent 1db8f6fbad
commit 40abeed7d4
3 changed files with 72 additions and 13 deletions

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
using libsecondlife;
namespace OpenSim.Framework
{
/// <summary>
/// An interface for accessing and managing agent inventory
/// </summary>
public interface IInventoryModule
{
// void TestFunction();
}
}

View File

@ -36,7 +36,7 @@ using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
{
public class InventoryModule : IRegionModule
public class InventoryModule : IInventoryModule, IRegionModule
{
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -48,14 +48,20 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
/// </summary>
private IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>();
private Scene m_scene;
private List<Scene> m_Scenelist = new List<Scene>();
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
scene.EventManager.OnNewClient += OnNewClient;
if(!m_Scenelist.Contains(scene))
{
m_Scenelist.Add(scene);
scene.RegisterModuleInterface<IInventoryModule>(this);
scene.EventManager.OnNewClient += OnNewClient;
}
}
public void PostInitialise()
@ -73,7 +79,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
public bool IsSharedModule
{
get { return false; }
get { return true; }
}
#endregion
@ -97,9 +103,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
"[AGENT INVENTORY]: Routing inventory offering message from {0}, {1} to {2}",
client.AgentId, client.Name, toAgentID);
if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
if (((Scene)(client.Scene)).Entities.ContainsKey(toAgentID) && ((Scene)(client.Scene)).Entities[toAgentID] is ScenePresence)
{
ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
ScenePresence user = (ScenePresence) ((Scene)(client.Scene)).Entities[toAgentID];
if (!user.IsChildAgent)
{
@ -143,9 +149,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
"[AGENT INVENTORY]: Routing inventory accepted message from {0}, {1} to {2}",
client.AgentId, client.Name, toAgentID);
if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
if (((Scene)(client.Scene)).Entities.ContainsKey(toAgentID) && ((Scene)(client.Scene)).Entities[toAgentID] is ScenePresence)
{
ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
ScenePresence user = (ScenePresence) ((Scene)(client.Scene)).Entities[toAgentID];
if (!user.IsChildAgent)
{
@ -160,7 +166,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
// Since the message originates from the accepting client, the toAgentID is
// the agent giving the item.
m_scene.GiveInventoryItem(client, toAgentID, m_pendingOffers[imSessionID]);
((Scene)(client.Scene)).GiveInventoryItem(client, toAgentID, m_pendingOffers[imSessionID]);
m_pendingOffers.Remove(imSessionID);
}
@ -189,9 +195,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
}
else if (dialog == (byte) InstantMessageDialog.InventoryDeclined)
{
if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
if (((Scene)(client.Scene)).Entities.ContainsKey(toAgentID) && ((Scene)(client.Scene)).Entities[toAgentID] is ScenePresence)
{
ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
ScenePresence user = (ScenePresence) ((Scene)(client.Scene)).Entities[toAgentID];
if (!user.IsChildAgent)
{
@ -216,5 +222,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
}
}
}
// public void TestFunction()
// {
// }
}
}
}

View File

@ -2308,5 +2308,14 @@ namespace OpenSim.Region.Environment.Scenes
else
EventManager.TriggerStopScript(part.LocalId, itemID);
}
// public void TestFunction()
// {
// IInventoryModule imod = RequestModuleInterface<IInventoryModule>();
// if (imod == null)
// return;
//
// imod.TestFunction();
// }
}
}