/// <summary> /// 添加一个模型的加载数据 /// 在结束解析的时候,开始加载 /// </summary> /// <param name="model"></param> /// <param name="structure"></param> /// <param name="motion"></param> /// <param name="direction"></param> /// <param name="resourceType"></param> /// <param name="resourceAssistType"></param> protected void Load(uint model, EModelStructure structure, CSMotion motion, CSDirection direction, EResourceType resourceType, EResourceAssistType resourceAssistType) { //加载的模型不存在 if (model == 0) { //如果要加载身体模型不存在,那么要注意清理其他的组件 if (structure == EModelStructure.Body) { } return; } long key = GetKey((int)model, (int)motion, (int)direction, (int)structure); ModelComponentLoadData data = null; if (!ModelComponentLoadedCacheDic.TryGetValue(key, out data)) { data = new T(); ModelComponentLoadedCacheDic[key] = data; } data.Model = model; data.Key = key; data.Structure = structure; data.ResourceType = resourceType; data.ResourceAssistType = resourceAssistType; WaitLoadComponentKey.Add(data); }
public CSProtoMessageData(string content) { this.content = content; string pattern = "message ([^{^ ])+"; MatchCollection matchs = null; matchs = Regex.Matches(content, pattern); if (matchs != null && matchs.Count > 0) { messageName = matchs[0].Groups[1].Value; } pattern = "(required|optional|repeated) (\\S+) ([\\S^=]+)[ ]*=[ ]*([0-9]+)[^;]*;//(\\S+)"; matchs = Regex.Matches(content, pattern); fieldList.Clear(); if (matchs != null && matchs.Count > 0) { for (int i = 0; i < matchs.Count; i++) { GroupCollection group = matchs[i].Groups; CSProtoMessageFieldData data = new CSProtoMessageFieldData(group[1].Value, group[2].Value, group[3].Value, uint.Parse(group[4].Value), group[5].Value); fieldList.Add(data); } } }
/// <summary> /// 设置放入对象池的时间 /// </summary> /// <param name="mPoolItem"></param> /// <param name="time">秒</param> public void SetPoolRemoveTime(CSObjectPoolItem mPoolItem, float time, EPoolItemRemoveMethod removeMethod = EPoolItemRemoveMethod.OnDisEnable) { if (mPoolItem == null) { return; } mPoolItem.RemoveTime = Time.time + time; WaitRemoveList.Add(mPoolItem); }
/// <summary> /// /// </summary> /// <param name="match"></param> /// <param name="obj">值类型装换成object有装箱操作,有一定的性能消耗,防止大量的装箱的出现</param> /// <param name="list"></param> public void FindAll(CompareFunc_2 match, object obj, CSBetterList <T> list) { list.Clear(); for (int i = 0; i < size; i++) { if (match(buffer[i], obj)) { list.Add(buffer[i]); } } }
public void FindAll(Predicate <T> match, CSBetterList <T> list) { list.Clear(); for (int i = 0; i < size; i++) { if (match(buffer[i])) { list.Add(buffer[i]); } } }
private void AddLoadingQueue(CSResource res) { if (!loadingQueue.ContainsKey(res.Path)) { loadingQueue.Add(res.Path, res); } if (!loadingQueueList.Contains(res)) { loadingQueueList.Add(res); } }
public Value this[Key i] { get { return(mDic[i]); } set { if (mIsHasValues) { mValues.Remove(mDic[i]); mValues.Add(value); } mDic[i] = value; } }
public void RefushFolder() { DirectoryInfo directory = new DirectoryInfo(OrigionFolder); if (!directory.Exists) { return; } FileList.Clear(); FileInfo[] files = directory.GetFiles("*.proto"); for (int i = 0; i < files.Length; i++) { FileList.Add(files[i]); } }
public CSBetterList <T> GetRange(int startIndex, int count, CSBetterList <T> list) { list.Clear(); for (int i = startIndex; i < startIndex + count; i++) { if (i < 0) { continue; } if (i < size) { list.Add(buffer[i]); } } return(list); }
private static CSBetterList <Node> CalculatePath(Node node, bool isAssist = false) { CSBetterList <Node> data = isAssist ? assistList : normalList; data.Clear(); while (node != null) { data.Add(node); node = node.parent; if (data.Count > 1000) { return(null); } } data.Reverse(); return(data); }
/// <summary> /// 从缓存池里面获得GameObject,并且从缓存池里面去除,返回的Gameobject.active = false /// </summary>resPath 资源路径,也是缓存池名称 /// <param name="poolName">资源路径</param> CSObjectPoolItem GetPoolItem(string resName, string resPath, EPoolType poolType, int poolNum = 0, bool isForever = false) { CSObjectPoolBase pool = null; string poolName = resPath; if (mDic.ContainsKey(poolName)) { pool = mDic[poolName]; } else { if (poolNum == 0) { return(null); } CSStringBuilder.Clear(); GameObject poolGO = new GameObject(); Transform trans = poolGO.transform; trans.parent = transform; if (poolType == EPoolType.Normal) { pool = poolGO.AddComponent <CSObjectPoolNormal>(); CSStringBuilder.Append("Normal Pool->", resName); poolGO.name = CSStringBuilder.ToString(); } else if (poolType == EPoolType.Resource) { pool = poolGO.AddComponent <CSObjectPoolAtlas>(); CSStringBuilder.Append("Atlas Pool->", resName); poolGO.name = CSStringBuilder.ToString(); } pool.resName = resName; //pool.resType = resType; pool.Init(this); mDic.Add(poolName, pool); mList.Add(pool); } pool.poolNum = poolNum; pool.poolName = poolName; pool.isForever = isForever; return(pool.GetGOFromPool()); }
/// <summary> /// 从缓存池里面获得GameObject,并且从缓存池里面去除,返回的Gameobject.active = false /// </summary>resPath 资源路径,也是缓存池名称 /// <param name="poolName">资源路径</param> private CSObjectPoolItem GetPoolItem(string resName, string resPath, EPoolType poolType, int poolNum = 0, bool isForever = false) { CSObjectPoolBase pool = null; string poolName = resPath; if (mDic.TryGetValue(poolName, out pool) && pool != null) { pool = mDic[poolName]; } else { if (poolNum == 0) { return(null); } CSStringBuilder.Clear(); GameObject poolGO = new GameObject(); Transform trans = poolGO.transform; trans.parent = transform; if (poolType == EPoolType.Normal) { pool = poolGO.AddComponent <CSObjectPoolNormal>(); CSStringBuilder.Append("Normal Pool->", resName); poolGO.name = CSStringBuilder.ToString(); } pool.resName = resName; //pool.resType = resType; pool.Init(); mDic[poolName] = pool; pool.transform.localScale = Vector3.zero; //mDic.Add(poolName, pool); mList.Add(pool); } pool.poolNum = poolNum; pool.poolName = poolName; pool.isForever = isForever; return(pool.GetGOFromPool()); }
public void Load(uint modelID, uint motion, uint direction, uint structure, ResourceType type, ResourceAssistType assistType) { //Debug.Log(modelID + " " + motion + " " + direction); if (SFOut.IResourceManager == null) { return; } long key = GetKey((int)modelID, (int)motion, (int)direction); //if (avater != null && avater.getAvatarType() == EAvatarType.MainPlayer) //{ // Debug.Log("motion = " + (CSMotion)motion); //} if (mLoadedDic.ContainsKey(key)) { ModelLoadData data = mLoadedDic[key]; if (data != null && data.atlas != null && !data.atlas.HasBeenDestroy) { mStructures[structure] = key; string path = SFOut.IResourceManager.GetKeyPath(key); CSResource res = SFOut.IResourceManager.GetRes(path); if (res != null) { BeginLoadModelResCallBack(res); } return; } } else { ModelLoadData data = new ModelLoadData(); mLoadedDic.Add(key, data); data.type = type; data.assistType = assistType; } mStructures[structure] = key; mObjectList.Add(key); mObjectFinishStateList.Add(false); }
public void AddFrontCallBack(OnLoaded onLoaded) { onLoadedList.Add(onLoaded); }