Elin Decompiled Documentation EA 23.348.1 Nightly
Loading...
Searching...
No Matches
ClassExtension.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6using System.Reflection;
7using System.Text;
8using System.Text.RegularExpressions;
9using Pluralize.NET;
10using Unity.Collections.LowLevel.Unsafe;
11using UnityEngine;
12using UnityEngine.Events;
13using UnityEngine.UI;
14
15public static class ClassExtension
16{
17 public static class EnumSize<T>
18 {
19 public static readonly bool IsInt = typeof(T).IsEnum && Enum.GetUnderlyingType(typeof(T)) == typeof(int);
20
21 public static readonly bool IsLong = typeof(T).IsEnum && Enum.GetUnderlyingType(typeof(T)) == typeof(long);
22 }
23
24 public static class EnumNames<T>
25 {
26 public static readonly Dictionary<string, T> cached;
27
28 public static readonly Dictionary<string, T> fuzzy;
29
30 static EnumNames()
31 {
32 cached = new Dictionary<string, T>();
33 fuzzy = new Dictionary<string, T>(StringComparer.OrdinalIgnoreCase);
34 string[] names = Enum.GetNames(typeof(T));
35 foreach (string text in names)
36 {
37 T value = (T)Enum.Parse(typeof(T), text);
38 cached[text] = value;
39 fuzzy.TryAdd(text, value);
40 }
41 }
42 }
43
44 private static Vector3 vector3;
45
46 public static IPluralize pluralizer = new Pluralizer();
47
48 public static string lang(this string s)
49 {
50 return Lang.Get(s);
51 }
52
53 public static string langPlural(this string s, int i)
54 {
55 string text = Lang.Get(s);
56 return Lang.Parse((i <= 1 || !Lang.setting.pluralize) ? text : pluralizer.Pluralize(text), i.ToString() ?? "");
57 }
58
59 public static string lang(this string s, string ref1, string ref2 = null, string ref3 = null, string ref4 = null, string ref5 = null)
60 {
61 return Lang.Parse(s, ref1, ref2, ref3, ref4, ref5);
62 }
63
64 public static string[] langList(this string s)
65 {
66 return Lang.GetList(s);
67 }
68
69 public static string langGame(this string s)
70 {
71 return Lang.Game.Get(s);
72 }
73
74 public static string langGame(this string s, string ref1, string ref2 = null, string ref3 = null, string ref4 = null)
75 {
76 return Lang.Game.Parse(s, ref1, ref2, ref3, ref4);
77 }
78
79 public static string Parentheses(this string str)
80 {
81 return "(" + str + ")";
82 }
83
84 public static string Bracket(this string str, int type = 0)
85 {
86 switch (type)
87 {
88 case -1:
89 return str;
90 case 1:
91 case 2:
92 case 3:
93 case 4:
94 case 5:
95 {
96 string[] list = Lang.GetList("bracket_" + type);
97 return list[0] + str + list[1];
98 }
99 default:
100 return "_bracketLeft".lang() + str + "_bracketRight".lang();
101 }
102 }
103
104 public static byte[] ToBytes(this BitArray bits)
105 {
106 byte[] array = new byte[(bits.Length - 1) / 8 + 1];
107 bits.CopyTo(array, 0);
108 return array;
109 }
110
111 public static bool GetBit(this byte pByte, int bitNo)
112 {
113 return (pByte & (1 << bitNo)) != 0;
114 }
115
116 public static byte SetBit(this byte pByte, int bitNo, bool value)
117 {
118 if (!value)
119 {
120 return Convert.ToByte(pByte & ~(1 << bitNo));
121 }
122 return Convert.ToByte(pByte | (1 << bitNo));
123 }
124
125 public static int ToInt3(this float a)
126 {
127 return (int)(a * 1000f);
128 }
129
130 public static float FromInt3(this int a)
131 {
132 return (float)a / 1000f;
133 }
134
135 public static int ToInt2(this float a)
136 {
137 return (int)(a * 100f);
138 }
139
140 public static float FromInt2(this int a)
141 {
142 return (float)a / 100f;
143 }
144
145 public static int Minimum(this int i)
146 {
147 if (i != 0)
148 {
149 if (i <= 0)
150 {
151 return -1;
152 }
153 return 1;
154 }
155 return 0;
156 }
157
158 public static bool IsNull(this object o)
159 {
160 return o == null;
161 }
162
163 public static bool IsOn(this int data, int digit)
164 {
165 BitArray32 bitArray = default(BitArray32);
166 bitArray.SetInt(data);
167 return bitArray[digit];
168 }
169
170 public static T ToEnum<T>(this int value)
171 {
172 if (!EnumSize<T>.IsInt)
173 {
174 return (T)Enum.ToObject(typeof(T), value);
175 }
176 return UnsafeUtility.As<int, T>(ref value);
177 }
178
179 public static T ToEnum<T>(this long value)
180 {
181 if (!EnumSize<T>.IsLong)
182 {
183 return (T)Enum.ToObject(typeof(T), value);
184 }
185 return UnsafeUtility.As<long, T>(ref value);
186 }
187
188 public static T ToEnum<T>(this string value, bool ignoreCase = true)
189 {
190 if (EnumNames<T>.cached.TryGetValue(value, out var value2))
191 {
192 return value2;
193 }
194 if (ignoreCase && EnumNames<T>.fuzzy.TryGetValue(value, out value2))
195 {
196 return value2;
197 }
198 return (T)Enum.Parse(typeof(T), value, ignoreCase);
199 }
200
201 public static Type ToType(this string value)
202 {
203 return Type.GetType("Elona." + value + ", Assembly-CSharp");
204 }
205
206 public static T NextEnum<T>(this T src) where T : struct
207 {
208 return ((T[])Enum.GetValues(src.GetType())).NextItem(src);
209 }
210
211 public static T PrevEnum<T>(this T src) where T : struct
212 {
213 return ((T[])Enum.GetValues(src.GetType())).PrevItem(src);
214 }
215
216 public static bool Within(this int v, int v2, int range)
217 {
218 if (v - v2 >= range)
219 {
220 return v - v2 < -range;
221 }
222 return true;
223 }
224
225 public static bool Within(this byte v, byte v2, byte range)
226 {
227 if (v - v2 >= range)
228 {
229 return v - v2 < -range;
230 }
231 return true;
232 }
233
234 public static int Clamp(this int v, int min, int max, bool loop = false)
235 {
236 if (v < min)
237 {
238 v = ((!loop) ? min : max);
239 }
240 else if (v > max)
241 {
242 v = ((!loop) ? max : min);
243 }
244 return v;
245 }
246
247 public static int ClampMin(this int v, int min)
248 {
249 if (v >= min)
250 {
251 return v;
252 }
253 return min;
254 }
255
256 public static int ClampMax(this int v, int max)
257 {
258 if (v <= max)
259 {
260 return v;
261 }
262 return max;
263 }
264
265 public static T ToField<T>(this string s, object o)
266 {
267 return (T)o.GetType().GetField(s).GetValue(o);
268 }
269
270 public static bool HasField<T>(this object o, string name)
271 {
272 FieldInfo field = o.GetType().GetField(name);
273 if (field != null)
274 {
275 return typeof(T).IsAssignableFrom(field.FieldType);
276 }
277 return false;
278 }
279
280 public static T GetField<T>(this object o, string name)
281 {
282 return (T)o.GetType().GetField(name).GetValue(o);
283 }
284
285 public static void SetField<T>(this object o, string name, T value)
286 {
287 o.GetType().GetField(name).SetValue(o, value);
288 }
289
290 public static T GetProperty<T>(this object o, string name)
291 {
292 return (T)o.GetType().GetProperty(name).GetValue(o);
293 }
294
295 public static void SetProperty<T>(this object o, string name, T value)
296 {
297 o.GetType().GetProperty(name).SetValue(o, value);
298 }
299
300 public static void Sort<T>(this IList<T> list, Comparison<T> comparison)
301 {
302 if (list is List<T>)
303 {
304 ((List<T>)list).Sort(comparison);
305 return;
306 }
307 List<T> list2 = new List<T>(list);
308 list2.Sort(comparison);
309 for (int i = 0; i < list.Count; i++)
310 {
311 list[i] = list2[i];
312 }
313 }
314
315 public static void Sort<T>(this IList<T> list, Func<T, int> keySelector)
316 {
317 List<T> list2 = list.OrderBy(keySelector).ToList();
318 list.Clear();
319 foreach (T item in list2)
320 {
321 list.Add(item);
322 }
323 }
324
325 public static TValue TryGet<TValue>(this IList<TValue> array, int index, int defIndex = -1)
326 {
327 if (array.Count != 0)
328 {
329 if (index >= array.Count)
330 {
331 if (defIndex != -1)
332 {
333 if (array.Count <= defIndex)
334 {
335 return array[Mathf.Max(0, array.Count - 1)];
336 }
337 return array[defIndex];
338 }
339 return array[Mathf.Max(0, array.Count - 1)];
340 }
341 return array[Math.Max(0, index)];
342 }
343 return default(TValue);
344 }
345
346 public static TValue TryGet<TValue>(this IList<TValue> array, int index, bool returnNull)
347 {
348 if (index >= array.Count)
349 {
350 return default(TValue);
351 }
352 return array[index];
353 }
354
355 public static bool IsEmpty(this Array array)
356 {
357 if (array != null)
358 {
359 return array.Length == 0;
360 }
361 return true;
362 }
363
364 public static int IndexOf(this IList<Component> list, GameObject go)
365 {
366 if (!go)
367 {
368 return -1;
369 }
370 for (int i = 0; i < list.Count; i++)
371 {
372 if (list[i].gameObject == go)
373 {
374 return i;
375 }
376 }
377 return -1;
378 }
379
380 public static TValue Move<TValue>(this IList<TValue> list, TValue target, int a)
381 {
382 int num = list.IndexOf(target);
383 int num2 = num + a;
384 if (num2 < 0)
385 {
386 num2 = list.Count - 1;
387 }
388 if (num2 >= list.Count)
389 {
390 num2 = 0;
391 }
392 list.Remove(target);
393 list.Insert(num2, target);
394 return list[num];
395 }
396
397 public static IList<TValue> Copy<TValue>(this IList<TValue> list)
398 {
399 return list.ToList();
400 }
401
402 public static void Each<TValue>(this IList<TValue> list, Action<TValue> action)
403 {
404 for (int num = list.Count - 1; num >= 0; num--)
405 {
406 action(list[num]);
407 }
408 }
409
410 public static IList<TValue> Shuffle<TValue>(this IList<TValue> list)
411 {
412 int num = list.Count;
413 while (num > 1)
414 {
415 int index = Rand._random.Next(num);
416 num--;
417 TValue value = list[num];
418 list[num] = list[index];
419 list[index] = value;
420 }
421 return list;
422 }
423
424 public static TValue TryGetValue<TKey, TValue>(this IDictionary<TKey, TValue> source, TKey key, TValue fallback = default(TValue))
425 {
426 TValue value = default(TValue);
427 if (key != null && source.TryGetValue(key, out value))
428 {
429 return value;
430 }
431 return fallback;
432 }
433
434 public static TValue TryGetValue<TKey, TValue>(this IDictionary<TKey, TValue> source, TKey key, TKey key_fallback)
435 {
436 TValue value = default(TValue);
437 if (key != null && source.TryGetValue(key, out value))
438 {
439 return value;
440 }
441 return source[key_fallback];
442 }
443
444 public static TValue GetOrCreate<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key, Func<TValue> func = null)
445 {
446 TValue val = dict.TryGetValue(key);
447 if (val == null)
448 {
449 val = ((func != null) ? func() : Activator.CreateInstance<TValue>());
450 dict.Add(key, val);
451 }
452 return val;
453 }
454
455 public static TKey[] CopyKeys<TKey, TValue>(this IDictionary<TKey, TValue> dict)
456 {
457 TKey[] array = new TKey[dict.Keys.Count];
458 dict.Keys.CopyTo(array, 0);
459 return array;
460 }
461
462 public static TValue[] CopyValues<TKey, TValue>(this IDictionary<TKey, TValue> dict)
463 {
464 TValue[] array = new TValue[dict.Keys.Count];
465 dict.Values.CopyTo(array, 0);
466 return array;
467 }
468
469 public static T RandomItem<T>(this IEnumerable<T> ie)
470 {
471 int num = ie.Count();
472 if (num == 0)
473 {
474 return default(T);
475 }
476 return ie.ElementAt(Rand.rnd(num));
477 }
478
479 public static TValue RandomItem<TKey, TValue>(this IDictionary<TKey, TValue> source)
480 {
481 if (source.Count != 0)
482 {
483 return source.ElementAt(Rand.rnd(source.Count)).Value;
484 }
485 return default(TValue);
486 }
487
488 public static TValue RandomItem<TValue>(this IList<TValue> source)
489 {
490 if (source.Count != 0)
491 {
492 return source[Rand.rnd(source.Count)];
493 }
494 return default(TValue);
495 }
496
497 public static TValue RandomItem<TValue>(this IList<TValue> source, TValue exclude)
498 {
499 return source.RandomItem(source.IndexOf(exclude));
500 }
501
502 public static TValue RandomItem<TValue>(this IList<TValue> source, int exclude)
503 {
504 if (source.Count > 1)
505 {
506 int num;
507 do
508 {
509 num = Rand.rnd(source.Count);
510 }
511 while (num == exclude);
512 return source[num];
513 }
514 if (source.Count == 1)
515 {
516 return source[0];
517 }
518 return default(TValue);
519 }
520
521 public static TValue RandomItem<TValue>(this IList<TValue> source, Func<TValue, bool> funcValid, TValue defaultValue = default(TValue))
522 {
523 for (int i = 0; i < 100; i++)
524 {
525 TValue val = source[Rand.rnd(source.Count)];
526 if (funcValid(val))
527 {
528 return val;
529 }
530 }
531 return defaultValue;
532 }
533
534 public static TValue RandomItemWeighted<TValue>(this IList<TValue> source, Func<TValue, float> getWeight)
535 {
536 if (source.Count == 0)
537 {
538 return default(TValue);
539 }
540 if (source.Count == 1)
541 {
542 return source[0];
543 }
544 float num = 0f;
545 foreach (TValue item in source)
546 {
547 num += getWeight(item);
548 }
549 float num2 = Rand.Range(0f, num);
550 num = 0f;
551 foreach (TValue item2 in source)
552 {
553 num += getWeight(item2);
554 if (num2 < num)
555 {
556 return item2;
557 }
558 }
559 return source.First();
560 }
561
562 public static TValue Remainder<TValue>(this IList<TValue> source, int divider)
563 {
564 if (source.Count != 0)
565 {
566 return source[divider % source.Count];
567 }
568 return default(TValue);
569 }
570
571 public static TValue FirstItem<TKey, TValue>(this IDictionary<TKey, TValue> source)
572 {
573 if (source == null)
574 {
575 return default(TValue);
576 }
577 return source[source.First().Key];
578 }
579
580 public static TValue LastItem<TValue>(this IList<TValue> source)
581 {
582 if (source.Count != 0)
583 {
584 return source[source.Count - 1];
585 }
586 return default(TValue);
587 }
588
589 public static TValue NextItem<TValue>(this IList<TValue> source, ref int index)
590 {
591 index++;
592 if (index >= source.Count)
593 {
594 index = 0;
595 }
596 if (source.Count != 0)
597 {
598 return source[index];
599 }
600 return default(TValue);
601 }
602
603 public static int NextIndex<TValue>(this IList<TValue> source, TValue val)
604 {
605 if (val == null)
606 {
607 return 0;
608 }
609 int num = source.IndexOf(val) + 1;
610 if (num >= source.Count)
611 {
612 num = 0;
613 }
614 return num;
615 }
616
617 public static TValue NextItem<TValue>(this IList<TValue> source, TValue val)
618 {
619 int num = source.IndexOf(val) + 1;
620 if (num >= source.Count)
621 {
622 num = 0;
623 }
624 if (source.Count != 0)
625 {
626 return source[num];
627 }
628 return default(TValue);
629 }
630
631 public static TValue PrevItem<TValue>(this IList<TValue> source, TValue val)
632 {
633 int num = source.IndexOf(val) - 1;
634 if (num < 0)
635 {
636 num = source.Count - 1;
637 }
638 if (source.Count != 0)
639 {
640 return source[num];
641 }
642 return default(TValue);
643 }
644
645 public static TValue Clamp<TValue>(this IList<TValue> source, int i)
646 {
647 if (i < 0)
648 {
649 i = 0;
650 }
651 else if (i >= source.Count)
652 {
653 i = source.Count - 1;
654 }
655 return source[i];
656 }
657
658 public static List<T> GetList<T>(this IDictionary source)
659 {
660 List<T> list = new List<T>();
661 foreach (object value in source.Values)
662 {
663 if (value is T)
664 {
665 list.Add((T)value);
666 }
667 }
668 return list;
669 }
670
671 public static void ToDictionary<T>(this IList<UPair<T>> list, ref Dictionary<string, T> dic)
672 {
673 dic = new Dictionary<string, T>();
674 for (int i = 0; i < list.Count; i++)
675 {
676 dic.Add(list[i].name, list[i].value);
677 }
678 }
679
680 public static T FindMax<T>(this List<T> list, Func<T, int> func)
681 {
682 int num = int.MinValue;
683 T result = default(T);
684 foreach (T item in list)
685 {
686 int num2 = func(item);
687 if (num2 > num)
688 {
689 num = num2;
690 result = item;
691 }
692 }
693 return result;
694 }
695
696 public static void Set<T1, T2>(this Dictionary<T1, T2> dic, Dictionary<T1, T2> from)
697 {
698 dic.Clear();
699 foreach (KeyValuePair<T1, T2> item in from)
700 {
701 dic[item.Key] = item.Value;
702 }
703 }
704
705 public static string[] SplitByNewline(this string text)
706 {
707 if (string.IsNullOrEmpty(text))
708 {
709 return new string[0];
710 }
711 return text.Split(new string[3] { "\r\n", "\n", "\r" }, StringSplitOptions.None);
712 }
713
714 public static string RemoveNewline(this string text)
715 {
716 if (string.IsNullOrEmpty(text))
717 {
718 return text;
719 }
720 return text.Replace("\r", "").Replace("\n", "");
721 }
722
723 public static string RemoveAllTags(this string text)
724 {
725 if (string.IsNullOrEmpty(text))
726 {
727 return text;
728 }
729 return Regex.Replace(text, "<.*?>", "");
730 }
731
732 public static int Calc(this string str, int power = 0, int ele = 0, int p2 = 0)
733 {
734 return Cal.Calcuate(str.Replace("p2", p2.ToString() ?? "").Replace("p", power.ToString() ?? "").Replace("e", ele.ToString() ?? "")
735 .Replace(";", ","));
736 }
737
738 public static int ToInt<T>(this string str)
739 {
740 return str.ToInt(typeof(T));
741 }
742
743 public static int ToInt(this string str, Type type)
744 {
745 FieldInfo field = type.GetField(str, BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
746 if (field == null)
747 {
748 Debug.LogError("Field is null:" + str + "/" + type);
749 return -1;
750 }
751 return (int)field.GetValue(null);
752 }
753
754 public static int ToInt(this string str)
755 {
756 if (int.TryParse(str, out var result))
757 {
758 return result;
759 }
760 return 0;
761 }
762
763 public static long ToLong(this string str)
764 {
765 if (long.TryParse(str, out var result))
766 {
767 return result;
768 }
769 return 0L;
770 }
771
772 public static float ToFloat(this string str)
773 {
774 float result = 0f;
775 try
776 {
777 if (!float.TryParse(str, out result))
778 {
779 Debug.Log("exception: ToFlat1" + str);
780 result = 1f;
781 }
782 }
783 catch
784 {
785 Debug.Log("exception: ToFlat2" + str);
786 result = 1f;
787 }
788 return result;
789 }
790
791 public static string StripLastPun(this string str)
792 {
793 if (str != null)
794 {
795 return str.TrimEnd(Lang.words.period);
796 }
797 return str;
798 }
799
800 public static string StripPun(this string str, bool stripComma, bool insertSpaceForComma = false)
801 {
802 StringBuilder stringBuilder = new StringBuilder();
803 foreach (char c in str)
804 {
805 if (c == Lang.words.comma)
806 {
807 if (stripComma)
808 {
809 if (insertSpaceForComma)
810 {
811 stringBuilder.Append('\u3000');
812 }
813 }
814 else
815 {
816 stringBuilder.Append(c);
817 }
818 }
819 else if (c != Lang.words.period)
820 {
821 stringBuilder.Append(c);
822 }
823 }
824 return stringBuilder.ToString();
825 }
826
827 public static string Repeat(this string str, int count)
828 {
829 StringBuilder stringBuilder = new StringBuilder();
830 for (int i = 0; i < Mathf.Abs(count); i++)
831 {
832 stringBuilder.Append(str);
833 }
834 return stringBuilder.ToString();
835 }
836
837 public static string StripBrackets(this string str)
838 {
839 HashSet<char> brackets = new HashSet<char> { '"', '「', '」', '“', '”' };
840 return string.Concat(str.Where((char c) => !brackets.Contains(c)));
841 }
842
843 public static string TryAddExtension(this string s, string ext)
844 {
845 if (!s.Contains("." + ext))
846 {
847 return s + "." + ext;
848 }
849 return s;
850 }
851
852 public static bool IsEmpty(this string str)
853 {
854 if (str != null)
855 {
856 return str == "";
857 }
858 return true;
859 }
860
861 public static string IsEmpty(this string str, string defaultStr)
862 {
863 if (str != null && !(str == ""))
864 {
865 return str;
866 }
867 return defaultStr;
868 }
869
870 public static string TrimNewLines(this string text)
871 {
872 while (text.EndsWith(Environment.NewLine))
873 {
874 text = text.Substring(0, text.Length - Environment.NewLine.Length);
875 }
876 return text;
877 }
878
879 public static int[] SplitToInts(this string str, char separator)
880 {
881 string[] array = str.Split(separator);
882 int[] array2 = new int[array.Length];
883 for (int i = 0; i < array.Length; i++)
884 {
885 array2[i] = int.Parse(array[i]);
886 }
887 return array2;
888 }
889
890 public static string[] SplitNewline(this string str)
891 {
892 return str.Split(Environment.NewLine.ToCharArray());
893 }
894
895 public static bool Contains(this string[] strs, string id)
896 {
897 if (strs == null || strs.Length == 0)
898 {
899 return false;
900 }
901 for (int i = 0; i < strs.Length; i++)
902 {
903 if (strs[i] == id)
904 {
905 return true;
906 }
907 }
908 return false;
909 }
910
911 public static string Evalute(this string[] array, float val)
912 {
913 return array[(int)Mathf.Clamp((float)(array.Length - 1) * val, 0f, array.Length - 1)];
914 }
915
916 public static string ToShortNumber(this int a)
917 {
918 if (a < 0)
919 {
920 string text;
921 if (a > -1000000)
922 {
923 if (a <= -1000)
924 {
925 return a / 1000 + "K";
926 }
927 text = a.ToString();
928 if (text == null)
929 {
930 return "";
931 }
932 }
933 else
934 {
935 text = a / 1000000 + "M";
936 }
937 return text;
938 }
939 string text2;
940 if (a < 1000000)
941 {
942 if (a >= 1000)
943 {
944 return a / 1000 + "K";
945 }
946 text2 = a.ToString();
947 if (text2 == null)
948 {
949 return "";
950 }
951 }
952 else
953 {
954 text2 = a / 1000000 + "M";
955 }
956 return text2;
957 }
958
959 public static string ToFormat(this int a)
960 {
961 return $"{a:#,0}";
962 }
963
964 public static string ToFormat(this long a)
965 {
966 return $"{a:#,0}";
967 }
968
969 public static string ToText(this int a, bool skipIfZero = true)
970 {
971 object obj;
972 if (!(a == 0 && skipIfZero))
973 {
974 if (a >= 0)
975 {
976 return "+" + a;
977 }
978 obj = a.ToString();
979 if (obj == null)
980 {
981 return "";
982 }
983 }
984 else
985 {
986 obj = "";
987 }
988 return (string)obj;
989 }
990
991 public static string TagColor(this string s, Color c, string txt)
992 {
993 return s + "<color=" + c.ToHex() + ">" + txt + "</color>";
994 }
995
996 public static string TagColor(this string s, Color c)
997 {
998 return "<color=" + c.ToHex() + ">" + s + "</color>";
999 }
1000
1001 public static string TagSize(this string s, string txt, int size)
1002 {
1003 return s + "<size=" + size + ">" + txt + "</size>";
1004 }
1005
1006 public static string TagSize(this string s, int size)
1007 {
1008 return "<size=" + size + ">" + s + "</size>";
1009 }
1010
1011 public static bool HasTag(this string s, string id, char splitter = '/')
1012 {
1013 return s.Split(splitter).Contains(id);
1014 }
1015
1016 public static string SetTag(this string s, string id, bool enable, char splitter = '/')
1017 {
1018 s = ((!enable) ? s.RemoveTag(id, splitter) : s.AddTag(id, splitter));
1019 return s;
1020 }
1021
1022 public static string AddTag(this string s, string id, char splitter = '/')
1023 {
1024 if (!s.HasTag(id, splitter))
1025 {
1026 s = s + (s.IsEmpty() ? "" : ((object)splitter))?.ToString() + id;
1027 }
1028 return s;
1029 }
1030
1031 public static string RemoveTag(this string s, string id, char splitter = '/')
1032 {
1033 string[] array = s.Split(splitter);
1034 s = "";
1035 string[] array2 = array;
1036 foreach (string text in array2)
1037 {
1038 if (!(text == id))
1039 {
1040 s.AddTag(text, splitter);
1041 }
1042 }
1043 return s;
1044 }
1045
1046 public static string GetFullFileNameWithoutExtension(this FileInfo fileInfo)
1047 {
1048 return fileInfo.Directory.FullName + "/" + Path.GetFileNameWithoutExtension(fileInfo.Name);
1049 }
1050
1051 public static string GetFullFileNameWithoutExtension(this string path)
1052 {
1053 return new FileInfo(path).GetFullFileNameWithoutExtension();
1054 }
1055
1056 public static string Pluralize(string s)
1057 {
1058 if (s == "talisman")
1059 {
1060 return "talismans";
1061 }
1062 return pluralizer.Pluralize(s);
1063 }
1064
1065 public static string GetSpecialArticle(string a)
1066 {
1067 if (a.ToLower() == "unicorn")
1068 {
1069 return "a ";
1070 }
1071 return null;
1072 }
1073
1074 public static string AddArticle(this string s)
1075 {
1076 if (!Lang.setting.addArticle || s.Length < 1)
1077 {
1078 return s;
1079 }
1080 char c = s.ToLower()[0];
1081 s = (GetSpecialArticle(s) ?? ((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "an " : "a ")) + s;
1082 return s;
1083 }
1084
1085 public static string AddArticle(this string s, int num, ArticleStyle style = ArticleStyle.Default, string replace = null)
1086 {
1087 if (!Lang.setting.addArticle || s.Length < 1)
1088 {
1089 return s;
1090 }
1091 char c = s[0];
1092 string text = ((num >= 2) ? (num.ToFormat() + " ") : (GetSpecialArticle(s) ?? ((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "an " : "a ")));
1093 if (num >= 2 && Lang.setting.pluralize)
1094 {
1095 s = ((replace.IsEmpty() || !s.Contains(replace) || s.Contains("limestone stone")) ? Pluralize(s) : s.Replace(replace, Pluralize(replace)));
1096 }
1097 return style switch
1098 {
1099 ArticleStyle.The => "_the".lang().ToTitleCase() + " " + ((num > 1) ? (num + " ") : "") + s,
1100 ArticleStyle.None => ((num > 1) ? (num.ToFormat() + " ") : "") + s.ToTitleCase(),
1101 _ => text + s,
1102 };
1103 }
1104
1105 public static string ToTitleCase(this string s, bool wholeText = false)
1106 {
1107 if (!Lang.setting.capitalize)
1108 {
1109 return s;
1110 }
1111 char[] array = s.ToCharArray();
1112 bool flag = true;
1113 for (int i = 0; i < array.Length; i++)
1114 {
1115 if (flag)
1116 {
1117 array[i] = char.ToUpper(array[i]);
1118 flag = false;
1119 }
1120 if (!wholeText)
1121 {
1122 break;
1123 }
1124 if (array[i] == ' ')
1125 {
1126 flag = true;
1127 }
1128 }
1129 return new string(array);
1130 }
1131
1132 public static void LoopTail<T>(this List<T> list, bool vertical = false) where T : Selectable
1133 {
1134 if (list.Count > 1)
1135 {
1136 Navigation navigation = list[0].navigation;
1137 Navigation navigation2 = list[list.Count - 1].navigation;
1138 if (vertical)
1139 {
1140 navigation.selectOnUp = list[list.Count - 1];
1141 navigation2.selectOnDown = list[0];
1142 }
1143 else
1144 {
1145 navigation.selectOnLeft = list[list.Count - 1];
1146 navigation2.selectOnRight = list[0];
1147 }
1148 list[0].navigation = navigation;
1149 list[list.Count - 1].navigation = navigation2;
1150 }
1151 }
1152
1153 public static void SetNavigation(this Component a, Component b, bool vertical = false)
1154 {
1155 if (!a || !b)
1156 {
1157 return;
1158 }
1159 Selectable component = a.GetComponent<Selectable>();
1160 Selectable component2 = b.GetComponent<Selectable>();
1161 if ((bool)component && (bool)component2)
1162 {
1163 Navigation navigation = component.navigation;
1164 Navigation navigation2 = component2.navigation;
1165 if (vertical)
1166 {
1167 navigation.selectOnUp = component2;
1168 navigation2.selectOnDown = component;
1169 }
1170 else
1171 {
1172 navigation.selectOnLeft = component2;
1173 navigation2.selectOnRight = component;
1174 }
1175 component.navigation = navigation;
1176 component2.navigation = navigation2;
1177 }
1178 }
1179
1180 public static void LoopSelectable(this List<Selectable> sels, bool vertical = true, bool horizonal = true, bool asGroup = true)
1181 {
1182 for (int i = 0; i < sels.Count; i++)
1183 {
1184 Selectable selectable = sels[i];
1185 Selectable selectable2 = sels[0];
1186 Navigation navigation = selectable.navigation;
1187 if (horizonal)
1188 {
1189 navigation.selectOnRight = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1190 }
1191 if (asGroup)
1192 {
1193 for (int j = i + 1; j < sels.Count; j++)
1194 {
1195 if (sels[j].transform.position.y < selectable.transform.position.y)
1196 {
1197 selectable2 = sels[j];
1198 break;
1199 }
1200 }
1201 }
1202 else
1203 {
1204 selectable2 = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1205 }
1206 if (vertical)
1207 {
1208 navigation.selectOnDown = selectable2;
1209 }
1210 selectable.navigation = navigation;
1211 }
1212 for (int num = sels.Count - 1; num >= 0; num--)
1213 {
1214 Selectable selectable3 = sels[num];
1215 Selectable selectable4 = sels[sels.Count - 1];
1216 Navigation navigation2 = selectable3.navigation;
1217 if (horizonal)
1218 {
1219 navigation2.selectOnLeft = ((num > 0) ? sels[num - 1] : selectable4);
1220 }
1221 if (asGroup)
1222 {
1223 int num2 = sels.Count - 1;
1224 for (int num3 = num - 1; num3 >= 0; num3--)
1225 {
1226 if (sels[num3].transform.position.y > selectable3.transform.position.y)
1227 {
1228 num2 = num3;
1229 break;
1230 }
1231 }
1232 int num4 = num2;
1233 while (num4 >= 0 && !(sels[num4].transform.position.y > sels[num2].transform.position.y))
1234 {
1235 selectable4 = sels[num4];
1236 num4--;
1237 }
1238 }
1239 else
1240 {
1241 selectable4 = ((num > 0) ? sels[num - 1] : selectable4);
1242 }
1243 if (vertical)
1244 {
1245 navigation2.selectOnUp = ((selectable4 == selectable3) ? sels[sels.Count - 1] : selectable4);
1246 }
1247 navigation2.mode = Navigation.Mode.Explicit;
1248 selectable3.navigation = navigation2;
1249 }
1250 }
1251
1252 public static void LoopSelectable(this Transform l, bool vertical = true, bool horizonal = true, bool asGroup = true)
1253 {
1254 List<Selectable> list = l.GetComponentsInChildren<Selectable>().ToList();
1255 for (int num = list.Count - 1; num >= 0; num--)
1256 {
1257 if (!list[num].interactable || list[num].navigation.mode == Navigation.Mode.None)
1258 {
1259 list.RemoveAt(num);
1260 }
1261 }
1262 list.LoopSelectable(vertical, horizonal, asGroup);
1263 }
1264
1265 public static Color ToColor(this string s)
1266 {
1267 Color color = Color.white;
1268 ColorUtility.TryParseHtmlString("#" + s, out color);
1269 return color;
1270 }
1271
1272 public static void SetAlpha(this Image c, float a)
1273 {
1274 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1275 }
1276
1277 public static void SetAlpha(this RawImage c, float a)
1278 {
1279 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1280 }
1281
1282 public static Color SetAlpha(this Color c, float a)
1283 {
1284 c.a = a;
1285 return c;
1286 }
1287
1288 public static Color Multiply(this Color c, float mtp, float add)
1289 {
1290 return new Color(c.r * mtp + add, c.g * mtp + add, c.b * mtp + add, c.a);
1291 }
1292
1293 public static string Tag(this Color c)
1294 {
1295 return "<color=" + $"#{(int)(c.r * 255f):X2}{(int)(c.g * 255f):X2}{(int)(c.b * 255f):X2}" + ">";
1296 }
1297
1298 public static string ToHex(this Color c)
1299 {
1300 return $"#{(int)(c.r * 255f):X2}{(int)(c.g * 255f):X2}{(int)(c.b * 255f):X2}";
1301 }
1302
1303 public static void SetOnClick(this Button b, Action action)
1304 {
1305 b.onClick.RemoveAllListeners();
1306 b.onClick.AddListener(delegate
1307 {
1308 action();
1309 });
1310 }
1311
1312 public static void SetListener(this Button.ButtonClickedEvent e, Action action)
1313 {
1314 e.RemoveAllListeners();
1315 e.AddListener(delegate
1316 {
1317 action();
1318 });
1319 }
1320
1321 public static void SetAlpha(this Text text, float aloha = 1f)
1322 {
1323 text.color = new Color(text.color.r, text.color.g, text.color.b, aloha);
1324 }
1325
1326 public static void SetSlider(this Slider slider, float value, Func<float, string> action, bool notify)
1327 {
1328 slider.SetSlider(value, action, -1, -1, notify);
1329 }
1330
1331 public static void SetSlider(this Slider slider, float value, Func<float, string> action, int min = -1, int max = -1, bool notify = true)
1332 {
1333 slider.onValueChanged.RemoveAllListeners();
1334 slider.onValueChanged.AddListener(delegate(float a)
1335 {
1336 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(a);
1337 });
1338 if (min != -1)
1339 {
1340 slider.minValue = min;
1341 slider.maxValue = max;
1342 }
1343 if (notify)
1344 {
1345 slider.value = value;
1346 }
1347 else
1348 {
1349 slider.SetValueWithoutNotify(value);
1350 }
1351 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(value);
1352 }
1353
1354 public static T GetOrCreate<T>(this Component t) where T : Component
1355 {
1356 T val = t.gameObject.GetComponent<T>();
1357 if (!val)
1358 {
1359 val = t.gameObject.AddComponent<T>();
1360 }
1361 return val;
1362 }
1363
1364 public static RectTransform Rect(this Component c)
1365 {
1366 return c.transform as RectTransform;
1367 }
1368
1369 public static void CopyRect(this RectTransform r, RectTransform t)
1370 {
1371 r.pivot = t.pivot;
1372 r.sizeDelta = t.sizeDelta;
1373 r.anchorMin = t.anchorMin;
1374 r.anchorMax = t.anchorMax;
1375 r.anchoredPosition = t.anchoredPosition;
1376 }
1377
1378 public static void ToggleActive(this Component c)
1379 {
1380 c.SetActive(!c.gameObject.activeSelf);
1381 }
1382
1383 public static void SetActive(this Component c, bool enable)
1384 {
1385 if (c.gameObject.activeSelf != enable)
1386 {
1387 c.gameObject.SetActive(enable);
1388 }
1389 }
1390
1391 public static void SetActive(this Component c, bool enable, Action<bool> onChangeState)
1392 {
1393 if (c.gameObject.activeSelf != enable)
1394 {
1395 c.gameObject.SetActive(enable);
1396 onChangeState(enable);
1397 }
1398 }
1399
1400 public static Selectable GetSelectable(this GameObject go)
1401 {
1402 return go.GetComponentInChildren<Selectable>();
1403 }
1404
1405 public static void SetLayerRecursively(this GameObject obj, int layer)
1406 {
1407 obj.layer = layer;
1408 foreach (Transform item in obj.transform)
1409 {
1410 item.gameObject.SetLayerRecursively(layer);
1411 }
1412 }
1413
1414 public static bool IsInteractable(this GameObject obj)
1415 {
1416 Selectable selectable = (obj ? obj.GetComponent<Selectable>() : null);
1417 if ((bool)selectable)
1418 {
1419 return selectable.interactable;
1420 }
1421 return false;
1422 }
1423
1424 public static bool IsChildOf(this GameObject c, GameObject root)
1425 {
1426 if (c.transform == root.transform)
1427 {
1428 return true;
1429 }
1430 if ((bool)c.transform.parent)
1431 {
1432 return c.transform.parent.gameObject.IsChildOf(root);
1433 }
1434 return false;
1435 }
1436
1437 public static bool IsPrefab(this Component c)
1438 {
1439 return c.gameObject.scene.name == null;
1440 }
1441
1442 public static T CreateMold<T>(this Component c, string name = null) where T : Component
1443 {
1444 T result = null;
1445 for (int i = 0; i < c.transform.childCount; i++)
1446 {
1447 T component = c.transform.GetChild(i).GetComponent<T>();
1448 if ((bool)component && (name.IsEmpty() || name == component.name))
1449 {
1450 component.gameObject.SetActive(value: false);
1451 result = component;
1452 break;
1453 }
1454 }
1455 c.DestroyChildren();
1456 return result;
1457 }
1458
1459 public static Transform Find(this Component c, string name = null)
1460 {
1461 return c.Find<Transform>(name);
1462 }
1463
1464 public static T Find<T>(this Component c, string name = null, bool recursive = false) where T : Component
1465 {
1466 if (recursive)
1467 {
1468 T[] componentsInChildren = c.transform.GetComponentsInChildren<T>();
1469 foreach (T val in componentsInChildren)
1470 {
1471 if (name == null || name == val.name)
1472 {
1473 return val;
1474 }
1475 }
1476 return null;
1477 }
1478 for (int j = 0; j < c.transform.childCount; j++)
1479 {
1480 T component = c.transform.GetChild(j).GetComponent<T>();
1481 if ((bool)component && (name == null || name == component.name))
1482 {
1483 return component;
1484 }
1485 }
1486 return null;
1487 }
1488
1489 public static GameObject FindTagInParents(this Component c, string tag, bool includeInactive = true)
1490 {
1491 Transform transform = c.transform;
1492 for (int i = 0; i < transform.childCount; i++)
1493 {
1494 Transform child = transform.GetChild(i);
1495 if ((includeInactive || child.gameObject.activeSelf) && child.tag == tag)
1496 {
1497 return child.gameObject;
1498 }
1499 }
1500 if ((bool)transform.parent)
1501 {
1502 return transform.parent.FindTagInParents(tag, includeInactive);
1503 }
1504 return null;
1505 }
1506
1507 public static T GetComponentInChildrenExcludSelf<T>(this Transform c) where T : Component
1508 {
1509 for (int i = 0; i < c.childCount; i++)
1510 {
1511 T component = c.GetChild(i).GetComponent<T>();
1512 if ((bool)component)
1513 {
1514 return component;
1515 }
1516 }
1517 return null;
1518 }
1519
1520 public static List<T> GetComponentsInDirectChildren<T>(this Transform comp, bool includeInactive = true) where T : Component
1521 {
1522 List<T> list = new List<T>();
1523 Transform transform = comp.transform;
1524 for (int i = 0; i < transform.childCount; i++)
1525 {
1526 T component = transform.GetChild(i).GetComponent<T>();
1527 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1528 {
1529 list.Add(component);
1530 }
1531 }
1532 return list;
1533 }
1534
1535 public static List<T> GetComponentsInDirectChildren<T>(this Component comp, bool includeInactive = true) where T : Component
1536 {
1537 List<T> list = new List<T>();
1538 Transform transform = comp.transform;
1539 for (int i = 0; i < transform.childCount; i++)
1540 {
1541 T component = transform.GetChild(i).GetComponent<T>();
1542 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1543 {
1544 list.Add(component);
1545 }
1546 }
1547 return list;
1548 }
1549
1550 public static T GetComponentInDirectChildren<T>(this Component comp) where T : Component
1551 {
1552 Transform transform = comp.transform;
1553 for (int i = 0; i < transform.childCount; i++)
1554 {
1555 T component = transform.GetChild(i).GetComponent<T>();
1556 if ((bool)component)
1557 {
1558 return component;
1559 }
1560 }
1561 return null;
1562 }
1563
1564 public static void DestroyChildren(this Component component, bool destroyInactive = false, bool ignoreDestroy = true)
1565 {
1566 if (!component || !component.transform)
1567 {
1568 Debug.LogWarning("DestroyChlidren:" + component);
1569 return;
1570 }
1571 for (int num = component.transform.childCount - 1; num >= 0; num--)
1572 {
1573 GameObject gameObject = component.transform.GetChild(num).gameObject;
1574 if ((!ignoreDestroy || !(gameObject.tag == "IgnoreDestroy")) && (destroyInactive || gameObject.activeSelf))
1575 {
1576 UnityEngine.Object.DestroyImmediate(gameObject);
1577 }
1578 }
1579 }
1580
1581 public static bool IsMouseOver(this RectTransform r, Camera cam)
1582 {
1583 return RectTransformUtility.RectangleContainsScreenPoint(r, Input.mousePosition, cam);
1584 }
1585
1586 public static void RebuildLayout(this Component c, bool recursive = false)
1587 {
1588 if (recursive)
1589 {
1590 foreach (Transform item in c.transform)
1591 {
1592 if (item is RectTransform)
1593 {
1594 item.RebuildLayout(recursive: true);
1595 }
1596 }
1597 }
1598 LayoutRebuilder.ForceRebuildLayoutImmediate(c.transform as RectTransform);
1599 }
1600
1601 public static void RebuildLayoutTo<T>(this Component c) where T : Component
1602 {
1603 c.RebuildLayout();
1604 if ((bool)c.transform.parent && !c.transform.parent.GetComponent<T>())
1605 {
1606 c.transform.parent.RebuildLayoutTo<T>();
1607 }
1608 }
1609
1610 public static void RebuildLayoutTo(this Component c, Component target)
1611 {
1612 c.RebuildLayout();
1613 if (!(c == target) && (bool)c.transform.parent)
1614 {
1615 c.transform.parent.RebuildLayoutTo(target);
1616 }
1617 }
1618
1619 public static void SetRect(this RectTransform r, float x, float y, float w, float h, float pivotX, float pivotY, float minX, float minY, float maxX, float maxY)
1620 {
1621 r.SetPivot(pivotX, pivotY);
1622 r.SetAnchor(minX, minY, maxX, maxY);
1623 if (w != -1f)
1624 {
1625 r.sizeDelta = new Vector2(w, h);
1626 }
1627 r.anchoredPosition = new Vector2((x == -1f) ? r.anchoredPosition.x : x, (y == -1f) ? r.anchoredPosition.y : y);
1628 }
1629
1630 public static void SetPivot(this RectTransform r, float x, float y)
1631 {
1632 r.pivot = new Vector2(x, y);
1633 }
1634
1635 public static void SetAnchor(this RectTransform r, float minX, float minY, float maxX, float maxY)
1636 {
1637 r.anchorMin = new Vector2(minX, minY);
1638 r.anchorMax = new Vector2(maxX, maxY);
1639 }
1640
1641 public static void _SetAnchor(this RectTransform _rect, RectPosition anchor)
1642 {
1643 switch (anchor)
1644 {
1645 case RectPosition.TopCenter:
1646 _rect.SetAnchor(0.5f, 1f, 0.5f, 1f);
1647 break;
1648 case RectPosition.BottomCenter:
1649 _rect.SetAnchor(0.5f, 0f, 0.5f, 0f);
1650 break;
1651 case RectPosition.TopLEFT:
1652 _rect.SetAnchor(0f, 1f, 0f, 1f);
1653 break;
1654 case RectPosition.TopRIGHT:
1655 _rect.SetAnchor(1f, 1f, 1f, 1f);
1656 break;
1657 case RectPosition.BottomLEFT:
1658 _rect.SetAnchor(0f, 0f, 0f, 0f);
1659 break;
1660 case RectPosition.BottomRIGHT:
1661 _rect.SetAnchor(1f, 0f, 1f, 0f);
1662 break;
1663 case RectPosition.Left:
1664 _rect.SetAnchor(0f, 0.5f, 0f, 0.5f);
1665 break;
1666 case RectPosition.Right:
1667 _rect.SetAnchor(1f, 0.5f, 1f, 0.5f);
1668 break;
1669 default:
1670 _rect.SetAnchor(0.5f, 0.5f, 0.5f, 0.5f);
1671 break;
1672 }
1673 }
1674
1675 public static void SetAnchor(this RectTransform _rect, RectPosition anchor = RectPosition.Auto)
1676 {
1677 Vector3 position = _rect.position;
1678 _rect._SetAnchor((anchor == RectPosition.Auto) ? _rect.GetAnchor() : anchor);
1679 _rect.position = position;
1680 }
1681
1682 public static RectPosition GetAnchor(this RectTransform _rect)
1683 {
1684 Vector3 position = _rect.position;
1685 int width = Screen.width;
1686 int height = Screen.height;
1687 bool flag = position.y > (float)height * 0.5f;
1688 if (position.x > (float)width * 0.3f && position.x < (float)width * 0.7f)
1689 {
1690 if (position.y > (float)height * 0.3f && position.y < (float)height * 0.7f)
1691 {
1692 return RectPosition.Center;
1693 }
1694 if (!flag)
1695 {
1696 return RectPosition.BottomCenter;
1697 }
1698 return RectPosition.TopCenter;
1699 }
1700 if (position.x < (float)width * 0.5f)
1701 {
1702 if (!flag)
1703 {
1704 return RectPosition.BottomLEFT;
1705 }
1706 return RectPosition.TopLEFT;
1707 }
1708 if (!flag)
1709 {
1710 return RectPosition.BottomRIGHT;
1711 }
1712 return RectPosition.TopRIGHT;
1713 }
1714
1715 public static Transform GetLastChild(this Transform trans)
1716 {
1717 return trans.GetChild(trans.childCount - 1);
1718 }
1719
1720 public static Vector2 ToVector2(this Vector3 self)
1721 {
1722 return new Vector2(self.x, self.z);
1723 }
1724
1725 public static void SetScale(this SpriteRenderer renderer, float size)
1726 {
1727 float x = renderer.bounds.size.x;
1728 float y = renderer.bounds.size.y;
1729 float x2 = size / x;
1730 float y2 = size / y;
1731 renderer.transform.localScale = new Vector3(x2, y2, 1f);
1732 }
1733
1734 private static float GetForwardDiffPoint(Vector2 forward)
1735 {
1736 if (object.Equals(forward, Vector2.up))
1737 {
1738 return 90f;
1739 }
1740 object.Equals(forward, Vector2.right);
1741 return 0f;
1742 }
1743
1744 public static void LookAt2D(this Transform self, Transform target, Vector2 forward)
1745 {
1746 self.LookAt2D(target.position, forward);
1747 }
1748
1749 public static void LookAt2D(this Transform self, Vector3 target, Vector2 forward)
1750 {
1751 float forwardDiffPoint = GetForwardDiffPoint(forward);
1752 Vector3 vector = target - self.position;
1753 float num = Mathf.Atan2(vector.y, vector.x) * 57.29578f;
1754 self.rotation = Quaternion.AngleAxis(num - forwardDiffPoint, Vector3.forward);
1755 }
1756
1757 public static float Distance(this Transform t, Vector2 pos)
1758 {
1759 return Vector3.Distance(t.position, pos);
1760 }
1761
1762 public static Vector3 Plus(this Vector3 v, Vector2 v2)
1763 {
1764 v.x += v2.x;
1765 v.y += v2.y;
1766 return v;
1767 }
1768
1769 public static Vector3 SetZ(this Vector3 v, float a)
1770 {
1771 v.z = a;
1772 return v;
1773 }
1774
1775 public static Vector3 SetY(this Vector3 v, float a)
1776 {
1777 v.y = a;
1778 return v;
1779 }
1780
1781 public static Vector3 PlusX(this Vector3 v, float a)
1782 {
1783 v.x += a;
1784 return v;
1785 }
1786
1787 public static Vector3 PlusY(this Vector3 v, float a)
1788 {
1789 v.y += a;
1790 return v;
1791 }
1792
1793 public static Vector3 PlusZ(this Vector3 v, float a)
1794 {
1795 v.z += a;
1796 return v;
1797 }
1798
1799 public static void SetPosition(this Transform transform, float x, float y, float z)
1800 {
1801 vector3.Set(x, y, z);
1802 transform.position = vector3;
1803 }
1804
1805 public static void SetPositionX(this Transform transform, float x)
1806 {
1807 vector3.Set(x, transform.position.y, transform.position.z);
1808 transform.position = vector3;
1809 }
1810
1811 public static void SetPositionY(this Transform transform, float y)
1812 {
1813 vector3.Set(transform.position.x, y, transform.position.z);
1814 transform.position = vector3;
1815 }
1816
1817 public static void SetPositionZ(this Transform transform, float z)
1818 {
1819 vector3.Set(transform.position.x, transform.position.y, z);
1820 transform.position = vector3;
1821 }
1822
1823 public static void AddPosition(this Transform transform, float x, float y, float z)
1824 {
1825 vector3.Set(transform.position.x + x, transform.position.y + y, transform.position.z + z);
1826 transform.position = vector3;
1827 }
1828
1829 public static void AddPositionX(this Transform transform, float x)
1830 {
1831 vector3.Set(transform.position.x + x, transform.position.y, transform.position.z);
1832 transform.position = vector3;
1833 }
1834
1835 public static void AddPositionY(this Transform transform, float y)
1836 {
1837 vector3.Set(transform.position.x, transform.position.y + y, transform.position.z);
1838 transform.position = vector3;
1839 }
1840
1841 public static void AddPositionZ(this Transform transform, float z)
1842 {
1843 vector3.Set(transform.position.x, transform.position.y, transform.position.z + z);
1844 transform.position = vector3;
1845 }
1846
1847 public static void SetLocalPosition(this Transform transform, float x, float y, float z)
1848 {
1849 vector3.Set(x, y, z);
1850 transform.localPosition = vector3;
1851 }
1852
1853 public static void SetLocalPositionX(this Transform transform, float x)
1854 {
1855 vector3.Set(x, transform.localPosition.y, transform.localPosition.z);
1856 transform.localPosition = vector3;
1857 }
1858
1859 public static void SetLocalPositionY(this Transform transform, float y)
1860 {
1861 vector3.Set(transform.localPosition.x, y, transform.localPosition.z);
1862 transform.localPosition = vector3;
1863 }
1864
1865 public static void SetLocalPositionZ(this Transform transform, float z)
1866 {
1867 vector3.Set(transform.localPosition.x, transform.localPosition.y, z);
1868 transform.localPosition = vector3;
1869 }
1870
1871 public static void AddLocalPosition(this Transform transform, float x, float y, float z)
1872 {
1873 vector3.Set(transform.localPosition.x + x, transform.localPosition.y + y, transform.localPosition.z + z);
1874 transform.localPosition = vector3;
1875 }
1876
1877 public static void AddLocalPositionX(this Transform transform, float x)
1878 {
1879 vector3.Set(transform.localPosition.x + x, transform.localPosition.y, transform.localPosition.z);
1880 transform.localPosition = vector3;
1881 }
1882
1883 public static void AddLocalPositionY(this Transform transform, float y)
1884 {
1885 vector3.Set(transform.localPosition.x, transform.localPosition.y + y, transform.localPosition.z);
1886 transform.localPosition = vector3;
1887 }
1888
1889 public static void AddLocalPositionZ(this Transform transform, float z)
1890 {
1891 vector3.Set(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z + z);
1892 transform.localPosition = vector3;
1893 }
1894
1895 public static void SetLocalScale(this Transform transform, float x, float y, float z)
1896 {
1897 vector3.Set(x, y, z);
1898 transform.localScale = vector3;
1899 }
1900
1901 public static void SetLocalScaleX(this Transform transform, float x)
1902 {
1903 vector3.Set(x, transform.localScale.y, transform.localScale.z);
1904 transform.localScale = vector3;
1905 }
1906
1907 public static void SetLocalScaleY(this Transform transform, float y)
1908 {
1909 vector3.Set(transform.localScale.x, y, transform.localScale.z);
1910 transform.localScale = vector3;
1911 }
1912
1913 public static void SetLocalScaleZ(this Transform transform, float z)
1914 {
1915 vector3.Set(transform.localScale.x, transform.localScale.y, z);
1916 transform.localScale = vector3;
1917 }
1918
1919 public static void AddLocalScale(this Transform transform, float x, float y, float z)
1920 {
1921 vector3.Set(transform.localScale.x + x, transform.localScale.y + y, transform.localScale.z + z);
1922 transform.localScale = vector3;
1923 }
1924
1925 public static void AddLocalScaleX(this Transform transform, float x)
1926 {
1927 vector3.Set(transform.localScale.x + x, transform.localScale.y, transform.localScale.z);
1928 transform.localScale = vector3;
1929 }
1930
1931 public static void AddLocalScaleY(this Transform transform, float y)
1932 {
1933 vector3.Set(transform.localScale.x, transform.localScale.y + y, transform.localScale.z);
1934 transform.localScale = vector3;
1935 }
1936
1937 public static void AddLocalScaleZ(this Transform transform, float z)
1938 {
1939 vector3.Set(transform.localScale.x, transform.localScale.y, transform.localScale.z + z);
1940 transform.localScale = vector3;
1941 }
1942
1943 public static void SetEulerAngles(this Transform transform, float x, float y, float z)
1944 {
1945 vector3.Set(x, y, z);
1946 transform.eulerAngles = vector3;
1947 }
1948
1949 public static void SetEulerAnglesX(this Transform transform, float x)
1950 {
1951 vector3.Set(x, transform.localEulerAngles.y, transform.localEulerAngles.z);
1952 transform.eulerAngles = vector3;
1953 }
1954
1955 public static void SetEulerAnglesY(this Transform transform, float y)
1956 {
1957 vector3.Set(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
1958 transform.eulerAngles = vector3;
1959 }
1960
1961 public static void SetEulerAnglesZ(this Transform transform, float z)
1962 {
1963 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, z);
1964 transform.eulerAngles = vector3;
1965 }
1966
1967 public static void AddEulerAngles(this Transform transform, float x, float y, float z)
1968 {
1969 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y + y, transform.eulerAngles.z + z);
1970 transform.eulerAngles = vector3;
1971 }
1972
1973 public static void AddEulerAnglesX(this Transform transform, float x)
1974 {
1975 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y, transform.eulerAngles.z);
1976 transform.eulerAngles = vector3;
1977 }
1978
1979 public static void AddEulerAnglesY(this Transform transform, float y)
1980 {
1981 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y + y, transform.eulerAngles.z);
1982 transform.eulerAngles = vector3;
1983 }
1984
1985 public static void AddEulerAnglesZ(this Transform transform, float z)
1986 {
1987 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z + z);
1988 transform.eulerAngles = vector3;
1989 }
1990
1991 public static void SetLocalEulerAngles(this Transform transform, float x, float y, float z)
1992 {
1993 vector3.Set(x, y, z);
1994 transform.localEulerAngles = vector3;
1995 }
1996
1997 public static void SetLocalEulerAnglesX(this Transform transform, float x)
1998 {
1999 vector3.Set(x, transform.localEulerAngles.y, transform.localEulerAngles.z);
2000 transform.localEulerAngles = vector3;
2001 }
2002
2003 public static void SetLocalEulerAnglesY(this Transform transform, float y)
2004 {
2005 vector3.Set(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
2006 transform.localEulerAngles = vector3;
2007 }
2008
2009 public static void SetLocalEulerAnglesZ(this Transform transform, float z)
2010 {
2011 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, z);
2012 transform.localEulerAngles = vector3;
2013 }
2014
2015 public static void AddLocalEulerAngles(this Transform transform, float x, float y, float z)
2016 {
2017 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y + y, transform.localEulerAngles.z + z);
2018 transform.localEulerAngles = vector3;
2019 }
2020
2021 public static void AddLocalEulerAnglesX(this Transform transform, float x)
2022 {
2023 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y, transform.localEulerAngles.z);
2024 transform.localEulerAngles = vector3;
2025 }
2026
2027 public static void AddLocalEulerAnglesY(this Transform transform, float y)
2028 {
2029 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y + y, transform.localEulerAngles.z);
2030 transform.localEulerAngles = vector3;
2031 }
2032
2033 public static void AddLocalEulerAnglesZ(this Transform transform, float z)
2034 {
2035 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, transform.localEulerAngles.z + z);
2036 transform.localEulerAngles = vector3;
2037 }
2038
2039 public static void ToggleKeyword(this Material m, string id, bool enable)
2040 {
2041 if (enable)
2042 {
2043 m.EnableKeyword(id);
2044 }
2045 else
2046 {
2047 m.DisableKeyword(id);
2048 }
2049 }
2050
2051 public static void ForeachReverse<T>(this IList<T> items, Action<T> action)
2052 {
2053 for (int num = items.Count - 1; num >= 0; num--)
2054 {
2055 action(items[num]);
2056 }
2057 }
2058
2059 public static void ForeachReverse<T>(this IList<T> items, Func<T, bool> action)
2060 {
2061 int num = items.Count - 1;
2062 while (num >= 0 && !action(items[num]))
2063 {
2064 num--;
2065 }
2066 }
2067
2068 public static bool RemoveFromEnd<T>(this List<T> items, T item)
2069 {
2070 int num = items.LastIndexOf(item);
2071 if (num < 0)
2072 {
2073 return false;
2074 }
2075 items.RemoveAt(num);
2076 return true;
2077 }
2078
2079 public static float ClampAngle(this float angle)
2080 {
2081 if (angle < 0f)
2082 {
2083 return 360f - (0f - angle) % 360f;
2084 }
2085 return angle % 360f;
2086 }
2087
2088 public static Vector3 Random(this Vector3 v)
2089 {
2090 return new Vector3(Rand.Range(0f - v.x, v.x), Rand.Range(0f - v.y, v.y), Rand.Range(0f - v.z, v.z));
2091 }
2092
2093 public static T Instantiate<T>(this T s) where T : ScriptableObject
2094 {
2095 string name = s.name;
2096 T val = UnityEngine.Object.Instantiate(s);
2097 val.name = name;
2098 return val;
2099 }
2100
2101 public static int GetRuntimeEventCount(this UnityEventBase unityEvent)
2102 {
2103 Type typeFromHandle = typeof(UnityEventBase);
2104 Assembly assembly = Assembly.GetAssembly(typeFromHandle);
2105 Type type = assembly.GetType("UnityEngine.Events.InvokableCallList");
2106 Type type2 = assembly.GetType("UnityEngine.Events.BaseInvokableCall");
2107 Type type3 = typeof(List<>).MakeGenericType(type2);
2108 FieldInfo field = typeFromHandle.GetField("m_Calls", BindingFlags.Instance | BindingFlags.NonPublic);
2109 FieldInfo field2 = type.GetField("m_RuntimeCalls", BindingFlags.Instance | BindingFlags.NonPublic);
2110 object value = field.GetValue(unityEvent);
2111 object value2 = field2.GetValue(value);
2112 return (int)type3.GetProperty("Count").GetValue(value2, null);
2113 }
2114}
ArticleStyle
Definition: ArticleStyle.cs:2
RectPosition
Definition: RectPosition.cs:2
static readonly Dictionary< string, T > fuzzy
static readonly Dictionary< string, T > cached
static readonly bool IsLong
static readonly bool IsInt
static string TryAddExtension(this string s, string ext)
static string StripLastPun(this string str)
static byte SetBit(this byte pByte, int bitNo, bool value)
static T GetComponentInChildrenExcludSelf< T >(this Transform c)
static int[] SplitToInts(this string str, char separator)
static void SetEulerAnglesZ(this Transform transform, float z)
static T CreateMold< T >(this Component c, string name=null)
static void SetAnchor(this RectTransform r, float minX, float minY, float maxX, float maxY)
static T GetField< T >(this object o, string name)
static void SetPosition(this Transform transform, float x, float y, float z)
static string TagColor(this string s, Color c, string txt)
static void SetEulerAnglesX(this Transform transform, float x)
static int NextIndex< TValue >(this IList< TValue > source, TValue val)
static string RemoveAllTags(this string text)
static int ClampMax(this int v, int max)
static void Each< TValue >(this IList< TValue > list, Action< TValue > action)
static void AddLocalPosition(this Transform transform, float x, float y, float z)
static T PrevEnum< T >(this T src)
static string langGame(this string s, string ref1, string ref2=null, string ref3=null, string ref4=null)
static Vector3 vector3
static string Pluralize(string s)
static TKey[] CopyKeys< TKey, TValue >(this IDictionary< TKey, TValue > dict)
static void AddLocalEulerAnglesY(this Transform transform, float y)
static IList< TValue > Shuffle< TValue >(this IList< TValue > list)
static string Parentheses(this string str)
static void AddLocalScale(this Transform transform, float x, float y, float z)
static string ToTitleCase(this string s, bool wholeText=false)
static T Find< T >(this Component c, string name=null, bool recursive=false)
static TValue Clamp< TValue >(this IList< TValue > source, int i)
static TValue TryGetValue< TKey, TValue >(this IDictionary< TKey, TValue > source, TKey key, TValue fallback=default(TValue))
static void SetLocalEulerAngles(this Transform transform, float x, float y, float z)
static string ToFormat(this int a)
static void LoopSelectable(this List< Selectable > sels, bool vertical=true, bool horizonal=true, bool asGroup=true)
static string langPlural(this string s, int i)
static void SetScale(this SpriteRenderer renderer, float size)
static int ToInt(this string str, Type type)
static float GetForwardDiffPoint(Vector2 forward)
static T ToEnum< T >(this int value)
static bool IsChildOf(this GameObject c, GameObject root)
static int Calc(this string str, int power=0, int ele=0, int p2=0)
static void AddLocalScaleY(this Transform transform, float y)
static void SetSlider(this Slider slider, float value, Func< float, string > action, int min=-1, int max=-1, bool notify=true)
static string StripPun(this string str, bool stripComma, bool insertSpaceForComma=false)
static int IndexOf(this IList< Component > list, GameObject go)
static Vector3 SetY(this Vector3 v, float a)
static void AddPositionX(this Transform transform, float x)
static void LoopTail< T >(this List< T > list, bool vertical=false)
static T GetOrCreate< T >(this Component t)
static bool IsOn(this int data, int digit)
static IList< TValue > Copy< TValue >(this IList< TValue > list)
static float FromInt2(this int a)
static Selectable GetSelectable(this GameObject go)
static string AddArticle(this string s, int num, ArticleStyle style=ArticleStyle.Default, string replace=null)
static void SetLocalPositionZ(this Transform transform, float z)
static void SetLocalEulerAnglesZ(this Transform transform, float z)
static void RebuildLayoutTo(this Component c, Component target)
static bool IsEmpty(this string str)
static bool IsPrefab(this Component c)
static void SetActive(this Component c, bool enable)
static void ToDictionary< T >(this IList< UPair< T > > list, ref Dictionary< string, T > dic)
static string RemoveTag(this string s, string id, char splitter='/')
static void AddEulerAnglesZ(this Transform transform, float z)
static void SetProperty< T >(this object o, string name, T value)
static bool Within(this byte v, byte v2, byte range)
static void SetAlpha(this Text text, float aloha=1f)
static void ToggleActive(this Component c)
static bool Contains(this string[] strs, string id)
static int GetRuntimeEventCount(this UnityEventBase unityEvent)
static string[] SplitByNewline(this string text)
static void SetLayerRecursively(this GameObject obj, int layer)
static void SetActive(this Component c, bool enable, Action< bool > onChangeState)
static void SetLocalEulerAnglesY(this Transform transform, float y)
static bool Within(this int v, int v2, int range)
static Vector2 ToVector2(this Vector3 self)
static bool HasTag(this string s, string id, char splitter='/')
static void LoopSelectable(this Transform l, bool vertical=true, bool horizonal=true, bool asGroup=true)
static string[] langList(this string s)
static Color ToColor(this string s)
static void AddLocalEulerAnglesX(this Transform transform, float x)
static void SetLocalPosition(this Transform transform, float x, float y, float z)
static void AddPositionY(this Transform transform, float y)
static RectPosition GetAnchor(this RectTransform _rect)
static bool GetBit(this byte pByte, int bitNo)
static void ToggleKeyword(this Material m, string id, bool enable)
static string Tag(this Color c)
static T NextEnum< T >(this T src)
static void SetPositionX(this Transform transform, float x)
static void SetLocalScaleX(this Transform transform, float x)
static TValue GetOrCreate< TKey, TValue >(this IDictionary< TKey, TValue > dict, TKey key, Func< TValue > func=null)
static Vector3 PlusY(this Vector3 v, float a)
static bool IsEmpty(this Array array)
static T GetProperty< T >(this object o, string name)
static void SetLocalPositionX(this Transform transform, float x)
static void SetLocalEulerAnglesX(this Transform transform, float x)
static float Distance(this Transform t, Vector2 pos)
static void AddLocalScaleX(this Transform transform, float x)
static float FromInt3(this int a)
static void AddEulerAngles(this Transform transform, float x, float y, float z)
static string TagSize(this string s, int size)
static void AddLocalScaleZ(this Transform transform, float z)
static void SetAlpha(this RawImage c, float a)
static void AddEulerAnglesX(this Transform transform, float x)
static Transform Find(this Component c, string name=null)
static void DestroyChildren(this Component component, bool destroyInactive=false, bool ignoreDestroy=true)
static bool IsInteractable(this GameObject obj)
static void Sort< T >(this IList< T > list, Comparison< T > comparison)
static int ToInt3(this float a)
static TValue RandomItem< TKey, TValue >(this IDictionary< TKey, TValue > source)
static string StripBrackets(this string str)
static string ToHex(this Color c)
static TValue RandomItemWeighted< TValue >(this IList< TValue > source, Func< TValue, float > getWeight)
static string lang(this string s)
static float ToFloat(this string str)
static Vector3 SetZ(this Vector3 v, float a)
static void AddLocalEulerAnglesZ(this Transform transform, float z)
static bool IsNull(this object o)
static void SetAlpha(this Image c, float a)
static void SetAnchor(this RectTransform _rect, RectPosition anchor=RectPosition.Auto)
static bool IsMouseOver(this RectTransform r, Camera cam)
static Vector3 PlusX(this Vector3 v, float a)
static List< T > GetComponentsInDirectChildren< T >(this Transform comp, bool includeInactive=true)
static string RemoveNewline(this string text)
static void SetSlider(this Slider slider, float value, Func< float, string > action, bool notify)
static bool RemoveFromEnd< T >(this List< T > items, T item)
static string langGame(this string s)
static void SetNavigation(this Component a, Component b, bool vertical=false)
static TValue RandomItem< TValue >(this IList< TValue > source)
static void AddLocalEulerAngles(this Transform transform, float x, float y, float z)
static int ClampMin(this int v, int min)
static TValue FirstItem< TKey, TValue >(this IDictionary< TKey, TValue > source)
static void SetPivot(this RectTransform r, float x, float y)
static TValue NextItem< TValue >(this IList< TValue > source, ref int index)
static T FindMax< T >(this List< T > list, Func< T, int > func)
static void SetField< T >(this object o, string name, T value)
static TValue TryGet< TValue >(this IList< TValue > array, int index, int defIndex=-1)
static TValue Move< TValue >(this IList< TValue > list, TValue target, int a)
static T GetComponentInDirectChildren< T >(this Component comp)
static void SetRect(this RectTransform r, float x, float y, float w, float h, float pivotX, float pivotY, float minX, float minY, float maxX, float maxY)
static Type ToType(this string value)
static string AddTag(this string s, string id, char splitter='/')
static void ForeachReverse< T >(this IList< T > items, Action< T > action)
static TValue PrevItem< TValue >(this IList< TValue > source, TValue val)
static void RebuildLayout(this Component c, bool recursive=false)
static Vector3 Plus(this Vector3 v, Vector2 v2)
static GameObject FindTagInParents(this Component c, string tag, bool includeInactive=true)
static string GetFullFileNameWithoutExtension(this string path)
static int ToInt< T >(this string str)
static string ToShortNumber(this int a)
static void SetEulerAnglesY(this Transform transform, float y)
static IPluralize pluralizer
static void AddLocalPositionX(this Transform transform, float x)
static string IsEmpty(this string str, string defaultStr)
static void Set< T1, T2 >(this Dictionary< T1, T2 > dic, Dictionary< T1, T2 > from)
static T RandomItem< T >(this IEnumerable< T > ie)
static T Instantiate< T >(this T s)
static string TagSize(this string s, string txt, int size)
static string Repeat(this string str, int count)
static Transform GetLastChild(this Transform trans)
static int ToInt(this string str)
static void SetPositionY(this Transform transform, float y)
static string ToFormat(this long a)
static string ToText(this int a, bool skipIfZero=true)
static void _SetAnchor(this RectTransform _rect, RectPosition anchor)
static Vector3 Random(this Vector3 v)
static string SetTag(this string s, string id, bool enable, char splitter='/')
static string GetFullFileNameWithoutExtension(this FileInfo fileInfo)
static void SetListener(this Button.ButtonClickedEvent e, Action action)
static void RebuildLayoutTo< T >(this Component c)
static void SetOnClick(this Button b, Action action)
static string Bracket(this string str, int type=0)
static void AddPosition(this Transform transform, float x, float y, float z)
static RectTransform Rect(this Component c)
static void AddLocalPositionZ(this Transform transform, float z)
static long ToLong(this string str)
static string Evalute(this string[] array, float val)
static string lang(this string s, string ref1, string ref2=null, string ref3=null, string ref4=null, string ref5=null)
static int Minimum(this int i)
static string GetSpecialArticle(string a)
static void LookAt2D(this Transform self, Transform target, Vector2 forward)
static void SetLocalScaleZ(this Transform transform, float z)
static void SetEulerAngles(this Transform transform, float x, float y, float z)
static float ClampAngle(this float angle)
static int Clamp(this int v, int min, int max, bool loop=false)
static string TrimNewLines(this string text)
static string TagColor(this string s, Color c)
static string[] SplitNewline(this string str)
static void CopyRect(this RectTransform r, RectTransform t)
static Color Multiply(this Color c, float mtp, float add)
static TValue[] CopyValues< TKey, TValue >(this IDictionary< TKey, TValue > dict)
static void SetLocalPositionY(this Transform transform, float y)
static Vector3 PlusZ(this Vector3 v, float a)
static void SetPositionZ(this Transform transform, float z)
static Color SetAlpha(this Color c, float a)
static void SetLocalScaleY(this Transform transform, float y)
static TValue LastItem< TValue >(this IList< TValue > source)
static byte[] ToBytes(this BitArray bits)
static T ToField< T >(this string s, object o)
static void SetLocalScale(this Transform transform, float x, float y, float z)
static string AddArticle(this string s)
static TValue Remainder< TValue >(this IList< TValue > source, int divider)
static int ToInt2(this float a)
static List< T > GetList< T >(this IDictionary source)
static void AddLocalPositionY(this Transform transform, float y)
static void AddPositionZ(this Transform transform, float z)
static bool HasField< T >(this object o, string name)
static void AddEulerAnglesY(this Transform transform, float y)
static void LookAt2D(this Transform self, Vector3 target, Vector2 forward)
bool pluralize
Definition: LangSetting.cs:32
bool addArticle
Definition: LangSetting.cs:30
bool capitalize
Definition: LangSetting.cs:34
char period
Definition: Lang.cs:20
char comma
Definition: Lang.cs:18
Definition: Lang.cs:7
static Words words
Definition: Lang.cs:27
static LangSetting setting
Definition: Lang.cs:55
static string Get(string id)
Definition: Lang.cs:90
static string[] GetList(string id)
Definition: Lang.cs:113
static LangGame Game
Definition: Lang.cs:49
static string Parse(string idLang, string val1, string val2=null, string val3=null, string val4=null, string val5=null)
Definition: Lang.cs:146
Definition: Rand.cs:4
static Random _random
Definition: Rand.cs:9
static int Range(int min, int max)
Definition: Rand.cs:49
static int rnd(int max)
Definition: Rand.cs:59
string Get(string id)
Definition: SourceLang.cs:12
string Parse(string idLang, string val1, string val2=null, string val3=null, string val4=null)
Definition: SourceLang.cs:43
Definition: UPair.cs:5
void SetInt(int i)
Definition: BitArray32.cs:89