public void ReadEntities(JObject json) { if (json["entities"] != null && json["entities"].Any()) { foreach (JToken e in json["entities"]) { FivemEntity entity = new FivemEntity(); var pos = e["position"]; if (pos != null) { entity.position = new Vector3( float.Parse(pos[0].ToString()), float.Parse(pos[1].ToString()), float.Parse(pos[2].ToString())); } var rot = e["rotation"]; if (rot != null) { entity.rotation = new Quaternion( float.Parse(rot[0].ToString()), float.Parse(rot[1].ToString()), float.Parse(rot[2].ToString()), float.Parse(rot[3].ToString())); } var name = e["archetypeName"]; if (name != null) { string namestring = name.ToString(); if (!namestring.StartsWith("hash:", StringComparison.Ordinal)) { hashes[Jenkin.GenHash(namestring)] = namestring; } entity.archetypeName = namestring; } entities.Add(entity); } } }
public void ReadArchetypes(JObject json) { if (json["archetypes"] != null && json["archetypes"].Any()) { foreach (JToken a in json["archetypes"]) { FivemArchetype archetype = new FivemArchetype(); var bbmin = a["aabbMin"]; if (bbmin != null) { archetype.aabbMin = new Vector3( float.Parse(bbmin[0].ToString()), float.Parse(bbmin[1].ToString()), float.Parse(bbmin[2].ToString())); } var bbmax = a["aabbMax"]; if (bbmax != null) { archetype.aabbMax = new Vector3( float.Parse(bbmax[0].ToString()), float.Parse(bbmax[1].ToString()), float.Parse(bbmax[2].ToString())); } var rd = a["radius"]; if (rd != null) { archetype.radius = float.Parse(rd.ToString()); } var center = a["centroid"]; if (center != null) { archetype.centroid = new Vector3( float.Parse(center[0].ToString()), float.Parse(center[1].ToString()), float.Parse(center[2].ToString())); } var name = a["archetypeName"]; if (name != null) { string namestring = name.ToString(); if (!namestring.StartsWith("hash:", StringComparison.Ordinal)) { hashes[Jenkin.GenHash(namestring)] = namestring; } archetype.archetypeName = namestring; } var txd = a["txdName"]; if (txd != null) { string txdstring = txd.ToString(); if (!txdstring.StartsWith("hash:", StringComparison.Ordinal)) { hashes[Jenkin.GenHash(txdstring)] = txdstring; } archetype.txdName = txdstring; } archetypes.Add(archetype); } } }