-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CharInterest, RndTransProxy, fix compile
- Loading branch information
1 parent
2f83288
commit a9a4334
Showing
7 changed files
with
202 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
using MiloLib.Assets.Rnd; | ||
using MiloLib.Classes; | ||
using MiloLib.Utils; | ||
|
||
namespace MiloLib.Assets.Char | ||
{ | ||
[Name("CharInterest"), Description("An interest object for a character to look at")] | ||
public class CharInterest : Object | ||
{ | ||
private ushort altRevision; | ||
private ushort revision; | ||
|
||
public RndTrans trans = new(); | ||
|
||
[Name("Max View Angle"), Description("In degrees, the maximum view cone angle for this object to be 'seen'")] | ||
public float maxViewAngle; | ||
[Name("Priority"), Description("An extra weight applied during scoring of this interest - use this to make it more or less important overall")] | ||
public float priority; | ||
[Name("Min Look Time"), Description("The minimum time you have to look at this object when its selected")] | ||
public float minLookTime; | ||
[Name("Max Look Time"), Description("The maximum allowable time to look at this object")] | ||
public float maxLookTime; | ||
[Name("Refractory Period"), Description("In secs, how long until this object can be looked at again")] | ||
public float refractoryPeriod; | ||
[Name("Char Eye Dart Override"), Description("if set, this dart ruleset will override the default one when looking at this interest object")] | ||
public Symbol charEyeDartOverride = new(0, ""); | ||
public int categoryFlags; | ||
[Name("Override Min Target Distance"), Description("if true, we will override the minimum distance this target can be from the eyes using the value below")] | ||
public bool overrideMinTargetDistance; | ||
[Name("Min Target Distance Override"), Description("the minimum distance, in inches, that this interest can be from the eyes. only applied if overrides_min_target_dist is true...")] | ||
public float minTargetDistanceOverride; | ||
public float maxViewAngleCosine; | ||
|
||
public Symbol unkSym = new(0, ""); | ||
|
||
public byte unkByte; | ||
|
||
public CharInterest Read(EndianReader reader, bool standalone, DirectoryMeta parent, DirectoryMeta.Entry entry) | ||
{ | ||
uint combinedRevision = reader.ReadUInt32(); | ||
if (BitConverter.IsLittleEndian) (revision, altRevision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)((combinedRevision >> 16) & 0xFFFF)); | ||
else (altRevision, revision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)((combinedRevision >> 16) & 0xFFFF)); | ||
|
||
base.Read(reader, false, parent, entry); | ||
|
||
trans = trans.Read(reader, false, parent, entry); | ||
|
||
maxViewAngle = reader.ReadFloat(); | ||
priority = reader.ReadFloat(); | ||
minLookTime = reader.ReadFloat(); | ||
maxLookTime = reader.ReadFloat(); | ||
refractoryPeriod = reader.ReadFloat(); | ||
|
||
// ? | ||
if (((short)((revision + 0x10000)) - 2 <= 3)) | ||
{ | ||
unkSym = Symbol.Read(reader); | ||
} | ||
else if (((short)((revision + 0x10000)) > 5)) | ||
{ | ||
charEyeDartOverride = Symbol.Read(reader); | ||
} | ||
if (revision > 2) | ||
{ | ||
categoryFlags = reader.ReadInt32(); | ||
if (revision == 3) | ||
{ | ||
unkByte = reader.ReadByte(); | ||
} | ||
} | ||
if (revision > 4) | ||
{ | ||
overrideMinTargetDistance = reader.ReadBoolean(); | ||
minTargetDistanceOverride = reader.ReadFloat(); | ||
} | ||
|
||
if (standalone) | ||
if ((reader.Endianness == Endian.BigEndian ? 0xADDEADDE : 0xDEADDEAD) != reader.ReadUInt32()) throw new Exception("Got to end of standalone asset but didn't find the expected end bytes, read likely did not succeed"); | ||
|
||
return this; | ||
} | ||
|
||
public override void Write(EndianWriter writer, bool standalone, DirectoryMeta parent, DirectoryMeta.Entry? entry) | ||
{ | ||
writer.WriteUInt32(BitConverter.IsLittleEndian ? (uint)((altRevision << 16) | revision) : (uint)((revision << 16) | altRevision)); | ||
|
||
base.Write(writer, false, parent, entry); | ||
|
||
trans.Write(writer, false, parent, entry); | ||
|
||
writer.WriteFloat(maxViewAngle); | ||
writer.WriteFloat(priority); | ||
writer.WriteFloat(minLookTime); | ||
writer.WriteFloat(maxLookTime); | ||
writer.WriteFloat(refractoryPeriod); | ||
|
||
// ? | ||
if (((short)((revision + 0x10000)) - 2 <= 3)) | ||
{ | ||
Symbol.Write(writer, unkSym); | ||
} | ||
else if (((short)((revision + 0x10000)) > 5)) | ||
{ | ||
Symbol.Write(writer, charEyeDartOverride); | ||
} | ||
|
||
if (revision > 2) | ||
{ | ||
writer.WriteInt32(categoryFlags); | ||
if (revision == 3) | ||
{ | ||
writer.WriteByte(unkByte); | ||
} | ||
} | ||
|
||
if (revision > 4) | ||
{ | ||
writer.WriteBoolean(overrideMinTargetDistance); | ||
writer.WriteFloat(minTargetDistanceOverride); | ||
} | ||
|
||
if (standalone) | ||
writer.WriteBlock(new byte[4] { 0xAD, 0xDE, 0xAD, 0xDE }); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using MiloLib.Classes; | ||
using MiloLib.Utils; | ||
|
||
namespace MiloLib.Assets.Rnd | ||
{ | ||
[Name("RndTransProxy"), Description("Stand-in for a RndTransformable inside of a proxy, so you can use it")] | ||
public class RndTransProxy : Object | ||
{ | ||
private ushort altRevision; | ||
private ushort revision; | ||
|
||
public RndTrans trans = new(); | ||
[Name("Proxy"), Description("Proxy object this will look into.")] | ||
public Symbol proxy = new(0, ""); | ||
[Name("Part"), Description("The part inside it")] | ||
public Symbol part = new(0, ""); | ||
|
||
public RndTransProxy Read(EndianReader reader, bool standalone, DirectoryMeta parent, DirectoryMeta.Entry entry) | ||
{ | ||
uint combinedRevision = reader.ReadUInt32(); | ||
if (BitConverter.IsLittleEndian) (revision, altRevision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)((combinedRevision >> 16) & 0xFFFF)); | ||
else (altRevision, revision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)((combinedRevision >> 16) & 0xFFFF)); | ||
|
||
base.Read(reader, false, parent, entry); | ||
|
||
if (revision != 0) | ||
trans = trans.Read(reader, false, parent, entry); | ||
|
||
proxy = Symbol.Read(reader); | ||
part = Symbol.Read(reader); | ||
|
||
if (standalone) | ||
if ((reader.Endianness == Endian.BigEndian ? 0xADDEADDE : 0xDEADDEAD) != reader.ReadUInt32()) throw new Exception("Got to end of standalone asset but didn't find the expected end bytes, read likely did not succeed"); | ||
|
||
return this; | ||
} | ||
|
||
public override void Write(EndianWriter writer, bool standalone, DirectoryMeta parent, DirectoryMeta.Entry? entry) | ||
{ | ||
writer.WriteUInt32(BitConverter.IsLittleEndian ? (uint)((altRevision << 16) | revision) : (uint)((revision << 16) | altRevision)); | ||
|
||
base.Write(writer, false, parent, entry); | ||
|
||
if (revision != 0) | ||
trans.Write(writer, false, parent, entry); | ||
|
||
Symbol.Write(writer, proxy); | ||
Symbol.Write(writer, part); | ||
|
||
if (standalone) | ||
writer.WriteBlock(new byte[4] { 0xAD, 0xDE, 0xAD, 0xDE }); | ||
} | ||
|
||
} | ||
} |