Add example code to DOExampleModule to pull data from that previously saved by DAExampleModule when instantiating a dynamc object.

user_profiles
Justin Clark-Casey (justincc) 2013-03-15 00:49:35 +00:00
parent cb74186888
commit d3e76730bd
2 changed files with 29 additions and 5 deletions

View File

@ -39,7 +39,7 @@ using OpenSim.Region.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule
namespace OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DAExampleModule")]
public class DAExampleModule : INonSharedRegionModule
@ -48,6 +48,8 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule
private static readonly bool ENABLED = false; // enable for testing
public const string DANamespace = "DAExample Module";
protected Scene m_scene;
protected IDialogModule m_dialogMod;
@ -89,7 +91,7 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule
if (sop == null)
return true;
if (!sop.DynAttrs.TryGetValue(Name, out attrs))
if (!sop.DynAttrs.TryGetValue(DANamespace, out attrs))
attrs = new OSDMap();
OSDInteger newValue;
@ -104,7 +106,7 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule
attrs["moves"] = newValue;
sop.DynAttrs[Name] = attrs;
sop.DynAttrs[DANamespace] = attrs;
}
sop.ParentGroup.HasGroupChanged = true;

View File

@ -36,6 +36,7 @@ using OpenMetaverse.Packets;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Region.Framework;
using OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
@ -50,9 +51,14 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DOExampleModule
public class MyObject
{
public int Moves { get; set; }
public MyObject(int moves)
{
Moves = moves;
}
}
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly bool ENABLED = false; // enable for testing
@ -92,7 +98,23 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DOExampleModule
private void OnObjectAddedToScene(SceneObjectGroup so)
{
so.RootPart.DynObjs.Add(Name, new MyObject());
SceneObjectPart rootPart = so.RootPart;
OSDMap attrs;
int movesSoFar = 0;
// Console.WriteLine("Here for {0}", so.Name);
if (rootPart.DynAttrs.TryGetValue(DAExampleModule.DANamespace, out attrs))
{
movesSoFar = attrs["moves"].AsInteger();
m_log.DebugFormat(
"[DO EXAMPLE MODULE]: Found saved moves {0} for {1} in {2}", movesSoFar, so.Name, m_scene.Name);
}
rootPart.DynObjs.Add(Name, new MyObject(movesSoFar));
}
private bool OnSceneGroupMove(UUID groupId, Vector3 delta)