Elin Decompiled Documentation EA 23.102 Nightly
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 if (seed != -1)
125 {
127 }
128 string combinedName = WordGen.GetCombinedName(EClass.Branch?.GetRandomName(), ListRoomNames().RandomItem(), room: true);
129 if (seed != -1)
130 {
131 Rand.SetSeed();
132 }
133 return combinedName;
134 }
135
136 public HashSet<string> ListRoomNames()
137 {
138 HashSet<string> hashSet = new HashSet<string>();
139 string[] list = Lang.GetList("rooms");
140 foreach (string item in list)
141 {
142 hashSet.Add(item);
143 }
144 foreach (Point point in points)
145 {
146 foreach (Thing thing in point.Things)
147 {
148 if (thing.IsInstalled && !thing.source.roomName.IsEmpty())
149 {
150 list = thing.source.GetTextArray("roomName");
151 foreach (string item2 in list)
152 {
153 hashSet.Add(item2);
154 }
155 }
156 }
157 }
158 return hashSet;
159 }
160
162 {
163 _ = 7;
164 return source._index;
165 }
166
167 public List<Interaction> ListInteractions()
168 {
169 return new List<Interaction>
170 {
171 new Interaction
172 {
173 text = "accessType".lang(("access_" + data.accessType).lang()),
174 action = delegate
175 {
176 UIContextMenu uIContextMenu = EClass.ui.CreateContextMenuInteraction();
177 foreach (AccessType t in Util.EnumToList<AccessType>())
178 {
179 uIContextMenu.AddButton(((data.accessType == t) ? "context_checker".lang() : "") + ("access_" + t).lang(), delegate
180 {
181 data.accessType = t;
182 if (plate != null)
183 {
184 plate.areaData.accessType = data.accessType;
185 }
186 SE.ClickOk();
187 });
188 }
189 CursorSystem.ignoreCount = 5;
190 uIContextMenu.Show();
191 }
192 },
193 new Interaction
194 {
195 text = "changeName",
196 action = delegate
197 {
198 Dialog.InputName("dialogChangeName", data.name.IsEmpty(GetRandomName()), delegate(bool cancel, string text)
199 {
200 if (!cancel)
201 {
202 data.name = text;
203 if (plate != null)
204 {
205 plate.areaData.name = text;
206 }
207 }
208 });
209 }
210 },
211 new Interaction
212 {
213 text = "toggleShowWallItem".lang() + "(" + (data.showWallItem ? "on" : "off").lang() + ")",
214 action = delegate
215 {
216 data.showWallItem = !data.showWallItem;
217 SE.ClickOk();
218 }
219 },
220 new Interaction
221 {
222 text = "toggleAtrium".lang() + "(" + (data.atrium ? "on" : "off").lang() + ")",
223 action = delegate
224 {
225 data.atrium = !data.atrium;
226 if (plate != null)
227 {
228 plate.areaData.atrium = data.atrium;
229 }
230 SE.ClickOk();
231 }
232 },
233 new Interaction
234 {
235 text = "limitRoomHeight",
236 action = delegate
237 {
238 List<string> list2 = new List<string>();
239 EClass.ui.AddLayer<LayerList>().SetStringList(delegate
240 {
241 list2.Clear();
242 for (int j = 1; j < 10; j++)
243 {
244 list2.Add(j.ToString() ?? "");
245 }
246 return list2;
247 }, delegate(int a, string b)
248 {
249 data.maxHeight = a + 1;
250 if (plate != null)
251 {
252 plate.areaData.maxHeight = a + 1;
253 }
255 });
256 }
257 },
258 new Interaction
259 {
260 text = "changeGroup",
261 action = delegate
262 {
263 List<string> list = new List<string>();
264 EClass.ui.AddLayer<LayerList>().SetStringList(delegate
265 {
266 list.Clear();
267 for (int i = 0; i < 5; i++)
268 {
269 list.Add(i.ToString() ?? "");
270 }
271 return list;
272 }, delegate(int a, string b)
273 {
274 data.group = a;
275 if (plate != null)
276 {
277 plate.areaData.group = a;
278 }
280 });
281 }
282 }
283 };
284 }
285
286 public void OnInspect()
287 {
288 }
289
290 public void WriteNote(UINote n, Action<UINote> onWriteNote = null, IInspect.NoteMode mode = IInspect.NoteMode.Default, Recipe recipe = null)
291 {
292 n.Clear();
293 n.AddHeaderCard(Name);
294 n.Build();
295 }
296}
@ 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:290
void OnInspect()
Definition: BaseArea.cs:286
string InspectName
Definition: BaseArea.cs:54
List< Interaction > ListInteractions()
Definition: BaseArea.cs:167
int GetSortVal(UIList.SortMode m)
Definition: BaseArea.cs:161
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:136
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:55
Trait trait
Definition: Card.cs:49
bool IsInstalled
Definition: Card.cs:2241
Definition: Dialog.cs:7
static Dialog InputName(string langDetail, string text, Action< bool, string > onClose, InputType inputType=InputType.Default)
Definition: Dialog.cs:528
Definition: EClass.cs:5
static Map _map
Definition: EClass.cs:18
static FactionBranch Branch
Definition: EClass.cs:22
static UI ui
Definition: EClass.cs:16
string GetRandomName()
Definition: Lang.cs:6
static string[] GetList(string id)
Definition: Lang.cs:114
RoomManager rooms
Definition: Map.cs:31
Definition: Point.cs:9
static Point Invalid
Definition: Point.cs:28
bool IsBlocked
Definition: Point.cs:339
List< Thing > Things
Definition: Point.cs:314
bool HasChara
Definition: Point.cs:226
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:37
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