Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ReinterpretCast.cs
Go to the documentation of this file.
1
using
System.Runtime.InteropServices
;
2
3
namespace
ReLogic.Utilities
;
4
5
public
static
class
ReinterpretCast
6
{
7
[StructLayout(
LayoutKind
.Explicit)]
8
private
struct
IntFloat
9
{
10
[FieldOffset(0)]
11
public
readonly
int
IntValue
;
12
13
[FieldOffset(0)]
14
public
readonly
float
FloatValue
;
15
16
public
IntFloat
(
int
value)
17
{
18
FloatValue
= 0f;
19
IntValue
= value;
20
}
21
22
public
IntFloat
(
float
value)
23
{
24
IntValue
= 0;
25
FloatValue
= value;
26
}
27
}
28
29
[StructLayout(
LayoutKind
.Explicit)]
30
private
struct
UIntFloat
31
{
32
[FieldOffset(0)]
33
public
readonly uint
UIntValue
;
34
35
[FieldOffset(0)]
36
public
readonly
float
FloatValue
;
37
38
public
UIntFloat
(uint value)
39
{
40
FloatValue
= 0f;
41
UIntValue
= value;
42
}
43
44
public
UIntFloat
(
float
value)
45
{
46
UIntValue
= 0u;
47
FloatValue
= value;
48
}
49
}
50
51
public
static
float
UIntAsFloat
(uint value)
52
{
53
return
new
UIntFloat
(value).
FloatValue
;
54
}
55
56
public
static
float
IntAsFloat
(
int
value)
57
{
58
return
new
IntFloat
(value).
FloatValue
;
59
}
60
61
public
static
uint
FloatAsUInt
(
float
value)
62
{
63
return
new
UIntFloat
(value).
UIntValue
;
64
}
65
66
public
static
int
FloatAsInt
(
float
value)
67
{
68
return
new
IntFloat
(value).
IntValue
;
69
}
70
}
ReLogic.Utilities.ReinterpretCast.UIntAsFloat
static float UIntAsFloat(uint value)
Definition
ReinterpretCast.cs:51
ReLogic.Utilities.ReinterpretCast.IntAsFloat
static float IntAsFloat(int value)
Definition
ReinterpretCast.cs:56
ReLogic.Utilities.ReinterpretCast.FloatAsInt
static int FloatAsInt(float value)
Definition
ReinterpretCast.cs:66
ReLogic.Utilities.ReinterpretCast.FloatAsUInt
static uint FloatAsUInt(float value)
Definition
ReinterpretCast.cs:61
ReLogic.Utilities.ReinterpretCast
Definition
ReinterpretCast.cs:6
ReLogic.Utilities
Definition
AttributeUtilities.cs:5
System.Runtime.InteropServices.LayoutKind
LayoutKind
Definition
LayoutKind.cs:4
System.Runtime.InteropServices
Definition
SequenceMarshal.cs:4
ReLogic.Utilities.ReinterpretCast.IntFloat.IntFloat
IntFloat(int value)
Definition
ReinterpretCast.cs:16
ReLogic.Utilities.ReinterpretCast.IntFloat.IntValue
readonly int IntValue
Definition
ReinterpretCast.cs:11
ReLogic.Utilities.ReinterpretCast.IntFloat.FloatValue
readonly float FloatValue
Definition
ReinterpretCast.cs:14
ReLogic.Utilities.ReinterpretCast.IntFloat.IntFloat
IntFloat(float value)
Definition
ReinterpretCast.cs:22
ReLogic.Utilities.ReinterpretCast.IntFloat
Definition
ReinterpretCast.cs:9
ReLogic.Utilities.ReinterpretCast.UIntFloat.FloatValue
readonly float FloatValue
Definition
ReinterpretCast.cs:36
ReLogic.Utilities.ReinterpretCast.UIntFloat.UIntFloat
UIntFloat(float value)
Definition
ReinterpretCast.cs:44
ReLogic.Utilities.ReinterpretCast.UIntFloat.UIntFloat
UIntFloat(uint value)
Definition
ReinterpretCast.cs:38
ReLogic.Utilities.ReinterpretCast.UIntFloat.UIntValue
readonly uint UIntValue
Definition
ReinterpretCast.cs:33
ReLogic.Utilities.ReinterpretCast.UIntFloat
Definition
ReinterpretCast.cs:31
source
ReLogic
ReLogic.Utilities
ReinterpretCast.cs
Generated by
1.10.0