/** 设置部件 */ public void setPart(int type, int partID) { //空部件不处理 if (partID <= 0) { return; } _partDic.put(type, partID); _partReady.remove(type); AssetPoolLoadTool tool = getPartLoadTool(type); AvatarPartConfig config = AvatarPartConfig.get(type, partID); tool.loadOne(config.sourceT, obj => partLoadOver(type, partID, obj)); }
/** 删除part */ public void removePart(int type, int id) { IntIntMap dic = _normalPartsDic[type]; if (dic == null) { _normalPartsDic[type] = (dic = new IntIntMap()); } int nowID = getPartID(type); if (dic.addValue(id, -1) == 0) { if (id == nowID) { int[] cArgs = { -1, -1 }; dic.forEach((k, v) => { if (v > 0) { int priority; if ((priority = AvatarPartConfig.get(type, k).proirity) > cArgs[0]) { cArgs[0] = priority; cArgs[1] = k; } } }); int rid = cArgs[1]; _normalParts[type] = rid; if (_changeFacadeID == -1) { setPart(type, id); } } } }
/** 添加part */ public void addPart(int type, int id) { IntIntMap dic = _normalPartsDic[type]; if (dic == null) { _normalPartsDic[type] = (dic = new IntIntMap()); } int nowID = getPartID(type); if (dic.addValue(id, 1) == 1 && id != nowID) { if (AvatarPartConfig.get(type, id).proirity > AvatarPartConfig.get(type, nowID).proirity) { _normalParts[type] = id; if (_changeFacadeID == -1) { setPart(type, id); } } } }