public Object() { if (EvtInterface == null && !IsPlayer()) { EvtInterface = AddInterface <EventInterface>(); } ScrInterface = AddInterface <ScriptsInterface>(); IsActive = false; }
static public void LoadScripts(bool Reload) { GeneralScripts = new ScriptsInterface(); ScriptCompiler = new CSharpScriptCompiler(); ScriptCompiler.LoadScripts(); GeneralScripts.ClearScripts(); foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type type in assembly.GetTypes()) { if (type.IsClass != true) continue; if (!type.IsSubclassOf(typeof(AGeneralScript))) continue; foreach (GeneralScriptAttribute at in type.GetCustomAttributes(typeof(GeneralScriptAttribute), true)) { if (at.ScriptName != null && at.ScriptName != "") at.ScriptName = at.ScriptName.ToLower(); Log.Success("Scripting", "Resgistering Script :" + at.ScriptName ); if (at.GlobalScript) { AGeneralScript Script = Activator.CreateInstance(type) as AGeneralScript; Script.ScriptName = at.ScriptName; GeneralScripts.RemoveScript(Script.ScriptName); GeneralScripts.AddScript(Script); GlobalScripts[at.ScriptName] = Script; } else { if (at.CreatureEntry != 0) { Log.Success("Scripts", "Registering Creature Script :" + at.CreatureEntry); if (!CreatureScripts.ContainsKey(at.CreatureEntry)) { CreatureScripts[at.CreatureEntry] = type; } else { CreatureScripts[at.CreatureEntry] = type; } } else if (at.GameObjectEntry != 0) { Log.Success("Scripts", "Registering GameObject Script :" + at.GameObjectEntry); if (!GameObjectScripts.ContainsKey(at.GameObjectEntry)) { GameObjectScripts[at.GameObjectEntry] = type; } else { GameObjectScripts[at.GameObjectEntry] = type; } } else if(at.ScriptName != null && at.ScriptName != "") { Log.Success("Scripts", "Registering Name Script :" + at.ScriptName); if (!LocalScripts.ContainsKey(at.ScriptName)) { LocalScripts[at.ScriptName] = type; } else { LocalScripts[at.ScriptName] = type; } } } } } } Log.Success("Scripting", "Loaded : " + (GeneralScripts.Scripts.Count + LocalScripts.Count) + " Scripts"); if (Reload) { if (Program.Server != null) Program.Server.LoadPacketHandler(); AbilityMgr.LoadAbilityHandlers(); } }