/// <summary> /// Finds all of the LSL event handlers this script registers in a /// given state /// </summary> /// <param name="state">State to search for event handlers</param> /// <returns>A bitmask containing the types of events this state has /// handlers for</returns> public LSLEventFlags GetEventsForState(string state) { Type scriptType = m_script.GetType(); LSLEventFlags eventFlags = 0; foreach (LSLEventFlags flag in Enum.GetValues(typeof(LSLEventFlags))) { string eventName = state + "_event_" + flag; try { MethodInfo method = scriptType.GetMethod(eventName); if (method != null) { eventFlags |= flag; } } catch (Exception) { } } return(eventFlags); }
public void Init(byte[] scriptBinary, LSLScriptInstance instance) { m_instance = instance; // Load the assembly into this AppDomain and create an instance of the // SecondLife.Script class (the main script class) Assembly scriptAssembly = Assembly.Load(scriptBinary); m_script = scriptAssembly.CreateInstance("SecondLife.Script") as LSLScriptBase; m_script.Init(this); // Create a dictionary of FastInvoke delegates for each method in the script MethodInfo[] methodInfos = m_script.GetType().GetMethods(); m_methods = new Dictionary <string, FastInvokeDelegate>(); for (int i = 0; i < methodInfos.Length; i++) { if (methodInfos[i].Module.Assembly == scriptAssembly) { m_methods.Add(methodInfos[i].Name, FastInvoke.Create(methodInfos[i])); } } }
public void Init(byte[] scriptBinary, LSLScriptInstance instance) { m_instance = instance; // Load the assembly into this AppDomain and create an instance of the // SecondLife.Script class (the main script class) Assembly scriptAssembly = Assembly.Load(scriptBinary); m_script = scriptAssembly.CreateInstance("SecondLife.Script") as LSLScriptBase; m_script.Init(this); // Create a dictionary of FastInvoke delegates for each method in the script MethodInfo[] methodInfos = m_script.GetType().GetMethods(); m_methods = new Dictionary<string, FastInvokeDelegate>(); for (int i = 0; i < methodInfos.Length; i++) { if (methodInfos[i].Module.Assembly == scriptAssembly) m_methods.Add(methodInfos[i].Name, FastInvoke.Create(methodInfos[i])); } }