Exemplo n.º 1
0
 public T this[ObjectRef objRef]
 {
     get
     {
         return(byObjRef(objRef, ModData.ModFromAssembly(Assembly.GetCallingAssembly())));
     }
 }
Exemplo n.º 2
0
        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]);
        }
Exemplo n.º 3
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.");
        }