-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add and update support for common UE Core data types.
- Loading branch information
Showing
24 changed files
with
517 additions
and
96 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -1,25 +1,51 @@ | ||
using System.Drawing; | ||
using System.Runtime.InteropServices; | ||
using UELib.Annotations; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace UELib.Core.Types | ||
namespace UELib.Core | ||
{ | ||
/// <summary> | ||
/// Implements FColor/UObject.Color | ||
/// </summary> | ||
[StructLayout(LayoutKind.Sequential)] | ||
public struct UColor : IUnrealAtomicStruct | ||
[StructLayout(LayoutKind.Sequential, Pack = 4)] | ||
public struct UColor : IUnrealSerializableClass, IUnrealAtomicStruct | ||
{ | ||
// The order may change based on compile-time constants. | ||
// Intel Win32 x86 | ||
public byte B, G, R, A; | ||
// Non-intel | ||
//public byte A, R, G, B; | ||
|
||
// <Intel-byte-order Win32 x86> | ||
public byte B, G, R, A; // UE2, UE3 | ||
//public byte R, G, B, A; // UE1 | ||
|
||
[PublicAPI] | ||
public Color ToColor() | ||
// <Intel-byte-order Linux x86> | ||
//public byte B, G, R, A; // UE3 | ||
|
||
// <Non-intel-byte-order> | ||
//public byte A, R, G, B; // UE2, UE3 | ||
//public byte A, B, G, R; // UE1 | ||
|
||
public UColor(byte b, byte g, byte r, byte a) | ||
{ | ||
B = b; | ||
G = g; | ||
R = r; | ||
A = a; | ||
} | ||
|
||
// FIXME: RGBA UE1, UE2, UE3.. | ||
// Always packed as one Int32 (order BGRA for Intel-byte-order) if serialized in bulk, and non bulk for later UE3 builds. | ||
// Packed as RGBA for UE1 unless not build intel-byte-order. | ||
public void Deserialize(IUnrealStream stream) | ||
{ | ||
stream.Read(out R); | ||
stream.Read(out G); | ||
stream.Read(out B); | ||
stream.Read(out A); | ||
} | ||
|
||
public void Serialize(IUnrealStream stream) | ||
{ | ||
return Color.FromArgb(A, R, G, B); | ||
stream.Write(R); | ||
stream.Write(G); | ||
stream.Write(B); | ||
stream.Write(A); | ||
} | ||
} | ||
} | ||
} |
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,40 @@ | ||
using System.Runtime.InteropServices; | ||
|
||
namespace UELib.Core | ||
{ | ||
/// <summary> | ||
/// Implements FCoords/UObject.Coords | ||
/// </summary> | ||
[StructLayout(LayoutKind.Sequential, Pack = 4)] | ||
public struct UCoords : IUnrealSerializableClass, IUnrealAtomicStruct | ||
{ | ||
public UVector Origin; | ||
public UVector XAxis; | ||
public UVector YAxis; | ||
public UVector ZAxis; | ||
|
||
public UCoords(ref UVector origin, ref UVector xAxis, ref UVector yAxis, ref UVector zAxis) | ||
{ | ||
Origin = origin; | ||
XAxis = xAxis; | ||
YAxis = yAxis; | ||
ZAxis = zAxis; | ||
} | ||
|
||
public void Deserialize(IUnrealStream stream) | ||
{ | ||
stream.ReadStruct(out Origin); | ||
stream.ReadStruct(out XAxis); | ||
stream.ReadStruct(out YAxis); | ||
stream.ReadStruct(out ZAxis); | ||
} | ||
|
||
public void Serialize(IUnrealStream stream) | ||
{ | ||
stream.WriteStruct(ref Origin); | ||
stream.WriteStruct(ref XAxis); | ||
stream.WriteStruct(ref YAxis); | ||
stream.WriteStruct(ref ZAxis); | ||
} | ||
} | ||
} |
Oops, something went wrong.