Elin Decompiled Documentation EA 23.356.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 string ToSentenceCase(this string s)
1133 {
1134 char[] array = s.ToCharArray();
1135 bool flag = true;
1136 for (int i = 0; i < array.Length; i++)
1137 {
1138 char c = array[i];
1139 if (char.IsLetter(c))
1140 {
1141 if (flag)
1142 {
1143 array[i] = char.ToUpperInvariant(c);
1144 }
1145 flag = false;
1146 }
1147 else if (c == '.' || c == '!' || c == '?')
1148 {
1149 flag = true;
1150 }
1151 }
1152 return new string(array);
1153 }
1154
1155 public static void LoopTail<T>(this List<T> list, bool vertical = false) where T : Selectable
1156 {
1157 if (list.Count > 1)
1158 {
1159 Navigation navigation = list[0].navigation;
1160 Navigation navigation2 = list[list.Count - 1].navigation;
1161 if (vertical)
1162 {
1163 navigation.selectOnUp = list[list.Count - 1];
1164 navigation2.selectOnDown = list[0];
1165 }
1166 else
1167 {
1168 navigation.selectOnLeft = list[list.Count - 1];
1169 navigation2.selectOnRight = list[0];
1170 }
1171 list[0].navigation = navigation;
1172 list[list.Count - 1].navigation = navigation2;
1173 }
1174 }
1175
1176 public static void SetNavigation(this Component a, Component b, bool vertical = false)
1177 {
1178 if (!a || !b)
1179 {
1180 return;
1181 }
1182 Selectable component = a.GetComponent<Selectable>();
1183 Selectable component2 = b.GetComponent<Selectable>();
1184 if ((bool)component && (bool)component2)
1185 {
1186 Navigation navigation = component.navigation;
1187 Navigation navigation2 = component2.navigation;
1188 if (vertical)
1189 {
1190 navigation.selectOnUp = component2;
1191 navigation2.selectOnDown = component;
1192 }
1193 else
1194 {
1195 navigation.selectOnLeft = component2;
1196 navigation2.selectOnRight = component;
1197 }
1198 component.navigation = navigation;
1199 component2.navigation = navigation2;
1200 }
1201 }
1202
1203 public static void LoopSelectable(this List<Selectable> sels, bool vertical = true, bool horizonal = true, bool asGroup = true)
1204 {
1205 for (int i = 0; i < sels.Count; i++)
1206 {
1207 Selectable selectable = sels[i];
1208 Selectable selectable2 = sels[0];
1209 Navigation navigation = selectable.navigation;
1210 if (horizonal)
1211 {
1212 navigation.selectOnRight = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1213 }
1214 if (asGroup)
1215 {
1216 for (int j = i + 1; j < sels.Count; j++)
1217 {
1218 if (sels[j].transform.position.y < selectable.transform.position.y)
1219 {
1220 selectable2 = sels[j];
1221 break;
1222 }
1223 }
1224 }
1225 else
1226 {
1227 selectable2 = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1228 }
1229 if (vertical)
1230 {
1231 navigation.selectOnDown = selectable2;
1232 }
1233 selectable.navigation = navigation;
1234 }
1235 for (int num = sels.Count - 1; num >= 0; num--)
1236 {
1237 Selectable selectable3 = sels[num];
1238 Selectable selectable4 = sels[sels.Count - 1];
1239 Navigation navigation2 = selectable3.navigation;
1240 if (horizonal)
1241 {
1242 navigation2.selectOnLeft = ((num > 0) ? sels[num - 1] : selectable4);
1243 }
1244 if (asGroup)
1245 {
1246 int num2 = sels.Count - 1;
1247 for (int num3 = num - 1; num3 >= 0; num3--)
1248 {
1249 if (sels[num3].transform.position.y > selectable3.transform.position.y)
1250 {
1251 num2 = num3;
1252 break;
1253 }
1254 }
1255 int num4 = num2;
1256 while (num4 >= 0 && !(sels[num4].transform.position.y > sels[num2].transform.position.y))
1257 {
1258 selectable4 = sels[num4];
1259 num4--;
1260 }
1261 }
1262 else
1263 {
1264 selectable4 = ((num > 0) ? sels[num - 1] : selectable4);
1265 }
1266 if (vertical)
1267 {
1268 navigation2.selectOnUp = ((selectable4 == selectable3) ? sels[sels.Count - 1] : selectable4);
1269 }
1270 navigation2.mode = Navigation.Mode.Explicit;
1271 selectable3.navigation = navigation2;
1272 }
1273 }
1274
1275 public static void LoopSelectable(this Transform l, bool vertical = true, bool horizonal = true, bool asGroup = true)
1276 {
1277 List<Selectable> list = l.GetComponentsInChildren<Selectable>().ToList();
1278 for (int num = list.Count - 1; num >= 0; num--)
1279 {
1280 if (!list[num].interactable || list[num].navigation.mode == Navigation.Mode.None)
1281 {
1282 list.RemoveAt(num);
1283 }
1284 }
1285 list.LoopSelectable(vertical, horizonal, asGroup);
1286 }
1287
1288 public static Color ToColor(this string s)
1289 {
1290 Color color = Color.white;
1291 ColorUtility.TryParseHtmlString("#" + s, out color);
1292 return color;
1293 }
1294
1295 public static void SetAlpha(this Image c, float a)
1296 {
1297 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1298 }
1299
1300 public static void SetAlpha(this RawImage c, float a)
1301 {
1302 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1303 }
1304
1305 public static Color SetAlpha(this Color c, float a)
1306 {
1307 c.a = a;
1308 return c;
1309 }
1310
1311 public static Color Multiply(this Color c, float mtp, float add)
1312 {
1313 return new Color(c.r * mtp + add, c.g * mtp + add, c.b * mtp + add, c.a);
1314 }
1315
1316 public static string Tag(this Color c)
1317 {
1318 return "<color=" + $"#{(int)(c.r * 255f):X2}{(int)(c.g * 255f):X2}{(int)(c.b * 255f):X2}" + ">";
1319 }
1320
1321 public static string ToHex(this Color c)
1322 {
1323 return $"#{(int)(c.r * 255f):X2}{(int)(c.g * 255f):X2}{(int)(c.b * 255f):X2}";
1324 }
1325
1326 public static void SetOnClick(this Button b, Action action)
1327 {
1328 b.onClick.RemoveAllListeners();
1329 b.onClick.AddListener(delegate
1330 {
1331 action();
1332 });
1333 }
1334
1335 public static void SetListener(this Button.ButtonClickedEvent e, Action action)
1336 {
1337 e.RemoveAllListeners();
1338 e.AddListener(delegate
1339 {
1340 action();
1341 });
1342 }
1343
1344 public static void SetAlpha(this Text text, float aloha = 1f)
1345 {
1346 text.color = new Color(text.color.r, text.color.g, text.color.b, aloha);
1347 }
1348
1349 public static void SetSlider(this Slider slider, float value, Func<float, string> action, bool notify)
1350 {
1351 slider.SetSlider(value, action, -1, -1, notify);
1352 }
1353
1354 public static void SetSlider(this Slider slider, float value, Func<float, string> action, int min = -1, int max = -1, bool notify = true)
1355 {
1356 slider.onValueChanged.RemoveAllListeners();
1357 slider.onValueChanged.AddListener(delegate(float a)
1358 {
1359 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(a);
1360 });
1361 if (min != -1)
1362 {
1363 slider.minValue = min;
1364 slider.maxValue = max;
1365 }
1366 if (notify)
1367 {
1368 slider.value = value;
1369 }
1370 else
1371 {
1372 slider.SetValueWithoutNotify(value);
1373 }
1374 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(value);
1375 }
1376
1377 public static T GetOrCreate<T>(this Component t) where T : Component
1378 {
1379 T val = t.gameObject.GetComponent<T>();
1380 if (!val)
1381 {
1382 val = t.gameObject.AddComponent<T>();
1383 }
1384 return val;
1385 }
1386
1387 public static RectTransform Rect(this Component c)
1388 {
1389 return c.transform as RectTransform;
1390 }
1391
1392 public static void CopyRect(this RectTransform r, RectTransform t)
1393 {
1394 r.pivot = t.pivot;
1395 r.sizeDelta = t.sizeDelta;
1396 r.anchorMin = t.anchorMin;
1397 r.anchorMax = t.anchorMax;
1398 r.anchoredPosition = t.anchoredPosition;
1399 }
1400
1401 public static void ToggleActive(this Component c)
1402 {
1403 c.SetActive(!c.gameObject.activeSelf);
1404 }
1405
1406 public static void SetActive(this Component c, bool enable)
1407 {
1408 if (c.gameObject.activeSelf != enable)
1409 {
1410 c.gameObject.SetActive(enable);
1411 }
1412 }
1413
1414 public static void SetActive(this Component c, bool enable, Action<bool> onChangeState)
1415 {
1416 if (c.gameObject.activeSelf != enable)
1417 {
1418 c.gameObject.SetActive(enable);
1419 onChangeState(enable);
1420 }
1421 }
1422
1423 public static Selectable GetSelectable(this GameObject go)
1424 {
1425 return go.GetComponentInChildren<Selectable>();
1426 }
1427
1428 public static void SetLayerRecursively(this GameObject obj, int layer)
1429 {
1430 obj.layer = layer;
1431 foreach (Transform item in obj.transform)
1432 {
1433 item.gameObject.SetLayerRecursively(layer);
1434 }
1435 }
1436
1437 public static bool IsInteractable(this GameObject obj)
1438 {
1439 Selectable selectable = (obj ? obj.GetComponent<Selectable>() : null);
1440 if ((bool)selectable)
1441 {
1442 return selectable.interactable;
1443 }
1444 return false;
1445 }
1446
1447 public static bool IsChildOf(this GameObject c, GameObject root)
1448 {
1449 if (c.transform == root.transform)
1450 {
1451 return true;
1452 }
1453 if ((bool)c.transform.parent)
1454 {
1455 return c.transform.parent.gameObject.IsChildOf(root);
1456 }
1457 return false;
1458 }
1459
1460 public static bool IsPrefab(this Component c)
1461 {
1462 return c.gameObject.scene.name == null;
1463 }
1464
1465 public static T CreateMold<T>(this Component c, string name = null) where T : Component
1466 {
1467 T result = null;
1468 for (int i = 0; i < c.transform.childCount; i++)
1469 {
1470 T component = c.transform.GetChild(i).GetComponent<T>();
1471 if ((bool)component && (name.IsEmpty() || name == component.name))
1472 {
1473 component.gameObject.SetActive(value: false);
1474 result = component;
1475 break;
1476 }
1477 }
1478 c.DestroyChildren();
1479 return result;
1480 }
1481
1482 public static Transform Find(this Component c, string name = null)
1483 {
1484 return c.Find<Transform>(name);
1485 }
1486
1487 public static T Find<T>(this Component c, string name = null, bool recursive = false) where T : Component
1488 {
1489 if (recursive)
1490 {
1491 T[] componentsInChildren = c.transform.GetComponentsInChildren<T>();
1492 foreach (T val in componentsInChildren)
1493 {
1494 if (name == null || name == val.name)
1495 {
1496 return val;
1497 }
1498 }
1499 return null;
1500 }
1501 for (int j = 0; j < c.transform.childCount; j++)
1502 {
1503 T component = c.transform.GetChild(j).GetComponent<T>();
1504 if ((bool)component && (name == null || name == component.name))
1505 {
1506 return component;
1507 }
1508 }
1509 return null;
1510 }
1511
1512 public static GameObject FindTagInParents(this Component c, string tag, bool includeInactive = true)
1513 {
1514 Transform transform = c.transform;
1515 for (int i = 0; i < transform.childCount; i++)
1516 {
1517 Transform child = transform.GetChild(i);
1518 if ((includeInactive || child.gameObject.activeSelf) && child.tag == tag)
1519 {
1520 return child.gameObject;
1521 }
1522 }
1523 if ((bool)transform.parent)
1524 {
1525 return transform.parent.FindTagInParents(tag, includeInactive);
1526 }
1527 return null;
1528 }
1529
1530 public static T GetComponentInChildrenExcludSelf<T>(this Transform c) where T : Component
1531 {
1532 for (int i = 0; i < c.childCount; i++)
1533 {
1534 T component = c.GetChild(i).GetComponent<T>();
1535 if ((bool)component)
1536 {
1537 return component;
1538 }
1539 }
1540 return null;
1541 }
1542
1543 public static List<T> GetComponentsInDirectChildren<T>(this Transform comp, bool includeInactive = true) where T : Component
1544 {
1545 List<T> list = new List<T>();
1546 Transform transform = comp.transform;
1547 for (int i = 0; i < transform.childCount; i++)
1548 {
1549 T component = transform.GetChild(i).GetComponent<T>();
1550 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1551 {
1552 list.Add(component);
1553 }
1554 }
1555 return list;
1556 }
1557
1558 public static List<T> GetComponentsInDirectChildren<T>(this Component comp, bool includeInactive = true) where T : Component
1559 {
1560 List<T> list = new List<T>();
1561 Transform transform = comp.transform;
1562 for (int i = 0; i < transform.childCount; i++)
1563 {
1564 T component = transform.GetChild(i).GetComponent<T>();
1565 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1566 {
1567 list.Add(component);
1568 }
1569 }
1570 return list;
1571 }
1572
1573 public static T GetComponentInDirectChildren<T>(this Component comp) where T : Component
1574 {
1575 Transform transform = comp.transform;
1576 for (int i = 0; i < transform.childCount; i++)
1577 {
1578 T component = transform.GetChild(i).GetComponent<T>();
1579 if ((bool)component)
1580 {
1581 return component;
1582 }
1583 }
1584 return null;
1585 }
1586
1587 public static void DestroyChildren(this Component component, bool destroyInactive = false, bool ignoreDestroy = true)
1588 {
1589 if (!component || !component.transform)
1590 {
1591 Debug.LogWarning("DestroyChlidren:" + component);
1592 return;
1593 }
1594 for (int num = component.transform.childCount - 1; num >= 0; num--)
1595 {
1596 GameObject gameObject = component.transform.GetChild(num).gameObject;
1597 if ((!ignoreDestroy || !(gameObject.tag == "IgnoreDestroy")) && (destroyInactive || gameObject.activeSelf))
1598 {
1599 UnityEngine.Object.DestroyImmediate(gameObject);
1600 }
1601 }
1602 }
1603
1604 public static bool IsMouseOver(this RectTransform r, Camera cam)
1605 {
1606 return RectTransformUtility.RectangleContainsScreenPoint(r, Input.mousePosition, cam);
1607 }
1608
1609 public static void RebuildLayout(this Component c, bool recursive = false)
1610 {
1611 if (recursive)
1612 {
1613 foreach (Transform item in c.transform)
1614 {
1615 if (item is RectTransform)
1616 {
1617 item.RebuildLayout(recursive: true);
1618 }
1619 }
1620 }
1621 LayoutRebuilder.ForceRebuildLayoutImmediate(c.transform as RectTransform);
1622 }
1623
1624 public static void RebuildLayoutTo<T>(this Component c) where T : Component
1625 {
1626 c.RebuildLayout();
1627 if ((bool)c.transform.parent && !c.transform.parent.GetComponent<T>())
1628 {
1629 c.transform.parent.RebuildLayoutTo<T>();
1630 }
1631 }
1632
1633 public static void RebuildLayoutTo(this Component c, Component target)
1634 {
1635 c.RebuildLayout();
1636 if (!(c == target) && (bool)c.transform.parent)
1637 {
1638 c.transform.parent.RebuildLayoutTo(target);
1639 }
1640 }
1641
1642 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)
1643 {
1644 r.SetPivot(pivotX, pivotY);
1645 r.SetAnchor(minX, minY, maxX, maxY);
1646 if (w != -1f)
1647 {
1648 r.sizeDelta = new Vector2(w, h);
1649 }
1650 r.anchoredPosition = new Vector2((x == -1f) ? r.anchoredPosition.x : x, (y == -1f) ? r.anchoredPosition.y : y);
1651 }
1652
1653 public static void SetPivot(this RectTransform r, float x, float y)
1654 {
1655 r.pivot = new Vector2(x, y);
1656 }
1657
1658 public static void SetAnchor(this RectTransform r, float minX, float minY, float maxX, float maxY)
1659 {
1660 r.anchorMin = new Vector2(minX, minY);
1661 r.anchorMax = new Vector2(maxX, maxY);
1662 }
1663
1664 public static void _SetAnchor(this RectTransform _rect, RectPosition anchor)
1665 {
1666 switch (anchor)
1667 {
1668 case RectPosition.TopCenter:
1669 _rect.SetAnchor(0.5f, 1f, 0.5f, 1f);
1670 break;
1671 case RectPosition.BottomCenter:
1672 _rect.SetAnchor(0.5f, 0f, 0.5f, 0f);
1673 break;
1674 case RectPosition.TopLEFT:
1675 _rect.SetAnchor(0f, 1f, 0f, 1f);
1676 break;
1677 case RectPosition.TopRIGHT:
1678 _rect.SetAnchor(1f, 1f, 1f, 1f);
1679 break;
1680 case RectPosition.BottomLEFT:
1681 _rect.SetAnchor(0f, 0f, 0f, 0f);
1682 break;
1683 case RectPosition.BottomRIGHT:
1684 _rect.SetAnchor(1f, 0f, 1f, 0f);
1685 break;
1686 case RectPosition.Left:
1687 _rect.SetAnchor(0f, 0.5f, 0f, 0.5f);
1688 break;
1689 case RectPosition.Right:
1690 _rect.SetAnchor(1f, 0.5f, 1f, 0.5f);
1691 break;
1692 default:
1693 _rect.SetAnchor(0.5f, 0.5f, 0.5f, 0.5f);
1694 break;
1695 }
1696 }
1697
1698 public static void SetAnchor(this RectTransform _rect, RectPosition anchor = RectPosition.Auto)
1699 {
1700 Vector3 position = _rect.position;
1701 _rect._SetAnchor((anchor == RectPosition.Auto) ? _rect.GetAnchor() : anchor);
1702 _rect.position = position;
1703 }
1704
1705 public static RectPosition GetAnchor(this RectTransform _rect)
1706 {
1707 Vector3 position = _rect.position;
1708 int width = Screen.width;
1709 int height = Screen.height;
1710 bool flag = position.y > (float)height * 0.5f;
1711 if (position.x > (float)width * 0.3f && position.x < (float)width * 0.7f)
1712 {
1713 if (position.y > (float)height * 0.3f && position.y < (float)height * 0.7f)
1714 {
1715 return RectPosition.Center;
1716 }
1717 if (!flag)
1718 {
1719 return RectPosition.BottomCenter;
1720 }
1721 return RectPosition.TopCenter;
1722 }
1723 if (position.x < (float)width * 0.5f)
1724 {
1725 if (!flag)
1726 {
1727 return RectPosition.BottomLEFT;
1728 }
1729 return RectPosition.TopLEFT;
1730 }
1731 if (!flag)
1732 {
1733 return RectPosition.BottomRIGHT;
1734 }
1735 return RectPosition.TopRIGHT;
1736 }
1737
1738 public static Transform GetLastChild(this Transform trans)
1739 {
1740 return trans.GetChild(trans.childCount - 1);
1741 }
1742
1743 public static Vector2 ToVector2(this Vector3 self)
1744 {
1745 return new Vector2(self.x, self.z);
1746 }
1747
1748 public static void SetScale(this SpriteRenderer renderer, float size)
1749 {
1750 float x = renderer.bounds.size.x;
1751 float y = renderer.bounds.size.y;
1752 float x2 = size / x;
1753 float y2 = size / y;
1754 renderer.transform.localScale = new Vector3(x2, y2, 1f);
1755 }
1756
1757 private static float GetForwardDiffPoint(Vector2 forward)
1758 {
1759 if (object.Equals(forward, Vector2.up))
1760 {
1761 return 90f;
1762 }
1763 object.Equals(forward, Vector2.right);
1764 return 0f;
1765 }
1766
1767 public static void LookAt2D(this Transform self, Transform target, Vector2 forward)
1768 {
1769 self.LookAt2D(target.position, forward);
1770 }
1771
1772 public static void LookAt2D(this Transform self, Vector3 target, Vector2 forward)
1773 {
1774 float forwardDiffPoint = GetForwardDiffPoint(forward);
1775 Vector3 vector = target - self.position;
1776 float num = Mathf.Atan2(vector.y, vector.x) * 57.29578f;
1777 self.rotation = Quaternion.AngleAxis(num - forwardDiffPoint, Vector3.forward);
1778 }
1779
1780 public static float Distance(this Transform t, Vector2 pos)
1781 {
1782 return Vector3.Distance(t.position, pos);
1783 }
1784
1785 public static Vector3 Plus(this Vector3 v, Vector2 v2)
1786 {
1787 v.x += v2.x;
1788 v.y += v2.y;
1789 return v;
1790 }
1791
1792 public static Vector3 SetZ(this Vector3 v, float a)
1793 {
1794 v.z = a;
1795 return v;
1796 }
1797
1798 public static Vector3 SetY(this Vector3 v, float a)
1799 {
1800 v.y = a;
1801 return v;
1802 }
1803
1804 public static Vector3 PlusX(this Vector3 v, float a)
1805 {
1806 v.x += a;
1807 return v;
1808 }
1809
1810 public static Vector3 PlusY(this Vector3 v, float a)
1811 {
1812 v.y += a;
1813 return v;
1814 }
1815
1816 public static Vector3 PlusZ(this Vector3 v, float a)
1817 {
1818 v.z += a;
1819 return v;
1820 }
1821
1822 public static void SetPosition(this Transform transform, float x, float y, float z)
1823 {
1824 vector3.Set(x, y, z);
1825 transform.position = vector3;
1826 }
1827
1828 public static void SetPositionX(this Transform transform, float x)
1829 {
1830 vector3.Set(x, transform.position.y, transform.position.z);
1831 transform.position = vector3;
1832 }
1833
1834 public static void SetPositionY(this Transform transform, float y)
1835 {
1836 vector3.Set(transform.position.x, y, transform.position.z);
1837 transform.position = vector3;
1838 }
1839
1840 public static void SetPositionZ(this Transform transform, float z)
1841 {
1842 vector3.Set(transform.position.x, transform.position.y, z);
1843 transform.position = vector3;
1844 }
1845
1846 public static void AddPosition(this Transform transform, float x, float y, float z)
1847 {
1848 vector3.Set(transform.position.x + x, transform.position.y + y, transform.position.z + z);
1849 transform.position = vector3;
1850 }
1851
1852 public static void AddPositionX(this Transform transform, float x)
1853 {
1854 vector3.Set(transform.position.x + x, transform.position.y, transform.position.z);
1855 transform.position = vector3;
1856 }
1857
1858 public static void AddPositionY(this Transform transform, float y)
1859 {
1860 vector3.Set(transform.position.x, transform.position.y + y, transform.position.z);
1861 transform.position = vector3;
1862 }
1863
1864 public static void AddPositionZ(this Transform transform, float z)
1865 {
1866 vector3.Set(transform.position.x, transform.position.y, transform.position.z + z);
1867 transform.position = vector3;
1868 }
1869
1870 public static void SetLocalPosition(this Transform transform, float x, float y, float z)
1871 {
1872 vector3.Set(x, y, z);
1873 transform.localPosition = vector3;
1874 }
1875
1876 public static void SetLocalPositionX(this Transform transform, float x)
1877 {
1878 vector3.Set(x, transform.localPosition.y, transform.localPosition.z);
1879 transform.localPosition = vector3;
1880 }
1881
1882 public static void SetLocalPositionY(this Transform transform, float y)
1883 {
1884 vector3.Set(transform.localPosition.x, y, transform.localPosition.z);
1885 transform.localPosition = vector3;
1886 }
1887
1888 public static void SetLocalPositionZ(this Transform transform, float z)
1889 {
1890 vector3.Set(transform.localPosition.x, transform.localPosition.y, z);
1891 transform.localPosition = vector3;
1892 }
1893
1894 public static void AddLocalPosition(this Transform transform, float x, float y, float z)
1895 {
1896 vector3.Set(transform.localPosition.x + x, transform.localPosition.y + y, transform.localPosition.z + z);
1897 transform.localPosition = vector3;
1898 }
1899
1900 public static void AddLocalPositionX(this Transform transform, float x)
1901 {
1902 vector3.Set(transform.localPosition.x + x, transform.localPosition.y, transform.localPosition.z);
1903 transform.localPosition = vector3;
1904 }
1905
1906 public static void AddLocalPositionY(this Transform transform, float y)
1907 {
1908 vector3.Set(transform.localPosition.x, transform.localPosition.y + y, transform.localPosition.z);
1909 transform.localPosition = vector3;
1910 }
1911
1912 public static void AddLocalPositionZ(this Transform transform, float z)
1913 {
1914 vector3.Set(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z + z);
1915 transform.localPosition = vector3;
1916 }
1917
1918 public static void SetLocalScale(this Transform transform, float x, float y, float z)
1919 {
1920 vector3.Set(x, y, z);
1921 transform.localScale = vector3;
1922 }
1923
1924 public static void SetLocalScaleX(this Transform transform, float x)
1925 {
1926 vector3.Set(x, transform.localScale.y, transform.localScale.z);
1927 transform.localScale = vector3;
1928 }
1929
1930 public static void SetLocalScaleY(this Transform transform, float y)
1931 {
1932 vector3.Set(transform.localScale.x, y, transform.localScale.z);
1933 transform.localScale = vector3;
1934 }
1935
1936 public static void SetLocalScaleZ(this Transform transform, float z)
1937 {
1938 vector3.Set(transform.localScale.x, transform.localScale.y, z);
1939 transform.localScale = vector3;
1940 }
1941
1942 public static void AddLocalScale(this Transform transform, float x, float y, float z)
1943 {
1944 vector3.Set(transform.localScale.x + x, transform.localScale.y + y, transform.localScale.z + z);
1945 transform.localScale = vector3;
1946 }
1947
1948 public static void AddLocalScaleX(this Transform transform, float x)
1949 {
1950 vector3.Set(transform.localScale.x + x, transform.localScale.y, transform.localScale.z);
1951 transform.localScale = vector3;
1952 }
1953
1954 public static void AddLocalScaleY(this Transform transform, float y)
1955 {
1956 vector3.Set(transform.localScale.x, transform.localScale.y + y, transform.localScale.z);
1957 transform.localScale = vector3;
1958 }
1959
1960 public static void AddLocalScaleZ(this Transform transform, float z)
1961 {
1962 vector3.Set(transform.localScale.x, transform.localScale.y, transform.localScale.z + z);
1963 transform.localScale = vector3;
1964 }
1965
1966 public static void SetEulerAngles(this Transform transform, float x, float y, float z)
1967 {
1968 vector3.Set(x, y, z);
1969 transform.eulerAngles = vector3;
1970 }
1971
1972 public static void SetEulerAnglesX(this Transform transform, float x)
1973 {
1974 vector3.Set(x, transform.localEulerAngles.y, transform.localEulerAngles.z);
1975 transform.eulerAngles = vector3;
1976 }
1977
1978 public static void SetEulerAnglesY(this Transform transform, float y)
1979 {
1980 vector3.Set(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
1981 transform.eulerAngles = vector3;
1982 }
1983
1984 public static void SetEulerAnglesZ(this Transform transform, float z)
1985 {
1986 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, z);
1987 transform.eulerAngles = vector3;
1988 }
1989
1990 public static void AddEulerAngles(this Transform transform, float x, float y, float z)
1991 {
1992 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y + y, transform.eulerAngles.z + z);
1993 transform.eulerAngles = vector3;
1994 }
1995
1996 public static void AddEulerAnglesX(this Transform transform, float x)
1997 {
1998 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y, transform.eulerAngles.z);
1999 transform.eulerAngles = vector3;
2000 }
2001
2002 public static void AddEulerAnglesY(this Transform transform, float y)
2003 {
2004 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y + y, transform.eulerAngles.z);
2005 transform.eulerAngles = vector3;
2006 }
2007
2008 public static void AddEulerAnglesZ(this Transform transform, float z)
2009 {
2010 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z + z);
2011 transform.eulerAngles = vector3;
2012 }
2013
2014 public static void SetLocalEulerAngles(this Transform transform, float x, float y, float z)
2015 {
2016 vector3.Set(x, y, z);
2017 transform.localEulerAngles = vector3;
2018 }
2019
2020 public static void SetLocalEulerAnglesX(this Transform transform, float x)
2021 {
2022 vector3.Set(x, transform.localEulerAngles.y, transform.localEulerAngles.z);
2023 transform.localEulerAngles = vector3;
2024 }
2025
2026 public static void SetLocalEulerAnglesY(this Transform transform, float y)
2027 {
2028 vector3.Set(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
2029 transform.localEulerAngles = vector3;
2030 }
2031
2032 public static void SetLocalEulerAnglesZ(this Transform transform, float z)
2033 {
2034 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, z);
2035 transform.localEulerAngles = vector3;
2036 }
2037
2038 public static void AddLocalEulerAngles(this Transform transform, float x, float y, float z)
2039 {
2040 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y + y, transform.localEulerAngles.z + z);
2041 transform.localEulerAngles = vector3;
2042 }
2043
2044 public static void AddLocalEulerAnglesX(this Transform transform, float x)
2045 {
2046 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y, transform.localEulerAngles.z);
2047 transform.localEulerAngles = vector3;
2048 }
2049
2050 public static void AddLocalEulerAnglesY(this Transform transform, float y)
2051 {
2052 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y + y, transform.localEulerAngles.z);
2053 transform.localEulerAngles = vector3;
2054 }
2055
2056 public static void AddLocalEulerAnglesZ(this Transform transform, float z)
2057 {
2058 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, transform.localEulerAngles.z + z);
2059 transform.localEulerAngles = vector3;
2060 }
2061
2062 public static void ToggleKeyword(this Material m, string id, bool enable)
2063 {
2064 if (enable)
2065 {
2066 m.EnableKeyword(id);
2067 }
2068 else
2069 {
2070 m.DisableKeyword(id);
2071 }
2072 }
2073
2074 public static void ForeachReverse<T>(this IList<T> items, Action<T> action)
2075 {
2076 for (int num = items.Count - 1; num >= 0; num--)
2077 {
2078 action(items[num]);
2079 }
2080 }
2081
2082 public static void ForeachReverse<T>(this IList<T> items, Func<T, bool> action)
2083 {
2084 int num = items.Count - 1;
2085 while (num >= 0 && !action(items[num]))
2086 {
2087 num--;
2088 }
2089 }
2090
2091 public static bool RemoveFromEnd<T>(this List<T> items, T item)
2092 {
2093 int num = items.LastIndexOf(item);
2094 if (num < 0)
2095 {
2096 return false;
2097 }
2098 items.RemoveAt(num);
2099 return true;
2100 }
2101
2102 public static float ClampAngle(this float angle)
2103 {
2104 if (angle < 0f)
2105 {
2106 return 360f - (0f - angle) % 360f;
2107 }
2108 return angle % 360f;
2109 }
2110
2111 public static Vector3 Random(this Vector3 v)
2112 {
2113 return new Vector3(Rand.Range(0f - v.x, v.x), Rand.Range(0f - v.y, v.y), Rand.Range(0f - v.z, v.z));
2114 }
2115
2116 public static T Instantiate<T>(this T s) where T : ScriptableObject
2117 {
2118 string name = s.name;
2119 T val = UnityEngine.Object.Instantiate(s);
2120 val.name = name;
2121 return val;
2122 }
2123
2124 public static int GetRuntimeEventCount(this UnityEventBase unityEvent)
2125 {
2126 Type typeFromHandle = typeof(UnityEventBase);
2127 Assembly assembly = Assembly.GetAssembly(typeFromHandle);
2128 Type type = assembly.GetType("UnityEngine.Events.InvokableCallList");
2129 Type type2 = assembly.GetType("UnityEngine.Events.BaseInvokableCall");
2130 Type type3 = typeof(List<>).MakeGenericType(type2);
2131 FieldInfo field = typeFromHandle.GetField("m_Calls", BindingFlags.Instance | BindingFlags.NonPublic);
2132 FieldInfo field2 = type.GetField("m_RuntimeCalls", BindingFlags.Instance | BindingFlags.NonPublic);
2133 object value = field.GetValue(unityEvent);
2134 object value2 = field2.GetValue(value);
2135 return (int)type3.GetProperty("Count").GetValue(value2, null);
2136 }
2137}
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 string ToSentenceCase(this string s)
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