Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TeleportManager.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using Newtonsoft.Json;
3
4public class TeleportManager : EClass
5{
6 public class Item : EClass
7 {
8 [JsonProperty]
9 public string id;
10
11 [JsonProperty]
12 public int uidZone;
13 }
14
15 [JsonProperty]
16 public Dictionary<int, Item> items = new Dictionary<int, Item>();
17
18 public void SetID(TraitTeleporter t, int uidZone)
19 {
20 string id = t.id;
21 int uid = t.owner.uid;
22 if (id.IsEmpty())
23 {
24 Remove(uid);
25 return;
26 }
27 Item item = items.TryGetValue(uid);
28 if (item == null)
29 {
30 item = new Item();
31 items.Add(uid, item);
32 }
33 item.uidZone = uidZone;
34 item.id = id;
35 }
36
38 {
39 string id = t.id;
40 int uid = t.owner.uid;
41 if (id.IsEmpty())
42 {
43 return null;
44 }
45 List<Zone> list = new List<Zone>();
46 foreach (KeyValuePair<int, Item> item in items)
47 {
48 if (item.Key != uid && item.Value.id == id)
49 {
50 Zone zone = EClass.game.spatials.Find(item.Value.uidZone);
51 if (zone != null && zone != EClass._zone)
52 {
53 list.Add(zone);
54 }
55 }
56 }
57 return list.RandomItem();
58 }
59
60 public void Remove(int uidThing)
61 {
62 items.Remove(uidThing);
63 }
64}
int uid
Definition: Card.cs:118
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Zone _zone
Definition: EClass.cs:20
SpatialManager spatials
Definition: Game.cs:152
Zone Find(string id)
void SetID(TraitTeleporter t, int uidZone)
Zone GetTeleportZone(TraitTeleporter t)
void Remove(int uidThing)
Dictionary< int, Item > items
Card owner
Definition: Trait.cs:26
Definition: Zone.cs:12