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]); }
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."); }
internal static IEnumerable<RecipeDef> SetRecipeModDefs(ModDef mod, IEnumerable<RecipeDef> defs) { return defs.Select(d => { d.Mod = mod.Info; return d; }); }
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()); }
public ObjectRef(string name, ModInfo mod) : this(name, mod.InternalName) { requesting = null; }
public override void OnAllModsLoaded() { Mod = this; }