Elin Decompiled Documentation EA 23.321 Nightly Patch 1
Loading...
Searching...
No Matches
BaseArea.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using Newtonsoft.Json;
4using UnityEngine;
5
6public class BaseArea : EClass, IInspect
7{
8 public enum AccessType
9 {
10 Public,
13 }
14
15 public class Interaction
16 {
17 public string text;
18
19 public Action action;
20 }
21
22 [JsonProperty]
23 public int uid;
24
25 [JsonProperty]
26 public PointList points = new PointList();
27
28 [JsonProperty]
29 public AreaData data = new AreaData();
30
31 [JsonProperty]
32 public AreaType type = new AreaTypeRoom();
33
35
36 public virtual string Name
37 {
38 get
39 {
40 if (!data.name.IsEmpty())
41 {
42 return data.name;
43 }
44 return type.source.GetName();
45 }
46 }
47
48 public bool IsPrivate => data.accessType == AccessType.Private;
49
51
52 public bool CanInspect => true;
53
54 public string InspectName => Name;
55
57
58 public Vector3 InspectPosition => Vector3.zero;
59
61 {
62 for (int i = 0; i < 100; i++)
63 {
64 Point point = points.RandomItem();
65 if (!point.IsBlocked)
66 {
67 return point;
68 }
69 }
70 return null;
71 }
72
74 {
75 foreach (Point point in points)
76 {
77 foreach (Thing thing in point.Things)
78 {
79 if (thing.IsInstalled && !thing.pos.HasChara && thing.trait is TraitChair)
80 {
81 return thing;
82 }
83 }
84 }
85 return null;
86 }
87
88 public virtual Point GetRandomPoint(bool walkable = true, bool allowChara = true)
89 {
90 if (walkable)
91 {
92 for (int i = 0; i < 100; i++)
93 {
94 foreach (Point point in points)
95 {
96 if (!point.IsBlocked && (allowChara || !point.HasChara))
97 {
98 return point;
99 }
100 }
101 }
102 }
103 return points.RandomItem();
104 }
105
106 public void ChangeType(string _id)
107 {
108 type = ClassCache.Create<AreaType>("AreaType" + _id, "Elin");
109 type.id = _id;
110 type.owner = this;
111 if (plate != null)
112 {
113 plate.areaData.type = type;
114 }
115 }
116
117 public void SetRandomName(int seed = -1)
118 {
119 data.name = GetRandomName(seed);
120 }
121
122 public string GetRandomName(int seed = -1)
123 {
124 bool flag = seed != -1;
125 if (flag)
126 {
128 }
129 string combinedName = WordGen.GetCombinedName(EClass.Branch?.GetRandomName(), ListRoomNames().RandomItem(), room: true, flag);
130 if (flag)
131 {
132 Rand.SetSeed();
133 }
134 return combinedName;
135 }
136
137 public HashSet<string> ListRoomNames()
138 {
139 HashSet<string> hashSet = new HashSet<string>();
140 string[] list = Lang.GetList("rooms");
141 foreach (string item in list)
142 {
143 hashSet.Add(item);
144 }
145 foreach (Point point in points)
146 {
147 foreach (Thing thing in point.Things)
148 {
149 if (thing.IsInstalled && !thing.source.roomName.IsEmpty())
150 {
151 list = thing.source.GetTextArray("roomName");
152 foreach (string item2 in list)
153 {
154 hashSet.Add(item2);
155 }
156 }
157 }
158 }
159 return hashSet;
160 }
161
163 {
164 _ = 7;
165 return source._index;
166 }
167
168 public List<Interaction> ListInteractions()
169 {
170 return new List<Interaction>
171 {
172 new Interaction
173 {
174 text = "accessType".lang(("access_" + data.accessType).lang()),
175 action = delegate
176 {
177 UIContextMenu uIContextMenu = EClass.ui.CreateContextMenuInteraction();
178 foreach (AccessType t in Util.EnumToList<AccessType>())
179 {
180 uIContextMenu.AddButton(((data.accessType == t) ? "context_checker".lang() : "") + ("access_" + t).lang(), delegate
181 {
182 data.accessType = t;
183 if (plate != null)
184 {
185 plate.areaData.accessType = data.accessType;
186 }
187 SE.ClickOk();
188 });
189 }
190 CursorSystem.ignoreCount = 5;
191 uIContextMenu.Show();
192 }
193 },
194 new Interaction
195 {
196 text = "changeName",
197 action = delegate
198 {
199 Dialog.InputName("dialogChangeName", data.name.IsEmpty(GetRandomName()), delegate(bool cancel, string text)
200 {
201 if (!cancel)
202 {
203 data.name = text;
204 if (plate != null)
205 {
206 plate.areaData.name = text;
207 }
208 }
209 });
210 }
211 },
212 new Interaction
213 {
214 text = "toggleShowWallItem".lang() + "(" + (data.showWallItem ? "on" : "off").lang() + ")",
215 action = delegate
216 {
217 data.showWallItem = !data.showWallItem;
218 SE.ClickOk();
219 }
220 },
221 new Interaction
222 {
223 text = "toggleAtrium".lang() + "(" + (data.atrium ? "on" : "off").lang() + ")",
224 action = delegate
225 {
226 data.atrium = !data.atrium;
227 if (plate != null)
228 {
229 plate.areaData.atrium = data.atrium;
230 }
231 SE.ClickOk();
232 }
233 },
234 new Interaction
235 {
236 text = "limitRoomHeight",
237 action = delegate
238 {
239 List<string> list2 = new List<string>();
240 EClass.ui.AddLayer<LayerList>().SetStringList(delegate
241 {
242 list2.Clear();
243 for (int j = 1; j < 10; j++)
244 {
245 list2.Add(j.ToString() ?? "");
246 }
247 return list2;
248 }, delegate(int a, string b)
249 {
250 data.maxHeight = a + 1;
251 if (plate != null)
252 {
253 plate.areaData.maxHeight = a + 1;
254 }
256 });
257 }
258 },
259 new Interaction
260 {
261 text = "changeGroup",
262 action = delegate
263 {
264 List<string> list = new List<string>();
265 EClass.ui.AddLayer<LayerList>().SetStringList(delegate
266 {
267 list.Clear();
268 for (int i = 0; i < 5; i++)
269 {
270 list.Add(i.ToString() ?? "");
271 }
272 return list;
273 }, delegate(int a, string b)
274 {
275 data.group = a;
276 if (plate != null)
277 {
278 plate.areaData.group = a;
279 }
281 });
282 }
283 }
284 };
285 }
286
287 public void OnInspect()
288 {
289 }
290
291 public void WriteNote(UINote n, Action<UINote> onWriteNote = null, IInspect.NoteMode mode = IInspect.NoteMode.Default, Recipe recipe = null)
292 {
293 n.Clear();
294 n.AddHeaderCard(Name);
295 n.Build();
296 }
297}
@ seed
bool showWallItem
Definition: AreaData.cs:54
BaseArea.AccessType accessType
Definition: AreaData.cs:42
bool atrium
Definition: AreaData.cs:66
string name
Definition: AreaData.cs:7
SourceArea.Row source
Definition: AreaType.cs:29
AccessType
Definition: BaseArea.cs:9
bool CanInspect
Definition: BaseArea.cs:52
TraitRoomPlate plate
Definition: BaseArea.cs:34
AreaData data
Definition: BaseArea.cs:29
AreaType type
Definition: BaseArea.cs:32
void SetRandomName(int seed=-1)
Definition: BaseArea.cs:117
void WriteNote(UINote n, Action< UINote > onWriteNote=null, IInspect.NoteMode mode=IInspect.NoteMode.Default, Recipe recipe=null)
Definition: BaseArea.cs:291
void OnInspect()
Definition: BaseArea.cs:287
string InspectName
Definition: BaseArea.cs:54
List< Interaction > ListInteractions()
Definition: BaseArea.cs:168
int GetSortVal(UIList.SortMode m)
Definition: BaseArea.cs:162
void ChangeType(string _id)
Definition: BaseArea.cs:106
Vector3 InspectPosition
Definition: BaseArea.cs:58
virtual string Name
Definition: BaseArea.cs:37
SourceArea.Row source
Definition: BaseArea.cs:50
PointList points
Definition: BaseArea.cs:26
int uid
Definition: BaseArea.cs:23
bool IsPrivate
Definition: BaseArea.cs:48
string GetRandomName(int seed=-1)
Definition: BaseArea.cs:122
HashSet< string > ListRoomNames()
Definition: BaseArea.cs:137
Point GetRandomFreePos()
Definition: BaseArea.cs:60
Thing GetEmptySeat()
Definition: BaseArea.cs:73
virtual Point GetRandomPoint(bool walkable=true, bool allowChara=true)
Definition: BaseArea.cs:88
Point InspectPoint
Definition: BaseArea.cs:56
Point pos
Definition: Card.cs:60
Trait trait
Definition: Card.cs:54
bool IsInstalled
Definition: Card.cs:2451
Definition: Dialog.cs:7
static Dialog InputName(string langDetail, string text, Action< bool, string > onClose, InputType inputType=InputType.Default)
Definition: Dialog.cs:536
Definition: EClass.cs:6
static Map _map
Definition: EClass.cs:19
static FactionBranch Branch
Definition: EClass.cs:23
static UI ui
Definition: EClass.cs:17
string GetRandomName()
Definition: Lang.cs:7
static string[] GetList(string id)
Definition: Lang.cs:113
RoomManager rooms
Definition: Map.cs:31
Definition: Point.cs:9
static Point Invalid
Definition: Point.cs:28
bool IsBlocked
Definition: Point.cs:363
List< Thing > Things
Definition: Point.cs:338
bool HasChara
Definition: Point.cs:238
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:44
Definition: Recipe.cs:7
void RefreshAll()
Definition: RoomManager.cs:43
Definition: Thing.cs:8
SourceThing.Row source
Definition: Thing.cs:11
Definition: UIList.cs:9
SortMode
Definition: UIList.cs:27
Definition: UINote.cs:6
UIItem AddHeaderCard(string text, Sprite sprite=null)
Definition: UINote.cs:84
void Clear()
Definition: UINote.cs:35
void Build()
Definition: UINote.cs:49
NoteMode
Definition: IInspect.cs:7