public void updataItemByNo(CharacterItemBean newItem) { //根据no查找item,并更新其他数据 for (int i = 0; i <= itemList.Length - 1; i++) { if ((itemList[i] != null) && (itemList[i].no == newItem.no)) { itemList[i] = new CharacterItemBean(newItem); return; } } throw new Exception("itemNoNotFound"); }
private int farcType(string farcName) { string chaname = farcName.Substring(0, 3); if (chaname.Equals("cmn")) { return(0); } CharacterTbl chaTbl = findCharactor(getStandardName(chaname)); CharacterItemBean cib = chaTbl.findItemByNo(Int32.Parse(farcName.Replace(chaname + "itm", "").Replace(".farc", ""))); if (cib.sub_id == 10) { return(1); } else { return(2); } }
public void copyModuleWithNewBody(int moduleId, String name) { ModuleBean mb = new ModuleBean(modules.findModuleById(moduleId)); CharacterTbl chaTbl = findCharactor(mb.chara); //更新module mb.id = modules.lastModuleId + 1; mb.sort_index = modules.lastSortIndex + 1; if (!name.Equals("")) { mb.name = mb.name + name; } int oriCosId = StringCut.cosString2Id(mb.cos); mb.cos = StringCut.cosId2String(chaTbl.lastCosId + 1); modules.add(mb); //更新cos CosBean newCos = new CosBean(chaTbl.findCosById(oriCosId)); int OldBodyno = chaTbl.findBodyNo(newCos); newCos.id = chaTbl.lastCosId + 1; foreach (ItemBean i in newCos.item) { if (Int32.Parse(i.item) == OldBodyno) { i.item = (chaTbl.lastItemNo + 1).ToString(); } } chaTbl.addCos(newCos); logs.modules.Add(new ModuleLogBean(modules.findModuleById(moduleId), mb, chaTbl.findCosById(oriCosId), newCos)); //新增身体 CharacterItemBean newItem = copyItemByNo(mb.chara, OldBodyno); //更新缩略图 String spiritName = sprdb.addMD(mb.id); //更新日志 }
public void addItem(CharacterItemBean newItem) { newItem.index = lastItemIndex + 1; if (itemList[newItem.index] != null) { throw new Exception(newItem + " ModuleIndexUsed"); } else { itemList[newItem.index] = new CharacterItemBean(); } itemList[newItem.index] = newItem; itemLength++; if (newItem.index > lastItemIndex) { lastItemIndex = newItem.index; } if (newItem.no > lastItemNo) { lastItemNo = newItem.no; } }
public void loopObjsetFolder(string objsetpath) { var files = Directory.GetFiles(objsetpath, "*.farc"); List <String> items = new List <string>(); foreach (var file in files) { String farcName = file.ToString().Replace(objsetpath + "\\", "", StringComparison.InvariantCultureIgnoreCase); string cha = farcName.Substring(0, 3); string farcName1 = farcName.Replace(".farc", ""); if (farcName1.Substring(6).Equals("000")) { continue; } switch (farcType(farcName)) { case 0: int no = mikTbl.findItemByNo(Int32.Parse(farcName1.Replace("cmnitm", ""))).no; copyCustomizeItemByObjId(no, " " + logs.farcPath.Substring(logs.farcPath.Length - 4)); break; case 1: copyModuleWithNewBody(farcName1, " " + logs.farcPath.Substring(logs.farcPath.Length - 4)); break; case 2: items.Add(farcName1); break; } } //不止替换身体的模组 foreach (String s in items) { //额外配件的信息 String cha = s.Substring(0, 3); int chano = Int32.Parse(s.Replace(cha + "itm", "")); CharacterItemBean cib = copyItemByNo(getStandardName(cha), chano); //遍历添加的模组 foreach (ModuleLogBean mlb in logs.modules) { //此模组与额外配件角色对应 if (mlb.newModule.chara.Equals(getStandardName(cha), StringComparison.InvariantCultureIgnoreCase)) { //替换配件 foreach (ItemBean ib in findCharactor(mlb.newModule.chara).findCosById(mlb.newCos.id).item) { if (ib.item.Equals(chano.ToString())) { ib.item = cib.no.ToString(); } } } } } //特殊处理换色零件 if (allowTextureReplace) { foreach (ItemLogBean ilb in logs.items) { if ((ilb.newItem.attr != 1) && (ilb.newItem.sub_id != 24)) { //非脸换色 foreach (ItemLogBean ilb2 in logs.items) { if ((ilb2.newItem.attr == 1) && (ilb.newItem.objset[0].objset.Equals(ilb2.oldItem.objset[0].objset))) //是原件&&旧原件name==新原件name { ilb.newItem.objset[0].objset = ilb2.newItem.objset[0].objset; ilb.newItem.dataObjUid[0].uid = ilb2.newItem.dataObjUid[0].uid; ilb.newItem.org_itm = ilb2.newItem.no; findCharactor(ilb.charactor).updataItemByNo(ilb.newItem); } } } } } }
public CharacterItemBean copyItemByNo(String charactor, int no, int itemid = -1, Boolean isTexReplaceAndCopyOri = false) //复制角色零件 { //复制item CharacterTbl chaTbl = findCharactor(charactor); CharacterItemBean newitem = new CharacterItemBean(chaTbl.findItemByNo(no)); String oriObjName = newitem.getObjsetName(allowTextureReplace); int oriMeshNum = objdb.getMeshId(oriObjName); String oriUid = objdb.getMeshName(oriObjName); newitem.name = newitem.name + " NEW"; String objsetName = ""; if (itemid == -1) { //添加普通角色配件 newitem.no = chaTbl.lastItemNo + 1; objsetName = objdb.getCharacterNameUpper(charactor, 1); } else { //添加通用配件,因为要指定编号 newitem.no = itemid; objsetName = "cmnitm" + itemid.ToString(); } //sub_id非1的都是纹理替换更新第二个objset,特殊情况attr=9不知道什么意思 if ((newitem.objsetLength == 1) || (!allowTextureReplace)) { newitem.objset[0].objset = objsetName.ToUpper(); } else { newitem.objset[1].objset = objsetName.ToUpper(); } if ((newitem.sub_id == 24) && (newitem.objsetLength == 2)) { //特殊处理 壱ノ桜・桜花顔 和 ctw 颜 String t = newitem.objset[0].objset; newitem.objset[0].objset = newitem.objset[1].objset; newitem.objset[1].objset = t; } if ((newitem.attr != 1) && (!allowTextureReplace)) { //不允许换色 if (newitem.sub_id == 24) { //脸,不能直接复制org_itm因为没有数据 //此外在copyFarc也要特殊处理 newitem.attr = 1; newitem.haveTexChg = false; newitem.haveTexOrg = false; newitem.haveTexLength = false; isTexReplaceAndCopyOri = true; } else { //复制原色零件 return(copyItemByNo(charactor, newitem.org_itm, itemid, true)); } } if (newitem.sub_id != 24) { String uid = objsetName + oriUid.Replace(oriObjName, "", StringComparison.InvariantCultureIgnoreCase); //避免meshname长度变化 if (uid.Length > oriUid.Length) { uid = uid.Substring(0, oriUid.Length); } if (uid.Length < oriUid.Length) { for (int i = uid.Length; i <= oriUid.Length - 1; i++) { uid = uid + "_"; } } newitem.dataObjUid[0].uid = uid.ToUpper(); } chaTbl.addItem(newitem); //复制objdb String newObjName = newitem.getObjsetName(allowTextureReplace); objdb.add(newObjName, objdb.lastId + 1, newObjName + "_obj.bin", newObjName + "_tex.bin", newObjName + ".farc", newitem.dataObjUid[0].uid, 0); logs.items.Add(new ItemLogBean(chaTbl.findItemByNo(no), oriMeshNum, newitem, charactor, isTexReplaceAndCopyOri)); return(newitem); }
private void doItem(string line) { int index = Int32.Parse(StringCut.splitPoint(line, 2)); if (itemList[index] == null) { itemList[index] = new CharacterItemBean(); } itemList[index].index = index; if (index > lastItemIndex) { lastItemIndex = index; } String key = StringCut.splitBeforeEqual(line); String value = StringCut.splitAfterEqual(line); //等号前第二段 String index1 = StringCut.splitPoint(StringCut.splitBeforeEqual(line, 2), 1); //处理col if (line.Contains(".col.")) { if (key.Equals("length")) { itemList[index].haveColLength = true; itemList[index].colLength = Int32.Parse(value); itemList[index].col = new ColBean[Int32.Parse(value)]; return; } itemList[index].haveCol = true; itemList[index].colOri.Add(line); return; } switch (key) { case "attr": itemList[index].attr = Int32.Parse(value); itemList[index].haveAttr = true; break; case "rpk": ObjRpkBean objrpk = new ObjRpkBean(); objrpk.index = Int32.Parse(index1); objrpk.rpk = Int32.Parse(value); itemList[index].dataObjRpk.Add(objrpk); itemList[index].haveRpk = true; break; case "uid": ObjUidBean objuid = new ObjUidBean(); objuid.index = Int32.Parse(index1); objuid.uid = value; itemList[index].dataObjUid.Add(objuid); itemList[index].haveUid = true; break; case "length": String lengthKey = StringCut.splitBeforeEqual(line, 2); switch (lengthKey) { case "obj.length": itemList[index].dataObjLength = Int32.Parse(value); itemList[index].haveObjLength = true; break; case "tex.length": itemList[index].dataTexLength = Int32.Parse(value); itemList[index].haveTexLength = true; break; case "objset.length": itemList[index].objsetLength = Int32.Parse(value); itemList[index].haveObjsetLength = true; break; default: Console.WriteLine(line); break; } break; case "chg": TexChgBean texchg = new TexChgBean(); texchg.index = Int32.Parse(index1); texchg.chg = value; itemList[index].dataTexChg.Add(texchg); itemList[index].haveTexChg = true; break; case "org": TexOrgBean texorg = new TexOrgBean(); texorg.index = Int32.Parse(index1); texorg.org = value; itemList[index].dataTexOrg.Add(texorg); itemList[index].haveTexOrg = true; break; case "des_id": itemList[index].des_id = Int32.Parse(value); itemList[index].haveDes_id = true; break; case "exclusion": itemList[index].exclusion = Int32.Parse(value); itemList[index].haveExclusion = true; break; case "face_depth": itemList[index].face_depth = double.Parse(value); itemList[index].haveFace_depth = true; break; case "flag": itemList[index].flag = Int32.Parse(value); itemList[index].haveFlag = true; break; case "name": itemList[index].name = value; itemList[index].haveName = true; break; case "no": itemList[index].no = Int32.Parse(value); itemList[index].haveNo = true; if (itemList[index].no > lastItemNo) { lastItemNo = itemList[index].no; } break; case "org_itm": itemList[index].org_itm = Int32.Parse(value); itemList[index].haveOrg_itm = true; break; case "point": itemList[index].point = Int32.Parse(value); itemList[index].havePoint = true; break; case "sub_id": itemList[index].sub_id = Int32.Parse(value); itemList[index].haveSub_id = true; break; case "type": itemList[index].type = Int32.Parse(value); itemList[index].haveType = true; break; case "npr_flag": itemList[index].npr_flag = Int32.Parse(value); itemList[index].haveNpr_flag = true; break; default: //数字 if (index1 == "objset") { ObjsetBean objset = new ObjsetBean(); //格式和别的行不同 objset.index = Int32.Parse(key); objset.objset = value; itemList[index].objset.Add(objset); itemList[index].haveObjset = true; } else { Console.WriteLine(line); } break; } }
public CharacterItemBean(CharacterItemBean old) { index = old.index; haveAttr = old.haveAttr; attr = old.attr; haveRpk = old.haveRpk; foreach (ObjRpkBean orb in old.dataObjRpk) { dataObjRpk.Add(new ObjRpkBean(orb)); } haveUid = old.haveUid; foreach (ObjUidBean oub in old.dataObjUid) { dataObjUid.Add(new ObjUidBean(oub)); } haveObjLength = old.haveObjLength; dataObjLength = old.dataObjLength; haveTexChg = old.haveTexChg; foreach (TexChgBean tcb in old.dataTexChg) { dataTexChg.Add(new TexChgBean(tcb)); } haveTexOrg = old.haveTexOrg; foreach (TexOrgBean tob in old.dataTexOrg) { dataTexOrg.Add(new TexOrgBean(tob)); } haveTexLength = old.haveTexLength; dataTexLength = old.dataTexLength; haveDes_id = old.haveDes_id; des_id = old.des_id; haveExclusion = old.haveExclusion; exclusion = old.exclusion; haveFace_depth = old.haveFace_depth; face_depth = old.face_depth; haveFlag = old.haveFlag; flag = old.flag; haveName = old.haveName; name = old.name; haveNo = old.haveNo; no = old.no; haveObjset = old.haveObjset; foreach (ObjsetBean ob in old.objset) { objset.Add(new ObjsetBean(ob)); } haveObjsetLength = old.haveObjsetLength; objsetLength = old.objsetLength; haveOrg_itm = old.haveOrg_itm; org_itm = old.org_itm; havePoint = old.havePoint; point = old.point; haveSub_id = old.haveSub_id; sub_id = old.sub_id; haveType = old.haveType; type = old.type; haveNpr_flag = old.haveNpr_flag; npr_flag = old.npr_flag; haveCol = old.haveCol; foreach (String s in old.colOri) { colOri.Add(s); } if (old.haveCol) { col = new ColBean[old.col.Length]; for (int i = 0; i <= old.col.Length - 1; i++) { col[i] = new ColBean(old.col[i]); } } haveColLength = old.haveColLength; colLength = old.colLength; }