Revert previous change to temporary prims as it means birds have to repopulate every
3 minutes. Instead hook the OnPrimsLoaded event (after scene object restore) and delete any persisted OpenSimBirdsN prims left over from last shutdown.pull/1/merge
parent
173e046aba
commit
f387b5e0c3
|
@ -92,7 +92,7 @@ namespace Flocking
|
||||||
|
|
||||||
public void AddRegion (Scene scene)
|
public void AddRegion (Scene scene)
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[{0}]: Adding region '{1}' to this module", m_name, scene.RegionInfo.RegionName);
|
m_log.InfoFormat("[{0}]: Adding region {1} to this module", m_name, scene.RegionInfo.RegionName);
|
||||||
IConfig cnf = m_config.Configs[scene.RegionInfo.RegionName];
|
IConfig cnf = m_config.Configs[scene.RegionInfo.RegionName];
|
||||||
|
|
||||||
if (cnf == null)
|
if (cnf == null)
|
||||||
|
@ -130,7 +130,8 @@ namespace Flocking
|
||||||
//register handlers
|
//register handlers
|
||||||
m_scene.EventManager.OnFrame += FlockUpdate;
|
m_scene.EventManager.OnFrame += FlockUpdate;
|
||||||
m_scene.EventManager.OnChatFromClient += SimChatSent; //listen for commands sent from the client
|
m_scene.EventManager.OnChatFromClient += SimChatSent; //listen for commands sent from the client
|
||||||
m_scene.EventManager.OnChatFromWorld += SimChatSent;
|
m_scene.EventManager.OnChatFromWorld += SimChatSent;
|
||||||
|
m_scene.EventManager.OnPrimsLoaded += PrimsLoaded;
|
||||||
|
|
||||||
// init module
|
// init module
|
||||||
m_model = new FlockingModel(m_name, m_maxSpeed, m_maxForce, m_neighbourDistance, m_desiredSeparation, m_tolerance, m_borderSize);
|
m_model = new FlockingModel(m_name, m_maxSpeed, m_maxForce, m_neighbourDistance, m_desiredSeparation, m_tolerance, m_borderSize);
|
||||||
|
@ -150,11 +151,17 @@ namespace Flocking
|
||||||
// Mark Module Ready for duty
|
// Mark Module Ready for duty
|
||||||
m_ready = true;
|
m_ready = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PrimsLoaded(Scene scene)
|
||||||
|
{
|
||||||
|
m_scene = scene;
|
||||||
|
ClearPersisted();
|
||||||
|
}
|
||||||
|
|
||||||
public void RemoveRegion (Scene scene)
|
public void RemoveRegion (Scene scene)
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[{0}]: Removing region '{1}' from this module", m_name, scene.RegionInfo.RegionName);
|
m_log.InfoFormat("[{0}]: Removing region {1} from this module", m_name, scene.RegionInfo.RegionName);
|
||||||
if (m_enabled) {
|
if (m_enabled) {
|
||||||
m_view.Clear();
|
m_view.Clear();
|
||||||
m_ready = false;
|
m_ready = false;
|
||||||
|
@ -193,6 +200,25 @@ namespace Flocking
|
||||||
m_view.PostInitialize(m_owner);
|
m_view.PostInitialize(m_owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ClearPersisted()
|
||||||
|
{
|
||||||
|
//really trash all possible birds that may have been persisted at last shutdown
|
||||||
|
int i;
|
||||||
|
for (i = m_flockSize; i < m_maxFlockSize; i++)
|
||||||
|
{
|
||||||
|
foreach (EntityBase e in m_scene.GetEntities())
|
||||||
|
{
|
||||||
|
if (e.Name == (string)(m_name + i))
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("[{0}]: Removing old persisted prim {1} from region {2}", m_name, m_name + i, m_scene.RegionInfo.RegionName);
|
||||||
|
m_scene.DeleteSceneObject((SceneObjectGroup)e, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_scene.ForceClientUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region EventHandlers
|
#region EventHandlers
|
||||||
|
@ -255,7 +281,7 @@ namespace Flocking
|
||||||
if (args.Trim ().Length > 0) {
|
if (args.Trim ().Length > 0) {
|
||||||
argStr = " <" + args + "> ";
|
argStr = " <" + args + "> ";
|
||||||
}
|
}
|
||||||
m_log.InfoFormat("[{0}]: Adding command {1} - {2} to region '{3}'", m_name, "birds-" + cmd + argStr, help, m_scene.RegionInfo.RegionName);
|
m_log.InfoFormat("[{0}]: Adding console command {1} - {2} to region {3}", m_name, "birds-" + cmd + argStr, help, m_scene.RegionInfo.RegionName);
|
||||||
//m_scene.AddCommand (this, "birds-" + cmd, "birds-" + cmd + argStr, help, fn);
|
//m_scene.AddCommand (this, "birds-" + cmd, "birds-" + cmd + argStr, help, fn);
|
||||||
m_console.Commands.AddCommand(m_name, false, "birds-" + cmd, "birds-" + cmd + argStr, help, fn);
|
m_console.Commands.AddCommand(m_name, false, "birds-" + cmd, "birds-" + cmd + argStr, help, fn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,12 +88,12 @@ namespace Flocking
|
||||||
SceneObjectPart rootPart;
|
SceneObjectPart rootPart;
|
||||||
|
|
||||||
if (existing == null) {
|
if (existing == null) {
|
||||||
m_log.InfoFormat("[{0}]: Adding prim {1} from region {2}", m_name, bird.Id, m_scene.RegionInfo.RegionName);
|
m_log.InfoFormat("[{0}]: Adding prim {1} in region {2}", m_name, bird.Id, m_scene.RegionInfo.RegionName);
|
||||||
SceneObjectGroup group = findByName (m_birdPrim);
|
SceneObjectGroup group = findByName (m_birdPrim);
|
||||||
sog = CopyPrim (group, bird.Id);
|
sog = CopyPrim (group, bird.Id);
|
||||||
rootPart = sog.RootPart;
|
rootPart = sog.RootPart;
|
||||||
//set prim to phantom
|
//set prim to phantom
|
||||||
sog.UpdatePrimFlags(rootPart.LocalId, false, true, true, false);
|
sog.UpdatePrimFlags(rootPart.LocalId, false, false, true, false);
|
||||||
m_sogMap [bird.Id] = sog;
|
m_sogMap [bird.Id] = sog;
|
||||||
m_scene.AddNewSceneObject (sog, false);
|
m_scene.AddNewSceneObject (sog, false);
|
||||||
// Fire script on_rez
|
// Fire script on_rez
|
||||||
|
|
Loading…
Reference in New Issue