Elin Modding Docs Doc
Loading...
Searching...
No Matches
ContentPolicy.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Runtime.CompilerServices;
5using UnityEngine;
6
7// Token: 0x02000551 RID: 1361
8public class ContentPolicy : EContent
9{
10 // Token: 0x060024FC RID: 9468 RVA: 0x000D14B0 File Offset: 0x000CF6B0
11 public override void OnSwitchContent(int idTab)
12 {
13 EClass.Branch.policies.Validate();
14 this.RefreshPolicy();
15 }
16
17 // Token: 0x060024FD RID: 9469 RVA: 0x000D14C8 File Offset: 0x000CF6C8
18 public void RefreshPolicy()
19 {
20 this.RefreshPolicyList(this.listPolicyLaw, "law", "department_law");
21 this.RefreshPolicyList(this.listPolicyEconomy, "economy", "department_economy");
22 this.RefreshPolicyList(this.listPolicyLife, "life", "department_life");
23 this.RefreshPolicyList(this.listUtility, "utility", "department_utility");
24 this.listUtility.SetActive(EClass.Branch.lv >= 2);
25 this.RefreshPolicyIcons();
26 base.GetComponentInParent<Layer>().RebuildLayout(true);
27 this.RebuildLayout(true);
28 }
29
30 // Token: 0x060024FE RID: 9470 RVA: 0x000D1564 File Offset: 0x000CF764
31 public void RefreshPolicyList(UIList list, string cat, string plan)
32 {
33 BaseList list2 = list;
34 UIList.Callback<Policy, UIButton> callback = new UIList.Callback<Policy, UIButton>();
35 callback.onClick = delegate(Policy a, UIButton b)
36 {
37 };
38 callback.onInstantiate = delegate(Policy a, UIButton b)
39 {
40 b.mainText.SetText(a.Name);
41 b.onClick.AddListener(delegate()
42 {
43 if (!a.active)
44 {
45 if ((a.Cost > 0 && EClass.Branch.policies.CurrentAP() + a.Cost > EClass.Branch.MaxAP) || !ContentPolicy.<RefreshPolicyList>g__CanActivate|7_0(a))
46 {
47 SE.Beep();
48 return;
49 }
50 if (a.id == 2514 && EClass.pc.faction.CountTaxFreeLand() >= 3)
51 {
52 SE.Beep();
53 return;
54 }
55 }
56 SE.ClickOk();
57 a.active = !a.active;
58 if (a.id == 2705)
59 {
60 EClass.pc.faction.SetGlobalPolicyActive(2705, a.active);
61 }
62 if (a.id == 2708)
63 {
64 EClass.pc.faction.SetGlobalPolicyActive(2708, a.active);
65 }
66 if (a.id == 2710)
67 {
68 EClass.pc.faction.SetGlobalPolicyActive(2710, a.active);
69 }
70 EClass.Branch.policies.RefreshEffects();
71 this.RefreshPolicyIcons();
72 });
73 b.refObj = a;
74 b.tooltip.onShowTooltip = delegate(UITooltip tp)
75 {
76 a.WriteNote(tp.note);
77 };
78 };
79 Func<Policy, bool> <>9__7;
80 callback.onList = delegate(UIList.SortMode m)
81 {
82 IEnumerable<Policy> list3 = EClass.Branch.policies.list;
83 Func<Policy, bool> predicate;
84 if ((predicate = <>9__7) == null)
85 {
86 predicate = (<>9__7 = ((Policy p) => p.source.categorySub == cat));
87 }
88 foreach (Policy o in list3.Where(predicate))
89 {
90 list.Add(o);
91 }
92 };
93 callback.onSort = ((Policy a, UIList.SortMode m) => a.GetSortVal(m));
94 callback.onRefresh = null;
95 list2.callbacks = callback;
96 list.List(false);
97 list.GetComponentInChildren<CanvasGroup>().alpha = ((list.items.Count > 0) ? 0.9f : 0.4f);
98 }
99
100 // Token: 0x060024FF RID: 9471 RVA: 0x000D164C File Offset: 0x000CF84C
101 public void RefreshPolicyIcons()
102 {
103 int num = EClass.Branch.policies.CurrentAP();
104 UIList[] array = new UIList[]
105 {
106 this.listPolicyLaw,
107 this.listPolicyLife,
108 this.listPolicyEconomy,
109 this.listUtility
110 };
111 for (int i = 0; i < array.Length; i++)
112 {
113 foreach (UIButton uibutton in array[i].GetComponentsInChildren<UIButton>())
114 {
115 Policy policy = uibutton.refObj as Policy;
116 uibutton.icon.material = (policy.active ? null : this.matGrayscale);
117 uibutton.imageCheck.SetActive(policy.active);
118 uibutton.subText.SetText(policy.Cost.ToString() ?? "", (num + policy.Cost <= EClass.Branch.MaxAP || policy.active) ? FontColor.Good : FontColor.Bad);
119 }
120 }
121 }
122
123 // Token: 0x06002501 RID: 9473 RVA: 0x000D1758 File Offset: 0x000CF958
124 [CompilerGenerated]
125 internal static bool <RefreshPolicyList>g__CanActivate|7_0(Policy p)
126 {
127 return (p.id != 2515 || !EClass.Branch.policies.IsActive(2516, -1)) && (p.id != 2516 || !EClass.Branch.policies.IsActive(2515, -1)) && (p.id != 2814 || !EClass.Branch.policies.IsActive(2823, -1)) && (p.id != 2823 || !EClass.Branch.policies.IsActive(2814, -1));
128 }
129
130 // Token: 0x04001487 RID: 5255
131 public UIList listPolicyLaw;
132
133 // Token: 0x04001488 RID: 5256
134 public UIList listPolicyEconomy;
135
136 // Token: 0x04001489 RID: 5257
137 public UIList listPolicyLife;
138
139 // Token: 0x0400148A RID: 5258
140 public UIList listUtility;
141
142 // Token: 0x0400148B RID: 5259
143 public Material matGrayscale;
144}