Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TriggersSet.cs
Go to the documentation of this file.
2using System.Linq;
4
5namespace Terraria.GameInput;
6
7public class TriggersSet
8{
10
12
13 public bool UsedMovementKey = true;
14
15 public int HotbarScrollCD;
16
17 public int HotbarHoldTime;
18
19 public bool MouseLeft
20 {
21 get
22 {
23 return KeyStatus["MouseLeft"];
24 }
25 set
26 {
27 KeyStatus["MouseLeft"] = value;
28 }
29 }
30
31 public bool MouseRight
32 {
33 get
34 {
35 return KeyStatus["MouseRight"];
36 }
37 set
38 {
39 KeyStatus["MouseRight"] = value;
40 }
41 }
42
43 public bool Up
44 {
45 get
46 {
47 return KeyStatus["Up"];
48 }
49 set
50 {
51 KeyStatus["Up"] = value;
52 }
53 }
54
55 public bool Down
56 {
57 get
58 {
59 return KeyStatus["Down"];
60 }
61 set
62 {
63 KeyStatus["Down"] = value;
64 }
65 }
66
67 public bool Left
68 {
69 get
70 {
71 return KeyStatus["Left"];
72 }
73 set
74 {
75 KeyStatus["Left"] = value;
76 }
77 }
78
79 public bool Right
80 {
81 get
82 {
83 return KeyStatus["Right"];
84 }
85 set
86 {
87 KeyStatus["Right"] = value;
88 }
89 }
90
91 public bool Jump
92 {
93 get
94 {
95 return KeyStatus["Jump"];
96 }
97 set
98 {
99 KeyStatus["Jump"] = value;
100 }
101 }
102
103 public bool Throw
104 {
105 get
106 {
107 return KeyStatus["Throw"];
108 }
109 set
110 {
111 KeyStatus["Throw"] = value;
112 }
113 }
114
115 public bool Inventory
116 {
117 get
118 {
119 return KeyStatus["Inventory"];
120 }
121 set
122 {
123 KeyStatus["Inventory"] = value;
124 }
125 }
126
127 public bool Grapple
128 {
129 get
130 {
131 return KeyStatus["Grapple"];
132 }
133 set
134 {
135 KeyStatus["Grapple"] = value;
136 }
137 }
138
139 public bool SmartSelect
140 {
141 get
142 {
143 return KeyStatus["SmartSelect"];
144 }
145 set
146 {
147 KeyStatus["SmartSelect"] = value;
148 }
149 }
150
151 public bool SmartCursor
152 {
153 get
154 {
155 return KeyStatus["SmartCursor"];
156 }
157 set
158 {
159 KeyStatus["SmartCursor"] = value;
160 }
161 }
162
163 public bool QuickMount
164 {
165 get
166 {
167 return KeyStatus["QuickMount"];
168 }
169 set
170 {
171 KeyStatus["QuickMount"] = value;
172 }
173 }
174
175 public bool QuickHeal
176 {
177 get
178 {
179 return KeyStatus["QuickHeal"];
180 }
181 set
182 {
183 KeyStatus["QuickHeal"] = value;
184 }
185 }
186
187 public bool QuickMana
188 {
189 get
190 {
191 return KeyStatus["QuickMana"];
192 }
193 set
194 {
195 KeyStatus["QuickMana"] = value;
196 }
197 }
198
199 public bool QuickBuff
200 {
201 get
202 {
203 return KeyStatus["QuickBuff"];
204 }
205 set
206 {
207 KeyStatus["QuickBuff"] = value;
208 }
209 }
210
211 public bool Loadout1
212 {
213 get
214 {
215 return KeyStatus["Loadout1"];
216 }
217 set
218 {
219 KeyStatus["Loadout1"] = value;
220 }
221 }
222
223 public bool Loadout2
224 {
225 get
226 {
227 return KeyStatus["Loadout2"];
228 }
229 set
230 {
231 KeyStatus["Loadout2"] = value;
232 }
233 }
234
235 public bool Loadout3
236 {
237 get
238 {
239 return KeyStatus["Loadout3"];
240 }
241 set
242 {
243 KeyStatus["Loadout3"] = value;
244 }
245 }
246
247 public bool MapZoomIn
248 {
249 get
250 {
251 return KeyStatus["MapZoomIn"];
252 }
253 set
254 {
255 KeyStatus["MapZoomIn"] = value;
256 }
257 }
258
259 public bool MapZoomOut
260 {
261 get
262 {
263 return KeyStatus["MapZoomOut"];
264 }
265 set
266 {
267 KeyStatus["MapZoomOut"] = value;
268 }
269 }
270
271 public bool MapAlphaUp
272 {
273 get
274 {
275 return KeyStatus["MapAlphaUp"];
276 }
277 set
278 {
279 KeyStatus["MapAlphaUp"] = value;
280 }
281 }
282
283 public bool MapAlphaDown
284 {
285 get
286 {
287 return KeyStatus["MapAlphaDown"];
288 }
289 set
290 {
291 KeyStatus["MapAlphaDown"] = value;
292 }
293 }
294
295 public bool MapFull
296 {
297 get
298 {
299 return KeyStatus["MapFull"];
300 }
301 set
302 {
303 KeyStatus["MapFull"] = value;
304 }
305 }
306
307 public bool MapStyle
308 {
309 get
310 {
311 return KeyStatus["MapStyle"];
312 }
313 set
314 {
315 KeyStatus["MapStyle"] = value;
316 }
317 }
318
319 public bool Hotbar1
320 {
321 get
322 {
323 return KeyStatus["Hotbar1"];
324 }
325 set
326 {
327 KeyStatus["Hotbar1"] = value;
328 }
329 }
330
331 public bool Hotbar2
332 {
333 get
334 {
335 return KeyStatus["Hotbar2"];
336 }
337 set
338 {
339 KeyStatus["Hotbar2"] = value;
340 }
341 }
342
343 public bool Hotbar3
344 {
345 get
346 {
347 return KeyStatus["Hotbar3"];
348 }
349 set
350 {
351 KeyStatus["Hotbar3"] = value;
352 }
353 }
354
355 public bool Hotbar4
356 {
357 get
358 {
359 return KeyStatus["Hotbar4"];
360 }
361 set
362 {
363 KeyStatus["Hotbar4"] = value;
364 }
365 }
366
367 public bool Hotbar5
368 {
369 get
370 {
371 return KeyStatus["Hotbar5"];
372 }
373 set
374 {
375 KeyStatus["Hotbar5"] = value;
376 }
377 }
378
379 public bool Hotbar6
380 {
381 get
382 {
383 return KeyStatus["Hotbar6"];
384 }
385 set
386 {
387 KeyStatus["Hotbar6"] = value;
388 }
389 }
390
391 public bool Hotbar7
392 {
393 get
394 {
395 return KeyStatus["Hotbar7"];
396 }
397 set
398 {
399 KeyStatus["Hotbar7"] = value;
400 }
401 }
402
403 public bool Hotbar8
404 {
405 get
406 {
407 return KeyStatus["Hotbar8"];
408 }
409 set
410 {
411 KeyStatus["Hotbar8"] = value;
412 }
413 }
414
415 public bool Hotbar9
416 {
417 get
418 {
419 return KeyStatus["Hotbar9"];
420 }
421 set
422 {
423 KeyStatus["Hotbar9"] = value;
424 }
425 }
426
427 public bool Hotbar10
428 {
429 get
430 {
431 return KeyStatus["Hotbar10"];
432 }
433 set
434 {
435 KeyStatus["Hotbar10"] = value;
436 }
437 }
438
439 public bool HotbarMinus
440 {
441 get
442 {
443 return KeyStatus["HotbarMinus"];
444 }
445 set
446 {
447 KeyStatus["HotbarMinus"] = value;
448 }
449 }
450
451 public bool HotbarPlus
452 {
453 get
454 {
455 return KeyStatus["HotbarPlus"];
456 }
457 set
458 {
459 KeyStatus["HotbarPlus"] = value;
460 }
461 }
462
463 public bool DpadRadial1
464 {
465 get
466 {
467 return KeyStatus["DpadRadial1"];
468 }
469 set
470 {
471 KeyStatus["DpadRadial1"] = value;
472 }
473 }
474
475 public bool DpadRadial2
476 {
477 get
478 {
479 return KeyStatus["DpadRadial2"];
480 }
481 set
482 {
483 KeyStatus["DpadRadial2"] = value;
484 }
485 }
486
487 public bool DpadRadial3
488 {
489 get
490 {
491 return KeyStatus["DpadRadial3"];
492 }
493 set
494 {
495 KeyStatus["DpadRadial3"] = value;
496 }
497 }
498
499 public bool DpadRadial4
500 {
501 get
502 {
503 return KeyStatus["DpadRadial4"];
504 }
505 set
506 {
507 KeyStatus["DpadRadial4"] = value;
508 }
509 }
510
511 public bool RadialHotbar
512 {
513 get
514 {
515 return KeyStatus["RadialHotbar"];
516 }
517 set
518 {
519 KeyStatus["RadialHotbar"] = value;
520 }
521 }
522
523 public bool RadialQuickbar
524 {
525 get
526 {
527 return KeyStatus["RadialQuickbar"];
528 }
529 set
530 {
531 KeyStatus["RadialQuickbar"] = value;
532 }
533 }
534
535 public bool DpadMouseSnap1
536 {
537 get
538 {
539 return KeyStatus["DpadSnap1"];
540 }
541 set
542 {
543 KeyStatus["DpadSnap1"] = value;
544 }
545 }
546
547 public bool DpadMouseSnap2
548 {
549 get
550 {
551 return KeyStatus["DpadSnap2"];
552 }
553 set
554 {
555 KeyStatus["DpadSnap2"] = value;
556 }
557 }
558
559 public bool DpadMouseSnap3
560 {
561 get
562 {
563 return KeyStatus["DpadSnap3"];
564 }
565 set
566 {
567 KeyStatus["DpadSnap3"] = value;
568 }
569 }
570
571 public bool DpadMouseSnap4
572 {
573 get
574 {
575 return KeyStatus["DpadSnap4"];
576 }
577 set
578 {
579 KeyStatus["DpadSnap4"] = value;
580 }
581 }
582
583 public bool MenuUp
584 {
585 get
586 {
587 return KeyStatus["MenuUp"];
588 }
589 set
590 {
591 KeyStatus["MenuUp"] = value;
592 }
593 }
594
595 public bool MenuDown
596 {
597 get
598 {
599 return KeyStatus["MenuDown"];
600 }
601 set
602 {
603 KeyStatus["MenuDown"] = value;
604 }
605 }
606
607 public bool MenuLeft
608 {
609 get
610 {
611 return KeyStatus["MenuLeft"];
612 }
613 set
614 {
615 KeyStatus["MenuLeft"] = value;
616 }
617 }
618
619 public bool MenuRight
620 {
621 get
622 {
623 return KeyStatus["MenuRight"];
624 }
625 set
626 {
627 KeyStatus["MenuRight"] = value;
628 }
629 }
630
631 public bool LockOn
632 {
633 get
634 {
635 return KeyStatus["LockOn"];
636 }
637 set
638 {
639 KeyStatus["LockOn"] = value;
640 }
641 }
642
643 public bool ViewZoomIn
644 {
645 get
646 {
647 return KeyStatus["ViewZoomIn"];
648 }
649 set
650 {
651 KeyStatus["ViewZoomIn"] = value;
652 }
653 }
654
655 public bool ViewZoomOut
656 {
657 get
658 {
659 return KeyStatus["ViewZoomOut"];
660 }
661 set
662 {
663 KeyStatus["ViewZoomOut"] = value;
664 }
665 }
666
668 {
669 get
670 {
671 return KeyStatus["ToggleCreativeMenu"];
672 }
673 set
674 {
675 KeyStatus["ToggleCreativeMenu"] = value;
676 }
677 }
678
680 {
681 get
682 {
683 return KeyStatus["ToggleCameraMode"];
684 }
685 set
686 {
687 KeyStatus["ToggleCameraMode"] = value;
688 }
689 }
690
691 public Vector2 DirectionsRaw => new Vector2(Right.ToInt() - Left.ToInt(), Down.ToInt() - Up.ToInt());
692
693 public void Reset()
694 {
695 string[] array = KeyStatus.Keys.ToArray();
696 for (int i = 0; i < array.Length; i++)
697 {
698 KeyStatus[array[i]] = false;
699 }
700 }
701
702 public void CloneFrom(TriggersSet other)
703 {
706 foreach (KeyValuePair<string, bool> item in other.KeyStatus)
707 {
708 KeyStatus.Add(item.Key, item.Value);
709 }
710 UsedMovementKey = other.UsedMovementKey;
711 HotbarScrollCD = other.HotbarScrollCD;
712 HotbarHoldTime = other.HotbarHoldTime;
713 }
714
715 public void SetupKeys()
716 {
718 foreach (string knownTrigger in PlayerInput.KnownTriggers)
719 {
720 KeyStatus.Add(knownTrigger, value: false);
721 }
722 }
723
725 {
726 bool flag = Main.gameMenu || Main.ingameOptionsWindow || Main.editChest || Main.editSign || ((Main.playerInventory || Main.LocalPlayer.talkNPC != -1) && PlayerInput.CurrentProfile.UsingDpadMovekeys());
727 bool value = Up || (flag && MenuUp);
728 bool value2 = Right || (flag && MenuRight);
729 bool value3 = Down || (flag && MenuDown);
730 bool value4 = Left || (flag && MenuLeft);
731 return new Vector2(value2.ToInt() - value4.ToInt(), value3.ToInt() - value.ToInt());
732 }
733
734 public void CopyInto(Player p)
735 {
737 {
738 p.controlUp = Up;
739 p.controlDown = Down;
740 p.controlLeft = Left;
741 p.controlRight = Right;
742 p.controlJump = Jump;
743 p.controlHook = Grapple;
744 p.controlTorch = SmartSelect;
745 p.controlSmart = SmartCursor;
746 p.controlMount = QuickMount;
747 p.controlQuickHeal = QuickHeal;
748 p.controlQuickMana = QuickMana;
749 p.controlCreativeMenu = OpenCreativePowersMenu;
750 if (QuickBuff)
751 {
752 p.QuickBuff();
753 }
754 if (Loadout1)
755 {
757 }
758 if (Loadout2)
759 {
761 }
762 if (Loadout3)
763 {
765 }
766 }
767 p.controlInv = Inventory;
768 p.controlThrow = Throw;
769 p.mapZoomIn = MapZoomIn;
770 p.mapZoomOut = MapZoomOut;
771 p.mapAlphaUp = MapAlphaUp;
772 p.mapAlphaDown = MapAlphaDown;
773 p.mapFullScreen = MapFull;
774 p.mapStyle = MapStyle;
775 if (MouseLeft)
776 {
777 if (!Main.blockMouse && !p.mouseInterface)
778 {
779 p.controlUseItem = true;
780 }
781 }
782 else
783 {
784 Main.blockMouse = false;
785 }
787 {
788 PlayerInput.LockGamepadTileUseButton = false;
789 }
791 {
792 p.controlUseTile = true;
793 }
795 {
796 p.controlInv = true;
797 }
798 if (SmartSelect && LatestInputMode.TryGetValue("SmartSelect", out var value) && IsInputFromGamepad(value))
799 {
801 }
802 bool flag = PlayerInput.Triggers.Current.HotbarPlus || PlayerInput.Triggers.Current.HotbarMinus;
803 if (flag)
804 {
806 }
807 else
808 {
809 HotbarHoldTime = 0;
810 }
811 if (HotbarScrollCD > 0 && (!(HotbarScrollCD == 1 && flag) || PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired <= 0))
812 {
814 }
815 }
816
818 {
819 if (MouseLeft)
820 {
821 if (!Main.blockMouse && !p.mouseInterface)
822 {
823 p.controlUseItem = true;
824 }
825 }
826 else
827 {
828 Main.blockMouse = false;
829 }
831 {
832 PlayerInput.LockGamepadTileUseButton = false;
833 }
835 {
836 p.controlUseTile = true;
837 }
838 bool flag = PlayerInput.Triggers.Current.HotbarPlus || PlayerInput.Triggers.Current.HotbarMinus;
839 if (flag)
840 {
842 }
843 else
844 {
845 HotbarHoldTime = 0;
846 }
847 if (HotbarScrollCD > 0 && (!(HotbarScrollCD == 1 && flag) || PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired <= 0))
848 {
850 }
851 }
852
853 private bool ShouldLockTileUsage()
854 {
856 {
858 }
859 return false;
860 }
861
862 private bool IsInputFromGamepad(InputMode mode)
863 {
864 if ((uint)mode <= 2u)
865 {
866 return false;
867 }
868 return true;
869 }
870}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
void Add(TKey key, TValue value)
static void SetCursorMode(CursorMode cursorMode)
static TriggersPack Triggers
static InputMode CurrentInputMode
static PlayerInputProfile CurrentProfile
static List< string > KnownTriggers
Dictionary< string, bool > KeyStatus
Definition TriggersSet.cs:9
Dictionary< string, InputMode > LatestInputMode
bool IsInputFromGamepad(InputMode mode)
void CloneFrom(TriggersSet other)
static bool blockMouse
Definition Main.cs:2521
static bool playerInventory
Definition Main.cs:1759
bool mouseInterface
Definition Player.cs:1137
void QuickBuff()
Definition Player.cs:4802
void TrySwitchingLoadout(int loadoutIndex)
Definition Player.cs:4778