Elin Decompiled Documentation EA 23.102 Nightly
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
ContentPopulation.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
6{
7 public class Topic
8 {
9 public string header;
10
11 public List<Chara> list = new List<Chara>();
12
13 public int color;
14
15 public int sortVal;
16 }
17
19
20 public static int queryTarget;
21
22 public static int queryType;
23
24 public Color[] colors;
25
26 public UIList list;
27
29
31
32 public Dictionary<string, Topic> topics;
33
34 public Func<Topic, UIList.SortMode, int> onSort;
35
36 public override void OnSwitchContent(int idTab)
37 {
38 Instance = this;
39 groupQueryTarget.Init(queryTarget, delegate(int a)
40 {
41 queryTarget = a;
42 Refresh();
43 });
44 groupQueryType.Init(queryType, delegate(int a)
45 {
46 queryType = a;
47 Refresh();
48 });
49 Refresh();
50 }
51
52 public void Refresh()
53 {
54 this.list.Clear();
55 this.list.callbacks = new UIList.Callback<Topic, ItemPopulation>
56 {
57 onInstantiate = delegate(Topic a, ItemPopulation b)
58 {
59 b.SetTopic(a);
60 },
62 };
63 onSort = (Topic t, UIList.SortMode m) => -this.list.items.IndexOf(t) + t.sortVal * 100;
64 topics = new Dictionary<string, Topic>();
66 switch (queryType)
67 {
68 case 0:
69 foreach (Chara item in list)
70 {
71 if (item.happiness > 70)
72 {
73 Add("happy".lang(), item, 1, 10);
74 }
75 else if (item.happiness > 30)
76 {
77 Add("normal".lang(), item, 0, 5);
78 }
79 else
80 {
81 Add("unhappy".lang(), item, 2);
82 }
83 }
84 break;
85 case 1:
86 foreach (Chara item2 in list)
87 {
88 Add("noJob".lang(), item2, 2);
89 }
90 break;
91 case 2:
92 foreach (Chara item3 in list)
93 {
94 Add("houseless".lang(), item3, 2);
95 }
96 break;
97 case 3:
98 foreach (Chara item4 in list)
99 {
100 Add(item4.faith.Name, item4);
101 }
102 onSort = (Topic t, UIList.SortMode m) => t.list.Count * 1000 - this.list.items.IndexOf(t);
103 break;
104 case 4:
105 foreach (Chara item5 in list)
106 {
107 Add("querySingle".lang(), item5, 2);
108 }
109 break;
110 default:
111 foreach (Chara item6 in list)
112 {
113 Add("test", item6);
114 }
115 break;
116 }
117 this.list.Refresh();
118 this.RebuildLayout(recursive: true);
119 }
120
121 public void Add(string idTopic, Chara c, int color = 1, int sortVal = 0)
122 {
123 Topic topic = topics.TryGetValue(idTopic);
124 if (topic == null)
125 {
126 topic = new Topic
127 {
128 header = idTopic,
129 color = color,
130 sortVal = sortVal
131 };
132 topics.Add(idTopic, topic);
133 list.Add(topic);
134 }
135 topic.list.Add(c);
136 }
137}
Definition: Chara.cs:10
Religion faith
Definition: Chara.cs:424
UISelectableGroup groupQueryType
static ContentPopulation Instance
Dictionary< string, Topic > topics
Func< Topic, UIList.SortMode, int > onSort
void Add(string idTopic, Chara c, int color=1, int sortVal=0)
UISelectableGroup groupQueryTarget
override void OnSwitchContent(int idTab)
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Faction Home
Definition: EClass.cs:26
static Map _map
Definition: EClass.cs:18
new Faction Wilds
FactionManager factions
Definition: Game.cs:161
void SetTopic(ContentPopulation.Topic t)
List< Chara > ListChara(Faction faction)
Definition: Map.cs:2484
string Name
Definition: Religion.cs:30
Definition: UIList.cs:9
List< object > items
Definition: UIList.cs:241
override void Clear()
Definition: UIList.cs:349
SortMode
Definition: UIList.cs:27
override void Add(object item)
Definition: UIList.cs:302
virtual void Init(int index=0, UnityAction< int > action=null, bool directChildren=false)