DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
EnConvert.c
См. документацию.
1class bool
2{
3 string ToString()
4 {
5 if (value) return "true";
6 else return "false";
7 }
8};
9
10class func
11{
13 private proto void SetInstance(Class inst);
14};
15
17{
18 NO = 0,
19 YES = 1
20}
21
22class int
23{
24 protected const int ZERO_PAD_SIZE = 8;
25 protected static string m_ZeroPad[ZERO_PAD_SIZE] = {"", "0", "00", "000", "0000", "00000", "000000", "0000000"};
26
27 const int MAX = 2147483647;
28 const int MIN = -2147483648;
29
30 proto string ToString();
31
44 proto string AsciiToString();
45
59 string ToStringLen(int len)
60 {
61 string str = value.ToString();
62
63 int l = len - str.Length();
64
65 if (l > 0 && l < ZERO_PAD_SIZE )
66 return m_ZeroPad[l] + str;
67
68 return str;
69 }
70
82 proto string ToHex();
83
97 bool InRange( int min, int max, bool inclusive_min = true, bool inclusive_max = true )
98 {
99 if( ( !inclusive_min && value <= min ) || value < min )
100 return false;
101
102 if( ( !inclusive_max && value >= max ) || value > max )
103 return false;
104
105 return true;
106 }
107};
108
109class float
110{
111 const float MIN = FLT_MIN;
112 const float MAX = FLT_MAX;
113 const float LOWEST = -FLT_MAX;
114
115 proto string ToString(bool simple = true);
116};
117
119{
120 static const vector Up = "0 1 0";
121 static const vector Aside = "1 0 0";
122 static const vector Forward = "0 0 1";
123 static const vector Zero = "0 0 0";
124
138 proto string ToString(bool beautify = true);
139
153 proto float Normalize();
154
157
169 proto native float Length();
170
182 proto native float LengthSq();
183
196 proto static native float Distance(vector v1, vector v2);
197
210 proto static native float DistanceSq(vector v1, vector v2);
211
223 {
224 return value * vector.Up;
225 }
226
240 {
241 float x = value[1] * v[2] - value[2] * v[1];
242 float y = value[2] * v[0] - value[0] * v[2];
243 float z = value[0] * v[1] - value[1] * v[0];
244
245 return Vector(x, y, z);
246 }
247
255 {
256 vector dir_vec;
257
258 dir_vec[0] = p2[0] - p1[0];
259 dir_vec[1] = p2[1] - p1[1];
260 dir_vec[2] = p2[2] - p1[2];
261
262 return dir_vec;
263 }
264
281
295 {
297 }
298
305 static float Dot(vector v1, vector v2)
306 {
307 return ((v1[0] * v2[0]) + (v1[1] * v2[1]) + (v1[2] * v2[2]));
308 }
309
321 {
322 for(int i = 0; i < 3; i++) {
323 if(value[i] > 180)
324 value[i] = value[i] - 360;
325 if(value[i] < -180)
326 value[i] = value[i] + 360;
327 }
328 return value;
329 }
330
345 proto float VectorToYaw();
346
359 proto native static vector YawToVector(float yaw);
360
375
390
404 proto void RotationMatrixFromAngles(out vector mat[3]);
405
419 proto vector Multiply4(vector mat[4]);
420
434 proto vector Multiply3(vector mat[3]);
435
450
465
474 proto static native vector Lerp(vector v1, vector v2, float t);
475
483
484 static vector RotateAroundZeroDeg(vector vec, vector axis, float angle)
485 {
486 return (vec * Math.Cos(angle * Math.DEG2RAD)) + ((axis * vec) * Math.Sin(angle * Math.DEG2RAD)) + (axis * vector.Dot(axis, vec)) * (1 - Math.Cos(angle * Math.DEG2RAD));
487 }
488
496
497 static vector RotateAroundZeroRad(vector vec, vector axis, float angle)
498 {
499 return (vec * Math.Cos(angle)) + ((axis * vec) * Math.Sin(angle)) + (axis * vector.Dot(axis, vec)) * (1 - Math.Cos(angle));
500 }
501
510
511 static vector RotateAroundZero(vector pos, vector axis, float cosAngle, float sinAngle)
512 {
513 return (pos * cosAngle) + ((axis * pos) * sinAngle) + (axis * vector.Dot(axis, pos)) * (1 - cosAngle);
514 }
515
525 static vector RotateAroundPoint(vector point, vector pos, vector axis, float cosAngle, float sinAngle)
526 {
527 vector offsetPos = pos - point;
528 return RotateAroundZero(offsetPos, axis, cosAngle, sinAngle) + point;
529 }
530
536 static vector ArrayToVec(float arr[])
537 {
538 return Vector(arr[0], arr[1], arr[2]);
539 }
540
542 static void SanitizeMinsMaxs(inout vector min, inout vector max)
543 {
544 vector minTmp, maxTmp;
545 minTmp[0] = Math.Min(min[0],max[0]);
546 maxTmp[0] = Math.Max(min[0],max[0]);
547 minTmp[1] = Math.Min(min[1],max[1]);
548 maxTmp[1] = Math.Max(min[1],max[1]);
549 minTmp[2] = Math.Min(min[2],max[2]);
550 maxTmp[2] = Math.Max(min[2],max[2]);
551 min = minTmp;
552 max = maxTmp;
553 }
554};
555
557{
565 proto volatile Class Spawn();
566
571 proto owned string GetModule();
572
574 proto native owned string ToString();
575
584 proto native bool IsInherited(typename baseType);
585
586 proto native int GetVariableCount();
587 proto native owned string GetVariableName(int vIdx);
588 proto native typename GetVariableType(int vIdx);
589 proto bool GetVariableValue(Class var, int vIdx, out void val);
590
598 static string EnumToString(typename e, int enumValue)
599 {
600 int cnt = e.GetVariableCount();
601 int val;
602
603 for (int i = 0; i < cnt; ++i)
604 {
605 if (e.GetVariableType(i) == int && e.GetVariableValue(null, i, val) && val == enumValue)
606 {
607 return e.GetVariableName(i);
608 }
609 }
610
611 return "unknown";
612 }
613
614 static string EnumFlagsToString(typename enumType, int value)
615 {
616 // Exact match first (non-flags and exact declared combinations)
617 string exact = enumType.EnumToString(enumType, value);
618 if (exact != "unknown")
619 return exact;
620
621 // unknown handlind
622 if (value == 0)
623 {
624 string zeroName = enumType.EnumToString(enumType, 0);
625 if (zeroName != string.Empty)
626 return zeroName;
627 else
628 return "unknown";
629 }
630
631 // Iterate bits and resolve each flag name
632 int remaining = value;
633 array<string> parts = {};
634 int bit = 1;
635
636 // keep within 32-bit enums
637 for (int i = 0; i < 32 && remaining != 0; ++i)
638 {
639 bit <<= 1;
640 if ((value & bit) != 0)
641 {
642 string name = enumType.EnumToString(enumType, bit);
643 if (name != "unknown")
644 {
645 parts.Insert(name);
646 remaining &= ~bit;
647 }
648 }
649 }
650
651 // If we couldn't map all bits, include the unknown residue in hex
652 if (remaining != 0)
653 parts.Insert(string.Format("0x%1", remaining.ToHex()));
654
655 if (parts.Count() == 0)
656 {
657 // Nothing mapped; last resort: hex of the original value
658 return string.Format("0x%1", value.ToHex());
659 }
660
661 return string.Join("|", parts);
662 }
663
670 static int StringToEnum(typename e, string enumName)
671 {
672 int count = e.GetVariableCount();
673 int value;
674
675 for (int i = 0; i < count; ++i)
676 {
677 if (e.GetVariableType(i) == int && e.GetVariableValue(null, i, value) && e.GetVariableName(i) == enumName)
678 {
679 return value;
680 }
681 }
682
683 return -1;
684 }
685};
686
688{
689 private void EnumTools();
690 private void ~EnumTools();
691
699 static string EnumToString(typename e, int enumValue)
700 {
701 return typename.EnumToString(e, enumValue);
702 }
703
704 static string EnumFlagsToString(typename enumType, int enumValue)
705 {
706 return typename.EnumFlagsToString(enumType, enumValue);
707 }
708
715 static int StringToEnum(typename e, string enumName)
716 {
717 return typename.StringToEnum(e, enumName);
718 }
719
726 static int GetEnumSize(typename e)
727 {
728 return e.GetVariableCount();
729 }
730
737 static int GetEnumValue(typename e, int idx)
738 {
739 int value;
740 e.GetVariableValue(null, idx, value);
741 return value;
742 }
743
750 static int GetLastEnumValue(typename e)
751 {
752 int lastValue;
753 e.GetVariableValue(null, e.GetVariableCount() - 1, lastValue);
754 return lastValue;
755 }
756}
ActionOverrideData int
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
enum EBool ZERO_PAD_SIZE
const int MIN
Определения EnConvert.c:28
proto string ToHex()
Integer to hex (as string)
bool InRange(int min, int max, bool inclusive_min=true, bool inclusive_max=true)
Check whether integer falls into an inclusive range.
Определения EnConvert.c:97
string ToStringLen(int len)
Integer to string with fixed length, padded with zeroes.
Определения EnConvert.c:59
static string m_ZeroPad[ZERO_PAD_SIZE]
Определения EnConvert.c:25
EBool
Определения EnConvert.c:17
@ NO
Определения EnConvert.c:18
@ YES
Определения EnConvert.c:19
proto string AsciiToString()
Converts ASCII code to string.
const int MAX
Определения EnConvert.c:27
proto string ToString()
Empty
Определения Hand_States.c:14
Icon x
Icon y
Super root of all classes in Enforce script.
Определения EnScript.c:11
void ~EnumTools()
static int GetEnumSize(typename e)
Return amount of values in enum.
Определения EnConvert.c:726
static int GetEnumValue(typename e, int idx)
Return the nth value in the enum.
Определения EnConvert.c:737
static int GetLastEnumValue(typename e)
Return amount of values in enum.
Определения EnConvert.c:750
static string EnumToString(typename e, int enumValue)
Return string name of enum value.
Определения EnConvert.c:699
static int StringToEnum(typename e, string enumName)
Return enum value from string name.
Определения EnConvert.c:715
static string EnumFlagsToString(typename enumType, int enumValue)
Определения EnConvert.c:704
void EnumTools()
Определения EnMath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
string ToString()
Определения EnConvert.c:3
Определения EnConvert.c:2
const float MIN
Определения EnConvert.c:111
proto string ToString(bool simple=true)
const float MAX
Определения EnConvert.c:112
const float LOWEST
Определения EnConvert.c:113
Определения EnConvert.c:110
proto void SetInstance(Class inst)
For internal usage of VM.
Определения EnConvert.c:11
proto volatile Class Spawn()
Dynamic variant to 'new' keyword. It creates new instance of class.
static string EnumFlagsToString(typename enumType, int value)
Определения EnConvert.c:614
proto owned string GetModule()
Get the name of the module the typename belongs to.
proto native GetVariableType(int vIdx)
proto native owned string GetVariableName(int vIdx)
proto native bool IsInherited(typename baseType)
Returns true when type is the same as 'baseType', or inherited one.
proto bool GetVariableValue(Class var, int vIdx, out void val)
proto native int GetVariableCount()
proto native owned string ToString()
Returns type name of variable as string.
static int StringToEnum(typename e, string enumName)
Return enum value from string name.
Определения EnConvert.c:670
static string EnumToString(typename e, int enumValue)
Return string name of enum value.
Определения EnConvert.c:598
Определения EnConvert.c:557
proto vector InvMultiply4(vector mat[4])
Invert-transforms position.
proto vector Multiply3(vector mat[3])
Transforms vector.
static vector RandomDir()
Returns randomly generated unit vector.
Определения EnConvert.c:277
vector GetRelAngles()
Returns relative angles between -180 and 180, not 0 to 360.
Определения EnConvert.c:320
proto vector Normalized()
return normalized vector (keeps orginal vector untouched)
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
proto native float Length()
Returns length of vector (magnitude)
static const vector Aside
Определения EnConvert.c:121
proto vector Multiply4(vector mat[4])
Transforms position.
static vector RotateAroundZeroDeg(vector vec, vector axis, float angle)
Rotate a vector around 0,0,0 by an angle in degrees.
Определения EnConvert.c:484
proto native float LengthSq()
Returns squared length (magnitudeSqr)
static vector ArrayToVec(float arr[])
Convert static array of floats into a vector.
Определения EnConvert.c:536
static vector RotateAroundZeroRad(vector vec, vector axis, float angle)
Rotate a vector around 0,0,0 by an angle in radians.
Определения EnConvert.c:497
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Определения EnConvert.c:305
static const vector Forward
Определения EnConvert.c:122
static const vector Zero
Определения EnConvert.c:123
static vector RandomDir2D()
Returns randomly generated XZ unit vector with the Y(up) axis set to 0.
Определения EnConvert.c:294
vector Cross(vector v)
Returns cross product of this vector with passed vector.
Определения EnConvert.c:239
proto float Normalize()
Normalizes vector. Returns length.
static void SanitizeMinsMaxs(inout vector min, inout vector max)
Makes sure all values in MIN are lower than the MAX.
Определения EnConvert.c:542
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
Определения EnConvert.c:254
static vector RotateAroundZero(vector pos, vector axis, float cosAngle, float sinAngle)
Rotate a vector around 0,0,0.
Определения EnConvert.c:511
proto void RotationMatrixFromAngles(out vector mat[3])
Creates rotation matrix from angles.
static vector RotateAroundPoint(vector point, vector pos, vector axis, float cosAngle, float sinAngle)
Rotate a vector around point.
Определения EnConvert.c:525
proto vector InvMultiply3(vector mat[3])
Invert-transforms vector.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto string ToString(bool beautify=true)
Vector to string.
proto static native vector YawToVector(float yaw)
Returns vector of yaw.
static const vector Up
Определения EnConvert.c:120
proto float VectorToYaw()
Returns yaw of vector.
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
static proto native vector Lerp(vector v1, vector v2, float t)
Lerp between two vectors.
proto vector AnglesToVector()
Converts spherical coordinates (yaw, pitch, roll in degrees) to unit length vector.
vector Perpend()
Returns perpendicular vector. Perpendicular vector is computed as cross product between input vector ...
Определения EnConvert.c:222
Определения EnConvert.c:119
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Max(float x, float y)
Returns bigger of two given values.
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:106
static proto float Min(float x, float y)
Returns smaller of two given values.
static proto float Cos(float angle)
Returns cosinus of angle in radians.
static proto float Sin(float angle)
Returns sinus of angle in radians.
static const float DEG2RAD
Определения EnMath.c:17
proto native int Length()
Returns length of string.
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.