// Init iso, destroy first, collections, header are ready. public void Init(int version, VCESceneSetting setting, VAOption options) { // Destroy old data Destroy(); // Init header data m_HeadInfo = new VCIsoHeadData(); m_HeadInfo.Version = version; m_HeadInfo.Category = setting.m_Category; m_HeadInfo.Author = ""; m_HeadInfo.Name = ""; m_HeadInfo.Desc = ""; m_HeadInfo.Remarks = "<REMARKS />"; m_HeadInfo.xSize = setting.m_EditorSize.x; m_HeadInfo.ySize = setting.m_EditorSize.y; m_HeadInfo.zSize = setting.m_EditorSize.z; m_HeadInfo.IconTex = new byte [0]; m_HeadInfo.EnsureIconTexValid(); // Allocate material, voxel, component, color. m_Materials = new VAMaterial [MAT_ARR_CNT]; m_DecalAssets = new VCDecalAsset[DECAL_ARR_CNT]; m_Voxels = new Dictionary <int, VCVoxel> (); m_Components = new List <VCComponentData> (); m_Colors = new Dictionary <int, Color32> (); // Option m_Options = options; }
// Destroy iso, free memory. public void Destroy() { // Destroy header m_HeadInfo = new VCIsoHeadData(); // Material, voxel, component, color. DestroyMaterials(); m_Materials = null; DestroyDecalAssets(); m_DecalAssets = null; if (m_Voxels != null) { m_Voxels.Clear(); m_Voxels = null; } if (m_Components != null) { if (m_Options.ForEditor) { foreach (VCComponentData cdata in m_Components) { cdata.DestroyEntity(); } } m_Components.Clear(); m_Components = null; } if (m_Colors != null) { m_Colors.Clear(); m_Colors = null; } }
void SetWorkShopGridItemInfo(SteamPreFileAndVoteDetail del, UIWorkShopGridItem item) { if (item == null) { return; } item.gameObject.SetActive(true); if (del != null) { item.SetIsoName(del.m_rgchTitle); item.SetDownloaded(UIWorkShopCtrl.CheckDownloadExist(del.m_rgchTitle + VCConfig.s_IsoFileExt)); if (del.m_aPreFileData != null) { VCIsoHeadData headData = new VCIsoHeadData(); headData.SteamPreview = del.m_aPreFileData; item.SetAuthor(PELocalization.GetString(8000696)); Texture2D texture = new Texture2D(4, 4); texture.LoadImage(headData.IconTex); item.SetIco(texture); } else { item.SetIco(null); } } else { item.SetIco(null); item.SetIsoName(PELocalization.GetString(8000695)); item.SetAuthor(PELocalization.GetString(8000695)); } item.ActiveLoadingItem(false); }
void OnClickWorkShopItem(int index) { mSelectedDetail = null; if (!mMyWorkShopMgr.mIndexMap.ContainsKey(index)) { mVCERightPanel.SetActive(false); return; } PublishedFileId_t p_id = mMyWorkShopMgr.mIndexMap[index]; if (p_id.m_PublishedFileId == 0) { mVCERightPanel.SetActive(false); return; } SteamPreFileAndVoteDetail del; if (mMyWorkShopMgr.mItemsMap.ContainsKey(p_id)) { del = mMyWorkShopMgr.mItemsMap[p_id]; } else { del = null; } mSelectedDetail = del; if (del == null) { mVCERightPanel.SetActive(false); return; } mVCERightPanel.SetActive(true); VCIsoHeadData headData = new VCIsoHeadData(); headData.SteamPreview = del.m_aPreFileData; Texture2D texture = new Texture2D(4, 4); texture.LoadImage(headData.IconTex); mRinghtPanelCtrl.m_NonEditorIcon = headData.IconTex; mRinghtPanelCtrl.m_NonEditorISODesc = del.m_rgchDescription; mRinghtPanelCtrl.m_NonEditorISOName = del.m_rgchTitle; mRinghtPanelCtrl.m_NonEditorRemark = headData.Remarks; mRinghtPanelCtrl.m_NonEditorISOVersion = del.m_rgchTags;//Log: lz-2016.05.13 Add version field mRinghtPanelCtrl.SetIsoIcon(); mRinghtPanelCtrl.OnCreationInfoRefresh(); this.UpdateDeleteBtnState(); this.UpdateDownloadBtnState(); }
private static ItemProto GenItemData(VCIsoHeadData headData, int objId) { CreationAttr attribute = GetCreationAttr(headData.Remarks); // 0.9 id修改 转换检测 attribute.CheckCostId(); ItemProto item = CreationData.StaticGenItemData(objId, headData, attribute); return(item); }
// byte buffer public static int ExtractHeader(byte[] buffer, out VCIsoHeadData iso_header) { iso_header = new VCIsoHeadData(); if (buffer == null) { return(0); } using (MemoryStream ms = new MemoryStream(buffer)) { return(ExtractHeader(ms, out iso_header)); } }
// file public static int ExtractHeader(string filename, out VCIsoHeadData iso_header) { iso_header = new VCIsoHeadData(); if (!File.Exists(filename)) { return(0); } try { using (FileStream fs = File.Open(filename, FileMode.Open)) { return(ExtractHeader(fs, out iso_header)); } } catch (Exception) { return(0); } }
// // Member functions // // Reset iso, destroy first, collections are ready. public void Reset(VAOption options) { // Destroy old data Destroy(); // Set default header m_HeadInfo = new VCIsoHeadData(); m_HeadInfo.Author = ""; m_HeadInfo.Name = ""; m_HeadInfo.Desc = ""; m_HeadInfo.Remarks = "<REMARKS />"; m_HeadInfo.IconTex = new byte [0]; // Allocate material, voxel, component, color. m_Materials = new VAMaterial [MAT_ARR_CNT]; m_DecalAssets = new VCDecalAsset[DECAL_ARR_CNT]; m_Voxels = new Dictionary <int, VCVoxel> (); m_Components = new List <VCComponentData> (); m_Colors = new Dictionary <int, Color32> (); // Set options m_Options = options; }
public static ItemProto StaticGenItemData(int obj_id, VCIsoHeadData headinfo, CreationAttr attr) { if (attr.m_Type == ECreation.Null) { return(null); } ItemProto item = new ItemProto(); item.name = headinfo.Name; // item.nameStringId = 0; item.englishDescription = headinfo.Desc; item.itemLabel = 100; item.setUp = 0; item.resourcePath = AssetsLoader.InvalidAssetPath; item.resourcePath1 = AssetsLoader.InvalidAssetPath; item.equipReplacePos = 0; item.currencyValue = Mathf.CeilToInt(attr.m_SellPrice); item.currencyValue2 = Mathf.CeilToInt(attr.m_SellPrice); item.durabilityMax = Mathf.CeilToInt(attr.m_Durability); item.repairLevel = 1; item.maxStackNum = 1; item.equipSex = Pathea.PeSex.Undefined; item.id = obj_id; item.level = 1; item.repairMaterialList = new List <MaterialItem>(attr.m_Cost.Count); item.strengthenMaterialList = new List <MaterialItem>(attr.m_Cost.Count); Dictionary <int, int> repairItemDic = new Dictionary <int, int>(); foreach (KeyValuePair <int, int> kvp in attr.m_Cost) { if (kvp.Value != 0) { Replicator.Formula formula = Replicator.Formula.Mgr.Instance.FindByProductId(kvp.Key); int itemID = kvp.Key; int itemCount = kvp.Value; if (null == formula) { if (repairItemDic.ContainsKey(itemID)) { repairItemDic[itemID] += itemCount; } else { repairItemDic[itemID] = itemCount; } } else { for (int i = 0; i < formula.materials.Count; ++i) { itemID = formula.materials[i].itemId; itemCount = formula.materials[i].itemCount * Mathf.CeilToInt((float)kvp.Value / formula.m_productItemCount); if (repairItemDic.ContainsKey(itemID)) { repairItemDic[itemID] += itemCount; } else { repairItemDic[itemID] = itemCount; } } } } } foreach (KeyValuePair <int, int> kvp in repairItemDic) { int finalCount = kvp.Value / 2; if (finalCount > 0) { item.repairMaterialList.Add(new MaterialItem() { protoId = kvp.Key, count = finalCount }); item.strengthenMaterialList.Add(new MaterialItem() { protoId = kvp.Key, count = finalCount }); } } // [VCCase] - Generate item data, different types of creations switch (attr.m_Type) { // 剑 ------------------------ case ECreation.Sword: item.equipType = EquipType.Sword; item.icon = new string[3] { "0", "0", "0" }; item.equipPos = 16; item.itemClassId = (int)CreationItemClass.Sword; item.tabIndex = 1; item.sortLabel = 9910; //item.level = Mathf.Clamp((int)((attr.m_Attack - 8f) / 2.5f), 1, 100); item.durabilityFactor = 1f; item.editorTypeId = 4; if (item.propertyList == null) { item.propertyList = new ItemProto.PropertyList(); } item.propertyList.AddProperty(Pathea.AttribType.Atk, attr.m_Attack); item.buffId = 30200087; break; //双手与双持 case ECreation.SwordLarge: case ECreation.SwordDouble: item.icon = new string[3] { "0", "0", "0" }; item.equipPos = 528; item.itemClassId = (int)CreationItemClass.Sword; item.tabIndex = 1; item.sortLabel = 9910; //item.level = Mathf.Clamp((int)((attr.m_Attack - 8f) / 2.5f), 1, 100); item.durabilityFactor = 1f; item.editorTypeId = 4; if (item.propertyList == null) { item.propertyList = new ItemProto.PropertyList(); } item.propertyList.AddProperty(Pathea.AttribType.Atk, attr.m_Attack); item.buffId = 30200087; break; // 弓 ------------------------ case ECreation.Bow: item.equipType = EquipType.Bow; item.icon = new string[3] { "0", "0", "0" }; item.equipPos = 528; item.itemClassId = (int)CreationItemClass.Bow; item.tabIndex = 1; item.sortLabel = 9914; //item.level = Mathf.Clamp((int)((attr.m_Attack - 8f) / 2.5f), 1, 100); item.durabilityFactor = 1f; item.editorTypeId = 10; if (item.propertyList == null) { item.propertyList = new ItemProto.PropertyList(); } item.propertyList.AddProperty(Pathea.AttribType.Atk, attr.m_Attack); item.buffId = 30200087; break; // 斧 ------------------------ case ECreation.Axe: item.equipType = EquipType.Axe; item.icon = new string[3] { "0", "0", "0" }; item.equipPos = 16; item.itemClassId = (int)CreationItemClass.Axe; item.tabIndex = 1; item.sortLabel = 9912; //item.level = Mathf.Clamp((int)((attr.m_Attack - 8f) / 2.5f), 1, 100); item.durabilityFactor = 1f; item.editorTypeId = 7; if (item.propertyList == null) { item.propertyList = new ItemProto.PropertyList(); } item.propertyList.AddProperty(Pathea.AttribType.Atk, attr.m_Attack * WhiteCat.PEVCConfig.instance.axeAttackScale); item.propertyList.AddProperty(Pathea.AttribType.CutDamage, attr.m_Attack * WhiteCat.PEVCConfig.instance.axeCutDamageScale); item.propertyList.AddProperty(Pathea.AttribType.CutBouns, 0.03f); item.buffId = 30200092; break; // 盾 ------------------------ case ECreation.Shield: item.equipType = EquipType.Shield_Hand; item.icon = new string[3] { "0", "0", "0" }; item.equipPos = 512; item.itemClassId = (int)CreationItemClass.Shield; item.tabIndex = 1; item.sortLabel = 9920; //item.level = Mathf.Clamp((int)((attr.m_Defense + 2f) / 2f), 1, 100); item.durabilityFactor = 0.01f; item.editorTypeId = 9; if (item.propertyList == null) { item.propertyList = new ItemProto.PropertyList(); } item.propertyList.AddProperty(Pathea.AttribType.Def, attr.m_Defense); item.propertyList.AddProperty(Pathea.AttribType.ShieldMeleeProtect, Mathf.Clamp(attr.m_Defense / 330 + 0.2f, 0.2f, 0.87f)); item.buffId = 30200093; break; // 手枪/单手枪 ------------------------ case ECreation.HandGun: item.equipType = EquipType.HandGun; item.icon = new string[3] { "0", "0", "0" }; item.equipPos = 528; item.itemClassId = (int)CreationItemClass.HandGun; item.tabIndex = 1; item.sortLabel = 9930; //item.level = Mathf.Clamp((int)((attr.m_Attack - 4f) / 2f), 1, 70); item.durabilityFactor = 1f; if (item.propertyList == null) { item.propertyList = new ItemProto.PropertyList(); } item.propertyList.AddProperty(Pathea.AttribType.Atk, attr.m_Attack); item.buffId = 30200095; item.editorTypeId = 11; break; // 步枪/双手枪 ------------------------ case ECreation.Rifle: item.equipType = EquipType.Rifle; item.icon = new string[3] { "0", "0", "0" }; item.equipPos = 528; item.itemClassId = (int)CreationItemClass.Rifle; item.tabIndex = 1; item.sortLabel = 9940; //item.level = Mathf.Clamp((int)((attr.m_Attack - 4f) / 2f), 1, 70); item.durabilityFactor = 1f; if (item.propertyList == null) { item.propertyList = new ItemProto.PropertyList(); } item.propertyList.AddProperty(Pathea.AttribType.Atk, attr.m_Attack); item.buffId = 30200095; item.editorTypeId = 11; break; // 车 ------------------------ case ECreation.Vehicle: item.equipType = EquipType.Null; item.icon = new string[3] { "0", "leftup_putdown", "0" }; item.equipPos = 0; item.itemClassId = (int)CreationItemClass.Vehicle; item.tabIndex = 0; item.sortLabel = 9950; //item.level = CalcCarrierLevel(attr.m_Durability); if (item.propertyList == null) { item.propertyList = new ItemProto.PropertyList(); } item.propertyList.AddProperty(Pathea.AttribType.HpMax, attr.m_Durability); item.propertyList.AddProperty(Pathea.AttribType.Hp, attr.m_Durability); item.engergyMax = (int)attr.m_MaxFuel; break; // 飞机 ------------------------ case ECreation.Aircraft: item.equipType = EquipType.Null; item.icon = new string[3] { "0", "leftup_putdown", "0" }; item.equipPos = 0; item.itemClassId = (int)CreationItemClass.Aircraft; item.tabIndex = 0; item.sortLabel = 9960; //item.level = CalcCarrierLevel(attr.m_Durability); if (item.propertyList == null) { item.propertyList = new ItemProto.PropertyList(); } item.propertyList.AddProperty(Pathea.AttribType.HpMax, attr.m_Durability); item.propertyList.AddProperty(Pathea.AttribType.Hp, attr.m_Durability); item.engergyMax = (int)attr.m_MaxFuel; break; // 船 ------------------------ case ECreation.Boat: item.equipType = EquipType.Null; item.icon = new string[3] { "0", "leftup_putdown", "0" }; item.equipPos = 0; item.itemClassId = (int)CreationItemClass.Boat; item.tabIndex = 0; item.sortLabel = 9970; //item.level = CalcCarrierLevel(attr.m_Durability); if (item.propertyList == null) { item.propertyList = new ItemProto.PropertyList(); } item.propertyList.AddProperty(Pathea.AttribType.HpMax, attr.m_Durability); item.propertyList.AddProperty(Pathea.AttribType.Hp, attr.m_Durability); item.engergyMax = (int)attr.m_MaxFuel; break; // 简单物体 ------------------------ case ECreation.SimpleObject: item.equipType = EquipType.Null; item.icon = new string[3] { "0", "leftup_putdown", "0" }; item.equipPos = 0; item.itemClassId = (int)CreationItemClass.SimpleObject; item.sortLabel = 9980; item.tabIndex = 0; if (item.propertyList == null) { item.propertyList = new ItemProto.PropertyList(); } item.propertyList.AddProperty(Pathea.AttribType.HpMax, attr.m_Durability); item.propertyList.AddProperty(Pathea.AttribType.Hp, attr.m_Durability); break; // 装甲 ------------------------ case ECreation.ArmorHead: case ECreation.ArmorBody: case ECreation.ArmorArmAndLeg: case ECreation.ArmorHandAndFoot: case ECreation.ArmorDecoration: item.equipType = EquipType.Null; item.icon = new string[3] { "0", "0", "0" }; item.equipPos = 0; item.itemClassId = (int)CreationItemClass.Armor; item.sortLabel = 9990 + (int)attr.m_Type; item.tabIndex = 3; item.durabilityFactor = 0.01f; break; // 机器人 ------------------------ case ECreation.Robot: item.equipType = EquipType.Null; item.icon = new string[3] { "0", "leftup_putdown", "0" }; item.equipPos = 0; item.itemClassId = (int)CreationItemClass.Robot; item.tabIndex = 0; item.sortLabel = 9945; if (item.propertyList == null) { item.propertyList = new ItemProto.PropertyList(); } item.propertyList.AddProperty(Pathea.AttribType.HpMax, attr.m_Durability); item.propertyList.AddProperty(Pathea.AttribType.Hp, attr.m_Durability); item.engergyMax = (int)attr.m_MaxFuel; break; // 炮台 ------------------------ case ECreation.AITurret: item.equipType = EquipType.Null; item.icon = new string[3] { "0", "leftup_putdown", "0" }; item.equipPos = 0; item.itemClassId = (int)CreationItemClass.AITurret; item.tabIndex = 0; item.sortLabel = 9946; if (item.propertyList == null) { item.propertyList = new ItemProto.PropertyList(); } item.propertyList.AddProperty(Pathea.AttribType.HpMax, attr.m_Durability); item.propertyList.AddProperty(Pathea.AttribType.Hp, attr.m_Durability); item.engergyMax = (int)attr.m_MaxFuel; item.unchargeable = attr.m_Defense < 0.5f; break; default: item.equipType = EquipType.Null; item.icon = new string[3] { "0", "0", "0" }; item.equipPos = 0; item.sortLabel = 10000; item.tabIndex = 0; break; } return(item); }
// Extract Header // stream private static int ExtractHeader(Stream stream, out VCIsoHeadData iso_header) { iso_header = new VCIsoHeadData(); int size = 0; try { BinaryReader r = new BinaryReader(stream); // Header string check_str = r.ReadString(); // r, string if (check_str != "VCISO") { stream.Close(); return(0); } int l = 0; iso_header.Version = r.ReadInt32(); // r, int iso_header.Category = (EVCCategory)(r.ReadInt32()); // r, int string author = ""; if (iso_header.Version >= 0x02020000) { author = r.ReadString(); } iso_header.Name = r.ReadString(); // r, string iso_header.Desc = r.ReadString(); // r, string string remarks = ""; if (iso_header.Version >= 0x02020000) { remarks = r.ReadString(); } iso_header.xSize = r.ReadInt32(); // r, int iso_header.ySize = r.ReadInt32(); // r, int iso_header.zSize = r.ReadInt32(); // r, int l = r.ReadInt32(); // r, int iso_header.IconTex = r.ReadBytes(l); // r, byte[] size = (int)(stream.Length); stream.Close(); iso_header.Author = ""; iso_header.Remarks = ""; if (iso_header.Version >= 0x02020000) { for (int c = 0; c < author.Length; ++c) { iso_header.Author += (char)(author[c] ^ (char)(0xAC)); } for (int c = 0; c < remarks.Length; ++c) { iso_header.Remarks += (char)(remarks[c] ^ (char)(0xAC)); } } if (iso_header.Name.Length > 256) { return(0); } if (iso_header.Desc.Length > 2048) { return(0); } if (iso_header.Author.Length > 256) { return(0); } if (iso_header.Remarks.Length > 8192) { return(0); } if (iso_header.xSize < 0) { return(0); } if (iso_header.xSize >= 512) { return(0); } if (iso_header.ySize < 0) { return(0); } if (iso_header.ySize >= 512) { return(0); } if (iso_header.zSize < 0) { return(0); } if (iso_header.zSize >= 512) { return(0); } } catch (Exception) { return(0); } iso_header.EnsureIconTexValid(); return(size); }