public WorkExperienceParser(IResourceLoader resourceLoader) { var assembly = Assembly.GetExecutingAssembly(); _jobLookUp = new List <string>(resourceLoader.Load(assembly, "JobTitles.txt", ',')); _countryLookUp = new List <string>(resourceLoader.Load(assembly, "Countries.txt", '|')); }
public void Preload() { if ((Interlocked.CompareExchange(ref pendingOperation, 1, 0) == 0)) { if (active.state == ResourceState.Ready) { return; } switch (inactive.state) { case ResourceState.Empty: inactive.state = ResourceState.Loading; resourceLoader.Load(this); return; case ResourceState.Ready: throw new NotSupportedException("active slot is not ready so inactive slot cannot be ready"); case ResourceState.Loading: throw new NotSupportedException("tried to load resource while loading"); case ResourceState.Unloading: throw new NotSupportedException("tried to load resource while unloading"); default: throw new NotSupportedException("this should never occur!"); } } }
public void Load(ResourceHandle resourceHandle) { executor.Add(() => { loader.Load(resourceHandle); }); }
public PersonalParser(IResourceLoader resourceLoader) { var assembly = Assembly.GetExecutingAssembly(); _firstNameLookUp = resourceLoader.LoadIntoHashSet(assembly, "FirstName.txt", ','); _countryLookUp = new List <string>(resourceLoader.Load(assembly, "Countries.txt", '|')); }
public T Load <T>(string filename, bool keepExtension) where T : Resource { Type t = typeof(T); // strip off the extension if it exists string filenameWithoutExtension; if (keepExtension == false) { filenameWithoutExtension = Utils.GetFilenameWithoutExtension(filename); } else { filenameWithoutExtension = filename; } // is the resource already loaded? Dictionary <Type, Resource> rs; Resource r; if (_loadedContent.TryGetValue(filenameWithoutExtension, out rs)) { if (rs.TryGetValue(t, out r)) { return((T)r); } } // we need to load it IResourceLoader loader = _loadersByType[t]; r = loader.Load(filename, this); // cache the new resource. // even though we just checked we need to check again // since the resource we loaded could have loaded other // stuff, so the state of the resource collection is unknown at this point if (_loadedContent.TryGetValue(filenameWithoutExtension, out rs)) { Resource dummy; if (rs.TryGetValue(t, out dummy)) { // nothing to do! } else { rs.Add(t, r); } } else { rs = new Dictionary <Type, Resource>(); rs.Add(t, r); _loadedContent.Add(filenameWithoutExtension, rs); } return((T)r); }
public IEnumerable <string> Load(Assembly assembly, string resourceName, char delimiter) { var key = "Load:" + resourceName; if (!_cacheResources.ContainsKey(key)) { _cacheResources[key] = _decorated.Load(assembly, resourceName, delimiter); } return(_cacheResources[key]); }
public SummaryParser(IResourceLoader resourceLoader) { var assembly = Assembly.GetExecutingAssembly(); using (StreamReader sr = new StreamReader("C:\\Tekathon 2019\\Data\\Technology.txt")) { // Read the stream to a string, and write the string to the console. String line = sr.ReadToEnd(); _technologylist = line.Split(',').ToList(); } _jobLookUp = new List <string>(resourceLoader.Load(assembly, "JobTitles.txt", ',')); }
/// /// /// </summary> public Object load(string name) { if (string.IsNullOrEmpty(name)) { return(null); } string path = Path.Combine(ResourceSetting.WAR_EFFECT, name); path = Path.Combine(ResourceSetting.UNPACKROOT, path); return(ObjLoader.Load(path)); }
private void InstantiateItem(string itemId, Transform attachmentPoint) { if (attachmentPoint.childCount > 0) { return; } var prefab = _resourceLoader.Load <GameObject>(itemId); var item = Instantiate(prefab); item.transform.SetParent(attachmentPoint); item.transform.localPosition = Vector3.zero; item.transform.localRotation = Quaternion.identity; }
/// <summary> /// Loads from unpack folder. country参数决定是否要读取 国家分类 /// </summary> /// <returns>The Object from unack.</returns> /// <param name="name">Name.</param> GameObject loadFromUnPack(string name, Quaternion qua, Vector3 pos, bool country, bool cached, bool ignoreSetting) { Object obj = null; GameObject go = null; if (!string.IsNullOrEmpty(name)) { string path = string.Empty; if (country) { path = Path.Combine(CountryRegion.country, ResourceSetting.UNPACKROOT); path = Path.Combine(path, name); } else { path = Path.Combine(ResourceSetting.UNPACKROOT, name); } if (cached) { obj = ObjLoader.Load(path); } else { obj = URes.Load(path); } if (obj == null) { ConsoleEx.DebugWarning(path + " is not find"); return(null); } if (ignoreSetting) { go = GameObject.Instantiate(obj) as GameObject; } else { go = GameObject.Instantiate(obj, pos, qua) as GameObject; } } return(go); }
protected override Texture2D Load(string info) => _loader.Load(_device, info);
public void LoadDataConfig(string pName, ResouceLoadedCompleteHandler pHandler, params object[] pParams) { _loader.Load("DataConfig/" + pName, typeof(TextAsset), pHandler, pParams); }
public JsonTranslate(IResourceLoader loader, string language) { _dict = loader.Load($"Services/i18n/{language}.json").Replace("{{value}}", "{0}"); }
private Task OnStart(CancellationToken token) { loader.Load(options.TemplateFiles); return(Task.CompletedTask); }
/// /// 先尝试从ObjLoader里面取,如果不存在则再去WeakObjLoader取 /// /// 但是如果是自己队伍里NPC则必须使用ObjLoader去创建 /// public ClientNPC Load(int num, int id, CAMP camp, GameObject WarPoint) { if (NpcModel == null) { NpcModel = Core.Data.getIModelConfig <NPCModel>(); } NPCConfigData configData = NpcModel.get(num); if (configData == null) { ConsoleEx.DebugWarning("not find npc config data :: " + num); return(null); } string path = Path.Combine(ResourceSetting.PACKROOT, NPC); path = Path.Combine(path, configData.model.ToString()); //TODO: 是自己队伍里NPC则必须使用ObjLoader去创建 bool cached = ObjLoader.hitCache(path); Object obj = null; if (cached) { obj = ObjLoader.Load(path); } else { obj = WeakObjLoader.Load(path); } if (obj == null) { ConsoleEx.DebugWarning(configData.model + " not find models. Npc Num = " + num); return(null); } GameObject go = GameObject.Instantiate(obj) as GameObject; UnityUtils.AddChild_Reverse(go, WarPoint); /// /// 数据的初始化过程 /// DynamicDataInit(go, num, camp, id); ClientNPC npc = go.GetComponent <ClientNPC> (); if (npc != null) { go.name = "NPC_" + npc.data.configData.ID + "_" + npc.UniqueID; if (!string.IsNullOrEmpty(configData.controlScript)) { ClientNpcAnimState animState = go.AddComponent(configData.controlScript) as ClientNpcAnimState; npc.animState = animState; animState.CachedNpc = npc; animState.AttackCount = configData.normalHit.Length; npc.broadcast = animState.OnNewStateReceived; } cliNpcMgr.CreateNpcUI(npc); } return(npc); }
protected override SpriteFont Load(string info) => _loader.Load(_device, info);
protected override Task OnStart(CancellationToken token) { _loader.Load(_options.TemplateFiles); return(Task.CompletedTask); }