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_chatChannel = 118;
private string m_birdPrim;
private int m_flockSize = 50;
private int m_flockSize = 50;
private int m_maxFlockSize = 100;
private float m_maxSpeed;
private float m_maxForce;
@ -71,7 +71,7 @@ namespace Flocking
private float m_desiredSeparation;
private float m_tolerance;
private float m_borderSize;
private int m_maxHeight;
private int m_maxHeight;
private Vector3 m_shoutPos = new Vector3(128f, 128f, 30f);
static object m_sync = new object();
@ -109,7 +109,7 @@ namespace Flocking
{
m_chatChannel = cnf.GetInt("BirdsChatChannel", 118);
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_maxSpeed = cnf.GetFloat("BirdsMaxSpeed", 3f);
m_maxForce = cnf.GetFloat("BirdsMaxForce", 0.25f);
@ -130,16 +130,16 @@ namespace Flocking
//register handlers
m_scene.EventManager.OnFrame += FlockUpdate;
m_scene.EventManager.OnChatFromClient += SimChatSent; //listen for commands sent from the client
m_scene.EventManager.OnChatFromWorld += SimChatSent;
m_scene.EventManager.OnChatFromClient += SimChatSent; //listen for commands sent from the client
m_scene.EventManager.OnChatFromWorld += SimChatSent;
m_scene.EventManager.OnPrimsLoaded += PrimsLoaded;
// init module
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.BirdPrim = m_birdPrim;
m_frame = 0;
m_shoutPos = new Vector3(scene.RegionInfo.RegionSizeX / 2f, scene.RegionInfo.RegionSizeY / 2f, 30f);
m_frame = 0;
m_shoutPos = new Vector3(scene.RegionInfo.RegionSizeX / 2f, scene.RegionInfo.RegionSizeY / 2f, 30f);
FlockInitialise();
@ -147,28 +147,28 @@ namespace Flocking
}
public void RegionLoaded (Scene scene)
{
if (m_enabled)
{
{
if (m_enabled)
{
// Mark Module Ready for duty
m_ready = true;
}
}
public void PrimsLoaded(Scene scene)
{
m_scene = scene;
ClearPersisted();
}
public void PrimsLoaded(Scene scene)
{
m_scene = scene;
ClearPersisted();
}
public void RemoveRegion (Scene scene)
{
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_ready = false;
scene.EventManager.OnFrame -= FlockUpdate;
scene.EventManager.OnChatFromClient -= SimChatSent;
scene.EventManager.OnChatFromClient -= SimChatSent;
scene.EventManager.OnChatFromWorld -= SimChatSent;
}
}
@ -179,7 +179,7 @@ namespace Flocking
{
m_ready = false;
m_scene.EventManager.OnFrame -= FlockUpdate;
m_scene.EventManager.OnChatFromClient -= SimChatSent;
m_scene.EventManager.OnChatFromClient -= SimChatSent;
m_scene.EventManager.OnChatFromWorld -= SimChatSent;
}
}
@ -200,25 +200,25 @@ namespace Flocking
// who is the owner for the flock in this region
m_owner = m_scene.RegionInfo.EstateSettings.EstateOwner;
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();
}
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
@ -256,26 +256,26 @@ namespace Flocking
if (cmd.StartsWith ("stop")) {
HandleStopCmd (m_name, args);
} else if (cmd.StartsWith ("start")) {
HandleStartCmd (m_name, args);
} else if (cmd.StartsWith("enable")) {
HandleEnableCmd(m_name, args);
} else if (cmd.StartsWith("disable")) {
HandleStartCmd (m_name, args);
} else if (cmd.StartsWith("enable")) {
HandleEnableCmd(m_name, args);
} else if (cmd.StartsWith("disable")) {
HandleDisableCmd(m_name, args);
} else if (cmd.StartsWith ("size")) {
HandleSetSizeCmd (m_name, args);
} else if (cmd.StartsWith ("stats")) {
HandleShowStatsCmd (m_name, args);
} else if (cmd.StartsWith ("prim")) {
HandleSetPrimCmd (m_name, args);
} else if (cmd.StartsWith("speed")) {
HandleSetMaxSpeedCmd(m_name, args);
} else if (cmd.StartsWith("force")) {
HandleSetMaxForceCmd(m_name, args);
} else if (cmd.StartsWith("distance")) {
HandleSetNeighbourDistanceCmd(m_name, args);
} else if (cmd.StartsWith("separation")) {
HandleSetDesiredSeparationCmd(m_name, args);
} else if (cmd.StartsWith("tolerance")) {
HandleSetPrimCmd (m_name, args);
} else if (cmd.StartsWith("speed")) {
HandleSetMaxSpeedCmd(m_name, args);
} else if (cmd.StartsWith("force")) {
HandleSetMaxForceCmd(m_name, args);
} else if (cmd.StartsWith("distance")) {
HandleSetNeighbourDistanceCmd(m_name, args);
} else if (cmd.StartsWith("separation")) {
HandleSetDesiredSeparationCmd(m_name, args);
} else if (cmd.StartsWith("tolerance")) {
HandleSetToleranceCmd(m_name, args);
} else if (cmd.StartsWith ("framerate")) {
HandleSetFrameRateCmd (m_name, args);
@ -306,11 +306,11 @@ namespace Flocking
AddCommand ("disable", "", "Disable Birds Flocking", HandleDisableCmd);
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 ("speed", "num", "Set the maximum velocity each bird may achieve", HandleSetMaxSpeedCmd);
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("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 ("speed", "num", "Set the maximum velocity each bird may achieve", HandleSetMaxSpeedCmd);
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("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("stats", "", "Show birds stats", HandleShowStatsCmd);
AddCommand("framerate", "num", "[debugging] only update birds every <num> frames", HandleSetFrameRateCmd);
}
@ -325,10 +325,10 @@ namespace Flocking
private bool IsInWorldCmd (ref string [] args)
{
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);
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);
return true;
}
}
return false;
}
@ -338,21 +338,21 @@ namespace Flocking
//IClientAPI ownerAPI = null;
//if (m_scene.TryGetClient (m_owner, out ownerAPI)) {
// ownerAPI.SendBlueBoxMessage (m_owner, "Birds", response);
//}
//}
SendSimChat(response, m_chatChannel);
} else {
MainConsole.Instance.Output (response);
}
}
private void SendSimChat(string msg, int channel)
{
m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Region, channel, m_shoutPos, m_name, UUID.Zero, false);
}
private void SendSimChat(string msg, int channel)
{
m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Region, channel, m_shoutPos, m_name, UUID.Zero, false);
}
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_enabled = false;
m_ready = false;
@ -363,7 +363,7 @@ namespace Flocking
public void HandleEnableCmd(string module, string[] args)
{
if (!m_ready && ShouldHandleCmd())
{
{
m_log.InfoFormat("[{0}]: Bird flocking is enabled in region {1}.", m_name, m_scene.RegionInfo.RegionName);
m_enabled = true;
m_ready = true;
@ -373,7 +373,7 @@ namespace Flocking
public void HandleStopCmd (string module, string[] args)
{
if (m_enabled && m_ready && ShouldHandleCmd())
{
{
m_log.InfoFormat("[{0}]: Bird flocking is stopped in region {1}.", m_name, m_scene.RegionInfo.RegionName);
m_enabled = false;
}
@ -382,7 +382,7 @@ namespace Flocking
public void HandleStartCmd(string module, string[] args)
{
if (!m_enabled && m_ready && ShouldHandleCmd())
{
{
m_log.InfoFormat("[{0}]: Bird flocking is started in region {1}.", m_name, m_scene.RegionInfo.RegionName);
m_enabled = true;
FlockUpdate();
@ -393,7 +393,7 @@ namespace Flocking
{
if (ShouldHandleCmd ()) {
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);
}
}
@ -402,10 +402,10 @@ namespace Flocking
{
if (ShouldHandleCmd ()) {
lock( m_sync ) {
int newSize = Convert.ToInt32(args[1]);
if (newSize > m_maxFlockSize) newSize = m_maxFlockSize;
m_view.Clear();
m_model.Size = newSize;
int newSize = Convert.ToInt32(args[1]);
if (newSize > m_maxFlockSize) newSize = m_maxFlockSize;
m_view.Clear();
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);
}
@ -415,53 +415,53 @@ namespace Flocking
public void HandleShowStatsCmd (string module, string[] args)
{
if (ShouldHandleCmd ()) {
bool inWorld = IsInWorldCmd (ref args);
int i;
int s=m_model.Size;
UUID primUuid;
List<ScenePresence> avatarsSitList = new List<ScenePresence>();
string avUuids;
if (inWorld)
{
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-enabled = " + (m_ready ? "True" : "False"), inWorld);
ShowResponse("birds-prim = " + m_view.BirdPrim, inWorld);
ShowResponse("birds-framerate = " + m_frameUpdateRate, inWorld);
ShowResponse("birds-maxsize = " + m_maxFlockSize, inWorld);
ShowResponse("birds-size = " + s, inWorld);
ShowResponse("birds-speed = " + m_model.MaxSpeed, inWorld);
ShowResponse("birds-force = " + m_model.MaxForce, inWorld);
ShowResponse("birds-distance = " + m_model.NeighbourDistance, inWorld);
ShowResponse("birds-separation = " + m_model.DesiredSeparation, inWorld);
ShowResponse("birds-tolerance = " + m_model.Tolerance, inWorld);
ShowResponse("birds-border = " + m_borderSize, inWorld);
for (i = 0; i < s; i++)
{
primUuid = UUID.Zero;
avatarsSitList.Clear();
avUuids = "";
foreach (EntityBase e in m_scene.GetEntities())
{
if (e.Name == m_name + i)
{
SceneObjectGroup sog = (SceneObjectGroup)e;
SceneObjectPart rootPart = sog.RootPart;
primUuid = rootPart.UUID;
avatarsSitList = sog.GetSittingAvatars();
foreach (ScenePresence av in avatarsSitList)
{
avUuids += av.UUID.ToString() + " ";
}
break;
}
}
ShowResponse("birds-prim" + i + " = " + m_name + i + " : " + primUuid.ToString() + " : " + avUuids.Trim(), inWorld);
bool inWorld = IsInWorldCmd (ref args);
int i;
int s=m_model.Size;
UUID primUuid;
List<ScenePresence> avatarsSitList = new List<ScenePresence>();
string avUuids;
if (inWorld)
{
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-enabled = " + (m_ready ? "True" : "False"), inWorld);
ShowResponse("birds-prim = " + m_view.BirdPrim, inWorld);
ShowResponse("birds-framerate = " + m_frameUpdateRate, inWorld);
ShowResponse("birds-maxsize = " + m_maxFlockSize, inWorld);
ShowResponse("birds-size = " + s, inWorld);
ShowResponse("birds-speed = " + m_model.MaxSpeed, inWorld);
ShowResponse("birds-force = " + m_model.MaxForce, inWorld);
ShowResponse("birds-distance = " + m_model.NeighbourDistance, inWorld);
ShowResponse("birds-separation = " + m_model.DesiredSeparation, inWorld);
ShowResponse("birds-tolerance = " + m_model.Tolerance, inWorld);
ShowResponse("birds-border = " + m_borderSize, inWorld);
for (i = 0; i < s; i++)
{
primUuid = UUID.Zero;
avatarsSitList.Clear();
avUuids = "";
foreach (EntityBase e in m_scene.GetEntities())
{
if (e.Name == m_name + i)
{
SceneObjectGroup sog = (SceneObjectGroup)e;
SceneObjectPart rootPart = sog.RootPart;
primUuid = rootPart.UUID;
avatarsSitList = sog.GetSittingAvatars();
foreach (ScenePresence av in avatarsSitList)
{
avUuids += av.UUID.ToString() + " ";
}
break;
}
}
ShowResponse("birds-prim" + i + " = " + m_name + i + " : " + primUuid.ToString() + " : " + avUuids.Trim(), inWorld);
}
}
}
@ -471,76 +471,76 @@ namespace Flocking
if (ShouldHandleCmd ()) {
string primName = args[1];
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_view.Clear();
}
}
}
public void HandleSetMaxSpeedCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float maxSpeed = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
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);
}
}
}
public void HandleSetMaxForceCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float maxForce = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
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);
}
}
}
public void HandleSetNeighbourDistanceCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float neighbourDistance = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
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);
}
}
}
public void HandleSetDesiredSeparationCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float desiredSeparation = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
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);
}
}
}
public void HandleSetToleranceCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float tolerance = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
m_model.Tolerance = tolerance;
m_log.InfoFormat("[{0}]: Birds tolerance is set to {1} in region {2}.", m_name, tolerance, m_scene.RegionInfo.RegionName);
}
}
}
public void HandleSetMaxSpeedCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float maxSpeed = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
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);
}
}
}
public void HandleSetMaxForceCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float maxForce = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
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);
}
}
}
public void HandleSetNeighbourDistanceCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float neighbourDistance = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
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);
}
}
}
public void HandleSetDesiredSeparationCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float desiredSeparation = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
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);
}
}
}
public void HandleSetToleranceCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float tolerance = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
m_model.Tolerance = tolerance;
m_log.InfoFormat("[{0}]: Birds tolerance is set to {1} in region {2}.", m_name, tolerance, m_scene.RegionInfo.RegionName);
}
}
}
#endregion

View File

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