Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
SpatialManager.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using Newtonsoft.Json;
5
6public class SpatialManager : EClass
7{
8 public class GlobalSpatialList : Dictionary<int, Spatial>
9 {
10 public void Add(Spatial s)
11 {
12 Add(s.uid, s);
13 }
14 }
15
16 [JsonProperty]
18
19 [JsonProperty]
20 public int uidNext = 1;
21
22 [JsonProperty]
24
25 public List<Spatial> listDestryoed = new List<Spatial>();
26
27 public Zone Somewhere => Find("somewhere");
28
29 public List<Zone> Zones => map.Values.Where((Spatial a) => a is Zone).Cast<Zone>().ToList();
30
31 public void AssignUID(Spatial s)
32 {
33 s.uid = uidNext;
34 uidNext++;
35 map.Add(s);
36 }
37
38 public void Remove(Spatial s)
39 {
40 if (s.parent != null)
41 {
42 s.parent.children.Remove(s);
43 }
44 map.Remove(s.uid);
45 listDestryoed.Add(s);
46 }
47
48 public T Find<T>(Func<T, bool> func) where T : Zone
49 {
50 foreach (Spatial value in map.Values)
51 {
52 if (value is T val && func(val))
53 {
54 return val;
55 }
56 }
57 return null;
58 }
59
60 public Zone Find(string id)
61 {
62 foreach (Spatial value in map.Values)
63 {
64 if (value is Zone && value.id == id)
65 {
66 return value as Zone;
67 }
68 }
69 return null;
70 }
71
72 public Zone Find(int uid)
73 {
74 return map.TryGetValue(uid) as Zone;
75 }
76
77 public List<Zone> ListReturnLocations()
78 {
80 {
81 List<Zone> list = (from Zone a in map.Values.Where((Spatial a) => a is Zone)
82 where a != EClass._zone && (a.IsReturnLocation || a.IsPCFaction || (!(a is Zone_Field) && !a.IsInstance && !a.isRandomSite)) && a.parent == EClass.world.region && !a.source.tag.Contains("closed")
83 select a).ToList();
84 list.Sort((Zone a, Zone b) => a.GetSortVal() - b.GetSortVal());
85 return list;
86 }
87 List<Zone> list2 = (from Zone a in map.Values.Where((Spatial a) => a is Zone)
88 where a != EClass._zone && a.IsReturnLocation && a.GetTopZone().visitCount > 0 && (a.GetTopZone().FindDeepestZone() == a || EClass.pc.homeZone == a)
89 select a).ToList();
90 list2.Sort((Zone a, Zone b) => a.GetSortVal() - b.GetSortVal());
91 return list2;
92 }
93}
bool returnAnywhere
Definition: CoreDebug.cs:202
Definition: EClass.cs:5
static Zone _zone
Definition: EClass.cs:20
static World world
Definition: EClass.cs:40
static CoreDebug debug
Definition: EClass.cs:48
List< Zone > Zones
void AssignUID(Spatial s)
void Remove(Spatial s)
Zone Find(string id)
T Find< T >(Func< T, bool > func)
GlobalSpatialList map
List< Zone > ListReturnLocations()
Zone Find(int uid)
RankedZoneManager ranks
List< Spatial > listDestryoed
bool isRandomSite
Definition: Spatial.cs:334
int uid
Definition: Spatial.cs:70
Spatial parent
Definition: Spatial.cs:10
SourceZone.Row source
Definition: Spatial.cs:441
string id
Definition: Spatial.cs:13
Zone FindDeepestZone()
Definition: Spatial.cs:701
int visitCount
Definition: Spatial.cs:154
List< Spatial > children
Definition: Spatial.cs:37
Region region
Definition: World.cs:23
Definition: Zone.cs:12
int GetSortVal()
Definition: Zone.cs:2998