using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; namespace ProBuilder2.Common { // Token: 0x02000039 RID: 57 public class pb_PreferenceDictionary : ScriptableObject, IEnumerable, ISerializationCallbackReceiver, pb_IHasDefault { // Token: 0x060001BB RID: 443 RVA: 0x00016FB0 File Offset: 0x000153B0 public void OnBeforeSerialize() { this.m_Bool_keys = this.m_Bool.Keys.ToList(); this.m_Int_keys = this.m_Int.Keys.ToList(); this.m_Float_keys = this.m_Float.Keys.ToList(); this.m_String_keys = this.m_String.Keys.ToList(); this.m_Color_keys = this.m_Color.Keys.ToList(); this.m_Material_keys = this.m_Material.Keys.ToList(); this.m_Bool_values = this.m_Bool.Values.ToList(); this.m_Int_values = this.m_Int.Values.ToList(); this.m_Float_values = this.m_Float.Values.ToList(); this.m_String_values = this.m_String.Values.ToList(); this.m_Color_values = this.m_Color.Values.ToList(); this.m_Material_values = this.m_Material.Values.ToList(); } // Token: 0x060001BC RID: 444 RVA: 0x000170C8 File Offset: 0x000154C8 public void OnAfterDeserialize() { for (int i = 0; i < this.m_Bool_keys.Count; i++) { this.m_Bool.Add(this.m_Bool_keys[i], this.m_Bool_values[i]); } for (int j = 0; j < this.m_Int_keys.Count; j++) { this.m_Int.Add(this.m_Int_keys[j], this.m_Int_values[j]); } for (int k = 0; k < this.m_Float_keys.Count; k++) { this.m_Float.Add(this.m_Float_keys[k], this.m_Float_values[k]); } for (int l = 0; l < this.m_String_keys.Count; l++) { this.m_String.Add(this.m_String_keys[l], this.m_String_values[l]); } for (int m = 0; m < this.m_Color_keys.Count; m++) { this.m_Color.Add(this.m_Color_keys[m], this.m_Color_values[m]); } for (int n = 0; n < this.m_Material_keys.Count; n++) { this.m_Material.Add(this.m_Material_keys[n], this.m_Material_values[n]); } } // Token: 0x17000031 RID: 49 // (get) Token: 0x060001BD RID: 445 RVA: 0x0001725B File Offset: 0x0001565B public int Length { get { return 6; } } // Token: 0x060001BE RID: 446 RVA: 0x0001725E File Offset: 0x0001565E IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } // Token: 0x060001BF RID: 447 RVA: 0x00017266 File Offset: 0x00015666 public pb_PreferenceDictionaryEnumerator GetEnumerator() { return new pb_PreferenceDictionaryEnumerator(this); } // Token: 0x060001C0 RID: 448 RVA: 0x00017270 File Offset: 0x00015670 public void SetDefaultValues() { this.m_Bool.Clear(); this.m_Int.Clear(); this.m_Float.Clear(); this.m_String.Clear(); this.m_Color.Clear(); this.m_Material.Clear(); } // Token: 0x060001C1 RID: 449 RVA: 0x000172C0 File Offset: 0x000156C0 public bool HasKey(string key) { return this.m_Bool.ContainsKey(key) || this.m_Int.ContainsKey(key) || this.m_Float.ContainsKey(key) || this.m_String.ContainsKey(key) || this.m_Color.ContainsKey(key) || this.m_Material.ContainsKey(key); } // Token: 0x060001C2 RID: 450 RVA: 0x00017334 File Offset: 0x00015734 public bool HasKey(string key) { Type typeFromHandle = typeof(T); if (typeFromHandle == typeof(int)) { return this.m_Int.ContainsKey(key); } if (typeFromHandle == typeof(float)) { return this.m_Float.ContainsKey(key); } if (typeFromHandle == typeof(bool)) { return this.m_Bool.ContainsKey(key); } if (typeFromHandle == typeof(string)) { return this.m_String.ContainsKey(key); } if (typeFromHandle == typeof(Color)) { return this.m_Color.ContainsKey(key); } if (typeFromHandle == typeof(Material)) { return this.m_Material.ContainsKey(key); } Debug.LogWarning(string.Format("HasKey<{0}>({1}) not valid preference type.", typeof(T).ToString(), key)); return false; } // Token: 0x060001C3 RID: 451 RVA: 0x0001741C File Offset: 0x0001581C public void DeleteKey(string key) { if (this.m_Bool.ContainsKey(key)) { this.m_Bool.Remove(key); } if (this.m_Int.ContainsKey(key)) { this.m_Int.Remove(key); } if (this.m_Float.ContainsKey(key)) { this.m_Float.Remove(key); } if (this.m_String.ContainsKey(key)) { this.m_String.Remove(key); } if (this.m_Color.ContainsKey(key)) { this.m_Color.Remove(key); } if (this.m_Material.ContainsKey(key)) { this.m_Material.Remove(key); } } // Token: 0x060001C4 RID: 452 RVA: 0x000174E0 File Offset: 0x000158E0 public T Get(string key, T fallback = default(T)) { Type typeFromHandle = typeof(T); if (typeFromHandle == typeof(int)) { if (this.m_Int.ContainsKey(key)) { return (T)((object)this.GetInt(key, 0)); } } else if (typeFromHandle == typeof(float)) { if (this.m_Float.ContainsKey(key)) { return (T)((object)this.GetFloat(key, 0f)); } } else if (typeFromHandle == typeof(bool)) { if (this.m_Bool.ContainsKey(key)) { return (T)((object)this.GetBool(key, false)); } } else if (typeFromHandle == typeof(string)) { if (this.m_String.ContainsKey(key)) { return (T)((object)this.GetString(key, null)); } } else if (typeFromHandle == typeof(Color)) { if (this.m_Color.ContainsKey(key)) { return (T)((object)this.GetColor(key, default(Color))); } } else if (typeFromHandle == typeof(Material)) { if (this.m_Material.ContainsKey(key)) { return (T)((object)this.GetMaterial(key, null)); } } else { Debug.LogWarning(string.Format("Get<{0}>({1}) not valid preference type.", typeof(T).ToString(), key)); } return fallback; } // Token: 0x060001C5 RID: 453 RVA: 0x00017670 File Offset: 0x00015A70 public void Set(string key, T value) { object obj = value; if (value is int) { this.SetInt(key, (int)obj); } else if (value is float) { this.SetFloat(key, (float)obj); } else if (value is bool) { this.SetBool(key, (bool)obj); } else if (value is string) { this.SetString(key, (string)obj); } else if (value is Color) { this.SetColor(key, (Color)obj); } else if (value is Material) { this.SetMaterial(key, (Material)obj); } else { Debug.LogWarning(string.Format("Set<{0}>({1}, {2}) not valid preference type.", typeof(T).ToString(), key, value.ToString())); } } // Token: 0x060001C6 RID: 454 RVA: 0x0001777C File Offset: 0x00015B7C public bool GetBool(string key, bool fallback = false) { bool flag; if (this.m_Bool.TryGetValue(key, out flag)) { return flag; } return fallback; } // Token: 0x060001C7 RID: 455 RVA: 0x000177A0 File Offset: 0x00015BA0 public int GetInt(string key, int fallback = 0) { int num; if (this.m_Int.TryGetValue(key, out num)) { return num; } return fallback; } // Token: 0x060001C8 RID: 456 RVA: 0x000177C4 File Offset: 0x00015BC4 public float GetFloat(string key, float fallback = 0f) { float num; if (this.m_Float.TryGetValue(key, out num)) { return num; } return fallback; } // Token: 0x060001C9 RID: 457 RVA: 0x000177E8 File Offset: 0x00015BE8 public string GetString(string key, string fallback = null) { string text; if (this.m_String.TryGetValue(key, out text)) { return text; } return fallback; } // Token: 0x060001CA RID: 458 RVA: 0x0001780C File Offset: 0x00015C0C public Color GetColor(string key, Color fallback = default(Color)) { Color color; if (this.m_Color.TryGetValue(key, out color)) { return color; } return fallback; } // Token: 0x060001CB RID: 459 RVA: 0x00017830 File Offset: 0x00015C30 public Material GetMaterial(string key, Material fallback = null) { Material material; if (this.m_Material.TryGetValue(key, out material)) { return material; } return fallback; } // Token: 0x060001CC RID: 460 RVA: 0x00017853 File Offset: 0x00015C53 public void SetBool(string key, bool value) { if (this.m_Bool.ContainsKey(key)) { this.m_Bool[key] = value; } else { this.m_Bool.Add(key, value); } } // Token: 0x060001CD RID: 461 RVA: 0x00017885 File Offset: 0x00015C85 public void SetInt(string key, int value) { if (this.m_Int.ContainsKey(key)) { this.m_Int[key] = value; } else { this.m_Int.Add(key, value); } } // Token: 0x060001CE RID: 462 RVA: 0x000178B7 File Offset: 0x00015CB7 public void SetFloat(string key, float value) { if (this.m_Float.ContainsKey(key)) { this.m_Float[key] = value; } else { this.m_Float.Add(key, value); } } // Token: 0x060001CF RID: 463 RVA: 0x000178E9 File Offset: 0x00015CE9 public void SetString(string key, string value) { if (this.m_String.ContainsKey(key)) { this.m_String[key] = value; } else { this.m_String.Add(key, value); } } // Token: 0x060001D0 RID: 464 RVA: 0x0001791B File Offset: 0x00015D1B public void SetColor(string key, Color value) { if (this.m_Color.ContainsKey(key)) { this.m_Color[key] = value; } else { this.m_Color.Add(key, value); } } // Token: 0x060001D1 RID: 465 RVA: 0x0001794D File Offset: 0x00015D4D public void SetMaterial(string key, Material value) { if (this.m_Material.ContainsKey(key)) { this.m_Material[key] = value; } else { this.m_Material.Add(key, value); } } // Token: 0x060001D2 RID: 466 RVA: 0x0001797F File Offset: 0x00015D7F public Dictionary GetBoolDictionary() { return this.m_Bool; } // Token: 0x060001D3 RID: 467 RVA: 0x00017987 File Offset: 0x00015D87 public Dictionary GetIntDictionary() { return this.m_Int; } // Token: 0x060001D4 RID: 468 RVA: 0x0001798F File Offset: 0x00015D8F public Dictionary GetFloatDictionary() { return this.m_Float; } // Token: 0x060001D5 RID: 469 RVA: 0x00017997 File Offset: 0x00015D97 public Dictionary GetStringDictionary() { return this.m_String; } // Token: 0x060001D6 RID: 470 RVA: 0x0001799F File Offset: 0x00015D9F public Dictionary GetColorDictionary() { return this.m_Color; } // Token: 0x060001D7 RID: 471 RVA: 0x000179A7 File Offset: 0x00015DA7 public Dictionary GetMaterialDictionary() { return this.m_Material; } // Token: 0x060001D8 RID: 472 RVA: 0x000179AF File Offset: 0x00015DAF public void Clear() { this.m_Bool.Clear(); this.m_Int.Clear(); this.m_Float.Clear(); this.m_String.Clear(); this.m_Color.Clear(); } // Token: 0x04000157 RID: 343 private Dictionary m_Bool = new Dictionary(); // Token: 0x04000158 RID: 344 private Dictionary m_Int = new Dictionary(); // Token: 0x04000159 RID: 345 private Dictionary m_Float = new Dictionary(); // Token: 0x0400015A RID: 346 private Dictionary m_String = new Dictionary(); // Token: 0x0400015B RID: 347 private Dictionary m_Color = new Dictionary(); // Token: 0x0400015C RID: 348 private Dictionary m_Material = new Dictionary(); // Token: 0x0400015D RID: 349 [SerializeField] private List m_Bool_keys; // Token: 0x0400015E RID: 350 [SerializeField] private List m_Int_keys; // Token: 0x0400015F RID: 351 [SerializeField] private List m_Float_keys; // Token: 0x04000160 RID: 352 [SerializeField] private List m_String_keys; // Token: 0x04000161 RID: 353 [SerializeField] private List m_Color_keys; // Token: 0x04000162 RID: 354 [SerializeField] private List m_Material_keys; // Token: 0x04000163 RID: 355 [SerializeField] private List m_Bool_values; // Token: 0x04000164 RID: 356 [SerializeField] private List m_Int_values; // Token: 0x04000165 RID: 357 [SerializeField] private List m_Float_values; // Token: 0x04000166 RID: 358 [SerializeField] private List m_String_values; // Token: 0x04000167 RID: 359 [SerializeField] private List m_Color_values; // Token: 0x04000168 RID: 360 [SerializeField] private List m_Material_values; } }