Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TraitDetector.cs
Go to the documentation of this file.
1public class TraitDetector : TraitItem
2{
3 public int interval;
4
5 public override bool IsTool => true;
6
7 public override bool CanStack => false;
8
9 public string term => owner.c_idRefName;
10
11 public override void TrySetHeldAct(ActPlan p)
12 {
13 if (p.IsSelf)
14 {
16 }
17 }
18
19 public override bool OnUse(Chara c)
20 {
21 Dialog.InputName("dialogDetector", term, delegate(bool cancel, string text)
22 {
23 if (!cancel)
24 {
25 owner.c_idRefName = text;
26 Search();
27 }
28 });
29 return false;
30 }
31
32 public override void OnHeld()
33 {
34 Search();
35 }
36
37 public override void OnTickHeld()
38 {
39 interval--;
40 if (interval <= 0)
41 {
42 Search();
43 }
44 }
45
46 public void Search()
47 {
48 if (term.IsEmpty())
49 {
50 return;
51 }
52 Card card = null;
53 int num = 999;
54 foreach (Thing thing in EClass._map.things)
55 {
56 int num2 = EClass.pc.Dist(thing);
57 if ((thing.id.ToLower().Contains(term.ToLower()) || thing.Name.ToLower().Contains(term.ToLower())) && num2 < num)
58 {
59 num = num2;
60 card = thing;
61 }
62 }
63 interval = 10;
64 if (card == null)
65 {
66 EClass.pc.PlaySound("detect_none");
67 }
68 else
69 {
70 EClass.pc.PlaySound("detect_" + ((num <= 1) ? "detected" : ((num < 5) ? "near" : ((num < 15) ? "medium" : ((num < 30) ? "far" : ((num < 50) ? "veryFar" : "superFar"))))));
71 interval = ((num <= 1) ? 1 : ((num < 5) ? 2 : ((num < 15) ? 4 : ((num < 30) ? 7 : 10))));
73 {
74 WidgetMainText.ignoreStack = true;
75 Msg.Say("beep".lang());
76 WidgetMainText.ignoreStack = false;
77 }
78 }
79 owner.PlayAnime(AnimeID.HitObj);
80 }
81
82 public override void SetName(ref string s)
83 {
84 if (!term.IsEmpty())
85 {
86 s = "_detect".lang(s, term);
87 }
88 }
89}
AnimeID
Definition: AnimeID.cs:2
bool IsSelf
Definition: ActPlan.cs:173
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
Definition: Card.cs:11
string id
Definition: Card.cs:31
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
string Name
Definition: Card.cs:2013
int Dist(Card c)
Definition: Card.cs:6777
string c_idRefName
Definition: Card.cs:1541
void PlayAnime(AnimeID id, bool force=false)
Definition: Card.cs:5423
Definition: Chara.cs:10
SoundSetting sound
Definition: CoreConfig.cs:590
CoreConfig config
Definition: Core.cs:70
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 Core core
Definition: EClass.cs:6
static Map _map
Definition: EClass.cs:18
static Chara pc
Definition: EClass.cs:14
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
Definition: Thing.cs:8
override void OnTickHeld()
override bool OnUse(Chara c)
override bool IsTool
Definition: TraitDetector.cs:5
override void OnHeld()
override void TrySetHeldAct(ActPlan p)
override void SetName(ref string s)
override bool CanStack
Definition: TraitDetector.cs:7
Card owner
Definition: Trait.cs:26
virtual string LangUse
Definition: Trait.cs:357