Remove whitespace

pull/1/merge
Jak Daniels 2015-02-28 14:27:24 +00:00
parent fc7bb966a3
commit 640d471a50
2 changed files with 201 additions and 201 deletions

View File

@ -63,7 +63,7 @@ namespace Flocking
private int m_frameUpdateRate = 1; private int m_frameUpdateRate = 1;
private int m_chatChannel = 118; private int m_chatChannel = 118;
private string m_birdPrim; private string m_birdPrim;
private int m_flockSize = 50; private int m_flockSize = 50;
private int m_maxFlockSize = 100; private int m_maxFlockSize = 100;
private float m_maxSpeed; private float m_maxSpeed;
private float m_maxForce; private float m_maxForce;
@ -71,7 +71,7 @@ namespace Flocking
private float m_desiredSeparation; private float m_desiredSeparation;
private float m_tolerance; private float m_tolerance;
private float m_borderSize; private float m_borderSize;
private int m_maxHeight; private int m_maxHeight;
private Vector3 m_shoutPos = new Vector3(128f, 128f, 30f); private Vector3 m_shoutPos = new Vector3(128f, 128f, 30f);
static object m_sync = new object(); static object m_sync = new object();
@ -109,7 +109,7 @@ namespace Flocking
{ {
m_chatChannel = cnf.GetInt("BirdsChatChannel", 118); m_chatChannel = cnf.GetInt("BirdsChatChannel", 118);
m_birdPrim = cnf.GetString("BirdsPrim", "birdPrim"); m_birdPrim = cnf.GetString("BirdsPrim", "birdPrim");
m_flockSize = cnf.GetInt("BirdsFlockSize", 50); m_flockSize = cnf.GetInt("BirdsFlockSize", 50);
m_maxFlockSize = cnf.GetInt("BirdsMaxFlockSize", 100); m_maxFlockSize = cnf.GetInt("BirdsMaxFlockSize", 100);
m_maxSpeed = cnf.GetFloat("BirdsMaxSpeed", 3f); m_maxSpeed = cnf.GetFloat("BirdsMaxSpeed", 3f);
m_maxForce = cnf.GetFloat("BirdsMaxForce", 0.25f); m_maxForce = cnf.GetFloat("BirdsMaxForce", 0.25f);
@ -130,16 +130,16 @@ 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; 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);
m_view = new FlockingView(m_name, m_scene); m_view = new FlockingView(m_name, m_scene);
m_view.BirdPrim = m_birdPrim; m_view.BirdPrim = m_birdPrim;
m_frame = 0; m_frame = 0;
m_shoutPos = new Vector3(scene.RegionInfo.RegionSizeX / 2f, scene.RegionInfo.RegionSizeY / 2f, 30f); m_shoutPos = new Vector3(scene.RegionInfo.RegionSizeX / 2f, scene.RegionInfo.RegionSizeY / 2f, 30f);
FlockInitialise(); FlockInitialise();
@ -147,28 +147,28 @@ namespace Flocking
} }
public void RegionLoaded (Scene scene) public void RegionLoaded (Scene scene)
{ {
if (m_enabled) if (m_enabled)
{ {
// Mark Module Ready for duty // Mark Module Ready for duty
m_ready = true; m_ready = true;
} }
} }
public void PrimsLoaded(Scene scene) public void PrimsLoaded(Scene scene)
{ {
m_scene = scene; m_scene = scene;
ClearPersisted(); 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;
scene.EventManager.OnFrame -= FlockUpdate; scene.EventManager.OnFrame -= FlockUpdate;
scene.EventManager.OnChatFromClient -= SimChatSent; scene.EventManager.OnChatFromClient -= SimChatSent;
scene.EventManager.OnChatFromWorld -= SimChatSent; scene.EventManager.OnChatFromWorld -= SimChatSent;
} }
} }
@ -179,7 +179,7 @@ namespace Flocking
{ {
m_ready = false; m_ready = false;
m_scene.EventManager.OnFrame -= FlockUpdate; m_scene.EventManager.OnFrame -= FlockUpdate;
m_scene.EventManager.OnChatFromClient -= SimChatSent; m_scene.EventManager.OnChatFromClient -= SimChatSent;
m_scene.EventManager.OnChatFromWorld -= SimChatSent; m_scene.EventManager.OnChatFromWorld -= SimChatSent;
} }
} }
@ -200,25 +200,25 @@ namespace Flocking
// who is the owner for the flock in this region // who is the owner for the flock in this region
m_owner = m_scene.RegionInfo.EstateSettings.EstateOwner; m_owner = m_scene.RegionInfo.EstateSettings.EstateOwner;
m_view.PostInitialize(m_owner); m_view.PostInitialize(m_owner);
} }
public void ClearPersisted() public void ClearPersisted()
{ {
//really trash all possible birds that may have been persisted at last shutdown //really trash all possible birds that may have been persisted at last shutdown
int i; int i;
for (i = m_flockSize; i < m_maxFlockSize; i++) for (i = m_flockSize; i < m_maxFlockSize; i++)
{ {
foreach (EntityBase e in m_scene.GetEntities()) foreach (EntityBase e in m_scene.GetEntities())
{ {
if (e.Name == (string)(m_name + i)) 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_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); m_scene.DeleteSceneObject((SceneObjectGroup)e, false);
break; break;
} }
} }
} }
m_scene.ForceClientUpdate(); m_scene.ForceClientUpdate();
} }
#endregion #endregion
@ -256,26 +256,26 @@ namespace Flocking
if (cmd.StartsWith ("stop")) { if (cmd.StartsWith ("stop")) {
HandleStopCmd (m_name, args); HandleStopCmd (m_name, args);
} else if (cmd.StartsWith ("start")) { } else if (cmd.StartsWith ("start")) {
HandleStartCmd (m_name, args); HandleStartCmd (m_name, args);
} else if (cmd.StartsWith("enable")) { } else if (cmd.StartsWith("enable")) {
HandleEnableCmd(m_name, args); HandleEnableCmd(m_name, args);
} else if (cmd.StartsWith("disable")) { } else if (cmd.StartsWith("disable")) {
HandleDisableCmd(m_name, args); HandleDisableCmd(m_name, args);
} else if (cmd.StartsWith ("size")) { } else if (cmd.StartsWith ("size")) {
HandleSetSizeCmd (m_name, args); HandleSetSizeCmd (m_name, args);
} else if (cmd.StartsWith ("stats")) { } else if (cmd.StartsWith ("stats")) {
HandleShowStatsCmd (m_name, args); HandleShowStatsCmd (m_name, args);
} else if (cmd.StartsWith ("prim")) { } else if (cmd.StartsWith ("prim")) {
HandleSetPrimCmd (m_name, args); HandleSetPrimCmd (m_name, args);
} else if (cmd.StartsWith("speed")) { } else if (cmd.StartsWith("speed")) {
HandleSetMaxSpeedCmd(m_name, args); HandleSetMaxSpeedCmd(m_name, args);
} else if (cmd.StartsWith("force")) { } else if (cmd.StartsWith("force")) {
HandleSetMaxForceCmd(m_name, args); HandleSetMaxForceCmd(m_name, args);
} else if (cmd.StartsWith("distance")) { } else if (cmd.StartsWith("distance")) {
HandleSetNeighbourDistanceCmd(m_name, args); HandleSetNeighbourDistanceCmd(m_name, args);
} else if (cmd.StartsWith("separation")) { } else if (cmd.StartsWith("separation")) {
HandleSetDesiredSeparationCmd(m_name, args); HandleSetDesiredSeparationCmd(m_name, args);
} else if (cmd.StartsWith("tolerance")) { } else if (cmd.StartsWith("tolerance")) {
HandleSetToleranceCmd(m_name, args); HandleSetToleranceCmd(m_name, args);
} else if (cmd.StartsWith ("framerate")) { } else if (cmd.StartsWith ("framerate")) {
HandleSetFrameRateCmd (m_name, args); HandleSetFrameRateCmd (m_name, args);
@ -306,11 +306,11 @@ namespace Flocking
AddCommand ("disable", "", "Disable Birds Flocking", HandleDisableCmd); AddCommand ("disable", "", "Disable Birds Flocking", HandleDisableCmd);
AddCommand ("size", "num", "Adjust the size of the flock ", HandleSetSizeCmd); AddCommand ("size", "num", "Adjust the size of the flock ", HandleSetSizeCmd);
AddCommand ("prim", "name", "Set the prim used for each bird to that passed in", HandleSetPrimCmd); AddCommand ("prim", "name", "Set the prim used for each bird to that passed in", HandleSetPrimCmd);
AddCommand ("speed", "num", "Set the maximum velocity each bird may achieve", HandleSetMaxSpeedCmd); AddCommand ("speed", "num", "Set the maximum velocity each bird may achieve", HandleSetMaxSpeedCmd);
AddCommand("force", "num", "Set the maximum force each bird may accelerate", HandleSetMaxForceCmd); AddCommand("force", "num", "Set the maximum force each bird may accelerate", HandleSetMaxForceCmd);
AddCommand("distance", "num", "Set the maximum distance that other birds are to be considered in the same flock as us", HandleSetNeighbourDistanceCmd); AddCommand("distance", "num", "Set the maximum distance that other birds are to be considered in the same flock as us", HandleSetNeighbourDistanceCmd);
AddCommand("separation", "num", "How far away from other birds we would like to stay", HandleSetDesiredSeparationCmd); AddCommand("separation", "num", "How far away from other birds we would like to stay", HandleSetDesiredSeparationCmd);
AddCommand("tolerance", "num", "How close to the edges of things can we get without being worried", HandleSetToleranceCmd); AddCommand("tolerance", "num", "How close to the edges of things can we get without being worried", HandleSetToleranceCmd);
AddCommand("stats", "", "Show birds stats", HandleShowStatsCmd); AddCommand("stats", "", "Show birds stats", HandleShowStatsCmd);
AddCommand("framerate", "num", "[debugging] only update birds every <num> frames", HandleSetFrameRateCmd); AddCommand("framerate", "num", "[debugging] only update birds every <num> frames", HandleSetFrameRateCmd);
} }
@ -325,10 +325,10 @@ namespace Flocking
private bool IsInWorldCmd (ref string [] args) private bool IsInWorldCmd (ref string [] args)
{ {
if (args.Length > 0 && args [args.Length - 1].Equals ("<ui>")) { if (args.Length > 0 && args [args.Length - 1].Equals ("<ui>")) {
m_log.InfoFormat("[{0}]: Inworld command detected in region {1}", m_name, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Inworld command detected in region {1}", m_name, m_scene.RegionInfo.RegionName);
return true; return true;
} }
return false; return false;
} }
@ -338,21 +338,21 @@ namespace Flocking
//IClientAPI ownerAPI = null; //IClientAPI ownerAPI = null;
//if (m_scene.TryGetClient (m_owner, out ownerAPI)) { //if (m_scene.TryGetClient (m_owner, out ownerAPI)) {
// ownerAPI.SendBlueBoxMessage (m_owner, "Birds", response); // ownerAPI.SendBlueBoxMessage (m_owner, "Birds", response);
//} //}
SendSimChat(response, m_chatChannel); SendSimChat(response, m_chatChannel);
} else { } else {
MainConsole.Instance.Output (response); MainConsole.Instance.Output (response);
} }
} }
private void SendSimChat(string msg, int channel) private void SendSimChat(string msg, int channel)
{ {
m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Region, channel, m_shoutPos, m_name, UUID.Zero, false); m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Region, channel, m_shoutPos, m_name, UUID.Zero, false);
} }
public void HandleDisableCmd(string module, string[] args) public void HandleDisableCmd(string module, string[] args)
{ {
if (m_ready && ShouldHandleCmd ()) { if (m_ready && ShouldHandleCmd ()) {
m_log.InfoFormat("[{0}]: Bird flocking is disabled in region {1}.", m_name, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Bird flocking is disabled in region {1}.", m_name, m_scene.RegionInfo.RegionName);
m_enabled = false; m_enabled = false;
m_ready = false; m_ready = false;
@ -363,7 +363,7 @@ namespace Flocking
public void HandleEnableCmd(string module, string[] args) public void HandleEnableCmd(string module, string[] args)
{ {
if (!m_ready && ShouldHandleCmd()) if (!m_ready && ShouldHandleCmd())
{ {
m_log.InfoFormat("[{0}]: Bird flocking is enabled in region {1}.", m_name, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Bird flocking is enabled in region {1}.", m_name, m_scene.RegionInfo.RegionName);
m_enabled = true; m_enabled = true;
m_ready = true; m_ready = true;
@ -373,7 +373,7 @@ namespace Flocking
public void HandleStopCmd (string module, string[] args) public void HandleStopCmd (string module, string[] args)
{ {
if (m_enabled && m_ready && ShouldHandleCmd()) if (m_enabled && m_ready && ShouldHandleCmd())
{ {
m_log.InfoFormat("[{0}]: Bird flocking is stopped in region {1}.", m_name, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Bird flocking is stopped in region {1}.", m_name, m_scene.RegionInfo.RegionName);
m_enabled = false; m_enabled = false;
} }
@ -382,7 +382,7 @@ namespace Flocking
public void HandleStartCmd(string module, string[] args) public void HandleStartCmd(string module, string[] args)
{ {
if (!m_enabled && m_ready && ShouldHandleCmd()) if (!m_enabled && m_ready && ShouldHandleCmd())
{ {
m_log.InfoFormat("[{0}]: Bird flocking is started in region {1}.", m_name, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Bird flocking is started in region {1}.", m_name, m_scene.RegionInfo.RegionName);
m_enabled = true; m_enabled = true;
FlockUpdate(); FlockUpdate();
@ -393,7 +393,7 @@ namespace Flocking
{ {
if (ShouldHandleCmd ()) { if (ShouldHandleCmd ()) {
int frameRate = Convert.ToInt32( args[1] ); int frameRate = Convert.ToInt32( args[1] );
m_frameUpdateRate = frameRate; m_frameUpdateRate = frameRate;
m_log.InfoFormat("[{0}]: Bird updates set to every {1} frames in region {2}.", m_name, frameRate, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Bird updates set to every {1} frames in region {2}.", m_name, frameRate, m_scene.RegionInfo.RegionName);
} }
} }
@ -402,10 +402,10 @@ namespace Flocking
{ {
if (ShouldHandleCmd ()) { if (ShouldHandleCmd ()) {
lock( m_sync ) { lock( m_sync ) {
int newSize = Convert.ToInt32(args[1]); int newSize = Convert.ToInt32(args[1]);
if (newSize > m_maxFlockSize) newSize = m_maxFlockSize; if (newSize > m_maxFlockSize) newSize = m_maxFlockSize;
m_view.Clear(); m_view.Clear();
m_model.Size = newSize; m_model.Size = newSize;
m_log.InfoFormat("[{0}]: Bird flock size is set to {1} in region {2}.", m_name, newSize, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Bird flock size is set to {1} in region {2}.", m_name, newSize, m_scene.RegionInfo.RegionName);
} }
@ -415,53 +415,53 @@ namespace Flocking
public void HandleShowStatsCmd (string module, string[] args) public void HandleShowStatsCmd (string module, string[] args)
{ {
if (ShouldHandleCmd ()) { if (ShouldHandleCmd ()) {
bool inWorld = IsInWorldCmd (ref args); bool inWorld = IsInWorldCmd (ref args);
int i; int i;
int s=m_model.Size; int s=m_model.Size;
UUID primUuid; UUID primUuid;
List<ScenePresence> avatarsSitList = new List<ScenePresence>(); List<ScenePresence> avatarsSitList = new List<ScenePresence>();
string avUuids; string avUuids;
if (inWorld) if (inWorld)
{ {
m_log.InfoFormat("[{0}]: Sending bird statistics to region {1}.", m_name, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Sending bird statistics to region {1}.", m_name, m_scene.RegionInfo.RegionName);
} }
ShowResponse("birds-started = " + (m_enabled ? "True" : "False"), inWorld); ShowResponse("birds-started = " + (m_enabled ? "True" : "False"), inWorld);
ShowResponse("birds-enabled = " + (m_ready ? "True" : "False"), inWorld); ShowResponse("birds-enabled = " + (m_ready ? "True" : "False"), inWorld);
ShowResponse("birds-prim = " + m_view.BirdPrim, inWorld); ShowResponse("birds-prim = " + m_view.BirdPrim, inWorld);
ShowResponse("birds-framerate = " + m_frameUpdateRate, inWorld); ShowResponse("birds-framerate = " + m_frameUpdateRate, inWorld);
ShowResponse("birds-maxsize = " + m_maxFlockSize, inWorld); ShowResponse("birds-maxsize = " + m_maxFlockSize, inWorld);
ShowResponse("birds-size = " + s, inWorld); ShowResponse("birds-size = " + s, inWorld);
ShowResponse("birds-speed = " + m_model.MaxSpeed, inWorld); ShowResponse("birds-speed = " + m_model.MaxSpeed, inWorld);
ShowResponse("birds-force = " + m_model.MaxForce, inWorld); ShowResponse("birds-force = " + m_model.MaxForce, inWorld);
ShowResponse("birds-distance = " + m_model.NeighbourDistance, inWorld); ShowResponse("birds-distance = " + m_model.NeighbourDistance, inWorld);
ShowResponse("birds-separation = " + m_model.DesiredSeparation, inWorld); ShowResponse("birds-separation = " + m_model.DesiredSeparation, inWorld);
ShowResponse("birds-tolerance = " + m_model.Tolerance, inWorld); ShowResponse("birds-tolerance = " + m_model.Tolerance, inWorld);
ShowResponse("birds-border = " + m_borderSize, inWorld); ShowResponse("birds-border = " + m_borderSize, inWorld);
for (i = 0; i < s; i++) for (i = 0; i < s; i++)
{ {
primUuid = UUID.Zero; primUuid = UUID.Zero;
avatarsSitList.Clear(); avatarsSitList.Clear();
avUuids = ""; avUuids = "";
foreach (EntityBase e in m_scene.GetEntities()) foreach (EntityBase e in m_scene.GetEntities())
{ {
if (e.Name == m_name + i) if (e.Name == m_name + i)
{ {
SceneObjectGroup sog = (SceneObjectGroup)e; SceneObjectGroup sog = (SceneObjectGroup)e;
SceneObjectPart rootPart = sog.RootPart; SceneObjectPart rootPart = sog.RootPart;
primUuid = rootPart.UUID; primUuid = rootPart.UUID;
avatarsSitList = sog.GetSittingAvatars(); avatarsSitList = sog.GetSittingAvatars();
foreach (ScenePresence av in avatarsSitList) foreach (ScenePresence av in avatarsSitList)
{ {
avUuids += av.UUID.ToString() + " "; avUuids += av.UUID.ToString() + " ";
} }
break; break;
} }
} }
ShowResponse("birds-prim" + i + " = " + m_name + i + " : " + primUuid.ToString() + " : " + avUuids.Trim(), inWorld); ShowResponse("birds-prim" + i + " = " + m_name + i + " : " + primUuid.ToString() + " : " + avUuids.Trim(), inWorld);
} }
} }
} }
@ -471,76 +471,76 @@ namespace Flocking
if (ShouldHandleCmd ()) { if (ShouldHandleCmd ()) {
string primName = args[1]; string primName = args[1];
lock(m_sync) { lock(m_sync) {
m_view.BirdPrim = primName; m_view.BirdPrim = primName;
m_log.InfoFormat("[{0}]: Bird prim is set to {1} in region {2}.", m_name, primName, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Bird prim is set to {1} in region {2}.", m_name, primName, m_scene.RegionInfo.RegionName);
m_view.Clear(); m_view.Clear();
} }
} }
} }
public void HandleSetMaxSpeedCmd(string module, string[] args) public void HandleSetMaxSpeedCmd(string module, string[] args)
{ {
if (ShouldHandleCmd()) if (ShouldHandleCmd())
{ {
float maxSpeed = (float)Convert.ToDecimal(args[1]); float maxSpeed = (float)Convert.ToDecimal(args[1]);
lock (m_sync) lock (m_sync)
{ {
m_model.MaxSpeed = maxSpeed; m_model.MaxSpeed = maxSpeed;
m_log.InfoFormat("[{0}]: Birds maximum speed is set to {1} in region {2}.", m_name, maxSpeed, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Birds maximum speed is set to {1} in region {2}.", m_name, maxSpeed, m_scene.RegionInfo.RegionName);
} }
} }
} }
public void HandleSetMaxForceCmd(string module, string[] args) public void HandleSetMaxForceCmd(string module, string[] args)
{ {
if (ShouldHandleCmd()) if (ShouldHandleCmd())
{ {
float maxForce = (float)Convert.ToDecimal(args[1]); float maxForce = (float)Convert.ToDecimal(args[1]);
lock (m_sync) lock (m_sync)
{ {
m_model.MaxForce = maxForce; m_model.MaxForce = maxForce;
m_log.InfoFormat("[{0}]: Birds maximum force is set to {1} in region {2}.", m_name, maxForce, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Birds maximum force is set to {1} in region {2}.", m_name, maxForce, m_scene.RegionInfo.RegionName);
} }
} }
} }
public void HandleSetNeighbourDistanceCmd(string module, string[] args) public void HandleSetNeighbourDistanceCmd(string module, string[] args)
{ {
if (ShouldHandleCmd()) if (ShouldHandleCmd())
{ {
float neighbourDistance = (float)Convert.ToDecimal(args[1]); float neighbourDistance = (float)Convert.ToDecimal(args[1]);
lock (m_sync) lock (m_sync)
{ {
m_model.NeighbourDistance = neighbourDistance; m_model.NeighbourDistance = neighbourDistance;
m_log.InfoFormat("[{0}]: Birds neighbour distance is set to {1} in region {2}.", m_name, neighbourDistance, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Birds neighbour distance is set to {1} in region {2}.", m_name, neighbourDistance, m_scene.RegionInfo.RegionName);
} }
} }
} }
public void HandleSetDesiredSeparationCmd(string module, string[] args) public void HandleSetDesiredSeparationCmd(string module, string[] args)
{ {
if (ShouldHandleCmd()) if (ShouldHandleCmd())
{ {
float desiredSeparation = (float)Convert.ToDecimal(args[1]); float desiredSeparation = (float)Convert.ToDecimal(args[1]);
lock (m_sync) lock (m_sync)
{ {
m_model.DesiredSeparation = desiredSeparation; m_model.DesiredSeparation = desiredSeparation;
m_log.InfoFormat("[{0}]: Birds desired separation is set to {1} in region {2}.", m_name, desiredSeparation, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Birds desired separation is set to {1} in region {2}.", m_name, desiredSeparation, m_scene.RegionInfo.RegionName);
} }
} }
} }
public void HandleSetToleranceCmd(string module, string[] args) public void HandleSetToleranceCmd(string module, string[] args)
{ {
if (ShouldHandleCmd()) if (ShouldHandleCmd())
{ {
float tolerance = (float)Convert.ToDecimal(args[1]); float tolerance = (float)Convert.ToDecimal(args[1]);
lock (m_sync) lock (m_sync)
{ {
m_model.Tolerance = tolerance; m_model.Tolerance = tolerance;
m_log.InfoFormat("[{0}]: Birds tolerance is set to {1} in region {2}.", m_name, tolerance, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Birds tolerance is set to {1} in region {2}.", m_name, tolerance, m_scene.RegionInfo.RegionName);
} }
} }
} }
#endregion #endregion

View File

@ -55,7 +55,7 @@ namespace Flocking
m_owner = owner; m_owner = owner;
} }
public String BirdPrim { public String BirdPrim {
get { return m_birdPrim; } get { return m_birdPrim; }
set{ m_birdPrim = value;} set{ m_birdPrim = value;}
} }
@ -65,14 +65,14 @@ namespace Flocking
//trash everything we have //trash everything we have
foreach (string name in m_sogMap.Keys) foreach (string name in m_sogMap.Keys)
{ {
m_log.InfoFormat("[{0}]: Removing prim {1} from region {2}", m_name, name, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Removing prim {1} from region {2}", m_name, name, m_scene.RegionInfo.RegionName);
SceneObjectGroup sog = m_sogMap[name]; SceneObjectGroup sog = m_sogMap[name];
m_scene.DeleteSceneObject(sog, false); m_scene.DeleteSceneObject(sog, false);
} }
m_sogMap.Clear(); m_sogMap.Clear();
m_scene.ForceClientUpdate(); m_scene.ForceClientUpdate();
} }
public void Render(List<Bird> birds) public void Render(List<Bird> birds)
{ {
foreach (Bird bird in birds) { foreach (Bird bird in birds) {
@ -88,7 +88,7 @@ namespace Flocking
SceneObjectGroup sog; SceneObjectGroup sog;
SceneObjectPart rootPart; SceneObjectPart rootPart;
if (existing == null) { if (existing == null) {
m_log.InfoFormat("[{0}]: Adding prim {1} in 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);
@ -96,14 +96,14 @@ namespace Flocking
//set prim to phantom //set prim to phantom
sog.UpdatePrimFlags(rootPart.LocalId, false, false, 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
sog.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 1); sog.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 1);
rootPart.ParentGroup.ResumeScripts(); rootPart.ParentGroup.ResumeScripts();
rootPart.ScheduleFullUpdate(); rootPart.ScheduleFullUpdate();
} else { } else {
sog = existing.ParentGroup; sog = existing.ParentGroup;
m_sogMap[bird.Id] = sog; m_sogMap[bird.Id] = sog;
//rootPart = sog.RootPart; //rootPart = sog.RootPart;
//set prim to phantom //set prim to phantom
//sog.UpdatePrimFlags(rootPart.LocalId, false, false, true, false); //sog.UpdatePrimFlags(rootPart.LocalId, false, false, true, false);