mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2025-02-03 19:33:07 +08:00
MloInstance saving fixes, hashes replaced with field names for CMloInstanceDef. Move and rotate MloInstance now works properly.
This commit is contained in:
parent
8ec5113a1c
commit
c9fb099db7
@ -334,10 +334,10 @@ namespace CodeWalker.GameFiles
|
|||||||
for (int i = 0; i < CMloInstanceDefs.Length; i++)
|
for (int i = 0; i < CMloInstanceDefs.Length; i++)
|
||||||
{
|
{
|
||||||
YmapEntityDef d = new YmapEntityDef(this, i, ref CMloInstanceDefs[i]);
|
YmapEntityDef d = new YmapEntityDef(this, i, ref CMloInstanceDefs[i]);
|
||||||
uint[] unkuints = MetaTypes.GetUintArray(Meta, CMloInstanceDefs[i].Unk_1407157833);
|
uint[] defentsets = MetaTypes.GetUintArray(Meta, CMloInstanceDefs[i].defaultEntitySets);
|
||||||
if (d.MloInstance != null)
|
if (d.MloInstance != null)
|
||||||
{
|
{
|
||||||
d.MloInstance.Unk_1407157833 = unkuints;
|
d.MloInstance.defaultEntitySets = defentsets;
|
||||||
}
|
}
|
||||||
alldefs.Add(d);
|
alldefs.Add(d);
|
||||||
mlodefs.Add(d);
|
mlodefs.Add(d);
|
||||||
@ -520,22 +520,39 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
public void BuildCEntityDefs()
|
public void BuildCEntityDefs()
|
||||||
{
|
{
|
||||||
//recreates the CEntityDefs array from AllEntities.
|
//recreates the CEntityDefs and CMloInstanceDefs arrays from AllEntities.
|
||||||
|
CEntityDefs = null;
|
||||||
|
CMloInstanceDefs = null;
|
||||||
if (AllEntities == null)
|
if (AllEntities == null)
|
||||||
{
|
{
|
||||||
CEntityDefs = null;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = AllEntities.Length;
|
|
||||||
CEntityDefs = new CEntityDef[count];
|
List<CEntityDef> centdefs = new List<CEntityDef>();
|
||||||
for (int i = 0; i < count; i++)
|
List<CMloInstanceDef> cmlodefs = new List<CMloInstanceDef>();
|
||||||
|
|
||||||
|
for (int i = 0; i < AllEntities.Length; i++)
|
||||||
{
|
{
|
||||||
CEntityDefs[i] = AllEntities[i].CEntityDef;
|
var ent = AllEntities[i];
|
||||||
|
if (ent.MloInstance != null)
|
||||||
|
{
|
||||||
|
cmlodefs.Add(ent.MloInstance.Instance);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
centdefs.Add(ent.CEntityDef);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: MloInstanceDefs!
|
if (centdefs.Count > 0)
|
||||||
|
{
|
||||||
|
CEntityDefs = centdefs.ToArray();
|
||||||
|
}
|
||||||
|
if (cmlodefs.Count > 0)
|
||||||
|
{
|
||||||
|
CMloInstanceDefs = cmlodefs.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void BuildCCarGens()
|
public void BuildCCarGens()
|
||||||
{
|
{
|
||||||
@ -560,7 +577,7 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
|
|
||||||
//since Ymap object contents have been modified, need to recreate the arrays which are what is saved.
|
//since Ymap object contents have been modified, need to recreate the arrays which are what is saved.
|
||||||
BuildCEntityDefs();
|
BuildCEntityDefs(); //technically this isn't required anymore since the CEntityDefs is no longer used for saving.
|
||||||
BuildCCarGens();
|
BuildCCarGens();
|
||||||
|
|
||||||
|
|
||||||
@ -583,34 +600,35 @@ namespace CodeWalker.GameFiles
|
|||||||
CMapData mapdata = CMapData;
|
CMapData mapdata = CMapData;
|
||||||
|
|
||||||
|
|
||||||
if (CEntityDefs != null)
|
|
||||||
|
if ((AllEntities != null) && (AllEntities.Length > 0))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < CEntityDefs.Length; i++)
|
for (int i = 0; i < AllEntities.Length; i++)
|
||||||
{
|
{
|
||||||
var yent = AllEntities[i]; //save the extensions..
|
var ent = AllEntities[i]; //save the extensions first..
|
||||||
CEntityDefs[i].extensions = mb.AddWrapperArrayPtr(yent.Extensions);
|
ent._CEntityDef.extensions = mb.AddWrapperArrayPtr(ent.Extensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaPOINTER[] ptrs = new MetaPOINTER[AllEntities.Length];
|
||||||
|
for (int i = 0; i < AllEntities.Length; i++)
|
||||||
|
{
|
||||||
|
var ent = AllEntities[i];
|
||||||
|
if (ent.MloInstance != null)
|
||||||
|
{
|
||||||
|
ptrs[i] = mb.AddItemPtr(MetaName.CMloInstanceDef, ent.MloInstance.Instance);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ptrs[i] = mb.AddItemPtr(MetaName.CEntityDef, ent.CEntityDef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mapdata.entities = mb.AddPointerArray(ptrs);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
|
||||||
MetaPOINTER[] ptrs = new MetaPOINTER[AllEntities.Length];
|
|
||||||
|
|
||||||
for (int i = 0; i < AllEntities.Length; i++)
|
|
||||||
{
|
{
|
||||||
if (AllEntities[i].MloInstance != null)
|
mapdata.entities = new Array_StructurePointer();
|
||||||
{
|
|
||||||
ptrs[i] = mb.AddItemPtr(MetaName.CMloInstanceDef, AllEntities[i].MloInstance.Instance);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ptrs[i] = mb.AddItemPtr(MetaName.CEntityDef, AllEntities[i].CEntityDef);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mapdata.entities = mb.AddPointerArray(ptrs);
|
|
||||||
|
|
||||||
//mapdata.entities = mb.AddItemPointerArrayPtr(MetaName.CEntityDef, CEntityDefs);
|
|
||||||
|
|
||||||
mapdata.timeCycleModifiers = mb.AddItemArrayPtr(MetaName.CTimeCycleModifier, CTimeCycleModifiers);
|
mapdata.timeCycleModifiers = mb.AddItemArrayPtr(MetaName.CTimeCycleModifier, CTimeCycleModifiers);
|
||||||
|
|
||||||
mapdata.physicsDictionaries = mb.AddHashArrayPtr(physicsDictionaries);
|
mapdata.physicsDictionaries = mb.AddHashArrayPtr(physicsDictionaries);
|
||||||
@ -1262,6 +1280,7 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
if (MloInstance != null)
|
if (MloInstance != null)
|
||||||
{
|
{
|
||||||
|
MloInstance.SetPosition(Position);
|
||||||
MloInstance.UpdateEntities();
|
MloInstance.UpdateEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1269,9 +1288,15 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
public void SetOrientation(Quaternion ori)
|
public void SetOrientation(Quaternion ori)
|
||||||
{
|
{
|
||||||
|
Quaternion inv = Quaternion.Normalize(Quaternion.Invert(ori));
|
||||||
Orientation = ori;
|
Orientation = ori;
|
||||||
Quaternion qinv = Quaternion.Normalize(Quaternion.Invert(ori));
|
_CEntityDef.rotation = new Vector4(inv.X, inv.Y, inv.Z, inv.W);
|
||||||
_CEntityDef.rotation = new Vector4(qinv.X, qinv.Y, qinv.Z, qinv.W);
|
|
||||||
|
if (MloInstance != null)
|
||||||
|
{
|
||||||
|
MloInstance.SetOrientation(ori);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Archetype != null)
|
if (Archetype != null)
|
||||||
{
|
{
|
||||||
@ -1283,8 +1308,15 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
public void SetOrientationInv(Quaternion inv)
|
public void SetOrientationInv(Quaternion inv)
|
||||||
{
|
{
|
||||||
|
Quaternion ori = Quaternion.Normalize(Quaternion.Invert(inv));
|
||||||
|
Orientation = ori;
|
||||||
_CEntityDef.rotation = new Vector4(inv.X, inv.Y, inv.Z, inv.W);
|
_CEntityDef.rotation = new Vector4(inv.X, inv.Y, inv.Z, inv.W);
|
||||||
Orientation = Quaternion.Normalize(Quaternion.Invert(inv));
|
|
||||||
|
if (MloInstance != null)
|
||||||
|
{
|
||||||
|
MloInstance.SetOrientation(ori);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Archetype != null)
|
if (Archetype != null)
|
||||||
{
|
{
|
||||||
|
@ -350,8 +350,7 @@ namespace CodeWalker.GameFiles
|
|||||||
new MetaStructureEntryInfo_s(MetaName.artificialAmbientOcclusion, 116, MetaStructureEntryDataType.SignedInt, 0, 0, 0),
|
new MetaStructureEntryInfo_s(MetaName.artificialAmbientOcclusion, 116, MetaStructureEntryDataType.SignedInt, 0, 0, 0),
|
||||||
new MetaStructureEntryInfo_s(MetaName.tintValue, 120, MetaStructureEntryDataType.UnsignedInt, 0, 0, 0)
|
new MetaStructureEntryInfo_s(MetaName.tintValue, 120, MetaStructureEntryDataType.UnsignedInt, 0, 0, 0)
|
||||||
);
|
);
|
||||||
case MetaName.CMloInstanceDef
|
case MetaName.CMloInstanceDef:
|
||||||
:
|
|
||||||
return new MetaStructureInfo(MetaName.CMloInstanceDef, 2151576752, 1024, 160,
|
return new MetaStructureInfo(MetaName.CMloInstanceDef, 2151576752, 1024, 160,
|
||||||
new MetaStructureEntryInfo_s(MetaName.archetypeName, 8, MetaStructureEntryDataType.Hash, 0, 0, 0),
|
new MetaStructureEntryInfo_s(MetaName.archetypeName, 8, MetaStructureEntryDataType.Hash, 0, 0, 0),
|
||||||
new MetaStructureEntryInfo_s(MetaName.flags, 12, MetaStructureEntryDataType.UnsignedInt, 0, 0, 0),
|
new MetaStructureEntryInfo_s(MetaName.flags, 12, MetaStructureEntryDataType.UnsignedInt, 0, 0, 0),
|
||||||
@ -2045,9 +2044,9 @@ namespace CodeWalker.GameFiles
|
|||||||
public CEntityDef CEntityDef { get; set; }
|
public CEntityDef CEntityDef { get; set; }
|
||||||
public uint groupId { get; set; } //128 128: UnsignedInt: 0: 2501631252
|
public uint groupId { get; set; } //128 128: UnsignedInt: 0: 2501631252
|
||||||
public uint floorId { get; set; } //132 132: UnsignedInt: 0: floorId//2187650609
|
public uint floorId { get; set; } //132 132: UnsignedInt: 0: floorId//2187650609
|
||||||
public Array_uint Unk_1407157833 { get; set; } //136 136: Array: 0: 1407157833 {0: Hash: 0: 256}
|
public Array_uint defaultEntitySets { get; set; } //136 136: Array: 0: defaultEntitySets//1407157833 {0: Hash: 0: 256}
|
||||||
public uint Unk_528711607 { get; set; } //152 152: UnsignedInt: 0: 528711607
|
public uint numExitPortals { get; set; } //152 152: UnsignedInt: 0: numExitPortals//528711607
|
||||||
public uint Unk_3761966250 { get; set; } //156 156: UnsignedInt: 0: 3761966250
|
public uint MLOInstflags { get; set; } //156 156: UnsignedInt: 0: MLOInstflags//3761966250
|
||||||
}
|
}
|
||||||
|
|
||||||
[TC(typeof(EXP))] public struct CMloRoomDef //112 bytes, Key:3885428245
|
[TC(typeof(EXP))] public struct CMloRoomDef //112 bytes, Key:3885428245
|
||||||
|
@ -153,7 +153,7 @@ namespace CodeWalker.GameFiles
|
|||||||
public YmapEntityDef Owner { get; set; }
|
public YmapEntityDef Owner { get; set; }
|
||||||
public CMloInstanceDef _Instance;
|
public CMloInstanceDef _Instance;
|
||||||
public CMloInstanceDef Instance { get { return _Instance; } set { _Instance = value; } }
|
public CMloInstanceDef Instance { get { return _Instance; } set { _Instance = value; } }
|
||||||
public uint[] Unk_1407157833 { get; set; }
|
public uint[] defaultEntitySets { get; set; }
|
||||||
|
|
||||||
public YmapEntityDef[] Entities { get; set; }
|
public YmapEntityDef[] Entities { get; set; }
|
||||||
|
|
||||||
@ -180,6 +180,20 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void SetPosition(Vector3 pos)
|
||||||
|
{
|
||||||
|
var cent = _Instance.CEntityDef;
|
||||||
|
cent.position = pos;
|
||||||
|
_Instance.CEntityDef = cent; //TODO: maybe find a better way of doing this...
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetOrientation(Quaternion ori)
|
||||||
|
{
|
||||||
|
var cent = _Instance.CEntityDef;
|
||||||
|
cent.rotation = new Vector4(ori.X, ori.Y, ori.Z, ori.W); //mlo instances have oppposite orientations to normal entities...
|
||||||
|
_Instance.CEntityDef = cent; //TODO: maybe find a better way of doing this...
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateEntities()
|
public void UpdateEntities()
|
||||||
{
|
{
|
||||||
if (Entities == null) return;
|
if (Entities == null) return;
|
||||||
@ -197,6 +211,7 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user