mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 23:12:59 +08:00
Created MloArchetype and TimeArchetype subclasses, Meta pointer improvement
This commit is contained in:
parent
7ddd88e561
commit
f974c9eb49
@ -997,15 +997,15 @@ namespace CodeWalker.GameFiles
|
||||
////not ideal: should transform all 8 corners!
|
||||
}
|
||||
|
||||
if (Archetype.IsMloArchetype)
|
||||
if (Archetype.Type == MetaName.CMloArchetypeDef)
|
||||
{
|
||||
//transform interior entities into world space...
|
||||
var mlod = Archetype.MloData;
|
||||
var mloa = Archetype as MloArchetype;
|
||||
if (MloInstance == null)
|
||||
{
|
||||
MloInstance = new MloInstanceData();
|
||||
}
|
||||
MloInstance.CreateYmapEntities(this, mlod);
|
||||
MloInstance.CreateYmapEntities(this, mloa);
|
||||
|
||||
if (BSRadius == 0.0f)
|
||||
{
|
||||
|
@ -83,61 +83,65 @@ namespace CodeWalker.GameFiles
|
||||
for (int i = 0; i < ptrs.Length; i++)
|
||||
{
|
||||
var ptr = ptrs[i];
|
||||
int blocki = ptr.BlockID - 1;
|
||||
int offset = ptr.ItemOffset * 16;//block data size...
|
||||
if (blocki >= Meta.DataBlocks.Count)
|
||||
var offset = ptr.Offset;
|
||||
var block = Meta.GetBlock(ptr.BlockID);
|
||||
if (block == null)
|
||||
{ continue; }
|
||||
var block = Meta.DataBlocks[blocki];
|
||||
if ((offset < 0) || (block.Data == null) || (offset >= block.Data.Length))
|
||||
{ continue; }
|
||||
|
||||
var ba = new Archetype();
|
||||
Archetype a = null;
|
||||
switch (block.StructureNameHash)
|
||||
{
|
||||
case MetaName.CBaseArchetypeDef:
|
||||
var basearch = PsoTypes.ConvertDataRaw<CBaseArchetypeDef>(block.Data, offset);
|
||||
ba.Init(this, ref basearch);
|
||||
ba.Extensions = MetaTypes.GetExtensions(Meta, basearch.extensions);
|
||||
a = new Archetype();
|
||||
a.Init(this, ref basearch);
|
||||
a.Extensions = MetaTypes.GetExtensions(Meta, basearch.extensions);
|
||||
break;
|
||||
case MetaName.CTimeArchetypeDef:
|
||||
var timearch = PsoTypes.ConvertDataRaw<CTimeArchetypeDef>(block.Data, offset);
|
||||
ba.Init(this, ref timearch);
|
||||
ba.Extensions = MetaTypes.GetExtensions(Meta, timearch.BaseArchetypeDef.extensions);
|
||||
var ta = new TimeArchetype();
|
||||
ta.Init(this, ref timearch);
|
||||
ta.Extensions = MetaTypes.GetExtensions(Meta, timearch._BaseArchetypeDef.extensions);
|
||||
a = ta;
|
||||
break;
|
||||
case MetaName.CMloArchetypeDef:
|
||||
var mloarch = PsoTypes.ConvertDataRaw<CMloArchetypeDef>(block.Data, offset);
|
||||
ba.Init(this, ref mloarch);
|
||||
ba.Extensions = MetaTypes.GetExtensions(Meta, mloarch.BaseArchetypeDef.extensions);
|
||||
var ma = new MloArchetype();
|
||||
ma.Init(this, ref mloarch);
|
||||
ma.Extensions = MetaTypes.GetExtensions(Meta, mloarch._BaseArchetypeDef.extensions);
|
||||
|
||||
MloArchetypeData mlod = new MloArchetypeData();
|
||||
var mlodef = mloarch.MloArchetypeDef;
|
||||
mlod.entities = MetaTypes.ConvertDataArray<CEntityDef>(Meta, MetaName.CEntityDef, mlodef.entities);
|
||||
mlod.rooms = MetaTypes.ConvertDataArray<CMloRoomDef>(Meta, MetaName.CMloRoomDef, mlodef.rooms);
|
||||
mlod.portals = MetaTypes.ConvertDataArray<CMloPortalDef>(Meta, MetaName.CMloPortalDef, mlodef.portals);
|
||||
mlod.entitySets = MetaTypes.ConvertDataArray<CMloEntitySet>(Meta, MetaName.CMloEntitySet, mlodef.entitySets);
|
||||
mlod.timeCycleModifiers = MetaTypes.ConvertDataArray<CMloTimeCycleModifier>(Meta, MetaName.CMloTimeCycleModifier, mlodef.timeCycleModifiers);
|
||||
ba.MloData = mlod;
|
||||
ma.entities = MetaTypes.ConvertDataArray<CEntityDef>(Meta, MetaName.CEntityDef, mlodef.entities);
|
||||
ma.rooms = MetaTypes.ConvertDataArray<CMloRoomDef>(Meta, MetaName.CMloRoomDef, mlodef.rooms);
|
||||
ma.portals = MetaTypes.ConvertDataArray<CMloPortalDef>(Meta, MetaName.CMloPortalDef, mlodef.portals);
|
||||
ma.entitySets = MetaTypes.ConvertDataArray<CMloEntitySet>(Meta, MetaName.CMloEntitySet, mlodef.entitySets);
|
||||
ma.timeCycleModifiers = MetaTypes.ConvertDataArray<CMloTimeCycleModifier>(Meta, MetaName.CMloTimeCycleModifier, mlodef.timeCycleModifiers);
|
||||
|
||||
if (mlod.entities != null)
|
||||
if (ma.entities != null)
|
||||
{
|
||||
//for (int e = 0; e < mlod.entities.Length; e++)
|
||||
//for (int e = 0; e < ma.entities.Length; e++)
|
||||
//{
|
||||
// if (mlod.entities[e].extensions.Count1 > 0)
|
||||
// if (ma.entities[e].extensions.Count1 > 0)
|
||||
// {
|
||||
// var exts = MetaTypes.GetExtensions(Meta, mlod.entities[e].extensions);
|
||||
// var exts = MetaTypes.GetExtensions(Meta, ma.entities[e].extensions);
|
||||
// if (exts != null)
|
||||
// { }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
a = ma;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
allarchs.Add(ba);
|
||||
if (a != null)
|
||||
{
|
||||
allarchs.Add(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
AllArchetypes = allarchs.ToArray();
|
||||
|
@ -2394,12 +2394,13 @@ namespace CodeWalker.GameFiles
|
||||
{
|
||||
foreach (var arch in ytyp.AllArchetypes)
|
||||
{
|
||||
if (arch.IsTimeArchetype)
|
||||
if (arch.Type == MetaName.CTimeArchetypeDef)
|
||||
{
|
||||
var t = arch.TimeArchetype.TimeArchetypeDef.timeFlags;
|
||||
sb.Append(arch.TimeArchetype.BaseArchetypeDef.name.ToString());
|
||||
var ta = arch as TimeArchetype;
|
||||
var t = ta.TimeFlags;
|
||||
sb.Append(arch.Name);
|
||||
sb.Append(",");
|
||||
sb.Append(arch.TimeArchetype.BaseArchetypeDef.assetName.ToString());
|
||||
sb.Append(arch.AssetName);
|
||||
sb.Append(",");
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
|
@ -882,7 +882,7 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
}
|
||||
|
||||
[TC(typeof(EXP))] public struct ArrayOfUshorts3 //array of 3 bytes
|
||||
[TC(typeof(EXP))] public struct ArrayOfUshorts3 //array of 3 ushorts
|
||||
{
|
||||
public ushort u0, u1, u2;
|
||||
public override string ToString()
|
||||
@ -961,22 +961,24 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
}
|
||||
|
||||
[TC(typeof(EXP))] public struct MetaPOINTER //8 bytes - pointer to data item //SectionUNKNOWN10
|
||||
[TC(typeof(EXP))] public struct MetaPOINTER //8 bytes - pointer to data item //was: SectionUNKNOWN10
|
||||
{
|
||||
public ushort BlockID { get; set; } //1-based ID
|
||||
public ushort ItemOffset { get; set; } //byte offset / 16
|
||||
public uint Pointer { get; set; }
|
||||
public uint ExtraOffset { get; set; }
|
||||
|
||||
public MetaPOINTER(ushort blockID, ushort itemOffset, uint extra)
|
||||
public int BlockIndex { get { return BlockID - 1; } }
|
||||
public int BlockID { get { return (int)(Pointer & 0xFFF); } set { Pointer = (Pointer & 0xFFFFF000) + ((uint)value & 0xFFF); } }
|
||||
public int Offset { get { return (int)((Pointer >> 12) & 0xFFFFF); } set { Pointer = (Pointer & 0xFFF) + (((uint)value << 12) & 0xFFFFF000); } }
|
||||
|
||||
public MetaPOINTER(int blockID, int itemOffset, uint extra)
|
||||
{
|
||||
BlockID = blockID;
|
||||
ItemOffset = itemOffset;
|
||||
Pointer = (((uint)itemOffset << 12) & 0xFFFFF000) + ((uint)blockID & 0xFFF);
|
||||
ExtraOffset = extra;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return BlockID.ToString() + ", " + ItemOffset.ToString() + ", " + ExtraOffset.ToString();
|
||||
return BlockID.ToString() + ", " + Offset.ToString() + ", " + ExtraOffset.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,8 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
int idx = block.AddItem(data);
|
||||
MetaBuilderPointer r = new MetaBuilderPointer();
|
||||
r.Block = block.Index + 1;
|
||||
r.Offset = (idx * data.Length) / 16;
|
||||
r.BlockID = block.Index + 1;
|
||||
r.Offset = (idx * data.Length);
|
||||
r.Length = data.Length;
|
||||
return r;
|
||||
}
|
||||
@ -65,11 +65,11 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
byte[] newdata = new byte[newlen];
|
||||
Buffer.BlockCopy(data, 0, newdata, 0, datalen);
|
||||
int offs = block.TotalSize / 16;
|
||||
int offs = block.TotalSize;
|
||||
int idx = block.AddItem(newdata);
|
||||
MetaBuilderPointer r = new MetaBuilderPointer();
|
||||
r.Block = block.Index + 1;
|
||||
r.Offset = offs; //(idx * data.Length) / 16;
|
||||
r.BlockID = block.Index + 1;
|
||||
r.Offset = offs; //(idx * data.Length);;
|
||||
r.Length = items.Length;
|
||||
return r;
|
||||
}
|
||||
@ -86,11 +86,11 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
byte[] newdata = new byte[newlen];
|
||||
Buffer.BlockCopy(data, 0, newdata, 0, datalen);
|
||||
int offs = block.TotalSize / 16;
|
||||
int offs = block.TotalSize;
|
||||
int idx = block.AddItem(newdata);
|
||||
MetaBuilderPointer r = new MetaBuilderPointer();
|
||||
r.Block = block.Index + 1;
|
||||
r.Offset = offs;// (idx * data.Length) / 16;//not sure if this is correct! should also use sub-offset!
|
||||
r.BlockID = block.Index + 1;
|
||||
r.Offset = offs;// (idx * data.Length);
|
||||
r.Length = datalen; //actual length of string.
|
||||
return r;
|
||||
}
|
||||
@ -98,7 +98,7 @@ namespace CodeWalker.GameFiles
|
||||
public MetaPOINTER AddItemPtr<T>(MetaName type, T item) where T : struct //helper method for AddItem<T>
|
||||
{
|
||||
var ptr = AddItem(type, item);
|
||||
return new MetaPOINTER((ushort)ptr.Block, (ushort)ptr.Offset, 0);
|
||||
return new MetaPOINTER(ptr.BlockID, ptr.Offset, 0);
|
||||
}
|
||||
public Array_Structure AddItemArrayPtr<T>(MetaName type, T[] items) where T : struct //helper method for AddItemArray<T>
|
||||
{
|
||||
@ -207,8 +207,8 @@ namespace CodeWalker.GameFiles
|
||||
if (i == 0)
|
||||
{
|
||||
MetaBuilderPointer mbp = new MetaBuilderPointer();
|
||||
mbp.Block = meptr.BlockID;
|
||||
mbp.Offset = meptr.ItemOffset;
|
||||
mbp.BlockID = meptr.BlockID;
|
||||
mbp.Offset = meptr.Offset;
|
||||
sa.Pointer = mbp.Pointer;
|
||||
}
|
||||
}
|
||||
@ -359,15 +359,15 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
public struct MetaBuilderPointer
|
||||
{
|
||||
public int Block { get; set; } //0-based index
|
||||
public int Offset { get; set; } //(byteoffset/16)
|
||||
public int BlockID { get; set; } //1-based id
|
||||
public int Offset { get; set; } //byte offset
|
||||
public int Length { get; set; } //for temp use...
|
||||
public uint Pointer
|
||||
{
|
||||
get
|
||||
{
|
||||
uint bidx = (((uint)Block) & 0xFFF);
|
||||
uint offs = (((uint)Offset) & 0xFFFF) << 16;
|
||||
uint bidx = (((uint)BlockID) & 0xFFF);
|
||||
uint offs = (((uint)Offset) & 0xFFFFF) << 12;
|
||||
return bidx + offs;
|
||||
}
|
||||
}
|
||||
|
@ -819,12 +819,10 @@ namespace CodeWalker.GameFiles
|
||||
//MetaName blocktype = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var sptr = ptrs[i];
|
||||
int blocki = sptr.BlockID - 1;
|
||||
int offset = sptr.ItemOffset * 16;//block data size...
|
||||
if (blocki >= meta.DataBlocks.Count)
|
||||
{ continue; }
|
||||
var block = meta.DataBlocks[blocki];
|
||||
var ptr = ptrs[i];
|
||||
var offset = ptr.Offset;
|
||||
var block = meta.GetBlock(ptr.BlockID);
|
||||
if (block == null) continue;
|
||||
|
||||
//if (blocktype == 0)
|
||||
//{ blocktype = block.StructureNameHash; }
|
||||
@ -983,11 +981,8 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
MetaPOINTER[] ptrs = new MetaPOINTER[count];
|
||||
int ptrsize = Marshal.SizeOf(typeof(MetaPOINTER));
|
||||
//int itemsleft = (int)count; //large arrays get split into chunks...
|
||||
uint ptr = array.Pointer;
|
||||
int ptrindex = (int)(ptr & 0xFFF) - 1;
|
||||
int ptroffset = (int)((ptr >> 12) & 0xFFFFF);
|
||||
var ptrblock = (ptrindex < meta.DataBlocks.Count) ? meta.DataBlocks[ptrindex] : null;
|
||||
int ptroffset = (int)array.PointerDataOffset;
|
||||
var ptrblock = meta.GetBlock((int)array.PointerDataId);
|
||||
if ((ptrblock == null) || (ptrblock.Data == null) || (ptrblock.StructureNameHash != MetaName.POINTER))
|
||||
{ return null; }
|
||||
|
||||
@ -1204,7 +1199,7 @@ namespace CodeWalker.GameFiles
|
||||
{
|
||||
var extptr = extptrs[i];
|
||||
MetaWrapper ext = null;
|
||||
var block = GetDataBlock(meta, extptr);
|
||||
var block = meta.GetBlock(extptr.BlockID);
|
||||
var h = block.StructureNameHash;
|
||||
switch (h)
|
||||
{
|
||||
@ -1277,18 +1272,10 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
|
||||
|
||||
public static MetaDataBlock GetDataBlock(Meta meta, MetaPOINTER ptr)
|
||||
{
|
||||
int blocki = ptr.BlockID - 1;
|
||||
if ((blocki < 0) || (blocki >= meta.DataBlocks.Count))
|
||||
{ return null; }
|
||||
var block = meta.DataBlocks[blocki];
|
||||
return block;
|
||||
}
|
||||
public static int GetDataOffset(MetaDataBlock block, MetaPOINTER ptr)
|
||||
{
|
||||
if (block == null) return -1;
|
||||
int offset = ptr.ItemOffset * 16;//block data size...
|
||||
var offset = ptr.Offset;
|
||||
if (ptr.ExtraOffset != 0)
|
||||
{ }
|
||||
//offset += (int)ptr.ExtraOffset;
|
||||
@ -1298,13 +1285,7 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
public static T GetData<T>(Meta meta, MetaPOINTER ptr) where T : struct
|
||||
{
|
||||
var block = GetDataBlock(meta, ptr);
|
||||
var offset = GetDataOffset(block, ptr);
|
||||
if (offset < 0) return new T();
|
||||
return ConvertData<T>(block.Data, offset);
|
||||
}
|
||||
public static T GetData<T>(MetaDataBlock block, MetaPOINTER ptr) where T : struct
|
||||
{
|
||||
var block = meta.GetBlock(ptr.BlockID);
|
||||
var offset = GetDataOffset(block, ptr);
|
||||
if (offset < 0) return new T();
|
||||
return ConvertData<T>(block.Data, offset);
|
||||
|
@ -285,8 +285,8 @@ namespace CodeWalker.GameFiles
|
||||
for (int n = 0; n < aCount; n++)
|
||||
{
|
||||
var ptr = ptrArr[n];
|
||||
var eboffset = ptr.ItemOffset * 16;
|
||||
WriteNode(sb, aind, cont, ptr.BlockID, eboffset, XmlTagMode.ItemAndType);
|
||||
var offset = ptr.Offset;
|
||||
WriteNode(sb, aind, cont, ptr.BlockID, offset, XmlTagMode.ItemAndType);
|
||||
}
|
||||
CloseTag(sb, indent, ename);
|
||||
}
|
||||
|
@ -11,11 +11,13 @@ namespace CodeWalker.GameFiles
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class Archetype
|
||||
{
|
||||
public virtual MetaName Type => MetaName.CBaseArchetypeDef;
|
||||
|
||||
public CBaseArchetypeDef _BaseArchetypeDef;
|
||||
public CBaseArchetypeDef BaseArchetypeDef { get { return _BaseArchetypeDef; } set { _BaseArchetypeDef = value; } }
|
||||
|
||||
public MetaHash Hash { get; set; }
|
||||
public YtypFile Ytyp { get; set; }
|
||||
public CBaseArchetypeDef BaseArchetype { get; set; }
|
||||
public CTimeArchetypeDef TimeArchetype { get; set; }
|
||||
public CMloArchetypeDef MloArchetype { get; set; }
|
||||
public MetaHash DrawableDict { get; set; }
|
||||
public MetaHash TextureDict { get; set; }
|
||||
public MetaHash ClipDict { get; set; }
|
||||
@ -23,35 +25,31 @@ namespace CodeWalker.GameFiles
|
||||
public Vector3 BBMax { get; set; }
|
||||
public Vector3 BSCenter { get; set; }
|
||||
public float BSRadius { get; set; }
|
||||
public bool IsTimeArchetype { get; set; }
|
||||
public bool IsMloArchetype { get; set; }
|
||||
public float LodDist { get; set; }
|
||||
public MloArchetypeData MloData { get; set; }
|
||||
public MetaWrapper[] Extensions { get; set; }
|
||||
public TimedArchetypeTimes Times { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsTimeArchetype) return TimeArchetype.BaseArchetypeDef.name.ToString();
|
||||
if (IsMloArchetype) return MloArchetype.BaseArchetypeDef.name.ToString();
|
||||
return BaseArchetype.name.ToString();
|
||||
return _BaseArchetypeDef.name.ToString();
|
||||
}
|
||||
}
|
||||
public string AssetName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsTimeArchetype) return TimeArchetype.BaseArchetypeDef.assetName.ToString();
|
||||
if (IsMloArchetype) return MloArchetype.BaseArchetypeDef.assetName.ToString();
|
||||
return BaseArchetype.assetName.ToString();
|
||||
return _BaseArchetypeDef.assetName.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitVars(ref CBaseArchetypeDef arch)
|
||||
|
||||
protected void InitVars(ref CBaseArchetypeDef arch)
|
||||
{
|
||||
BaseArchetypeDef = arch;
|
||||
Hash = arch.assetName;
|
||||
if (Hash.Hash == 0) Hash = arch.name;
|
||||
DrawableDict = arch.drawableDictionary;
|
||||
@ -68,57 +66,87 @@ namespace CodeWalker.GameFiles
|
||||
{
|
||||
Ytyp = ytyp;
|
||||
InitVars(ref arch);
|
||||
BaseArchetype = arch;
|
||||
IsTimeArchetype = false;
|
||||
IsMloArchetype = false;
|
||||
}
|
||||
public void Init(YtypFile ytyp, ref CTimeArchetypeDef arch)
|
||||
{
|
||||
Ytyp = ytyp;
|
||||
InitVars(ref arch._BaseArchetypeDef);
|
||||
TimeArchetype = arch;
|
||||
IsTimeArchetype = true;
|
||||
IsMloArchetype = false;
|
||||
Times = new TimedArchetypeTimes(arch.TimeArchetypeDef.timeFlags);
|
||||
}
|
||||
public void Init(YtypFile ytyp, ref CMloArchetypeDef arch)
|
||||
{
|
||||
Ytyp = ytyp;
|
||||
InitVars(ref arch._BaseArchetypeDef);
|
||||
MloArchetype = arch;
|
||||
IsTimeArchetype = false;
|
||||
IsMloArchetype = true;
|
||||
}
|
||||
|
||||
public bool IsActive(float hour)
|
||||
public virtual bool IsActive(float hour)
|
||||
{
|
||||
if (Times == null) return true;
|
||||
//if (Times.ExtraFlag) hour -= 0.5f;
|
||||
//if (hour < 0.0f) hour += 24.0f;
|
||||
int h = ((int)hour) % 24;
|
||||
if ((h < 0) || (h > 23)) return true;
|
||||
return Times.ActiveHours[h];
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (IsTimeArchetype) return TimeArchetype.ToString();
|
||||
if (IsMloArchetype) return MloArchetype.ToString();
|
||||
return BaseArchetype.ToString();
|
||||
return _BaseArchetypeDef.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class MloArchetypeData
|
||||
public class TimeArchetype : Archetype
|
||||
{
|
||||
public override MetaName Type => MetaName.CTimeArchetypeDef;
|
||||
|
||||
public CTimeArchetypeDefData _TimeArchetypeDef;
|
||||
public CTimeArchetypeDefData TimeArchetypeDef { get { return _TimeArchetypeDef; } set { _TimeArchetypeDef = value; } }
|
||||
|
||||
|
||||
public uint TimeFlags { get; set; }
|
||||
public bool[] ActiveHours { get; set; }
|
||||
public string[] ActiveHoursText { get; set; }
|
||||
public bool ExtraFlag { get; set; }
|
||||
|
||||
|
||||
public void Init(YtypFile ytyp, ref CTimeArchetypeDef arch)
|
||||
{
|
||||
Ytyp = ytyp;
|
||||
InitVars(ref arch._BaseArchetypeDef);
|
||||
TimeArchetypeDef = arch.TimeArchetypeDef;
|
||||
|
||||
TimeFlags = _TimeArchetypeDef.timeFlags;
|
||||
ActiveHours = new bool[24];
|
||||
ActiveHoursText = new string[24];
|
||||
for (int i = 0; i < 24; i++)
|
||||
{
|
||||
bool v = ((TimeFlags >> i) & 1) == 1;
|
||||
ActiveHours[i] = v;
|
||||
|
||||
int nxth = (i < 23) ? (i + 1) : 0;
|
||||
string hrs = string.Format("{0:00}:00 - {1:00}:00", i, nxth);
|
||||
ActiveHoursText[i] = (hrs + (v ? " - On" : " - Off"));
|
||||
}
|
||||
ExtraFlag = ((TimeFlags >> 24) & 1) == 1;
|
||||
}
|
||||
|
||||
public override bool IsActive(float hour)
|
||||
{
|
||||
if (ActiveHours == null) return true;
|
||||
int h = ((int)hour) % 24;
|
||||
if ((h < 0) || (h > 23)) return true;
|
||||
return ActiveHours[h];
|
||||
}
|
||||
}
|
||||
|
||||
public class MloArchetype : Archetype
|
||||
{
|
||||
public override MetaName Type => MetaName.CMloArchetypeDef;
|
||||
|
||||
public CMloArchetypeDefData _MloArchetypeDef;
|
||||
public CMloArchetypeDefData MloArchetypeDef { get { return _MloArchetypeDef; } set { _MloArchetypeDef = value; } }
|
||||
|
||||
public CEntityDef[] entities { get; set; }
|
||||
public CMloRoomDef[] rooms { get; set; }
|
||||
public CMloPortalDef[] portals { get; set; }
|
||||
public CMloEntitySet[] entitySets { get; set; }
|
||||
public CMloTimeCycleModifier[] timeCycleModifiers { get; set; }
|
||||
|
||||
public void Init(YtypFile ytyp, ref CMloArchetypeDef arch)
|
||||
{
|
||||
Ytyp = ytyp;
|
||||
InitVars(ref arch._BaseArchetypeDef);
|
||||
MloArchetypeDef = arch.MloArchetypeDef;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class MloInstanceData
|
||||
{
|
||||
@ -130,16 +158,16 @@ namespace CodeWalker.GameFiles
|
||||
public YmapEntityDef[] Entities { get; set; }
|
||||
|
||||
|
||||
public void CreateYmapEntities(YmapEntityDef owner, MloArchetypeData mlod)
|
||||
public void CreateYmapEntities(YmapEntityDef owner, MloArchetype mloa)
|
||||
{
|
||||
Owner = owner;
|
||||
if (owner == null) return;
|
||||
if (mlod.entities == null) return;
|
||||
var ec = mlod.entities.Length;
|
||||
if (mloa.entities == null) return;
|
||||
var ec = mloa.entities.Length;
|
||||
Entities = new YmapEntityDef[ec];
|
||||
for (int i = 0; i < ec; i++)
|
||||
{
|
||||
YmapEntityDef e = new YmapEntityDef(null, i, ref mlod.entities[i]);
|
||||
YmapEntityDef e = new YmapEntityDef(null, i, ref mloa.entities[i]);
|
||||
e.MloRefPosition = e.Position;
|
||||
e.MloRefOrientation = e.Orientation;
|
||||
e.MloParent = owner;
|
||||
@ -172,31 +200,4 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class TimedArchetypeTimes
|
||||
{
|
||||
public uint TimeFlags { get; set; }
|
||||
public bool[] ActiveHours { get; set; }
|
||||
public string[] ActiveHoursText { get; set; }
|
||||
public bool ExtraFlag { get; set; }
|
||||
|
||||
public TimedArchetypeTimes(uint timeFlags)
|
||||
{
|
||||
TimeFlags = timeFlags;
|
||||
ActiveHours = new bool[24];
|
||||
ActiveHoursText = new string[24];
|
||||
for (int i = 0; i < 24; i++)
|
||||
{
|
||||
bool v = ((timeFlags >> i) & 1) == 1;
|
||||
ActiveHours[i] = v;
|
||||
|
||||
int nxth = (i < 23) ? (i + 1) : 0;
|
||||
string hrs = string.Format("{0:00}:00 - {1:00}:00", i, nxth);
|
||||
ActiveHoursText[i] = (hrs + (v ? " - On" : " - Off"));
|
||||
}
|
||||
ExtraFlag = ((timeFlags >> 24) & 1) == 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
35
WorldForm.cs
35
WorldForm.cs
@ -2199,7 +2199,8 @@ namespace CodeWalker
|
||||
Archetype arch = ent.Archetype;
|
||||
if (arch != null)
|
||||
{
|
||||
if (!arch.IsTimeArchetype || (rendertimedents && (rendertimedentsalways || arch.IsActive(timeofday))))
|
||||
bool timed = (arch.Type == MetaName.CTimeArchetypeDef);
|
||||
if (!timed || (rendertimedents && (rendertimedentsalways || arch.IsActive(timeofday))))
|
||||
{
|
||||
ent.CamRel = ent.Position - camera.Position;
|
||||
RenderArchetype(arch, ent);
|
||||
@ -2232,7 +2233,8 @@ namespace CodeWalker
|
||||
Archetype arch = entity.Archetype;
|
||||
if (arch != null)
|
||||
{
|
||||
if (!arch.IsTimeArchetype || (rendertimedents && (rendertimedentsalways || arch.IsActive(timeofday))))
|
||||
bool timed = (arch.Type == MetaName.CTimeArchetypeDef);
|
||||
if (!timed || (rendertimedents && (rendertimedentsalways || arch.IsActive(timeofday))))
|
||||
{
|
||||
bool usechild = false;
|
||||
entity.CamRel = entity.Position - camera.Position;
|
||||
@ -2418,23 +2420,23 @@ namespace CodeWalker
|
||||
var arch = ent.Archetype;
|
||||
bool isshadowproxy = false;
|
||||
bool isreflproxy = false;
|
||||
uint archflags = arch.BaseArchetype.flags;
|
||||
if (arch.IsTimeArchetype)
|
||||
uint archflags = arch._BaseArchetypeDef.flags;
|
||||
if (arch.Type == MetaName.CTimeArchetypeDef)
|
||||
{
|
||||
if (!(rendertimedents && (rendertimedentsalways || arch.IsActive(timeofday)))) return false;
|
||||
archflags = arch.TimeArchetype.BaseArchetypeDef.flags;
|
||||
//archflags = arch._BaseArchetypeDef.flags;
|
||||
}
|
||||
else if (arch.IsMloArchetype)
|
||||
{
|
||||
archflags = arch.MloArchetype.BaseArchetypeDef.flags;
|
||||
}
|
||||
//switch (archflags)
|
||||
//else if (arch.Type == MetaName.CMloArchetypeDef)
|
||||
//{
|
||||
// //case 8192: //8192: is YTYP no shadow rendering - CP
|
||||
// case 2048: //000000000000000000100000000000 shadow proxies...
|
||||
// case 536872960: //100000000000000000100000000000 tunnel refl/shadow prox?
|
||||
// isshadowproxy = true; break;
|
||||
// archflags = arch._BaseArchetypeDef.flags;
|
||||
//}
|
||||
////switch (archflags)
|
||||
////{
|
||||
//// //case 8192: //8192: is YTYP no shadow rendering - CP
|
||||
//// case 2048: //000000000000000000100000000000 shadow proxies...
|
||||
//// case 536872960: //100000000000000000100000000000 tunnel refl/shadow prox?
|
||||
//// isshadowproxy = true; break;
|
||||
////}
|
||||
if ((archflags & 2048) > 0)
|
||||
{
|
||||
isshadowproxy = true;
|
||||
@ -2445,7 +2447,7 @@ namespace CodeWalker
|
||||
// isreflproxy = true;
|
||||
//}
|
||||
|
||||
switch (ent.CEntityDef.flags)
|
||||
switch (ent._CEntityDef.flags)
|
||||
{
|
||||
case 135790592: //001000000110000000000000000000 prewater proxy (golf course)
|
||||
case 135790593: //001000000110000000000000000001 water refl proxy? (mike house)
|
||||
@ -2503,9 +2505,6 @@ namespace CodeWalker
|
||||
|
||||
Vector3 camrel = (entity != null) ? entity.CamRel : -camera.Position;
|
||||
|
||||
if (arche.IsMloArchetype)
|
||||
{ }
|
||||
|
||||
Quaternion orientation = Quaternion.Identity;
|
||||
Vector3 scale = Vector3.One;
|
||||
Vector3 bscent = camrel;
|
||||
|
Loading…
Reference in New Issue
Block a user