Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TraitTeleporter.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2
4{
5 public int teleportedTurn;
6
7 public string id
8 {
9 get
10 {
11 return owner.GetStr(31);
12 }
13 set
14 {
15 owner.SetStr(31, value);
16 }
17 }
18
20
21 public override string langOnUse => "actUse";
22
23 public override bool IsTeleport => true;
24
25 public override bool CanBeHeld => true;
26
27 public override bool CanBeOnlyBuiltInHome => true;
28
29 public override void TrySetAct(ActPlan p)
30 {
31 base.TrySetAct(p);
32 if (p.input != ActInput.AllAction || (!EClass.debug.enable && owner.isNPCProperty))
33 {
34 return;
35 }
36 p.TrySetAct("actSetTeleporterID", delegate
37 {
38 Dialog.InputName("dialogTeleportId", id.IsEmpty(""), delegate(bool cancel, string text)
39 {
40 if (!cancel)
41 {
42 id = text;
44 }
45 });
46 return false;
47 }, owner);
48 }
49
50 public override void OnChangePlaceState(PlaceState state)
51 {
52 if (state == PlaceState.installed)
53 {
55 }
56 else
57 {
59 }
60 }
61
62 public override bool TryTeleport()
63 {
64 if (id.IsEmpty() && !GetParam(1).IsEmpty())
65 {
66 return false;
67 }
69 {
71 return true;
72 }
73 List<TraitTeleporter> list = new List<TraitTeleporter>();
74 foreach (Thing thing in EClass._map.things)
75 {
76 if (thing.trait is TraitTeleporter traitTeleporter && traitTeleporter != this && traitTeleporter.owner.IsInstalled && traitTeleporter.owner.pos.IsInBounds && traitTeleporter.IsOn && traitTeleporter.id == id && traitTeleporter != this)
77 {
78 list.Add(traitTeleporter);
79 }
80 }
81 if (list.Count > 0)
82 {
83 TraitTeleporter traitTeleporter2 = list.RandomItem();
84 traitTeleporter2.teleportedTurn = EClass.pc.turn;
85 EClass.pc.Teleport(traitTeleporter2.owner.pos, silent: false, force: true);
86 return true;
87 }
89 if (zone is Zone_Tent || EClass._zone is Zone_Tent)
90 {
91 zone = null;
92 }
93 if (zone != null)
94 {
96 {
97 Msg.Say("noNetwork");
98 return false;
99 }
101 {
102 bool flag = true;
103 foreach (Quest item in EClass.game.quests.list)
104 {
105 if (item.ForbidTeleport)
106 {
107 flag = false;
108 }
109 }
110 if (!flag)
111 {
112 Msg.Say("hasInvalidQuest");
113 return false;
114 }
115 }
117 {
118 state = enterState,
119 idTele = id.IsEmpty(GetParam(3))
120 });
121 return true;
122 }
123 return false;
124 }
125
126 public override void SetName(ref string s)
127 {
128 if (!id.IsEmpty())
129 {
130 s = "_engraved".lang(id, s);
131 }
132 }
133}
ActInput
Definition: ActInput.cs:2
PlaceState
Definition: PlaceState.cs:2
ActInput input
Definition: ActPlan.cs:151
bool TrySetAct(string lang, Func< bool > onPerform, Card tc, CursorInfo cursor=null, int dist=1, bool isHostileAct=false, bool localAct=true, bool canRepeat=false)
Definition: ActPlan.cs:344
void SetStr(int id, string value=null)
Definition: BaseCard.cs:63
string GetStr(int id, string defaultStr=null)
Definition: BaseCard.cs:54
void Teleport(Point point, bool silent=false, bool force=false)
Definition: Card.cs:5153
bool isNPCProperty
Definition: Card.cs:526
Point pos
Definition: Card.cs:55
int uid
Definition: Card.cs:118
Trait trait
Definition: Card.cs:49
bool IsInstalled
Definition: Card.cs:2241
int turn
Definition: Card.cs:61
void MoveZone(string alias)
Definition: Chara.cs:3010
bool enable
Definition: CoreDebug.cs:285
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 Game game
Definition: EClass.cs:8
static Zone _zone
Definition: EClass.cs:20
static Map _map
Definition: EClass.cs:18
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
TeleportManager teleports
Definition: Game.cs:194
QuestManager quests
Definition: Game.cs:179
List< Thing > things
Definition: Map.cs:49
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
List< Quest > list
Definition: QuestManager.cs:11
Definition: Quest.cs:7
int uid
Definition: Spatial.cs:70
void SetID(TraitTeleporter t, int uidZone)
Zone GetTeleportZone(TraitTeleporter t)
void Remove(int uidThing)
Definition: Thing.cs:8
override bool IsTeleport
override void SetName(ref string s)
override bool TryTeleport()
override void OnChangePlaceState(PlaceState state)
override void TrySetAct(ActPlan p)
override ZoneTransition.EnterState enterState
override string langOnUse
override bool CanBeOnlyBuiltInHome
override bool CanBeHeld
string GetParam(int i, string def=null)
Definition: Trait.cs:515
Card owner
Definition: Trait.cs:26
Definition: Zone.cs:12
FactionBranch branch
Definition: Zone.cs:34
bool IsPCFaction
Definition: Zone.cs:464