Elin Modding Docs Doc
Loading...
Searching...
No Matches
LayerPolicy.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using UnityEngine;
5
6// Token: 0x020005B4 RID: 1460
7public class LayerPolicy : ELayer
8{
9 // Token: 0x06002809 RID: 10249 RVA: 0x000E214E File Offset: 0x000E034E
10 public override void OnInit()
11 {
12 this.RefreshPolicy();
13 }
14
15 // Token: 0x0600280A RID: 10250 RVA: 0x000E2158 File Offset: 0x000E0358
16 public void RefreshPolicy()
17 {
18 this.RefreshPolicyList(this.listPolicyLaw, "law", "department_law");
19 this.RefreshPolicyList(this.listPolicyEconomy, "economy", "department_economy");
20 this.RefreshPolicyList(this.listPolicyLife, "life", "department_life");
21 this.RefreshPolicyIcons();
22 }
23
24 // Token: 0x0600280B RID: 10251 RVA: 0x000E21B0 File Offset: 0x000E03B0
25 public void RefreshPolicyList(UIList list, string cat, string plan)
26 {
27 BaseList list2 = list;
28 UIList.Callback<Policy, UIButton> callback = new UIList.Callback<Policy, UIButton>();
29 callback.onClick = delegate(Policy a, UIButton b)
30 {
31 };
32 callback.onInstantiate = delegate(Policy a, UIButton b)
33 {
34 b.mainText.SetText(a.Name);
35 b.onClick.AddListener(delegate()
36 {
37 if (!a.active && ELayer.Branch.policies.CurrentAP() + a.Cost > ELayer.Branch.MaxAP)
38 {
39 SE.Beep();
40 return;
41 }
42 SE.ClickOk();
43 a.active = !a.active;
44 ELayer.Branch.policies.RefreshEffects();
45 this.RefreshPolicyIcons();
46 });
47 b.refObj = a;
48 b.tooltip.onShowTooltip = delegate(UITooltip tp)
49 {
50 a.WriteNote(tp.note);
51 };
52 };
53 Func<Policy, bool> <>9__6;
54 callback.onList = delegate(UIList.SortMode m)
55 {
56 IEnumerable<Policy> list3 = ELayer.Branch.policies.list;
57 Func<Policy, bool> predicate;
58 if ((predicate = <>9__6) == null)
59 {
60 predicate = (<>9__6 = ((Policy p) => p.source.categorySub == cat));
61 }
62 foreach (Policy o in list3.Where(predicate))
63 {
64 list.Add(o);
65 }
66 };
67 callback.onSort = ((Policy a, UIList.SortMode m) => a.GetSortVal(m));
68 callback.onRefresh = null;
69 list2.callbacks = callback;
70 list.List(false);
71 list.GetComponentInChildren<CanvasGroup>().alpha = ((list.items.Count > 0) ? 0.9f : 0.4f);
72 }
73
74 // Token: 0x0600280C RID: 10252 RVA: 0x000E2298 File Offset: 0x000E0498
75 public void RefreshPolicyIcons()
76 {
77 int num = ELayer.Branch.policies.CurrentAP();
78 UIList[] array = new UIList[]
79 {
80 this.listPolicyLaw,
81 this.listPolicyLife,
82 this.listPolicyEconomy
83 };
84 for (int i = 0; i < array.Length; i++)
85 {
86 foreach (UIButton uibutton in array[i].GetComponentsInChildren<UIButton>())
87 {
88 Policy policy = uibutton.refObj as Policy;
89 uibutton.icon.material = (policy.active ? null : this.matGrayscale);
90 uibutton.imageCheck.SetActive(policy.active);
91 uibutton.subText.SetText(policy.Cost.ToString() ?? "", (num + policy.Cost <= ELayer.Branch.MaxAP || policy.active) ? FontColor.Good : FontColor.Bad);
92 }
93 }
94 }
95
96 // Token: 0x0400162E RID: 5678
97 public UIList listPolicyLaw;
98
99 // Token: 0x0400162F RID: 5679
100 public UIList listPolicyEconomy;
101
102 // Token: 0x04001630 RID: 5680
103 public UIList listPolicyLife;
104
105 // Token: 0x04001631 RID: 5681
106 public Material matGrayscale;
107}