示例#1
0
文件: Sdk.cs 项目: jayands/tAPI-SDK
        /// <summary>
        /// Initializes the SDK.
        /// Call this in OnLoad.
        /// If you do not call this, the SDK will not work (partially).
        /// </summary>
        public static void Init()
        {
            if (Inited)
                return;

            // Adding the current assembly to the mods... *puts on sunglasses*

            // because of this, all mods will load the same assembly instance (hehehe), so the data can be accessible for all mods

            Assembly code = Assembly.GetExecutingAssembly();

            JsonData modInfo = JsonMapper.ToObject(ReadResource("ModInfo.json"));

            const string
                MODFILE = "TAPI.SDK.tapimod",
                MODNAME = "TAPI.SDK",
                DISPLAYNAME = "tAPI SDK";

            ModBase modBase = new Mod();

            modBase.fileName = MODFILE;
            modBase.modName = MODNAME;
            modBase.modInfo = new ModInfo(modInfo);

            Mods.loadOrder.Add(MODNAME);
            Mods.modBases.Add(modBase);

            #region instantiate mod[...]
            modBase.modPlayers.Add(new MPlayer(modBase, null));
            modBase.modWorlds.Add(new MWorld(modBase));
            modBase.modItems.Add(new MItem(modBase, null));
            modBase.modNPCs.Add(new MNPC(modBase, null));
            modBase.modProjectiles.Add(new MProj(modBase, null));
            modBase.modInterfaces.Add(new SdkUI(modBase));

            foreach (ModBase m in Mods.modBases)
                Defs.FillCallPriorities(m.GetType());
            foreach (ModWorld m in Mods.globalModWorlds)
                Defs.FillCallPriorities(m.GetType());
            foreach (ModPlayer m in Mods.globalModPlayers)
                Defs.FillCallPriorities(m.GetType());
            foreach (ModItem m in Mods.globalModItems)
                Defs.FillCallPriorities(m.GetType());
            foreach (ModNPC m in Mods.globalModNPCs)
                Defs.FillCallPriorities(m.GetType());
            foreach (ModProjectile m in Mods.globalModProjectiles)
                Defs.FillCallPriorities(m.GetType());
            foreach (ModInterface m in Mods.globalModInterfaces)
                Defs.FillCallPriorities(m.GetType());
            foreach (ModPrefix m in Mods.globalModPrefixes)
                Defs.FillCallPriorities(m.GetType());
            #endregion

            modBase.OnLoad();

            Inited = true;
        }
示例#2
0
文件: Mod.cs 项目: jayands/tAPI-SDK
 public Mod()
     : base()
 {
     instance = this;
 }