public List <T> GetScriptsInChildren <T>(MochaInterface.GameObject g)
        {
            if (g == null)
            {
                Logger.Log("Null GameObject passed on invoke class to find: ");
                return(null);
            }
            List <T> scripts = new List <T>();

            foreach (MochaInterface.CTransform ct in g.transform.children)
            {
                if (ScriptSubsystemManaged.getInstance().gameObjectToBoundScriptsLookup.ContainsKey(ct.gameObject))
                {
                    foreach (BoundScript bs in ScriptSubsystemManaged.getInstance().gameObjectToBoundScriptsLookup[ct.gameObject])
                    {
                        if (bs == null || bs.scriptObject == null)
                        {
                            continue;
                        }
                        if (bs.scriptObject.GetType() == typeof(T))
                        {
                            scripts.Add((T)bs.scriptObject);
                        }
                    }
                }
            }

            return(scripts);
        }
        public CompilerResults CompileAll()
        {
            Logger.Log("Scripts recompiling...");
            //compile all scripts 
            CSharpCodeProvider provider = new CSharpCodeProvider();
            CompilerParameters parameters = new CompilerParameters();
            parameters.ReferencedAssemblies.Add("MochaCore.dll");
            parameters.ReferencedAssemblies.Add("Microsoft.Xna.Framework.Math.dll");
            parameters.ReferencedAssemblies.Add("System.dll");
            parameters.GenerateExecutable = false;
            parameters.GenerateInMemory = false; //default
            parameters.TempFiles = new TempFileCollection(Environment.GetEnvironmentVariable("TEMP"), true);
            parameters.IncludeDebugInformation = true;
            //parameters.CompilerOptions += "/optimize";
            string[] filepaths = Directory.GetFiles("Assets\\Scripts\\", "*.cs", SearchOption.AllDirectories);
            for (int i = 0; i < filepaths.Count(); ++i )
                filepaths[i] = Directory.GetCurrentDirectory() + "\\" + filepaths[i];
            CompilerResults results = provider.CompileAssemblyFromFile(parameters, filepaths);
            if (results.Errors.HasErrors)
            {
                StringBuilder sb = new StringBuilder();
                foreach (CompilerError error in results.Errors)
                    sb.AppendLine(String.Format("Error in {0} at {1}: {2} ({3})", Path.GetFileNameWithoutExtension(error.FileName), error.Line, error.ErrorText, error.ErrorNumber));
                Logger.Log("Scripts recompiled with errors.");
                Logger.Log(sb.ToString());
                ScriptSubsystemManaged.getInstance().SetHasError(true);
                return null;
            }
            else
                ScriptSubsystemManaged.getInstance().SetHasError(false);

            _comp = results;

            Logger.Log("Scripts recompiled without error.");

            return results;
        }