protected void InitVars(ref CBaseArchetypeDef arch) { _BaseArchetypeDef = arch; Hash = arch.assetName; if (Hash.Hash == 0) { Hash = arch.name; } DrawableDict = arch.drawableDictionary; TextureDict = arch.textureDictionary; ClipDict = arch.clipDictionary; BBMin = arch.bbMin; BBMax = arch.bbMax; BSCenter = arch.bsCentre; BSRadius = arch.bsRadius; LodDist = arch.lodDist; }
public void Init(YtypFile ytyp, CBaseArchetypeDef arch) { Hash = arch.assetName; if (Hash.Hash == 0) { Hash = arch.name; } Ytyp = ytyp; BaseArchetype = arch; DrawableDict = arch.drawableDictionary; TextureDict = arch.textureDictionary; ClipDict = arch.clipDictionary; BBMin = arch.bbMin; BBMax = arch.bbMax; BSCenter = arch.bsCentre; BSRadius = arch.bsRadius; IsTimeArchetype = false; IsMloArchetype = false; LodDist = arch.lodDist; }
public void Init(YtypFile ytyp, ref CBaseArchetypeDef arch) { Ytyp = ytyp; InitVars(ref arch); }
public static void ConvertJson(FivemJson[] jsonfiles) { if (jsonfiles == null || jsonfiles.Length <= 0) { return; } Ytyp[] ytypfiles = new Ytyp[jsonfiles.Length]; Ymap[] ymapfiles = new Ymap[jsonfiles.Length]; for (int i = 0; i < jsonfiles.Length; i++) { ytypfiles[i] = new Ytyp(jsonfiles[i].filename.Replace(".json", ".ytyp.xml")); ytypfiles[i].CMapTypes.name = jsonfiles[i].filename.Replace(".json", ""); List <CBaseArchetypeDef> unresolved_arc = new List <CBaseArchetypeDef>(); foreach (FivemArchetype a in jsonfiles[i].archetypes) { CBaseArchetypeDef arc = new CBaseArchetypeDef(); //arc.lodDist = 0; arc.flags = 0; arc.specialAttribute = 0; arc.bbMin = a.aabbMin; arc.bbMax = a.aabbMax; arc.bsCentre = a.centroid; arc.bsRadius = a.radius; //arc.hdTextureDist = 0; arc.name = a.archetypeName; arc.textureDictionary = a.txdName; arc.clipDictionary = null; arc.drawableDictionary = null; arc.physicsDictionary = a.archetypeName; arc.assetType = assetType.ASSET_TYPE_DRAWABLE; arc.assetName = a.archetypeName; arc.extensions = null; arc.lodDist = 100 + (1.5f * arc.bsRadius); arc.hdTextureDist = 0.75f * arc.lodDist; if (a.archetypeName.StartsWith("0x") || a.txdName.StartsWith("0x")) { unresolved_arc.Add(arc); } else { ytypfiles[i].CMapTypes.archetypes.Add(arc); } } ymapfiles[i] = new Ymap(jsonfiles[i].filename.Replace(".json", ".ymap.xml")); ymapfiles[i].CMapData.name = jsonfiles[i].filename.Replace(".json", ""); Random rnd = new Random(); List <CEntityDef> unresolved_ent = new List <CEntityDef>(); foreach (FivemEntity e in jsonfiles[i].entities) { CEntityDef ent = new CEntityDef(); ent.archetypeName = e.archetypeName; ent.flags = 0; ent.guid = (uint)rnd.Next(); ent.position = e.position; ent.rotation = e.rotation; ent.scaleXY = 1; ent.scaleZ = 1; ent.parentIndex = -1; ent.lodDist = 100; ent.childLodDist = 0; ent.lodLevel = lodLevel.LODTYPES_DEPTH_ORPHANHD; ent.numChildren = 0; ent.priorityLevel = priorityLevel.PRI_REQUIRED; ent.extensions = null; ent.ambientOcclusionMultiplier = 255; ent.artificialAmbientOcclusion = 255; ent.tintValue = 0; if (e.archetypeName.StartsWith("0x")) { unresolved_ent.Add(ent); } else { ymapfiles[i].CMapData.entities.Add(ent); } } ymapfiles[i].UpdatelodDist(ytypfiles[i].CMapTypes.archetypes); ymapfiles[i].UpdateExtents(ytypfiles[i].CMapTypes.archetypes); ytypfiles[i].WriteXML().Save(ytypfiles[i].filename); Console.WriteLine("Saved " + ytypfiles[i].filename); ymapfiles[i].WriteXML().Save(ymapfiles[i].filename); Console.WriteLine("Saved " + ymapfiles[i].filename); if (unresolved_arc?.Any() ?? false) { string unresolvedname = ytypfiles[i].CMapTypes.name + "_unresolved"; ytypfiles[i].CMapTypes.archetypes = unresolved_arc; ytypfiles[i].CMapTypes.name = unresolvedname; ytypfiles[i].WriteXML().Save(unresolvedname + ".ymap.xml"); Console.WriteLine("Saved " + unresolvedname + ".ymap.xml"); } if (unresolved_ent?.Any() ?? false) { string unresolvedname = ymapfiles[i].CMapData.name + "_unresolved"; ymapfiles[i].CMapData.entities = unresolved_ent; ymapfiles[i].CMapData.name = unresolvedname; ymapfiles[i].WriteXML().Save(unresolvedname + ".ymap.xml"); Console.WriteLine("Saved " + unresolvedname + ".ymap.xml"); } } }