Module is started by default, and can run without a config, but will not be enabled. Module can be specifically disabled in a region with BirdsModuleStartup = True/False
parent
3dcb5d0b1c
commit
d356b62176
|
@ -59,7 +59,8 @@ namespace Flocking
|
|||
private Scene m_scene;
|
||||
private ICommandConsole m_console;
|
||||
private FlockingModel m_model;
|
||||
private FlockingView m_view;
|
||||
private FlockingView m_view;
|
||||
private bool m_startup = true;
|
||||
private bool m_enabled = false;
|
||||
private bool m_ready = false;
|
||||
private uint m_frame = 0;
|
||||
|
@ -126,12 +127,13 @@ namespace Flocking
|
|||
m_enabled = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_startup = cnf.GetBoolean("BirdsModuleStartup", true);
|
||||
|
||||
m_enabled = cnf.GetBoolean("BirdsEnabled", false);
|
||||
|
||||
if (m_enabled)
|
||||
{
|
||||
if (m_startup)
|
||||
{
|
||||
m_enabled = cnf.GetBoolean("BirdsEnabled", false);
|
||||
m_chatChannel = cnf.GetInt("BirdsChatChannel", 118);
|
||||
m_birdPrim = cnf.GetString("BirdsPrim", "birdPrim");
|
||||
m_flockSize = cnf.GetInt("BirdsFlockSize", 50);
|
||||
|
@ -145,7 +147,7 @@ namespace Flocking
|
|||
m_maxHeight = cnf.GetInt("BirdsMaxHeight", 256);
|
||||
m_frameUpdateRate = cnf.GetInt("BirdsUpdateEveryNFrames", 1);
|
||||
|
||||
m_log.InfoFormat("[{0}] Enabled on channel {1} with Flock Size {2}", m_name, m_chatChannel, m_flockSize);
|
||||
m_log.InfoFormat("[{0}] Module is {1} listening for commands on channel {2} with Flock Size {3}", m_name, m_enabled?"enabled and":"disabled, but", m_chatChannel, m_flockSize);
|
||||
|
||||
m_scene = scene;
|
||||
m_console = MainConsole.Instance;
|
||||
|
@ -168,15 +170,15 @@ namespace Flocking
|
|||
|
||||
FlockInitialise();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RegionLoaded (Scene scene)
|
||||
{
|
||||
if (m_enabled)
|
||||
{
|
||||
if (m_startup)
|
||||
{
|
||||
// Mark Module Ready for duty
|
||||
m_ready = true;
|
||||
m_ready = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,25 +190,26 @@ namespace Flocking
|
|||
|
||||
public void RemoveRegion (Scene scene)
|
||||
{
|
||||
m_log.InfoFormat("[{0}]: Removing region {1} from this module", m_name, scene.RegionInfo.RegionName);
|
||||
if (m_enabled) {
|
||||
m_log.InfoFormat("[{0}]: Removing region {1} from this module", m_name, scene.RegionInfo.RegionName);
|
||||
if (m_startup) {
|
||||
m_view.Clear();
|
||||
m_ready = false;
|
||||
scene.EventManager.OnFrame -= FlockUpdate;
|
||||
scene.EventManager.OnChatFromClient -= SimChatSent;
|
||||
scene.EventManager.OnFrame -= FlockUpdate;
|
||||
scene.EventManager.OnChatFromClient -= SimChatSent;
|
||||
scene.EventManager.OnChatFromWorld -= SimChatSent;
|
||||
scene.EventManager.OnPrimsLoaded -= PrimsLoaded;
|
||||
}
|
||||
scene.EventManager.OnPrimsLoaded -= PrimsLoaded;
|
||||
m_ready = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (m_enabled)
|
||||
{
|
||||
if (m_startup)
|
||||
{
|
||||
m_ready = false;
|
||||
m_scene.EventManager.OnFrame -= FlockUpdate;
|
||||
m_scene.EventManager.OnChatFromClient -= SimChatSent;
|
||||
m_scene.EventManager.OnChatFromWorld -= SimChatSent;
|
||||
m_scene.EventManager.OnChatFromWorld -= SimChatSent;
|
||||
m_scene.EventManager.OnPrimsLoaded -= PrimsLoaded;
|
||||
m_ready = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,8 +255,9 @@ namespace Flocking
|
|||
#region EventHandlers
|
||||
|
||||
public void FlockUpdate ()
|
||||
{
|
||||
if (((m_frame++ % m_frameUpdateRate) != 0) || !m_ready || !m_enabled) {
|
||||
{
|
||||
if (!m_ready || !m_enabled || ((m_frame++ % m_frameUpdateRate) != 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -396,18 +400,18 @@ namespace Flocking
|
|||
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;
|
||||
//m_ready = false;
|
||||
m_view.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
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_enabled = true;
|
||||
m_ready = true;
|
||||
//m_ready = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,8 +435,9 @@ namespace Flocking
|
|||
}
|
||||
|
||||
void HandleSetFrameRateCmd (string module, string[] args)
|
||||
{
|
||||
if (ShouldHandleCmd ()) {
|
||||
{
|
||||
if (m_ready && ShouldHandleCmd())
|
||||
{
|
||||
int frameRate = Convert.ToInt32( args[1] );
|
||||
m_frameUpdateRate = frameRate;
|
||||
m_log.InfoFormat("[{0}]: Bird updates set to every {1} frames in region {2}.", m_name, frameRate, m_scene.RegionInfo.RegionName);
|
||||
|
@ -440,8 +445,9 @@ namespace Flocking
|
|||
}
|
||||
|
||||
public void HandleSetSizeCmd (string module, string[] args)
|
||||
{
|
||||
if (ShouldHandleCmd ()) {
|
||||
{
|
||||
if (m_ready && ShouldHandleCmd())
|
||||
{
|
||||
lock( m_sync ) {
|
||||
int newSize = Convert.ToInt32(args[1]);
|
||||
if (newSize > m_maxFlockSize) newSize = m_maxFlockSize;
|
||||
|
@ -454,8 +460,9 @@ namespace Flocking
|
|||
}
|
||||
|
||||
public void HandleShowStatsCmd (string module, string[] args)
|
||||
{
|
||||
if (ShouldHandleCmd ()) {
|
||||
{
|
||||
if (m_ready && ShouldHandleCmd())
|
||||
{
|
||||
bool inWorld = IsInWorldCmd (ref args);
|
||||
int i;
|
||||
int s=m_model.Size;
|
||||
|
@ -508,8 +515,9 @@ namespace Flocking
|
|||
}
|
||||
|
||||
public void HandleSetPrimCmd (string module, string[] args)
|
||||
{
|
||||
if (ShouldHandleCmd ()) {
|
||||
{
|
||||
if (m_ready && ShouldHandleCmd())
|
||||
{
|
||||
string primName = args[1];
|
||||
lock(m_sync) {
|
||||
m_view.BirdPrim = primName;
|
||||
|
@ -520,8 +528,8 @@ namespace Flocking
|
|||
}
|
||||
|
||||
public void HandleSetMaxSpeedCmd(string module, string[] args)
|
||||
{
|
||||
if (ShouldHandleCmd())
|
||||
{
|
||||
if (m_ready && ShouldHandleCmd())
|
||||
{
|
||||
float maxSpeed = (float)Convert.ToDecimal(args[1]);
|
||||
lock (m_sync)
|
||||
|
@ -533,8 +541,8 @@ namespace Flocking
|
|||
}
|
||||
|
||||
public void HandleSetMaxForceCmd(string module, string[] args)
|
||||
{
|
||||
if (ShouldHandleCmd())
|
||||
{
|
||||
if (m_ready && ShouldHandleCmd())
|
||||
{
|
||||
float maxForce = (float)Convert.ToDecimal(args[1]);
|
||||
lock (m_sync)
|
||||
|
@ -546,8 +554,8 @@ namespace Flocking
|
|||
}
|
||||
|
||||
public void HandleSetNeighbourDistanceCmd(string module, string[] args)
|
||||
{
|
||||
if (ShouldHandleCmd())
|
||||
{
|
||||
if (m_ready && ShouldHandleCmd())
|
||||
{
|
||||
float neighbourDistance = (float)Convert.ToDecimal(args[1]);
|
||||
lock (m_sync)
|
||||
|
@ -559,8 +567,8 @@ namespace Flocking
|
|||
}
|
||||
|
||||
public void HandleSetDesiredSeparationCmd(string module, string[] args)
|
||||
{
|
||||
if (ShouldHandleCmd())
|
||||
{
|
||||
if (m_ready && ShouldHandleCmd())
|
||||
{
|
||||
float desiredSeparation = (float)Convert.ToDecimal(args[1]);
|
||||
lock (m_sync)
|
||||
|
@ -572,8 +580,8 @@ namespace Flocking
|
|||
}
|
||||
|
||||
public void HandleSetToleranceCmd(string module, string[] args)
|
||||
{
|
||||
if (ShouldHandleCmd())
|
||||
{
|
||||
if (m_ready && ShouldHandleCmd())
|
||||
{
|
||||
float tolerance = (float)Convert.ToDecimal(args[1]);
|
||||
lock (m_sync)
|
||||
|
|
Loading…
Reference in New Issue