pull/1/merge
kcozens 2018-04-03 14:56:24 +00:00 committed by GitHub
commit 90e2661c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 849 additions and 847 deletions

View File

@ -43,8 +43,10 @@ using OpenSim.Framework.Console;
using Mono.Addins;
using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
[assembly: Addin("OpenSimBirds", "0.2")]
[assembly: Addin("OpenSimBirds", OpenSim.VersionInfo.VersionNumber + "0.3")]
[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
[assembly: AddinDescription("OpenSimBirds module.")]
[assembly: AddinAuthor("Jak Daniels")]
namespace Flocking
{
@ -60,8 +62,8 @@ namespace Flocking
private ICommandConsole m_console;
private FlockingModel m_model;
private FlockingView m_view;
private bool m_startup = true;
private bool m_enabled = false;
private bool m_startup = false;
private bool m_ready = false;
private uint m_frame = 0;
private int m_frameUpdateRate = 1;
@ -108,12 +110,12 @@ namespace Flocking
if (cnf == null)
{
m_log.InfoFormat("[{0}]: No region section [{1}] found in addon-modules/{2}/config/*.ini configuration files.", m_name, scene.RegionInfo.RegionName, m_name);
m_log.InfoFormat("[{0}]: No region section [{1}] found in {2} configuration file.", m_name, scene.RegionInfo.RegionName, m_regionConfigDir);
//string moduleConfigFile = Path.Combine(Util.configDir(),m_name + ".ini");
string moduleConfigFile = Path.Combine(m_regionConfigDir, "Regions.ini");
try
{
m_log.InfoFormat("[{0}]: Checking {1} for [{2}] section containing valid config keys", m_name, moduleConfigFile, scene.RegionInfo.RegionName);
m_log.InfoFormat("[{0}]: Checking {1} for [{2}] section", m_name, moduleConfigFile, scene.RegionInfo.RegionName);
m_config = new IniConfigSource(moduleConfigFile);
cnf = m_config.Configs[scene.RegionInfo.RegionName];
}
@ -124,18 +126,23 @@ namespace Flocking
if (cnf == null)
{
m_log.InfoFormat("[{0}]: No region section [{1}] found in configuration {2}. Birds in this region are set to Disabled", m_name, scene.RegionInfo.RegionName, moduleConfigFile);
m_enabled = false;
m_log.InfoFormat("[{0}]: No region section [{1}] found in configuration {2}.", m_name, scene.RegionInfo.RegionName, moduleConfigFile);
cnf = m_config.Configs[scene.RegionInfo.RegionName];
if (cnf == null)
{
m_log.InfoFormat("[{0}]: No region section [{1}] found in main configuration. Module is disabled.", m_name, scene.RegionInfo.RegionName);
return;
}
}
}
m_startup = cnf.GetBoolean("BirdsModuleStartup", true);
m_enabled = cnf.GetBoolean("BirdsModuleEnabled", false);
if (m_startup)
if (m_enabled)
{
m_scene = scene;
m_enabled = cnf.GetBoolean("BirdsEnabled", false);
m_startup = cnf.GetBoolean("BirdsShowOnStartup", false);
m_chatChannel = cnf.GetInt("BirdsChatChannel", 118);
m_birdPrim = cnf.GetString("BirdsPrim", "birdPrim");
m_flockSize = cnf.GetInt("BirdsFlockSize", 20);
@ -185,7 +192,7 @@ namespace Flocking
m_log.InfoFormat("[{0}] No command security was defined in the config. Any user may possibly configure this module from a script!", m_name);
}
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 still", m_chatChannel, m_flockSize);
m_log.InfoFormat("[{0}] Module is {1} listening for commands on channel {2} with Flock Size {3}", m_name, m_startup ? "enabled and" : "disabled, but still", m_chatChannel, m_flockSize);
m_console = MainConsole.Instance;
//register commands with the scene
@ -205,14 +212,13 @@ namespace Flocking
m_shoutPos = new Vector3(scene.RegionInfo.RegionSizeX / 2f, scene.RegionInfo.RegionSizeY / 2f, 30f);
FlockInitialise();
}
else m_log.InfoFormat("[{0}] Module is disabled in Region {1}", m_name, scene.RegionInfo.RegionName);
else m_log.InfoFormat("[{0}] Module is disabled in region {1}", m_name, scene.RegionInfo.RegionName);
}
public void RegionLoaded (Scene scene)
{
if (m_startup)
if (m_enabled)
{
// Mark Module Ready for duty
m_ready = true;
@ -228,7 +234,7 @@ namespace Flocking
public void RemoveRegion (Scene scene)
{
m_log.InfoFormat("[{0}]: Removing region {1} from this module", m_name, scene.RegionInfo.RegionName);
if (m_startup) {
if (m_enabled) {
m_view.Clear();
scene.EventManager.OnFrame -= FlockUpdate;
scene.EventManager.OnChatFromClient -= SimChatSent;
@ -240,7 +246,7 @@ namespace Flocking
public void Close()
{
if (m_startup)
if (m_enabled)
{
m_scene.EventManager.OnFrame -= FlockUpdate;
m_scene.EventManager.OnChatFromClient -= SimChatSent;
@ -293,7 +299,7 @@ namespace Flocking
public void FlockUpdate ()
{
if (!m_ready || !m_enabled || ((m_frame++ % m_frameUpdateRate) != 0))
if (!m_ready || !m_startup || ((m_frame++ % m_frameUpdateRate) != 0))
{
return;
}
@ -359,7 +365,6 @@ namespace Flocking
} else if (cmd.StartsWith ("framerate")) {
HandleSetFrameRateCmd (m_name, args);
}
}
#endregion
@ -400,7 +405,6 @@ namespace Flocking
if (comms != null)
{
comms.RegisterScriptInvocation(this, "birdsGetStats");
}
}
@ -435,6 +439,7 @@ namespace Flocking
//}
SendSimChat(response, m_chatChannel);
} else {
if (m_ready)
MainConsole.Instance.Output (response);
}
}
@ -448,7 +453,7 @@ 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_startup = false;
//m_ready = false;
m_view.Clear();
}
@ -459,26 +464,26 @@ namespace Flocking
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_startup = true;
//m_ready = true;
}
}
public void HandleStopCmd (string module, string[] args)
{
if (m_enabled && m_ready && ShouldHandleCmd())
if (m_startup && m_ready && ShouldHandleCmd())
{
m_log.InfoFormat("[{0}]: Bird flocking is stopped in region {1}.", m_name, m_scene.RegionInfo.RegionName);
m_enabled = false;
m_startup = false;
}
}
public void HandleStartCmd(string module, string[] args)
{
if (!m_enabled && m_ready && ShouldHandleCmd())
if (!m_startup && m_ready && ShouldHandleCmd())
{
m_log.InfoFormat("[{0}]: Bird flocking is started in region {1}.", m_name, m_scene.RegionInfo.RegionName);
m_enabled = true;
m_startup = true;
FlockUpdate();
}
}
@ -503,7 +508,6 @@ namespace Flocking
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);
}
}
}
@ -523,8 +527,8 @@ namespace Flocking
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-enabled = " + (m_enabled ? "True" : "False"), inWorld);
ShowResponse("birds-startup = " + (m_ready ? "True" : "False"), inWorld);
ShowResponse("birds-prim = " + m_view.BirdPrim, inWorld);
ShowResponse("birds-framerate = " + m_frameUpdateRate, inWorld);
ShowResponse("birds-maxsize = " + m_maxFlockSize, inWorld);
@ -642,7 +646,5 @@ namespace Flocking
}
#endregion
}
}

View File

@ -60,8 +60,8 @@ Here is an example config:
[Test Region 1]
BirdsModuleStartup = True ;this is the default and determines whether the module does anything
BirdsEnabled = True ;set to false to disable the birds from appearing in this region
BirdsModuleEnabled = True ;this is the default and determines whether the module does anything
BirdsShowOnStartup = True ;set to false to disable the birds from appearing in this region
BirdsFlockSize = 50 ;the number of birds to flock
BirdsMaxFlockSize = 100 ;the maximum flock size that can be created (keeps things sane)
BirdsMaxSpeed = 3 ;how far each bird can travel per update