The base class used to define a mod. Every mod must have exactly one type that inherits from ModDef.
Inheritance: HookContainer
コード例 #1
0
ファイル: DefIndexer.cs プロジェクト: Nopezal/Prism
        public T ByObjRef(ObjectRef or, ModDef requesting)
        {
            var req = requesting ?? or.requesting;

            if (String.IsNullOrEmpty(or.ModName) && req != null && GetModDefs(req).ContainsKey(or.Name))
            {
                return(GetModDefs(req)[or.Name]);
            }

            if (or.Mod == PrismApi.VanillaInfo)
            {
                if (!VanillaDefsByName.ContainsKey(or.Name))
                {
                    throw new InvalidOperationException("Vanilla " + objName + " definition '" + or.Name + "' is not found.");
                }

                return(VanillaDefsByName[or.Name]);
            }

            if (!ModData.ModsFromInternalName.ContainsKey(or.ModName))
            {
                throw new InvalidOperationException(objName + " definition '" + or.Name + "' in mod '" + or.ModName + "' could not be returned because the mod is not loaded.");
            }
            if (!ModData.ModsFromInternalName[or.ModName].ItemDefs.ContainsKey(or.Name))
            {
                throw new InvalidOperationException(objName + " definition '" + or.Name + "' in mod '" + or.ModName + "' could not be resolved because the " + objName + " is not loaded.");
            }

            return(GetModDefs(ModData.ModsFromInternalName[or.ModName])[or.Name]);
        }
コード例 #2
0
        public T ByObjRef(ObjectRef or, ModDef requesting)
        {
            var req = requesting ?? or.requesting;
            T   ret;

            if (String.IsNullOrEmpty(or.ModName) && req != null && GetModDefs(req).TryGetValue(or.Name, out ret))
            {
                return(ret);
            }

            if (or.Mod == PrismApi.VanillaInfo)
            {
                if (VanillaDefsByName.TryGetValue(or.Name, out ret))
                {
                    return(ret);
                }

                throw new InvalidOperationException("Vanilla " + objName + " definition '" + or.Name + "' is not found.");
            }

            ModDef md;

            if (!ModData.ModsFromInternalName.TryGetValue(or.ModName, out md))
            {
                throw new InvalidOperationException(objName + " definition '" + or.Name + "' in mod '" + or.ModName + "' could not be returned because the mod is not loaded.");
            }

            if (GetModDefs(md).TryGetValue(or.Name, out ret))
            {
                return(ret);
            }

            throw new InvalidOperationException(objName + " definition '" + or.Name + "' in mod '" + or.ModName + "' could not be resolved because the " + objName + " is not loaded.");
        }
コード例 #3
0
ファイル: RecipeDefHandler.cs プロジェクト: Neojin9/Prism
 internal static IEnumerable<RecipeDef> SetRecipeModDefs(ModDef mod, IEnumerable<RecipeDef> defs)
 {
     return defs.Select(d =>
     {
         d.Mod = mod.Info;
         return d;
     });
 }
コード例 #4
0
ファイル: ObjectRef.cs プロジェクト: Nopezal/Prism
        public ObjectRef(string name, string modName = null)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            this.name    = name;
            this.modName = modName ?? String.Empty;

            requesting = ModData.ModFromAssembly(Assembly.GetCallingAssembly());
        }
コード例 #5
0
ファイル: ObjectRef.cs プロジェクト: Nopezal/Prism
 public ObjectRef(string name, ModInfo mod)
     : this(name, mod.InternalName)
 {
     requesting = null;
 }
コード例 #6
0
ファイル: Spectrum.cs プロジェクト: MiraiMai/Spectrum
 public override void OnAllModsLoaded()
 {
     Mod = this;
 }