/*
* Copyright (c) DeepThink Pty Ltd, http://www.deepthink.com.au
*/
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using libsecondlife;
namespace OpenSim.Region.Environment.Modules
{
public class DTLCreatures : IRegionModule
{
private Scene m_scene;
private LogBase m_log;
public DTLCreatures()
{
}
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
m_log = MainLog.Instance;
}
public void PostInitialise()
{
// Insert some critters into our scene.
m_log.Verbose("DTLCREATURES", "Inserting critters");
m_scene.AddEntity(new DTLCritter(m_scene, m_scene.RegionInfo.RegionHandle, m_scene.RegionInfo.MasterAvatarAssignedUUID, m_scene.PrimIDAllocate(), new LLVector3(128, 128, 128)));
}
public void Close()
{
}
public string Name
{
get { return "DTLCreatures"; }
}
public bool IsSharedModule
{
get { return false; }
}
///
/// DeepThinkLabs Critter
///
/// A very simple automaton which can be inserted into the scene.
///
private class DTLCritter : SceneObjectGroup
{
///
/// A subprimitive on the critter.
///
private class DTLCritterPart : SceneObjectPart
{
public DTLCritterPart(ulong regionHandle, SceneObjectGroup parent, LLUUID ownerID, uint localID,
LLVector3 groupPosition, LLVector3 offsetPosition, LLQuaternion rotationDirection) :
base(regionHandle, parent, ownerID, localID, new BoxShape(0.5f), groupPosition, rotationDirection, offsetPosition)
{
this.SetText("CritterPart", new Axiom.Math.Vector3(1.0f, 0.0f, 0.0f), 1.0);
}
///
/// Used to make sub-parts move around a little
///
public override void UpdateMovement()
{
this.UpdateOffSet(new libsecondlife.LLVector3(0, 0, (float)System.Math.Sin(Util.UnixTimeSinceEpoch() / 15)));
base.UpdateMovement();
}
}
public DTLCritter(Scene scene, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos)
: base(scene, regionHandle, ownerID, localID, pos, new BoxShape(1))
{
AddPart(new DTLCritterPart(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, LLVector3.Zero, LLQuaternion.Identity));
UpdateParentIDs();
}
///
/// Move the critter itself here
///
public override void UpdateMovement()
{
UpdateGroupPosition(new LLVector3(128, 128, 80));
base.UpdateMovement();
}
}
}
}