Skip to content

Commit

Permalink
Fixes + Add ymap parentIndex support + add FXC stuff by dexyfex
Browse files Browse the repository at this point in the history
  • Loading branch information
indilo53 committed Jun 26, 2019
1 parent 17ffdb7 commit adfca39
Show file tree
Hide file tree
Showing 19 changed files with 2,981 additions and 91 deletions.
26 changes: 20 additions & 6 deletions RageLib.GTA5/RageLib.GTA5.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="HtmlAgilityPack, Version=1.8.5.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.8.5\lib\Net45\HtmlAgilityPack.dll</HintPath>
<Reference Include="HtmlAgilityPack, Version=1.11.4.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.11.4\lib\Net45\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="SharpDX, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.4.1.0\lib\net45\SharpDX.dll</HintPath>
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll</HintPath>
</Reference>
<Reference Include="SharpDX.Mathematics, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.Mathematics.4.1.0\lib\net45\SharpDX.Mathematics.dll</HintPath>
<Reference Include="SharpDX.D3DCompiler, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.D3DCompiler.4.2.0\lib\net45\SharpDX.D3DCompiler.dll</HintPath>
</Reference>
<Reference Include="SharpDX.Direct3D11, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.Direct3D11.4.2.0\lib\net45\SharpDX.Direct3D11.dll</HintPath>
</Reference>
<Reference Include="SharpDX.DXGI, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.DXGI.4.2.0\lib\net45\SharpDX.DXGI.dll</HintPath>
</Reference>
<Reference Include="SharpDX.Mathematics, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.Mathematics.4.2.0\lib\net45\SharpDX.Mathematics.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -208,6 +217,7 @@
<Compile Include="Resources\PC\Drawables\Unknown_D_001.cs" />
<Compile Include="Resources\PC\Drawables\VertexBuffer.cs" />
<Compile Include="Resources\PC\Drawables\VertexDeclaration.cs" />
<Compile Include="Resources\PC\Drawables\VertexTypes.cs" />
<Compile Include="Resources\PC\Expressions\Expression.cs" />
<Compile Include="Resources\PC\Expressions\ExpressionDictionary.cs" />
<Compile Include="Resources\PC\Expressions\Unknown_E_001.cs" />
Expand All @@ -231,10 +241,13 @@
<Compile Include="Resources\PC\Fragments\Unknown_F_002.cs" />
<Compile Include="Resources\PC\Fragments\Unknown_F_003.cs" />
<Compile Include="Resources\PC\Fragments\Unknown_F_004.cs" />
<Compile Include="Resources\PC\GameFiles\FxcFile.cs" />
<Compile Include="Resources\PC\GameFiles\FxcParser.cs" />
<Compile Include="Resources\PC\GameFiles\GameFileBase.cs" />
<Compile Include="Resources\PC\GameFiles\Gxt2File.cs" />
<Compile Include="Resources\PC\GameFiles\YbnFile.cs" />
<Compile Include="Resources\PC\GameFiles\YddFile.cs" />
<Compile Include="Resources\PC\GameFiles\TxdFile.cs" />
<Compile Include="Resources\PC\GameFiles\YdrFile.cs" />
<Compile Include="Resources\PC\GameFiles\YmtPedDefinitionFile.cs" />
<Compile Include="Resources\PC\GameFiles\YtypFile.cs" />
Expand Down Expand Up @@ -461,6 +474,7 @@
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ public static void WriteItemArray<T>(StringBuilder sb, T[] arr, int ind, string

public static string FormatHash(MetaName h) //for use with WriteItemArray
{
var str = h.ToString();
if (!string.IsNullOrEmpty(str)) return str;
return HashString(h);// "hash_" + h.Hex;
}
public static string FormatVector2(Vector2 v) //for use with WriteItemArray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public override void Build(MetaBuilder mb, bool isRoot = false)
this.MetaStructure.version = this.Version;
this.MetaStructure.flags = this.Flags;
this.MetaStructure.name = mb.AddStringPtr(this.Name);
this.MetaStructure.exportedBy = mb.AddStringPtr(this.ExportedBy);
this.MetaStructure.owner = mb.AddStringPtr(this.Owner);
this.MetaStructure.exportedBy = mb.AddStringPtr("GTAUtil");
this.MetaStructure.owner = mb.AddStringPtr(this.Owner);
this.MetaStructure.time = mb.AddStringPtr(this.Time);

MCBlockDesc.AddEnumAndStructureInfo(mb);
Expand Down
180 changes: 157 additions & 23 deletions RageLib.GTA5/ResourceWrappers/PC/Meta/Structures/MCEntityDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,122 @@ public class MCEntityDef : MetaStructureWrapper<CEntityDef>
public Vector4 Rotation;
public float ScaleXY;
public float ScaleZ;
public int ParentIndex;
public float LodDist;

public int _ParentIndex;

public int ParentIndex
{
get
{
return this._ParentIndex;
}
set
{
this._ParentIndex = value;

if(this.Parent != null)
{
if (this._ParentEntity != null && this._ParentEntity.Children.IndexOf(this) != -1)
{
this._ParentEntity.Children.Remove(this);
this._ParentEntity.NumChildren = (uint)this._ParentEntity.Children.Count;
}

if (value == -1)
{
this._ParentEntity = null;
}
else
{
var ymapEntity = this.Parent.Entities.Count > value ? this.Parent.Entities[value] : null;
var parentYmapEntity = this.Parent?.ParentMapData?.Entities.Count > value ? this.Parent.ParentMapData.Entities[value] : null;
var lodLevel = MCMapData.LodLevels.IndexOf(this.LodLevel);

bool found = false;

if (ymapEntity != null)
{
var ymapEntityLodLevel = MCMapData.LodLevels.IndexOf(ymapEntity.LodLevel);

if (ymapEntityLodLevel < lodLevel)
{
found = true;
this._ParentEntity = ymapEntity;
}
}

if(!found && parentYmapEntity != null)
{
var parentYmapEntityLodLevel = MCMapData.LodLevels.IndexOf(parentYmapEntity.LodLevel);

if (parentYmapEntityLodLevel < lodLevel)
{
found = true;
this._ParentEntity = parentYmapEntity;
}
}

if(!found)
{
this._ParentEntity = null;
}

}

if (this._ParentEntity != null && this._ParentEntity.Children.IndexOf(this) == -1)
{
this._ParentEntity.Children.Add(this);
this._ParentEntity.NumChildren = (uint)this._ParentEntity.Children.Count;
}
}
}
}

public float LodDist;
public float ChildLodDist;
public Unk_1264241711 LodLevel;
public uint NumChildren;
public Unk_648413703 PriorityLevel;
public Array_StructurePointer Extensions;

public MCMapData Parent;
public MCEntityDef _ParentEntity = null;

public MCEntityDef ParentEntity
{
get
{
return this._ParentEntity;
}
set
{
if (this._ParentEntity != null && this.ParentEntity.Children.IndexOf(this) != -1)
{
this._ParentEntity.Children.Remove(this);
this._ParentEntity.NumChildren = (uint)this._ParentEntity.Children.Count;
}

this._ParentEntity = value;

if (value == null)
{
this._ParentIndex = -1;
}
else
{
this._ParentIndex = value.Parent.Entities.IndexOf(value);
}

if (this._ParentEntity != null && this.ParentEntity.Children.IndexOf(this) == -1)
{
this._ParentEntity.Children.Add(this);
this._ParentEntity.NumChildren = (uint) this._ParentEntity.Children.Count;
}
}
}

public List<MCEntityDef> Children = new List<MCEntityDef>();

//Extensions
public List<MCExtensionDefLightEffect> ExtensionDefLightEffect = new List<MCExtensionDefLightEffect>();
public List<MCExtensionDefSpawnPointOverride> ExtensionDefSpawnPointOverride = new List<MCExtensionDefSpawnPointOverride>();
Expand All @@ -35,10 +143,12 @@ public class MCEntityDef : MetaStructureWrapper<CEntityDef>
public uint TintValue;


public MCEntityDef()
public MCEntityDef(MCMapData parent = null)
{
this.MetaName = MetaName.CEntityDef;
this.MetaStructure = new CEntityDef();

this.Parent = parent;
}

public static void AddEnumAndStructureInfo(MetaBuilder mb)
Expand All @@ -52,27 +162,26 @@ public static void AddEnumAndStructureInfo(MetaBuilder mb)
}


public override void Parse(MetaFile meta, CEntityDef CEntityDef)
{
this.Meta = meta;
this.MetaStructure = CEntityDef;

this.ArchetypeName = CEntityDef.archetypeName;
this.Flags = CEntityDef.flags;
this.Guid = CEntityDef.guid;
this.Position = CEntityDef.position;
this.Rotation = CEntityDef.rotation;
this.ScaleXY = CEntityDef.scaleXY;
this.ScaleZ = CEntityDef.scaleZ;
this.ParentIndex = CEntityDef.parentIndex;
this.LodDist = CEntityDef.lodDist;
this.ChildLodDist = CEntityDef.childLodDist;
this.LodLevel = CEntityDef.lodLevel;
this.NumChildren = CEntityDef.numChildren;
this.PriorityLevel = CEntityDef.priorityLevel;
public override void Parse(MetaFile meta, CEntityDef CEntityDef)
{
this.Meta = meta;
this.MetaStructure = CEntityDef;

this.ArchetypeName = CEntityDef.archetypeName;
this.Flags = CEntityDef.flags;
this.Guid = CEntityDef.guid;
this.Position = CEntityDef.position;
this.Rotation = CEntityDef.rotation;
this.ScaleXY = CEntityDef.scaleXY;
this.ScaleZ = CEntityDef.scaleZ;
this.ParentIndex = CEntityDef.parentIndex;
this.LodDist = CEntityDef.lodDist;
this.ChildLodDist = CEntityDef.childLodDist;
this.LodLevel = CEntityDef.lodLevel;
this.NumChildren = CEntityDef.numChildren;
this.PriorityLevel = CEntityDef.priorityLevel;

// Extensions

var extptrs = MetaUtils.GetPointerArray(meta, CEntityDef.extensions);

if(extptrs != null)
Expand Down Expand Up @@ -130,7 +239,32 @@ public override void Parse(MetaFile meta, CEntityDef CEntityDef)
this.TintValue = CEntityDef.tintValue;
}

public override void Build(MetaBuilder mb, bool isRoot = false)
public void ParseWithoutExtensions(MetaFile meta, CEntityDef CEntityDef)
{
this.Meta = meta;
this.MetaStructure = CEntityDef;

this.ArchetypeName = CEntityDef.archetypeName;
this.Flags = CEntityDef.flags;
this.Guid = CEntityDef.guid;
this.Position = CEntityDef.position;
this.Rotation = CEntityDef.rotation;
this.ScaleXY = CEntityDef.scaleXY;
this.ScaleZ = CEntityDef.scaleZ;
this.ParentIndex = CEntityDef.parentIndex;
this.LodDist = CEntityDef.lodDist;
this.ChildLodDist = CEntityDef.childLodDist;
this.LodLevel = CEntityDef.lodLevel;
this.NumChildren = CEntityDef.numChildren;
this.PriorityLevel = CEntityDef.priorityLevel;

this.AmbientOcclusionMultiplier = CEntityDef.ambientOcclusionMultiplier;
this.ArtificialAmbientOcclusion = CEntityDef.artificialAmbientOcclusion;
this.TintValue = CEntityDef.tintValue;
}


public override void Build(MetaBuilder mb, bool isRoot = false)
{
this.MetaStructure.archetypeName = this.ArchetypeName;
this.MetaStructure.flags = this.Flags;
Expand Down
Loading

0 comments on commit adfca39

Please sign in to comment.