read ENEX section of IPL files

This commit is contained in:
in0finite 2019-10-21 01:54:52 +02:00
parent b3d082dbe2
commit a3f73edef8
4 changed files with 77 additions and 0 deletions

View file

@ -10,6 +10,9 @@ namespace SanAndreasUnity.Importing.Items
{
private static readonly List<Zone> _zones = new List<Zone>();
private static readonly List<EntranceExit> _enexes = new List<EntranceExit>();
public static List<EntranceExit> Enexes => _enexes;
private static readonly Dictionary<int, IObjectDefinition> _definitions
= new Dictionary<int, IObjectDefinition>();
@ -73,6 +76,11 @@ namespace SanAndreasUnity.Importing.Items
_zones.Add(zone);
}
foreach (var enex in file.GetSection<EntranceExit>("enex"))
{
_enexes.Add(enex);
}
var insts = file.GetSection<Instance>("inst");
var list = new List<Instance>();

View file

@ -81,6 +81,17 @@ namespace SanAndreasUnity.Importing.Items
{
return double.Parse(_parts[index], CultureInfo.InvariantCulture);
}
public UnityEngine.Vector3 GetUnityVec3(ref int index, bool invertYAndZ)
{
float x = GetSingle(index++);
float y = GetSingle(index++);
float z = GetSingle(index++);
if (invertYAndZ)
return new UnityEngine.Vector3(x, z, y);
else
return new UnityEngine.Vector3(x, y, z);
}
}
public abstract class Definition : ItemBase

View file

@ -0,0 +1,47 @@

namespace SanAndreasUnity.Importing.Items.Placements
{
[System.Flags]
public enum EnexFlags
{
}
[Section("enex")]
public class EntranceExit : Placement
{
public readonly UnityEngine.Vector3 EntrancePos;
public readonly float EntranceAngle;
public readonly UnityEngine.Vector3 Size;
public readonly UnityEngine.Vector3 ExitPos;
public readonly float ExitAngle;
public readonly int TargetInterior;
public readonly int Flags;
public readonly string Name;
public readonly int SkyColorType;
public readonly int NumPedsToSpawn;
public readonly int TimeOn;
public readonly int TimeOff;
public EntranceExit(string line) : base(line)
{
int index = 0;
EntrancePos = GetUnityVec3(ref index, true);
EntranceAngle = GetSingle(index++);
Size = GetUnityVec3(ref index, false);
ExitPos = GetUnityVec3(ref index, true);
ExitAngle = GetSingle(index++);
TargetInterior = GetInt(index++);
Flags = GetInt(index++);
Name = GetString(index++);
SkyColorType = GetInt(index++);
NumPedsToSpawn = GetInt(index++);
TimeOn = GetInt(index++);
TimeOff = GetInt(index++);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3b56ab0ea20be4d438e6a42402140ad2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: