DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
EnScript.c
См. документацию.
1
8
10class Class
11{
23 proto native external bool IsInherited(typename type);
24
37 proto native owned external string ClassName();
38
39 string GetDebugName() { return ClassName(); }
40
52 proto native external typename Type();
53
64 proto external static typename StaticType();
65
73 static typename StaticGetType(typename t)
74 {
75 return t;
76 }
77
78 proto external string ToString();
79
94 proto static Class Cast(Class from);
95
110 proto static bool CastTo(out Class to, Class from);
111
113 private proto static bool SafeCastType(Class type, out Class to, Class from);
114};
115
118{
119};
120
123{
124};
125
127typedef int[] TypeID;
128
131{
132 private void ~ScriptModule();
133
139 proto volatile int Call(Class inst, string function, void parm);
140
146 proto volatile int CallFunction(Class inst, string function, out void returnVal, void parm);
147 proto volatile int CallFunctionParams(Class inst, string function, out void returnVal, Class parms);
148 proto native void Release();
149
160 static proto native ScriptModule LoadScript(ScriptModule parentModule, string scriptFile, bool listing);
161};
162
163//main script module (contains script.c and this file)
164//ScriptModule g_Script;
165
167{
168 private void EnScript() {}
169 private void ~EnScript() {}
170
188 static proto int GetClassVar(Class inst, string varname,int index, out void result);
189
211 static proto int SetClassVar(Class inst, string varname, int index, void input);
212
222 static proto int SetVar(out void var, string value);
223
230 static proto void Watch(void var, int flags);
231};
232
233
234
253proto void Sort(void param_array[], int num);
254proto void reversearray(void param_array);
255proto void copyarray(void destArray, void srcArray);
256
287proto int ParseStringEx(inout string input, string token);
288
307proto int ParseString(string input, out string tokens[]);
308
318proto native int KillThread(Class owner, string name);
319
323proto volatile void Idle();
324
336proto owned string ThreadFunction(Class owner, string name, int backtrace, out int linenumber);
337
339string String(string s)
340{
341 return s;
342}
343
360{
361 string m_Msg;
362 void Obsolete(string msg = "")
363 {
364 m_Msg = msg;
365 }
366}
367
369void PrintString(string s)
372}
373
374class array<Class T>
375{
380 proto native int Count();
385 proto native void Clear();
389 proto void Set(int n, T value);
394 proto int Find(T value);
398
399 proto T Get(int n);
407 proto int Insert(T value);
418 proto int InsertAt(T value, int index);
449 void InsertAll(notnull array<T> from)
450 {
451 int nFrom = from.Count();
452 for ( int i = 0; i < nFrom; ++i )
453 {
454 Insert( from.Get(i) );
455 }
456 }
457
463 proto native void Remove(int index);
470 proto native void RemoveOrdered(int index);
476 proto native void Resize(int newSize);
477
482 proto native void Reserve(int newSize);
483
488 proto native void Swap(notnull array<T> other);
489
493 proto native void Sort(bool reverse = false);
498
499 proto int Copy(notnull array<T> from);
500 proto int Init(T init[]);
501
502 void RemoveItem(T value)
503 {
504 int remove_index = Find(value);
505
506 if ( remove_index >= 0 )
507 {
508 RemoveOrdered(remove_index);
509 }
510 }
511
513 {
514 int remove_index = Find(value);
515
516 if ( remove_index >= 0 )
517 {
518 Remove(remove_index);
519 }
520 }
521
522 bool IsValidIndex( int index )
523 {
524 return ( index > -1 && index < Count() );
525 }
526
527 /*
528 T GetChecked( int index )
529 {
530 if( IsValidIndex( index ) )
531 return Get( index );
532 else
533 return null;
534 }
535 */
536
548 void Debug()
549 {
550 Print(string.Format("Array count: %1", Count()));
551 for (int i = 0; i < Count(); i++)
552 {
553 T item = Get(i);
554 Print(string.Format("[%1] => %2", i, item));
555 }
556 }
557
568 {
569 if ( Count() > 0 )
570 {
571 return Math.RandomInt(0, Count());
572 }
573
574 return -1;
575 }
576
587 {
588 return Get(GetRandomIndex());
589 }
590
591 void SwapItems(int item1_index, int item2_index)
592 {
593 T item1 = Get(item1_index);
594 Set(item1_index, Get(item2_index));
595 Set(item2_index, item1);
596 }
597
599 {
600 foreach(T item : other)
601 {
602 Insert(item);
603 }
604 }
605
606 void Invert()
607 {
608 int left = 0;
609 int right = Count() - 1;
610 if (right > 0)
611 {
612 while (left < right)
613 {
614 T temp = Get(left);
615 Set(left++, Get(right));
616 Set(right--, temp);
617 }
618 }
619 }
620
634 int MoveIndex(int curr_index, int move_number)
635 {
636 int count = Count();
637 int new_index = curr_index;
638
639 if ( move_number > 0 )
640 {
641 new_index = curr_index + move_number;
642 }
643
644 if ( move_number < 0 )
645 {
646 new_index = curr_index - move_number;
647
648 if ( new_index < 0 )
649 {
650 if ( new_index <= -count )
651 {
652 new_index = (new_index % count);
653 }
654
655 new_index = new_index + count;
656 }
657 }
658
659 if ( new_index >= count )
660 {
661 new_index = (new_index % count);
662 }
663
664 // move_number is 0
665 return new_index;
666 }
667
669 {
670 for (int i = 0; i < Count(); i++)
671 {
673 }
674 }
675
689 {
690 if (Count() != pOtherArray.Count())
691 {
692 ErrorEx("arrays are not the same size");
693 return -1;
694 }
695
696 int nOther = pOtherArray.Count();
697 for (int i = 0; i < nOther; ++i)
698 {
699 if (Get(i) != pOtherArray.Get(i))
700 {
701 return i;
702 }
703 }
704
705 return -1;
706 }
707
720 array<T> Slice(int from, int to)
721 {
722 array<T> result = new array<T>();
723 for (int i = from; i <= to && i < Count(); ++i)
724 result.Insert(Get(i));
725
726 return result;
727 }
728}
729
730//force these to compile so we can link C++ methods to them
740
741class set<Class T>
742{
743 proto native int Count();
744 proto native void Clear();
749 proto int Find(T value);
750 proto T Get(int n);
758 proto int Insert(T value);
769 proto int InsertAt(T value, int index);
775 proto native void Remove(int index);
776 proto int Copy(set<T> from);
777 proto native void Swap(set<T> other);
778 proto int Init(T init[]);
779
780 void InsertSet(set<T> other)
781 {
782 int count = other.Count();
783 for (int i = 0; i < count; i++)
784 {
785 T item = other[i];
786 Insert(item);
787 }
788 }
789
790 void RemoveItem(T value)
791 {
792 int remove_index = Find(value);
793 if (remove_index >= 0)
794 {
795 Remove(remove_index);
796 }
797 }
798
799 void RemoveItems(set<T> other)
800 {
801 int count = other.Count();
802 for (int i = 0; i < count; i++)
803 {
804 T item = other[i];
805 RemoveItem(item);
806 }
807 }
808
809 void Debug()
810 {
811 Print(string.Format("Set count: %1", Count()));
812 for (int i = 0; i < Count(); i++)
813 {
814 T item = Get(i);
815 Print(string.Format("[%1] => %2", i, item));
816 }
817 }
818};
819
820//force these to compile so we can link C++ methods to them
821typedef set<string> TStringSet;
822typedef set<float> TFloatSet;
823typedef set<int> TIntSet;
824typedef set<Class> TClassSet;
825typedef set<Managed> TManagedSet;
826typedef set<ref Managed> TManagedRefSet;
827typedef set<typename> TTypenameSet;
828
829typedef int MapIterator;
846class map<Class TKey,Class TValue>
847{
852 proto native int Count();
853
857 proto native void Clear();
866 proto TValue Get(TKey key);
877 proto bool Find(TKey key, out TValue val);
887 proto TValue GetElement(int index);
897 proto TKey GetKey(int i);
902 proto void Set(TKey key, TValue value);
906 proto void Remove(TKey key);
913 proto void RemoveElement(int i);
917 proto bool Contains(TKey key);
926 proto bool Insert(TKey key, TValue value);
927 proto int Copy(map<TKey,TValue> from);
928
930 {
931 array<TKey> keys = new array<TKey>();
932 for (int i = 0; i < Count(); ++i)
933 keys.Insert(GetKey(i));
934
935 return keys;
936 }
937
939 {
940 array<TValue> elements = new array<TValue>();
941 for (int i = 0; i < Count(); ++i)
942 elements.Insert(GetElement(i));
943
944 return elements;
945 }
946
947 bool ReplaceKey(TKey old_key, TKey new_key)
948 {
949 if (Contains(old_key))
950 {
951 Set(new_key, Get(old_key));
952 Remove(old_key);
953 return true;
954 }
955 return false;
956 }
957
958 TKey GetKeyByValue(TValue value)
959 {
960 TKey ret;
961 for (int i = 0; i < Count(); i++)
962 {
963 if (GetElement(i) == value)
964 {
965 ret = GetKey(i);
966 break;
967 }
968 }
969
970 return ret;
971 }
972
973 bool GetKeyByValueChecked(TValue value, out TKey key)
974 {
975 for (int i = 0; i < Count(); i++)
976 {
977 if (GetElement(i) == value)
978 {
979 key = GetKey(i);
980 return true;
981 }
982 }
983 return false;
984 }
985
986 proto native MapIterator Begin();
987 proto native MapIterator End();
988 proto native MapIterator Next(MapIterator it);
991};
992
1001
1010
1019
1028
1037
1046
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DisplayElementBase GetElement(eDisplayElements element_id)
Определения DisplayStatus.c:96
enum MagnumStableStateID init
override float Get()
Определения PlayerStatBase.c:134
void Set(T value, string system="")
Определения PlayerStatBase.c:85
@ Count
Определения RandomGeneratorSyncManager.c:8
Super root of all classes in Enforce script.
Определения EnScript.c:11
TODO doc.
Определения EnScript.c:118
Определения EnMath.c:7
TODO doc.
Определения EnScript.c:123
Module containing compiled scripts.
Определения EnScript.c:131
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения Transport.c:70
proto void Print(void var)
Prints content of variable to console/log.
enum ShapeType ErrorEx
proto int ParseString(string input, out string tokens[])
Parses string into array of tokens returns number of tokens.
map< Managed, int > TManagedIntMap
Определения EnScript.c:1030
proto native void Sort(bool reverse=false)
map< Managed, Class > TManagedClassMap
Определения EnScript.c:1032
map< typename, float > TTypeNameFloatMap
Определения EnScript.c:1020
proto int ParseStringEx(inout string input, string token)
Parses one token from input string. Result is put into token string, and type of token is returned....
proto int Insert(T value)
static proto int SetClassVar(Class inst, string varname, int index, void input)
Dynamic write to variable by its name.
void InsertAll(notnull array< T > from)
Inserts all elements from array.
Определения EnScript.c:449
proto void Sort(void param_array[], int num)
Sorts static array of integers(ascendically) / floats(ascendically) / strings(alphabetically)
set< int > TIntSet
Определения EnScript.c:823
array< typename > TTypenameArray
Определения EnScript.c:739
static proto int SetVar(out void var, string value)
Sets variable value by value in string.
array< float > TFloatArray
Определения EnScript.c:732
proto int Init(T init[])
set< Class > TClassSet
Определения EnScript.c:824
map< Class, vector > TClassVectorMap
Определения EnScript.c:1018
void Debug()
Определения EnScript.c:809
map< Class, typename > TClassTypenameMap
Определения EnScript.c:1017
int MoveIndex(int curr_index, int move_number)
Returns a index in array moved by specific number.
Определения EnScript.c:634
proto void RemoveElement(int i)
array< TKey > GetKeyArray()
Определения EnScript.c:929
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
array< T > Slice(int from, int to)
Returns an array with elements from range given on input.
Определения EnScript.c:720
proto native void Clear()
map< ref Managed, Managed > TManagedRefManagedMap
Определения EnScript.c:1042
proto int Insert(T value)
static proto int GetClassVar(Class inst, string varname, int index, out void result)
Dynamic read of variable value by its name.
void SwapItems(int item1_index, int item2_index)
Определения EnScript.c:591
map< int, Class > TIntClassMap
Определения EnScript.c:996
proto native MapIterator End()
map< Class, float > TClassFloatMap
Определения EnScript.c:1011
proto void Set(int n, T value)
map< string, vector > TStringVectorMap
Определения EnScript.c:1009
proto native int KillThread(Class owner, string name)
Kills thread.
proto native owned external string ClassName()
Returns name of class-type.
map< int, string > TIntStringMap
Определения EnScript.c:995
map< int, float > TIntFloatMap
Определения EnScript.c:993
proto owned string ThreadFunction(Class owner, string name, int backtrace, out int linenumber)
Debug function. Returns current function on stack of the thread.
proto native external bool IsInherited(typename type)
Returns true when instance is of the type, or inherited one.
proto native void RemoveOrdered(int index)
proto void Remove(TKey key)
array< Managed > TManagedArray
Определения EnScript.c:736
void RemoveItem(T value)
Определения EnScript.c:790
map< ref Managed, vector > TManagedRefVectorMap
Определения EnScript.c:1045
void RemoveItemUnOrdered(T value)
Определения EnScript.c:512
bool IsValidIndex(int index)
Определения EnScript.c:522
int MapIterator
Определения EnScript.c:829
proto TValue Get(TKey key)
map< ref Managed, float > TManagedRefFloatMap
Определения EnScript.c:1038
array< vector > TVectorArray
Определения EnScript.c:738
proto int Find(T value)
array< ref Managed > TManagedRefArray
Определения EnScript.c:737
proto TKey GetIteratorKey(MapIterator it)
map< ref Managed, ref Managed > TManagedRefManagedRefMap
Определения EnScript.c:1043
proto native void Swap(notnull array< T > other)
proto volatile int CallFunctionParams(Class inst, string function, out void returnVal, Class parms)
proto T Get(int n)
void ~EnScript()
Определения EnScript.c:169
array< int > TIntArray
Определения EnScript.c:733
proto int InsertAt(T value, int index)
map< Class, Class > TClassClassMap
Определения EnScript.c:1014
Obsolete Managed PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Определения EnScript.c:369
static proto native ScriptModule LoadScript(ScriptModule parentModule, string scriptFile, bool listing)
Do load script and create ScriptModule for it.
proto int Copy(notnull array< T > from)
int GetRandomIndex()
Returns a random index of array. If Count is 0, return index is -1 .
Определения EnScript.c:567
array< Class > TClassArray
Определения EnScript.c:735
map< Class, int > TClassIntMap
Определения EnScript.c:1012
proto void copyarray(void destArray, void srcArray)
proto bool Contains(TKey key)
static proto void Watch(void var, int flags)
Debug tool for watching certain variable. Invokes debugger whenever is variable used.
proto native external Type()
Returns typename of object's class.
array< TValue > GetValueArray()
Определения EnScript.c:938
proto int Find(T value)
set< float > TFloatSet
Определения EnScript.c:822
string String(string s)
Helper for passing string expression to functions with void parameter. Example: Print(String("Hello "...
Определения EnScript.c:339
TKey GetKeyByValue(TValue value)
Определения EnScript.c:958
void EnScript()
Определения EnScript.c:168
map< ref Managed, typename > TManagedRefTypenameMap
Определения EnScript.c:1044
void InsertSet(set< T > other)
Определения EnScript.c:780
map< Managed, typename > TManagedTypenameMap
Определения EnScript.c:1035
proto TValue GetIteratorElement(MapIterator it)
map< string, int > TStringIntMap
Определения EnScript.c:1003
proto volatile void Idle()
set< ref Managed > TManagedRefSet
Определения EnScript.c:826
void InsertArray(array< T > other)
Определения EnScript.c:598
proto native int Count()
map< typename, vector > TTypeNameVectorMap
Определения EnScript.c:1027
proto native void Release()
map< ref Managed, string > TManagedRefStringMap
Определения EnScript.c:1040
map< int, typename > TIntTypenameMap
Определения EnScript.c:999
map< Class, ref Managed > TClassManagedRefMap
Определения EnScript.c:1016
proto volatile int Call(Class inst, string function, void parm)
map< Managed, Managed > TManagedManagedMap
Определения EnScript.c:1033
proto native void Reserve(int newSize)
void RemoveItem(T value)
Определения EnScript.c:502
proto native void Resize(int newSize)
map< typename, Managed > TTypeNameManagedMap
Определения EnScript.c:1024
proto volatile int CallFunction(Class inst, string function, out void returnVal, void parm)
proto static external StaticType()
Returns typename of object's reference.
proto bool Insert(TKey key, TValue value)
bool ReplaceKey(TKey old_key, TKey new_key)
Определения EnScript.c:947
proto void reversearray(void param_array)
map< Managed, ref Managed > TManagedManagedRefMap
Определения EnScript.c:1034
proto native MapIterator Next(MapIterator it)
void RemoveItems(set< T > other)
Определения EnScript.c:799
map< string, ref Managed > TStringManagedRefMap
Определения EnScript.c:1007
proto native void Clear()
map< typename, ref Managed > TTypeNameManagedRefMap
Определения EnScript.c:1025
map< typename, int > TTypeNameIntMap
Определения EnScript.c:1021
proto native MapIterator Begin()
static StaticGetType(typename t)
Returns typename of class even without a variable or instance.
Определения EnScript.c:73
map< string, string > TStringStringMap
Определения EnScript.c:1004
array< bool > TBoolArray
Определения EnScript.c:734
map< Class, string > TClassStringMap
Определения EnScript.c:1013
map< int, int > TIntIntMap
Определения EnScript.c:994
void Debug()
Print all elements in array.
Определения EnScript.c:548
proto external string ToString()
string GetDebugName()
Определения EnScript.c:39
int DifferentAtPosition(array< T > pOtherArray)
Returns an index where 2 arrays start to differ from each other.
Определения EnScript.c:688
map< string, float > TStringFloatMap
Определения EnScript.c:1002
map< ref Managed, int > TManagedRefIntMap
Определения EnScript.c:1039
T GetRandomElement()
Returns a random element of array.
Определения EnScript.c:586
proto native void Remove(int index)
proto void Set(TKey key, TValue value)
map< typename, Class > TTypeNameClassMap
Определения EnScript.c:1023
bool GetKeyByValueChecked(TValue value, out TKey key)
Определения EnScript.c:973
class array< Class T > TStringArray
void Obsolete(string msg="")
Определения EnScript.c:362
static proto Class Cast(Class from)
Try to safely down-cast base class to child class.
void ~ScriptModule()
proto int Init(T init[])
map< string, Class > TStringClassMap
Определения EnScript.c:1005
int[] TypeID
script representation for C++ RTTI types
Определения EnScript.c:127
proto TValue GetElement(int index)
string m_Msg
Определения EnScript.c:361
set< typename > TTypenameSet
Определения EnScript.c:827
proto native int Count()
map< typename, string > TTypeNameStringMap
Определения EnScript.c:1022
proto int InsertAt(T value, int index)
map< int, Managed > TIntManagedMap
Определения EnScript.c:997
set< string > TStringSet
Определения EnScript.c:821
map< string, typename > TStringTypenameMap
Определения EnScript.c:1008
map< Managed, float > TManagedFloatMap
Определения EnScript.c:1029
proto T Get(int n)
proto int Copy(set< T > from)
proto int Copy(map< TKey, TValue > from)
proto native void Swap(set< T > other)
void ShuffleArray()
Определения EnScript.c:668
static proto bool SafeCastType(Class type, out Class to, Class from)
This function is for internal script usage.
proto bool Find(TKey key, out TValue val)
map< int, vector > TIntVectorMap
Определения EnScript.c:1000
set< Managed > TManagedSet
Определения EnScript.c:825
map< int, ref Managed > TIntManagedRefMap
Определения EnScript.c:998
map< typename, typename > TTypeNameTypenameMap
Определения EnScript.c:1026
map< ref Managed, Class > TManagedRefClassMap
Определения EnScript.c:1041
proto native void Remove(int index)
void Invert()
Определения EnScript.c:606
map< Managed, string > TManagedStringMap
Определения EnScript.c:1031
map< Managed, vector > TManagedVectorMap
Определения EnScript.c:1036
map< string, Managed > TStringManagedMap
Определения EnScript.c:1006
map< Class, Managed > TClassManagedMap
Определения EnScript.c:1015
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].