Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using Newtonsoft.Json.Linq;
- namespace MiniPlacement
- {
- class Program
- {
- static void Main(string[] args)
- {
- var ideMapping = new Dictionary<string, string[]>();
- //var sourceIde = @"Y:\dev\ydr\speed2\nj_liberty.ide";
- var sourceIde = @"Y:\dls\gta_ldn\gta_ldn.ide";
- // read the source IDE
- var lines = File.ReadAllLines(sourceIde);
- var inObjs = false;
- foreach (var line in lines)
- {
- if (line == "objs")
- {
- inObjs = true;
- }
- else if (inObjs)
- {
- if (line == "end")
- {
- break;
- }
- var bits = line.Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
- if (bits.Last() == "null")
- {
- ideMapping[bits[0].ToLower()] = bits;
- }
- }
- }
- // read the source IPLs
- var sourceIPLs = Directory.GetFiles(@"Y:\dls\gta_ldn", "*.opl");
- var iplMapping = new List<string[]>();
- foreach (var ipl in sourceIPLs)
- {
- lines = File.ReadAllLines(ipl);
- inObjs = false;
- foreach (var line in lines)
- {
- if (line == "inst")
- {
- inObjs = true;
- }
- else if (inObjs)
- {
- if (line == "end")
- {
- break;
- }
- var bits = line.Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
- if (ideMapping.ContainsKey(bits[7].ToLower()) || bits[7].StartsWith("hash:"))
- {
- iplMapping.Add(bits);
- }
- }
- }
- }
- // write the object
- var jo = new JObject();
- jo["$schema"] = "schema.json";
- var archetypes = new JArray();
- jo["archetypes"] = archetypes;
- foreach (var entry in ideMapping)
- {
- var at = new JObject();
- at["aabbMin"] = new JArray() { float.Parse(entry.Value[5]), float.Parse(entry.Value[6]), float.Parse(entry.Value[7]) };
- at["aabbMax"] = new JArray() { float.Parse(entry.Value[8]), float.Parse(entry.Value[9]), float.Parse(entry.Value[10]) };
- at["centroid"] = new JArray() { float.Parse(entry.Value[11]), float.Parse(entry.Value[12]), float.Parse(entry.Value[13]) };
- at["radius"] = float.Parse(entry.Value[14]);
- at["archetypeName"] = entry.Value[0];
- at["txdName"] = entry.Value[1];
- archetypes.Add(at);
- }
- var entities = new JArray();
- jo["entities"] = entities;
- foreach (var entry in iplMapping)
- {
- var et = new JObject();
- et["position"] = new JArray() { float.Parse(entry[0]), float.Parse(entry[1]), float.Parse(entry[2]) };
- et["rotation"] = new JArray() { float.Parse(entry[3]), float.Parse(entry[4]), float.Parse(entry[5]), float.Parse(entry[6]) };
- et["guid"] = Guid.NewGuid().ToString();
- et["archetypeName"] = entry[7];
- entities.Add(et);
- }
- File.WriteAllText(@"X:\gta\iv\citizenmp\citizenmp\bin\five\debug\citizen\common\data\levels\gta5\london.json", jo.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement