Client LuaCsForBarotrauma
LuaTypes.cs
1 using System;
2 
3 namespace Barotrauma
4 {
5  public struct LuaSByte
6  {
7  public readonly sbyte Value;
8 
9  public LuaSByte(double v)
10  {
11  Value = (sbyte)v;
12  }
13 
14  public LuaSByte(string v, int radix = 10)
15  {
16  Value = Convert.ToSByte(v, radix);
17  }
18 
19  public static implicit operator sbyte(LuaSByte luaValue) => luaValue.Value;
20 
21  public override string ToString()
22  {
23  return Value.ToString();
24  }
25  }
26 
27  public struct LuaByte
28  {
29  public readonly byte Value;
30 
31  public LuaByte(double v)
32  {
33  Value = (byte)v;
34  }
35 
36  public LuaByte(string v, int radix = 10)
37  {
38  Value = Convert.ToByte(v, radix);
39  }
40 
41  public static implicit operator byte(LuaByte luaValue) => luaValue.Value;
42 
43  public override string ToString()
44  {
45  return Value.ToString();
46  }
47  }
48 
49  public struct LuaInt16
50  {
51  public readonly short Value;
52 
53  public LuaInt16(double v)
54  {
55  Value = (short)v;
56  }
57 
58  public LuaInt16(string v, int radix = 10)
59  {
60  Value = Convert.ToInt16(v, radix);
61  }
62 
63  public static implicit operator short(LuaInt16 luaValue) => luaValue.Value;
64 
65  public override string ToString()
66  {
67  return Value.ToString();
68  }
69  }
70 
71  public struct LuaUInt16
72  {
73  public readonly ushort Value;
74 
75  public LuaUInt16(double v)
76  {
77  Value = (ushort)v;
78  }
79 
80  public LuaUInt16(string v, int radix = 10)
81  {
82  Value = Convert.ToUInt16(v, radix);
83  }
84 
85  public static implicit operator ushort(LuaUInt16 luaValue) => luaValue.Value;
86 
87  public override string ToString()
88  {
89  return Value.ToString();
90  }
91  }
92 
93  public struct LuaInt32
94  {
95  public readonly int Value;
96 
97  public LuaInt32(double v)
98  {
99  Value = (int)v;
100  }
101 
102  public LuaInt32(string v, int radix = 10)
103  {
104  Value = Convert.ToInt32(v, radix);
105  }
106 
107  public static implicit operator int(LuaInt32 luaValue) => luaValue.Value;
108 
109  public override string ToString()
110  {
111  return Value.ToString();
112  }
113  }
114 
115  public struct LuaUInt32
116  {
117  public readonly uint Value;
118 
119  public LuaUInt32(double v)
120  {
121  Value = (uint)v;
122  }
123 
124  public LuaUInt32(string v, int radix = 10)
125  {
126  Value = Convert.ToUInt32(v, radix);
127  }
128 
129  public static implicit operator uint(LuaUInt32 luaValue) => luaValue.Value;
130 
131  public override string ToString()
132  {
133  return Value.ToString();
134  }
135  }
136 
137  public struct LuaInt64
138  {
139  public readonly long Value;
140 
141  public LuaInt64(double v)
142  {
143  Value = (long)v;
144  }
145 
146  public LuaInt64(double lo, double hi)
147  {
148  Value = Convert.ToUInt32(lo) | (long)Convert.ToInt32(hi) << 32;
149  }
150 
151  public LuaInt64(string v, int radix = 10)
152  {
153  Value = Convert.ToInt64(v, radix);
154  }
155 
156  public static implicit operator long(LuaInt64 luaValue) => luaValue.Value;
157 
158  public override string ToString()
159  {
160  return Value.ToString();
161  }
162  }
163 
164  public struct LuaUInt64
165  {
166  public readonly ulong Value;
167 
168  public LuaUInt64(double v)
169  {
170  Value = (ulong)v;
171  }
172 
173  public LuaUInt64(double lo, double hi)
174  {
175  Value = Convert.ToUInt32(lo) | (ulong)Convert.ToUInt32(hi) << 32;
176  }
177 
178  public LuaUInt64(string v, int radix = 10)
179  {
180  Value = Convert.ToUInt64(v, radix);
181  }
182 
183  public static implicit operator ulong(LuaUInt64 luaValue) => luaValue.Value;
184 
185  public override string ToString()
186  {
187  return Value.ToString();
188  }
189  }
190 
191  public struct LuaSingle
192  {
193  public readonly float Value;
194 
195  public LuaSingle(double v)
196  {
197  Value = (float)v;
198  }
199 
200  public LuaSingle(string v)
201  {
202  Value = float.Parse(v);
203  }
204 
205  public static implicit operator float(LuaSingle luaValue) => luaValue.Value;
206 
207  public override string ToString()
208  {
209  return Value.ToString();
210  }
211  }
212 
213  public struct LuaDouble
214  {
215  public readonly double Value;
216 
217  public LuaDouble(double v)
218  {
219  Value = v;
220  }
221 
222  public LuaDouble(string v)
223  {
224  Value = double.Parse(v);
225  }
226 
227  public static implicit operator double(LuaDouble luaValue) => luaValue.Value;
228 
229  public override string ToString()
230  {
231  return Value.ToString();
232  }
233  }
234 }
override string ToString()
Definition: LuaTypes.cs:43
LuaByte(double v)
Definition: LuaTypes.cs:31
LuaByte(string v, int radix=10)
Definition: LuaTypes.cs:36
readonly byte Value
Definition: LuaTypes.cs:29
override string ToString()
Definition: LuaTypes.cs:229
LuaDouble(string v)
Definition: LuaTypes.cs:222
LuaDouble(double v)
Definition: LuaTypes.cs:217
readonly double Value
Definition: LuaTypes.cs:215
override string ToString()
Definition: LuaTypes.cs:65
LuaInt16(double v)
Definition: LuaTypes.cs:53
readonly short Value
Definition: LuaTypes.cs:51
LuaInt16(string v, int radix=10)
Definition: LuaTypes.cs:58
LuaInt32(string v, int radix=10)
Definition: LuaTypes.cs:102
override string ToString()
Definition: LuaTypes.cs:109
LuaInt32(double v)
Definition: LuaTypes.cs:97
readonly int Value
Definition: LuaTypes.cs:95
LuaInt64(double lo, double hi)
Definition: LuaTypes.cs:146
LuaInt64(double v)
Definition: LuaTypes.cs:141
readonly long Value
Definition: LuaTypes.cs:139
override string ToString()
Definition: LuaTypes.cs:158
LuaInt64(string v, int radix=10)
Definition: LuaTypes.cs:151
LuaSByte(double v)
Definition: LuaTypes.cs:9
override string ToString()
Definition: LuaTypes.cs:21
readonly sbyte Value
Definition: LuaTypes.cs:7
LuaSByte(string v, int radix=10)
Definition: LuaTypes.cs:14
LuaSingle(string v)
Definition: LuaTypes.cs:200
readonly float Value
Definition: LuaTypes.cs:193
LuaSingle(double v)
Definition: LuaTypes.cs:195
override string ToString()
Definition: LuaTypes.cs:207
override string ToString()
Definition: LuaTypes.cs:87
readonly ushort Value
Definition: LuaTypes.cs:73
LuaUInt16(double v)
Definition: LuaTypes.cs:75
LuaUInt16(string v, int radix=10)
Definition: LuaTypes.cs:80
LuaUInt32(string v, int radix=10)
Definition: LuaTypes.cs:124
readonly uint Value
Definition: LuaTypes.cs:117
LuaUInt32(double v)
Definition: LuaTypes.cs:119
override string ToString()
Definition: LuaTypes.cs:131
LuaUInt64(double lo, double hi)
Definition: LuaTypes.cs:173
readonly ulong Value
Definition: LuaTypes.cs:166
LuaUInt64(string v, int radix=10)
Definition: LuaTypes.cs:178
LuaUInt64(double v)
Definition: LuaTypes.cs:168
override string ToString()
Definition: LuaTypes.cs:185